1 |
francois |
283 |
//------------------------------------------------------------ |
2 |
|
|
//------------------------------------------------------------ |
3 |
|
|
// MAGiC |
4 |
|
|
// Jean Christophe Cuilli�e et Vincent FRANCOIS |
5 |
|
|
// D�artement de G�ie M�anique - UQTR |
6 |
|
|
//------------------------------------------------------------ |
7 |
|
|
// Le projet MAGIC est un projet de recherche du d�artement |
8 |
|
|
// de g�ie m�anique de l'Universit�du Qu�ec � |
9 |
|
|
// Trois Rivi�es |
10 |
|
|
// Les librairies ne peuvent �re utilis�s sans l'accord |
11 |
|
|
// des auteurs (contact : francois@uqtr.ca) |
12 |
|
|
//------------------------------------------------------------ |
13 |
|
|
//------------------------------------------------------------ |
14 |
|
|
// |
15 |
|
|
// mailleur3d.cpp |
16 |
|
|
// |
17 |
|
|
//------------------------------------------------------------ |
18 |
|
|
//------------------------------------------------------------ |
19 |
|
|
// COPYRIGHT 2000 |
20 |
|
|
// Version du 02/03/2006 �11H23 |
21 |
|
|
//------------------------------------------------------------ |
22 |
|
|
//------------------------------------------------------------ |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "gestionversion.h" |
26 |
|
|
|
27 |
|
|
|
28 |
|
|
//#pragma hdrstop |
29 |
|
|
#include <time.h> |
30 |
|
|
#include "tpl_set.h" |
31 |
|
|
#include "mailleur3d.h" |
32 |
|
|
#include "m3d_triangle.h" |
33 |
|
|
#include "mg_gestionnaire.h" |
34 |
francois |
287 |
#include "mailleur3d_optimisation.h" |
35 |
francois |
283 |
//--------------------------------------------------------------------------- |
36 |
|
|
|
37 |
|
|
//#pragma package(smart_init) |
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
MAILLEUR3D::MAILLEUR3D(MG_MAILLAGE* mgmai,MG_GEOMETRIE *mggeo,MG_VOLUME* mgvol,FCT_TAILLE* fct_taille,int destruction):MAILLEUR(),mg_maillage(mgmai),mg_geometrie(mggeo),mg_volume(mgvol),metrique(fct_taille),activelog(0),niveau_optimisation(2),type_mailleur(FRONTAL),typedestruction(destruction) |
42 |
|
|
{ |
43 |
|
|
|
44 |
|
|
for (int i=0;i<100;i++) |
45 |
|
|
{ |
46 |
|
|
cpu[i]=0.; |
47 |
|
|
nbfois[i]=0; |
48 |
|
|
} |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
|
52 |
|
|
MAILLEUR3D::MAILLEUR3D(FCT_GENERATEUR_3D<4> *carte,MG_MAILLAGE* mgmai,OT_CPU* comp,int destruction):MAILLEUR(comp),metrique(carte),type_mailleur(OCTAL),mg_maillage(mgmai),coef(2.),typedestruction(destruction) |
53 |
|
|
{ |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
|
57 |
|
|
MAILLEUR3D::~MAILLEUR3D() |
58 |
|
|
{ |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
void MAILLEUR3D::maille(MG_GROUPE_TOPOLOGIQUE* mggt) |
65 |
|
|
{ |
66 |
|
|
if (type_mailleur==FRONTAL) |
67 |
|
|
{ |
68 |
|
|
if (mg_volume!=NULL) maille(mg_volume); |
69 |
|
|
else |
70 |
|
|
{ |
71 |
|
|
TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> lst; |
72 |
|
|
if (mggt!=NULL) |
73 |
|
|
{ |
74 |
|
|
int nb=mggt->get_nb(); |
75 |
|
|
for (int i=0;i<nb;i++) |
76 |
|
|
{ |
77 |
|
|
lst.ajouter(mggt->get(i)); |
78 |
|
|
mggt->get(i)->get_topologie_sousjacente(&lst); |
79 |
|
|
} |
80 |
|
|
} |
81 |
|
|
int nb_vol=mg_geometrie->get_nb_mg_volume(); |
82 |
|
|
for (int i=0;i<nb_vol;i++) |
83 |
|
|
{ |
84 |
|
|
MG_VOLUME* mgvol=mg_geometrie->get_mg_volume(i); |
85 |
|
|
if (mggt!=NULL) |
86 |
|
|
if (lst.existe(mgvol)==0) continue; |
87 |
|
|
maille(mgvol); |
88 |
|
|
} |
89 |
|
|
} |
90 |
francois |
287 |
} |
91 |
francois |
283 |
if (type_mailleur==OCTAL) |
92 |
|
|
{ |
93 |
|
|
FCT_GENERATEUR_3D<4> *carte=(FCT_GENERATEUR_3D<4> *)metrique; |
94 |
|
|
maille(carte); |
95 |
|
|
} |
96 |
|
|
|
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
void MAILLEUR3D::maille(MG_VOLUME* mgvol,TPL_LISTE_ENTITE<MG_TRIANGLE*> *lsttri,TPL_LISTE_ENTITE<MG_TETRA*> *lsttet) |
102 |
|
|
{ |
103 |
|
|
initialise_frontiere(mgvol); |
104 |
|
|
cree_octree(); |
105 |
|
|
int creation_metrique=0; |
106 |
|
|
if (metrique==NULL) |
107 |
|
|
{ |
108 |
|
|
metrique=new FCT_TAILLE_VOLUME(distance_maximale,octree_de_frontiere); |
109 |
|
|
creation_metrique=1; |
110 |
|
|
} |
111 |
|
|
else distance_maximale=metrique->get_valeur_maximale(0); |
112 |
|
|
if (affichageactif==1) (*affiche)((char*)" Construction du front"); |
113 |
|
|
initialise_front(mgvol); |
114 |
|
|
if (lsttri!=NULL) insere_contrainte_triangle(mgvol,lsttri); |
115 |
|
|
if (lsttet!=NULL) insere_contrainte_tetra(mgvol,lsttet); |
116 |
|
|
if (affichageactif==1) (*affiche)((char*)" Progression du front"); |
117 |
|
|
//mg_maillage->get_gestionnaire()->enregistrer("c:\\void.magic"); |
118 |
|
|
progresse_front(mgvol); |
119 |
|
|
if (affichageactif==1) (*affiche)((char*)" Construction du maillage final"); |
120 |
|
|
detruit_element_inactif(); |
121 |
|
|
if (affichageactif==1) (*affiche)((char*)" Optimisation du maillage final"); |
122 |
francois |
287 |
MAILLEUR3D_OPTIMISATION opt(mg_maillage,niveau_optimisation); |
123 |
francois |
374 |
if (affichageactif==1) opt.active_affichage(affiche); |
124 |
francois |
288 |
opt.optimise(mgvol); |
125 |
francois |
283 |
if (creation_metrique==1) delete metrique; |
126 |
|
|
|
127 |
|
|
delete octree_de_triangle; |
128 |
|
|
delete octree_de_frontiere; |
129 |
|
|
delete octree_de_front; |
130 |
|
|
|
131 |
|
|
triangle_frontiere.vide(); |
132 |
|
|
noeud_frontiere.vide(); |
133 |
|
|
noeud_arete_frontiere.vide(); |
134 |
|
|
} |
135 |
|
|
|
136 |
|
|
void MAILLEUR3D::initialise_frontiere(MG_VOLUME* mgvol) |
137 |
|
|
{ |
138 |
|
|
clock_t cpu1=clock(); //debug |
139 |
|
|
int nbcoq=mgvol->get_nb_mg_coquille(); |
140 |
|
|
for (int i=0;i<nbcoq;i++) |
141 |
|
|
{ |
142 |
|
|
MG_COQUILLE* mgcoq=mgvol->get_mg_coquille(i); |
143 |
|
|
int nbcoface=mgcoq->get_nb_mg_coface(); |
144 |
|
|
for (int j=0;j<nbcoface;j++) |
145 |
|
|
{ |
146 |
|
|
MG_COFACE* coface=mgcoq->get_mg_coface(j); |
147 |
|
|
MG_FACE* mgface=coface->get_face(); |
148 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*> * lien_maillage = mgface->get_lien_maillage(); |
149 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR it; |
150 |
|
|
MG_ELEMENT_MAILLAGE* element; |
151 |
|
|
for (element = lien_maillage->get_premier(it); element; element = lien_maillage->get_suivant(it) ) |
152 |
|
|
{ |
153 |
|
|
MG_TRIANGLE* mgtri=(MG_TRIANGLE*)element; |
154 |
|
|
MG_TRIANGLE* tritemp=mg_maillage->get_mg_triangleid(mgtri->get_id()); |
155 |
|
|
if (tritemp==NULL) continue; |
156 |
|
|
triangle_frontiere.ajouter(mgtri); |
157 |
|
|
noeud_frontiere.ajouter(mgtri->get_noeud1()); |
158 |
|
|
noeud_frontiere.ajouter(mgtri->get_noeud2()); |
159 |
|
|
noeud_frontiere.ajouter(mgtri->get_noeud3()); |
160 |
|
|
} |
161 |
|
|
int nbbou=mgface->get_nb_mg_boucle(); |
162 |
|
|
for (int l=0;l<nbbou;l++) |
163 |
|
|
{ |
164 |
|
|
MG_BOUCLE* mgbou=mgface->get_mg_boucle(l); |
165 |
|
|
int nbcoarete=mgbou->get_nb_mg_coarete(); |
166 |
|
|
for (int m=0;m<nbcoarete;m++) |
167 |
|
|
{ |
168 |
|
|
MG_COARETE* mgcoarete=mgbou->get_mg_coarete(m); |
169 |
|
|
MG_ARETE* mgarete=mgcoarete->get_arete(); |
170 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*> * lien_maillage = mgarete->get_lien_maillage(); |
171 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR it; |
172 |
|
|
MG_ELEMENT_MAILLAGE* element; |
173 |
|
|
for (element = lien_maillage->get_premier(it); element; element = lien_maillage->get_suivant(it) ) |
174 |
|
|
{ |
175 |
|
|
MG_SEGMENT* mgseg=(MG_SEGMENT*)element; |
176 |
|
|
MG_SEGMENT* segtemp=mg_maillage->get_mg_segmentid(mgseg->get_id()); |
177 |
|
|
if (segtemp==NULL) continue; |
178 |
|
|
noeud_arete_frontiere.ajouter(mgseg->get_noeud1()); |
179 |
|
|
noeud_arete_frontiere.ajouter(mgseg->get_noeud2()); |
180 |
|
|
} |
181 |
|
|
} |
182 |
|
|
} |
183 |
|
|
} |
184 |
|
|
} |
185 |
|
|
|
186 |
|
|
clock_t cpu2=clock(); //debug |
187 |
|
|
cpu[0]=cpu[0]+(cpu2-cpu1)/CLK_TCK; //debug |
188 |
|
|
nbfois[0]++; //debug |
189 |
|
|
} |
190 |
|
|
|
191 |
|
|
void MAILLEUR3D::cree_octree(void) |
192 |
|
|
{ |
193 |
|
|
/*double xmin,ymin,zmin; |
194 |
|
|
double xmax,ymax,zmax; |
195 |
|
|
|
196 |
|
|
clock_t cpu1=clock(); // debug |
197 |
|
|
int nb_noeud=noeud_arete_frontiere.get_nb(); |
198 |
|
|
for (int i=0;i<nb_noeud;i++) |
199 |
|
|
{ |
200 |
|
|
MG_NOEUD* mgnoeud=noeud_arete_frontiere.get(i); |
201 |
|
|
if (i==0) |
202 |
|
|
{ |
203 |
|
|
xmin=mgnoeud->get_x(); |
204 |
|
|
xmax=mgnoeud->get_x(); |
205 |
|
|
ymin=mgnoeud->get_y(); |
206 |
|
|
ymax=mgnoeud->get_y(); |
207 |
|
|
zmin=mgnoeud->get_z(); |
208 |
|
|
zmax=mgnoeud->get_z(); |
209 |
|
|
} |
210 |
|
|
else |
211 |
|
|
{ |
212 |
|
|
xmin=std::min(xmin,mgnoeud->get_x()); |
213 |
|
|
ymin=std::min(ymin,mgnoeud->get_y()); |
214 |
|
|
zmin=std::min(zmin,mgnoeud->get_z()); |
215 |
|
|
xmax=std::max(xmax,mgnoeud->get_x()); |
216 |
|
|
ymax=std::max(ymax,mgnoeud->get_y()); |
217 |
|
|
zmax=std::max(zmax,mgnoeud->get_z()); |
218 |
|
|
} |
219 |
|
|
} |
220 |
|
|
double xdiff=xmax-xmin; |
221 |
|
|
double ydiff=ymax-ymin; |
222 |
|
|
double zdiff=zmax-zmin; |
223 |
|
|
double xcentre=0.5*(xmax+xmin); |
224 |
|
|
double ycentre=0.5*(ymax+ymin); |
225 |
|
|
double zcentre=0.5*(zmax+zmin); |
226 |
|
|
xmin=xcentre-10.25*xdiff; |
227 |
|
|
xmax=xcentre+10.25*xdiff; |
228 |
|
|
ymin=ycentre-10.25*ydiff; |
229 |
|
|
ymax=ycentre+10.25*ydiff; |
230 |
|
|
zmin=zcentre-10.25*zdiff; |
231 |
|
|
zmax=zcentre+10.25*zdiff; */ |
232 |
|
|
FCT_GENERATEUR_3D<4> *carte=(FCT_GENERATEUR_3D<4> *)metrique; |
233 |
|
|
int nb_cellule=carte->get_nb_cellule(); |
234 |
|
|
double param[32]; |
235 |
|
|
carte->get_information(0,0,param); |
236 |
|
|
double xmin=param[0]+0.005*(param[1]-param[0]); |
237 |
|
|
double ymin=param[8]+0.005*(param[10]-param[8]); |
238 |
|
|
double zmin=param[16]+0.005*(param[20]-param[16]); |
239 |
|
|
carte->get_information(nb_cellule-1,0,param); |
240 |
|
|
double xmax=param[1]-0.005*(param[1]-param[0]); |
241 |
|
|
double ymax=param[10]-0.005*(param[10]-param[8]); |
242 |
|
|
double zmax=param[20]-0.005*(param[20]-param[16]); |
243 |
|
|
octree_de_triangle=new TPL_OCTREE_FCT<MG_TRIANGLE*,FCT_GENERATEUR_3D<4> >; |
244 |
|
|
octree_de_frontiere=new TPL_OCTREE<MG_TRIANGLE*,MG_NOEUD*>; |
245 |
|
|
octree_de_front=new TPL_OCTREE<MG_FRONT_3D*,MG_NOEUD*>; |
246 |
|
|
octree_de_triangle->initialiser(*carte,xmin,ymin,zmin,xmax,ymax,zmax); |
247 |
|
|
octree_de_frontiere->initialiser(octree_de_triangle); |
248 |
|
|
octree_de_front->initialiser(octree_de_triangle); |
249 |
|
|
|
250 |
|
|
int nb_triangle=triangle_frontiere.get_nb(); |
251 |
|
|
for (int j=0;j<nb_triangle;j++) |
252 |
|
|
{ |
253 |
|
|
octree_de_frontiere->inserer(triangle_frontiere.get(j)); |
254 |
|
|
octree_de_triangle->inserer(triangle_frontiere.get(j)); |
255 |
|
|
} |
256 |
|
|
/*clock_t cpu2=clock(); //debug |
257 |
|
|
cpu[1]=cpu[1]+(cpu2-cpu1)/CLK_TCK; //debug |
258 |
|
|
nbfois[1]++; //debug*/ |
259 |
|
|
} |
260 |
|
|
|
261 |
|
|
void MAILLEUR3D::initialise_front(MG_VOLUME* mgvol) |
262 |
|
|
{ |
263 |
|
|
clock_t cpu1=clock(); //debug |
264 |
|
|
// constitution du front |
265 |
|
|
int nbcoq=mgvol->get_nb_mg_coquille(); |
266 |
|
|
for (int i=0;i<nbcoq;i++) |
267 |
|
|
{ |
268 |
|
|
MG_COQUILLE* mgcoq=mgvol->get_mg_coquille(i); |
269 |
|
|
int nbcoface=mgcoq->get_nb_mg_coface(); |
270 |
|
|
for (int j=0;j<nbcoface;j++) |
271 |
|
|
{ |
272 |
|
|
MG_COFACE* coface=mgcoq->get_mg_coface(j); |
273 |
|
|
MG_FACE* mgface=coface->get_face(); |
274 |
|
|
|
275 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*> * lien_maillage = mgface->get_lien_maillage(); |
276 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR it; |
277 |
|
|
MG_ELEMENT_MAILLAGE* element; |
278 |
|
|
for (element = lien_maillage->get_premier(it); element; element = lien_maillage->get_suivant(it) ) |
279 |
|
|
{ |
280 |
|
|
MG_TRIANGLE* mgtri=(MG_TRIANGLE*)element; |
281 |
|
|
MG_TRIANGLE* tritemp=mg_maillage->get_mg_triangleid(mgtri->get_id()); |
282 |
|
|
if (tritemp==NULL) continue; |
283 |
|
|
if (coface->get_orientation()==1) ajouter_front_courant(NONFORCE,mgtri->get_noeud1(),mgtri->get_noeud2(),mgtri->get_noeud3(),mgtri); |
284 |
|
|
else ajouter_front_courant(NONFORCE,mgtri->get_noeud1(),mgtri->get_noeud3(),mgtri->get_noeud2(),mgtri); |
285 |
|
|
} |
286 |
|
|
} |
287 |
|
|
} |
288 |
|
|
|
289 |
|
|
// recherche des voisins |
290 |
|
|
for (int l=0;l<11;l++) |
291 |
|
|
{ |
292 |
|
|
int nb_front=get_nb_front(front_courant[l]); |
293 |
|
|
for (int i=0;i<nb_front;i++) |
294 |
|
|
{ |
295 |
|
|
MG_FRONT_3D* ft=get_front(front_courant[l],i); |
296 |
|
|
MG_NOEUD* mgnoeud1=ft->get_noeud1(); |
297 |
|
|
MG_NOEUD* mgnoeud2=ft->get_noeud2(); |
298 |
|
|
MG_NOEUD* mgnoeud3=ft->get_noeud3(); |
299 |
|
|
ft->changer_front_voisin(NULL,0); |
300 |
|
|
ft->changer_front_voisin(NULL,1); |
301 |
|
|
ft->changer_front_voisin(NULL,2); |
302 |
|
|
for (int j=0;j<mgnoeud1->get_lien_triangle()->get_nb();j++) |
303 |
|
|
for (int k=0;k<mgnoeud2->get_lien_triangle()->get_nb();k++) |
304 |
|
|
{ |
305 |
|
|
M3D_TRIANGLE* tri1=(M3D_TRIANGLE*)mgnoeud1->get_lien_triangle()->get(j); |
306 |
|
|
M3D_TRIANGLE* tri2=(M3D_TRIANGLE*)mgnoeud2->get_lien_triangle()->get(k); |
307 |
|
|
if (tri1==tri2) |
308 |
|
|
if (tri1->get_etat_front()==FRONT_ACTIF) |
309 |
|
|
if (tri1->get_mgfront()!=ft) |
310 |
|
|
{ |
311 |
|
|
MG_FRONT_3D* ft2=tri1->get_mgfront(); |
312 |
|
|
if (ft->get_front_voisin(0)==NULL) |
313 |
|
|
{ |
314 |
|
|
ft->changer_front_voisin(ft2,0); |
315 |
|
|
ft->changer_angle_voisin(angle_front(ft,ft2),0); |
316 |
|
|
} |
317 |
|
|
else |
318 |
|
|
{ |
319 |
|
|
double angle=angle_front(ft,ft2); |
320 |
|
|
if (angle<ft->get_angle_voisin(0)) |
321 |
|
|
{ |
322 |
|
|
ft->changer_front_voisin(ft2,0); |
323 |
|
|
ft->changer_angle_voisin(angle,0); |
324 |
|
|
} |
325 |
|
|
} |
326 |
|
|
} |
327 |
|
|
} |
328 |
|
|
for (int j=0;j<mgnoeud1->get_lien_triangle()->get_nb();j++) |
329 |
|
|
for (int k=0;k<mgnoeud3->get_lien_triangle()->get_nb();k++) |
330 |
|
|
{ |
331 |
|
|
M3D_TRIANGLE* tri1=(M3D_TRIANGLE*)mgnoeud1->get_lien_triangle()->get(j); |
332 |
|
|
M3D_TRIANGLE* tri2=(M3D_TRIANGLE*)mgnoeud3->get_lien_triangle()->get(k); |
333 |
|
|
if (tri1==tri2) |
334 |
|
|
if (tri1->get_etat_front()==FRONT_ACTIF) |
335 |
|
|
if (tri1->get_mgfront()!=ft) |
336 |
|
|
{ |
337 |
|
|
MG_FRONT_3D* ft2=tri1->get_mgfront(); |
338 |
|
|
if (ft->get_front_voisin(1)==NULL) |
339 |
|
|
{ |
340 |
|
|
ft->changer_front_voisin(ft2,1); |
341 |
|
|
ft->changer_angle_voisin(angle_front(ft,ft2),1); |
342 |
|
|
} |
343 |
|
|
else |
344 |
|
|
{ |
345 |
|
|
double angle=angle_front(ft,ft2); |
346 |
|
|
if (angle<ft->get_angle_voisin(1)) |
347 |
|
|
{ |
348 |
|
|
ft->changer_front_voisin(ft2,1); |
349 |
|
|
ft->changer_angle_voisin(angle,1); |
350 |
|
|
} |
351 |
|
|
} |
352 |
|
|
} |
353 |
|
|
} |
354 |
|
|
for (int j=0;j<mgnoeud2->get_lien_triangle()->get_nb();j++) |
355 |
|
|
for (int k=0;k<mgnoeud3->get_lien_triangle()->get_nb();k++) |
356 |
|
|
{ |
357 |
|
|
M3D_TRIANGLE* tri1=(M3D_TRIANGLE*)mgnoeud2->get_lien_triangle()->get(j); |
358 |
|
|
M3D_TRIANGLE* tri2=(M3D_TRIANGLE*)mgnoeud3->get_lien_triangle()->get(k); |
359 |
|
|
if (tri1==tri2) |
360 |
|
|
if (tri1->get_etat_front()==FRONT_ACTIF) |
361 |
|
|
if (tri1->get_mgfront()!=ft) |
362 |
|
|
{ |
363 |
|
|
MG_FRONT_3D* ft2=tri1->get_mgfront(); |
364 |
|
|
if (ft->get_front_voisin(2)==NULL) |
365 |
|
|
{ |
366 |
|
|
ft->changer_front_voisin(ft2,2); |
367 |
|
|
ft->changer_angle_voisin(angle_front(ft,ft2),2); |
368 |
|
|
} |
369 |
|
|
else |
370 |
|
|
{ |
371 |
|
|
double angle=angle_front(ft,ft2); |
372 |
|
|
if (angle<ft->get_angle_voisin(2)) |
373 |
|
|
{ |
374 |
|
|
ft->changer_front_voisin(ft2,2); |
375 |
|
|
ft->changer_angle_voisin(angle,2); |
376 |
|
|
} |
377 |
|
|
} |
378 |
|
|
} |
379 |
|
|
} |
380 |
|
|
if ( (ft->get_front_voisin(0)==NULL) || (ft->get_front_voisin(1)==NULL)|| (ft->get_front_voisin(2)==NULL)) |
381 |
|
|
refresh(); |
382 |
|
|
} |
383 |
|
|
|
384 |
|
|
} |
385 |
|
|
clock_t cpu2=clock(); //debug |
386 |
|
|
cpu[2]=cpu[2]+(cpu2-cpu1)/CLK_TCK; //debug |
387 |
|
|
nbfois[2]++; //debug |
388 |
|
|
} |
389 |
|
|
|
390 |
|
|
|
391 |
|
|
|
392 |
|
|
// FONCTIONS GERANT L ENTITE FRONT (ajout suppression et tout le bordel) |
393 |
|
|
MG_FRONT_3D* MAILLEUR3D::ajouter_front_courant(int numero_front,MG_NOEUD* noeud1,MG_NOEUD* noeud2,MG_NOEUD* noeud3,MG_TRIANGLE* triangle) |
394 |
|
|
{ |
395 |
|
|
int numfront; |
396 |
|
|
if (numero_front==NONFORCE) |
397 |
|
|
{ |
398 |
|
|
numfront=(int)(triangle->get_longueur()/distance_maximale*10.); |
399 |
|
|
if (numfront>10) numfront=10; |
400 |
|
|
} |
401 |
|
|
else numfront=numero_front; |
402 |
|
|
MG_FRONT_3D* mgfront; |
403 |
|
|
if (numfront>11) mgfront=ajouter_front(front_attente,noeud1,noeud2,noeud3,triangle); |
404 |
|
|
else mgfront=ajouter_front(front_courant[numfront],noeud1,noeud2,noeud3,triangle); |
405 |
|
|
mgfront->changer_numero_front(numfront); |
406 |
|
|
if (triangle->get_type_entite()==IDM3D_TRIANGLE) |
407 |
|
|
{ |
408 |
|
|
M3D_TRIANGLE* mtri=(M3D_TRIANGLE*)triangle; |
409 |
|
|
mtri->change_etat_front(FRONT_ACTIF); |
410 |
|
|
mtri->change_mgfront(mgfront); |
411 |
|
|
} |
412 |
|
|
return mgfront; |
413 |
|
|
} |
414 |
|
|
|
415 |
|
|
MG_FRONT_3D* MAILLEUR3D::ajouter_front(FRONT& front,MG_NOEUD* noeud1,MG_NOEUD* noeud2,MG_NOEUD* noeud3,MG_TRIANGLE* triangle) |
416 |
|
|
{ |
417 |
|
|
MG_FRONT_3D* ft=new MG_FRONT_3D(noeud1,noeud2,noeud3,triangle); |
418 |
|
|
ajouter_front(front,ft); |
419 |
|
|
octree_de_front->inserer(ft); |
420 |
|
|
return ft; |
421 |
|
|
} |
422 |
|
|
|
423 |
|
|
void MAILLEUR3D::ajouter_front(FRONT& front,MG_FRONT_3D *ft) |
424 |
|
|
{ |
425 |
|
|
std::pair<const double,MG_FRONT_3D*> tmp(ft->get_triangle()->get_longueur(),ft); |
426 |
|
|
front.insert(tmp); |
427 |
|
|
} |
428 |
|
|
|
429 |
|
|
MG_FRONT_3D* MAILLEUR3D::get_front(FRONT& front,unsigned int num) |
430 |
|
|
{ |
431 |
|
|
FRONT::iterator i=front.begin(); |
432 |
|
|
for (unsigned long j=0;j<num;j++) i++; |
433 |
|
|
return ((*i).second); |
434 |
|
|
} |
435 |
|
|
|
436 |
|
|
|
437 |
|
|
unsigned int MAILLEUR3D::get_nb_front(FRONT& front) |
438 |
|
|
{ |
439 |
|
|
return front.size(); |
440 |
|
|
} |
441 |
|
|
|
442 |
|
|
unsigned int MAILLEUR3D::get_nb_front_courant(void) |
443 |
|
|
{ |
444 |
|
|
|
445 |
|
|
return front_courant[0].size()+front_courant[1].size()+front_courant[2].size()+front_courant[3].size()+front_courant[4].size()+front_courant[5].size()+front_courant[6].size()+front_courant[7].size()+front_courant[8].size()+front_courant[9].size()+front_courant[10].size(); |
446 |
|
|
} |
447 |
|
|
|
448 |
|
|
void MAILLEUR3D::supprimer_front_en_avancant(MG_FRONT_3D* ft) |
449 |
|
|
{ |
450 |
|
|
supprimer_front_en_avancant_sans_delete(ft); |
451 |
|
|
delete ft; |
452 |
|
|
} |
453 |
|
|
|
454 |
|
|
void MAILLEUR3D::supprimer_front_en_avancant_sans_delete(MG_FRONT_3D* ft) |
455 |
|
|
{ |
456 |
|
|
octree_de_front->supprimer(ft); |
457 |
|
|
int numfront=ft->get_numero_front(); |
458 |
|
|
FRONT* front_original; |
459 |
|
|
if (numfront==ATTENTE) |
460 |
|
|
front_original=&front_attente; |
461 |
|
|
else |
462 |
|
|
front_original=front_courant+numfront; |
463 |
|
|
FRONT::iterator j=front_original->lower_bound(ft->get_triangle()->get_longueur()); |
464 |
|
|
while (ft!=(*j).second) j++; |
465 |
|
|
front_original->erase(j); |
466 |
|
|
MG_TRIANGLE* mgtri=ft->get_triangle(); |
467 |
|
|
if (mgtri->get_type_entite()==IDM3D_TRIANGLE) |
468 |
|
|
{ |
469 |
|
|
M3D_TRIANGLE* m3dtri=(M3D_TRIANGLE*)mgtri; |
470 |
|
|
m3dtri->change_etat_front(FRONT_PASSE); |
471 |
|
|
m3dtri->change_mgfront(NULL); |
472 |
|
|
} |
473 |
|
|
} |
474 |
|
|
|
475 |
|
|
void MAILLEUR3D::supprimer_front_en_reculant(MG_FRONT_3D* ft) |
476 |
|
|
{ |
477 |
|
|
octree_de_front->supprimer(ft); |
478 |
|
|
int numfront=ft->get_numero_front(); |
479 |
|
|
FRONT* front_original; |
480 |
|
|
if (numfront==ATTENTE) |
481 |
|
|
front_original=&front_attente; |
482 |
|
|
else |
483 |
|
|
front_original=front_courant+numfront; |
484 |
|
|
FRONT::iterator j=front_original->lower_bound(ft->get_triangle()->get_longueur()); |
485 |
|
|
while (ft!=(*j).second) j++; |
486 |
|
|
front_original->erase(j); |
487 |
|
|
MG_TRIANGLE* mgtri=ft->get_triangle(); |
488 |
|
|
if (mgtri->get_type_entite()==IDM3D_TRIANGLE) |
489 |
|
|
{ |
490 |
|
|
M3D_TRIANGLE* m3dtri=(M3D_TRIANGLE*)mgtri; |
491 |
|
|
m3dtri->change_etat_front(FRONT_NONACTIF); |
492 |
|
|
m3dtri->change_mgfront(NULL); |
493 |
|
|
} |
494 |
|
|
delete ft; |
495 |
|
|
} |
496 |
|
|
|
497 |
|
|
void MAILLEUR3D::echange_de_front(FRONT& front_original,FRONT& front_destination,MG_FRONT_3D* ft) |
498 |
|
|
{ |
499 |
|
|
FRONT::iterator j=front_original.lower_bound(ft->get_triangle()->get_longueur()); |
500 |
|
|
while (ft!=(*j).second) j++; |
501 |
|
|
front_original.erase(j); |
502 |
|
|
ajouter_front(front_destination,ft); |
503 |
|
|
} |
504 |
|
|
|
505 |
|
|
void MAILLEUR3D::echange_de_front(MG_FRONT_3D* ft,int num) |
506 |
|
|
{ |
507 |
|
|
int numfront; |
508 |
|
|
if (num==NONFORCE) |
509 |
|
|
{ |
510 |
|
|
numfront=(int)(ft->get_triangle()->get_longueur()/distance_maximale*10.); |
511 |
|
|
if (numfront>10) numfront=10; |
512 |
|
|
} |
513 |
|
|
else if (num==ATTENTE) numfront=ATTENTE; |
514 |
|
|
else numfront=num; |
515 |
|
|
if (numfront>10) numfront=ATTENTE; |
516 |
|
|
FRONT* front_original; |
517 |
|
|
int num_front_original=ft->get_numero_front(); |
518 |
|
|
if (num_front_original==ATTENTE) |
519 |
|
|
front_original=&front_attente; |
520 |
|
|
else |
521 |
|
|
front_original=front_courant+num_front_original; |
522 |
|
|
FRONT* front_destination; |
523 |
|
|
if (numfront==ATTENTE) |
524 |
|
|
front_destination=&front_attente; |
525 |
|
|
else |
526 |
|
|
front_destination=front_courant+numfront; |
527 |
|
|
|
528 |
|
|
|
529 |
|
|
|
530 |
|
|
FRONT::iterator j=front_original->lower_bound(ft->get_triangle()->get_longueur()); |
531 |
|
|
while (ft!=(*j).second) j++; |
532 |
|
|
front_original->erase(j); |
533 |
|
|
ft->changer_numero_front(numfront); |
534 |
|
|
ajouter_front(*front_destination,ft); |
535 |
|
|
|
536 |
|
|
} |
537 |
|
|
|
538 |
|
|
|
539 |
|
|
void MAILLEUR3D::swap_front(FRONT& front_original,FRONT& front_destination) |
540 |
|
|
{ |
541 |
|
|
front_original.swap(front_destination); |
542 |
|
|
} |
543 |
|
|
|
544 |
|
|
|
545 |
|
|
|
546 |
|
|
int MAILLEUR3D::premier_front_courant(void) |
547 |
|
|
{ |
548 |
|
|
int num=-1; |
549 |
|
|
if (front_courant[0].size()>0) num=0; |
550 |
|
|
else if (front_courant[1].size()>0) num=1; |
551 |
|
|
else if (front_courant[2].size()>0) num=2; |
552 |
|
|
else if (front_courant[3].size()>0) num=3; |
553 |
|
|
else if (front_courant[4].size()>0) num=4; |
554 |
|
|
else if (front_courant[5].size()>0) num=5; |
555 |
|
|
else if (front_courant[6].size()>0) num=6; |
556 |
|
|
else if (front_courant[7].size()>0) num=7; |
557 |
|
|
else if (front_courant[8].size()>0) num=8; |
558 |
|
|
else if (front_courant[9].size()>0) num=9; |
559 |
|
|
else if (front_courant[10].size()>0) num=10; |
560 |
|
|
return num; |
561 |
|
|
} |
562 |
|
|
|
563 |
|
|
|
564 |
|
|
|
565 |
|
|
void MAILLEUR3D::active_log(char* nomfile) |
566 |
|
|
{ |
567 |
|
|
activelog=1; |
568 |
|
|
nomlog=nomfile; |
569 |
|
|
} |
570 |
|
|
|
571 |
|
|
void MAILLEUR3D::desactive_log(void) |
572 |
|
|
{ |
573 |
|
|
activelog=0; |
574 |
|
|
} |
575 |
|
|
|
576 |
francois |
287 |
void MAILLEUR3D::change_niveau_optimisation(int num) |
577 |
|
|
{ |
578 |
|
|
niveau_optimisation=num; |
579 |
|
|
} |
580 |
francois |
283 |
|
581 |
francois |
287 |
int MAILLEUR3D::get_niveau_optimisation(void) |
582 |
|
|
{ |
583 |
|
|
return niveau_optimisation; |
584 |
|
|
} |
585 |
francois |
283 |
|