ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/occ_surface.cpp
Revision: 818
Committed: Fri Aug 12 19:12:56 2016 UTC (8 years, 9 months ago) by couturad
File size: 26619 byte(s)
Log Message:
Mise à jour de la fonction d'identification des pôles afin de prendre en compte les surfaces de type Geom_RectangularTrimmedSurface 

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