ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/occ_surface.cpp
Revision: 820
Committed: Fri Aug 19 19:45:21 2016 UTC (8 years, 8 months ago) by francois
File size: 27510 byte(s)
Log Message:
prise en compte des poles dans le maillage des spheres pour le mailleur 2D. 20 ans après ca marche un peu pres.

File Contents

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