ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/CAD4FE/src/CAD4FE_MCBody.cpp
Revision: 1158
Committed: Thu Jun 13 22:18:49 2024 UTC (11 months ago) by francois
File size: 66336 byte(s)
Log Message:
compatibilité Ubuntu 22.04
Suppression des refeences à Windows
Ajout d'une banière

File Contents

# User Rev Content
1 francois 1158 //####//------------------------------------------------------------
2     //####//------------------------------------------------------------
3     //####// MAGiC
4     //####// Jean Christophe Cuilliere et Vincent FRANCOIS
5     //####// Departement de Genie Mecanique - UQTR
6     //####//------------------------------------------------------------
7     //####// MAGIC est un projet de recherche de l equipe ERICCA
8     //####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres
9     //####// http://www.uqtr.ca/ericca
10     //####// http://www.uqtr.ca/
11     //####//------------------------------------------------------------
12     //####//------------------------------------------------------------
13     //####//
14     //####// CAD4FE_MCBody.cpp
15     //####//
16     //####//------------------------------------------------------------
17     //####//------------------------------------------------------------
18     //####// COPYRIGHT 2000-2024
19     //####// jeu 13 jun 2024 11:58:56 EDT
20     //####//------------------------------------------------------------
21     //####//------------------------------------------------------------
22 foucault 27 #include <vector>
23     #include <string>
24     #include <sstream>
25     #include <fstream>
26     #include <algorithm>
27     #include <math.h>
28     #pragma hdrstop
29    
30    
31 foucault 176 #include "gestionversion.h"
32     #include "lc_point.h"
33     #include "step_point.h"
34 foucault 27
35 foucault 176 #include "CAD4FE_MCFace.h"
36     #include "CAD4FE_MCEdge.h"
37     #include "CAD4FE_PolyCurve.h"
38     #include "CAD4FE_PolySurface.h"
39     #include "CAD4FE_MCVertex.h"
40     #include "mg_maillage.h"
41     #include "CAD4FE_mg_utils.h"
42     #include "mg_gestionnaire.h"
43     #include "ot_mathematique.h"
44 foucault 27
45 foucault 569 #include "CAD4FE_Geometric_Tools.h"
46 foucault 27 #include "CAD4FE_MakeLoops.h"
47     #include "CAD4FE_MCBody.h"
48     #include "CAD4FE_ColorMap.h"
49     #include "CAD4FE_Criteria.h"
50 foucault 569 #include "hypergraphlib_components.h"
51     #include "hypergraphlib_neato.h"
52     #include "hypergraphlib_findcycles.h"
53 foucault 27
54     using namespace CAD4FE;
55    
56    
57     void MCTChanges::Merge(MCTChanges& __mctChanges)
58     {
59 foucault 569 /*int i;
60    
61 foucault 27 std::multimap<MCEdge*,MCEdge*>::iterator itEdge1, itEdge2;
62     for ( itEdge1 = E.begin();
63     itEdge1 != E.end();
64     itEdge1++)
65     {
66     i=0;
67     for ( itEdge2 = __mctChanges.E.find(itEdge1->second);
68     itEdge2->first == itEdge1->second && itEdge2 != __mctChanges.E.end();
69     itEdge2++)
70     {
71     if (itEdge2->second == itEdge2->first)
72     continue;
73     E.insert(std::make_pair(itEdge1->first, itEdge2->second));
74     i++;
75     }
76 foucault 569 if (i>0){
77     itEdge2 = itEdge1;
78     itEdge2 --;
79 foucault 27 E.erase(itEdge1);
80 foucault 569 itEdge1 = itEdge2;
81     }
82 foucault 27 }
83    
84     for ( itEdge2 = __mctChanges.E.begin();
85     itEdge2 != __mctChanges.E.end();
86     itEdge2++)
87     {
88     itEdge1 = E.find(itEdge2->first);
89     if (itEdge1 == E.end())
90     {
91     E.insert(std::make_pair(itEdge1->first,itEdge1->second));
92     }
93 foucault 569 }*/
94 foucault 27 }
95    
96     MCBody::MCBody(MG_GEOMETRIE* __refGeom, MG_VOLUME * __refBody)
97     {
98     time = 0;
99     _refBody = __refBody;
100     _refGeom = __refGeom;
101 foucault 569 InitHyperGraphs();
102 foucault 27 }
103    
104     MCBody::~MCBody()
105     {
106     delete _G10;
107     delete _G20;
108     delete _G21;
109     }
110    
111     void MCBody::Graph_SetUserData(MG_ELEMENT_TOPOLOGIQUE * __topo)
112     {
113     Graph_SetUserData(_G10, __topo);
114     Graph_SetUserData(_G20, __topo);
115     Graph_SetUserData(_G21, __topo);
116     }
117    
118     void MCBody::Graph_SetUserData(Graph::Graph * __G, MG_ELEMENT_TOPOLOGIQUE * __topo)
119     {
120     int id = __topo->get_id();
121    
122     switch (__topo->get_dimension())
123     {
124     case 0:// MCVertex
125     {
126     // reference vertex in arc of g10 and g20
127     if (__G == _G10 || __G == _G20 )
128     __G->GetArc(id)->SetUserData(__topo);
129    
130     break;
131     }
132     case 1:// MCEdge
133     {
134     // reference edge in node of g10 and arc of g21
135     if (__G == _G10 )
136     __G->GetNode(id)->SetUserData(__topo);
137     else if (__G == _G21 )
138     __G->GetArc(id)->SetUserData(__topo);
139    
140     break;
141     }
142     case 2:// MCFace
143     {
144     // reference face in node of g20 and g21
145     if (__G == _G20 || __G == _G21 )
146     __G->GetNode(id)->SetUserData(__topo);
147    
148     break;
149     }
150     }
151     }
152    
153     MCFace * MCBody::AddMCFace(MG_FACE * __refFace)
154     {
155     MCFace *newMCFace = new MCFace(__refFace);
156     // Set the face ID
157     _refGeom->ajouter_mg_surface(newMCFace->GetPolySurface());
158     _refGeom->ajouter_mg_face(newMCFace);
159    
160     return newMCFace;
161     }
162    
163     MCFace * MCBody::AddMCFace( MCFace *__a, MCFace *__b)
164     {
165     std::ostringstream idOriginal;
166     MCFace & mcFace1 = *__a;
167     MCFace & mcFace2 = *__b;
168     MCFace *newMCFace = new MCFace(mcFace1, mcFace2);
169     _refGeom->ajouter_mg_surface(newMCFace->GetPolySurface());
170     _refGeom->ajouter_mg_face(newMCFace);
171     return newMCFace;
172     }
173    
174     MCFace* MCBody::GetMCFace(const int __id) const
175     {
176     Graph::Node * node = _G21->GetNode(__id);
177     if (node)
178     return GetMCFace(node);
179     else
180     printf("Error in GetMCFace ID = %d\n", __id);
181    
182     return NULL;
183     }
184    
185     bool MCBody::Contains(MCFace * __mcFace) const
186     {
187     return (GetMCFace(__mcFace->get_id()) != NULL);
188     }
189    
190     MCFace* MCBody::GetMCFace(Graph::GraphObject * __graphObject)
191     {
192     return (MCFace*) __graphObject->GetUserData();
193     }
194     void MCBody::AddMCEdgeCovertices(MCEdge * __mcEdge, std::vector<MCVertex *> __mcVertex)
195     {
196     int i;
197    
198     // Set the covertex ID and add it in the geometry manager
199     MG_COSOMMET * covertex[2];
200     for (i=0;i<2;i++)
201     covertex[i] = _refGeom->ajouter_mg_cosommet(__mcEdge, __mcVertex[i]);
202    
203     if ( covertex[0]->get_t() > covertex[1]->get_t() && ! __mcEdge->GetPolyCurve()->est_periodique() )
204     std::swap (covertex[0], covertex[1]);
205    
206    
207     __mcEdge->changer_cosommet1(covertex[0]);
208     __mcEdge->changer_cosommet2(covertex[1]);
209     }
210     void MCBody::DeleteMCEdgeCovertices(MCEdge * __mcEdge)
211     {
212     _refGeom->supprimer_mg_cosommet(__mcEdge->get_cosommet1());
213     _refGeom->supprimer_mg_cosommet(__mcEdge->get_cosommet2());
214     }
215     void MCBody::DeleteMCEdge(MCEdge * __mcEdge)
216     {
217 foucault 569 printf("Deleting MC Edge\t : ID \"%lu\" at adress %p\n",__mcEdge->get_id(), __mcEdge);
218 foucault 27 _refGeom->supprimer_mg_courbeid(__mcEdge->GetPolyCurve()->get_id());
219     _refGeom->supprimer_mg_areteid(__mcEdge->get_id());
220     }
221     void MCBody::DeleteMCFace(MCFace * __mcFace)
222     {
223 foucault 569 printf("Deleting MC Face\t : ID \"%lu\" at adress %p\n",__mcFace->get_id(), __mcFace);
224 foucault 27 _refGeom->supprimer_mg_surfaceid(__mcFace->GetPolySurface()->get_id());
225     _refGeom->supprimer_mg_faceid(__mcFace->get_id());
226     }
227     void MCBody::DeleteMCVertex(MCVertex * __mcVertex)
228     {
229    
230     _refGeom->supprimer_mg_sommetid(__mcVertex->get_id());
231     }
232     MCEdge * MCBody::AddMCEdge(MG_ARETE * __refEdge)
233     {
234     // Construct a mc edge
235     MCEdge * newMCEdge = new MCEdge(__refEdge);
236    
237     // Set the newEdge ID
238     _refGeom->ajouter_mg_courbe(newMCEdge->GetPolyCurve());
239    
240     if (_refGeom->get_mg_courbeid( newMCEdge->GetPolyCurve()->get_id()) == NULL)
241     printf("PB!\n");
242    
243     _refGeom->ajouter_mg_arete(newMCEdge);
244     if (_refGeom->get_mg_areteid( newMCEdge->get_id()) == NULL)
245     printf("PB!\n");
246    
247     return newMCEdge;
248     }
249     MCEdge * MCBody::AddMCEdge(MCEdge *__A, MCEdge *__B)
250     {
251     std::ostringstream idOriginal;
252     idOriginal<< __A->get_idoriginal();
253     idOriginal<<"+";
254     idOriginal<< __B->get_idoriginal();
255    
256     // Create a polycurve
257     MCEdge * newMCEdge = new MCEdge( idOriginal.str(), *__A, *__B);
258    
259     // Set the newEdge ID
260     _refGeom->ajouter_mg_courbe(newMCEdge->GetPolyCurve());
261    
262     if (_refGeom->get_mg_courbeid( newMCEdge->GetPolyCurve()->get_id()) == NULL)
263     printf("PB!\n");
264    
265     _refGeom->ajouter_mg_arete(newMCEdge);
266     if (_refGeom->get_mg_areteid( newMCEdge->get_id()) == NULL)
267     printf("PB!\n");
268    
269     return newMCEdge;
270     }
271     MCEdge * MCBody::AddMCEdge(PolyCurve *__curve)
272     {
273     std::ostringstream idOriginal;
274     idOriginal<< "MCEdge" ;
275     for (unsigned i=0; i<__curve->GetRefEdgeCount(); i++)
276     idOriginal<<"-"<<__curve->GetRefEdge(i)->get_id();
277     MCEdge * newMCEdge = new MCEdge(idOriginal.str(), __curve);
278    
279     // Set the newEdge ID
280     _refGeom->ajouter_mg_courbe(newMCEdge->GetPolyCurve());
281    
282     if (_refGeom->get_mg_courbeid( newMCEdge->GetPolyCurve()->get_id()) == NULL)
283     printf("PB!\n");
284    
285     _refGeom->ajouter_mg_arete(newMCEdge);
286     if (_refGeom->get_mg_areteid( newMCEdge->get_id()) == NULL)
287     printf("PB!\n");
288    
289     return newMCEdge;
290     }
291    
292     Graph::Graph * MCBody::G10() const
293     {
294     return _G10;
295     }
296    
297     Graph::Graph * MCBody::G21() const
298     {
299     return _G21;
300     }
301    
302     Graph::Graph * MCBody::G20() const
303     {
304     return _G20;
305     }
306    
307     MCEdge* MCBody::GetMCEdge(int __id) const
308     {
309     Graph::Node * node = _G10->GetNode(__id);
310    
311     if (node)
312     return GetMCEdge(node);
313     else
314     cout << "GetMCEdge : Error: Did not find the MCEdge corresponding to the ID \""<<__id<<"\"\n";
315    
316     return NULL;
317     }
318    
319     MCEdge* MCBody::GetMCEdge(Graph::GraphObject * __graphObject)
320     {
321     return (MCEdge *) __graphObject->GetUserData();
322     }
323    
324     bool MCBody::Contains(MCEdge * __mcEdge) const
325     {
326     Graph::Node * n = _G10->GetNode(__mcEdge->get_id());
327    
328     if (!n)
329     return false;
330    
331     return ( n->GetUserData() == __mcEdge );
332     }
333    
334     MCVertex * MCBody::AddMCVertex(MG_SOMMET * __refVertex)
335     {
336     double pos[3]; __refVertex->get_point()->evaluer(pos);
337     MCVertex *mcVertex = new MCVertex(__refVertex);
338    
339     // Add the vertex to the geometry manager in order to
340     // set its ID
341     _refGeom->ajouter_mg_sommet(mcVertex);
342    
343     return mcVertex;
344     }
345    
346     MCVertex* MCBody::GetMCVertex(int __id)const
347     {
348     Graph::Arc * arc;
349     arc = _G10->GetArc(__id);
350     if (arc)
351     return GetMCVertex(arc);
352     else
353     {
354     printf("Error in GetMCVertex (int id) method : can't find the arc ID %d in G10 Graph !\n", __id);
355     }
356     return NULL;
357     }
358    
359     bool MCBody::Contains(MCVertex * __mcVertex) const
360     {
361     Graph::Arc * a = _G10->GetArc(__mcVertex->get_id());
362    
363     if (!a)
364     return false;
365    
366     return (a->GetUserData() == __mcVertex );
367     }
368    
369     MCVertex * MCBody::GetMCVertex(Graph::GraphObject * __graphObject)
370     {
371     return (MCVertex*) __graphObject->GetUserData();
372     }
373    
374     void MCBody::InitHyperGraphs()
375     {
376     int j, k;
377     _G21 = new Graph::Graph;
378     _G10 = new Graph::Graph;
379     _G20 = new Graph::Graph;
380    
381     std::set < MG_FACE * > lst_ref_faces;
382     std::set < MG_ARETE * > lst_ref_edges;
383     std::set < MG_SOMMET * > lst_ref_vertices;
384    
385     // initialize face, edge, and vertices lists
386     unsigned nb_shells = _refBody->get_nb_mg_coquille ();
387     for (unsigned it_shells = 0; it_shells < nb_shells; it_shells++)
388     {
389     MG_COQUILLE * shell = _refBody->get_mg_coquille(it_shells);
390     unsigned nb_coface = shell->get_nb_mg_coface();
391     for (unsigned it_coface = 0; it_coface < nb_coface; it_coface++)
392     {
393     MG_FACE * face = shell->get_mg_coface(it_coface)->get_face();
394     lst_ref_faces.insert(face);
395    
396     unsigned nb_loop = face->get_nb_mg_boucle();
397     for (unsigned it_loop = 0; it_loop < nb_loop; it_loop++)
398     {
399     MG_BOUCLE * loop = face->get_mg_boucle(it_loop);
400     unsigned nb_edge = loop->get_nb_mg_coarete();
401    
402     for (unsigned it_edge = 0; it_edge < nb_edge; it_edge++)
403     {
404     MG_ARETE * edge = loop->get_mg_coarete(it_edge)->get_arete();
405     lst_ref_edges.insert(edge);
406    
407     lst_ref_vertices.insert (edge->get_cosommet1()->get_sommet());
408     lst_ref_vertices.insert (edge->get_cosommet2()->get_sommet());
409     }
410     }
411     }
412     }
413    
414    
415     // Correspondance map between Reference Entities and MC entities
416     std::map <MG_FACE *, MCFace *> mapRefToMCFace;
417     std::map <MG_ARETE *, MCEdge *> mapRefToMCEdge;
418     std::map <MG_SOMMET *, MCVertex *> mapRefToMCVertex;
419    
420     // Create the MC Vertices
421     for (std::set<MG_SOMMET*>::iterator it_vert = lst_ref_vertices.begin();
422     it_vert != lst_ref_vertices.end(); it_vert++)
423     {
424     MG_SOMMET * refVertex = *it_vert;
425     // Create the MC Vertex
426     // and initialize the Indentifier using the Geometry manager
427     MCVertex * mcVertex = AddMCVertex(refVertex);
428     // Map the MC Vertex to its reference vertex in the correspondance map
429     mapRefToMCVertex [ refVertex ] = mcVertex;
430     }
431    
432     // Create the MC Edges
433     for (std::set <MG_ARETE *>::iterator it_edge = lst_ref_edges.begin();
434     it_edge != lst_ref_edges.end();
435     it_edge ++)
436     {
437     MG_ARETE * refEdge = *it_edge;
438     // Create the MC Edge
439     // and initialize the Indentifier using the Geometry manager
440     MCEdge * mcEdge = AddMCEdge(refEdge);
441     // Map the MC Edge to its reference edge in the correspondance map
442     mapRefToMCEdge [ refEdge ] = mcEdge;
443     }
444    
445     // Create the MC Faces
446     for (std::set<MG_FACE*>::iterator it_face = lst_ref_faces.begin();
447     it_face != lst_ref_faces.end();
448     it_face++)
449     {
450     MG_FACE * refFace = *it_face;
451     // Create the MC Face
452     // and initialize the Indentifier using the Geometry manager
453     MCFace * mcFace = AddMCFace(refFace);
454     // Map the MC Face to its reference Face in the correspondance map
455     mapRefToMCFace [ refFace ] = mcFace;
456     }
457    
458     // for each face of the reference topology
459     for (std::set<MG_FACE*>::iterator it_face = lst_ref_faces.begin();
460     it_face != lst_ref_faces.end();
461     it_face++)
462     {
463     MG_FACE * refFace = *it_face;
464    
465     // Get the MCFace corresponding to the reference face
466     MCFace * mcFace = mapRefToMCFace [ refFace ];
467    
468 foucault 569 printf("Initializing\tMC Face\tID \"%lu\" \t(Ref Face ID \"%lu\")\n",mcFace->get_id(), refFace->get_id());
469 foucault 27
470     // Add a node in _G21 and _G20
471     _G21->AddNode (mcFace->get_id());
472     _G20->AddNode (mcFace->get_id());
473    
474     // initialize graph G21 and G20 nodes to face
475     Graph_SetUserData(mcFace);
476     }
477    
478     // For each edge of refBody :
479     // create an arc in G21 and connect-it to each nodes of adjacent faces
480     // create a node in G1
481     for (std::set <MG_ARETE *>::iterator it_edge = lst_ref_edges.begin();
482     it_edge != lst_ref_edges.end();
483     it_edge ++)
484     {
485     MG_ARETE * refEdge = *it_edge;
486    
487     // Get the MCEdge corresponding to the reference Edge
488     MCEdge * mcEdge = mapRefToMCEdge [ refEdge ];
489    
490     // printing the step number
491 francois 1075 printf("Initializing\t MC Edge\t%lu of %lu : ID = \"%lu\" \t(Reference Edge ID \"%lu\")\n", std::distance(lst_ref_edges.begin(), it_edge)+1, lst_ref_edges.size(), mcEdge->get_id(), refEdge->get_id());
492 foucault 27
493     // create a node in G1
494    
495     // add a node in _G10
496     _G10->AddNode (mcEdge->get_id());
497    
498     // create an arc in G21 and connect-it to each nodes of adjacent faces
499     std::vector <int> nodes;
500     for (int j=0; j < refEdge->get_nb_mg_coarete(); j++)
501     {
502     MG_FACE * refFace = refEdge->get_mg_coarete(j)->get_boucle()->get_mg_face();
503     // mcFace = adjacent face
504     MCFace * mcFace = mapRefToMCFace [ refFace ];
505    
506     // connect arc to adjacent faces
507     nodes.push_back(mcFace->get_id());
508     }
509     _G21->AddArc(nodes, mcEdge->get_id());
510    
511     // initialize graph G21 arcs and G10 nodes to MC Edge
512     Graph_SetUserData(mcEdge);
513     }
514    
515    
516     // For each ref vertex of reference Body :
517     for (std::set<MG_SOMMET*>::iterator it_vertex = lst_ref_vertices.begin();
518     it_vertex != lst_ref_vertices.end();
519     it_vertex++)
520     {
521     MG_SOMMET * refVertex = *it_vertex;
522    
523     // Get the MCVertex corresponding to the reference Vertex
524     MCVertex * mcVertex = mapRefToMCVertex [ refVertex ];
525    
526     // -------------- G20 Arc --------------------------------------------
527     // create an arc in G20 and connect-it to each nodes of adjacent faces
528     {
529     std::vector <int> nodes;
530     for (unsigned j = 0; j < refVertex->get_nb_mg_cosommet(); j++)
531     {
532     MG_ARETE * refEdge = refVertex->get_mg_cosommet(j)->get_arete();
533    
534     for (int k=0; k < refEdge->get_nb_mg_coarete(); k++)
535     {
536     MG_FACE * refFace = refEdge->get_mg_coarete(k)->get_boucle()->get_mg_face();
537     MCFace * mcFace = mapRefToMCFace [ refFace ];
538    
539     if (std::find (nodes.begin(), nodes.end(), mcFace->get_id()) == nodes.end())
540     nodes.push_back(mcFace->get_id());
541     }
542     }
543     // create a graph-arc in G20
544     _G20->AddArc(nodes, mcVertex->get_id());
545     }
546    
547    
548     // -------------- G10 Arc --------------------------------------------
549     // create an arc in G10 and connect-it to each nodes of adjacent edges
550     {
551     std::vector <int> nodes;
552     for (unsigned j = 0; j < refVertex->get_nb_mg_cosommet(); j++)
553     {
554     MG_ARETE * refEdge = refVertex->get_mg_cosommet(j)->get_arete();
555     MCEdge * mcEdge = mapRefToMCEdge [ refEdge ];
556    
557     nodes.push_back(mcEdge->get_id());
558     }
559     // create a graph-arc in G10
560     _G10->AddArc(nodes, mcVertex->get_id());
561     }
562    
563     // initialize graph G10 arc and G20 arc to MC Vertex
564     Graph_SetUserData(mcVertex);
565     }
566    
567     // Add covertices for each edge
568     {
569     MCBODY_FOR_EACH_MCEDGE(this, mcEdge)
570     {
571     std::vector <MCVertex*> extremities;
572     Edge_GetVertices(mcEdge, extremities);
573     AddMCEdgeCovertices(mcEdge, extremities);
574     }
575     }
576     }
577    
578     int
579     MCBody::G2ToNeatoFile (Graph::Graph * __G2,
580     char * __filename,
581     char *__graphname)
582     {
583     using std::cout;
584 foucault 64 std::string graphNeato;
585 foucault 27 std::ofstream neatoFile;
586     neatoFile.open( __filename );
587 foucault 64 graphNeato = NeatoGraph(*__G2);
588     std::cout << graphNeato;
589     neatoFile << graphNeato;
590     neatoFile.flush();
591 foucault 27 neatoFile.close(); //explicit
592    
593     return 0;
594     }
595     MCVertex * MCBody::CreateMCVertex (MG_SOMMET * __refVertex)
596     {
597     // Create the MC Vertex in G20 and G10
598    
599     MCVertex * mcVertex = new MCVertex (__refVertex);
600    
601     _refGeom->ajouter_mg_sommet(mcVertex);
602    
603     int id = mcVertex->get_id();
604     Graph::Arc * G20Arc = _G20->AddArc(id, 0 /*rank=0*/);
605     Graph::Arc * G10Arc = _G10->AddArc(id, 0 /*rank=0*/);
606    
607     Graph_SetUserData(mcVertex);
608    
609     return mcVertex;
610     }
611    
612     void MCBody::SplitEdge(MCEdge * __mcEdge, double __xyz[3], MCTChanges * __mctChanges, RTChanges * __rtChanges)
613     {
614     MG_ARETE *__origRefEdge;
615     MG_SOMMET * __splitRefVertex;
616     MG_ARETE *__splitRefEdges[2];
617     MCVertex * __mcVertex;
618     MCEdge *__result[2];
619     int i;
620    
621     // store the extremities of the original edge in a vector
622     std::vector <MCVertex * > origEdgeExtremities;
623     Edge_GetVertices ( __mcEdge, origEdgeExtremities );
624    
625     // split curves
626     PolyCurve * edgePolyCurve = __mcEdge->GetPolyCurve();
627     PolyCurve * curves[2];
628     SplitPolyCurve(edgePolyCurve, __xyz, _refBody, _refGeom, curves, &__origRefEdge, &__splitRefVertex, __splitRefEdges);
629     if ( __splitRefVertex == NULL )
630     {
631     printf("Can't split MC Edge in MC body\n");
632     return;
633     }
634     _refGeom->ajouter_mg_sommet(__splitRefVertex);
635    
636     __mcVertex = CreateMCVertex(__splitRefVertex);
637    
638 foucault 569 printf("Inserting MC Vertex\t : ID \"%lu\" \n", __mcVertex->get_id());
639 foucault 27
640     // Create the two MC Edges
641     for ( i=0; i<2; i++)
642     {
643     __result[i] = AddMCEdge(curves[i]);
644 francois 830 __result[i]->transfert_ccf(*__mcEdge);
645 foucault 27 }
646    
647     // duplicate G21A to get 2 parallel arcs
648     Graph::Arc * G21A[3];
649     G21A[2] = _G21->GetArc(__mcEdge->get_id());
650     int faceId[2];
651    
652     // save the G21 nodes adjacent to the mc Edges's arc
653     Graph::Node * G21N[2];
654     i=0;
655     for (Graph::Arc::MultimapNodesById::iterator itG21Node = G21A[2]->Nodes().begin();
656     itG21Node != G21A[2]->Nodes().end();
657     itG21Node++ )
658     {
659     faceId[i] = itG21Node->first;
660     G21N[i++] = itG21Node->second;
661     }
662    
663    
664     // Set edges id
665     int edgeId[3];
666     edgeId[2] = __mcEdge->get_id();
667     for (i = 0; i < 2; i++)
668     edgeId[i] = __result[i]->get_id();
669    
670     // Duplicate the G21 arc of the split edge
671     for (i = 0; i < 2; i++)
672     G21A[i] = _G21->DuplicateArc(G21A[2], edgeId[i]);
673     // Remove the G21 Arc of the split edge
674     _G21->RemoveArc(G21A[2]);
675    
676     // split the G10 node of the split edge
677     Graph::Arc * G10A[3];
678     Graph::Node * G10N[3];
679     G10A[2] = _G10->GetArc( __mcVertex->get_id() ); // the arc representing the split vertex
680     G10N[2] = _G10->GetNode( __mcEdge->get_id() );
681     // delete the G10 node of the old edge
682     _G10->RemoveNode(G10N[2]);
683     // Add two new nodes
684     for ( i=0; i<2; i++)
685     G10N[i] = _G10->AddNode(edgeId[i]);
686     // Add an arc linking the 2 nodes. This arc represents the split vertex
687     // Link the G10 arc of the MC vertex to the 2 nodes representing the edges
688     for (i=0; i<2; i++)
689     {
690     G10A[2]->Add(G10N[i]);
691     G10N[i]->Add(G10A[2]);
692     }
693    
694     for (i=0; i<2; i++)
695     {
696     MG_SOMMET * refVertex = NULL;
697     if (curves[i]->get_sommet1()->get_id() != __mcVertex->GetRefVertex()->get_id())
698     refVertex = curves[i]->get_sommet1();
699     else
700     refVertex = curves[i]->get_sommet2();
701     MCVertex * V;
702    
703     for (int j=0; j<2; j++)
704     if (origEdgeExtremities[j]->Contains( refVertex ))
705     V = origEdgeExtremities[j];
706    
707     G10A[i] = _G10->GetArc(V->get_id());
708     }
709    
710    
711     // add new node[i] in arc[i]
712     for ( i=0; i<2; i++)
713     {
714     G10A[i]->Add(G10N[i]);
715     G10N[i]->Add(G10A[i]);
716     }
717    
718     // Add an arc in G20
719     Graph::Arc * G20Arc = _G20->GetArc(__mcVertex->get_id());
720     Graph::Node * G20Node[2];
721     for ( i=0; i<2; i++)
722     {
723     G20Node[i] = _G20->GetNode(faceId[i]);
724     G20Arc->Add(G20Node[i]);
725     G20Node[i]->Add(G20Arc);
726     }
727    
728     printf("G10A[2]->Rank = %d\n", G10A[2]->Rank());
729     printf("G20A[2]->Rank = %d\n", _G20->GetArc(__mcVertex->get_id())->Rank());
730    
731     /// Operations using the resulting Graph of this MC Edge
732     /// split :
733     /// Get the vertex extremities of both new MC Edge
734     /// and Add 2 Covertices
735     for (i=0; i<2; i++)
736     {
737     MCEdge * newMCEdge = __result[i];
738    
739     std::vector<MCVertex*> mcVertexExtremities;
740     Edge_GetVertices(newMCEdge, mcVertexExtremities);
741     AddMCEdgeCovertices(newMCEdge, mcVertexExtremities);
742    
743     /// Set graph user Data of new MCEdge G21 Arc and G10 Node
744     Graph_SetUserData(newMCEdge);
745     }
746    
747 foucault 569
748 foucault 27 // Deleted and Created MC Topology
749     if (__mctChanges)
750     {
751     // a new vertex has been created
752     __mctChanges->V.insert( std::make_pair ((MCVertex*)NULL, __mcVertex));
753     // __mcEdge has been replaces by 2 new edges
754     __mctChanges->E.insert( std::make_pair (__mcEdge, (MCEdge*) NULL) );
755     __mctChanges->E.insert( std::make_pair ((MCEdge*) NULL, __result[0]) );
756     __mctChanges->E.insert( std::make_pair ((MCEdge*) NULL, __result[1]) );
757     }
758    
759     // Deleted and created Reference Topology
760     if (__rtChanges)
761     {
762     // a new vertex __splitRefVertex has been created
763     __rtChanges->V.insert( std::make_pair ((MCVertex*)NULL , __splitRefVertex) );
764     // __origRefEdge has been replaces by 2 new edges __splitRefEdges
765     __rtChanges->E.insert( std::make_pair (__origRefEdge , __splitRefEdges[0]) );
766     __rtChanges->E.insert( std::make_pair (__origRefEdge , __splitRefEdges[1]) );
767     }
768 foucault 569
769 foucault 27 }
770    
771     int
772     MCBody::G1ToNeatoFile (Graph::Graph * __G1,
773     char * __filename,
774     char *__graphname)
775     {
776     using std::cout;
777     std::ofstream neatoFile;
778     neatoFile.open( __filename );
779     neatoFile << "graph \""<< __graphname <<"\" {" << std::endl;
780     neatoFile << "node [ shape=box , color = blue ]\n";
781    
782     //////// G1 graph
783     GRAPH_FOR_EACH_ARC_CONST(__G1,itarcs)
784     {
785     neatoFile << "\""<<itarcs->first<<"\" [ shape=point, style=filled, fillcolor=red ]\n";
786    
787     ARC_FOR_EACH_NODE_CONST( itarcs->second, itnodes)
788     {
789     neatoFile << "\""<< itnodes->first << "\"";
790     neatoFile << " -- ";
791     neatoFile << "\""<< itarcs->first << "\"";
792     neatoFile << " [ len=1 ] ";
793     neatoFile << std::endl;
794     }
795     }
796     neatoFile << "}" << std::endl;
797     neatoFile << std::endl;
798    
799     neatoFile.close(); //explicit
800    
801     return 0;
802     }
803    
804 foucault 569 bool V2(MCBody * _mcBody, MG_ELEMENT_TOPOLOGIQUE * topo)
805     {
806     if (topo)
807     {
808     switch (topo->get_dimension())
809     {
810     case 0:
811     {
812     MCVertex * mctopo = _mcBody->GetMCVertex(topo->get_id());
813    
814    
815     if (mctopo != topo)
816     {
817     printf("MC Vertex %ld does not exist !\n", topo->get_id());
818     return false;
819     }
820     else
821     return true;
822    
823    
824    
825     }
826     case 1:
827     {
828     MCEdge * mctopo = _mcBody->GetMCEdge(topo->get_id());
829     MCEdge * topo2 = (MCEdge*) _mcBody->GetGeometry()->get_mg_areteid(topo->get_id());
830    
831     if (mctopo != topo || topo2 != topo)
832     {
833     printf("MC Edge %ld does not exist !\n", topo->get_id());
834     return false;
835     }
836     else
837     return true;
838     }
839     case 2:
840     {
841     MCFace * mctopo = _mcBody->GetMCFace(topo->get_id());
842    
843     if (mctopo != topo)
844     {
845     printf("MC Face %ld does not exist !\n", topo->get_id());
846     return false;
847     }
848     else
849     return true;
850     }
851     default:
852     printf("The topological link claims a dimension \"%d\" > 2 or < 0 !\n", topo->get_dimension());
853     }
854     }
855     else
856     {
857     printf("Topo = NULL\n");
858     return false;
859     }
860     return false;
861     }
862    
863     void V(MCBody * _mcBody)
864     {
865     int i=0;
866     {MCBODY_FOR_EACH_MCEDGE(_mcBody, edge22){
867     if (_mcBody->G21()->GetArcs().size() <= 1)
868     break;
869     if (V2(_mcBody, edge22) == false)
870     printf("MC Edge ID=%lu not OK\n", edge22->get_id());
871     i++;
872     }
873     }
874    
875     }
876 foucault 27 void
877     MCBody::SuppressMCEdge(MCEdge * __mcEdge, MCFace * __F[3])
878     {
879     int i;
880     int __id = __mcEdge->get_id();
881    
882     // Find the arc __id in G2V (G2 Virtual)
883     Graph::Arc * arcG21 = _G21->GetArc(__id);
884 foucault 569 // V(this);
885 foucault 27
886     ///// Process G2 Graph
887 foucault 569 printf("Deleting MC Edge\t : ID \"%d\" at adress %p \n", __id, __mcEdge);
888 foucault 27
889     if ( ! arcG21->IsLoop() ) // The arc represents an boundary edge
890     {
891     // Get the two mc faces adjacent to the suppressed mc edge
892     MCFace * face[3];
893     int faceId[3];
894     Graph::Node * faceNode[3];
895    
896     i = 0;
897     Graph::Arc::MultimapNodesById::iterator itNode = arcG21->Nodes().begin();
898     for (i=0; i<2; i++)
899     {
900     faceId[i] = itNode->first;
901     faceNode[i] = itNode->second;
902     face[i] = GetMCFace(faceId[i]);
903    
904     itNode++;
905     }
906    
907 foucault 569 //V(this);
908     _G21->RemoveArc(__id);
909     //V(this);
910    
911 foucault 27 // Merge the nodes of these 2 mc face in G21
912     // (contract the arc in G21)
913     MCFace* newMCFace = AddMCFace(face[0], face[1]);
914     faceId[2] = newMCFace->get_id();
915     faceNode[2] = _G21->MergeNodes(faceNode[0], faceNode[1], faceId[2]);
916    
917     // Merge the nodes of these 2 mc faces in G20
918     Graph::Node * mergedG20Node = _G20->MergeNodes( faceId[0], faceId[1], faceId[2]);
919 foucault 569 //V(this);
920 foucault 27
921     // Remove the node in G10
922     _G10->RemoveNode(__mcEdge->get_id());
923 foucault 569 //V(this);
924 foucault 27
925     // Attach the MC Face to Graph nodes of G21 and G10
926     Graph_SetUserData(newMCFace);
927 foucault 569 //V(this);
928 foucault 27
929     printf ("Adding new merged face %d = { %d + %d }\n", faceId[2], faceId[0], faceId[1]);
930    
931     __F[0] = face[0];
932     __F[1] = face[1];
933     __F[2] = newMCFace;
934     }
935     else // The arc represents an interior edge
936     {
937     Graph::Node *n = _G21->GetArc(__id)->First();
938    
939     // if the arc is a loop then delete it
940     // in G2V : delete the g2v arc from the node and from the graph
941     _G21->RemoveArc(__id);
942 foucault 569 //V(this);
943 foucault 27 // in G1V : delete the g1v node from the graph
944     _G10->RemoveNode(__id);
945 foucault 569 //V(this);
946 foucault 27
947     __F[0] = 0;
948     __F[1] = 0;
949     __F[2] = GetMCFace(n);
950 foucault 569 //V(this);
951 foucault 27 }
952     }
953    
954     void
955     MCBody::SuppressMCVertex(MCVertex * __mcVertex, MCTChanges * __mctChanges)
956     {
957 foucault 569 printf("Deleting MC Vertex\t : ID \"%lu\" at adress %p\n",__mcVertex->get_id(), __mcVertex);
958 foucault 27
959     // Find the arc __name in G1V (G1 Virtual)
960     Graph::Arc *g1vArc = _G10->GetArc( __mcVertex->get_id() );
961     MCVertex * mcVertex = __mcVertex;
962    
963     // Case of a B-Rep vertex separating only 2 edges
964     if ( g1vArc->Rank() == 2 )
965     {
966     // Get the 2 MC Edges separated by the MC Vertex
967     std::vector <MCEdge *> edge;
968     Vertex_GetAdjacentEdges( mcVertex, edge );
969    
970     // Get the MC Faces Separated by the 2 MC Edges
971     std::set <MCFace *> listMCFaces = Edge_GetAdjacentFaces(edge[0]);
972     MCFace * mcFace[2];
973     std::set<MCFace*>::iterator itr=listMCFaces.begin();
974     for (unsigned i=0;i<2;i++)
975     {
976     mcFace[i] = *itr;
977     itr++;
978     }
979    
980     // Unify parallel G21 arcs
981    
982     // Create a unique arc in G2 Which connect n1 and n2
983     Graph::Arc::MultimapNodesById newG21ArcNodes = _G21->GetArc( edge[0]->get_id() )->Nodes();
984     _G21->RemoveArc( edge[0]->get_id() );
985     _G21->RemoveArc( edge[1]->get_id() );
986    
987 francois 1075 printf("the deleted vertex was adjacent to %d / %lu faces\n", _G20->GetArc( __mcVertex->get_id() )->Rank(), listMCFaces.size());
988 foucault 27 printf("the deleted vertex was adjacent to %d edges\n", _G10->GetArc( __mcVertex->get_id() )->Rank());
989     // attach to the new node a edge attribute
990     // constructed by the merge of the 2 edge attributes
991     MCEdge * newMCEdge = AddMCEdge(edge[0], edge[1]);
992    
993     _G21->AddArc(newMCEdge->get_id(), newG21ArcNodes);
994    
995     // Merge nodes G10
996     Graph::Node* n = _G10->MergeNodes(_G10->GetNode(edge[0]->get_id()), _G10->GetNode(edge[1]->get_id()), newMCEdge->get_id());
997     // Remove G10 loop-arc to newNode
998     _G10->RemoveArc( _G10->GetArc(__mcVertex->get_id()) );
999     // Remove G20 arc
1000     _G20->RemoveArc( _G20->GetArc(__mcVertex->get_id()));
1001    
1002     /// Operations using the resulting Graph of this MC Vertex
1003     /// Suppression :
1004     /// Get the vertex extremities of this new MC Edge
1005     /// and Add 2 Covertices
1006     std::vector<MCVertex*> mcVertexExtremities;
1007     Edge_GetVertices(newMCEdge, mcVertexExtremities);
1008     PolyCurve * newPolyCurve = newMCEdge->GetPolyCurve();
1009    
1010     if (newPolyCurve->est_periodique())
1011     if (newPolyCurve->get_sommet1() != mcVertexExtremities[0]->GetRefVertex())
1012     newPolyCurve->SetPeriodicPoleRefVertex(mcVertexExtremities[0]->GetRefVertex());
1013    
1014     AddMCEdgeCovertices(newMCEdge, mcVertexExtremities);
1015     /// Set graph user Data of new MCEdge G21 Arc and G10 Node
1016     Graph_SetUserData(newMCEdge);
1017    
1018     if (__mctChanges)
1019     {
1020     // The mc vertex has been deleted
1021     __mctChanges->V.insert( std::make_pair (__mcVertex, (MCVertex*) NULL) );
1022     // The 2 adjacent edges have been merged together
1023 foucault 569 __mctChanges->E.insert( std::make_pair (edge[0], newMCEdge) );
1024 foucault 27 __mctChanges->E.insert( std::make_pair (edge[1], newMCEdge) );
1025     }
1026     }
1027     else if (g1vArc->Rank() == 0)
1028     { // case of a vertex isolated in the domain of a face
1029     _G10->RemoveArc(_G10->GetArc(__mcVertex->get_id()));
1030     _G20->RemoveArc(_G20->GetArc(__mcVertex->get_id()));
1031    
1032     if (__mctChanges)
1033     {
1034     // The mc vertex has been deleted
1035     __mctChanges->V.insert( std::make_pair (__mcVertex, (MCVertex*) NULL) );
1036     }
1037     }
1038     else
1039     {
1040 foucault 569 printf("Warning : MCBody can't delete vertex %d because its rank equals %d\n", g1vArc->Id(), g1vArc->Rank());
1041 foucault 27 }
1042     }
1043    
1044     void MCBody::MergeVertices(MCVertex * __deleteVertex, MCVertex * __targetVertex, std::set<MCEdge*> & edges)
1045     {
1046     int V1_id, V2_id;
1047     MCVertex * V1, * V2;
1048     Graph::Arc * V1_G10Arc, *V2_G10Arc, *V1_G20Arc, *V2_G20Arc;
1049     V1=__deleteVertex; V1_id=V1->get_id();
1050     V2=__targetVertex; V2_id=V2->get_id();
1051     V1_G10Arc=_G10->GetArc(V1_id);
1052     V1_G20Arc=_G20->GetArc(V1_id);
1053     V2_G10Arc=_G10->GetArc(V2_id);
1054     V2_G20Arc=_G20->GetArc(V2_id);
1055     Graph::Arc::MultimapNodesById V1_G10Arc_MapNodes = V1_G10Arc->Nodes();
1056     Graph::Arc::MultimapNodesById V1_G20Arc_MapNodes = V1_G20Arc->Nodes();
1057     Graph::Arc::MultimapNodesById::iterator itNode;
1058    
1059     // Initialize edge list
1060     for (itNode = V1_G10Arc_MapNodes.begin(); itNode != V1_G10Arc_MapNodes.end(); itNode++)
1061     {
1062     Graph::Node * n = itNode->second;
1063     MCEdge * e = GetMCEdge(n);
1064     edges.insert(e);
1065     }
1066     // Replace V1 by V2 in G20 and G10
1067     for (itNode = V1_G10Arc_MapNodes.begin(); itNode != V1_G10Arc_MapNodes.end(); itNode++)
1068     {
1069     Graph::Node * n = itNode->second;
1070     V2_G10Arc->Add(n);
1071     n->Add(V2_G10Arc);
1072     }
1073     _G10->RemoveArc(V1_G10Arc);
1074     for (itNode = V1_G20Arc_MapNodes.begin(); itNode != V1_G20Arc_MapNodes.end(); itNode++)
1075     {
1076     Graph::Node * n = itNode->second;
1077     V2_G20Arc->Add(n);
1078     n->Add(V2_G20Arc);
1079     }
1080     _G20->RemoveArc(V1_G20Arc);
1081    
1082     // replace each covertices to V1 by covertex to V2
1083     int i,N;
1084     N=V1->get_nb_mg_cosommet();
1085     for (i=0; i<N; i++)
1086     {
1087     MG_COSOMMET * cov = V1->get_mg_cosommet(i);
1088     MCEdge * e = (MCEdge*) cov->get_arete();
1089    
1090     cov = _refGeom->ajouter_mg_cosommet(e,V2);
1091    
1092     if (e->get_cosommet1()->get_sommet()==V1)
1093     e->changer_cosommet1(cov);
1094     else if (e->get_cosommet2()->get_sommet()==V1)
1095     e->changer_cosommet2(cov);
1096     }
1097    
1098     V2->Merge(V1);
1099     }
1100     /**
1101     * Edge collapse operator
1102     * arguments : name of the edge to be contracted, name of the vertex to contract the edge on
1103     *
1104     */
1105     void MCBody::ContractEdgeToVertex(MCEdge * __mcEdge, MCVertex * __targetVertex, std::set <MCEdge*> & newEdges, std::set<MCEdge*> & oldEdges)
1106     {
1107     // E3 = mcedge V3 = target vertex V4 = delete vertex
1108 foucault 569 printf("Contracting\tMC Edge \"%lu\" to MC Vertex \"%lu\"\n", __mcEdge->get_id(), __targetVertex->get_id());
1109 foucault 27
1110     MCVertex * V3 = __targetVertex, * V4;
1111     MCEdge * E3 = __mcEdge;
1112     int V4_id, V3_id, E3_id;
1113     Graph::Arc * V4_G10Arc, *V3_G10Arc, * V4_G20Arc, *V3_G20Arc, * E3_G21Arc;
1114     Graph::Node * E3_G10Node;
1115    
1116     V3_id = V3->get_id();
1117     V3_G10Arc = _G10->GetArc(V3_id);
1118     V3_G20Arc = _G20->GetArc(V3_id);
1119    
1120     E3_id = E3->get_id();
1121     E3_G10Node = _G10->GetNode(E3_id);
1122     E3_G21Arc = _G21->GetArc(E3_id);
1123    
1124     // Get G1 arc V4 the second incident arc to E3 different to V3
1125     for (Graph::Node::MultimapArcsById::const_iterator incidentArcIter = E3_G10Node->IncidentArcs().begin();
1126     incidentArcIter != E3_G10Node->IncidentArcs().end();
1127     incidentArcIter++)
1128     if (incidentArcIter->first != V3_id)
1129     V4_G10Arc = incidentArcIter->second;
1130     V4 = GetMCVertex(V4_G10Arc);
1131     V4_id = V4->get_id();
1132     V4_G20Arc = _G20->GetArc(V4_id);
1133    
1134     // Merge E3 with edges that are adjacent to V4
1135     // get the nodes of the arc
1136     Graph::Arc::MultimapNodesById initialV4Nodes = V4_G10Arc->Nodes();
1137     for (Graph::Arc::MultimapNodesById::const_iterator itNode = initialV4Nodes.begin();
1138     itNode != initialV4Nodes.end();
1139     itNode++)
1140     {
1141     int id = itNode->first;
1142    
1143     if (V4_G10Arc->IsLoopOfNode(id) || V3_G10Arc->IsLoopOfNode(E3_id)|| V4_G10Arc->IsLoopOfNode(E3_id) )
1144     {
1145     printf("Warning while Contracting\tMC Edge \"%d\" to MC Vertex \"%d\" \nArc %d is a loop of node %d\n",
1146     V4_id, E3_id, V3_id, id);
1147    
1148     return;
1149     }
1150     }
1151    
1152    
1153     for (Graph::Arc::MultimapNodesById::const_iterator itNode = initialV4Nodes.begin();
1154     itNode != initialV4Nodes.end();
1155     itNode++)
1156     {
1157     oldEdges.insert(GetMCEdge(itNode->second));
1158     }
1159    
1160     for (Graph::Arc::MultimapNodesById::const_iterator itNode = initialV4Nodes.begin();
1161     itNode != initialV4Nodes.end();
1162     itNode++)
1163     {
1164     int id = itNode->first;
1165     Graph::Node * node = itNode->second;
1166    
1167     if (id != E3_id)
1168     {
1169    
1170     // attach to the new node a MC edge attribute
1171     // constructed by the merge of the 2 edge attributes
1172     MCEdge * newEdge = AddMCEdge(GetMCEdge(id), E3);
1173     int newId = newEdge->get_id();
1174    
1175     Graph::Node * newG10Node = _G10->MergeNodes(node, E3_G10Node, newId, true);
1176     printf("Edge Contraction : merging edges %d and %d in new edge %d\n", node->Id(), E3_id, newId);
1177    
1178     // Create an edge in G2 named newVEdgeName and
1179     // conecting nodes n1_g2nodes
1180     Graph::Arc* newG21Arc = _G21->AddArc(newId, _G21->GetArc(id)->Nodes());
1181    
1182     newEdges.insert(newEdge);
1183     }
1184     }
1185     for (Graph::Arc::MultimapNodesById::const_iterator itNode = V4_G20Arc->Nodes().begin();
1186     itNode != V4_G20Arc->Nodes().end();
1187     itNode++)
1188     {
1189     Graph::Node * n = itNode->second;
1190     int idN = itNode->first;
1191     if (E3_G21Arc->Nodes().find(idN) == E3_G21Arc->Nodes().end())
1192     {
1193     V3_G20Arc->Add(n);
1194     n->Add(V3_G20Arc);
1195     }
1196     }
1197     for (Graph::Arc::MultimapNodesById::const_iterator itNode = initialV4Nodes.begin();
1198     itNode != initialV4Nodes.end();
1199     itNode++)
1200     {
1201     // in G1 : remove the old edges adjacent to v4
1202     _G10->RemoveNode(itNode->first);
1203    
1204     // In G2 :
1205     // remove the old edges adjacent to v4
1206     _G21->RemoveArc(itNode->first);
1207     }
1208    
1209     _G20->RemoveArc(V4_id);
1210     _G10->RemoveArc(V4_id);
1211    
1212     for (std::set<MCEdge*>::iterator itEdge=newEdges.begin();itEdge!=newEdges.end();itEdge++)
1213     {
1214     MCEdge * newEdge = *itEdge;
1215     Graph_SetUserData(newEdge);
1216     std::vector<MCVertex*> mcVertexExtremities;
1217     Edge_GetVertices(newEdge, mcVertexExtremities);
1218     AddMCEdgeCovertices(newEdge, mcVertexExtremities);
1219     }
1220    
1221     V3->Merge(V4);
1222     }
1223    
1224     void MCBody::Edge_GetVertices (MCEdge * __mcEdge, std::vector<MCVertex*> & __mcVertices)
1225     {
1226     // Get the incident G10 arcs to G10 node
1227     // they compose the loops of the MC face
1228    
1229     Graph::Node::MultimapArcsById & arcsOfG10Node = _G10->GetNode( __mcEdge->get_id() )->IncidentArcs();
1230    
1231     // Get each MC edge from incident arcs
1232     for ( Graph::Node::MultimapArcsById::const_iterator it = arcsOfG10Node.begin();
1233     it != arcsOfG10Node.end(); it++)
1234     {
1235     __mcVertices.push_back(GetMCVertex (it->second));
1236     }
1237     }
1238    
1239     std::set < MCFace * >
1240     MCBody::Edge_GetAdjacentFaces(MCEdge * __mcEdge)
1241     {
1242     std::set < MCFace * > result;
1243    
1244     // Get the G21 nodes to G21 arc
1245     // they compose the MC faces adjacent to the MC edge
1246     Graph::Arc *G21Arc = _G21->GetArc(__mcEdge->get_id());
1247    
1248     Graph::Arc::MultimapNodesById & nodesOfG21Arc = G21Arc->Nodes();
1249    
1250    
1251     for (Graph::Arc::MultimapNodesById::const_iterator it = nodesOfG21Arc.begin();
1252     it != nodesOfG21Arc.end();
1253     it++)
1254     {
1255    
1256     MCFace *mcFace = GetMCFace(it->second);
1257     result.insert( mcFace );
1258    
1259     }
1260    
1261     return result;
1262     }
1263    
1264    
1265     std::set < MCEdge * >
1266     MCBody::Face_GetAdjacentEdges(MCFace * __mcFace)
1267     {
1268     std::set < MCEdge * > result;
1269    
1270     // Get the G21 arcs to G21 node
1271     // they compose the MC edges adjacent to the MC face
1272     Graph::Node *G21Node = _G21->GetNode(__mcFace->get_id());
1273    
1274     Graph::Node::MultimapArcsById & arcsOfG21Node = G21Node->IncidentArcs();
1275    
1276    
1277     for (Graph::Node::MultimapArcsById::const_iterator it = arcsOfG21Node.begin();
1278     it != arcsOfG21Node.end();
1279     it++)
1280     {
1281    
1282     result.insert( GetMCEdge(it->second) );
1283    
1284     }
1285    
1286     return result;
1287     }
1288    
1289     std::vector < std::vector < MCEdge * > >
1290     MCBody::Face_GetUnsortedLoops(MCFace * __mcFace)
1291     {
1292     std::set < std::set < Graph::Node * > > loops;
1293     std::vector < std::vector < MCEdge * > > result;
1294    
1295     // Extract G 10 subgraph of this face
1296     Graph::Graph * G10 = Face_G10SubGraph(__mcFace);
1297    
1298     // Extract Strongly Connected Components
1299     // The SCC represent the BRep loop edges !
1300     std::set < std::set < Graph::Node * > > scc;
1301     Graph::FindSCC(G10,scc);
1302    
1303     for (std::set < std::set < Graph::Node * > >::iterator it1 = scc.begin();
1304     it1 != scc.end();
1305     it1++
1306     )
1307     {
1308     std::vector <MCEdge * > loop;
1309 foucault 176 const std::set < Graph::Node * > & loopNodes = *it1;
1310     for ( std::set < Graph::Node * >::const_iterator it2 = loopNodes.begin();
1311 foucault 27 it2 != loopNodes.end();
1312     it2++)
1313     {
1314     Graph::Node * node = *it2;
1315     MCEdge * mcEdge = GetMCEdge( node );
1316     loop.push_back(mcEdge);
1317     }
1318     result.push_back(loop);
1319     }
1320    
1321     delete G10;
1322     return result;
1323     }
1324    
1325     std::vector < std::vector < MCEdge * > >
1326     MCBody::Face_GetCycles(MCFace * __mcFace)
1327     {
1328     std::set < std::set < Graph::Node * > > loops;
1329     std::vector < std::vector < MCEdge * > > result;
1330    
1331     // Extract G 10 subgraph of this face
1332     Graph::Graph * G10 = Face_G10SubGraph(__mcFace);
1333    
1334     // Extract Graph cycles
1335     // The graph cycles represent loops which toopology is a circle !
1336     std::vector < std::vector < Graph::Node * > > cycles;
1337     Graph::FindCycles(G10,cycles);
1338    
1339     for (std::vector < std::vector < Graph::Node * > >::iterator it1 = cycles.begin();
1340     it1 != cycles.end();
1341     it1++
1342     )
1343     {
1344     std::vector <MCEdge * > mcEdgeLoop;
1345     std::vector < Graph::Node * > & cycleNodes = *it1;
1346     for ( std::vector < Graph::Node * >::iterator it2 = cycleNodes.begin();
1347     it2 != cycleNodes.end();
1348     it2++)
1349     {
1350     Graph::Node * node = *it2;
1351     MCEdge * mcEdge = GetMCEdge( node );
1352     mcEdgeLoop.push_back(mcEdge);
1353     }
1354     result.push_back(mcEdgeLoop);
1355     }
1356    
1357     for (Graph::Graph::MapNodesById::const_iterator itNode = G10->GetNodes().begin();
1358     itNode != G10->GetNodes().end();
1359     itNode++)
1360     {
1361     Graph::Node * node = itNode->second;
1362     for (Graph::Node::MultimapArcsById::const_iterator itArc = node->IncidentArcs().begin();
1363     itArc != node->IncidentArcs().end();
1364     itArc ++)
1365     {
1366     Graph::Arc * arc = itArc->second;
1367     if ( arc->IsLoopOfNode(node->Id()) )
1368     {
1369     std::vector < MCEdge * > loop;
1370     MCEdge * mcEdge = GetMCEdge(node);
1371     loop.push_back(mcEdge);
1372     result.push_back(loop);
1373     }
1374     }
1375     }
1376    
1377     delete G10;
1378     return result;
1379     }
1380     void MCBody::Face_GetMCVertices (MCFace * __mcFace, std::vector<MCVertex*> & __mcVertices)
1381     {
1382     // Get the incident G20 arcs to G20 node
1383     const Graph::Node::MultimapArcsById & arcsOfG20Node = _G20->GetNode(__mcFace->get_id())->IncidentArcs();
1384    
1385     // Get each MC edge from incident arcs
1386     for ( Graph::Node::MultimapArcsById::const_iterator it = arcsOfG20Node.begin();
1387     it != arcsOfG20Node.end(); it++)
1388     {
1389     __mcVertices.push_back(GetMCVertex (it->second));
1390     }
1391     }
1392    
1393     void MCBody::Vertex_GetAdjacentEdges(MCVertex * __mcVertex, std::vector<MCEdge *> & __list)
1394     {
1395     __list.clear();
1396    
1397     Graph::Arc * a = _G10->GetArc(__mcVertex->get_id());
1398     for (Graph::Arc::MultimapNodesById::const_iterator it = a->Nodes().begin();
1399     it != a->Nodes().end();
1400     it++)
1401 foucault 64 {
1402     MCEdge * mcEdge = GetMCEdge(it->second);
1403     __list.push_back(mcEdge);
1404     }
1405 foucault 27 }
1406    
1407     void MCBody::Vertex_GetAdjacentEdges(MCVertex * __mcVertex, std::set<MCEdge *> & __list)
1408     {
1409     __list.clear();
1410    
1411     Graph::Arc * a = _G10->GetArc( __mcVertex->get_id() );
1412     for (Graph::Arc::MultimapNodesById::const_iterator it = a->Nodes().begin();
1413     it != a->Nodes().end();
1414     it++)
1415 foucault 64 {
1416     MCEdge * mcEdge = GetMCEdge(it->second);
1417     __list.insert(mcEdge);
1418     }
1419 foucault 27 }
1420    
1421    
1422     void MCBody::Vertex_GetAdjacentFaces(MCVertex * __mcVertex, std::set<MCFace *> & __list)
1423     {
1424     __list.clear();
1425    
1426     Graph::Arc * a = _G20->GetArc(__mcVertex->get_id());
1427     for (Graph::Arc::MultimapNodesById::const_iterator it = a->Nodes().begin();
1428     it != a->Nodes().end();
1429     it++)
1430 foucault 64 {
1431     MCFace * mcFace = GetMCFace(it->second);
1432     __list.insert(mcFace);
1433     }
1434 foucault 27 }
1435     Graph::Graph * MCBody::Face_G10SubGraph(MCFace * __mcFace)
1436     {
1437     std::set < Graph::Node * > nodes;
1438     Graph::Graph * result;
1439    
1440     // Get the G21 arcs to G21 node
1441     // they compose the MC edges adjacent to the MC face
1442     Graph::Node *G21Node = _G21->GetNode( __mcFace->get_id() );
1443    
1444     Graph::Node::MultimapArcsById & arcsOfG21Node = G21Node->IncidentArcs();
1445    
1446    
1447     for (Graph::Node::MultimapArcsById::const_iterator it = arcsOfG21Node.begin();
1448     it != arcsOfG21Node.end();
1449     it++)
1450     {
1451     MCEdge * edge = GetMCEdge(it->second);
1452     Graph::Node * g10Node = _G10->GetNode(edge->get_id());
1453     nodes.insert(g10Node);
1454     }
1455    
1456     result = new Graph::Graph(*_G10,nodes);
1457    
1458     return result;
1459     }
1460    
1461     MG_COARETE * MCBody::CreateCoEdge(MCFace * mcFace, MG_BOUCLE * mcLoop, MCEdge * mcEdge, int sense)
1462     {
1463     MG_COARETE * mcCoEdge = _refGeom->ajouter_mg_coarete (mcEdge, mcLoop, sense);
1464     mcLoop->ajouter_mg_coarete(mcCoEdge);
1465     return mcCoEdge;
1466     }
1467     int MCBody::ExportBRep_MCEdgeSense(MCFace * mcFace, MCEdge * mcEdge)
1468     {
1469    
1470     // for each shell of the ref body
1471     unsigned nb_shells = _refBody->get_nb_mg_coquille ();
1472     for (unsigned it_shells = 0; it_shells < nb_shells; it_shells++)
1473     {
1474     MG_COQUILLE * shell = _refBody->get_mg_coquille(it_shells);
1475     // for each coface->face F of the shell
1476     unsigned nb_coface = shell->get_nb_mg_coface();
1477     for (unsigned it_coface = 0; it_coface < nb_coface; it_coface++)
1478     {
1479     MG_FACE * face = shell->get_mg_coface(it_coface)->get_face();
1480    
1481     if ( ! mcFace->GetPolySurface()->Contains(face) )
1482     continue;
1483    
1484     // for each loop L of this face
1485     unsigned nb_loop = face->get_nb_mg_boucle();
1486     for (unsigned it_loop = 0; it_loop < nb_loop; it_loop++)
1487     {
1488     MG_BOUCLE * loop = face->get_mg_boucle(it_loop);
1489     // for each coedge coe of L
1490     unsigned nb_edge = loop->get_nb_mg_coarete();
1491     for (unsigned it_edge = 0; it_edge < nb_edge; it_edge++)
1492     {
1493     MG_COARETE * coedge = loop->get_mg_coarete(it_edge);
1494     MG_ARETE * edge = coedge->get_arete();
1495    
1496     int iRefEdge = -1;
1497     for (int itRefEdge = 0; itRefEdge != mcEdge->GetPolyCurve()->GetRefEdgeCount(); itRefEdge++)
1498     {
1499    
1500     if (mcEdge->GetPolyCurve()->GetRefEdge(itRefEdge) == edge)
1501     {
1502     // Do not take reference edge if it is interior to the MC Face
1503     // (e.g. boundary edge contracted along an interior edge)
1504     int nbInteriorFaces = 0;
1505     for (int it_face2 = 0; it_face2 < edge->get_nb_mg_coarete(); it_face2++)
1506     {
1507     MG_FACE * face2 = edge->get_mg_coarete(it_face2)->get_boucle()->get_mg_face();
1508     if (mcFace->GetPolySurface()->Contains(face2))
1509     nbInteriorFaces ++;
1510     }
1511     if (nbInteriorFaces == 1)
1512     iRefEdge = itRefEdge;
1513     }
1514     }
1515    
1516     if ( iRefEdge != -1 )
1517     {
1518     MG_SOMMET * polycurveStartRefVertex = mcEdge->GetPolyCurve()->GetRefVertex(iRefEdge);
1519     MG_ARETE * polycurveStartRefEdge = mcEdge->GetPolyCurve()->GetRefEdge(iRefEdge);
1520    
1521     // Get the start vertex of this coedge
1522     // coedgeStartVertex = start ref vertex of coe1
1523     MG_SOMMET * coedgeStartVertex;
1524     if ( coedge->get_orientation() == 1)
1525     coedgeStartVertex = edge->get_cosommet1()->get_sommet();
1526     else
1527     coedgeStartVertex = edge->get_cosommet2()->get_sommet();
1528    
1529     //
1530     // sense = ( coedgeStartVertex != v1 ) ? -1 : 1 ;
1531     int sense;
1532     if ( polycurveStartRefVertex != edge->get_cosommet1()->get_sommet() )
1533     sense = -coedge->get_orientation();
1534     else
1535     sense = coedge->get_orientation();
1536    
1537     /*OT_VECTEUR_3D tangentPc, tangentRefEdge;
1538     PolyCurve * pc = mcEdge->GetPolyCurve();
1539     MG_SOMMET * polycurveStartRefVertex = pc->GetRefVertex(iRefEdge);
1540     MG_SOMMET * polycurveEndRefVertex = pc->GetRefVertex(iRefEdge+1);
1541     double sMid = .5*(pc->RefVertex_GetS(polycurveStartRefVertex)+pc->RefVertex_GetS(polycurveEndRefVertex));
1542     pc->deriver(sMid, tangentPc);
1543     double tMidRefEdge, dtMidRefEdge; MG_ARETE * tmpRefEdge;
1544     pc->Parameter_SToRefEdgeT(sMid, &tmpRefEdge, &tMidRefEdge, &dtMidRefEdge, false);
1545     tmpRefEdge->deriver(tMidRefEdge, tangentRefEdge);
1546    
1547     double fSense = tangentRefEdge * tangentPc;
1548     int sense;
1549     if ( fSense < 0 )
1550     sense = -coedge->get_orientation();
1551     else
1552     sense = coedge->get_orientation(); */
1553    
1554     return sense;
1555     }
1556     } // end for coedge
1557     } // end for face->loop
1558     } // end for coface
1559     } // end shell
1560    
1561 foucault 569 return -10000;
1562 foucault 27 }
1563     MG_VOLUME * MCBody::ExportBRep()
1564     {
1565     int i,j,k;
1566    
1567     std::ostringstream idBRepVolume;
1568     idBRepVolume << "MCBody of reference BRep "<< _refBody->get_idoriginal();
1569     _brep = new MG_VOLUME (idBRepVolume.str());
1570     _refGeom->ajouter_mg_volume(_brep);
1571    
1572     MG_COQUILLE * mcShell = new MG_COQUILLE(_brep);
1573     _refGeom->ajouter_mg_coquille(mcShell, _brep);
1574    
1575     {MCBODY_FOR_EACH_MCFACE(this, mcFace)
1576     {
1577     _refGeom->ajouter_mg_face(mcFace);
1578    
1579     MG_COFACE * mcCoFace = _refGeom->ajouter_mg_coface(mcFace, mcShell, 1);
1580     mcShell->ajouter_mg_coface(mcCoFace);
1581     MG_SURFACE * surface = mcFace->get_surface();
1582     _refGeom->ajouter_mg_surface(surface);
1583    
1584     std::set <MCEdge*> mcEdgeArray = Face_GetAdjacentEdges(mcFace);
1585     std::vector <MG_FACE*> faces;std::vector <MG_ARETE*> edges;std::vector <int> edgesense;
1586     for (std::set <MCEdge*>::iterator itEdge = mcEdgeArray.begin();
1587     itEdge != mcEdgeArray.end(); itEdge++)
1588     {
1589     MCEdge * mcEdge = *itEdge;
1590    
1591     bool boundaryEdge = (!_G21->GetArc(mcEdge->get_id())->IsLoop());
1592    
1593     // If the MC Edge is a boundary, then create an oriented coedge
1594     if (boundaryEdge)
1595     {
1596     faces.push_back(mcFace);
1597     edges.push_back(mcEdge);
1598     int sense = ExportBRep_MCEdgeSense(mcFace,mcEdge);
1599     edgesense.push_back(sense);
1600     }
1601     // If the MC Edge is interior, then create two coedges
1602     // with same sense and inverse sense
1603     else
1604     {
1605     faces.push_back(mcFace); faces.push_back(mcFace);
1606     edges.push_back(mcEdge);edges.push_back(mcEdge);
1607     edgesense.push_back(+1);edgesense.push_back(-1);
1608     }
1609     }
1610     std::vector < std::vector<CAD4FE::MakeLoops::CoEdge*> > loops;
1611     CAD4FE::MakeLoops makeLoops(faces,edges,edgesense);
1612     makeLoops.GetFaceLoops(mcFace,loops);
1613     for (unsigned k=0;k<loops.size();k++)
1614     {
1615     MG_BOUCLE * mcLoop = new MG_BOUCLE(mcFace);
1616     _refGeom->ajouter_mg_boucle(mcLoop, mcFace);
1617     for (unsigned l=0;l<loops[k].size();l++)
1618     {
1619     CAD4FE::MakeLoops::CoEdge* c = loops[k][l];
1620     CreateCoEdge(mcFace,mcLoop,(MCEdge*)c->Edge(),c->Sense());
1621     }
1622     }
1623     }}
1624    
1625 foucault 64 {MCBODY_FOR_EACH_MCVERTEX(this, mcVertex)
1626     {
1627     MCFace * mcFace = 0;
1628     int test = TestInteriorVertexIsolatedInFace(mcVertex, &mcFace);
1629     if (test)
1630     {
1631     ExportBRep_CreateInteriorVertexIsolatedInFace(mcVertex, mcFace);
1632     }
1633     }}
1634    
1635 foucault 27 return _brep;
1636     }
1637    
1638 foucault 64 int MCBody::TestInteriorVertexIsolatedInFace(MCVertex * __mcVertex, MCFace ** __mcFace)
1639     {
1640     std::set<MCFace*> adjacentFaces;
1641     Vertex_GetAdjacentFaces(__mcVertex, adjacentFaces);
1642     std::set<MCEdge*> adjacentEdges;
1643     Vertex_GetAdjacentEdges(__mcVertex, adjacentEdges);
1644 foucault 27
1645 foucault 64 if ( adjacentFaces.size() == 1 && adjacentEdges.size() == 0)
1646     {
1647     *__mcFace = *(adjacentFaces.begin());
1648     return 1;
1649     }
1650     else
1651     {
1652     *__mcFace = 0;
1653     return 0;
1654     }
1655     }
1656    
1657     int MCBody::ExportBRep_CreateInteriorVertexIsolatedInFace(MCVertex * __mcVertex, MCFace * __mcFace)
1658     {
1659     /*
1660 foucault 569 \item soit $RV$ le sommet r�f�rence du {\mcvertex} $V$,
1661     \item g�n�rer une {\mcedge}, not�e $E$, n'ayant aucune ar�te r�f�rence,
1662     mais contenant sommet r�f�rence $RV$,
1663     \item g�n�rer une coar�te $CE$ liant $E$ � $F$,
1664     \item ajouter � $F$ une boucle $B$ contenant $CE$
1665 foucault 64 */
1666     PolyCurve * edgeCurve = new PolyCurve(__mcVertex->GetRefVertex());
1667     MCEdge * edge = AddMCEdge(edgeCurve);
1668     std::vector<MCVertex*> edgeVertices;
1669     for (int i=0;i<2;i++) edgeVertices.push_back(__mcVertex);
1670     AddMCEdgeCovertices(edge,edgeVertices);
1671     MG_BOUCLE * mcLoop = new MG_BOUCLE(__mcFace);
1672     _refGeom->ajouter_mg_boucle(mcLoop, __mcFace);
1673     CreateCoEdge(__mcFace, mcLoop, edge, +1);
1674     return 1;
1675     }
1676    
1677     void MCBody::GetFEVCount(int * __faceCount,int * __edgeCount,int * __vertexCount)
1678     {
1679     * __faceCount = _G21->GetNodes().size();
1680     * __edgeCount = _G21->GetArcs().size();
1681     * __vertexCount = _G10->GetArcs().size();
1682     }
1683    
1684     void MCBody::GetRefBodyFEVCount(int * __faceCount,int * __edgeCount,int * __vertexCount)
1685     {
1686     MG_UTILS::GetFEVCount(_refBody,__faceCount,__edgeCount,__vertexCount);
1687     }
1688    
1689 foucault 27 int MCBody::DeleteBRep(MG_GESTIONNAIRE * gest, MG_GEOMETRIE * mggeo)
1690     {
1691     /// Lists of MCT entities
1692     std::set < CAD4FE::MCFace * > lst_mc_faces;
1693     std::set < CAD4FE::MCEdge * > lst_mc_edges;
1694     std::set < CAD4FE::MCVertex * > lst_mc_vertices;
1695     std::set < MG_COQUILLE * > lst_mc_shell;
1696     std::set < MG_BOUCLE * > lst_mc_loop;
1697    
1698     // initialize MC face, MC edge, MC loop, MC shell, and MC vertices lists
1699     unsigned nb_shells = _brep->get_nb_mg_coquille ();
1700     for (unsigned it_shells = 0; it_shells < nb_shells; it_shells++)
1701     {
1702     MG_COQUILLE * shell = _brep->get_mg_coquille(it_shells);
1703     lst_mc_shell.insert(shell);
1704     unsigned nb_coface = shell->get_nb_mg_coface();
1705     for (unsigned it_coface = 0; it_coface < nb_coface; it_coface++)
1706     {
1707     CAD4FE::MCFace * face = (CAD4FE::MCFace *)shell->get_mg_coface(it_coface)->get_face();
1708     lst_mc_faces.insert(face);
1709    
1710     unsigned nb_loop = face->get_nb_mg_boucle();
1711     for (unsigned it_loop = 0; it_loop < nb_loop; it_loop++)
1712     {
1713     MG_BOUCLE * loop = face->get_mg_boucle(it_loop);
1714     lst_mc_loop.insert(loop);
1715     unsigned nb_edge = loop->get_nb_mg_coarete();
1716    
1717     for (unsigned it_edge = 0; it_edge < nb_edge; it_edge++)
1718     {
1719     CAD4FE::MCEdge * edge = (CAD4FE::MCEdge*)loop->get_mg_coarete(it_edge)->get_arete();
1720     lst_mc_edges.insert(edge);
1721    
1722     lst_mc_vertices.insert ((CAD4FE::MCVertex*)edge->get_cosommet1()->get_sommet());
1723     lst_mc_vertices.insert ((CAD4FE::MCVertex*)edge->get_cosommet2()->get_sommet());
1724     }
1725     }
1726     }
1727     }
1728    
1729     for (unsigned i=0;i<gest->get_nb_mg_maillage();)
1730     {
1731     MG_MAILLAGE * tmpMesh = gest->get_mg_maillage(i);
1732     LISTE_MG_TRIANGLE::iterator itTri;
1733     for (MG_TRIANGLE * tri = tmpMesh->get_premier_triangle(itTri);
1734     tri; tri = tmpMesh->get_suivant_triangle(itTri))
1735     if (lst_mc_faces.end() != lst_mc_faces.find((CAD4FE::MCFace*)tri->get_lien_topologie()))
1736     tmpMesh->supprimer_mg_triangleid(tri->get_id());
1737     LISTE_MG_SEGMENT::iterator itSeg;
1738     for (MG_SEGMENT * seg = tmpMesh->get_premier_segment(itSeg);
1739     seg; seg=tmpMesh->get_suivant_segment(itSeg) )
1740     if (lst_mc_edges.end() != lst_mc_edges.find((CAD4FE::MCEdge*)seg->get_lien_topologie())
1741     || lst_mc_faces.end() != lst_mc_faces.find((CAD4FE::MCFace*)seg->get_lien_topologie())
1742     )
1743     tmpMesh->supprimer_mg_segmentid(seg->get_id());
1744     LISTE_MG_NOEUD::iterator itNo;
1745     for (MG_NOEUD * no = tmpMesh->get_premier_noeud(itNo);
1746     no; no=tmpMesh->get_suivant_noeud(itNo))
1747     if (
1748     lst_mc_vertices.end() != lst_mc_vertices.find((CAD4FE::MCVertex*)no->get_lien_topologie())
1749     || lst_mc_edges.end() != lst_mc_edges.find((CAD4FE::MCEdge*)no->get_lien_topologie())
1750     || lst_mc_faces.end() != lst_mc_faces.find((CAD4FE::MCFace*)no->get_lien_topologie())
1751     )
1752     tmpMesh->supprimer_mg_noeudid(no->get_id());
1753    
1754     if (tmpMesh->get_nb_mg_noeud() == 0)
1755     gest->supprimer_mg_maillage(i);
1756     else
1757     i++;
1758     }
1759     for (std::set < MG_COQUILLE * >::iterator itShell = lst_mc_shell.begin();
1760     itShell != lst_mc_shell.end();
1761     itShell++)
1762     mggeo->supprimer_mg_coquilleid((*itShell)->get_id());
1763     for (std::set<CAD4FE::MCFace *>::iterator itFace = lst_mc_faces.begin(); itFace != lst_mc_faces.end(); itFace++)
1764     {
1765     CAD4FE::MCFace* mcFace=*itFace;
1766     CAD4FE::PolySurface * ps = mcFace->GetPolySurface();
1767     mggeo->supprimer_mg_faceid(mcFace->get_id());
1768     mggeo->supprimer_mg_surfaceid(ps->get_id());
1769     }
1770     for (std::set < MG_BOUCLE * >::iterator itLoop = lst_mc_loop.begin();
1771     itLoop != lst_mc_loop.end();
1772     itLoop++)
1773     mggeo->supprimer_mg_boucleid((*itLoop)->get_id());
1774    
1775     for (std::set<CAD4FE::MCEdge *>::iterator itEdge = lst_mc_edges.begin(); itEdge != lst_mc_edges.end(); itEdge++)
1776     {
1777     CAD4FE::MCEdge* mcEdge=*itEdge;
1778     CAD4FE::PolyCurve * pc=mcEdge->GetPolyCurve();
1779     mggeo->supprimer_mg_areteid(mcEdge->get_id());
1780     mggeo->supprimer_mg_courbeid(pc->get_id());
1781     }
1782     for (std::set<CAD4FE::MCVertex *>::iterator itVertex = lst_mc_vertices.begin(); itVertex != lst_mc_vertices.end(); itVertex++)
1783     {
1784 francois 830 CAD4FE::MCVertex * mcVertex = *itVertex;
1785     mggeo->supprimer_mg_sommetid(mcVertex->get_id());
1786     }
1787    
1788     mggeo->supprimer_mg_volumeid(_brep->get_id());
1789    
1790     return 1;
1791    
1792 foucault 27 }