MAGiC  V5.0
Mailleurs Automatiques de Géometries intégrés à la Cao
mailleur3d_octal.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 //####// mailleur3d_octal.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 "mailleur3d.h"
26 
27 
29 {
30  metrique=metri;
31  BOITE_3D boite=metri->get_boite_3D();
32  double xmin=boite.get_xmin();
33  double ymin=boite.get_ymin();
34  double zmin=boite.get_zmin();
35  double xmax=boite.get_xmax();
36  double ymax=boite.get_ymax();
37  double zmax=boite.get_zmax();
40  octree.initialiser(*metri,xmin,ymin,zmin,xmax,ymax,zmax);
41  octree.equilibre();
42  int nb_feuille=octree.get_nb_feuille();
43  std::map<int,MG_NOEUD*,std::less<unsigned long> > lst;
44  for (int i=0;i<nb_feuille;i++)
45  {
46  for (int j=0;j<8;j++)
47  {
48  unsigned long keycode=octree.get_feuille_keycode(i,j);
49  if (lst[keycode]==NULL)
50  {
51  double x,y,z;
52  octree.get_xyzsommet_feuille(i,j,x,y,z);
53  MG_NOEUD* noeud=new MG_NOEUD(NULL,x,y,z,MAGIC::ORIGINE::MAILLEUR_AUTO);
55  lst[keycode]=noeud;
56  }
57  }
58  }
59  for (int i=0;i<nb_feuille;i++)
60  {
62  double xyz[3];
63  feuille->boite.get_centre(xyz);
64  MG_NOEUD* noeud=new MG_NOEUD(NULL,xyz[0],xyz[1],xyz[2],MAGIC::ORIGINE::MAILLEUR_AUTO);
66  int face[6]={0,0,0,0,0,0};
67  for (int j=0;j<6;j++)
68  {
69  //OUTIL_OCTREE oo;
71  if (cell!=NULL)
72  if (cell->feuille==0)
73  face[j]=1;
74  }
75  for (int j=0;j<6;j++)
76  {
77  OUTIL_OCTREE oo;
78  int arete[5]={0,0,0,0};
79  if (face[j]==1)
80  {
81  arete[0]=1;
82  arete[1]=1;
83  arete[2]=1;
84  arete[3]=1;
85  }
86  for (int k=0;k<4;k++)
87  {
88  if (arete[k]==0)
89  {
90  if (face[oo.faceadjacente(j,k)]==1)
91  arete[k]=1;
92  else
93  {
94  int numarete=oo.areteface(j,k);
96  if (cell!=NULL)
97  if (cell->feuille==0) arete[k]=1;
98  }
99  }
100  }
101  arete[4]=arete[0]+arete[1]+arete[2]+arete[3];
102  if (arete[4]==0)
103  {
104  unsigned long key1=octree.get_feuille_keycode(i,oo.sommetface(j,0));
105  unsigned long key2=octree.get_feuille_keycode(i,oo.sommetface(j,1));
106  unsigned long key3=octree.get_feuille_keycode(i,oo.sommetface(j,2));
107  unsigned long key4=octree.get_feuille_keycode(i,oo.sommetface(j,3));
108  if ( (j==2) || (j==4) )
109  {
110  if ( (feuille->get_sontype()==0) ||(feuille->get_sontype()==1) ||(feuille->get_sontype()==6) ||(feuille->get_sontype()==7))
111  {
112  insere_tetra(mg_maillage,lst[key1],lst[key3],lst[key2],noeud);
113  insere_tetra(mg_maillage,lst[key1],lst[key4],lst[key3],noeud);
114  }
115  else
116  {
117  insere_tetra(mg_maillage,lst[key1],lst[key2],lst[key4],noeud);
118  insere_tetra(mg_maillage,lst[key2],lst[key3],lst[key4],noeud);
119  }
120  }
121  if ( (j==1) || (j==3) )
122  {
123  if ( (feuille->get_sontype()==0) ||(feuille->get_sontype()==2) ||(feuille->get_sontype()==5) ||(feuille->get_sontype()==7))
124  {
125  insere_tetra(mg_maillage,lst[key1],lst[key3],lst[key2],noeud);
126  insere_tetra(mg_maillage,lst[key1],lst[key4],lst[key3],noeud);
127  }
128  else
129  {
130  insere_tetra(mg_maillage,lst[key1],lst[key2],lst[key4],noeud);
131  insere_tetra(mg_maillage,lst[key2],lst[key3],lst[key4],noeud);
132  }
133  }
134  if ( (j==0) || (j==5) )
135  {
136  if ( (feuille->get_sontype()==0) ||(feuille->get_sontype()==4) ||(feuille->get_sontype()==7) ||(feuille->get_sontype()==3))
137  {
138  insere_tetra(mg_maillage,lst[key1],lst[key3],lst[key2],noeud);
139  insere_tetra(mg_maillage,lst[key1],lst[key4],lst[key3],noeud);
140  }
141  else
142  {
143  insere_tetra(mg_maillage,lst[key1],lst[key2],lst[key4],noeud);
144  insere_tetra(mg_maillage,lst[key2],lst[key3],lst[key4],noeud);
145  }
146  }
147  }
148  else
149  {
150  OUTIL_OCTREE oo;
151  double xcentre=0.,ycentre=0.,zcentre=0.;
152  double x,y,z;
153  octree.get_xyzsommet_feuille(i,oo.sommetface(j,0),x,y,z);
154  xcentre=xcentre+x;
155  ycentre=ycentre+y;
156  zcentre=zcentre+z;
157  octree.get_xyzsommet_feuille(i,oo.sommetface(j,1),x,y,z);
158  xcentre=xcentre+x;
159  ycentre=ycentre+y;
160  zcentre=zcentre+z;
161  octree.get_xyzsommet_feuille(i,oo.sommetface(j,2),x,y,z);
162  xcentre=xcentre+x;
163  ycentre=ycentre+y;
164  zcentre=zcentre+z;
165  octree.get_xyzsommet_feuille(i,oo.sommetface(j,3),x,y,z);
166  xcentre=xcentre+x;
167  ycentre=ycentre+y;
168  zcentre=zcentre+z;
169  xcentre=0.25*xcentre;
170  ycentre=0.25*ycentre;
171  zcentre=0.25*zcentre;
172  unsigned long key=octree.get_keycode(xcentre,ycentre,zcentre);
173  if (lst[key]==NULL)
174  {
175  MG_NOEUD* noeud=new MG_NOEUD(NULL,xcentre,ycentre,zcentre,MAGIC::ORIGINE::MAILLEUR_AUTO);
177  lst[key]=noeud;
178  }
179  MG_NOEUD* centroideface=lst[key];
180  for (int k=0;k<4;k++)
181  {
182  unsigned long key1=octree.get_feuille_keycode(i,oo.sommetarete(oo.areteface(j,k),0));
183  unsigned long key2=octree.get_feuille_keycode(i,oo.sommetarete(oo.areteface(j,k),1));
184  if (arete[k]==0)
185  {
186  insere_tetra(mg_maillage,lst[key1],lst[key2],centroideface,noeud);
187  }
188  else
189  {
190  double x1,y1,z1,x2,y2,z2;
191  octree.get_xyzsommet_feuille(i,oo.sommetarete(oo.areteface(j,k),0),x1,y1,z1);
192  octree.get_xyzsommet_feuille(i,oo.sommetarete(oo.areteface(j,k),1),x2,y2,z2);
193  unsigned long keymilieu=octree.get_keycode(0.5*(x1+x2),0.5*(y1+y2),0.5*(z1+z2));
194  insere_tetra(mg_maillage,lst[key1],lst[keymilieu],centroideface,noeud);
195  insere_tetra(mg_maillage,lst[keymilieu],lst[key2],centroideface,noeud);
196 
197  }
198  }
199  }
200 
201  }
202 
203 
204  }
205 return OK;
206 }
207 
208 
209 
210 void MAILLEUR3D::insere_tetra(MG_MAILLAGE* mai,MG_NOEUD* noeud1,MG_NOEUD* noeud2,MG_NOEUD* noeud3,MG_NOEUD* noeud4)
211 {
212  double q=OPERATEUR::qualite_tetra(noeud1->get_coord(),noeud2->get_coord(),noeud3->get_coord(),noeud4->get_coord());
213  if (q>0.) mai->ajouter_mg_tetra(NULL,noeud1,noeud2,noeud3,noeud4,MAGIC::ORIGINE::MAILLEUR_AUTO);
214  else mai->ajouter_mg_tetra(NULL,noeud2,noeud1,noeud3,noeud4,MAGIC::ORIGINE::MAILLEUR_AUTO);
215 }
216 
217 
218 
219 void MAILLEUR3D::change_coef(double val)
220 {
221  coef=val;
222 }
223 
225 {
226  int nbtri=mai->get_nb_mg_triangle();
227  for (int i=0;i<nbtri;i++)
228  {
229  MG_TRIANGLE* tri=mai->get_mg_triangle(i);
230  if (tri->get_lien_tetra()->get_nb()!=1) continue;
231  MG_NOEUD* noeud[3];
232  noeud[0]=tri->get_noeud1();
233  noeud[1]=tri->get_noeud2();
234  noeud[2]=tri->get_noeud3();
235  MG_NOEUD* n1=new MG_NOEUD(NULL,noeud[0]->get_x(),noeud[0]->get_y(),noeud[0]->get_z(),MAGIC::ORIGINE::MAILLEUR_AUTO);
236  MG_NOEUD* n2=new MG_NOEUD(NULL,noeud[1]->get_x(),noeud[1]->get_y(),noeud[1]->get_z(),MAGIC::ORIGINE::MAILLEUR_AUTO);
237  MG_NOEUD* n3=new MG_NOEUD(NULL,noeud[2]->get_x(),noeud[2]->get_y(),noeud[2]->get_z(),MAGIC::ORIGINE::MAILLEUR_AUTO);
238  maisur->ajouter_mg_noeud(n1);
239  maisur->ajouter_mg_noeud(n2);
240  maisur->ajouter_mg_noeud(n3);
241  maisur->ajouter_mg_triangle(NULL,n1,n2,n3,MAGIC::ORIGINE::MAILLEUR_AUTO);
242  }
243 }
FCT_TAILLE::get_boite_3D
virtual BOITE_3D get_boite_3D(void)=0
MG_MAILLAGE::ajouter_mg_tetra
MG_TETRA * 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=0)
Definition: mg_maillage.cpp:1158
TPL_OCTREE_FCT::initialiser
virtual void initialiser(B &fonction, double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
Definition: tpl_octree.h:1027
MAILLEUR3D::coef
double coef
Definition: mailleur3d.h:184
TPL_OCTREE::get_keycode
virtual unsigned long get_keycode(TPL_CELLULE_OCTREE< A, CONDITION > *cellule, int numsommet)
Definition: tpl_octree.h:734
gestionversion.h
BOITE_3D::get_xmin
double get_xmin(void)
Definition: ot_boite_3d.cpp:104
TPL_OCTREE::get_nb_feuille
virtual int get_nb_feuille(void)
Definition: tpl_octree.h:358
MG_MAILLAGE::get_nb_mg_triangle
unsigned int get_nb_mg_triangle(void)
Definition: mg_maillage.cpp:814
BOITE_3D::get_centre
void get_centre(double *coo)
Definition: ot_boite_3d.cpp:149
OUTIL_OCTREE::areteface
int areteface(int numface, int numarete)
Definition: tpl_octree.h:201
OUTIL_OCTREE
Definition: tpl_octree.h:33
TPL_OCTREE::get_xyzsommet_feuille
virtual void get_xyzsommet_feuille(int numcellule, int numsommet, double &x, double &y, double &z)
Definition: tpl_octree.h:789
MAILLEUR3D::maille
virtual int maille(MG_GROUPE_TOPOLOGIQUE *mggt=NULL)
Definition: mailleur3d.cpp:55
MAILLEUR3D::verifie_conformite_octale
virtual void verifie_conformite_octale(MG_MAILLAGE *mai, MG_MAILLAGE *maisur)
Definition: mailleur3d_octal.cpp:224
MAILLEUR3D::mg_maillage
MG_MAILLAGE * mg_maillage
Definition: mailleur3d.h:167
OK
const int OK
Definition: mg_definition.h:38
MG_TRIANGLE
Definition: mg_triangle.h:38
FCT_TAILLE
Definition: fct_taille.h:30
OUTIL_OCTREE::sommetarete
int sommetarete(int numarete, int numsommet)
Definition: tpl_octree.h:177
MG_TRIANGLE::get_lien_tetra
TPL_LISTE_ENTITE< class MG_TETRA * > * get_lien_tetra(void)
Definition: mg_triangle.cpp:177
TPL_OCTREE_FCT< MG_NOEUD *, FCT_TAILLE >
TPL_OCTREE_FCT::change_coefficent_multiplicateur
virtual void change_coefficent_multiplicateur(double val)
Definition: tpl_octree.h:1025
BOITE_3D::get_zmax
double get_zmax(void)
Definition: ot_boite_3d.cpp:129
BOITE_3D::get_ymin
double get_ymin(void)
Definition: ot_boite_3d.cpp:114
MAILLEUR3D::change_coef
virtual void change_coef(double val)
Definition: mailleur3d_octal.cpp:219
MAILLEUR3D::metrique
FCT_TAILLE * metrique
Definition: mailleur3d.h:170
TPL_CELLULE_OCTREE
Definition: tpl_octree.h:267
TPL_OCTREE::get_feuille
virtual TPL_CELLULE_OCTREE< A, CONDITION > * get_feuille(int num)
Definition: tpl_octree.h:363
MG_MAILLAGE::ajouter_mg_triangle
MG_TRIANGLE * ajouter_mg_triangle(MG_ELEMENT_TOPOLOGIQUE *topo, class MG_NOEUD *mgnoeud1, class MG_NOEUD *mgnoeud2, class MG_NOEUD *mgnoeud3, int origine, unsigned long num=0)
Definition: mg_maillage.cpp:731
BOITE_3D::get_xmax
double get_xmax(void)
Definition: ot_boite_3d.cpp:109
MG_NOEUD
Definition: mg_noeud.h:41
OUTIL_OCTREE::faceadjacente
int faceadjacente(int numface, int numarete)
Definition: tpl_octree.h:215
MG_NOEUD::get_coord
virtual double * get_coord(void)
Definition: mg_noeud.cpp:92
TPL_LISTE_ENTITE::get_nb
virtual int get_nb(void)
Definition: tpl_liste_entite.h:67
TPL_CELLULE_OCTREE::boite
BOITE_3D boite
Definition: tpl_octree.h:276
MG_TRIANGLE::get_noeud2
virtual MG_NOEUD * get_noeud2(void)
Definition: mg_triangle.cpp:131
BOITE_3D::get_ymax
double get_ymax(void)
Definition: ot_boite_3d.cpp:119
OPERATEUR::qualite_tetra
static double qualite_tetra(double *noeud1, double *noeud2, double *noeud3, double *noeud4)
Definition: ot_mathematique.cpp:1673
TPL_OCTREE::equilibre
virtual void equilibre(int niveauequilibre=1)
Definition: tpl_octree.h:809
MG_TRIANGLE::get_noeud1
virtual MG_NOEUD * get_noeud1(void)
Definition: mg_triangle.cpp:126
BOITE_3D
Definition: ot_boite_3d.h:27
MG_MAILLAGE::get_mg_triangle
MG_TRIANGLE * get_mg_triangle(unsigned int num)
Definition: mg_maillage.cpp:784
mailleur3d.h
TPL_OCTREE::get_cellule_adjacent
virtual TPL_CELLULE_OCTREE< A, CONDITION > * get_cellule_adjacent(TPL_CELLULE_OCTREE< A, CONDITION > *cellule, int direction)
Definition: tpl_octree.h:650
OUTIL_OCTREE::sommetface
int sommetface(int numface, int numsommet)
Definition: tpl_octree.h:163
TPL_CELLULE_OCTREE::get_sontype
int get_sontype(void)
Definition: tpl_octree.h:290
MG_TRIANGLE::get_noeud3
virtual MG_NOEUD * get_noeud3(void)
Definition: mg_triangle.cpp:137
BOITE_3D::get_zmin
double get_zmin(void)
Definition: ot_boite_3d.cpp:124
MG_MAILLAGE
Definition: mg_maillage.h:62
TPL_CELLULE_OCTREE::feuille
int feuille
Definition: tpl_octree.h:278
TPL_OCTREE::get_cellule_voisin
virtual TPL_CELLULE_OCTREE< A, CONDITION > * get_cellule_voisin(TPL_CELLULE_OCTREE< A, CONDITION > *cellule, int direction)
Definition: tpl_octree.h:664
MAGIC::ORIGINE::MAILLEUR_AUTO
@ MAILLEUR_AUTO
Definition: mg_definition.h:79
MAILLEUR3D::insere_tetra
virtual class MG_TETRA * insere_tetra(class MG_ELEMENT_TOPOLOGIQUE *mgvol, class MG_FRONT_3D *ft, MG_NOEUD *noeud4, int type, TPL_MAP_ENTITE< class MG_TRIANGLE * > &liste_intersection)
Definition: mailleur3d_outil.cpp:147
MG_MAILLAGE::ajouter_mg_noeud
MG_NOEUD * ajouter_mg_noeud(MG_ELEMENT_TOPOLOGIQUE *topo, double xx, double yy, double zz, int origine, unsigned long num=0)
Definition: mg_maillage.cpp:421
TPL_OCTREE::get_feuille_keycode
virtual unsigned long get_feuille_keycode(int numcellule, int numsommet)
Definition: tpl_octree.h:728