MAGiC  V5.0
Mailleurs Automatiques de Géometries intégrés à la Cao
mailleur2d_traite_front.cpp
Aller à la documentation de ce fichier.
1 //####//------------------------------------------------------------
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 //####// mailleur2d_traite_front.cpp
15 //####//
16 //####//------------------------------------------------------------
17 //####//------------------------------------------------------------
18 //####// COPYRIGHT 2000-2024
19 //####// jeu 13 jun 2024 11:58:55 EDT
20 //####//------------------------------------------------------------
21 //####//------------------------------------------------------------
22 
23 
24 #include "gestionversion.h"
25 #include "mailleur2d.h"
26 #include "ot_mathematique.h"
27 
28 
29 
30 
31 int MAILLEUR2D::traite_front(int type_front,MG_FACE *mgface,MG_FRONT_2D* ftp,MG_FRONT_2D* ft,MG_FRONT_2D* fts)
32 {
33 int solution;
34 
35 switch (type_front)
36  {
37  case MAGIC::MAILLEURFRONTALETAT::CAS_FRONT_3: solution=traite_front_cas_front_3(mgface,ftp,ft,fts);
38  break;
39  case MAGIC::MAILLEURFRONTALETAT::CAS_FRONT_4: solution=traite_front_cas_front_4(mgface,ftp,ft,fts);
40  break;
42  break;
44  break;
46  break;
47  case MAGIC::MAILLEURFRONTALETAT::CAS_GENERAL: solution=traite_front_cas_general(mgface,ftp,ft,fts);
48  break;
49  }
50 
51 return solution;
52 }
53 
54 
55 
56 
58 {
59 MG_NOEUD* no1=ft->get_noeud1();
60 MG_NOEUD* no2=fts->get_noeud2();
61 MG_NOEUD* no3=ft->get_noeud2();
63 insere_triangle(mgface,ft->get_noeud1(),fts->get_noeud2(),ft->get_noeud2());
64 supprimer_front(ftp);
65 supprimer_front(ft);
66 supprimer_front(fts);
68 }
69 
70 
71 
73 {
74 MG_NOEUD* nop=ftp->get_noeud1();
75 MG_NOEUD* no1=ft->get_noeud1();
76 MG_NOEUD* no2=ft->get_noeud2();
77 MG_NOEUD* nos=fts->get_noeud2();
78 MG_SEGMENT* mgsegment=NULL;
79 if (noeud_est_dans_triangle(nos,nop,no1,no2))
80  {
83  insere_segment(mgface,&mgsegment,no1,nos,MAGIC::MAILLEURFRONTALETAT::RIEN);
84  insere_triangle(mgface,no1,nos,no2);
85  insere_triangle(mgface,nop,nos,no1);
86  }
87 else if (noeud_est_dans_triangle(no2,nop,no1,nos))
88  {
91  insere_segment(mgface,&mgsegment,no2,nop,MAGIC::MAILLEURFRONTALETAT::RIEN);
92  insere_triangle(mgface,no1,nop,no2);
93  insere_triangle(mgface,nop,nos,no2);
94  }
95 else if (noeud_est_dans_triangle(no1,nop,no2,nos))
96  {
99  insere_segment(mgface,&mgsegment,no1,nos,MAGIC::MAILLEURFRONTALETAT::RIEN);
100  insere_triangle(mgface,no1,nos,no2);
101  insere_triangle(mgface,nop,nos,no1);
102  }
103 else if (noeud_est_dans_triangle(nop,no1,no2,nos))
104  {
107  insere_segment(mgface,&mgsegment,no2,nop,MAGIC::MAILLEURFRONTALETAT::RIEN);
108  insere_triangle(mgface,no1,nop,no2);
109  insere_triangle(mgface,nop,nos,no2);
110  }
111 else
112  {
113  double crit11=OPERATEUR::qualite_triangle(no1->get_coord(),no2->get_coord(),nop->get_coord());
114  double crit12=OPERATEUR::qualite_triangle(nop->get_coord(),no2->get_coord(),nos->get_coord());
115  double crit21=OPERATEUR::qualite_triangle(no1->get_coord(),no2->get_coord(),nos->get_coord());
116  double crit22=OPERATEUR::qualite_triangle(nop->get_coord(),no1->get_coord(),nos->get_coord());
117  double crit1=std::min(crit11,crit12);
118  double crit2=std::min(crit21,crit22);
119  if (crit1>crit2)
120  {
123  insere_segment(mgface,&mgsegment,nop,no2,MAGIC::MAILLEURFRONTALETAT::RIEN);
124  insere_triangle(mgface,no1,nop,no2);
125  insere_triangle(mgface,nop,nos,no2);
126  }
127  else
128  {
131  insere_segment(mgface,&mgsegment,no1,nos,MAGIC::MAILLEURFRONTALETAT::RIEN);
132  insere_triangle(mgface,no1,nos,no2);
133  insere_triangle(mgface,nop,nos,no1);
134  }
135  }
137 supprimer_front(ftp);
138 supprimer_front(ft);
139 supprimer_front(fts);
141 }
142 
144 {
145 MG_NOEUD* nop=ftp->get_noeud1();
146 MG_NOEUD* no1=ft->get_noeud1();
147 MG_NOEUD* no2=ft->get_noeud2();
148 MG_NOEUD* nos=fts->get_noeud2();
149 double crit11=OPERATEUR::qualite_triangle(no1->get_coord(),no2->get_coord(),nop->get_coord());
150 double crit12=OPERATEUR::qualite_triangle(nop->get_coord(),no2->get_coord(),nos->get_coord());
151 double crit21=OPERATEUR::qualite_triangle(no1->get_coord(),no2->get_coord(),nos->get_coord());
152 double crit22=OPERATEUR::qualite_triangle(nop->get_coord(),no1->get_coord(),nos->get_coord());
153 double crit1=std::min(crit11,crit12);
154 double crit2=std::min(crit21,crit22);
155 MG_SEGMENT* mgsegment=NULL;
156 MG_SEGMENT* mgsegmentref=NULL;
157 int ierr=insere_segment(mgface,&mgsegment,nop,nos,MAGIC::MAILLEURFRONTALETAT::TOUS_SEGMENT);
158 int solu;
159 if (ierr==1)
160  {
161  if (crit1>crit2)
162  {
163  ierr=insere_segment(mgface,&mgsegmentref,nop,no2,MAGIC::MAILLEURFRONTALETAT::TOUS_FRONT);
164  solu=1;
165  }
166  else
167  {
168  ierr=insere_segment(mgface,&mgsegmentref,no1,nos,MAGIC::MAILLEURFRONTALETAT::TOUS_FRONT);
169  solu=2;
170  }
171  if (ierr==0)
172  if (crit1>crit2)
173  {
174  ierr=insere_segment(mgface,&mgsegmentref,no1,nos,MAGIC::MAILLEURFRONTALETAT::TOUS_FRONT);
175  solu=2;
176  }
177  else
178  {
179  ierr=insere_segment(mgface,&mgsegmentref,nop,no2,MAGIC::MAILLEURFRONTALETAT::TOUS_FRONT);
180  solu=1;
181  }
182  if (ierr==0)
183  {
184  supprime_segment(mgsegment);
186  }
187  else
188  {
189  MG_FRONT_2D *nv_ft=ajouter_front(front_courant,nop,nos,mgsegment);
194  supprimer_front(ft);
195  supprimer_front(ftp);
196  supprimer_front(fts);
197  if (solu==1)
198  {
199  insere_triangle(mgface,no1,nop,no2);
200  insere_triangle(mgface,nop,nos,no2);
201  }
202  else
203  {
204  insere_triangle(mgface,no1,nos,no2);
205  insere_triangle(mgface,nop,nos,no1);
206  }
207  }
208  }
211 }
212 
214 {
215 MG_NOEUD* nop=ftp->get_noeud1();
216 MG_NOEUD* no1=ft->get_noeud1();
217 MG_NOEUD* no2=ft->get_noeud2();
218 MG_SEGMENT* mgsegment=NULL;
219 int ierr=insere_segment(mgface,&mgsegment,nop,no2,MAGIC::MAILLEURFRONTALETAT::TOUS_SEGMENT);
220 if (ierr==1)
221  {
222  MG_FRONT_2D *nv_ft=ajouter_front(front_courant,nop,no2,mgsegment);
224  nv_ft->changer_front_suivant(fts);
226  fts->changer_front_precedent(nv_ft);
227  insere_triangle(mgface,no1,nop,no2);
228  supprimer_front(ft);
229  supprimer_front(ftp);
231  }
233 }
234 
236 {
237 MG_NOEUD* no1=ft->get_noeud1();
238 MG_NOEUD* no2=ft->get_noeud2();
239 MG_NOEUD* nos=fts->get_noeud2();
240 MG_SEGMENT* mgsegment=NULL;
241 
242 int ierr=insere_segment(mgface,&mgsegment,no1,nos,MAGIC::MAILLEURFRONTALETAT::TOUS_SEGMENT);
243 if (ierr==1)
244  {
245  MG_FRONT_2D *nv_ft=ajouter_front(front_courant,no1,nos,mgsegment);
246  nv_ft->changer_front_precedent(ftp);
248  ftp->changer_front_suivant(nv_ft);
250  insere_triangle(mgface,no1,nos,no2);
251  supprimer_front(ft);
252  supprimer_front(fts);
254  }
256 }
257 
259 {
260 MG_NOEUD* nop=ftp->get_noeud1();
261 MG_NOEUD* no1=ft->get_noeud1();
262 MG_NOEUD* no2=ft->get_noeud2();
263 MG_NOEUD* nos=fts->get_noeud2();
264 MG_FRONT_2D* front_rencontre;
265 MG_NOEUD* noeud_solution;
266 
267 int solution=genere_noeud(mgface,ft,&front_rencontre,&noeud_solution);
269  {
270  if (noeud_solution==nos) solution=traite_front_cas_ferme_cavite_s(mgface,ftp,ft,fts);
271  if (noeud_solution==nop) solution=traite_front_cas_ferme_cavite_p(mgface,ftp,ft,fts);
272  }
274  {
275  MG_SEGMENT* mgsegment=NULL;
276  MG_SEGMENT* mgsegment2=NULL;
277  int ierr=insere_segment(mgface,&mgsegment,no1,noeud_solution,MAGIC::MAILLEURFRONTALETAT::TOUS_FRONT);
278  int ierr2;
279  if (ierr) ierr2=insere_segment(mgface,&mgsegment2,noeud_solution,no2,MAGIC::MAILLEURFRONTALETAT::TOUS_FRONT);
280  if ( ierr==0 )
281  {
282  mg_maillage->supprimer_mg_noeudid(noeud_solution->get_id());
284  }
285  else if ( ierr2==0 )
286  {
287  supprime_segment(mgsegment);
289  }
290  else
291  {
292  MG_FRONT_2D *nv_ft=ajouter_front(front_courant,no1,noeud_solution,mgsegment);
293  MG_FRONT_2D *nv_ft2=ajouter_front(front_courant,noeud_solution,no2,mgsegment2);
294  ftp->changer_front_suivant(nv_ft);
295  nv_ft->changer_front_precedent(ftp);
296  nv_ft->changer_front_suivant(nv_ft2);
297  nv_ft2->changer_front_precedent(nv_ft);
298  nv_ft2->changer_front_suivant(fts);
299  fts->changer_front_precedent(nv_ft2);
300  insere_triangle(mgface,no1,noeud_solution,no2);
301  supprimer_front(ft);
303  }
304  }
306  {
307  MG_SEGMENT* mgsegment=NULL;
308  MG_SEGMENT* mgsegment2=NULL;
309  int ierr=insere_segment(mgface,&mgsegment,no1,noeud_solution,MAGIC::MAILLEURFRONTALETAT::TOUS_FRONT);
310  int ierr2;
311  if (ierr) ierr2=insere_segment(mgface,&mgsegment2,noeud_solution,no2,MAGIC::MAILLEURFRONTALETAT::TOUS_FRONT);
312  if (ierr==0) solution=MAGIC::MAILLEURFRONTALETAT::PASTROUVE;
313  else if (ierr2==0)
314  {
315  supprime_segment(mgsegment);
317  }
318  else
319  {
320  MG_FRONT_2D *nv_ft=ajouter_front(front_courant,no1,noeud_solution,mgsegment);
321  MG_FRONT_2D *nv_ft2=ajouter_front(front_courant,noeud_solution,no2,mgsegment2);
322  ftp->changer_front_suivant(nv_ft);
323  nv_ft->changer_front_precedent(ftp);
324  nv_ft->changer_front_suivant(front_rencontre);
325  nv_ft2->changer_front_precedent(front_rencontre->get_front_precedent());
326  nv_ft2->changer_front_suivant(fts);
327  fts->changer_front_precedent(nv_ft2);
328  front_rencontre->get_front_precedent()->changer_front_suivant(nv_ft2);
329  front_rencontre->changer_front_precedent(nv_ft);
330  insere_triangle(mgface,no1,noeud_solution,no2);
331  supprimer_front(ft);
333  }
334  }
336 return solution;
337 }
338 
MAGIC::MAILLEURFRONTALETAT::NOEUD_CREE
@ NOEUD_CREE
Definition: mg_definition.h:106
MAILLEUR2D::traite_front
int traite_front(int type_front, MG_FACE *mgface, MG_FRONT_2D *ftp, MG_FRONT_2D *ft, MG_FRONT_2D *fts)
Definition: mailleur2d_traite_front.cpp:31
MAGIC::MAILLEURFRONTALETAT::ERREUR
@ ERREUR
Definition: mg_definition.h:106
MAGIC::MAILLEURFRONTALETAT::TOUS_SEGMENT
@ TOUS_SEGMENT
Definition: mg_definition.h:106
MG_SEGMENT
Definition: mg_segment.h:38
MAILLEUR2D::supprimer_front
void supprimer_front(MG_FRONT_2D *ft)
Definition: mailleur2d.cpp:1648
MAILLEUR2D::front_courant
FRONT front_courant
Definition: mailleur2d.h:123
MAILLEUR2D::supprime_segment
void supprime_segment(MG_SEGMENT *mgsegment)
Definition: mailleur2d_outil.cpp:140
gestionversion.h
MG_FRONT_2D
Definition: mg_front_2D.h:32
MAILLEUR2D::insere_triangle
MG_TRIANGLE * insere_triangle(MG_ELEMENT_TOPOLOGIQUE *topo, class MG_NOEUD *mgnoeud1, class MG_NOEUD *mgnoeud2, class MG_NOEUD *mgnoeud3)
Definition: mailleur2d_outil.cpp:301
MAGIC::MAILLEURFRONTALETAT::TOUS_FRONT
@ TOUS_FRONT
Definition: mg_definition.h:106
MAILLEUR2D::ajouter_front
MG_FRONT_2D * ajouter_front(FRONT &front, MG_NOEUD *noeud1, MG_NOEUD *noeud2, MG_SEGMENT *segment)
Definition: mailleur2d.cpp:1620
mailleur2d.h
MAILLEUR2D::mg_maillage
MG_MAILLAGE * mg_maillage
Definition: mailleur2d.h:110
MG_IDENTIFICATEUR::get_id
unsigned long get_id()
Definition: mg_identificateur.cpp:53
MG_FRONT_2D::get_noeud1
MG_NOEUD * get_noeud1(void)
Definition: mg_front_2D.cpp:43
MAGIC::MAILLEURFRONTALETAT::PASTROUVE
@ PASTROUVE
Definition: mg_definition.h:106
MAILLEUR2D::insere_segment
int insere_segment(MG_FACE *mgface, MG_SEGMENT **nv_segment, MG_NOEUD *noeud1, MG_NOEUD *noeud2, int type_verication)
Definition: mailleur2d_outil.cpp:77
MAILLEUR2D::noeud_est_dans_triangle
int noeud_est_dans_triangle(MG_NOEUD *noeud, MG_TRIANGLE *triangle)
Definition: mailleur2d_outil.cpp:37
MG_FRONT_2D::get_front_suivant
MG_FRONT_2D * get_front_suivant(void)
Definition: mg_front_2D.cpp:63
MAGIC::MAILLEURFRONTALETAT::TROUVE
@ TROUVE
Definition: mg_definition.h:106
MAILLEUR2D::traite_front_cas_front_4
int traite_front_cas_front_4(MG_FACE *mgface, MG_FRONT_2D *ftp, MG_FRONT_2D *ft, MG_FRONT_2D *fts)
Definition: mailleur2d_traite_front.cpp:72
MG_FRONT_2D::get_noeud2
MG_NOEUD * get_noeud2(void)
Definition: mg_front_2D.cpp:48
MAILLEUR2D::traite_front_cas_ferme_cavite_p
int traite_front_cas_ferme_cavite_p(MG_FACE *mgface, MG_FRONT_2D *ftp, MG_FRONT_2D *ft, MG_FRONT_2D *fts)
Definition: mailleur2d_traite_front.cpp:213
MAGIC::MAILLEURFRONTALETAT::CAS_FERME_CAVITE_S
@ CAS_FERME_CAVITE_S
Definition: mg_definition.h:106
MAILLEUR2D::traite_front_cas_general
int traite_front_cas_general(MG_FACE *mgface, MG_FRONT_2D *ftp, MG_FRONT_2D *ft, MG_FRONT_2D *fts)
Definition: mailleur2d_traite_front.cpp:258
MG_NOEUD
Definition: mg_noeud.h:41
MAILLEUR2D::traite_front_cas_ferme_cavite_s
int traite_front_cas_ferme_cavite_s(MG_FACE *mgface, MG_FRONT_2D *ftp, MG_FRONT_2D *ft, MG_FRONT_2D *fts)
Definition: mailleur2d_traite_front.cpp:235
MG_NOEUD::get_coord
virtual double * get_coord(void)
Definition: mg_noeud.cpp:92
MAGIC::MAILLEURFRONTALETAT::CAS_FRONT_3
@ CAS_FRONT_3
Definition: mg_definition.h:106
MAILLEUR2D::traite_front_cas_ferme_cavite
int traite_front_cas_ferme_cavite(MG_FACE *mgface, MG_FRONT_2D *ftp, MG_FRONT_2D *ft, MG_FRONT_2D *fts)
Definition: mailleur2d_traite_front.cpp:143
MAGIC::MAILLEURFRONTALETAT::FRONT_RENCONTRE
@ FRONT_RENCONTRE
Definition: mg_definition.h:106
MAGIC::MAILLEURFRONTALETAT::CAS_GENERAL
@ CAS_GENERAL
Definition: mg_definition.h:106
ot_mathematique.h
MG_FRONT_2D::changer_front_suivant
void changer_front_suivant(MG_FRONT_2D *front)
Definition: mg_front_2D.cpp:73
MAGIC::MAILLEURFRONTALETAT::CAS_FERME_CAVITE_P
@ CAS_FERME_CAVITE_P
Definition: mg_definition.h:106
MAILLEUR2D::traite_front_cas_front_3
int traite_front_cas_front_3(MG_FACE *mgface, MG_FRONT_2D *ftp, MG_FRONT_2D *ft, MG_FRONT_2D *fts)
Definition: mailleur2d_traite_front.cpp:57
MAILLEUR2D::triangle_est_dans_bon_sens
int triangle_est_dans_bon_sens(MG_FACE *face, MG_NOEUD *noeud1, MG_NOEUD *noeud2, MG_NOEUD *noeud3)
Definition: mailleur2d_outil.cpp:317
MG_FRONT_2D::get_front_precedent
MG_FRONT_2D * get_front_precedent(void)
Definition: mg_front_2D.cpp:58
MG_MAILLAGE::supprimer_mg_noeudid
int supprimer_mg_noeudid(unsigned long num)
Definition: mg_maillage.cpp:482
OPERATEUR::qualite_triangle
static double qualite_triangle(double *noeud1, double *noeud2, double *noeud3)
Definition: ot_mathematique.cpp:1647
MAGIC::MAILLEURFRONTALETAT::CAS_FRONT_4
@ CAS_FRONT_4
Definition: mg_definition.h:106
MG_FACE
Definition: mg_face.h:34
MG_FRONT_2D::changer_front_precedent
void changer_front_precedent(MG_FRONT_2D *front)
Definition: mg_front_2D.cpp:68
MAGIC::MAILLEURFRONTALETAT::CAS_FERME_CAVITE
@ CAS_FERME_CAVITE
Definition: mg_definition.h:106
MAGIC::MAILLEURFRONTALETAT::RIEN
@ RIEN
Definition: mg_definition.h:106
MAILLEUR2D::genere_noeud
int genere_noeud(MG_FACE *mgface, MG_FRONT_2D *front, MG_FRONT_2D **front_rencontre, MG_NOEUD **noeud)
Definition: mailleur2d_outil.cpp:147