ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/occ_surface.cpp
Revision: 509
Committed: Mon May 26 16:03:15 2014 UTC (10 years, 11 months ago) by francois
File size: 23814 byte(s)
Log Message:
occ_import erreur de tolerance sur la recuperation des aretes

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 francois 283 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 francois 339 if (PPS.NbPoints() < 1)
201     {
202     uv[0]=1e308;
203     uv[1]=1e308;
204     return;
205     }
206 francois 283 //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> &param)
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> &param)
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 francois 363 for (int v=1;v<=bspline->NbVPoles();v++)
467 francois 283 {
468 francois 363 for (int u=1;u<=bspline->NbUPoles();u++)
469 francois 283 {
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 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)
491 francois 283 {
492 francois 353 TPL_MAP_ENTITE<MG_SOMMET*> listsom;
493     TPL_MAP_ENTITE<MG_ARETE*> listare;
494 francois 371 //std::map<unsigned long,bool> aretemaille;
495     std::map<unsigned long,std::map<double,NOEUDARETE,less<double> >,less<unsigned long> > areteamaille;
496 francois 353 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 francois 371 //bool amailler=true;
506     //if (are->get_lien_maillage()->get_nb()>0) amailler=false;
507     //aretemaille[are->get_id()]=amailler;
508 francois 353 listsom.ajouter(bou->get_mg_coarete(j)->get_arete()->get_cosommet1()->get_sommet());
509 francois 371 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 francois 353 }
514     }
515    
516    
517 francois 283 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 francois 295 std::vector<MG_NOEUD*> tabnoeud;
525 francois 283 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 francois 295 std::multimap<double,MG_NOEUD*,std::less<double> >::iterator it,itbas,ithaut;
536 francois 283 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 francois 353 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 francois 371 double param_t;
568 francois 353 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 francois 509 if (vec.get_longueur()<1e-6*eps)
582 francois 353 if ((t>are->get_tmin()) && (t<are->get_tmax()))
583     {
584     topo=are;
585 francois 371 param_t=t;
586     break;
587 francois 353 }
588     }
589     }
590     nvnoeud=new MG_NOEUD(topo,xx,yy,zz,TRIANGULATION);
591 francois 283 mai->ajouter_mg_noeud(nvnoeud);
592     std::pair<double,MG_NOEUD*> tmp(key,nvnoeud);
593     tabnoeudfus.insert(tmp);
594 francois 371 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 francois 283 }
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     mai->ajouter_mg_triangle(mgface,noeud1,noeud2,noeud3,TRIANGULATION);
621 francois 353 if (noeud1->get_lien_topologie()->get_dimension()==0)
622     {
623     MG_SOMMET* som=(MG_SOMMET*)noeud1->get_lien_topologie();
624     som->get_lien_maillage()->ajouter(noeud1);
625     }
626     if (noeud2->get_lien_topologie()->get_dimension()==0)
627     {
628     MG_SOMMET* som=(MG_SOMMET*)noeud2->get_lien_topologie();
629     som->get_lien_maillage()->ajouter(noeud2);
630     }
631     if (noeud3->get_lien_topologie()->get_dimension()==0)
632     {
633     MG_SOMMET* som=(MG_SOMMET*)noeud3->get_lien_topologie();
634     som->get_lien_maillage()->ajouter(noeud3);
635     }
636 francois 371 /*if (noeud1->get_lien_topologie()==noeud2->get_lien_topologie())
637 francois 353 if (noeud1->get_lien_topologie()->get_dimension()==1)
638     {
639     MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie();
640     if (aretemaille[are->get_id()]==true)
641     {
642     MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud2,TRIANGULATION);
643     are->get_lien_maillage()->ajouter(seg);
644     }
645     }
646     if (noeud1->get_lien_topologie()==noeud3->get_lien_topologie())
647     if (noeud1->get_lien_topologie()->get_dimension()==1)
648     {
649     MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie();
650     if (aretemaille[are->get_id()]==true)
651     {
652     MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud3,TRIANGULATION);
653     are->get_lien_maillage()->ajouter(seg);
654     }
655 francois 371 }#include <../gmsh/tutorial/t8.geo>
656 francois 353 if (noeud3->get_lien_topologie()==noeud2->get_lien_topologie())
657     if (noeud3->get_lien_topologie()->get_dimension()==1)
658     {
659     MG_ARETE* are=(MG_ARETE*)noeud3->get_lien_topologie();
660     if (aretemaille[are->get_id()]==true)
661     {
662     MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud3,noeud2,TRIANGULATION);
663     are->get_lien_maillage()->ajouter(seg);
664     }
665     }
666     if (noeud1->get_lien_topologie()->get_dimension()==1)
667     if (noeud2->get_lien_topologie()->get_dimension()==0)
668     {
669     MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie();
670     MG_SOMMET* som=(MG_SOMMET*)noeud2->get_lien_topologie();
671     if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som))
672     {
673     if (aretemaille[are->get_id()]==true)
674     {
675     MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud2,TRIANGULATION);
676     are->get_lien_maillage()->ajouter(seg);
677     }
678     }
679     }
680     if (noeud1->get_lien_topologie()->get_dimension()==1)
681     if (noeud3->get_lien_topologie()->get_dimension()==0)
682     {
683     MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie();
684     MG_SOMMET* som=(MG_SOMMET*)noeud3->get_lien_topologie();
685     if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som))
686     {
687     if (aretemaille[are->get_id()]==true)
688     {
689     MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud3,TRIANGULATION);
690     are->get_lien_maillage()->ajouter(seg);
691     }
692     }
693     }
694     if (noeud2->get_lien_topologie()->get_dimension()==1)
695     if (noeud1->get_lien_topologie()->get_dimension()==0)
696     {
697     MG_ARETE* are=(MG_ARETE*)noeud2->get_lien_topologie();
698     MG_SOMMET* som=(MG_SOMMET*)noeud1->get_lien_topologie();
699     if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som))
700     {
701     if (aretemaille[are->get_id()]==true)
702     {
703     MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud2,noeud1,TRIANGULATION);
704     are->get_lien_maillage()->ajouter(seg);
705     }
706     }
707     }
708     if (noeud2->get_lien_topologie()->get_dimension()==1)
709     if (noeud3->get_lien_topologie()->get_dimension()==0)
710     {
711     MG_ARETE* are=(MG_ARETE*)noeud2->get_lien_topologie();
712     MG_SOMMET* som=(MG_SOMMET*)noeud3->get_lien_topologie();
713     if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som))
714     {
715     if (aretemaille[are->get_id()]==true)
716     {
717     MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud2,noeud3,TRIANGULATION);
718     are->get_lien_maillage()->ajouter(seg);
719     }
720     }
721     }
722     if (noeud3->get_lien_topologie()->get_dimension()==1)
723     if (noeud1->get_lien_topologie()->get_dimension()==0)
724     {
725     MG_ARETE* are=(MG_ARETE*)noeud3->get_lien_topologie();
726     MG_SOMMET* som=(MG_SOMMET*)noeud1->get_lien_topologie();
727     if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som))
728     {
729     if (aretemaille[are->get_id()]==true)
730     {
731     MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud3,noeud1,TRIANGULATION);
732     are->get_lien_maillage()->ajouter(seg);
733     }
734     }
735     }
736     if (noeud3->get_lien_topologie()->get_dimension()==1)
737     if (noeud2->get_lien_topologie()->get_dimension()==0)
738     {
739     MG_ARETE* are=(MG_ARETE*)noeud3->get_lien_topologie();
740     MG_SOMMET* som=(MG_SOMMET*)noeud2->get_lien_topologie();
741     if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som))
742     {
743     if (aretemaille[are->get_id()]==true)
744     {
745     MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud3,noeud2,TRIANGULATION);
746     are->get_lien_maillage()->ajouter(seg);
747     }
748     }
749 francois 371 }*/
750 francois 283 }
751 francois 353 TPL_MAP_ENTITE<MG_ARETE*>::ITERATEUR it2;
752     for (MG_ARETE* are=listare.get_premier(it2);are!=NULL;are=listare.get_suivant(it2))
753     {
754     if (are->get_lien_maillage()->get_nb()==0)
755     {
756 francois 371 unsigned long id=are->get_id();
757     MG_NOEUD* nodep=(MG_NOEUD*)are->get_cosommet1()->get_sommet()->get_lien_maillage()->get(0);
758     MG_NOEUD* noarr=(MG_NOEUD*)are->get_cosommet2()->get_sommet()->get_lien_maillage()->get(0);
759     std::map<double,NOEUDARETE,less<double> >::iterator it=areteamaille[id].begin();
760     MG_NOEUD* noeudcourant=nodep;
761     while (it!=areteamaille[id].end())
762     {
763     MG_NOEUD* noeud=(*it).second.no;
764     MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeudcourant,noeud,TRIANGULATION);
765     are->get_lien_maillage()->ajouter(seg);
766     noeudcourant=noeud;
767     it++;
768     }
769     MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeudcourant,noarr,TRIANGULATION);
770 francois 353 are->get_lien_maillage()->ajouter(seg);
771     }
772     }
773 francois 283 }
774    
775     #endif