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