ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/occ_surface.cpp
Revision: 814
Committed: Fri Aug 12 14:58:19 2016 UTC (8 years, 9 months ago) by couturad
File size: 25563 byte(s)
Log Message:
-> Mise à jour de la version du fichier MAGiC (version 2.2)
-> Ajout de la fonctionnalité get_liste_pole permettant d'obtenir les pôles d'une face
-> Ajout d'une méthode de génération d'un VES aléatoire selon la méthode RSA

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