1 |
francois |
283 |
//--------------------------------------------------------------------------- |
2 |
|
|
//------------------------------------------------------------ |
3 |
|
|
//------------------------------------------------------------ |
4 |
|
|
// MAGiC |
5 |
|
|
// Jean Christophe Cuilli�re et Vincent FRANCOIS |
6 |
|
|
// D�partement de G�nie M�canique - UQTR |
7 |
|
|
//------------------------------------------------------------ |
8 |
|
|
// Le projet MAGIC est un projet de recherche du d�partement |
9 |
|
|
// de g�nie m�canique de l'Universit� du Qu�bec � |
10 |
|
|
// Trois Rivi�res |
11 |
|
|
// Les librairies ne peuvent �tre utilis�es sans l'accord |
12 |
|
|
// des auteurs (contact : francois@uqtr.ca) |
13 |
|
|
//------------------------------------------------------------ |
14 |
|
|
//------------------------------------------------------------ |
15 |
|
|
// |
16 |
|
|
// OCC_Surface.cpp |
17 |
|
|
// |
18 |
|
|
//------------------------------------------------------------ |
19 |
|
|
//------------------------------------------------------------ |
20 |
|
|
// COPYRIGHT 2000 |
21 |
|
|
// Version du 02/03/2006 � 11H22 |
22 |
|
|
//------------------------------------------------------------ |
23 |
|
|
//------------------------------------------------------------ |
24 |
|
|
|
25 |
|
|
#pragma hdrstop |
26 |
|
|
#include "gestionversion.h" |
27 |
|
|
#ifdef BREP_OCC |
28 |
|
|
|
29 |
|
|
#include "occ_surface.h" |
30 |
|
|
#include <gp_Pnt.hxx> |
31 |
|
|
#include <gp_Vec.hxx> |
32 |
|
|
#include "GeomAPI_ProjectPointOnSurf.hxx" |
33 |
|
|
#include <ShapeAnalysis_Surface.hxx> |
34 |
|
|
#include <BRep_Tool.hxx> |
35 |
|
|
#include <BRepAdaptor_Surface.hxx> |
36 |
|
|
//*********************************** |
37 |
|
|
#include <BRep_Tool.hxx> |
38 |
|
|
#include <Poly_Triangulation.hxx> |
39 |
|
|
#include <Geom_Plane.hxx> |
40 |
|
|
#include <gp_Pln.hxx> |
41 |
|
|
#include <Geom_CylindricalSurface.hxx> |
42 |
|
|
#include <gp_Cylinder.hxx> |
43 |
|
|
#include <Geom_ConicalSurface.hxx> |
44 |
|
|
#include <gp_Cone.hxx> |
45 |
|
|
#include <Geom_SphericalSurface.hxx> |
46 |
|
|
#include <gp_Sphere.hxx> |
47 |
|
|
#include "Geom_ToroidalSurface.hxx" |
48 |
|
|
#include <gp_Torus.hxx> |
49 |
|
|
#include <Geom_BSplineSurface.hxx> |
50 |
|
|
#include <Geom_BezierSurface.hxx> |
51 |
|
|
#include <GeomConvert.hxx> |
52 |
|
|
#include <BRepBuilderAPI_NurbsConvert.hxx> |
53 |
|
|
#include <BRepLib_FindSurface.hxx> |
54 |
|
|
#include "mg_gestionnaire.h" |
55 |
|
|
#include "constantegeo.h" |
56 |
francois |
295 |
#include "ot_mathematique.h" |
57 |
francois |
283 |
|
58 |
|
|
#pragma package(smart_init) |
59 |
|
|
OCC_SURFACE::OCC_SURFACE(unsigned long num, TopoDS_Face srf, OCC_FONCTION1& fonc):MG_SURFACE(num),face(srf), fonction1(fonc) |
60 |
|
|
{ |
61 |
|
|
|
62 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
63 |
|
|
double u1; |
64 |
|
|
double u2; |
65 |
|
|
double v1; |
66 |
|
|
double v2; |
67 |
|
|
surface->Bounds(u1,u2,v1, v2); |
68 |
|
|
u_min=u1; |
69 |
|
|
u_max=u2; |
70 |
|
|
v_min=v1; |
71 |
|
|
v_max=v2; |
72 |
|
|
|
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
OCC_SURFACE::OCC_SURFACE(TopoDS_Face srf, OCC_FONCTION1& fonc):MG_SURFACE(),face(srf), fonction1(fonc) |
76 |
|
|
{ |
77 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
78 |
|
|
double u1; |
79 |
|
|
double u2; |
80 |
|
|
double v1; |
81 |
|
|
double v2; |
82 |
|
|
surface->Bounds(u1,u2,v1, v2); |
83 |
|
|
u_min=u1; |
84 |
|
|
u_max=u2; |
85 |
|
|
v_min=v1; |
86 |
|
|
v_max=v2; |
87 |
|
|
} |
88 |
|
|
|
89 |
|
|
OCC_SURFACE::OCC_SURFACE(OCC_SURFACE& mdd):MG_SURFACE(mdd),face(mdd.face), fonction1(mdd.fonction1) |
90 |
|
|
{ |
91 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
92 |
|
|
u_min=mdd.get_umin(); |
93 |
|
|
u_max=mdd.get_umax(); |
94 |
|
|
v_min=mdd.get_vmin(); |
95 |
|
|
v_max=mdd.get_vmax(); |
96 |
|
|
|
97 |
|
|
} |
98 |
|
|
OCC_SURFACE::~OCC_SURFACE() |
99 |
|
|
{ |
100 |
|
|
} |
101 |
|
|
void OCC_SURFACE::evaluer(double *uv,double *xyz) |
102 |
|
|
{ |
103 |
|
|
|
104 |
|
|
const Handle(Geom_Surface) &surface=BRep_Tool::Surface(face); |
105 |
|
|
gp_Pnt P; |
106 |
|
|
double u=uv[0]; |
107 |
|
|
double v=uv[1]; |
108 |
|
|
|
109 |
|
|
surface->D0(u,v,P); |
110 |
|
|
|
111 |
|
|
xyz[0]=P.X(); |
112 |
|
|
xyz[1]=P.Y(); |
113 |
|
|
xyz[2]=P.Z(); |
114 |
|
|
} |
115 |
|
|
void OCC_SURFACE::deriver(double *uv,double *xyzdu, double *xyzdv) |
116 |
|
|
{ |
117 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
118 |
|
|
double u=uv[0]; |
119 |
|
|
double v=uv[1]; |
120 |
|
|
gp_Vec D1U; |
121 |
|
|
gp_Vec D1V; |
122 |
|
|
gp_Pnt P; |
123 |
|
|
|
124 |
|
|
surface->D1(u,v,P,D1U,D1V); |
125 |
|
|
xyzdu[0]=D1U.X(); |
126 |
|
|
xyzdu[1]=D1U.Y(); |
127 |
|
|
xyzdu[2]=D1U.Z(); |
128 |
|
|
|
129 |
|
|
xyzdv[0]=D1V.X(); |
130 |
|
|
xyzdv[1]=D1V.Y(); |
131 |
|
|
xyzdv[2]=D1V.Z(); |
132 |
|
|
|
133 |
|
|
} |
134 |
|
|
void OCC_SURFACE::deriver_seconde(double *uv,double* xyzduu,double* xyzduv,double* xyzdvv,double *xyz, double *xyzdu, double *xyzdv) |
135 |
|
|
{ |
136 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
137 |
|
|
double u=uv[0]; |
138 |
|
|
double v=uv[1]; |
139 |
|
|
gp_Pnt P; |
140 |
|
|
gp_Vec D1U; |
141 |
|
|
gp_Vec D1V; |
142 |
|
|
gp_Vec D2U; |
143 |
|
|
gp_Vec D2V; |
144 |
|
|
gp_Vec D2UV; |
145 |
|
|
|
146 |
|
|
surface->D2(u,v,P,D1U,D1V,D2U,D2V,D2UV); |
147 |
|
|
|
148 |
|
|
xyz[0]=P.X(); |
149 |
|
|
xyz[1]=P.Y(); |
150 |
|
|
xyz[2]=P.Z(); |
151 |
|
|
|
152 |
|
|
xyzdu[0]=D1U.X(); |
153 |
|
|
xyzdu[1]=D1U.Y(); |
154 |
|
|
xyzdu[2]=D1U.Z(); |
155 |
|
|
|
156 |
|
|
xyzdv[0]=D1V.X(); |
157 |
|
|
xyzdv[1]=D1V.Y(); |
158 |
|
|
xyzdv[2]=D1V.Z(); |
159 |
|
|
|
160 |
|
|
xyzduu[0]=D2U.X(); |
161 |
|
|
xyzduu[1]=D2U.Y(); |
162 |
|
|
xyzduu[2]=D2U.Z(); |
163 |
|
|
|
164 |
|
|
xyzdvv[0]=D2V.X(); |
165 |
|
|
xyzdvv[1]=D2V.Y(); |
166 |
|
|
xyzdvv[2]=D2V.Z(); |
167 |
|
|
|
168 |
|
|
xyzduv[0]=D2UV.X(); |
169 |
|
|
xyzduv[1]=D2UV.Y(); |
170 |
|
|
xyzduv[2]=D2UV.Z(); |
171 |
|
|
|
172 |
|
|
} |
173 |
|
|
|
174 |
|
|
void OCC_SURFACE::inverser(double *uv,double *xyz,double precision) |
175 |
|
|
{ |
176 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
177 |
|
|
double u=xyz[0]; |
178 |
|
|
double v=xyz[1]; |
179 |
|
|
double w=xyz[2]; |
180 |
|
|
gp_Pnt P(u,v,w); |
181 |
|
|
|
182 |
|
|
//ShapeAnalysis_Surface SAS(surface); |
183 |
|
|
//gp_Pnt2d pnt2d=SAS.ValueOfUV(P, precision); |
184 |
|
|
GeomAPI_ProjectPointOnSurf PPS(P,surface, precision); |
185 |
francois |
339 |
if (PPS.NbPoints() < 1) |
186 |
|
|
{ |
187 |
|
|
uv[0]=1e308; |
188 |
|
|
uv[1]=1e308; |
189 |
|
|
return; |
190 |
|
|
} |
191 |
francois |
283 |
//PPS.Perform(P); |
192 |
|
|
double UU, VV; |
193 |
|
|
PPS.LowerDistanceParameters(UU,VV); |
194 |
|
|
uv[0]=UU; |
195 |
|
|
uv[1]=VV; |
196 |
|
|
} |
197 |
|
|
int OCC_SURFACE::est_periodique_u(void) |
198 |
|
|
{ |
199 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
200 |
|
|
return surface->IsUClosed(); |
201 |
|
|
} |
202 |
|
|
|
203 |
|
|
int OCC_SURFACE::est_periodique_v(void) |
204 |
|
|
{ |
205 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
206 |
|
|
return surface->IsVPeriodic(); |
207 |
|
|
} |
208 |
|
|
double OCC_SURFACE::get_periode_u(void) |
209 |
|
|
{ |
210 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
211 |
|
|
if (surface->IsUPeriodic()==0) return 0.; |
212 |
|
|
return surface->UPeriod(); |
213 |
|
|
} |
214 |
|
|
|
215 |
|
|
double OCC_SURFACE::get_periode_v(void) |
216 |
|
|
{ |
217 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
218 |
|
|
if (surface->IsVPeriodic()==0) return 0.; |
219 |
|
|
return surface->VPeriod(); |
220 |
|
|
} |
221 |
|
|
void OCC_SURFACE::enregistrer(std::ostream& o) |
222 |
|
|
{ |
223 |
|
|
o <<"%"<<get_id()<< "=SURFACE_OCC("<< fonction1.GetID(face)<< ");" << std::endl; |
224 |
|
|
} |
225 |
|
|
int OCC_SURFACE::get_type_geometrique(TPL_LISTE_ENTITE<double> ¶m) |
226 |
|
|
{ |
227 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
228 |
|
|
Handle(Standard_Type) type=surface->DynamicType(); |
229 |
|
|
//******plan |
230 |
|
|
if (type==STANDARD_TYPE(Geom_Plane)) |
231 |
|
|
{ |
232 |
|
|
Handle(Geom_Plane) Pln=Handle(Geom_Plane)::DownCast(surface); |
233 |
|
|
gp_Pln plan=Pln->Pln(); |
234 |
|
|
|
235 |
|
|
double origine[3]; |
236 |
|
|
gp_Pnt centre=plan.Location(); |
237 |
|
|
|
238 |
|
|
origine[0]=centre.X(); |
239 |
|
|
origine[1]=centre.Y(); |
240 |
|
|
origine[2]=centre.Z(); |
241 |
|
|
|
242 |
|
|
double normal[3]; |
243 |
|
|
gp_Ax1 axe=plan.Axis(); |
244 |
|
|
gp_Dir direction=axe.Direction(); |
245 |
|
|
|
246 |
|
|
normal[0]=direction.X(); |
247 |
|
|
normal[1]=direction.Y(); |
248 |
|
|
normal[2]=direction.Z(); |
249 |
|
|
|
250 |
|
|
param.ajouter(origine[0]); |
251 |
|
|
param.ajouter(origine[1]); |
252 |
|
|
param.ajouter(origine[2]); |
253 |
|
|
param.ajouter(normal[0]); |
254 |
|
|
param.ajouter(normal[1]); |
255 |
|
|
param.ajouter(normal[2]); |
256 |
|
|
|
257 |
|
|
return MGCo_PLAN; |
258 |
|
|
} |
259 |
|
|
//******cylindre |
260 |
|
|
if (type==STANDARD_TYPE(Geom_CylindricalSurface)) |
261 |
|
|
{ |
262 |
|
|
Handle(Geom_CylindricalSurface) cylinder=Handle(Geom_CylindricalSurface)::DownCast(surface); |
263 |
|
|
gp_Cylinder cylin=cylinder->Cylinder(); |
264 |
|
|
|
265 |
|
|
double origine[3]; |
266 |
|
|
gp_Pnt centre=cylin.Location(); |
267 |
|
|
origine[0]=centre.X(); |
268 |
|
|
origine[1]=centre.Y(); |
269 |
|
|
origine[2]=centre.Z(); |
270 |
|
|
double direction[3]; |
271 |
|
|
gp_Ax1 axe=cylin.Axis(); |
272 |
|
|
gp_Dir dir=axe.Direction(); |
273 |
|
|
direction[0]=dir.X(); |
274 |
|
|
direction[1]=dir.Y(); |
275 |
|
|
direction[2]=dir.Z(); |
276 |
|
|
double rayon; |
277 |
|
|
rayon=cylin.Radius(); |
278 |
|
|
|
279 |
|
|
param.ajouter(origine[0]); |
280 |
|
|
param.ajouter(origine[1]); |
281 |
|
|
param.ajouter(origine[2]); |
282 |
|
|
param.ajouter(direction[0]); |
283 |
|
|
param.ajouter(direction[1]); |
284 |
|
|
param.ajouter(direction[2]); |
285 |
|
|
param.ajouter(rayon); |
286 |
|
|
|
287 |
|
|
return MGCo_CYLINDRE; |
288 |
|
|
} |
289 |
|
|
//******Cone |
290 |
|
|
if (type==STANDARD_TYPE(Geom_ConicalSurface)) |
291 |
|
|
{ |
292 |
|
|
Handle(Geom_ConicalSurface) cone=Handle(Geom_ConicalSurface)::DownCast(surface); |
293 |
|
|
gp_Cone con=cone->Cone(); |
294 |
|
|
|
295 |
|
|
double origine[3]; |
296 |
|
|
gp_Pnt centre=con.Location(); |
297 |
|
|
origine[0]=centre.X(); |
298 |
|
|
origine[1]=centre.Y(); |
299 |
|
|
origine[2]=centre.Z(); |
300 |
|
|
double direction[3]; |
301 |
|
|
gp_Ax1 axe=con.Axis(); |
302 |
|
|
gp_Dir dir=axe.Direction(); |
303 |
|
|
direction[0]=dir.X(); |
304 |
|
|
direction[1]=dir.Y(); |
305 |
|
|
direction[2]=dir.Z(); |
306 |
|
|
double rayon; |
307 |
|
|
rayon=con.RefRadius(); |
308 |
|
|
double angle; |
309 |
|
|
angle=con.SemiAngle(); |
310 |
|
|
|
311 |
|
|
param.ajouter(origine[0]); |
312 |
|
|
param.ajouter(origine[1]); |
313 |
|
|
param.ajouter(origine[2]); |
314 |
|
|
param.ajouter(direction[0]); |
315 |
|
|
param.ajouter(direction[1]); |
316 |
|
|
param.ajouter(direction[2]); |
317 |
|
|
param.ajouter(rayon); |
318 |
|
|
param.ajouter(angle); |
319 |
|
|
|
320 |
|
|
return MGCo_CONE; |
321 |
|
|
|
322 |
|
|
} |
323 |
|
|
//*****Sphere |
324 |
|
|
if (type==STANDARD_TYPE(Geom_SphericalSurface)) |
325 |
|
|
{ |
326 |
|
|
Handle(Geom_SphericalSurface) sphere=Handle(Geom_SphericalSurface)::DownCast(surface); |
327 |
|
|
gp_Sphere sph=sphere->Sphere(); |
328 |
|
|
|
329 |
|
|
double origine[3]; |
330 |
|
|
gp_Pnt centre=sph.Location(); |
331 |
|
|
origine[0]=centre.X(); |
332 |
|
|
origine[1]=centre.Y(); |
333 |
|
|
origine[2]=centre.Z(); |
334 |
|
|
double rayon; |
335 |
|
|
rayon=sph.Radius(); |
336 |
|
|
param.ajouter(origine[0]); |
337 |
|
|
param.ajouter(origine[1]); |
338 |
|
|
param.ajouter(origine[2]); |
339 |
|
|
param.ajouter(rayon); |
340 |
|
|
|
341 |
|
|
return MGCo_SPHERE; |
342 |
|
|
|
343 |
|
|
} |
344 |
|
|
//****** Tore |
345 |
|
|
if (type==STANDARD_TYPE(Geom_ToroidalSurface)) |
346 |
|
|
{ |
347 |
|
|
Handle(Geom_ToroidalSurface) tore=Handle(Geom_ToroidalSurface)::DownCast(surface); |
348 |
|
|
gp_Torus tro=tore->Torus(); |
349 |
|
|
double origine[3]; |
350 |
|
|
gp_Pnt centre=tro.Location(); |
351 |
|
|
origine[0]=centre.X(); |
352 |
|
|
origine[1]=centre.Y(); |
353 |
|
|
origine[2]=centre.Z(); |
354 |
|
|
double direction[3]; |
355 |
|
|
gp_Ax1 axe=tro.Axis(); |
356 |
|
|
gp_Dir dir=axe.Direction(); |
357 |
|
|
direction[0]=dir.X(); |
358 |
|
|
direction[1]=dir.Y(); |
359 |
|
|
direction[2]=dir.Z(); |
360 |
|
|
double Grayon; |
361 |
|
|
Grayon=tro.MajorRadius(); |
362 |
|
|
double Prayon; |
363 |
|
|
Prayon=tro.MinorRadius(); |
364 |
|
|
|
365 |
|
|
param.ajouter(origine[0]); |
366 |
|
|
param.ajouter(origine[1]); |
367 |
|
|
param.ajouter(origine[2]); |
368 |
|
|
param.ajouter(direction[0]); |
369 |
|
|
param.ajouter(direction[1]); |
370 |
|
|
param.ajouter(direction[2]); |
371 |
|
|
param.ajouter(Grayon); |
372 |
|
|
param.ajouter(Prayon); |
373 |
|
|
|
374 |
|
|
return MGCo_TORE; |
375 |
|
|
|
376 |
|
|
} |
377 |
|
|
//*******BSpline |
378 |
|
|
if (type==STANDARD_TYPE(Geom_BSplineSurface)) |
379 |
|
|
{ |
380 |
|
|
Handle(Geom_BSplineSurface) bspline=Handle(Geom_BSplineSurface)::DownCast(surface); |
381 |
|
|
|
382 |
|
|
//nombre des noeuds suivant Udirection |
383 |
|
|
int nb_Uknot=bspline->NbUKnots(); |
384 |
|
|
//valeur de Unoeud |
385 |
|
|
for (int i=1; i<=nb_Uknot; i++) |
386 |
|
|
{ |
387 |
|
|
double Uvaleur=bspline->UKnot(i); |
388 |
|
|
param.ajouter(Uvaleur); |
389 |
|
|
} |
390 |
|
|
//nombre des noeuds suivants Vdirection |
391 |
|
|
int nb_Vknot=bspline->NbVKnots(); |
392 |
|
|
//valeur de Vnoeud |
393 |
|
|
for (int j=1; j<=nb_Vknot; j++) |
394 |
|
|
{ |
395 |
|
|
double Vvaleur=bspline->VKnot(j); |
396 |
|
|
param.ajouter(Vvaleur); |
397 |
|
|
} |
398 |
|
|
//point de controle et poids |
399 |
|
|
gp_Pnt pctr; |
400 |
|
|
double poids; |
401 |
|
|
for (int u=1; u<=bspline->NbUPoles(); u++) |
402 |
|
|
for (int v=1; v<=bspline->NbVPoles(); v++) |
403 |
|
|
{ |
404 |
|
|
pctr=bspline->Pole(u, v); |
405 |
|
|
|
406 |
|
|
param.ajouter(pctr.X()); |
407 |
|
|
param.ajouter(pctr.Y()); |
408 |
|
|
param.ajouter(pctr.Z()); |
409 |
|
|
|
410 |
|
|
poids=bspline->Weight(u, v); |
411 |
|
|
param.ajouter(poids); |
412 |
|
|
} |
413 |
|
|
|
414 |
|
|
double uDegree=bspline->UDegree(); |
415 |
|
|
param.ajouter(uDegree); |
416 |
|
|
double vDegree=bspline->VDegree(); |
417 |
|
|
param.ajouter(vDegree); |
418 |
|
|
return MGCo_BSPLINES; |
419 |
|
|
} |
420 |
|
|
|
421 |
|
|
} |
422 |
|
|
void OCC_SURFACE::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> ¶m) |
423 |
|
|
{ |
424 |
|
|
//Conversion of the complete geometry of a shape into |
425 |
|
|
//NURBS geometry |
426 |
|
|
BRepBuilderAPI_NurbsConvert NURBS(face); |
427 |
|
|
Handle(Geom_Surface) surface=BRepLib_FindSurface(NURBS).Surface(); |
428 |
|
|
Handle(Geom_BSplineSurface) bspline=GeomConvert::SurfaceToBSplineSurface(surface) ; |
429 |
|
|
|
430 |
|
|
// The first parameter indicate the code access |
431 |
|
|
param.ajouter(2); |
432 |
|
|
//The follewing two parameters of the list indicate the orders of the net points |
433 |
|
|
param.ajouter( bspline->UDegree()+1); |
434 |
|
|
param.ajouter(bspline->VDegree()+1); |
435 |
|
|
|
436 |
|
|
//The follewing two parameters indicate the number of rows and colons of the control points |
437 |
|
|
//respectively to the two parameters directions |
438 |
|
|
param.ajouter(bspline->NbUPoles()); |
439 |
|
|
param.ajouter(bspline->NbVPoles()); |
440 |
|
|
|
441 |
|
|
// this present the knot vector in the u-direction |
442 |
|
|
for (unsigned int i=1;i<=bspline->NbUKnots();i++) |
443 |
|
|
{ |
444 |
|
|
param.ajouter(bspline->UKnot(i)); |
445 |
|
|
} |
446 |
|
|
//This present the knot vector in the v-direction |
447 |
|
|
for (unsigned int j=1;j<=bspline->NbVKnots();j++) |
448 |
|
|
{ |
449 |
|
|
param.ajouter(bspline->VKnot(j)); |
450 |
|
|
} |
451 |
francois |
363 |
for (int v=1;v<=bspline->NbVPoles();v++) |
452 |
francois |
283 |
{ |
453 |
francois |
363 |
for (int u=1;u<=bspline->NbUPoles();u++) |
454 |
francois |
283 |
{ |
455 |
|
|
double w=bspline->Weight(u,v); |
456 |
|
|
gp_Pnt point=bspline->Pole(u, v); |
457 |
|
|
double x=point.X(); |
458 |
|
|
double y=point.Y(); |
459 |
|
|
double z=point.Z(); |
460 |
|
|
param.ajouter(x); |
461 |
|
|
param.ajouter(y); |
462 |
|
|
param.ajouter(z); |
463 |
|
|
param.ajouter(w); |
464 |
|
|
} |
465 |
|
|
|
466 |
|
|
} |
467 |
|
|
indx_premier_ptctr=5+bspline->NbUKnots()+bspline->NbVKnots(); |
468 |
|
|
|
469 |
|
|
|
470 |
|
|
|
471 |
|
|
|
472 |
|
|
|
473 |
|
|
} |
474 |
|
|
|
475 |
francois |
295 |
void OCC_SURFACE::get_triangulation(MG_MAILLAGE* mai,MG_FACE* mgface,std::multimap<double,MG_NOEUD*,std::less<double> >& tabnoeudfus,double eps,int mode) |
476 |
francois |
283 |
{ |
477 |
francois |
353 |
TPL_MAP_ENTITE<MG_SOMMET*> listsom; |
478 |
|
|
TPL_MAP_ENTITE<MG_ARETE*> listare; |
479 |
|
|
std::map<unsigned long,bool> aretemaille; |
480 |
|
|
int nbboucle=mgface->get_nb_mg_boucle(); |
481 |
|
|
for (int i=0;i<nbboucle;i++) |
482 |
|
|
{ |
483 |
|
|
MG_BOUCLE* bou=mgface->get_mg_boucle(i); |
484 |
|
|
int nbarete=bou->get_nb_mg_coarete(); |
485 |
|
|
for (int j=0;j<nbarete;j++) |
486 |
|
|
{ |
487 |
|
|
MG_ARETE* are=bou->get_mg_coarete(j)->get_arete(); |
488 |
|
|
listare.ajouter(are); |
489 |
|
|
bool amailler=true; |
490 |
|
|
if (are->get_lien_maillage()->get_nb()>0) amailler=false; |
491 |
|
|
aretemaille[are->get_id()]=amailler; |
492 |
|
|
listsom.ajouter(bou->get_mg_coarete(j)->get_arete()->get_cosommet1()->get_sommet()); |
493 |
|
|
listsom.ajouter(bou->get_mg_coarete(j)->get_arete()->get_cosommet2()->get_sommet()); |
494 |
|
|
} |
495 |
|
|
} |
496 |
|
|
|
497 |
|
|
|
498 |
francois |
283 |
TopLoc_Location L; |
499 |
|
|
Handle (Poly_Triangulation) pt=BRep_Tool::Triangulation(face,L); |
500 |
|
|
int nbnoeud=pt->NbNodes(); |
501 |
|
|
int nbmaille=pt->NbTriangles(); |
502 |
|
|
const TColgp_Array1OfPnt& nodes = pt->Nodes(); |
503 |
|
|
const Poly_Array1OfTriangle& triangles = pt->Triangles(); |
504 |
|
|
const TColgp_Array1OfPnt2d& uvNodes = pt->UVNodes(); |
505 |
francois |
295 |
std::vector<MG_NOEUD*> tabnoeud; |
506 |
francois |
283 |
for ( Standard_Integer i = 0; i < nbnoeud; i++ ) |
507 |
|
|
{ |
508 |
|
|
gp_Pnt p1=nodes(i+1); |
509 |
|
|
double xx=p1.X(); |
510 |
|
|
double yy=p1.Y(); |
511 |
|
|
double zz=p1.Z(); |
512 |
|
|
double key=fabs(xx)+fabs(yy)+fabs(zz); |
513 |
|
|
MG_NOEUD* nvnoeud=NULL; |
514 |
|
|
if (mode>1) |
515 |
|
|
{ |
516 |
francois |
295 |
std::multimap<double,MG_NOEUD*,std::less<double> >::iterator it,itbas,ithaut; |
517 |
francois |
283 |
itbas=tabnoeudfus.lower_bound(key*0.99); |
518 |
|
|
ithaut=tabnoeudfus.upper_bound(key*1.1010101); |
519 |
|
|
for ( it=itbas ; it != ithaut; it++ ) |
520 |
|
|
{ |
521 |
|
|
MG_NOEUD* ntmp=(*it).second; |
522 |
|
|
double xtmp=ntmp->get_x(); |
523 |
|
|
double ytmp=ntmp->get_y(); |
524 |
|
|
double ztmp=ntmp->get_z(); |
525 |
|
|
OT_VECTEUR_3D vec(xtmp-xx,ytmp-yy,ztmp-zz); |
526 |
|
|
if (vec.get_longueur()<1e-6*eps) { |
527 |
|
|
nvnoeud=ntmp; |
528 |
|
|
break; |
529 |
|
|
} |
530 |
|
|
} |
531 |
|
|
} |
532 |
|
|
if (nvnoeud==NULL) |
533 |
|
|
{ |
534 |
francois |
353 |
MG_ELEMENT_TOPOLOGIQUE *topo=mgface; |
535 |
|
|
TPL_MAP_ENTITE<MG_SOMMET*>::ITERATEUR it1; |
536 |
|
|
for (MG_SOMMET* som=listsom.get_premier(it1);som!=NULL;som=listsom.get_suivant(it1)) |
537 |
|
|
{ |
538 |
|
|
double xyz[3]; |
539 |
|
|
som->get_point()->evaluer(xyz); |
540 |
|
|
OT_VECTEUR_3D vec(xyz[0]-xx,xyz[1]-yy,xyz[2]-zz); |
541 |
|
|
if (vec.get_longueur()<1e-6*eps) |
542 |
|
|
{ |
543 |
|
|
topo=som; |
544 |
|
|
break; |
545 |
|
|
|
546 |
|
|
} |
547 |
|
|
} |
548 |
|
|
if (topo==mgface) |
549 |
|
|
{ |
550 |
|
|
TPL_MAP_ENTITE<MG_ARETE*>::ITERATEUR it2; |
551 |
|
|
for (MG_ARETE* are=listare.get_premier(it2);are!=NULL;are=listare.get_suivant(it2)) |
552 |
|
|
{ |
553 |
|
|
double t; |
554 |
|
|
double xyz[3]={xx,yy,zz}; |
555 |
|
|
are->inverser(t,xyz); |
556 |
|
|
if (are->get_courbe()->est_periodique()) |
557 |
|
|
if (t< are->get_tmin()) t=t+are->get_courbe()->get_periode(); |
558 |
|
|
double xyztmp[3]; |
559 |
|
|
are->evaluer(t,xyztmp ); |
560 |
|
|
OT_VECTEUR_3D vec(xyz,xyztmp); |
561 |
|
|
if (vec.get_longueur()<eps) |
562 |
|
|
if ((t>are->get_tmin()) && (t<are->get_tmax())) |
563 |
|
|
{ |
564 |
|
|
topo=are; |
565 |
|
|
break; |
566 |
|
|
} |
567 |
|
|
} |
568 |
|
|
} |
569 |
|
|
nvnoeud=new MG_NOEUD(topo,xx,yy,zz,TRIANGULATION); |
570 |
francois |
283 |
mai->ajouter_mg_noeud(nvnoeud); |
571 |
|
|
std::pair<double,MG_NOEUD*> tmp(key,nvnoeud); |
572 |
|
|
tabnoeudfus.insert(tmp); |
573 |
|
|
} |
574 |
|
|
|
575 |
|
|
|
576 |
|
|
tabnoeud.insert(tabnoeud.end(),nvnoeud); |
577 |
|
|
} |
578 |
|
|
for ( Standard_Integer i = 0; i < nbmaille; i++ ) |
579 |
|
|
{ |
580 |
|
|
int n1,n2,n3; |
581 |
|
|
Poly_Triangle triangle = triangles( i + 1 ); |
582 |
|
|
bool face_reversed = (face.Orientation() == TopAbs_REVERSED); |
583 |
|
|
if ( face_reversed ) |
584 |
|
|
triangle.Get( n1, n3, n2 ); |
585 |
|
|
else |
586 |
|
|
triangle.Get( n1, n2, n3 ); |
587 |
|
|
MG_NOEUD* noeud1=tabnoeud[n1-1]; |
588 |
|
|
MG_NOEUD* noeud2=tabnoeud[n2-1]; |
589 |
|
|
MG_NOEUD* noeud3=tabnoeud[n3-1]; |
590 |
|
|
mai->ajouter_mg_triangle(mgface,noeud1,noeud2,noeud3,TRIANGULATION); |
591 |
francois |
353 |
if (noeud1->get_lien_topologie()->get_dimension()==0) |
592 |
|
|
{ |
593 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud1->get_lien_topologie(); |
594 |
|
|
som->get_lien_maillage()->ajouter(noeud1); |
595 |
|
|
} |
596 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==0) |
597 |
|
|
{ |
598 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud2->get_lien_topologie(); |
599 |
|
|
som->get_lien_maillage()->ajouter(noeud2); |
600 |
|
|
} |
601 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==0) |
602 |
|
|
{ |
603 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud3->get_lien_topologie(); |
604 |
|
|
som->get_lien_maillage()->ajouter(noeud3); |
605 |
|
|
} |
606 |
|
|
if (noeud1->get_lien_topologie()==noeud2->get_lien_topologie()) |
607 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==1) |
608 |
|
|
{ |
609 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie(); |
610 |
|
|
if (aretemaille[are->get_id()]==true) |
611 |
|
|
{ |
612 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud2,TRIANGULATION); |
613 |
|
|
are->get_lien_maillage()->ajouter(seg); |
614 |
|
|
} |
615 |
|
|
} |
616 |
|
|
if (noeud1->get_lien_topologie()==noeud3->get_lien_topologie()) |
617 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==1) |
618 |
|
|
{ |
619 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie(); |
620 |
|
|
if (aretemaille[are->get_id()]==true) |
621 |
|
|
{ |
622 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud3,TRIANGULATION); |
623 |
|
|
are->get_lien_maillage()->ajouter(seg); |
624 |
|
|
} |
625 |
|
|
} |
626 |
|
|
if (noeud3->get_lien_topologie()==noeud2->get_lien_topologie()) |
627 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==1) |
628 |
|
|
{ |
629 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud3->get_lien_topologie(); |
630 |
|
|
if (aretemaille[are->get_id()]==true) |
631 |
|
|
{ |
632 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud3,noeud2,TRIANGULATION); |
633 |
|
|
are->get_lien_maillage()->ajouter(seg); |
634 |
|
|
} |
635 |
|
|
} |
636 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==1) |
637 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==0) |
638 |
|
|
{ |
639 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie(); |
640 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud2->get_lien_topologie(); |
641 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
642 |
|
|
{ |
643 |
|
|
if (aretemaille[are->get_id()]==true) |
644 |
|
|
{ |
645 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud2,TRIANGULATION); |
646 |
|
|
are->get_lien_maillage()->ajouter(seg); |
647 |
|
|
} |
648 |
|
|
} |
649 |
|
|
} |
650 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==1) |
651 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==0) |
652 |
|
|
{ |
653 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie(); |
654 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud3->get_lien_topologie(); |
655 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
656 |
|
|
{ |
657 |
|
|
if (aretemaille[are->get_id()]==true) |
658 |
|
|
{ |
659 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud3,TRIANGULATION); |
660 |
|
|
are->get_lien_maillage()->ajouter(seg); |
661 |
|
|
} |
662 |
|
|
} |
663 |
|
|
} |
664 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==1) |
665 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==0) |
666 |
|
|
{ |
667 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud2->get_lien_topologie(); |
668 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud1->get_lien_topologie(); |
669 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
670 |
|
|
{ |
671 |
|
|
if (aretemaille[are->get_id()]==true) |
672 |
|
|
{ |
673 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud2,noeud1,TRIANGULATION); |
674 |
|
|
are->get_lien_maillage()->ajouter(seg); |
675 |
|
|
} |
676 |
|
|
} |
677 |
|
|
} |
678 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==1) |
679 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==0) |
680 |
|
|
{ |
681 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud2->get_lien_topologie(); |
682 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud3->get_lien_topologie(); |
683 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
684 |
|
|
{ |
685 |
|
|
if (aretemaille[are->get_id()]==true) |
686 |
|
|
{ |
687 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud2,noeud3,TRIANGULATION); |
688 |
|
|
are->get_lien_maillage()->ajouter(seg); |
689 |
|
|
} |
690 |
|
|
} |
691 |
|
|
} |
692 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==1) |
693 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==0) |
694 |
|
|
{ |
695 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud3->get_lien_topologie(); |
696 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud1->get_lien_topologie(); |
697 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
698 |
|
|
{ |
699 |
|
|
if (aretemaille[are->get_id()]==true) |
700 |
|
|
{ |
701 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud3,noeud1,TRIANGULATION); |
702 |
|
|
are->get_lien_maillage()->ajouter(seg); |
703 |
|
|
} |
704 |
|
|
} |
705 |
|
|
} |
706 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==1) |
707 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==0) |
708 |
|
|
{ |
709 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud3->get_lien_topologie(); |
710 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud2->get_lien_topologie(); |
711 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
712 |
|
|
{ |
713 |
|
|
if (aretemaille[are->get_id()]==true) |
714 |
|
|
{ |
715 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud3,noeud2,TRIANGULATION); |
716 |
|
|
are->get_lien_maillage()->ajouter(seg); |
717 |
|
|
} |
718 |
|
|
} |
719 |
|
|
} |
720 |
francois |
283 |
} |
721 |
francois |
353 |
TPL_MAP_ENTITE<MG_ARETE*>::ITERATEUR it2; |
722 |
|
|
for (MG_ARETE* are=listare.get_premier(it2);are!=NULL;are=listare.get_suivant(it2)) |
723 |
|
|
{ |
724 |
|
|
if (are->get_lien_maillage()->get_nb()==0) |
725 |
|
|
{ |
726 |
|
|
MG_NOEUD *no1=(MG_NOEUD*)are->get_cosommet1()->get_sommet()->get_lien_maillage()->get(0); |
727 |
|
|
MG_NOEUD *no2=(MG_NOEUD*)are->get_cosommet2()->get_sommet()->get_lien_maillage()->get(0); |
728 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,no1,no2,TRIANGULATION); |
729 |
|
|
are->get_lien_maillage()->ajouter(seg); |
730 |
|
|
} |
731 |
|
|
} |
732 |
francois |
283 |
} |
733 |
|
|
|
734 |
|
|
#endif |