ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/mg_maillage.cpp
Revision: 466
Committed: Fri Nov 22 21:04:19 2013 UTC (11 years, 9 months ago) by francois
File size: 80133 byte(s)
Log Message:
erreur dans le terme structure corrige

File Contents

# Content
1 //------------------------------------------------------------
2 //------------------------------------------------------------
3 // MAGiC
4 // Jean Christophe Cuilli�re et Vincent FRANCOIS
5 // D�partement de G�nie M�canique - UQTR
6 //------------------------------------------------------------
7 // Le projet MAGIC est un projet de recherche du d�partement
8 // de g�nie m�canique de l'Universit� du Qu�bec �
9 // Trois Rivi�res
10 // Les librairies ne peuvent �tre utilis�es sans l'accord
11 // des auteurs (contact : francois@uqtr.ca)
12 //------------------------------------------------------------
13 //------------------------------------------------------------
14 //
15 // mg_maillage.cpp
16 //
17 //------------------------------------------------------------
18 //------------------------------------------------------------
19 // COPYRIGHT 2000
20 // Version du 02/03/2006 � 11H22
21 //------------------------------------------------------------
22 //------------------------------------------------------------
23
24
25 #include "gestionversion.h"
26 #include <fstream>
27 #include <iostream>
28
29
30 #include "mg_maillage.h"
31 #include "mg_gestionnaire.h"
32 #include "mc_gestionnaire.h"
33 #include "mc_propriete.h"
34 #include "mc_materiau.h"
35 #include "tpl_map_entite.h"
36 //#include "message.h"
37
38
39
40 int MG_MAILLAGE::DIMENSIONMAILLAGESANSTOPO=0;
41
42
43 MG_MAILLAGE::MG_MAILLAGE(MG_GEOMETRIE* geo):MG_IDENTIFICATEUR(),mg_geometrie(geo),est_structure(false)
44 {
45 }
46
47 MG_MAILLAGE::MG_MAILLAGE(unsigned long num,MG_GEOMETRIE* geo):MG_IDENTIFICATEUR(num),mg_geometrie(geo),est_structure(false)
48 {
49 }
50
51 MG_MAILLAGE* MG_MAILLAGE::dupliquer(MG_GESTIONNAIRE* gest)
52 {
53 MG_MAILLAGE* mgmai=new MG_MAILLAGE(this->get_mg_geometrie());
54 gest->ajouter_mg_maillage(mgmai);
55 long decalage=mgmai->get_id()-this->get_id();
56 LISTE_ENTITE::const_iterator i;
57 // D'abord les noeuds (les segments en dependent)
58 LISTE_MG_NOEUD::iterator itNo;
59 for (MG_NOEUD * noeud = get_premier_noeud(itNo); noeud; noeud=get_suivant_noeud(itNo))
60 noeud->dupliquer(mgmai,decalage);
61 // Ensuite les segments (les triangles en dependent)
62 LISTE_MG_SEGMENT::iterator itSeg;
63 for (MG_SEGMENT * segment = get_premier_segment(itSeg); segment; segment=get_suivant_segment(itSeg))
64 segment->dupliquer(mgmai,decalage);
65 // Ensuite les triangles (les tetra en dependent)
66 LISTE_MG_TRIANGLE::iterator itTri;
67 for (MG_TRIANGLE * triangle = get_premier_triangle(itTri); triangle; triangle=get_suivant_triangle(itTri))
68 triangle->dupliquer(mgmai,decalage);
69 // Pour finir les tetra
70 LISTE_MG_TETRA::iterator itTetra;
71 for (MG_TETRA * tetra = get_premier_tetra(itTetra); tetra; tetra=get_suivant_tetra(itTetra))
72 tetra->dupliquer(mgmai,decalage);
73 /* bug quand l'identificateur d'un triangle pr�c�de celui de ses segments
74 for (i=lst_entite.begin();i!=lst_entite.end();i++)
75 {
76 MG_ELEMENT_MAILLAGE& ele=(MG_ELEMENT_MAILLAGE&)(*(*i));
77 ele.dupliquer(mgmai,decalage);
78 }*/
79 int nb_segment = get_nb_mg_segment();
80 int nb_triangle = get_nb_mg_triangle();
81 int nb_tetra = get_nb_mg_tetra();
82
83 for (MG_TRIANGLE * triangle = get_premier_triangle(itTri); triangle; triangle=get_suivant_triangle(itTri))
84 {
85 MG_TRIANGLE * triangle2 = mgmai->get_mg_triangleid(triangle->get_id()+decalage);
86
87 TPL_LISTE_ENTITE< MG_TETRA*> * lst_lien_tetra = triangle->get_lien_tetra();
88 TPL_LISTE_ENTITE< MG_TETRA*> * lst_lien_tetra2 = triangle2->get_lien_tetra();
89 for (int it_tetra = 0; it_tetra != lst_lien_tetra->get_nb(); it_tetra++)
90 {
91 MG_TETRA * t = lst_lien_tetra->get(it_tetra);
92 MG_TETRA * t2 = mgmai->get_mg_tetraid( t->get_id() + decalage );
93
94 lst_lien_tetra2->ajouter ( t2 );
95 }
96 }
97
98 for (MG_SEGMENT * segment = get_premier_segment(itSeg); segment; segment=get_suivant_segment(itSeg))
99 {
100 MG_SEGMENT * segment2 = mgmai->get_mg_segmentid(segment->get_id()+decalage);
101
102 TPL_LISTE_ENTITE<MG_TRIANGLE*> * lst_lien_triangle = segment->get_lien_triangle();
103 TPL_LISTE_ENTITE<MG_TRIANGLE*> * lst_lien_triangle2 = segment2->get_lien_triangle();
104 for (int it_triang = 0; it_triang != lst_lien_triangle->get_nb(); it_triang++)
105 {
106 MG_TRIANGLE * t = lst_lien_triangle->get(it_triang);
107 MG_TRIANGLE * t2 = mgmai->get_mg_triangleid( t->get_id() + decalage );
108
109 lst_lien_triangle2->ajouter ( t2 );
110 }
111 }
112
113 for (MG_NOEUD * n = get_premier_noeud(itNo); n; n=get_suivant_noeud(itNo))
114 {
115 MG_NOEUD * n2 = mgmai->get_mg_noeudid(n->get_id()+decalage);
116
117 if (nb_segment != 0)
118 {
119 TPL_LISTE_ENTITE<MG_SEGMENT*> * lst_lien_segment = n->get_lien_segment();
120 TPL_LISTE_ENTITE<MG_SEGMENT*> * lst_lien_segment2 = n2->get_lien_segment();
121 for (int it_seg = 0; it_seg != lst_lien_segment->get_nb(); it_seg++)
122 {
123 MG_SEGMENT * seg = lst_lien_segment->get(it_seg);
124 MG_SEGMENT * seg2 = mgmai->get_mg_segmentid( seg->get_id() + decalage );
125
126 lst_lien_segment2->ajouter ( seg2 );
127 }
128
129 TPL_LISTE_ENTITE< MG_SEGMENT*> * lst_lien_petit_segment = n->get_lien_petit_segment();
130 TPL_LISTE_ENTITE< MG_SEGMENT*> * lst_lien_petit_segment2 = n2->get_lien_petit_segment();
131 for (int it_seg = 0; it_seg != lst_lien_petit_segment->get_nb(); it_seg++)
132 {
133 MG_SEGMENT * seg = lst_lien_petit_segment->get(it_seg);
134 MG_SEGMENT * seg2 = mgmai->get_mg_segmentid( seg->get_id() + decalage );
135
136 lst_lien_petit_segment2->ajouter ( seg2 );
137 }
138 }
139
140 if (nb_triangle != 0)
141 {
142 TPL_LISTE_ENTITE< MG_TRIANGLE*> * lst_lien_triangle = n->get_lien_triangle();
143 TPL_LISTE_ENTITE< MG_TRIANGLE*> * lst_lien_triangle2 = n2->get_lien_triangle();
144 for (int it_triang = 0; it_triang != lst_lien_triangle->get_nb(); it_triang++)
145 {
146 MG_TRIANGLE * t = lst_lien_triangle->get(it_triang);
147 MG_TRIANGLE * t2 = mgmai->get_mg_triangleid( t->get_id() + decalage );
148
149 lst_lien_triangle2->ajouter ( t2 );
150 }
151
152 TPL_LISTE_ENTITE< MG_TRIANGLE*> * lst_lien_petit_triangle = n->get_lien_petit_triangle();
153 TPL_LISTE_ENTITE< MG_TRIANGLE*> * lst_lien_petit_triangle2 = n2->get_lien_petit_triangle();
154 for (int it_triang = 0; it_triang != lst_lien_petit_triangle->get_nb(); it_triang++)
155 {
156 MG_TRIANGLE * t = lst_lien_petit_triangle->get(it_triang);
157 MG_TRIANGLE * t2 = mgmai->get_mg_triangleid( t->get_id() + decalage );
158
159 lst_lien_petit_triangle2->ajouter ( t2 );
160 }
161 }
162
163 if (nb_tetra != 0)
164 {
165 TPL_LISTE_ENTITE< MG_TETRA*> * lst_lien_tetra = n->get_lien_tetra();
166 TPL_LISTE_ENTITE< MG_TETRA*> * lst_lien_tetra2 = n2->get_lien_tetra();
167 for (int it_tetra = 0; it_tetra != lst_lien_tetra->get_nb(); it_tetra++)
168 {
169 MG_TETRA * t = lst_lien_tetra->get(it_tetra);
170 MG_TETRA * t2 = mgmai->get_mg_tetraid( t->get_id() + decalage );
171
172 lst_lien_tetra2->ajouter ( t2 );
173 }
174
175 TPL_LISTE_ENTITE< MG_TETRA*> * lst_lien_petit_tetra = n->get_lien_petit_tetra();
176 TPL_LISTE_ENTITE< MG_TETRA*> * lst_lien_petit_tetra2 = n2->get_lien_petit_tetra();
177 for (int it_tetra = 0; it_tetra != lst_lien_petit_tetra->get_nb(); it_tetra++)
178 {
179 MG_TETRA * t = lst_lien_petit_tetra->get(it_tetra);
180 MG_TETRA * t2 = mgmai->get_mg_tetraid( t->get_id() + decalage );
181
182 lst_lien_petit_tetra2->ajouter ( t2 );
183 }
184 }
185
186 }
187
188 return mgmai;
189 }
190
191
192 MG_MAILLAGE::~MG_MAILLAGE()
193 {
194 supprimer_tout_mg_tetra();
195 supprimer_tout_mg_triangle();
196 supprimer_tout_mg_segment();
197 supprimer_tout_mg_noeud();
198 }
199
200 MG_GEOMETRIE* MG_MAILLAGE::get_mg_geometrie(void)
201 {
202 return mg_geometrie;
203 }
204
205
206 void MG_MAILLAGE::change_gestionnaire(MG_GESTIONNAIRE* mggest)
207 {
208 gest=mggest;
209 }
210
211 // ENTITE MG_NOEUD
212 MG_NOEUD* MG_MAILLAGE::ajouter_mg_noeud(MG_ELEMENT_TOPOLOGIQUE* topo,double xx,double yy,double zz,int origine,unsigned long num)
213 {
214 MG_NOEUD* mgnoeud;
215 if (num==0) mgnoeud=new MG_NOEUD(topo,xx,yy,zz,origine);
216 else mgnoeud=new MG_NOEUD(num,topo,xx,yy,zz,origine);
217 int resultat = ajouter_mg_noeud(mgnoeud);
218 if (resultat==FAIL)
219 {
220 delete mgnoeud;
221 return NULL;
222 }
223 return mgnoeud;
224 }
225
226 int MG_MAILLAGE::ajouter_mg_noeud(MG_NOEUD *mgnoeud)
227 {
228 gest->recherche_bonid(*mgnoeud);
229 MG_IDENTIFICATEUR *id=mgnoeud;
230 std::pair<LISTE_ENTITE::iterator,bool> p=lst_entite.insert(id);
231 if (!p.second)
232 {
233 // afficheur << ENTITEID << id->get_id() << DUPLIQUE << enderr;
234 return FAIL;
235 }
236
237 std::pair<const unsigned long,MG_NOEUD*> tmp(mgnoeud->get_id(),mgnoeud);
238 lst_mg_noeud.insert(tmp);
239 return OK;
240 }
241
242
243 MG_NOEUD* MG_MAILLAGE::get_mg_noeudid(unsigned long num)
244 {
245 LISTE_MG_NOEUD::iterator i=lst_mg_noeud.find(num);
246 if (i==lst_mg_noeud.end())
247 {
248 // afficheur << INEXISTE << enderr;
249 return NULL;
250 }
251 return ((*i).second);
252 }
253
254
255
256 MG_NOEUD* MG_MAILLAGE::get_mg_noeud(unsigned int num)
257 {
258 if (!(num<lst_mg_noeud.size()))
259 {
260 // afficheur << INEXISTE << enderr;
261 return NULL;
262 }
263 LISTE_MG_NOEUD::iterator i=lst_mg_noeud.begin();
264 for (unsigned long j=0;j<num;j++) i++;
265 return ((*i).second);
266 }
267
268
269
270 unsigned int MG_MAILLAGE::get_nb_mg_noeud(void)
271 {
272 return lst_mg_noeud.size();
273 }
274
275
276 int MG_MAILLAGE::supprimer_mg_noeudid(unsigned long num)
277 {
278 MG_NOEUD* mgnoeud=get_mg_noeudid(num);
279 if (mgnoeud==NULL)
280 {
281 // afficheur << INEXISTE2 << enderr;
282 return FAIL;
283 }
284 if (mgnoeud->get_lien_segment()->get_nb())
285 {
286 // afficheur << ERRNOEUDSEGMENT << mgnoeud->get_id() << enderr;
287 return FAIL;
288 }
289 if (mgnoeud->get_lien_triangle()->get_nb())
290 {
291 // afficheur << ERRNOEUDTRIANGLE << mgnoeud->get_id() << enderr;
292 return FAIL;
293 }
294 MG_IDENTIFICATEUR* id=mgnoeud;
295 LISTE_ENTITE::iterator i=lst_entite.find(id);
296 lst_entite.erase(i);
297 LISTE_MG_NOEUD::iterator j=lst_mg_noeud.find(num);
298 lst_mg_noeud.erase(j);
299 delete mgnoeud;
300 return OK;
301 }
302
303
304 int MG_MAILLAGE::supprimer_mg_noeud(unsigned int num)
305 {
306 MG_NOEUD* mgnoeud=get_mg_noeud(num);
307 if (mgnoeud==NULL)
308 {
309 // afficheur << INEXISTE2 << enderr;
310 return FAIL;
311 }
312 if (mgnoeud->get_lien_segment()->get_nb())
313 {
314 // afficheur << ERRNOEUDSEGMENT << mgnoeud->get_id() << enderr;
315 return FAIL;
316 }
317 if (mgnoeud->get_lien_triangle()->get_nb())
318 {
319 // afficheur << ERRNOEUDTRIANGLE << mgnoeud->get_id() << enderr;
320 return FAIL;
321 }
322 MG_IDENTIFICATEUR* id=mgnoeud;
323 LISTE_ENTITE::iterator i=lst_entite.find(id);
324 lst_entite.erase(i);
325 LISTE_MG_NOEUD::iterator j=lst_mg_noeud.begin();
326 for (unsigned int k=0;k<num;k++) j++;
327 lst_mg_noeud.erase(j);
328 delete mgnoeud;
329 return OK;
330 }
331
332
333 void MG_MAILLAGE::supprimer_tout_mg_noeud(void)
334 {
335 while (get_nb_mg_noeud()!=0)
336 {
337 LISTE_MG_NOEUD::iterator j=lst_mg_noeud.begin();
338 MG_NOEUD* mgnoeud=(*j).second;
339 MG_IDENTIFICATEUR* id=mgnoeud;
340 LISTE_ENTITE::iterator i=lst_entite.find(id);
341 lst_entite.erase(i);
342 lst_mg_noeud.erase(j);
343 delete mgnoeud;
344 }
345 }
346
347
348 MG_NOEUD* MG_MAILLAGE::get_premier_noeud(LISTE_MG_NOEUD::iterator & it)
349 {
350 it = lst_mg_noeud.begin();
351 if (it == lst_mg_noeud.end())
352 return NULL;
353 return it->second;
354 }
355
356 MG_NOEUD* MG_MAILLAGE::get_suivant_noeud(LISTE_MG_NOEUD::iterator & it)
357 {
358 it++;
359 if (it == lst_mg_noeud.end())
360 return NULL;
361 return it->second;
362 }
363
364
365 // ENTITE MG_SEGMENT
366 MG_SEGMENT* MG_MAILLAGE::ajouter_mg_segment(MG_ELEMENT_TOPOLOGIQUE* topo,class MG_NOEUD *mgnoeud1,class MG_NOEUD *mgnoeud2,int origine,double longue,unsigned long num)
367 {
368 MG_SEGMENT* mgsegment;
369 if (num==0) mgsegment=new MG_SEGMENT(topo,mgnoeud1,mgnoeud2,origine,longue);
370 else mgsegment=new MG_SEGMENT(num,topo,mgnoeud1,mgnoeud2,origine,longue);
371 int resultat=ajouter_mg_segment(mgsegment);
372 if (resultat==FAIL)
373 {
374 delete mgsegment;
375 return NULL;
376 }
377 return mgsegment;
378 }
379
380 int MG_MAILLAGE::ajouter_mg_segment(MG_SEGMENT *mgsegment)
381 {
382 gest->recherche_bonid(*mgsegment);
383 MG_IDENTIFICATEUR *id=mgsegment;
384 std::pair<LISTE_ENTITE::iterator,bool> p=lst_entite.insert(id);
385 if (!p.second)
386 {
387 // afficheur << ENTITEID << id->get_id() << DUPLIQUE << enderr;
388 return FAIL;
389 }
390
391 std::pair<const unsigned long,MG_SEGMENT*> tmp(mgsegment->get_id(),mgsegment);
392 lst_mg_segment.insert(tmp);
393 return OK;
394 }
395
396
397 MG_SEGMENT* MG_MAILLAGE::get_mg_segmentid(unsigned long num)
398 {
399 LISTE_MG_SEGMENT::iterator i=lst_mg_segment.find(num);
400 if (i==lst_mg_segment.end())
401 {
402 // afficheur << INEXISTE << enderr;
403 return NULL;
404 }
405 return ((*i).second);
406 }
407
408 MG_SEGMENT* MG_MAILLAGE::get_mg_segment(unsigned long noeud1id,unsigned long noeud2id)
409 {
410 unsigned long id=std::min(noeud1id,noeud2id);
411 MG_NOEUD* noeud=get_mg_noeudid(id);
412 int nb_segment=noeud->get_lien_petit_segment()->get_nb();
413 for (int i=0;i<nb_segment;i++)
414 {
415 MG_SEGMENT* mgsegment=noeud->get_lien_petit_segment()->get(i);
416 if ( (mgsegment->get_noeud1()->get_id()==noeud1id) && (mgsegment->get_noeud2()->get_id()==noeud2id) ) return mgsegment;
417 if ( (mgsegment->get_noeud2()->get_id()==noeud1id) && (mgsegment->get_noeud1()->get_id()==noeud2id) ) return mgsegment;
418 }
419 return NULL;
420 }
421
422 MG_SEGMENT* MG_MAILLAGE::get_mg_segment(unsigned int num)
423 {
424 if (!(num<lst_mg_segment.size()))
425 {
426 // afficheur << INEXISTE << enderr;
427 return NULL;
428 }
429 LISTE_MG_SEGMENT::iterator i=lst_mg_segment.begin();
430 //for (unsigned long j=0;j<num;j++) i++;
431 std::advance(i,num);
432 return ((*i).second);
433 }
434
435 MG_SEGMENT* MG_MAILLAGE::get_premier_segment(LISTE_MG_SEGMENT::iterator & it)
436 {
437 it = lst_mg_segment.begin();
438 if (it == lst_mg_segment.end())
439 return NULL;
440 return it->second;
441 }
442
443 MG_SEGMENT* MG_MAILLAGE::get_suivant_segment(LISTE_MG_SEGMENT::iterator & it)
444 {
445 it++;
446 if (it == lst_mg_segment.end())
447 return NULL;
448 return it->second;
449 }
450
451 unsigned int MG_MAILLAGE::get_nb_mg_segment(void)
452 {
453 return lst_mg_segment.size();
454 }
455
456
457 int MG_MAILLAGE::supprimer_mg_segmentid(unsigned long num)
458 {
459 MG_SEGMENT* mgsegment=get_mg_segmentid(num);
460 if (mgsegment==NULL)
461 {
462 // afficheur << INEXISTE2 << enderr;
463 return FAIL;
464 }
465 MG_IDENTIFICATEUR* id=mgsegment;
466 LISTE_ENTITE::iterator i=lst_entite.find(id);
467 lst_entite.erase(i);
468 LISTE_MG_SEGMENT::iterator j=lst_mg_segment.find(num);
469 lst_mg_segment.erase(j);
470 MG_NOEUD* noeud1=mgsegment->get_noeud1();
471 MG_NOEUD* noeud2=mgsegment->get_noeud2();
472 delete mgsegment;
473 if (noeud1->get_nb_reference()==0)
474 if (noeud1->get_lien_topologie()!=NULL)
475 {
476 if (noeud1->get_lien_topologie()->get_dimension()>0) supprimer_mg_noeudid(noeud1->get_id());
477 }
478 else supprimer_mg_noeudid(noeud1->get_id());
479 if (noeud2->get_nb_reference()==0)
480 if (noeud2->get_lien_topologie()!=NULL)
481 {
482 if (noeud2->get_lien_topologie()->get_dimension()>0) supprimer_mg_noeudid(noeud2->get_id());
483 }
484 else supprimer_mg_noeudid(noeud2->get_id());
485 return OK;
486 }
487
488
489 int MG_MAILLAGE::supprimer_mg_segment(unsigned int num)
490 {
491 MG_SEGMENT* mgsegment=get_mg_segment(num);
492 if (mgsegment==NULL)
493 {
494 // afficheur << INEXISTE2 << enderr;
495 return FAIL;
496 }
497 MG_IDENTIFICATEUR* id=mgsegment;
498 LISTE_ENTITE::iterator i=lst_entite.find(id);
499 lst_entite.erase(i);
500 LISTE_MG_SEGMENT::iterator j=lst_mg_segment.begin();
501 for (unsigned int k=0;k<num;k++) j++;
502 lst_mg_segment.erase(j);
503 MG_NOEUD* noeud1=mgsegment->get_noeud1();
504 MG_NOEUD* noeud2=mgsegment->get_noeud2();
505 delete mgsegment;
506 if (noeud1->get_nb_reference()==0)
507 if (noeud1->get_lien_topologie()!=NULL)
508 {
509 if (noeud1->get_lien_topologie()->get_dimension()>0) supprimer_mg_noeudid(noeud1->get_id());
510 }
511 else supprimer_mg_noeudid(noeud1->get_id());
512 if (noeud2->get_nb_reference()==0)
513 if (noeud2->get_lien_topologie()!=NULL)
514 {
515 if (noeud2->get_lien_topologie()->get_dimension()>0) supprimer_mg_noeudid(noeud2->get_id());
516 }
517 else supprimer_mg_noeudid(noeud2->get_id());
518 return OK;
519 }
520
521
522 void MG_MAILLAGE::supprimer_tout_mg_segment(void)
523 {
524 while (get_nb_mg_segment()!=0)
525 {
526 LISTE_MG_SEGMENT::iterator j=lst_mg_segment.begin();
527 MG_SEGMENT* mgsegment=(*j).second;
528 MG_IDENTIFICATEUR* id=mgsegment;
529 LISTE_ENTITE::iterator i=lst_entite.find(id);
530 lst_entite.erase(i);
531 lst_mg_segment.erase(j);
532 delete mgsegment;
533 }
534
535 }
536
537 // ENTITE MG_TRIANGLE
538
539 MG_TRIANGLE* MG_MAILLAGE::ajouter_mg_triangle(MG_ELEMENT_TOPOLOGIQUE* topo,class MG_NOEUD *mgnoeud1,class MG_NOEUD *mgnoeud2,class MG_NOEUD *mgnoeud3,int origine,unsigned long num)
540 {
541 MG_SEGMENT* mgsegment1=get_mg_segment(mgnoeud1->get_id(),mgnoeud2->get_id());
542 MG_SEGMENT* mgsegment2=get_mg_segment(mgnoeud2->get_id(),mgnoeud3->get_id());
543 MG_SEGMENT* mgsegment3=get_mg_segment(mgnoeud3->get_id(),mgnoeud1->get_id());
544 if (mgsegment1==NULL) mgsegment1=ajouter_mg_segment(topo,mgnoeud1,mgnoeud2,origine);
545 if (mgsegment2==NULL) mgsegment2=ajouter_mg_segment(topo,mgnoeud2,mgnoeud3,origine);
546 if (mgsegment3==NULL) mgsegment3=ajouter_mg_segment(topo,mgnoeud3,mgnoeud1,origine);
547 MG_TRIANGLE* mgtriangle;
548 if (num==0) mgtriangle=new MG_TRIANGLE(topo,mgnoeud1,mgnoeud2,mgnoeud3,mgsegment1,mgsegment2,mgsegment3,origine);
549 else mgtriangle=new MG_TRIANGLE(num,topo,mgnoeud1,mgnoeud2,mgnoeud3,mgsegment1,mgsegment2,mgsegment3,origine);
550 int resultat=ajouter_mg_triangle(mgtriangle);
551 if (resultat==FAIL)
552 {
553 delete mgtriangle;
554 return NULL;
555 }
556 return mgtriangle;
557 }
558
559
560 int MG_MAILLAGE::ajouter_mg_triangle(MG_TRIANGLE *mgtriangle)
561 {
562 gest->recherche_bonid(*mgtriangle);
563 MG_IDENTIFICATEUR *id=mgtriangle;
564 std::pair<LISTE_ENTITE::iterator,bool> p=lst_entite.insert(id);
565 if (!p.second)
566 {
567 // afficheur << ENTITEID << id->get_id() << DUPLIQUE << enderr;
568 return FAIL;
569 }
570
571 std::pair<const unsigned long,MG_TRIANGLE*> tmp(mgtriangle->get_id(),mgtriangle);
572 lst_mg_triangle.insert(tmp);
573 return OK;
574 }
575
576
577 MG_TRIANGLE* MG_MAILLAGE::get_mg_triangleid(unsigned long num)
578 {
579 LISTE_MG_TRIANGLE::iterator i=lst_mg_triangle.find(num);
580 if (i==lst_mg_triangle.end())
581 {
582 // afficheur << INEXISTE << enderr;
583 return NULL;
584 }
585 return ((*i).second);
586 }
587
588
589
590 MG_TRIANGLE* MG_MAILLAGE::get_mg_triangle(unsigned int num)
591 {
592 if (!(num<lst_mg_triangle.size()))
593 {
594 // afficheur << INEXISTE << enderr;
595 return NULL;
596 }
597 LISTE_MG_TRIANGLE::iterator i=lst_mg_triangle.begin();
598 for (unsigned long j=0;j<num;j++) i++;
599 return ((*i).second);
600 }
601
602 MG_TRIANGLE* MG_MAILLAGE::get_mg_triangle(unsigned long noeud1id,unsigned long noeud2id,unsigned long noeud3id)
603 {
604 unsigned long id=std::min(noeud1id,noeud2id);
605 id=std::min(id,noeud3id);
606 MG_NOEUD* noeud=get_mg_noeudid(id);
607 int nb_triangle=noeud->get_lien_petit_triangle()->get_nb();
608 for (int i=0;i<nb_triangle;i++)
609 {
610 MG_TRIANGLE* mgtriangle=noeud->get_lien_petit_triangle()->get(i);
611 if ( (mgtriangle->get_noeud1()->get_id()==noeud1id) && (mgtriangle->get_noeud2()->get_id()==noeud2id) && (mgtriangle->get_noeud3()->get_id()==noeud3id) ) return mgtriangle;
612 if ( (mgtriangle->get_noeud1()->get_id()==noeud1id) && (mgtriangle->get_noeud2()->get_id()==noeud3id) && (mgtriangle->get_noeud3()->get_id()==noeud2id) ) return mgtriangle;
613 if ( (mgtriangle->get_noeud1()->get_id()==noeud2id) && (mgtriangle->get_noeud2()->get_id()==noeud1id) && (mgtriangle->get_noeud3()->get_id()==noeud3id) ) return mgtriangle;
614 if ( (mgtriangle->get_noeud1()->get_id()==noeud2id) && (mgtriangle->get_noeud2()->get_id()==noeud3id) && (mgtriangle->get_noeud3()->get_id()==noeud1id) ) return mgtriangle;
615 if ( (mgtriangle->get_noeud1()->get_id()==noeud3id) && (mgtriangle->get_noeud2()->get_id()==noeud1id) && (mgtriangle->get_noeud3()->get_id()==noeud2id) ) return mgtriangle;
616 if ( (mgtriangle->get_noeud1()->get_id()==noeud3id) && (mgtriangle->get_noeud2()->get_id()==noeud2id) && (mgtriangle->get_noeud3()->get_id()==noeud1id) ) return mgtriangle;
617 }
618 return NULL;
619 }
620
621 unsigned int MG_MAILLAGE::get_nb_mg_triangle(void)
622 {
623 return lst_mg_triangle.size();
624 }
625
626
627 int MG_MAILLAGE::supprimer_mg_triangleid(unsigned long num)
628 {
629 MG_TRIANGLE* mgtriangle=get_mg_triangleid(num);
630 if (mgtriangle==NULL)
631 {
632 // afficheur << INEXISTE2 << enderr;
633 return FAIL;
634 }
635 MG_IDENTIFICATEUR* id=mgtriangle;
636 LISTE_ENTITE::iterator i=lst_entite.find(id);
637 lst_entite.erase(i);
638 LISTE_MG_TRIANGLE::iterator j=lst_mg_triangle.find(num);
639 lst_mg_triangle.erase(j);
640 MG_SEGMENT* segment1=mgtriangle->get_segment1();
641 MG_SEGMENT* segment2=mgtriangle->get_segment2();
642 MG_SEGMENT* segment3=mgtriangle->get_segment3();
643 delete mgtriangle;
644 if (segment1->get_nb_reference()==0)
645 if (segment1->get_lien_topologie()!=NULL)
646 {
647 if (segment1->get_lien_topologie()->get_dimension()>1) supprimer_mg_segmentid(segment1->get_id());
648 }
649 else supprimer_mg_segmentid(segment1->get_id());
650 if (segment2->get_nb_reference()==0)
651 if (segment2->get_lien_topologie()!=NULL)
652 {
653 if (segment2->get_lien_topologie()->get_dimension()>1) supprimer_mg_segmentid(segment2->get_id());
654 }
655 else supprimer_mg_segmentid(segment2->get_id());
656 if (segment3->get_nb_reference()==0)
657 if (segment3->get_lien_topologie()!=NULL)
658 {
659 if (segment3->get_lien_topologie()->get_dimension()>1) supprimer_mg_segmentid(segment3->get_id());
660 }
661 else supprimer_mg_segmentid(segment3->get_id());
662 return OK;
663 }
664
665
666 int MG_MAILLAGE::supprimer_mg_triangle(unsigned int num)
667 {
668 MG_TRIANGLE* mgtriangle=get_mg_triangle(num);
669 if (mgtriangle==NULL)
670 {
671 // afficheur << INEXISTE2 << enderr;
672 return FAIL;
673 }
674 MG_IDENTIFICATEUR* id=mgtriangle;
675 LISTE_ENTITE::iterator i=lst_entite.find(id);
676 lst_entite.erase(i);
677 LISTE_MG_TRIANGLE::iterator j=lst_mg_triangle.begin();
678 for (unsigned int k=0;k<num;k++) j++;
679 lst_mg_triangle.erase(j);
680 MG_SEGMENT* segment1=mgtriangle->get_segment1();
681 MG_SEGMENT* segment2=mgtriangle->get_segment2();
682 MG_SEGMENT* segment3=mgtriangle->get_segment3();
683 delete mgtriangle;
684 if (segment1->get_nb_reference()==0)
685 if (segment1->get_lien_topologie()!=NULL)
686 {
687 if (segment1->get_lien_topologie()->get_dimension()>1) supprimer_mg_segmentid(segment1->get_id());
688 }
689 else supprimer_mg_segmentid(segment1->get_id());
690 if (segment2->get_nb_reference()==0)
691 if (segment2->get_lien_topologie()!=NULL)
692 {
693 if (segment2->get_lien_topologie()->get_dimension()>1) supprimer_mg_segmentid(segment2->get_id());
694 }
695 else supprimer_mg_segmentid(segment2->get_id());
696 if (segment3->get_nb_reference()==0)
697 if (segment3->get_lien_topologie()!=NULL)
698 {
699 if (segment3->get_lien_topologie()->get_dimension()>1) supprimer_mg_segmentid(segment3->get_id());
700 }
701 else supprimer_mg_segmentid(segment3->get_id());
702 return OK;
703 }
704
705
706 void MG_MAILLAGE::supprimer_tout_mg_triangle(void)
707 {
708 while (get_nb_mg_triangle()!=0)
709 {
710 LISTE_MG_TRIANGLE::iterator j=lst_mg_triangle.begin();
711 MG_TRIANGLE* mgtriangle=(*j).second;
712 MG_IDENTIFICATEUR* id=mgtriangle;
713 LISTE_ENTITE::iterator i=lst_entite.find(id);
714 lst_entite.erase(i);
715 lst_mg_triangle.erase(j);
716 delete mgtriangle;
717 }
718 }
719
720
721 MG_TRIANGLE* MG_MAILLAGE::get_premier_triangle(LISTE_MG_TRIANGLE::iterator & it)
722 {
723 it = lst_mg_triangle.begin();
724 if (it == lst_mg_triangle.end())
725 return NULL;
726 return it->second;
727 }
728
729 MG_TRIANGLE* MG_MAILLAGE::get_suivant_triangle(LISTE_MG_TRIANGLE::iterator & it)
730 {
731 it++;
732 if (it == lst_mg_triangle.end())
733 return NULL;
734 return it->second;
735 }
736
737
738 // ENTITE MG_QUADRANGLE
739
740 MG_QUADRANGLE* MG_MAILLAGE::ajouter_mg_quadrangle(MG_ELEMENT_TOPOLOGIQUE* topo,class MG_NOEUD *mgnoeud1,class MG_NOEUD *mgnoeud2,class MG_NOEUD *mgnoeud3,class MG_NOEUD *mgnoeud4,int origine,unsigned long num)
741 {
742 MG_SEGMENT* mgsegment1=get_mg_segment(mgnoeud1->get_id(),mgnoeud2->get_id());
743 MG_SEGMENT* mgsegment2=get_mg_segment(mgnoeud2->get_id(),mgnoeud3->get_id());
744 MG_SEGMENT* mgsegment3=get_mg_segment(mgnoeud3->get_id(),mgnoeud4->get_id());
745 MG_SEGMENT* mgsegment4=get_mg_segment(mgnoeud4->get_id(),mgnoeud1->get_id());
746 if (mgsegment1==NULL) mgsegment1=ajouter_mg_segment(topo,mgnoeud1,mgnoeud2,origine);
747 if (mgsegment2==NULL) mgsegment2=ajouter_mg_segment(topo,mgnoeud2,mgnoeud3,origine);
748 if (mgsegment3==NULL) mgsegment3=ajouter_mg_segment(topo,mgnoeud3,mgnoeud4,origine);
749 if (mgsegment4==NULL) mgsegment4=ajouter_mg_segment(topo,mgnoeud4,mgnoeud1,origine);
750 MG_QUADRANGLE* mgquadrangle;
751 if (num==0) mgquadrangle=new MG_QUADRANGLE(topo,mgnoeud1,mgnoeud2,mgnoeud3,mgnoeud4,mgsegment1,mgsegment2,mgsegment3,mgsegment4,origine);
752 else mgquadrangle=new MG_QUADRANGLE(num,topo,mgnoeud1,mgnoeud2,mgnoeud3,mgnoeud4,mgsegment1,mgsegment2,mgsegment3,mgsegment4,origine);
753 int resultat=ajouter_mg_quadrangle(mgquadrangle);
754 if (resultat==FAIL)
755 {
756 delete mgquadrangle;
757 return NULL;
758 }
759 return mgquadrangle;
760 }
761
762
763 int MG_MAILLAGE::ajouter_mg_quadrangle(MG_QUADRANGLE *mgquadrangle)
764 {
765 gest->recherche_bonid(*mgquadrangle);
766 MG_IDENTIFICATEUR *id=mgquadrangle;
767 std::pair<LISTE_ENTITE::iterator,bool> p=lst_entite.insert(id);
768 if (!p.second)
769 {
770 // afficheur << ENTITEID << id->get_id() << DUPLIQUE << enderr;
771 return FAIL;
772 }
773
774 std::pair<const unsigned long,MG_QUADRANGLE*> tmp(mgquadrangle->get_id(),mgquadrangle);
775 lst_mg_quadrangle.insert(tmp);
776 return OK;
777 }
778
779
780 MG_QUADRANGLE* MG_MAILLAGE::get_mg_quadrangleid(unsigned long num)
781 {
782 LISTE_MG_QUADRANGLE::iterator i=lst_mg_quadrangle.find(num);
783 if (i==lst_mg_quadrangle.end())
784 {
785 // afficheur << INEXISTE << enderr;
786 return NULL;
787 }
788 return ((*i).second);
789 }
790
791
792
793 MG_QUADRANGLE* MG_MAILLAGE::get_mg_quadrangle(unsigned int num)
794 {
795 if (!(num<lst_mg_quadrangle.size()))
796 {
797 // afficheur << INEXISTE << enderr;
798 return NULL;
799 }
800 LISTE_MG_QUADRANGLE::iterator i=lst_mg_quadrangle.begin();
801 for (unsigned long j=0;j<num;j++) i++;
802 return ((*i).second);
803 }
804
805 MG_QUADRANGLE* MG_MAILLAGE::get_mg_quadrangle(unsigned long noeud1id,unsigned long noeud2id,unsigned long noeud3id,unsigned long noeud4id)
806 {
807 unsigned long id=std::min(noeud1id,noeud2id);
808 id=std::min(id,noeud3id);
809 id=std::min(id,noeud4id);
810 std::map<unsigned long,unsigned long> map1;
811 map1[noeud1id]=noeud1id;
812 map1[noeud2id]=noeud2id;
813 map1[noeud3id]=noeud3id;
814 map1[noeud4id]=noeud4id;
815 MG_NOEUD* noeud=get_mg_noeudid(id);
816 int nb_quadrangle=noeud->get_lien_petit_quadrangle()->get_nb();
817 for (int i=0;i<nb_quadrangle;i++)
818 {
819 MG_QUADRANGLE* mgquadrangle=noeud->get_lien_petit_quadrangle()->get(i);
820 std::map<unsigned long,unsigned long> map2;
821 map2[mgquadrangle->get_noeud1()->get_id()]=mgquadrangle->get_noeud1()->get_id();
822 map2[mgquadrangle->get_noeud2()->get_id()]=mgquadrangle->get_noeud2()->get_id();
823 map2[mgquadrangle->get_noeud3()->get_id()]=mgquadrangle->get_noeud3()->get_id();
824 map2[mgquadrangle->get_noeud4()->get_id()]=mgquadrangle->get_noeud4()->get_id();
825 std::map<unsigned long,unsigned long>::iterator it1,it2;
826 it1=map1.begin();it2=map2.begin();
827 int ok=1;
828 while (it1!=map1.end())
829 {
830 if ((*it1).first!=(*it2).first) {ok=0;break;}
831 it1++;
832 it2++;
833 }
834 if (ok) return mgquadrangle;
835 }
836 return NULL;
837 }
838
839 unsigned int MG_MAILLAGE::get_nb_mg_quadrangle(void)
840 {
841 return lst_mg_quadrangle.size();
842 }
843
844
845 int MG_MAILLAGE::supprimer_mg_quadrangleid(unsigned long num)
846 {
847 MG_QUADRANGLE* mgquadrangle=get_mg_quadrangleid(num);
848 if (mgquadrangle==NULL)
849 {
850 // afficheur << INEXISTE2 << enderr;
851 return FAIL;
852 }
853 MG_IDENTIFICATEUR* id=mgquadrangle;
854 LISTE_ENTITE::iterator i=lst_entite.find(id);
855 lst_entite.erase(i);
856 LISTE_MG_QUADRANGLE::iterator j=lst_mg_quadrangle.find(num);
857 lst_mg_quadrangle.erase(j);
858 MG_SEGMENT* segment1=mgquadrangle->get_segment1();
859 MG_SEGMENT* segment2=mgquadrangle->get_segment2();
860 MG_SEGMENT* segment3=mgquadrangle->get_segment3();
861 MG_SEGMENT* segment4=mgquadrangle->get_segment4();
862 delete mgquadrangle;
863 if (segment1->get_nb_reference()==0)
864 if (segment1->get_lien_topologie()!=NULL)
865 {
866 if (segment1->get_lien_topologie()->get_dimension()>1) supprimer_mg_segmentid(segment1->get_id());
867 }
868 else supprimer_mg_segmentid(segment1->get_id());
869 if (segment2->get_nb_reference()==0)
870 if (segment2->get_lien_topologie()!=NULL)
871 {
872 if (segment2->get_lien_topologie()->get_dimension()>1) supprimer_mg_segmentid(segment2->get_id());
873 }
874 else supprimer_mg_segmentid(segment2->get_id());
875 if (segment3->get_nb_reference()==0)
876 if (segment3->get_lien_topologie()!=NULL)
877 {
878 if (segment3->get_lien_topologie()->get_dimension()>1) supprimer_mg_segmentid(segment3->get_id());
879 }
880 else supprimer_mg_segmentid(segment3->get_id());
881 if (segment4->get_nb_reference()==0)
882 if (segment4->get_lien_topologie()!=NULL)
883 {
884 if (segment4->get_lien_topologie()->get_dimension()>1) supprimer_mg_segmentid(segment4->get_id());
885 }
886 else supprimer_mg_segmentid(segment4->get_id());
887 return OK;
888 }
889
890
891 int MG_MAILLAGE::supprimer_mg_quadrangle(unsigned int num)
892 {
893 MG_QUADRANGLE* mgquadrangle=get_mg_quadrangle(num);
894 if (mgquadrangle==NULL)
895 {
896 // afficheur << INEXISTE2 << enderr;
897 return FAIL;
898 }
899 MG_IDENTIFICATEUR* id=mgquadrangle;
900 LISTE_ENTITE::iterator i=lst_entite.find(id);
901 lst_entite.erase(i);
902 LISTE_MG_QUADRANGLE::iterator j=lst_mg_quadrangle.begin();
903 for (unsigned int k=0;k<num;k++) j++;
904 lst_mg_quadrangle.erase(j);
905 MG_SEGMENT* segment1=mgquadrangle->get_segment1();
906 MG_SEGMENT* segment2=mgquadrangle->get_segment2();
907 MG_SEGMENT* segment3=mgquadrangle->get_segment3();
908 MG_SEGMENT* segment4=mgquadrangle->get_segment4();
909 delete mgquadrangle;
910 if (segment1->get_nb_reference()==0)
911 if (segment1->get_lien_topologie()!=NULL)
912 {
913 if (segment1->get_lien_topologie()->get_dimension()>1) supprimer_mg_segmentid(segment1->get_id());
914 }
915 else supprimer_mg_segmentid(segment1->get_id());
916 if (segment2->get_nb_reference()==0)
917 if (segment2->get_lien_topologie()!=NULL)
918 {
919 if (segment2->get_lien_topologie()->get_dimension()>1) supprimer_mg_segmentid(segment2->get_id());
920 }
921 else supprimer_mg_segmentid(segment2->get_id());
922 if (segment3->get_nb_reference()==0)
923 if (segment3->get_lien_topologie()!=NULL)
924 {
925 if (segment3->get_lien_topologie()->get_dimension()>1) supprimer_mg_segmentid(segment3->get_id());
926 }
927 else supprimer_mg_segmentid(segment3->get_id());
928 if (segment4->get_nb_reference()==0)
929 if (segment4->get_lien_topologie()!=NULL)
930 {
931 if (segment4->get_lien_topologie()->get_dimension()>1) supprimer_mg_segmentid(segment4->get_id());
932 }
933 else supprimer_mg_segmentid(segment4->get_id());
934 return OK;
935 }
936
937
938 void MG_MAILLAGE::supprimer_tout_mg_quadrangle(void)
939 {
940 while (get_nb_mg_quadrangle()!=0)
941 {
942 LISTE_MG_QUADRANGLE::iterator j=lst_mg_quadrangle.begin();
943 MG_QUADRANGLE* mgquadrangle=(*j).second;
944 MG_IDENTIFICATEUR* id=mgquadrangle;
945 LISTE_ENTITE::iterator i=lst_entite.find(id);
946 lst_entite.erase(i);
947 lst_mg_quadrangle.erase(j);
948 delete mgquadrangle;
949 }
950 }
951
952
953 MG_QUADRANGLE* MG_MAILLAGE::get_premier_quadrangle(LISTE_MG_QUADRANGLE::iterator & it)
954 {
955 it = lst_mg_quadrangle.begin();
956 if (it == lst_mg_quadrangle.end())
957 return NULL;
958 return it->second;
959 }
960
961 MG_QUADRANGLE* MG_MAILLAGE::get_suivant_quadrangle(LISTE_MG_QUADRANGLE::iterator & it)
962 {
963 it++;
964 if (it == lst_mg_quadrangle.end())
965 return NULL;
966 return it->second;
967 }
968 // ENTITE MG_TETRA
969
970 MG_TETRA* MG_MAILLAGE::ajouter_mg_tetra(MG_ELEMENT_TOPOLOGIQUE* topo,class MG_NOEUD *mgnoeud1,class MG_NOEUD *mgnoeud2,class MG_NOEUD *mgnoeud3,class MG_NOEUD *mgnoeud4,int origine,unsigned long num)
971 {
972 MG_TRIANGLE* mgtriangle1=get_mg_triangle(mgnoeud1->get_id(),mgnoeud3->get_id(),mgnoeud2->get_id());
973 MG_TRIANGLE* mgtriangle2=get_mg_triangle(mgnoeud1->get_id(),mgnoeud2->get_id(),mgnoeud4->get_id());
974 MG_TRIANGLE* mgtriangle3=get_mg_triangle(mgnoeud2->get_id(),mgnoeud3->get_id(),mgnoeud4->get_id());
975 MG_TRIANGLE* mgtriangle4=get_mg_triangle(mgnoeud1->get_id(),mgnoeud4->get_id(),mgnoeud3->get_id());
976 if (mgtriangle1==NULL) mgtriangle1=ajouter_mg_triangle(topo,mgnoeud1,mgnoeud3,mgnoeud2,origine);
977 if (mgtriangle2==NULL) mgtriangle2=ajouter_mg_triangle(topo,mgnoeud1,mgnoeud2,mgnoeud4,origine);
978 if (mgtriangle3==NULL) mgtriangle3=ajouter_mg_triangle(topo,mgnoeud2,mgnoeud3,mgnoeud4,origine);
979 if (mgtriangle4==NULL) mgtriangle4=ajouter_mg_triangle(topo,mgnoeud1,mgnoeud4,mgnoeud3,origine);
980 MG_TETRA* mgtetra;
981 if (num==0) mgtetra=new MG_TETRA(topo,mgnoeud1,mgnoeud2,mgnoeud3,mgnoeud4,mgtriangle1,mgtriangle2,mgtriangle3,mgtriangle4,origine);
982 else mgtetra=new MG_TETRA(num,topo,mgnoeud1,mgnoeud2,mgnoeud3,mgnoeud4,mgtriangle1,mgtriangle2,mgtriangle3,mgtriangle4,origine);
983 int resultat=ajouter_mg_tetra(mgtetra);
984 if (resultat==FAIL)
985 {
986 delete mgtetra;
987 return NULL;
988 }
989 return mgtetra;
990 }
991
992
993 int MG_MAILLAGE::ajouter_mg_tetra(MG_TETRA *mgtetra)
994 {
995 gest->recherche_bonid(*mgtetra);
996 MG_IDENTIFICATEUR *id=mgtetra;
997 std::pair<LISTE_ENTITE::iterator,bool> p=lst_entite.insert(id);
998 if (!p.second)
999 {
1000 // afficheur << ENTITEID << id->get_id() << DUPLIQUE << enderr;
1001 return FAIL;
1002 }
1003
1004 std::pair<const unsigned long,MG_TETRA*> tmp(mgtetra->get_id(),mgtetra);
1005 lst_mg_tetra.insert(tmp);
1006 return OK;
1007 }
1008
1009
1010 MG_TETRA* MG_MAILLAGE::get_mg_tetraid(unsigned long num)
1011 {
1012 LISTE_MG_TETRA::iterator i=lst_mg_tetra.find(num);
1013 if (i==lst_mg_tetra.end())
1014 {
1015 // afficheur << INEXISTE << enderr;
1016 return NULL;
1017 }
1018 return ((*i).second);
1019 }
1020
1021
1022
1023 MG_TETRA* MG_MAILLAGE::get_mg_tetra(unsigned int num)
1024 {
1025 if (!(num<lst_mg_tetra.size()))
1026 {
1027 // afficheur << INEXISTE << enderr;
1028 return NULL;
1029 }
1030 LISTE_MG_TETRA::iterator i=lst_mg_tetra.begin();
1031 for (unsigned long j=0;j<num;j++) i++;
1032 return ((*i).second);
1033 }
1034
1035 MG_TETRA* MG_MAILLAGE::get_mg_tetra(MG_NOEUD* noeud1,MG_NOEUD* noeud2,MG_NOEUD* noeud3,MG_NOEUD* noeud4)
1036 {
1037 MG_NOEUD* noeud=noeud1;
1038 if (noeud2->get_id()<noeud->get_id()) noeud=noeud2;
1039 if (noeud3->get_id()<noeud->get_id()) noeud=noeud3;
1040 if (noeud4->get_id()<noeud->get_id()) noeud=noeud4;
1041 int nb_tetra=noeud->get_lien_petit_tetra()->get_nb();
1042 for (int i=0;i<nb_tetra;i++)
1043 {
1044 MG_TETRA* mgtetra=noeud->get_lien_petit_tetra()->get(i);
1045 if ( (mgtetra->get_noeud1()==noeud1) && (mgtetra->get_noeud2()==noeud2) && (mgtetra->get_noeud3()==noeud3) && (mgtetra->get_noeud4()==noeud4) ) return mgtetra;
1046 if ( (mgtetra->get_noeud1()==noeud1) && (mgtetra->get_noeud2()==noeud2) && (mgtetra->get_noeud3()==noeud4) && (mgtetra->get_noeud4()==noeud3) ) return mgtetra;
1047 if ( (mgtetra->get_noeud1()==noeud1) && (mgtetra->get_noeud2()==noeud3) && (mgtetra->get_noeud3()==noeud2) && (mgtetra->get_noeud4()==noeud4) ) return mgtetra;
1048 if ( (mgtetra->get_noeud1()==noeud1) && (mgtetra->get_noeud2()==noeud3) && (mgtetra->get_noeud3()==noeud4) && (mgtetra->get_noeud4()==noeud2) ) return mgtetra;
1049 if ( (mgtetra->get_noeud1()==noeud1) && (mgtetra->get_noeud2()==noeud4) && (mgtetra->get_noeud3()==noeud2) && (mgtetra->get_noeud4()==noeud3) ) return mgtetra;
1050 if ( (mgtetra->get_noeud1()==noeud1) && (mgtetra->get_noeud2()==noeud4) && (mgtetra->get_noeud3()==noeud3) && (mgtetra->get_noeud4()==noeud2) ) return mgtetra;
1051 if ( (mgtetra->get_noeud1()==noeud2) && (mgtetra->get_noeud2()==noeud1) && (mgtetra->get_noeud3()==noeud3) && (mgtetra->get_noeud4()==noeud4) ) return mgtetra;
1052 if ( (mgtetra->get_noeud1()==noeud2) && (mgtetra->get_noeud2()==noeud1) && (mgtetra->get_noeud3()==noeud4) && (mgtetra->get_noeud4()==noeud3) ) return mgtetra;
1053 if ( (mgtetra->get_noeud1()==noeud2) && (mgtetra->get_noeud2()==noeud3) && (mgtetra->get_noeud3()==noeud1) && (mgtetra->get_noeud4()==noeud4) ) return mgtetra;
1054 if ( (mgtetra->get_noeud1()==noeud2) && (mgtetra->get_noeud2()==noeud3) && (mgtetra->get_noeud3()==noeud4) && (mgtetra->get_noeud4()==noeud1) ) return mgtetra;
1055 if ( (mgtetra->get_noeud1()==noeud2) && (mgtetra->get_noeud2()==noeud4) && (mgtetra->get_noeud3()==noeud1) && (mgtetra->get_noeud4()==noeud3) ) return mgtetra;
1056 if ( (mgtetra->get_noeud1()==noeud2) && (mgtetra->get_noeud2()==noeud4) && (mgtetra->get_noeud3()==noeud3) && (mgtetra->get_noeud4()==noeud1) ) return mgtetra;
1057 if ( (mgtetra->get_noeud1()==noeud3) && (mgtetra->get_noeud2()==noeud1) && (mgtetra->get_noeud3()==noeud2) && (mgtetra->get_noeud4()==noeud4) ) return mgtetra;
1058 if ( (mgtetra->get_noeud1()==noeud3) && (mgtetra->get_noeud2()==noeud1) && (mgtetra->get_noeud3()==noeud4) && (mgtetra->get_noeud4()==noeud2) ) return mgtetra;
1059 if ( (mgtetra->get_noeud1()==noeud3) && (mgtetra->get_noeud2()==noeud2) && (mgtetra->get_noeud3()==noeud1) && (mgtetra->get_noeud4()==noeud4) ) return mgtetra;
1060 if ( (mgtetra->get_noeud1()==noeud3) && (mgtetra->get_noeud2()==noeud2) && (mgtetra->get_noeud3()==noeud4) && (mgtetra->get_noeud4()==noeud1) ) return mgtetra;
1061 if ( (mgtetra->get_noeud1()==noeud3) && (mgtetra->get_noeud2()==noeud4) && (mgtetra->get_noeud3()==noeud1) && (mgtetra->get_noeud4()==noeud2) ) return mgtetra;
1062 if ( (mgtetra->get_noeud1()==noeud3) && (mgtetra->get_noeud2()==noeud4) && (mgtetra->get_noeud3()==noeud2) && (mgtetra->get_noeud4()==noeud1) ) return mgtetra;
1063 if ( (mgtetra->get_noeud1()==noeud4) && (mgtetra->get_noeud2()==noeud1) && (mgtetra->get_noeud3()==noeud2) && (mgtetra->get_noeud4()==noeud3) ) return mgtetra;
1064 if ( (mgtetra->get_noeud1()==noeud4) && (mgtetra->get_noeud2()==noeud1) && (mgtetra->get_noeud3()==noeud3) && (mgtetra->get_noeud4()==noeud2) ) return mgtetra;
1065 if ( (mgtetra->get_noeud1()==noeud4) && (mgtetra->get_noeud2()==noeud2) && (mgtetra->get_noeud3()==noeud1) && (mgtetra->get_noeud4()==noeud3) ) return mgtetra;
1066 if ( (mgtetra->get_noeud1()==noeud4) && (mgtetra->get_noeud2()==noeud2) && (mgtetra->get_noeud3()==noeud3) && (mgtetra->get_noeud4()==noeud1) ) return mgtetra;
1067 if ( (mgtetra->get_noeud1()==noeud4) && (mgtetra->get_noeud2()==noeud3) && (mgtetra->get_noeud3()==noeud1) && (mgtetra->get_noeud4()==noeud2) ) return mgtetra;
1068 if ( (mgtetra->get_noeud1()==noeud4) && (mgtetra->get_noeud2()==noeud3) && (mgtetra->get_noeud3()==noeud2) && (mgtetra->get_noeud4()==noeud1) ) return mgtetra;
1069 }
1070 return NULL;
1071 }
1072
1073 unsigned int MG_MAILLAGE::get_nb_mg_tetra(void)
1074 {
1075 return lst_mg_tetra.size();
1076 }
1077
1078
1079 int MG_MAILLAGE::supprimer_mg_tetraid(unsigned long num)
1080 {
1081 MG_TETRA* mgtetra=get_mg_tetraid(num);
1082 if (mgtetra==NULL)
1083 {
1084 // afficheur << INEXISTE2 << enderr;
1085 return FAIL;
1086 }
1087 MG_IDENTIFICATEUR* id=mgtetra;
1088 LISTE_ENTITE::iterator i=lst_entite.find(id);
1089 lst_entite.erase(i);
1090 LISTE_MG_TETRA::iterator j=lst_mg_tetra.find(num);
1091 lst_mg_tetra.erase(j);
1092 MG_TRIANGLE* triangle1=mgtetra->get_triangle1();
1093 MG_TRIANGLE* triangle2=mgtetra->get_triangle2();
1094 MG_TRIANGLE* triangle3=mgtetra->get_triangle3();
1095 MG_TRIANGLE* triangle4=mgtetra->get_triangle4();
1096 delete mgtetra;
1097 if (triangle1->get_nb_reference()==0)
1098 if (triangle1->get_lien_topologie()!=NULL)
1099 {
1100 if (triangle1->get_lien_topologie()->get_dimension()>2) supprimer_mg_triangleid(triangle1->get_id());
1101 }
1102 else supprimer_mg_triangleid(triangle1->get_id());
1103 if (triangle2->get_nb_reference()==0)
1104 if (triangle2->get_lien_topologie()!=NULL)
1105 {
1106 if (triangle2->get_lien_topologie()->get_dimension()>2) supprimer_mg_triangleid(triangle2->get_id());
1107 }
1108 else supprimer_mg_triangleid(triangle2->get_id());
1109 if (triangle3->get_nb_reference()==0)
1110 if (triangle3->get_lien_topologie()!=NULL)
1111 {
1112 if (triangle3->get_lien_topologie()->get_dimension()>2) supprimer_mg_triangleid(triangle3->get_id());
1113 }
1114 else supprimer_mg_triangleid(triangle3->get_id());
1115 if (triangle4->get_nb_reference()==0)
1116 if (triangle4->get_lien_topologie()!=NULL)
1117 {
1118 if (triangle4->get_lien_topologie()->get_dimension()>2) supprimer_mg_triangleid(triangle4->get_id());
1119 }
1120 else supprimer_mg_triangleid(triangle4->get_id());
1121 return OK;
1122 }
1123
1124
1125 int MG_MAILLAGE::supprimer_mg_tetra(unsigned int num)
1126 {
1127 MG_TETRA* mgtetra=get_mg_tetra(num);
1128 if (mgtetra==NULL)
1129 {
1130 // afficheur << INEXISTE2 << enderr;
1131 return FAIL;
1132 }
1133 MG_IDENTIFICATEUR* id=mgtetra;
1134 LISTE_ENTITE::iterator i=lst_entite.find(id);
1135 lst_entite.erase(i);
1136 LISTE_MG_TETRA::iterator j=lst_mg_tetra.begin();
1137 for (unsigned int k=0;k<num;k++) j++;
1138 lst_mg_tetra.erase(j);
1139 MG_TRIANGLE* triangle1=mgtetra->get_triangle1();
1140 MG_TRIANGLE* triangle2=mgtetra->get_triangle2();
1141 MG_TRIANGLE* triangle3=mgtetra->get_triangle3();
1142 MG_TRIANGLE* triangle4=mgtetra->get_triangle4();
1143 delete mgtetra;
1144 if (triangle1->get_nb_reference()==0)
1145 if (triangle1->get_lien_topologie()!=NULL)
1146 {
1147 if (triangle1->get_lien_topologie()->get_dimension()>2) supprimer_mg_triangleid(triangle1->get_id());
1148 }
1149 else supprimer_mg_triangleid(triangle1->get_id());
1150 if (triangle2->get_nb_reference()==0)
1151 if (triangle2->get_lien_topologie()!=NULL)
1152 {
1153 if (triangle2->get_lien_topologie()->get_dimension()>2) supprimer_mg_triangleid(triangle2->get_id());
1154 }
1155 else supprimer_mg_triangleid(triangle2->get_id());
1156 if (triangle3->get_nb_reference()==0)
1157 if (triangle3->get_lien_topologie()!=NULL)
1158 {
1159 if (triangle3->get_lien_topologie()->get_dimension()>2) supprimer_mg_triangleid(triangle3->get_id());
1160 }
1161 else supprimer_mg_triangleid(triangle3->get_id());
1162 if (triangle4->get_nb_reference()==0)
1163 if (triangle4->get_lien_topologie()!=NULL)
1164 {
1165 if (triangle4->get_lien_topologie()->get_dimension()>2) supprimer_mg_triangleid(triangle4->get_id());
1166 }
1167 else supprimer_mg_triangleid(triangle4->get_id());
1168 return OK;
1169 }
1170
1171
1172 void MG_MAILLAGE::supprimer_tout_mg_tetra(void)
1173 {
1174 while (get_nb_mg_tetra()!=0)
1175 {
1176 LISTE_MG_TETRA::iterator j=lst_mg_tetra.begin();
1177 MG_TETRA* mgtetra=(*j).second;
1178 MG_IDENTIFICATEUR* id=mgtetra;
1179 LISTE_ENTITE::iterator i=lst_entite.find(id);
1180 lst_entite.erase(i);
1181 lst_mg_tetra.erase(j);
1182 delete mgtetra;
1183 }
1184 }
1185
1186
1187 MG_TETRA* MG_MAILLAGE::get_premier_tetra(LISTE_MG_TETRA::iterator & it)
1188 {
1189 it = lst_mg_tetra.begin();
1190 if (it == lst_mg_tetra.end())
1191 return NULL;
1192 return it->second;
1193 }
1194
1195 MG_TETRA* MG_MAILLAGE::get_suivant_tetra(LISTE_MG_TETRA::iterator & it)
1196 {
1197 it++;
1198 if (it == lst_mg_tetra.end())
1199 return NULL;
1200 return it->second;
1201 }
1202 // ENTITE MG_HEXA
1203
1204 MG_HEXA* MG_MAILLAGE::ajouter_mg_hexa(MG_ELEMENT_TOPOLOGIQUE* topo,class MG_NOEUD *mgnoeud1,class MG_NOEUD *mgnoeud2,class MG_NOEUD *mgnoeud3,class MG_NOEUD *mgnoeud4,class MG_NOEUD *mgnoeud5,class MG_NOEUD *mgnoeud6,class MG_NOEUD *mgnoeud7,class MG_NOEUD *mgnoeud8,int origine,unsigned long num)
1205 {
1206 MG_QUADRANGLE* mgquadrangle1=get_mg_quadrangle(mgnoeud1->get_id(),mgnoeud2->get_id(),mgnoeud6->get_id(),mgnoeud5->get_id());
1207 MG_QUADRANGLE* mgquadrangle2=get_mg_quadrangle(mgnoeud2->get_id(),mgnoeud3->get_id(),mgnoeud7->get_id(),mgnoeud6->get_id());
1208 MG_QUADRANGLE* mgquadrangle3=get_mg_quadrangle(mgnoeud3->get_id(),mgnoeud4->get_id(),mgnoeud8->get_id(),mgnoeud7->get_id());
1209 MG_QUADRANGLE* mgquadrangle4=get_mg_quadrangle(mgnoeud4->get_id(),mgnoeud1->get_id(),mgnoeud5->get_id(),mgnoeud8->get_id());
1210 MG_QUADRANGLE* mgquadrangle5=get_mg_quadrangle(mgnoeud1->get_id(),mgnoeud4->get_id(),mgnoeud3->get_id(),mgnoeud2->get_id());
1211 MG_QUADRANGLE* mgquadrangle6=get_mg_quadrangle(mgnoeud5->get_id(),mgnoeud6->get_id(),mgnoeud7->get_id(),mgnoeud8->get_id());
1212 if (mgquadrangle1==NULL) mgquadrangle1=ajouter_mg_quadrangle(topo,mgnoeud1,mgnoeud2,mgnoeud6,mgnoeud5,origine);
1213 if (mgquadrangle2==NULL) mgquadrangle2=ajouter_mg_quadrangle(topo,mgnoeud2,mgnoeud3,mgnoeud7,mgnoeud6,origine);
1214 if (mgquadrangle3==NULL) mgquadrangle3=ajouter_mg_quadrangle(topo,mgnoeud3,mgnoeud4,mgnoeud8,mgnoeud7,origine);
1215 if (mgquadrangle4==NULL) mgquadrangle4=ajouter_mg_quadrangle(topo,mgnoeud4,mgnoeud1,mgnoeud5,mgnoeud8,origine);
1216 if (mgquadrangle5==NULL) mgquadrangle5=ajouter_mg_quadrangle(topo,mgnoeud1,mgnoeud4,mgnoeud3,mgnoeud2,origine);
1217 if (mgquadrangle6==NULL) mgquadrangle6=ajouter_mg_quadrangle(topo,mgnoeud5,mgnoeud6,mgnoeud7,mgnoeud8,origine);
1218 MG_HEXA* mghexa;
1219 if (num==0) mghexa=new MG_HEXA(topo,mgnoeud1,mgnoeud2,mgnoeud3,mgnoeud4,mgnoeud5,mgnoeud6,mgnoeud7,mgnoeud8,mgquadrangle1,mgquadrangle2,mgquadrangle3,mgquadrangle4,mgquadrangle5,mgquadrangle6,origine);
1220 else mghexa=new MG_HEXA(num,topo,mgnoeud1,mgnoeud2,mgnoeud3,mgnoeud4,mgnoeud5,mgnoeud6,mgnoeud7,mgnoeud8,mgquadrangle1,mgquadrangle2,mgquadrangle3,mgquadrangle4,mgquadrangle5,mgquadrangle6,origine);
1221 int resultat=ajouter_mg_hexa(mghexa);
1222 if (resultat==FAIL)
1223 {
1224 delete mghexa;
1225 return NULL;
1226 }
1227 return mghexa;
1228 }
1229
1230
1231 int MG_MAILLAGE::ajouter_mg_hexa(MG_HEXA *mghexa)
1232 {
1233 gest->recherche_bonid(*mghexa);
1234 MG_IDENTIFICATEUR *id=mghexa;
1235 std::pair<LISTE_ENTITE::iterator,bool> p=lst_entite.insert(id);
1236 if (!p.second)
1237 {
1238 // afficheur << ENTITEID << id->get_id() << DUPLIQUE << enderr;
1239 return FAIL;
1240 }
1241
1242 std::pair<const unsigned long,MG_HEXA*> tmp(mghexa->get_id(),mghexa);
1243 lst_mg_hexa.insert(tmp);
1244 return OK;
1245 }
1246
1247
1248 MG_HEXA* MG_MAILLAGE::get_mg_hexaid(unsigned long num)
1249 {
1250 LISTE_MG_HEXA::iterator i=lst_mg_hexa.find(num);
1251 if (i==lst_mg_hexa.end())
1252 {
1253 // afficheur << INEXISTE << enderr;
1254 return NULL;
1255 }
1256 return ((*i).second);
1257 }
1258
1259
1260
1261 MG_HEXA* MG_MAILLAGE::get_mg_hexa(unsigned int num)
1262 {
1263 if (!(num<lst_mg_hexa.size()))
1264 {
1265 // afficheur << INEXISTE << enderr;
1266 return NULL;
1267 }
1268 LISTE_MG_HEXA::iterator i=lst_mg_hexa.begin();
1269 for (unsigned long j=0;j<num;j++) i++;
1270 return ((*i).second);
1271 }
1272
1273 MG_HEXA* MG_MAILLAGE::get_mg_hexa(MG_NOEUD* noeud1,MG_NOEUD* noeud2,MG_NOEUD* noeud3,MG_NOEUD* noeud4,MG_NOEUD* noeud5,MG_NOEUD* noeud6,MG_NOEUD* noeud7,MG_NOEUD* noeud8)
1274 {
1275 MG_NOEUD* noeud=noeud1;
1276 if (noeud2->get_id()<noeud->get_id()) noeud=noeud2;
1277 if (noeud3->get_id()<noeud->get_id()) noeud=noeud3;
1278 if (noeud4->get_id()<noeud->get_id()) noeud=noeud4;
1279 if (noeud5->get_id()<noeud->get_id()) noeud=noeud5;
1280 if (noeud6->get_id()<noeud->get_id()) noeud=noeud6;
1281 if (noeud7->get_id()<noeud->get_id()) noeud=noeud7;
1282 if (noeud8->get_id()<noeud->get_id()) noeud=noeud8;
1283
1284
1285 std::map<unsigned long,unsigned long> map1;
1286 map1[noeud1->get_id()]=noeud1->get_id();
1287 map1[noeud2->get_id()]=noeud2->get_id();
1288 map1[noeud3->get_id()]=noeud3->get_id();
1289 map1[noeud4->get_id()]=noeud4->get_id();
1290 map1[noeud5->get_id()]=noeud5->get_id();
1291 map1[noeud6->get_id()]=noeud6->get_id();
1292 map1[noeud7->get_id()]=noeud7->get_id();
1293 map1[noeud8->get_id()]=noeud8->get_id();
1294 int nb_hexa=noeud->get_lien_petit_hexa()->get_nb();
1295 for (int i=0;i<nb_hexa;i++)
1296 {
1297 MG_HEXA* mghexa=noeud->get_lien_petit_hexa()->get(i);
1298 std::map<unsigned long,unsigned long> map2;
1299 map2[mghexa->get_noeud1()->get_id()]=mghexa->get_noeud1()->get_id();
1300 map2[mghexa->get_noeud2()->get_id()]=mghexa->get_noeud2()->get_id();
1301 map2[mghexa->get_noeud3()->get_id()]=mghexa->get_noeud3()->get_id();
1302 map2[mghexa->get_noeud4()->get_id()]=mghexa->get_noeud4()->get_id();
1303 map2[mghexa->get_noeud5()->get_id()]=mghexa->get_noeud5()->get_id();
1304 map2[mghexa->get_noeud6()->get_id()]=mghexa->get_noeud6()->get_id();
1305 map2[mghexa->get_noeud7()->get_id()]=mghexa->get_noeud7()->get_id();
1306 map2[mghexa->get_noeud8()->get_id()]=mghexa->get_noeud8()->get_id();
1307 std::map<unsigned long,unsigned long>::iterator it1,it2;
1308 it1=map1.begin();it2=map2.begin();
1309 int ok=1;
1310 while (it1!=map1.end())
1311 {
1312 if ((*it1).first!=(*it2).first) {ok=0;break;}
1313 it1++;
1314 it2++;
1315 }
1316 if (ok) return mghexa;
1317 }
1318 return NULL;
1319
1320
1321
1322
1323 }
1324
1325 unsigned int MG_MAILLAGE::get_nb_mg_hexa(void)
1326 {
1327 return lst_mg_hexa.size();
1328 }
1329
1330
1331 int MG_MAILLAGE::supprimer_mg_hexaid(unsigned long num)
1332 {
1333 MG_HEXA* mghexa=get_mg_hexaid(num);
1334 if (mghexa==NULL)
1335 {
1336 // afficheur << INEXISTE2 << enderr;
1337 return FAIL;
1338 }
1339 MG_IDENTIFICATEUR* id=mghexa;
1340 LISTE_ENTITE::iterator i=lst_entite.find(id);
1341 lst_entite.erase(i);
1342 LISTE_MG_HEXA::iterator j=lst_mg_hexa.find(num);
1343 lst_mg_hexa.erase(j);
1344 MG_QUADRANGLE* quadrangle1=mghexa->get_quadrangle1();
1345 MG_QUADRANGLE* quadrangle2=mghexa->get_quadrangle2();
1346 MG_QUADRANGLE* quadrangle3=mghexa->get_quadrangle3();
1347 MG_QUADRANGLE* quadrangle4=mghexa->get_quadrangle4();
1348 MG_QUADRANGLE* quadrangle5=mghexa->get_quadrangle5();
1349 MG_QUADRANGLE* quadrangle6=mghexa->get_quadrangle6();
1350 delete mghexa;
1351 if (quadrangle1->get_nb_reference()==0)
1352 if (quadrangle1->get_lien_topologie()!=NULL)
1353 {
1354 if (quadrangle1->get_lien_topologie()->get_dimension()>2) supprimer_mg_quadrangleid(quadrangle1->get_id());
1355 }
1356 else supprimer_mg_quadrangleid(quadrangle1->get_id());
1357 if (quadrangle2->get_nb_reference()==0)
1358 if (quadrangle2->get_lien_topologie()!=NULL)
1359 {
1360 if (quadrangle2->get_lien_topologie()->get_dimension()>2) supprimer_mg_quadrangleid(quadrangle2->get_id());
1361 }
1362 else supprimer_mg_quadrangleid(quadrangle2->get_id());
1363 if (quadrangle3->get_nb_reference()==0)
1364 if (quadrangle3->get_lien_topologie()!=NULL)
1365 {
1366 if (quadrangle3->get_lien_topologie()->get_dimension()>2) supprimer_mg_quadrangleid(quadrangle3->get_id());
1367 }
1368 else supprimer_mg_quadrangleid(quadrangle3->get_id());
1369 if (quadrangle4->get_nb_reference()==0)
1370 if (quadrangle4->get_lien_topologie()!=NULL)
1371 {
1372 if (quadrangle4->get_lien_topologie()->get_dimension()>2) supprimer_mg_quadrangleid(quadrangle4->get_id());
1373 }
1374 else supprimer_mg_quadrangleid(quadrangle4->get_id());
1375 if (quadrangle5->get_nb_reference()==0)
1376 if (quadrangle5->get_lien_topologie()!=NULL)
1377 {
1378 if (quadrangle5->get_lien_topologie()->get_dimension()>2) supprimer_mg_quadrangleid(quadrangle5->get_id());
1379 }
1380 else supprimer_mg_quadrangleid(quadrangle5->get_id());
1381 if (quadrangle6->get_nb_reference()==0)
1382 if (quadrangle6->get_lien_topologie()!=NULL)
1383 {
1384 if (quadrangle6->get_lien_topologie()->get_dimension()>2) supprimer_mg_quadrangleid(quadrangle6->get_id());
1385 }
1386 else supprimer_mg_quadrangleid(quadrangle6->get_id());
1387 return OK;
1388 }
1389
1390
1391 int MG_MAILLAGE::supprimer_mg_hexa(unsigned int num)
1392 {
1393 MG_HEXA* mghexa=get_mg_hexa(num);
1394 if (mghexa==NULL)
1395 {
1396 // afficheur << INEXISTE2 << enderr;
1397 return FAIL;
1398 }
1399 MG_IDENTIFICATEUR* id=mghexa;
1400 LISTE_ENTITE::iterator i=lst_entite.find(id);
1401 lst_entite.erase(i);
1402 LISTE_MG_HEXA::iterator j=lst_mg_hexa.begin();
1403 for (unsigned int k=0;k<num;k++) j++;
1404 lst_mg_hexa.erase(j);
1405 MG_QUADRANGLE* quadrangle1=mghexa->get_quadrangle1();
1406 MG_QUADRANGLE* quadrangle2=mghexa->get_quadrangle2();
1407 MG_QUADRANGLE* quadrangle3=mghexa->get_quadrangle3();
1408 MG_QUADRANGLE* quadrangle4=mghexa->get_quadrangle4();
1409 MG_QUADRANGLE* quadrangle5=mghexa->get_quadrangle5();
1410 MG_QUADRANGLE* quadrangle6=mghexa->get_quadrangle6();
1411 delete mghexa;
1412 if (quadrangle1->get_nb_reference()==0)
1413 if (quadrangle1->get_lien_topologie()!=NULL)
1414 {
1415 if (quadrangle1->get_lien_topologie()->get_dimension()>2) supprimer_mg_quadrangleid(quadrangle1->get_id());
1416 }
1417 else supprimer_mg_quadrangleid(quadrangle1->get_id());
1418 if (quadrangle2->get_nb_reference()==0)
1419 if (quadrangle2->get_lien_topologie()!=NULL)
1420 {
1421 if (quadrangle2->get_lien_topologie()->get_dimension()>2) supprimer_mg_quadrangleid(quadrangle2->get_id());
1422 }
1423 else supprimer_mg_quadrangleid(quadrangle2->get_id());
1424 if (quadrangle3->get_nb_reference()==0)
1425 if (quadrangle3->get_lien_topologie()!=NULL)
1426 {
1427 if (quadrangle3->get_lien_topologie()->get_dimension()>2) supprimer_mg_quadrangleid(quadrangle3->get_id());
1428 }
1429 else supprimer_mg_quadrangleid(quadrangle3->get_id());
1430 if (quadrangle4->get_nb_reference()==0)
1431 if (quadrangle4->get_lien_topologie()!=NULL)
1432 {
1433 if (quadrangle4->get_lien_topologie()->get_dimension()>2) supprimer_mg_quadrangleid(quadrangle4->get_id());
1434 }
1435 else supprimer_mg_quadrangleid(quadrangle4->get_id());
1436 if (quadrangle5->get_nb_reference()==0)
1437 if (quadrangle5->get_lien_topologie()!=NULL)
1438 {
1439 if (quadrangle5->get_lien_topologie()->get_dimension()>2) supprimer_mg_quadrangleid(quadrangle5->get_id());
1440 }
1441 else supprimer_mg_quadrangleid(quadrangle5->get_id());
1442 if (quadrangle6->get_nb_reference()==0)
1443 if (quadrangle6->get_lien_topologie()!=NULL)
1444 {
1445 if (quadrangle6->get_lien_topologie()->get_dimension()>2) supprimer_mg_quadrangleid(quadrangle6->get_id());
1446 }
1447 else supprimer_mg_quadrangleid(quadrangle6->get_id());
1448 return OK;
1449 }
1450
1451
1452 void MG_MAILLAGE::supprimer_tout_mg_hexa(void)
1453 {
1454 while (get_nb_mg_hexa()!=0)
1455 {
1456 LISTE_MG_HEXA::iterator j=lst_mg_hexa.begin();
1457 MG_HEXA* mghexa=(*j).second;
1458 MG_IDENTIFICATEUR* id=mghexa;
1459 LISTE_ENTITE::iterator i=lst_entite.find(id);
1460 lst_entite.erase(i);
1461 lst_mg_hexa.erase(j);
1462 delete mghexa;
1463 }
1464 }
1465
1466
1467 MG_HEXA* MG_MAILLAGE::get_premier_hexa(LISTE_MG_HEXA::iterator & it)
1468 {
1469 it = lst_mg_hexa.begin();
1470 if (it == lst_mg_hexa.end())
1471 return NULL;
1472 return it->second;
1473 }
1474
1475 MG_HEXA* MG_MAILLAGE::get_suivant_hexa(LISTE_MG_HEXA::iterator & it)
1476 {
1477 it++;
1478 if (it == lst_mg_hexa.end())
1479 return NULL;
1480 return it->second;
1481 }
1482
1483
1484
1485
1486 bool MG_MAILLAGE::contient ( MG_IDENTIFICATEUR * id )
1487 {
1488 return ( lst_entite.find ( id ) != lst_entite.end() );
1489 }
1490
1491 void MG_MAILLAGE::enregistrer(std::ostream& o)
1492 {
1493 if (mg_geometrie==NULL)
1494 {
1495 if (get_nb_mg_tetra()!=0) MG_MAILLAGE::DIMENSIONMAILLAGESANSTOPO=3;
1496 else if (get_nb_mg_hexa()!=0) MG_MAILLAGE::DIMENSIONMAILLAGESANSTOPO=3;
1497 else if (get_nb_mg_triangle()!=0) MG_MAILLAGE::DIMENSIONMAILLAGESANSTOPO=2;
1498 else if (get_nb_mg_quadrangle()!=0) MG_MAILLAGE::DIMENSIONMAILLAGESANSTOPO=2;
1499 else if (get_nb_mg_segment()!=0) MG_MAILLAGE::DIMENSIONMAILLAGESANSTOPO=1;
1500 else MG_MAILLAGE::DIMENSIONMAILLAGESANSTOPO=0;
1501 }
1502 if (est_structure==true)
1503 {
1504 if (mg_geometrie==NULL) o << "%" << get_id() << "=MAILLAGE_STRUCTURE(NULL," << boite_englobante.get_xmin() << "," << boite_englobante.get_ymin() << "," << boite_englobante.get_zmin() << "," << boite_englobante.get_xmax() << "," << boite_englobante.get_ymax() << ","<< boite_englobante.get_zmax() << "," << nx <<"," << ny << "," << nz <<"," << ");" << std::endl;
1505 else o << "%" << get_id() << "=MAILLAGE_STRUCTURE($" << mg_geometrie->get_id() << boite_englobante.get_xmin() << "," << boite_englobante.get_ymin() << "," << boite_englobante.get_zmin() << "," << boite_englobante.get_xmax() << "," << boite_englobante.get_ymax() << ","<< boite_englobante.get_zmax() << "," << nx <<"," << ny << "," << nz <<"," << ");" << std::endl;
1506 }
1507 else
1508 {
1509 if (mg_geometrie==NULL) o << "%" << get_id() << "=MAILLAGE(NULL);" << std::endl;
1510 else o << "%" << get_id() << "=MAILLAGE($" << mg_geometrie->get_id() << ");" << std::endl;
1511 }
1512 LISTE_ENTITE::const_iterator i;
1513 for (i=lst_entite.begin();i!=lst_entite.end();i++)
1514 {
1515 MG_IDENTIFICATEUR* entite = *i;
1516 entite->enregistrer(o);
1517 }
1518 }
1519
1520 void MG_MAILLAGE::enregistrer_sous_mesh_1D(std::ostream& o)
1521 {
1522
1523 int nb_noeud=0;
1524 for (LISTE_MG_NOEUD::iterator i=lst_mg_noeud.begin();i!=lst_mg_noeud.end();i++)
1525 {
1526 MG_NOEUD* noeud=((*i).second);
1527 if (noeud->get_lien_topologie()->get_dimension()<2) nb_noeud++;
1528 }
1529
1530 int nb_seg=0;
1531 for (LISTE_MG_SEGMENT::iterator i=lst_mg_segment.begin();i!=lst_mg_segment.end();i++)
1532 {
1533 MG_SEGMENT* seg=((*i).second);
1534 if (seg->get_lien_topologie()->get_dimension()<2) nb_seg++;
1535 }
1536
1537 o << nb_noeud << " " << nb_seg << std::endl;
1538 int ii=0;
1539 for (LISTE_MG_NOEUD::iterator i=lst_mg_noeud.begin();i!=lst_mg_noeud.end();i++)
1540 {
1541 MG_NOEUD* noeud=((*i).second);
1542 if (noeud->get_lien_topologie()->get_dimension()<2)
1543 {
1544 o << (ii+1) << " " << noeud->get_x() << " " << noeud->get_y() << " " << noeud->get_z() << " " ;
1545 if (noeud->get_lien_topologie()->get_dimension()==0) o << "vertex ";
1546 if (noeud->get_lien_topologie()->get_dimension()==1) o << "edge ";
1547 o << noeud->get_lien_topologie()->get_id() << " " << noeud->get_id() << std::endl;
1548 noeud->change_nouveau_numero(ii+1);
1549 ii++;
1550 }
1551 }
1552
1553 for (LISTE_MG_SEGMENT::iterator i=lst_mg_segment.begin();i!=lst_mg_segment.end();i++)
1554 {
1555 MG_SEGMENT* seg=((*i).second);
1556 if (seg->get_lien_topologie()->get_dimension()<2)
1557 {
1558 o << "2 " << seg->get_noeud1()->get_nouveau_numero() << " " << seg->get_noeud2()->get_nouveau_numero() << " " ;
1559 if (seg->get_lien_topologie()->get_dimension()==0) o << "vertex ";
1560 if (seg->get_lien_topologie()->get_dimension()==1) o << "edge ";
1561 o << seg->get_lien_topologie()->get_id() << std::endl;
1562 }
1563 }
1564
1565 }
1566
1567 void MG_MAILLAGE::enregistrer_sous_mesh_2D
1568 (std::ostream& o)
1569 {
1570 int nb_noeud=0;
1571 for (LISTE_MG_NOEUD::iterator i=lst_mg_noeud.begin();i!=lst_mg_noeud.end();i++)
1572 {
1573 MG_NOEUD* noeud=((*i).second);
1574 if (noeud->get_lien_topologie()->get_dimension()<3) nb_noeud++;
1575 }
1576
1577 int nb_tri=0;
1578 for (LISTE_MG_TRIANGLE::iterator i=lst_mg_triangle.begin();i!=lst_mg_triangle.end();i++)
1579 {
1580 MG_TRIANGLE* triangle=((*i).second);
1581 if (triangle->get_lien_topologie()->get_dimension()<3) nb_tri++;
1582 }
1583
1584 o << nb_noeud << " " << nb_tri << std::endl;
1585 int ii=0;
1586 for (LISTE_MG_NOEUD::iterator i=lst_mg_noeud.begin();i!=lst_mg_noeud.end();i++)
1587 {
1588 MG_NOEUD* noeud=((*i).second);
1589 if (noeud->get_lien_topologie()->get_dimension()<3)
1590 {
1591 o << (ii+1) << " " << noeud->get_x() << " " << noeud->get_y() << " " << noeud->get_z() << " " ;
1592 if (noeud->get_lien_topologie()->get_dimension()==0) o << "vertex ";
1593 if (noeud->get_lien_topologie()->get_dimension()==1) o << "edge ";
1594 if (noeud->get_lien_topologie()->get_dimension()==2) o << "face ";
1595 o << noeud->get_lien_topologie()->get_id() << std::endl;
1596 noeud->change_nouveau_numero(ii+1);
1597 ii++;
1598 }
1599 }
1600
1601 int compteur=0;
1602 for (LISTE_MG_TRIANGLE::iterator i=lst_mg_triangle.begin();i!=lst_mg_triangle.end();i++)
1603 {
1604 MG_TRIANGLE* triangle=((*i).second);
1605 if (triangle->get_lien_topologie()->get_dimension()<3)
1606 {
1607 o << "3 " << triangle->get_noeud1()->get_nouveau_numero() << " " << triangle->get_noeud2()->get_nouveau_numero() << " " << triangle->get_noeud3()->get_nouveau_numero() << " " ;
1608 if (triangle->get_lien_topologie()->get_dimension()==0) o << "vertex ";
1609 if (triangle->get_lien_topologie()->get_dimension()==1) o << "edge ";
1610 if (triangle->get_lien_topologie()->get_dimension()==2) o << "face ";
1611 if (triangle->get_lien_topologie()->get_dimension()==3) o << "body ";
1612 o << triangle->get_lien_topologie()->get_id() << std::endl;
1613 compteur++;
1614 }
1615 }
1616
1617 }
1618
1619 void MG_MAILLAGE::enregistrer_sous_mesh_3D(std::ostream& o)
1620 {
1621 o << get_nb_mg_noeud() << " " << get_nb_mg_tetra() << std::endl;
1622 int ii=0;
1623 for (LISTE_MG_NOEUD::iterator i=lst_mg_noeud.begin();i!=lst_mg_noeud.end();i++)
1624 {
1625 MG_NOEUD* noeud=((*i).second);
1626 o << (ii+1) << " " << noeud->get_x() << " " << noeud->get_y() << " " << noeud->get_z() << " " ;
1627 if (noeud->get_lien_topologie()->get_dimension()==0) o << "vertex ";
1628 if (noeud->get_lien_topologie()->get_dimension()==1) o << "edge ";
1629 if (noeud->get_lien_topologie()->get_dimension()==2) o << "face ";
1630 if (noeud->get_lien_topologie()->get_dimension()==3) o << "body ";
1631 o << noeud->get_lien_topologie()->get_id() << std::endl;
1632 noeud->change_nouveau_numero(ii+1);
1633 ii++;
1634 }
1635
1636
1637 for (LISTE_MG_TETRA::iterator i=lst_mg_tetra.begin();i!=lst_mg_tetra.end();i++)
1638 {
1639 MG_TETRA* tetra=((*i).second);
1640 o << "4 " << tetra->get_noeud1()->get_nouveau_numero() << " " << tetra->get_noeud2()->get_nouveau_numero() << " " << tetra->get_noeud3()->get_nouveau_numero() << " " << tetra->get_noeud4()->get_nouveau_numero() << " " ;
1641 if (tetra->get_lien_topologie()->get_dimension()==0) o << "vertex ";
1642 if (tetra->get_lien_topologie()->get_dimension()==1) o << "edge ";
1643 if (tetra->get_lien_topologie()->get_dimension()==2) o << "face ";
1644 if (tetra->get_lien_topologie()->get_dimension()==3) o << "body ";
1645 o << tetra->get_lien_topologie()->get_id() << std::endl;
1646 }
1647
1648 }
1649
1650 void MG_MAILLAGE::exporter_mesh(std::string& nomfic)
1651 {
1652 char chaine[500];
1653 sprintf(chaine,"%s_1D.mai",nomfic.c_str());
1654 std::ofstream of1(chaine,std::ios::out|std::ios::trunc);
1655 of1.precision(16);
1656 of1.setf(std::ios::showpoint);
1657 enregistrer_sous_mesh_1D(of1);
1658 sprintf(chaine,"%s_2D.mai",nomfic.c_str());
1659 std::ofstream of2(chaine,std::ios::out|std::ios::trunc);
1660 of2.precision(16);
1661 of2.setf(std::ios::showpoint);
1662 enregistrer_sous_mesh_2D(of2);
1663 sprintf(chaine,"%s_3D.mai",nomfic.c_str());
1664 std::ofstream of3(chaine,std::ios::out|std::ios::trunc);
1665 of3.precision(16);
1666 of3.setf(std::ios::showpoint);
1667 enregistrer_sous_mesh_3D(of3);
1668 }
1669
1670 /*
1671 void MG_MAILLAGE::exporter_cosmos(std::string& nomfic)
1672 {
1673 char chaine[500];
1674 sprintf(chaine,"%s.ses",nomfic.c_str());
1675 std::ofstream of1(chaine,std::ios::out|std::ios::trunc);
1676 of1.precision(16);
1677 of1.setf(std::ios::showpoint);
1678 of1 << "TITLE, " << chaine << " : Fichier de maillage MAGiC" << std::endl;
1679 of1 << "EGROUP,1,TETRA4,0,0,0,0,0,0,0,0;" << std::endl;
1680 int nb_volume=mg_geometrie->get_nb_mg_volume();
1681 for (int i=0;i<nb_volume;i++)
1682 {
1683 MG_VOLUME *mgvol=mg_geometrie->get_mg_volume(i);
1684 if (mgvol->get_num_materiau()>=0)
1685 {
1686 MT_GESTIONNAIRE mtgest(mg_geometrie->get_gest_materiau());
1687 MT_MATERIAU* mat=mtgest.get_materiau(mgvol->get_num_materiau());
1688 MT_PROPRIETE* prop=mat->get_propriete("EX");
1689 of1<< "MPROP, "<< mgvol->get_num_materiau()+1 << ", EX, " << prop->get_valeur(2) << ";" << std::endl;
1690 prop=mat->get_propriete("NUXY");
1691 of1<< "MPROP, "<< mgvol->get_num_materiau()+1 << ", NUXY, " << prop->get_valeur(2) << ";" << std::endl;
1692 prop=mat->get_propriete("GXY");
1693 of1<< "MPROP, "<< mgvol->get_num_materiau()+1 << ", GXY, " << prop->get_valeur(2) << ";" << std::endl;
1694 prop=mat->get_propriete("DENS");
1695 of1<< "MPROP, "<< mgvol->get_num_materiau()+1 << ", DENS, " << prop->get_valeur(2) << ";" << std::endl;
1696 prop=mat->get_propriete("SIGXT");
1697 of1<< "MPROP, "<< mgvol->get_num_materiau()+1 << ", SIGXT, " << prop->get_valeur(2) << ";" << std::endl;
1698 prop=mat->get_propriete("SIGYLD");
1699 of1<< "MPROP, "<< mgvol->get_num_materiau()+1 << ", SIGYLD, " << prop->get_valeur(2) << ";" << std::endl;
1700 prop=mat->get_propriete("ALPX");
1701 of1<< "MPROP, "<< mgvol->get_num_materiau()+1 << ", ALPX, " << prop->get_valeur(2) << ";" << std::endl;
1702 prop=mat->get_propriete("KX");
1703 of1<< "MPROP, "<< mgvol->get_num_materiau()+1 << ", KX, " << prop->get_valeur(2) << ";" << std::endl;
1704 prop=mat->get_propriete("C");
1705 of1<< "MPROP, "<< mgvol->get_num_materiau()+1 << ", C, " << prop->get_valeur(2) << ";" << std::endl;
1706 }
1707 }
1708 of1 << "ACTSET,CS,0;" << std::endl;
1709 of1 << "ACTSET,EG,1;" << std::endl;
1710 int ii=0;
1711 double valeurunite=mg_geometrie->get_valeur_unite();
1712 for (LISTE_MG_NOEUD::iterator i=lst_mg_noeud.begin();i!=lst_mg_noeud.end();i++)
1713 {
1714 MG_NOEUD* noeud=((*i).second);
1715 of1 << "ND, " << (ii+1) << ", " << noeud->get_x()*valeurunite << ", " << noeud->get_y()*valeurunite << ", " << noeud->get_z()*valeurunite << ";" << std::endl;
1716 char nom[3];
1717 int nb=noeud->get_lien_topologie()->get_nb_ccf();
1718 for (int k=0;k<nb;k++)
1719 {
1720 noeud->get_lien_topologie()->get_type_ccf(k,nom);
1721 if (strcmp(nom,"Da")==0) of1 << "DND , " << ii+1 << ", AL, " << noeud->get_lien_topologie()->get_valeur_ccf(k) << ", " << ii+1 << ", 1;" << std::endl;
1722 if (strcmp(nom,"Dx")==0) of1 << "DND , " << ii+1 << ", UX, " << noeud->get_lien_topologie()->get_valeur_ccf(k) << ", " << ii+1 << ", 1;" << std::endl;
1723 if (strcmp(nom,"Dy")==0) of1 << "DND , " << ii+1 << ", UY, " << noeud->get_lien_topologie()->get_valeur_ccf(k) << ", " << ii+1 << ", 1;" << std::endl;
1724 if (strcmp(nom,"Dz")==0) of1 << "DND , " << ii+1 << ", UZ, " << noeud->get_lien_topologie()->get_valeur_ccf(k) << ", " << ii+1 << ", 1;" << std::endl;
1725 if (strcmp(nom,"Fx")==0) of1 << "FND , " << ii+1 << ", FX, " << noeud->get_lien_topologie()->get_valeur_ccf(k) << ", " << ii+1 << ", 1;" << std::endl;
1726 if (strcmp(nom,"Fy")==0) of1 << "FND , " << ii+1 << ", FY, " << noeud->get_lien_topologie()->get_valeur_ccf(k) << ", " << ii+1 << ", 1;" << std::endl;
1727 if (strcmp(nom,"Fz")==0) of1 << "FND , " << ii+1 << ", FZ, " << noeud->get_lien_topologie()->get_valeur_ccf(k) << ", " << ii+1 << ", 1;" << std::endl;
1728 }
1729 ii++;
1730 noeud->change_nouveau_numero(ii);
1731 }
1732 ii=0;
1733 int nummat=-10;
1734 for (LISTE_MG_TETRA::iterator i=lst_mg_tetra.begin();i!=lst_mg_tetra.end();i++)
1735 {
1736 MG_TETRA* tetra=((*i).second);
1737 MG_VOLUME* vol=(MG_VOLUME*)tetra->get_lien_topologie();
1738 int nummatac=vol->get_num_materiau();
1739 if (nummatac!=nummat)
1740 {
1741 nummat=nummatac;
1742 of1 << "ACTSET, MP," << nummat+1 << ";" << std::endl;
1743 }
1744 of1 << "EL, " << ii+1 << ", VL, 1, 4, " << tetra->get_noeud1()->get_nouveau_numero() << ", " << tetra->get_noeud2()->get_nouveau_numero() << ", " << tetra->get_noeud3()->get_nouveau_numero() << ", " << tetra->get_noeud4()->get_nouveau_numero() << ", " ;
1745 ii++;
1746 if (tetra->get_triangle1()->get_lien_topologie()->get_dimension()!=3) of1 << "1, "; else of1 << "0, ";
1747 if (tetra->get_triangle2()->get_lien_topologie()->get_dimension()!=3) of1 << "1, "; else of1 << "0, ";
1748 if (tetra->get_triangle3()->get_lien_topologie()->get_dimension()!=3) of1 << "1, "; else of1 << "0, ";
1749 if (tetra->get_triangle4()->get_lien_topologie()->get_dimension()!=3) of1 << "1;" << std::endl ; else of1 << "0;" << std::endl;
1750 char nom[3];
1751 int nb=tetra->get_triangle1()->get_lien_topologie()->get_nb_ccf();
1752 for (int k=0;k<nb;k++)
1753 {
1754 tetra->get_triangle1()->get_lien_topologie()->get_type_ccf(k,nom);
1755 if (strcmp(nom,"Px")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle1()->get_lien_topologie()->get_valeur_ccf(k) << ", 1, " << ii << ", 1, 1;" << std::endl;
1756 if (strcmp(nom,"Py")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle1()->get_lien_topologie()->get_valeur_ccf(k) << ", 1, " << ii << ", 1, 2;" << std::endl;
1757 if (strcmp(nom,"Pz")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle1()->get_lien_topologie()->get_valeur_ccf(k) << ", 1, " << ii << ", 1, 3;" << std::endl;
1758 if (strcmp(nom,"Pn")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle1()->get_lien_topologie()->get_valeur_ccf(k) << ", 1, " << ii << ", 1, 4;" << std::endl;
1759 }
1760 nb=tetra->get_triangle2()->get_lien_topologie()->get_nb_ccf();
1761 for (int k=0;k<nb;k++)
1762 {
1763 tetra->get_triangle2()->get_lien_topologie()->get_type_ccf(k,nom);
1764 if (strcmp(nom,"Px")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle2()->get_lien_topologie()->get_valeur_ccf(k) << ", 2, " << ii << ", 1, 1;" << std::endl;
1765 if (strcmp(nom,"Py")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle2()->get_lien_topologie()->get_valeur_ccf(k) << ", 2, " << ii << ", 1, 2;" << std::endl;
1766 if (strcmp(nom,"Pz")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle2()->get_lien_topologie()->get_valeur_ccf(k) << ", 2, " << ii << ", 1, 3;" << std::endl;
1767 if (strcmp(nom,"Pn")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle2()->get_lien_topologie()->get_valeur_ccf(k) << ", 2, " << ii << ", 1, 4;" << std::endl;
1768 }
1769 nb=tetra->get_triangle3()->get_lien_topologie()->get_nb_ccf();
1770 for (int k=0;k<nb;k++)
1771 {
1772 tetra->get_triangle3()->get_lien_topologie()->get_type_ccf(k,nom);
1773 if (strcmp(nom,"Px")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle3()->get_lien_topologie()->get_valeur_ccf(k) << ", 3, " << ii << ", 1, 1;" << std::endl;
1774 if (strcmp(nom,"Py")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle3()->get_lien_topologie()->get_valeur_ccf(k) << ", 3, " << ii << ", 1, 2;" << std::endl;
1775 if (strcmp(nom,"Pz")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle3()->get_lien_topologie()->get_valeur_ccf(k) << ", 3, " << ii << ", 1, 3;" << std::endl;
1776 if (strcmp(nom,"Pn")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle3()->get_lien_topologie()->get_valeur_ccf(k) << ", 3, " << ii << ", 1, 4;" << std::endl;
1777 }
1778 nb=tetra->get_triangle4()->get_lien_topologie()->get_nb_ccf();
1779 for (int k=0;k<nb;k++)
1780 {
1781 tetra->get_triangle4()->get_lien_topologie()->get_type_ccf(k,nom);
1782 if (strcmp(nom,"Px")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle4()->get_lien_topologie()->get_valeur_ccf(k) << ", 4, " << ii << ", 1, 1;" << std::endl;
1783 if (strcmp(nom,"Py")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle4()->get_lien_topologie()->get_valeur_ccf(k) << ", 4, " << ii << ", 1, 2;" << std::endl;
1784 if (strcmp(nom,"Pz")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle4()->get_lien_topologie()->get_valeur_ccf(k) << ", 4, " << ii << ", 1, 3;" << std::endl;
1785 if (strcmp(nom,"Pn")==0) of1 << "PEL , " << ii << ", " << tetra->get_triangle4()->get_lien_topologie()->get_valeur_ccf(k) << ", 4, " << ii << ", 1, 4;" << std::endl;
1786 }
1787 }
1788 }
1789
1790 */
1791
1792
1793
1794 void MG_MAILLAGE::exporter_giref(std::string& nomfic)
1795 {
1796 char chaine[500];
1797 sprintf(chaine,"%s.mail",nomfic.c_str());
1798 FILE *in=fopen(chaine,"wt");
1799 int lieu=0;
1800
1801 fprintf(in,"8 Maillage\n");
1802 fprintf(in,"11 Version 1.0\n");
1803 fprintf(in,"%lu\n\n",get_id());
1804 int nb=get_nb_mg_noeud();
1805 fprintf(in,"%d\n",nb);
1806
1807 LISTE_MG_NOEUD::iterator ind;
1808 MG_NOEUD* noeud=get_premier_noeud(ind);
1809 int i=0;
1810 while (noeud)
1811 {
1812 noeud->change_nouveau_numero(i++);
1813 MG_ELEMENT_TOPOLOGIQUE* topo=noeud->get_lien_topologie();
1814 if (topo->get_nouveau_numero()==-1)
1815 {
1816 topo->change_nouveau_numero(lieu);
1817 lieu++;
1818 }
1819 fprintf(in,"%.16e %.16e %.16e 0 %d \n",noeud->get_x(),noeud->get_y(),noeud->get_z(),topo->get_nouveau_numero());
1820 noeud=get_suivant_noeud(ind);
1821 }
1822
1823
1824 nb=get_nb_mg_segment();
1825 fprintf(in,"\n%d\n",nb);
1826
1827 LISTE_MG_SEGMENT::iterator iseg;
1828 MG_SEGMENT* seg=get_premier_segment(iseg);
1829 i=0;
1830
1831 while (seg)
1832 {
1833
1834 seg->change_nouveau_numero(i);
1835 MG_ELEMENT_TOPOLOGIQUE* topo=seg->get_lien_topologie();
1836 if (topo->get_nouveau_numero()==-1)
1837 {
1838 topo->change_nouveau_numero(lieu);
1839 lieu++;
1840 }
1841 fprintf(in,"%d %d 0 %d \n",seg->get_noeud1()->get_nouveau_numero(),seg->get_noeud2()->get_nouveau_numero(),topo->get_nouveau_numero());
1842 seg = get_suivant_segment(iseg);
1843 }
1844 nb=get_nb_mg_triangle();
1845 fprintf(in,"\n%d\n",nb);
1846 for (int i=0;i<nb;i++)
1847 {
1848 MG_TRIANGLE* tri=get_mg_triangle(i);
1849 tri->change_nouveau_numero(i);
1850 MG_ELEMENT_TOPOLOGIQUE* topo=tri->get_lien_topologie();
1851 if (topo->get_nouveau_numero()==-1)
1852 {
1853 topo->change_nouveau_numero(lieu);
1854 lieu++;
1855 }
1856 fprintf(in,"3 %d %d %d 0 %d \n",tri->get_segment3()->get_nouveau_numero(),tri->get_segment2()->get_nouveau_numero(),tri->get_segment1()->get_nouveau_numero(),topo->get_nouveau_numero());
1857 }
1858 nb=get_nb_mg_tetra();
1859 fprintf(in,"\n0\n\n0\n\n0\n\n%d\n",nb);
1860 for (int i=0;i<nb;i++)
1861 {
1862 MG_TETRA* tet=get_mg_tetra(i);
1863 tet->change_nouveau_numero(i);
1864 MG_ELEMENT_TOPOLOGIQUE* topo=tet->get_lien_topologie();
1865 if (topo->get_nouveau_numero()==-1)
1866 {
1867 topo->change_nouveau_numero(lieu);
1868 lieu++;
1869 }
1870 TPL_MAP_ENTITE<MG_SEGMENT*> lst_segment;
1871 lst_segment.ajouter(tet->get_triangle1()->get_segment1());
1872 lst_segment.ajouter(tet->get_triangle1()->get_segment2());
1873 lst_segment.ajouter(tet->get_triangle1()->get_segment3());
1874 lst_segment.ajouter(tet->get_triangle2()->get_segment1());
1875 lst_segment.ajouter(tet->get_triangle2()->get_segment2());
1876 lst_segment.ajouter(tet->get_triangle2()->get_segment3());
1877 lst_segment.ajouter(tet->get_triangle3()->get_segment1());
1878 lst_segment.ajouter(tet->get_triangle3()->get_segment2());
1879 lst_segment.ajouter(tet->get_triangle3()->get_segment3());
1880 lst_segment.ajouter(tet->get_triangle4()->get_segment1());
1881 lst_segment.ajouter(tet->get_triangle4()->get_segment2());
1882 lst_segment.ajouter(tet->get_triangle4()->get_segment3());
1883 int tab[6];
1884 for (int j=0;j<6;j++)
1885 {
1886 MG_SEGMENT* seg=lst_segment.get(j);
1887 if ((seg->get_noeud1()==tet->get_noeud1()) && (seg->get_noeud2()==tet->get_noeud2())) tab[0]=j;
1888 else if ((seg->get_noeud1()==tet->get_noeud2()) && (seg->get_noeud2()==tet->get_noeud1())) tab[0]=j;
1889 else if ((seg->get_noeud1()==tet->get_noeud1()) && (seg->get_noeud2()==tet->get_noeud3())) tab[1]=j;
1890 else if ((seg->get_noeud1()==tet->get_noeud3()) && (seg->get_noeud2()==tet->get_noeud1())) tab[1]=j;
1891 else if ((seg->get_noeud1()==tet->get_noeud1()) && (seg->get_noeud2()==tet->get_noeud4())) tab[2]=j;
1892 else if ((seg->get_noeud1()==tet->get_noeud4()) && (seg->get_noeud2()==tet->get_noeud1())) tab[2]=j;
1893 else if ((seg->get_noeud1()==tet->get_noeud2()) && (seg->get_noeud2()==tet->get_noeud3())) tab[3]=j;
1894 else if ((seg->get_noeud1()==tet->get_noeud3()) && (seg->get_noeud2()==tet->get_noeud2())) tab[3]=j;
1895 else if ((seg->get_noeud1()==tet->get_noeud2()) && (seg->get_noeud2()==tet->get_noeud4())) tab[4]=j;
1896 else if ((seg->get_noeud1()==tet->get_noeud4()) && (seg->get_noeud2()==tet->get_noeud2())) tab[4]=j;
1897 else if ((seg->get_noeud1()==tet->get_noeud3()) && (seg->get_noeud2()==tet->get_noeud4())) tab[5]=j;
1898 else if ((seg->get_noeud1()==tet->get_noeud4()) && (seg->get_noeud2()==tet->get_noeud3())) tab[5]=j;
1899 }
1900 fprintf(in,"%d %d %d %d %d %d %d %d %d %d %d %d %d %d 0 %d \n",tet->get_noeud1()->get_nouveau_numero(),tet->get_noeud2()->get_nouveau_numero(),tet->get_noeud3()->get_nouveau_numero(),tet->get_noeud4()->get_nouveau_numero(),lst_segment.get(tab[0])->get_nouveau_numero(),lst_segment.get(tab[1])->get_nouveau_numero(),lst_segment.get(tab[2])->get_nouveau_numero(),lst_segment.get(tab[3])->get_nouveau_numero(),lst_segment.get(tab[4])->get_nouveau_numero(),lst_segment.get(tab[5])->get_nouveau_numero(),tet->get_triangle1()->get_nouveau_numero(),tet->get_triangle2()->get_nouveau_numero(),tet->get_triangle3()->get_nouveau_numero(),tet->get_triangle4()->get_nouveau_numero(),topo->get_nouveau_numero());
1901 }
1902
1903 fprintf(in,"\n0\n\n0\n\n8 Maillage\n",nb);
1904 fclose(in);
1905 }
1906
1907
1908 std::ostream& operator << (std::ostream& o,MG_MAILLAGE& maillage)
1909 {
1910 maillage.enregistrer(o);
1911 return o;
1912 }
1913
1914
1915 MG_SOLUTION* MG_MAILLAGE::calculer_carte_taille_reelle(char* nomfichier)
1916 {
1917 int nb_noeud=get_nb_mg_noeud();
1918 std::string nomsol="Carte de taille reelle";
1919 MG_SOLUTION* mgsol=new MG_SOLUTION(this,1,nomfichier,nb_noeud,nomsol);
1920 mgsol->change_legende(0,"F(x,y,z)");
1921 for (int j=0;j<nb_noeud;j++)
1922 {
1923 MG_NOEUD* noeud=get_mg_noeud(j);
1924 int nb_segment=noeud->get_lien_segment()->get_nb();
1925 double ec=0.;
1926 int nbr=0;
1927 for (int k=0;k<nb_segment;k++)
1928 {
1929 MG_SEGMENT* seg=noeud->get_lien_segment()->get(k);
1930 MG_SEGMENT* segtmp=get_mg_segmentid(seg->get_id());
1931 if (segtmp!=NULL)
1932 {
1933 nbr++;
1934 ec=ec+seg->get_longueur();
1935 }
1936 }
1937 ec=ec/nbr;
1938 mgsol->ecrire(ec,j,0,0,0);
1939 }
1940 return mgsol;
1941 }
1942
1943
1944 MG_GESTIONNAIRE* MG_MAILLAGE::get_gestionnaire(void)
1945 {
1946 return gest;
1947 }
1948
1949 void MG_MAILLAGE::change_param_structure(BOITE_3D btmp,int nxtmp,int nytmp,int nztmp)
1950 {
1951 boite_englobante=btmp;
1952 nx=nxtmp;
1953 ny=nytmp;
1954 nz=nztmp;
1955 est_structure=true;
1956 }
1957
1958 bool MG_MAILLAGE::get_param_structure(BOITE_3D &btmp,int &nxtmp,int &nytmp,int &nztmp)
1959 {
1960 if (est_structure==true)
1961 {
1962 btmp=boite_englobante;
1963 nxtmp=nx;
1964 nytmp=ny;
1965 nztmp=nz;
1966 return true;
1967 }
1968 return false;
1969 }
1970
1971
1972 bool MG_MAILLAGE::get_est_structure(void)
1973 {
1974 return est_structure;
1975 }
1976