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 |
//####// mstruct_generateur.cpp |
15 |
//####// |
16 |
//####//------------------------------------------------------------ |
17 |
//####//------------------------------------------------------------ |
18 |
//####// COPYRIGHT 2000-2024 |
19 |
//####// jeu 13 jun 2024 11:58:57 EDT |
20 |
//####//------------------------------------------------------------ |
21 |
//####//------------------------------------------------------------ |
22 |
#include "mstruct_generateur.h" |
23 |
#include "mstruct_definition.h" |
24 |
#include "mg_cg_modele.h" |
25 |
#include "mg_gestionnaire.h" |
26 |
#include "mg_cg.h" |
27 |
#include "ot_geometrie.h" |
28 |
#include "mg_cg_forme_volume.h" |
29 |
#include "mg_cg_forme_multi_volume.h" |
30 |
#include "mg_cg_op_inclusion_matrice.h" |
31 |
#include "mg_cg_op_bool_difference.h" |
32 |
#include "mg_cg_op_bool_intersection.h" |
33 |
#include "mg_cg_op_transf_decallage.h" |
34 |
#include <stack> |
35 |
|
36 |
|
37 |
MSTRUCT_GENERATEUR::MSTRUCT_GENERATEUR(MG_GESTIONNAIRE* mg_gestionnaire,char* nom_mgcg_modele) |
38 |
{ |
39 |
m_mg_gestionnaire=mg_gestionnaire; |
40 |
m_mgcg_modele=MG_CG::creer_MG_CG_MODELE(m_mg_gestionnaire,nom_mgcg_modele); |
41 |
mg_gestionnaire->ajouter_mgcg_modele(m_mgcg_modele); |
42 |
m_mgcg_modele->change_importer_triangulation(true); |
43 |
m_mgcg_modele->change_fusionner_entite_similaire(false); |
44 |
m_mgcg_modele->change_epsilon_triangulation(0.01); |
45 |
m_grille_init=false; |
46 |
} |
47 |
|
48 |
MSTRUCT_GENERATEUR::MSTRUCT_GENERATEUR(MSTRUCT_GENERATEUR& mcpy) |
49 |
{ |
50 |
m_mg_gestionnaire=mcpy.m_mg_gestionnaire; |
51 |
m_mgcg_modele=mcpy.m_mgcg_modele; |
52 |
m_boite3d_ves=mcpy.m_boite3d_ves; |
53 |
m_boite3d_distribution=mcpy.m_boite3d_distribution; |
54 |
m_intersection_bords_ves=mcpy.m_intersection_bords_ves; |
55 |
m_angle_min=mcpy.m_angle_min; |
56 |
m_longueur_min=mcpy.m_longueur_min; |
57 |
m_aire_min=mcpy.m_aire_min; |
58 |
m_volume_min=mcpy.m_volume_min; |
59 |
m_distance_min=mcpy.m_distance_min; |
60 |
m_nb_pas_grille=mcpy.m_nb_pas_grille; |
61 |
m_nb_pas_echantillonnage=mcpy.m_nb_pas_echantillonnage; |
62 |
m_precision=mcpy.m_precision; |
63 |
m_grille_init=mcpy.m_grille_init; |
64 |
if(m_grille_init) |
65 |
m_grille_volume_inclusion.initialiser(m_boite3d_distribution.get_xmin(),m_boite3d_distribution.get_ymin(),m_boite3d_distribution.get_zmin(), |
66 |
m_boite3d_distribution.get_xmax(),m_boite3d_distribution.get_ymax(),m_boite3d_distribution.get_zmax(), |
67 |
m_nb_pas_echantillonnage,m_nb_pas_echantillonnage,m_nb_pas_echantillonnage); |
68 |
m_vector_mgcg_groupe_forme_inclusion=mcpy.m_vector_mgcg_groupe_forme_inclusion; |
69 |
std::vector<MG_CG_GROUPE_FORME*>::iterator it_gr_forme; |
70 |
for(it_gr_forme=m_vector_mgcg_groupe_forme_inclusion.begin();it_gr_forme!=m_vector_mgcg_groupe_forme_inclusion.end();it_gr_forme++) |
71 |
{ |
72 |
MG_CG_GROUPE_FORME* groupe_forme=*it_gr_forme; |
73 |
TPL_MAP_ENTITE<MG_VOLUME*> tpl_map_volume=groupe_forme->get_tpl_map_volume(); |
74 |
TPL_MAP_ENTITE<MG_VOLUME*>::ITERATEUR it_volume; |
75 |
for(MG_VOLUME* vol=tpl_map_volume.get_premier(it_volume);vol!=NULL;vol=tpl_map_volume.get_suivant(it_volume)) |
76 |
{ |
77 |
m_grille_volume_inclusion.inserer(vol); |
78 |
} |
79 |
} |
80 |
m_matrice=mcpy.m_matrice; |
81 |
m_cube_initial=mcpy.m_cube_initial; |
82 |
m_nb_pas_x=mcpy.m_nb_pas_x; |
83 |
m_nb_pas_y=mcpy.m_nb_pas_y; |
84 |
m_nb_pas_z=mcpy.m_nb_pas_z; |
85 |
affichageactif=mcpy.affichageactif; |
86 |
fonc_affiche=mcpy.fonc_affiche; |
87 |
} |
88 |
|
89 |
MSTRUCT_GENERATEUR::~MSTRUCT_GENERATEUR(void) |
90 |
{ |
91 |
} |
92 |
|
93 |
MG_GESTIONNAIRE* MSTRUCT_GENERATEUR::get_mg_gestionnaire(void) |
94 |
{ |
95 |
return m_mg_gestionnaire; |
96 |
} |
97 |
|
98 |
MG_CG_MODELE* MSTRUCT_GENERATEUR::get_mgcg_modele(void) |
99 |
{ |
100 |
return m_mgcg_modele; |
101 |
} |
102 |
|
103 |
void MSTRUCT_GENERATEUR::change_mgcg_modele(MG_CG_MODELE* mgcg_modele) |
104 |
{ |
105 |
m_mgcg_modele=mgcg_modele; |
106 |
} |
107 |
|
108 |
void MSTRUCT_GENERATEUR::change_boite3d_ves(BOITE_3D boite3d_ves) |
109 |
{ |
110 |
m_boite3d_ves=boite3d_ves; |
111 |
} |
112 |
|
113 |
void MSTRUCT_GENERATEUR::change_boite3d_distribution(BOITE_3D boite3d_distribution) |
114 |
{ |
115 |
m_boite3d_distribution=boite3d_distribution; |
116 |
} |
117 |
|
118 |
void MSTRUCT_GENERATEUR::change_intersection_bords_ves(bool intersection_bords_ves) |
119 |
{ |
120 |
m_intersection_bords_ves=intersection_bords_ves; |
121 |
} |
122 |
|
123 |
void MSTRUCT_GENERATEUR::change_angle_min(double angle_min) |
124 |
{ |
125 |
m_angle_min=angle_min; |
126 |
} |
127 |
|
128 |
void MSTRUCT_GENERATEUR::change_longueur_min(double longueur_min) |
129 |
{ |
130 |
m_longueur_min=longueur_min; |
131 |
} |
132 |
|
133 |
void MSTRUCT_GENERATEUR::change_aire_min(double aire_min) |
134 |
{ |
135 |
m_aire_min=aire_min; |
136 |
} |
137 |
|
138 |
void MSTRUCT_GENERATEUR::change_volume_min(double volume_min) |
139 |
{ |
140 |
m_volume_min=volume_min; |
141 |
} |
142 |
|
143 |
void MSTRUCT_GENERATEUR::change_distance_inter_volume_min(double distance_min) |
144 |
{ |
145 |
m_distance_min=distance_min; |
146 |
} |
147 |
|
148 |
void MSTRUCT_GENERATEUR::change_nb_pas_grille(int nb_pas_grille) |
149 |
{ |
150 |
m_nb_pas_grille=nb_pas_grille; |
151 |
} |
152 |
|
153 |
void MSTRUCT_GENERATEUR::change_nb_pas_echantillonage(int nb_pas_echantillonnage) |
154 |
{ |
155 |
m_nb_pas_echantillonnage=nb_pas_echantillonnage; |
156 |
} |
157 |
|
158 |
void MSTRUCT_GENERATEUR::change_precision(double precision) |
159 |
{ |
160 |
m_precision=precision; |
161 |
} |
162 |
|
163 |
double MSTRUCT_GENERATEUR::get_fraction_volumique_groupe_forme(std::string nom) |
164 |
{ |
165 |
std::vector<MG_CG_GROUPE_FORME*>::iterator it_gr_forme=m_vector_mgcg_groupe_forme_inclusion.begin(); |
166 |
MG_CG_GROUPE_FORME* groupe_forme=NULL; |
167 |
while(groupe_forme==NULL && it_gr_forme!=m_vector_mgcg_groupe_forme_inclusion.end()) |
168 |
{ |
169 |
if((*it_gr_forme)->get_nom()==nom) groupe_forme=*it_gr_forme; |
170 |
it_gr_forme++; |
171 |
} |
172 |
if(groupe_forme==NULL) return 0.0; |
173 |
double fraction_volumique=0.0; |
174 |
TPL_MAP_ENTITE<MG_VOLUME*> tpl_map_volume=groupe_forme->get_tpl_map_volume(); |
175 |
TPL_MAP_ENTITE<MG_VOLUME*>::ITERATEUR it_volume; |
176 |
for(MG_VOLUME* vol=tpl_map_volume.get_premier(it_volume);vol!=NULL;vol=tpl_map_volume.get_suivant(it_volume)) |
177 |
{ |
178 |
fraction_volumique+=OT_GEOMETRIE::get_volume(vol,m_precision); |
179 |
} |
180 |
fraction_volumique=fraction_volumique/m_boite3d_ves.get_volume(); |
181 |
return fraction_volumique; |
182 |
} |
183 |
|
184 |
|
185 |
void MSTRUCT_GENERATEUR::initialiser_grille(void) |
186 |
{ |
187 |
if(!m_grille_init) |
188 |
{ |
189 |
m_grille_volume_inclusion.initialiser(m_boite3d_distribution.get_xmin(),m_boite3d_distribution.get_ymin(),m_boite3d_distribution.get_zmin(), |
190 |
m_boite3d_distribution.get_xmax(),m_boite3d_distribution.get_ymax(),m_boite3d_distribution.get_zmax(), |
191 |
m_nb_pas_echantillonnage,m_nb_pas_echantillonnage,m_nb_pas_echantillonnage); |
192 |
m_grille_init=true; |
193 |
} |
194 |
} |
195 |
|
196 |
int MSTRUCT_GENERATEUR::position_relative_inclusion_ves(MG_VOLUME* inclusion,bool &plan_x0yz,bool &plan_x1yz,bool &plan_xy0z,bool &plan_xy1z,bool &plan_xyz0,bool &plan_xyz1) |
197 |
{ |
198 |
plan_x0yz=false;plan_x1yz=false;plan_xy0z=false;plan_xy1z=false;plan_xyz0=false;plan_xyz1=false; |
199 |
MG_ELEMENT_TOPOLOGIQUE::change_pas_echantillon(m_nb_pas_echantillonnage); |
200 |
BOITE_3D boite_inclusion=inclusion->get_boite_3D(); |
201 |
MG_ELEMENT_TOPOLOGIQUE::restaure_pas_echantillon(); |
202 |
if(m_boite3d_ves.contient(boite_inclusion.get_xmin(),boite_inclusion.get_ymin(),boite_inclusion.get_zmin())) |
203 |
if(m_boite3d_ves.contient(boite_inclusion.get_xmin(),boite_inclusion.get_ymin(),boite_inclusion.get_zmax())) |
204 |
if(m_boite3d_ves.contient(boite_inclusion.get_xmin(),boite_inclusion.get_ymax(),boite_inclusion.get_zmin())) |
205 |
if(m_boite3d_ves.contient(boite_inclusion.get_xmin(),boite_inclusion.get_ymax(),boite_inclusion.get_zmax())) |
206 |
if(m_boite3d_ves.contient(boite_inclusion.get_xmax(),boite_inclusion.get_ymin(),boite_inclusion.get_zmin())) |
207 |
if(m_boite3d_ves.contient(boite_inclusion.get_xmax(),boite_inclusion.get_ymin(),boite_inclusion.get_zmax())) |
208 |
if(m_boite3d_ves.contient(boite_inclusion.get_xmax(),boite_inclusion.get_ymax(),boite_inclusion.get_zmin())) |
209 |
if(m_boite3d_ves.contient(boite_inclusion.get_xmax(),boite_inclusion.get_ymax(),boite_inclusion.get_zmax())) return MSTRUCT::POSITION_RELATIVE::INTERIEUR; |
210 |
|
211 |
if(!m_boite3d_ves.contient(boite_inclusion.get_xmin(),boite_inclusion.get_ymin(),boite_inclusion.get_zmin())) |
212 |
if(!m_boite3d_ves.contient(boite_inclusion.get_xmin(),boite_inclusion.get_ymin(),boite_inclusion.get_zmax())) |
213 |
if(!m_boite3d_ves.contient(boite_inclusion.get_xmin(),boite_inclusion.get_ymax(),boite_inclusion.get_zmin())) |
214 |
if(!m_boite3d_ves.contient(boite_inclusion.get_xmin(),boite_inclusion.get_ymax(),boite_inclusion.get_zmax())) |
215 |
if(!m_boite3d_ves.contient(boite_inclusion.get_xmax(),boite_inclusion.get_ymin(),boite_inclusion.get_zmin())) |
216 |
if(!m_boite3d_ves.contient(boite_inclusion.get_xmax(),boite_inclusion.get_ymin(),boite_inclusion.get_zmax())) |
217 |
if(!m_boite3d_ves.contient(boite_inclusion.get_xmax(),boite_inclusion.get_ymax(),boite_inclusion.get_zmin())) |
218 |
if(!m_boite3d_ves.contient(boite_inclusion.get_xmax(),boite_inclusion.get_ymax(),boite_inclusion.get_zmax())) return MSTRUCT::POSITION_RELATIVE::EXTERIEUR; |
219 |
|
220 |
if(boite_inclusion.get_xmin()<m_boite3d_ves.get_xmin()) plan_x0yz=true; |
221 |
if(boite_inclusion.get_xmax()>m_boite3d_ves.get_xmax()) plan_x1yz=true; |
222 |
if(boite_inclusion.get_ymin()<m_boite3d_ves.get_ymin()) plan_xy0z=true; |
223 |
if(boite_inclusion.get_ymax()>m_boite3d_ves.get_ymax()) plan_xy0z=true; |
224 |
if(boite_inclusion.get_zmin()<m_boite3d_ves.get_zmin()) plan_xyz0=true; |
225 |
if(boite_inclusion.get_zmax()>m_boite3d_ves.get_zmax()) plan_xyz1=true; |
226 |
return MSTRUCT::POSITION_RELATIVE::AU_BORD; |
227 |
} |
228 |
|
229 |
bool MSTRUCT_GENERATEUR::angle_entre_face_acceptable(MG_ARETE* mgarete) |
230 |
{ |
231 |
long nb_mg_coarete = mgarete->get_nb_mg_coarete(); |
232 |
for(int i=0;i<nb_mg_coarete-1;i++) |
233 |
{ |
234 |
MG_FACE* face1 = mgarete->get_mg_coarete(i)->get_boucle()->get_mg_face(); |
235 |
for(int j=i+1;j<nb_mg_coarete;j++) |
236 |
{ |
237 |
MG_FACE* face2 = mgarete->get_mg_coarete(j)->get_boucle()->get_mg_face(); |
238 |
double tmin = mgarete->get_tmin(); |
239 |
double tmax = mgarete->get_tmax(); |
240 |
if(mgarete->get_courbe()->est_periodique()) |
241 |
{ |
242 |
tmin=0; |
243 |
tmax=mgarete->get_courbe()->get_periode(); |
244 |
} |
245 |
double pas_t = (tmin-tmax)/m_nb_pas_echantillonnage; |
246 |
bool planaire=true; |
247 |
for(int k=0;k<m_nb_pas_echantillonnage;k++) |
248 |
{ |
249 |
double t = tmin+k*pas_t; |
250 |
double xyz[3]; |
251 |
mgarete->evaluer(t,xyz); |
252 |
double uv1[2]; |
253 |
face1->inverser(uv1,xyz); |
254 |
double uv2[2]; |
255 |
face2->inverser(uv2,xyz); |
256 |
double normale1[3]; |
257 |
face1->calcul_normale_unitaire(uv1,normale1); |
258 |
double normale2[3]; |
259 |
face2->calcul_normale_unitaire(uv2,normale2); |
260 |
OT_VECTEUR_3D vect_normale1(normale1); |
261 |
OT_VECTEUR_3D vect_normale2(normale2); |
262 |
double angle = fabs(acos((vect_normale1*vect_normale2)/(vect_normale1.get_longueur()*vect_normale2.get_longueur()))); |
263 |
if(planaire) |
264 |
if(angle<m_angle_min) |
265 |
if(!OPERATEUR::egal(angle,0.0,m_precision))planaire=false; |
266 |
if(!planaire) |
267 |
{ |
268 |
if(angle<m_angle_min) return false; |
269 |
} |
270 |
} |
271 |
} |
272 |
} |
273 |
return true; |
274 |
} |
275 |
|
276 |
bool MSTRUCT_GENERATEUR::longueur_acceptable(MG_ARETE* mgarete) |
277 |
{ |
278 |
if(OT_GEOMETRIE::get_longueur(mgarete)<m_longueur_min) return false; |
279 |
return true; |
280 |
} |
281 |
|
282 |
bool MSTRUCT_GENERATEUR::aire_acceptable(MG_FACE* mgface) |
283 |
{ |
284 |
if(OT_GEOMETRIE::get_aire(mgface,m_precision)<m_aire_min) return false; |
285 |
return true; |
286 |
} |
287 |
|
288 |
bool MSTRUCT_GENERATEUR::volume_acceptable(MG_VOLUME* mgvolume) |
289 |
{ |
290 |
if(OT_GEOMETRIE::get_volume(mgvolume,m_precision)<m_volume_min) return false; |
291 |
return true; |
292 |
} |
293 |
|
294 |
bool MSTRUCT_GENERATEUR::volume_intersection_ves_acceptable(MG_VOLUME* mgvolume) |
295 |
{ |
296 |
if(m_matrice->get_type_forme()==MG_CG_FORME::TYPE_FORME::VOLUME) |
297 |
{ |
298 |
MG_CG_FORME_VOLUME* forme_volume_matrice = (MG_CG_FORME_VOLUME*)m_matrice; |
299 |
double volume_inclusion = OT_GEOMETRIE::get_volume_intersection(mgvolume,forme_volume_matrice->get_mg_volume()); |
300 |
if(volume_inclusion>m_volume_min) return true; |
301 |
return false; |
302 |
} |
303 |
else if(m_matrice->get_type_forme()==MG_CG_FORME::TYPE_FORME::MULTI_VOLUME) |
304 |
{ |
305 |
MG_CG_FORME_MULTI_VOLUME* forme_multi_volume_matrice = (MG_CG_FORME_MULTI_VOLUME*)m_matrice; |
306 |
double volume_inclusion=0; |
307 |
std::map<long,MG_VOLUME*>::iterator it_volume; |
308 |
for(MG_VOLUME* volume_matrice=forme_multi_volume_matrice->get_premier_mg_volume(it_volume);volume_matrice!=NULL;volume_matrice=forme_multi_volume_matrice->get_suivant_mg_volume(it_volume)) |
309 |
{ |
310 |
volume_inclusion+=OT_GEOMETRIE::get_volume_intersection(mgvolume,volume_matrice); |
311 |
} |
312 |
if(volume_inclusion>m_volume_min) return true; |
313 |
return false; |
314 |
} |
315 |
return true; |
316 |
} |
317 |
|
318 |
bool MSTRUCT_GENERATEUR::distance_acceptable_bord_ves(MG_VOLUME* mgvolume) |
319 |
{ |
320 |
BOITE_3D boite_volume=OT_GEOMETRIE::get_boite_3D(mgvolume); |
321 |
if(boite_volume.get_xmin()<(m_boite3d_ves.get_xmin()+m_distance_min)) return false; |
322 |
if(boite_volume.get_ymin()<(m_boite3d_ves.get_ymin()+m_distance_min)) return false; |
323 |
if(boite_volume.get_zmin()<(m_boite3d_ves.get_zmin()+m_distance_min)) return false; |
324 |
if(boite_volume.get_xmax()>(m_boite3d_ves.get_xmax()-m_distance_min)) return false; |
325 |
if(boite_volume.get_ymax()>(m_boite3d_ves.get_ymax()-m_distance_min)) return false; |
326 |
if(boite_volume.get_zmax()>(m_boite3d_ves.get_zmax()-m_distance_min)) return false; |
327 |
return true; |
328 |
} |
329 |
|
330 |
|
331 |
bool MSTRUCT_GENERATEUR::configuration_acceptable(MG_CG_FORME_VOLUME* forme_volume_inclusion,MG_CG_FORME* forme_matrice) |
332 |
{ |
333 |
TPL_MAP_ENTITE<MG_FACE*> tpl_map_face; |
334 |
TPL_MAP_ENTITE<MG_ARETE*> tpl_map_arete; |
335 |
TPL_MAP_ENTITE<MG_SOMMET*> tpl_map_sommet; |
336 |
TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> tpl_map_ele_topo_matrice; |
337 |
TPL_GRILLE<MG_ELEMENT_TOPOLOGIQUE*> tpl_grille_ele_topo; |
338 |
tpl_grille_ele_topo.initialiser(m_boite3d_ves.get_xmin()-0.1,m_boite3d_ves.get_ymin()-0.1,m_boite3d_ves.get_zmin()-0.1, |
339 |
m_boite3d_ves.get_xmax()+0.1,m_boite3d_ves.get_ymax()+0.1,m_boite3d_ves.get_zmax()+0.1, |
340 |
m_nb_pas_grille,m_nb_pas_grille,m_nb_pas_grille); |
341 |
if(OT_GEOMETRIE::get_volume(forme_volume_inclusion->get_mg_volume())<m_volume_min) return FAIL; |
342 |
OT_GEOMETRIE::get_map_mg_ele_topo_sous_jacent(forme_volume_inclusion->get_mg_volume(),tpl_map_sommet,tpl_map_arete,tpl_map_face); |
343 |
if(forme_matrice!=NULL) |
344 |
{ |
345 |
if(forme_matrice->get_type_forme()==MG_CG_FORME::TYPE_FORME::VOLUME) |
346 |
{ |
347 |
MG_CG_FORME_VOLUME* forme_volume_matrice=(MG_CG_FORME_VOLUME*)forme_matrice; |
348 |
OT_GEOMETRIE::get_map_mg_ele_topo_sous_jacent(forme_volume_matrice->get_mg_volume(),tpl_map_sommet,tpl_map_arete,tpl_map_face); |
349 |
} |
350 |
else if(forme_matrice->get_type_forme()==MG_CG_FORME::TYPE_FORME::MULTI_VOLUME) |
351 |
{ |
352 |
MG_CG_FORME_MULTI_VOLUME* forme_multi_volume_matrice=(MG_CG_FORME_MULTI_VOLUME*)forme_matrice; |
353 |
std::map<long,MG_VOLUME*>::iterator it_volume; |
354 |
for(MG_VOLUME* volume=forme_multi_volume_matrice->get_premier_mg_volume(it_volume);volume!=NULL;volume=forme_multi_volume_matrice->get_suivant_mg_volume(it_volume)) |
355 |
{ |
356 |
OT_GEOMETRIE::get_map_mg_ele_topo_sous_jacent(volume,tpl_map_sommet,tpl_map_arete,tpl_map_face); |
357 |
} |
358 |
} |
359 |
} |
360 |
TPL_MAP_ENTITE<MG_FACE*>::ITERATEUR it_face; |
361 |
for(MG_FACE* face=tpl_map_face.get_premier(it_face);face!=NULL;face=tpl_map_face.get_suivant(it_face)) |
362 |
{ |
363 |
if(OT_GEOMETRIE::get_aire(face)<m_aire_min) return FAIL; |
364 |
tpl_map_ele_topo_matrice.ajouter(face); |
365 |
tpl_grille_ele_topo.inserer(face); |
366 |
} |
367 |
tpl_map_face.vide(); |
368 |
TPL_MAP_ENTITE<MG_ARETE*>::ITERATEUR it_arete; |
369 |
for(MG_ARETE* arete=tpl_map_arete.get_premier(it_arete);arete!=NULL;arete=tpl_map_arete.get_suivant(it_arete)) |
370 |
{ |
371 |
if(OT_GEOMETRIE::get_longueur(arete)<m_longueur_min) return FAIL; |
372 |
if(!angle_entre_face_acceptable(arete)) return FAIL; |
373 |
tpl_map_ele_topo_matrice.ajouter(arete); |
374 |
tpl_grille_ele_topo.inserer(arete); |
375 |
} |
376 |
tpl_map_arete.vide(); |
377 |
TPL_MAP_ENTITE<MG_SOMMET*>::ITERATEUR it_sommet; |
378 |
for(MG_SOMMET* sommet=tpl_map_sommet.get_premier(it_sommet);sommet!=NULL;sommet=tpl_map_sommet.get_suivant(it_sommet)) |
379 |
{ |
380 |
tpl_map_ele_topo_matrice.ajouter(sommet); |
381 |
tpl_grille_ele_topo.inserer(sommet); |
382 |
} |
383 |
tpl_map_sommet.vide(); |
384 |
|
385 |
OT_GEOMETRIE::get_map_mg_ele_topo_sous_jacent(forme_volume_inclusion->get_mg_volume(),tpl_map_sommet,tpl_map_arete,tpl_map_face); |
386 |
std::stack<MG_ELEMENT_TOPOLOGIQUE*> stack_ele_topo; |
387 |
for(MG_FACE* face=tpl_map_face.get_premier(it_face);face!=NULL;face=tpl_map_face.get_suivant(it_face)) |
388 |
{ |
389 |
if(OT_GEOMETRIE::get_aire(face)<m_aire_min) return FAIL; |
390 |
tpl_grille_ele_topo.inserer(face); |
391 |
stack_ele_topo.push(face); |
392 |
} |
393 |
for(MG_ARETE* arete=tpl_map_arete.get_premier(it_arete);arete!=NULL;arete=tpl_map_arete.get_suivant(it_arete)) |
394 |
{ |
395 |
if(OT_GEOMETRIE::get_longueur(arete)<m_longueur_min) return FAIL; |
396 |
if(!angle_entre_face_acceptable(arete)) return FAIL; |
397 |
|
398 |
tpl_grille_ele_topo.inserer(arete); |
399 |
stack_ele_topo.push(arete); |
400 |
|
401 |
} |
402 |
for(MG_SOMMET* sommet=tpl_map_sommet.get_premier(it_sommet);sommet!=NULL;sommet=tpl_map_sommet.get_suivant(it_sommet)) |
403 |
{ |
404 |
tpl_grille_ele_topo.inserer(sommet); |
405 |
stack_ele_topo.push(sommet); |
406 |
} |
407 |
while(!stack_ele_topo.empty()) |
408 |
{ |
409 |
MG_ELEMENT_TOPOLOGIQUE* ele_topo=stack_ele_topo.top(); stack_ele_topo.pop(); |
410 |
TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> tpl_map_topo_trouve; |
411 |
BOITE_3D boite_recherche(ele_topo->get_boite_3D().get_xmin()-m_distance_min, |
412 |
ele_topo->get_boite_3D().get_ymin()-m_distance_min, |
413 |
ele_topo->get_boite_3D().get_zmin()-m_distance_min, |
414 |
ele_topo->get_boite_3D().get_xmax()+m_distance_min, |
415 |
ele_topo->get_boite_3D().get_ymax()+m_distance_min, |
416 |
ele_topo->get_boite_3D().get_zmax()+m_distance_min); |
417 |
tpl_grille_ele_topo.rechercher(boite_recherche,tpl_map_topo_trouve); |
418 |
TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*>::ITERATEUR it_trouve; |
419 |
for(MG_ELEMENT_TOPOLOGIQUE* ele_top_trouve=tpl_map_topo_trouve.get_premier(it_trouve);ele_top_trouve!=NULL;ele_top_trouve=tpl_map_topo_trouve.get_suivant(it_trouve)) |
420 |
{ |
421 |
if(ele_topo==ele_top_trouve) continue; |
422 |
if(OT_GEOMETRIE::get_lien_topologique(ele_topo,ele_top_trouve)==OT_GEOMETRIE::TYPE_LIEN_TOPOLOGIQUE::AUCUN) |
423 |
{ |
424 |
double distance; |
425 |
if(OT_GEOMETRIE::get_distance_min_mg_eletopo_mg_eletopo(ele_topo,ele_top_trouve,distance)==FAIL) return FAIL; |
426 |
if(distance<m_distance_min) return FAIL; |
427 |
} |
428 |
} |
429 |
tpl_grille_ele_topo.supprimer(ele_topo); |
430 |
} |
431 |
return OK; |
432 |
} |
433 |
|
434 |
|
435 |
|
436 |
void MSTRUCT_GENERATEUR::echec_insertion_inclusion(std::vector< MG_CG_FORME* >& vector_forme, std::vector< MG_CG_OPERATEUR* >& vector_operateur) |
437 |
{ |
438 |
std::vector<MG_CG_FORME*>::iterator it_forme; |
439 |
for(it_forme=vector_forme.begin();it_forme!=vector_forme.end();it_forme++) m_mgcg_modele->supprimer_mgcg_formeid((*it_forme)->get_id()); |
440 |
std::vector<MG_CG_OPERATEUR*>::iterator it_operateur; |
441 |
for(it_operateur=vector_operateur.begin();it_operateur!=vector_operateur.end();it_operateur++) m_mgcg_modele->supprimer_mgcg_operateurid((*it_operateur)->get_id()); |
442 |
} |
443 |
|
444 |
int MSTRUCT_GENERATEUR::faces_correspondantes(MG_VOLUME* volume1, MG_VOLUME* volume2,double decallage,int nb_pas,double precision) |
445 |
{ |
446 |
TPL_MAP_ENTITE<MG_FACE*> tpl_map_face_volume1; |
447 |
TPL_MAP_ENTITE<MG_FACE*> tpl_map_face_volume2; |
448 |
OT_GEOMETRIE::get_map_mg_face_sous_jacent(volume1,tpl_map_face_volume1); |
449 |
OT_GEOMETRIE::get_map_mg_face_sous_jacent(volume2,tpl_map_face_volume2); |
450 |
TPL_MAP_ENTITE<MG_FACE*>::ITERATEUR it_face1; |
451 |
TPL_MAP_ENTITE<MG_FACE*>::ITERATEUR it_face2; |
452 |
while(tpl_map_face_volume1.get_nb()>0 && tpl_map_face_volume2.get_nb()>0) |
453 |
{ |
454 |
bool trouve=false; |
455 |
MG_FACE* face1=tpl_map_face_volume1.get_premier(it_face1); |
456 |
MG_FACE* face2=tpl_map_face_volume2.get_premier(it_face2); |
457 |
while(trouve==false && face2!=NULL) |
458 |
{ |
459 |
double distance_moyenne; |
460 |
double ecart_type_distance; |
461 |
if(OT_GEOMETRIE::declage_mg_face_mg_face(face1,face2,distance_moyenne,ecart_type_distance,nb_pas,precision)!=FAIL) |
462 |
{ |
463 |
if(OPERATEUR::egal(distance_moyenne,decallage,precision) && ecart_type_distance<precision) |
464 |
{ |
465 |
trouve=true; |
466 |
tpl_map_face_volume1.supprimer(face1); |
467 |
tpl_map_face_volume2.supprimer(face2); |
468 |
} |
469 |
else if(OPERATEUR::egal(distance_moyenne,0.0,precision) && ecart_type_distance<precision) |
470 |
{ |
471 |
trouve=true; |
472 |
tpl_map_face_volume1.supprimer(face1); |
473 |
tpl_map_face_volume2.supprimer(face2); |
474 |
} |
475 |
} |
476 |
face2=tpl_map_face_volume2.get_suivant(it_face2); |
477 |
} |
478 |
if(trouve==false) return FAIL; |
479 |
} |
480 |
return OK; |
481 |
} |
482 |
|
483 |
|
484 |
bool MSTRUCT_GENERATEUR::insertion_inclusion(MG_CG_FORME* forme_inclusion, |
485 |
double fraction_volumique_cible, |
486 |
double eps_fra_vol, |
487 |
double &fraction_volumique_actuelle, |
488 |
std::vector<MG_CG_FORME*> &vector_inclusion_genere, |
489 |
int &position_relative, |
490 |
std::vector< double > *vector_epaisseur_couche, |
491 |
bool porosite) |
492 |
{ |
493 |
|
494 |
MG_CG_FORME_VOLUME* boite_frac_vol=MG_CG::creer_MG_CG_FORME_VOLUME_BOITE(m_mgcg_modele, |
495 |
m_boite3d_ves.get_xmin(),m_boite3d_ves.get_ymin(),m_boite3d_ves.get_zmin(), |
496 |
m_boite3d_ves.get_xmax(),m_boite3d_ves.get_ymax(),m_boite3d_ves.get_zmax()); |
497 |
boite_frac_vol->construire(); |
498 |
double volume_particule; |
499 |
MG_CG_FORME* matrice=m_matrice; |
500 |
std::vector<MG_CG_FORME*> vector_forme_genere; |
501 |
std::vector<MG_CG_OPERATEUR*> vector_operateur_genere; |
502 |
vector_forme_genere.push_back(forme_inclusion); |
503 |
//vector_forme_genere.push_back(boite_frac_vol); |
504 |
if(forme_inclusion->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
505 |
{ |
506 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
507 |
return FAIL; |
508 |
} |
509 |
MG_CG_FORME_VOLUME* forme_volume_inclusion = (MG_CG_FORME_VOLUME*)forme_inclusion; |
510 |
MG_CG_FORME_VOLUME* forme_volume_verif_grille=NULL; |
511 |
bool multicouche=false; |
512 |
if(vector_epaisseur_couche!=NULL) multicouche=true; |
513 |
if(multicouche) |
514 |
{ |
515 |
// Creation de l'enveloppe externe |
516 |
double decallage_max=0; |
517 |
std::vector<double>::iterator it_epaisseur; |
518 |
for(it_epaisseur=vector_epaisseur_couche->begin();it_epaisseur!=vector_epaisseur_couche->end();it_epaisseur++) decallage_max+=*it_epaisseur; |
519 |
MG_CG_OP_TRANSF_DECALLAGE* op_decallage_couche_externe=MG_CG::creer_MG_CG_OP_TRANSF_DECALLAGE(m_mgcg_modele,MAGIC::SEMANTIQUECSG::DECALLAGE,forme_volume_inclusion); |
520 |
vector_operateur_genere.push_back(op_decallage_couche_externe); |
521 |
op_decallage_couche_externe->change_decallage(decallage_max); |
522 |
if(op_decallage_couche_externe->construire()==FAIL) |
523 |
{ |
524 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
525 |
return FAIL; |
526 |
} |
527 |
vector_forme_genere.push_back(op_decallage_couche_externe->get_mgcg_forme_sortie()); |
528 |
if(op_decallage_couche_externe->get_mgcg_forme_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
529 |
{ |
530 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
531 |
return FAIL; |
532 |
} |
533 |
MG_CG_FORME_VOLUME* forme_volume_couche_externe=(MG_CG_FORME_VOLUME*)op_decallage_couche_externe->get_mgcg_forme_sortie(); |
534 |
forme_volume_verif_grille=forme_volume_couche_externe; |
535 |
MG_VOLUME* volume_inclusion=forme_volume_inclusion->get_mg_volume(); |
536 |
MG_VOLUME* volume_inclusion_couche_externe=forme_volume_couche_externe->get_mg_volume(); |
537 |
// Verification du positionnement |
538 |
if(positionnement_acceptable(forme_volume_couche_externe->get_mg_volume())==FAIL) |
539 |
{ |
540 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
541 |
return FAIL; |
542 |
} |
543 |
// Verification de la fraction volumique |
544 |
volume_particule=OT_GEOMETRIE::get_volume_intersection(volume_inclusion_couche_externe,boite_frac_vol->get_mg_volume(),m_precision); |
545 |
m_mgcg_modele->supprimer_mgcg_formeid(boite_frac_vol->get_id()); |
546 |
if((volume_particule+fraction_volumique_actuelle)>fraction_volumique_cible+eps_fra_vol) |
547 |
{ |
548 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
549 |
return FAIL; |
550 |
} |
551 |
// Verification des plans de coupe (coeur VS enveloppe) |
552 |
bool plan_x0yz_inc;bool plan_x1yz_inc;bool plan_xy0z_inc;bool plan_xy1z_inc;bool plan_xyz0_inc;bool plan_xyz1_inc; |
553 |
bool plan_x0yz_ext;bool plan_x1yz_ext;bool plan_xy0z_ext;bool plan_xy1z_ext;bool plan_xyz0_ext;bool plan_xyz1_ext; |
554 |
int position_relative_inc=position_relative_inclusion_ves(volume_inclusion,plan_x0yz_inc,plan_x1yz_inc,plan_xy0z_inc,plan_xy1z_inc,plan_xyz0_inc,plan_xyz1_inc); |
555 |
int position_relative_ext=position_relative_inclusion_ves(volume_inclusion_couche_externe,plan_x0yz_ext,plan_x1yz_ext,plan_xy0z_ext,plan_xy1z_ext,plan_xyz0_ext,plan_xyz1_ext); |
556 |
if(position_relative_inc!=position_relative_ext || position_relative_ext==MSTRUCT::POSITION_RELATIVE::EXTERIEUR) |
557 |
{ |
558 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
559 |
return FAIL; |
560 |
} |
561 |
if(!m_intersection_bords_ves && position_relative_ext==MSTRUCT::POSITION_RELATIVE::AU_BORD) |
562 |
{ |
563 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
564 |
return FAIL; |
565 |
} |
566 |
if(position_relative_ext==MSTRUCT::POSITION_RELATIVE::AU_BORD) |
567 |
{ |
568 |
bool ok_plan=false; |
569 |
if(plan_x0yz_inc==plan_x0yz_ext) |
570 |
if(plan_x1yz_inc==plan_x1yz_ext) |
571 |
if(plan_xy0z_inc==plan_xy0z_ext) |
572 |
if(plan_xy1z_inc==plan_xy1z_ext) |
573 |
if(plan_xyz0_inc==plan_xyz0_ext) |
574 |
if(plan_xyz1_inc==plan_xyz1_ext) ok_plan=true; |
575 |
if(!ok_plan) |
576 |
{ |
577 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
578 |
return FAIL; |
579 |
} |
580 |
} |
581 |
// Creation de l'intersection couche externe / matrice |
582 |
MG_CG_OP_BOOL_INTERSECTION* op_inter_ext=MG_CG::creer_MG_CG_OP_BOOL_INTERSECTION(m_mgcg_modele,MAGIC::SEMANTIQUECSG::INTERSECTION,forme_volume_couche_externe,matrice); |
583 |
vector_operateur_genere.push_back(op_inter_ext); |
584 |
if(op_inter_ext->construire()==FAIL) |
585 |
{ |
586 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
587 |
return FAIL; |
588 |
} |
589 |
vector_forme_genere.push_back(op_inter_ext->get_mgcg_forme_sortie()); |
590 |
if(op_inter_ext->get_mgcg_forme_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
591 |
{ |
592 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
593 |
return FAIL; |
594 |
} |
595 |
MG_CG_FORME_VOLUME* couche_externe_inter = (MG_CG_FORME_VOLUME*)op_inter_ext->get_mgcg_forme_sortie(); |
596 |
// Fragmentation de l'inclusion / matrice |
597 |
MG_CG_OP_INCLUSION_MATRICE* op_inc_matrice_ext=MG_CG::creer_MG_CG_OP_INCLUSION_MATRICE(m_mgcg_modele,MAGIC::SEMANTIQUECSG::FRAGMENT,couche_externe_inter,matrice); |
598 |
vector_operateur_genere.push_back(op_inc_matrice_ext); |
599 |
if(op_inc_matrice_ext->construire()==FAIL) |
600 |
{ |
601 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
602 |
return FAIL; |
603 |
} |
604 |
vector_forme_genere.push_back(op_inc_matrice_ext->get_mgcg_forme_matrice_sortie()); |
605 |
vector_forme_genere.push_back(op_inc_matrice_ext->get_mgcg_forme_inclusion_sortie()); |
606 |
if(op_inc_matrice_ext->get_mgcg_forme_inclusion_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
607 |
{ |
608 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
609 |
return FAIL; |
610 |
} |
611 |
matrice=op_inc_matrice_ext->get_mgcg_forme_matrice_sortie(); |
612 |
MG_CG_FORME_VOLUME* couche_externe_matrice=(MG_CG_FORME_VOLUME*)op_inc_matrice_ext->get_mgcg_forme_inclusion_sortie(); |
613 |
if(configuration_acceptable(couche_externe_matrice,matrice)==FAIL) |
614 |
{ |
615 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
616 |
return FAIL; |
617 |
} |
618 |
// OK POUR GENERER |
619 |
MG_CG_FORME_VOLUME* matrice_couche_partielle; |
620 |
if(porosite) |
621 |
{ |
622 |
MG_CG_OP_BOOL_DIFFERENCE* op_diff_porosite=MG_CG::creer_MG_CG_OP_BOOL_DIFFERENCE(m_mgcg_modele,MAGIC::SEMANTIQUECSG::SOUSTRACTION,couche_externe_matrice,forme_volume_inclusion); |
623 |
vector_operateur_genere.push_back(op_diff_porosite); |
624 |
if(op_diff_porosite->construire()==FAIL) |
625 |
{ |
626 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
627 |
return FAIL; |
628 |
} |
629 |
vector_forme_genere.push_back(op_diff_porosite->get_mgcg_forme_sortie()); |
630 |
if(op_diff_porosite->get_mgcg_forme_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
631 |
{ |
632 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
633 |
return FAIL; |
634 |
} |
635 |
matrice_couche_partielle=(MG_CG_FORME_VOLUME*)op_diff_porosite->get_mgcg_forme_sortie(); |
636 |
} |
637 |
else |
638 |
{ |
639 |
MG_CG_OP_BOOL_INTERSECTION* op_inter_couche=MG_CG::creer_MG_CG_OP_BOOL_INTERSECTION(m_mgcg_modele,MAGIC::SEMANTIQUECSG::INTERSECTION,forme_volume_inclusion,couche_externe_matrice); |
640 |
vector_operateur_genere.push_back(op_inter_couche); |
641 |
if(op_inter_couche->construire()==FAIL) |
642 |
{ |
643 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
644 |
return FAIL; |
645 |
} |
646 |
vector_forme_genere.push_back(op_inter_couche->get_mgcg_forme_sortie()); |
647 |
if(op_inter_couche->get_mgcg_forme_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
648 |
{ |
649 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
650 |
return FAIL; |
651 |
} |
652 |
MG_CG_OP_INCLUSION_MATRICE* op_inc_matrice_coeur=MG_CG::creer_MG_CG_OP_INCLUSION_MATRICE(m_mgcg_modele,MAGIC::SEMANTIQUECSG::FRAGMENT,op_inter_couche->get_mgcg_forme_sortie(),couche_externe_matrice); |
653 |
vector_operateur_genere.push_back(op_inc_matrice_coeur); |
654 |
if(op_inc_matrice_coeur->construire()==FAIL) |
655 |
{ |
656 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
657 |
return FAIL; |
658 |
} |
659 |
vector_forme_genere.push_back(op_inc_matrice_coeur->get_mgcg_forme_inclusion_sortie()); |
660 |
vector_forme_genere.push_back(op_inc_matrice_coeur->get_mgcg_forme_matrice_sortie()); |
661 |
if(op_inc_matrice_coeur->get_mgcg_forme_inclusion_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME || |
662 |
op_inc_matrice_coeur->get_mgcg_forme_matrice_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
663 |
{ |
664 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
665 |
return FAIL; |
666 |
} |
667 |
|
668 |
MG_CG_FORME_VOLUME* inclusion_coeur=(MG_CG_FORME_VOLUME*)op_inc_matrice_coeur->get_mgcg_forme_inclusion_sortie(); |
669 |
matrice_couche_partielle=(MG_CG_FORME_VOLUME*)op_inc_matrice_coeur->get_mgcg_forme_matrice_sortie(); |
670 |
if(configuration_acceptable(inclusion_coeur,NULL)==FAIL) |
671 |
{ |
672 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
673 |
return FAIL; |
674 |
} |
675 |
// Verification des faces correspondantes |
676 |
if(position_relative_ext==MSTRUCT::POSITION_RELATIVE::AU_BORD) |
677 |
if(faces_correspondantes(inclusion_coeur->get_mg_volume(),couche_externe_matrice->get_mg_volume(),decallage_max,m_nb_pas_echantillonnage,m_precision)==FAIL) |
678 |
{ |
679 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
680 |
return FAIL; |
681 |
} |
682 |
if(position_relative_ext==MSTRUCT::POSITION_RELATIVE::INTERIEUR) MG_CG::creer_MG_CG_INFO_STRING(op_inc_matrice_coeur->get_mgcg_forme_inclusion_sortie(),(char*)"POSITION_RELATIVE",(char*)"INTERIEUR"); |
683 |
if(position_relative_ext==MSTRUCT::POSITION_RELATIVE::AU_BORD) MG_CG::creer_MG_CG_INFO_STRING(op_inc_matrice_coeur->get_mgcg_forme_inclusion_sortie(),(char*)"POSITION_RELATIVE",(char*)"AU_BORD"); |
684 |
vector_inclusion_genere.push_back(inclusion_coeur); |
685 |
} |
686 |
double decallage=0; |
687 |
double epaisseur; |
688 |
for(it_epaisseur=vector_epaisseur_couche->begin();it_epaisseur!=vector_epaisseur_couche->end()-1;it_epaisseur++) |
689 |
{ |
690 |
epaisseur=*it_epaisseur; |
691 |
decallage+=*it_epaisseur; |
692 |
MG_CG_OP_TRANSF_DECALLAGE* op_decallage_couche=MG_CG::creer_MG_CG_OP_TRANSF_DECALLAGE(m_mgcg_modele,MAGIC::SEMANTIQUECSG::DECALLAGE,forme_volume_inclusion); |
693 |
vector_operateur_genere.push_back(op_decallage_couche); |
694 |
op_decallage_couche->change_decallage(decallage); |
695 |
if(op_decallage_couche->construire()==FAIL) |
696 |
{ |
697 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
698 |
return FAIL; |
699 |
} |
700 |
vector_forme_genere.push_back(op_decallage_couche->get_mgcg_forme_sortie()); |
701 |
if(op_decallage_couche->get_mgcg_forme_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
702 |
{ |
703 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
704 |
return FAIL; |
705 |
} |
706 |
MG_CG_OP_BOOL_INTERSECTION* op_inter_couche=MG_CG::creer_MG_CG_OP_BOOL_INTERSECTION(m_mgcg_modele,MAGIC::SEMANTIQUECSG::INTERSECTION,op_decallage_couche->get_mgcg_forme_sortie(),matrice_couche_partielle); |
707 |
vector_operateur_genere.push_back(op_inter_couche); |
708 |
if(op_inter_couche->construire()==FAIL) |
709 |
{ |
710 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
711 |
return FAIL; |
712 |
} |
713 |
vector_forme_genere.push_back(op_inter_couche->get_mgcg_forme_sortie()); |
714 |
if(op_inter_couche->get_mgcg_forme_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
715 |
{ |
716 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
717 |
return FAIL; |
718 |
} |
719 |
MG_CG_OP_INCLUSION_MATRICE* op_inc_matrice_couche=MG_CG::creer_MG_CG_OP_INCLUSION_MATRICE(m_mgcg_modele,MAGIC::SEMANTIQUECSG::FRAGMENT,op_inter_couche->get_mgcg_forme_sortie(),matrice_couche_partielle); |
720 |
vector_operateur_genere.push_back(op_inc_matrice_couche); |
721 |
if(op_inc_matrice_couche->construire()==FAIL) |
722 |
{ |
723 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
724 |
return FAIL; |
725 |
} |
726 |
vector_forme_genere.push_back(op_inc_matrice_couche->get_mgcg_forme_inclusion_sortie()); |
727 |
vector_forme_genere.push_back(op_inc_matrice_couche->get_mgcg_forme_matrice_sortie()); |
728 |
if(op_inc_matrice_couche->get_mgcg_forme_inclusion_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME || |
729 |
op_inc_matrice_couche->get_mgcg_forme_matrice_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
730 |
{ |
731 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
732 |
return FAIL; |
733 |
} |
734 |
MG_CG_FORME_VOLUME* inclusion_couche = (MG_CG_FORME_VOLUME*)op_inc_matrice_couche->get_mgcg_forme_inclusion_sortie(); |
735 |
vector_inclusion_genere.push_back(inclusion_couche); |
736 |
if(position_relative_ext==MSTRUCT::POSITION_RELATIVE::INTERIEUR) MG_CG::creer_MG_CG_INFO_STRING(inclusion_couche,(char*)"POSITION_RELATIVE",(char*)"INTERIEUR"); |
737 |
if(position_relative_ext==MSTRUCT::POSITION_RELATIVE::AU_BORD) MG_CG::creer_MG_CG_INFO_STRING(inclusion_couche,(char*)"POSITION_RELATIVE",(char*)"AU_BORD"); |
738 |
MG_CG::creer_MG_CG_INFO_DOUBLE(inclusion_couche,(char*)"EPAISSEUR",epaisseur); |
739 |
matrice_couche_partielle=(MG_CG_FORME_VOLUME*)op_inc_matrice_couche->get_mgcg_forme_matrice_sortie(); |
740 |
configurer_volume_mince(inclusion_couche->get_mg_volume(),epaisseur); |
741 |
} |
742 |
epaisseur=*it_epaisseur; |
743 |
if(position_relative_ext==MSTRUCT::POSITION_RELATIVE::INTERIEUR) MG_CG::creer_MG_CG_INFO_STRING(matrice_couche_partielle,(char*)"POSITION_RELATIVE",(char*)"INTERIEUR"); |
744 |
if(position_relative_ext==MSTRUCT::POSITION_RELATIVE::AU_BORD) MG_CG::creer_MG_CG_INFO_STRING(matrice_couche_partielle,(char*)"POSITION_RELATIVE",(char*)"AU_BORD"); |
745 |
MG_CG::creer_MG_CG_INFO_DOUBLE(matrice_couche_partielle,(char*)"EPAISSEUR",epaisseur); |
746 |
vector_inclusion_genere.push_back(matrice_couche_partielle); |
747 |
configurer_volume_mince(matrice_couche_partielle->get_mg_volume(),epaisseur); |
748 |
position_relative=position_relative_ext; |
749 |
} |
750 |
else |
751 |
{ |
752 |
// Verification du positionnement |
753 |
if(positionnement_acceptable(forme_volume_inclusion->get_mg_volume())==FAIL) |
754 |
{ |
755 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
756 |
m_mgcg_modele->supprimer_mgcg_formeid(boite_frac_vol->get_id()); |
757 |
return FAIL; |
758 |
} |
759 |
// Verification de la fraction volumique |
760 |
volume_particule=OT_GEOMETRIE::get_volume_intersection(forme_volume_inclusion->get_mg_volume(),boite_frac_vol->get_mg_volume(),m_precision); |
761 |
m_mgcg_modele->supprimer_mgcg_formeid(boite_frac_vol->get_id()); |
762 |
if(((volume_particule/m_boite3d_ves.get_volume())+fraction_volumique_actuelle)>fraction_volumique_cible+eps_fra_vol) |
763 |
{ |
764 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
765 |
return FAIL; |
766 |
} |
767 |
// Verification de la position relative |
768 |
bool plan_x0yz;bool plan_x1yz;bool plan_xy0z;bool plan_xy1z;bool plan_xyz0;bool plan_xyz1; |
769 |
position_relative=position_relative_inclusion_ves(forme_volume_inclusion->get_mg_volume(),plan_x0yz,plan_x1yz,plan_xy0z,plan_xy1z,plan_xyz0,plan_xyz1); |
770 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::EXTERIEUR) |
771 |
{ |
772 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
773 |
return FAIL; |
774 |
} |
775 |
if(!m_intersection_bords_ves && position_relative==MSTRUCT::POSITION_RELATIVE::AU_BORD) |
776 |
{ |
777 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
778 |
return FAIL; |
779 |
} |
780 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::AU_BORD) |
781 |
{ |
782 |
MG_CG_OP_BOOL_INTERSECTION* op_inter=MG_CG::creer_MG_CG_OP_BOOL_INTERSECTION(m_mgcg_modele,MAGIC::SEMANTIQUECSG::INTERSECTION,forme_volume_inclusion,m_matrice); |
783 |
vector_operateur_genere.push_back(op_inter); |
784 |
if(op_inter->construire()==FAIL) |
785 |
{ |
786 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
787 |
return FAIL; |
788 |
} |
789 |
vector_forme_genere.push_back(op_inter->get_mgcg_forme_sortie()); |
790 |
if(op_inter->get_mgcg_forme_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
791 |
{ |
792 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
793 |
return FAIL; |
794 |
} |
795 |
forme_volume_inclusion=(MG_CG_FORME_VOLUME*)op_inter->get_mgcg_forme_sortie(); |
796 |
} |
797 |
MG_CG_OP_INCLUSION_MATRICE* op_inc_matrice=MG_CG::creer_MG_CG_OP_INCLUSION_MATRICE(m_mgcg_modele,MAGIC::SEMANTIQUECSG::FRAGMENT,forme_volume_inclusion,m_matrice); |
798 |
vector_operateur_genere.push_back(op_inc_matrice); |
799 |
if(op_inc_matrice->construire()==FAIL) |
800 |
{ |
801 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
802 |
return FAIL; |
803 |
} |
804 |
matrice=op_inc_matrice->get_mgcg_forme_matrice_sortie(); |
805 |
vector_forme_genere.push_back(matrice); |
806 |
vector_forme_genere.push_back(op_inc_matrice->get_mgcg_forme_inclusion_sortie()); |
807 |
if(op_inc_matrice->get_mgcg_forme_inclusion_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
808 |
{ |
809 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
810 |
return FAIL; |
811 |
} |
812 |
forme_volume_inclusion=(MG_CG_FORME_VOLUME*)op_inc_matrice->get_mgcg_forme_inclusion_sortie(); |
813 |
if(configuration_acceptable(forme_volume_inclusion,matrice)==FAIL) |
814 |
{ |
815 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
816 |
return FAIL; |
817 |
} |
818 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::INTERIEUR) MG_CG::creer_MG_CG_INFO_STRING(forme_volume_inclusion,(char*)"POSITION_RELATIVE",(char*)"INTERIEUR"); |
819 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::AU_BORD) MG_CG::creer_MG_CG_INFO_STRING(forme_volume_inclusion,(char*)"POSITION_RELATIVE",(char*)"AU_BORD"); |
820 |
vector_inclusion_genere.push_back(forme_volume_inclusion); |
821 |
forme_volume_verif_grille=forme_volume_inclusion; |
822 |
} |
823 |
fraction_volumique_actuelle+=volume_particule/m_boite3d_ves.get_volume(); |
824 |
m_grille_volume_inclusion.inserer(forme_volume_verif_grille->get_mg_volume()); |
825 |
m_matrice=matrice; |
826 |
return OK; |
827 |
} |
828 |
|
829 |
bool MSTRUCT_GENERATEUR::insertion_inclusion(MG_CG_FORME* forme_inclusion, |
830 |
double& fraction_volumique_actuelle, |
831 |
std::vector< MG_CG_FORME* >& vector_inclusion_genere, |
832 |
int& position_relative |
833 |
) |
834 |
{ |
835 |
|
836 |
double volume_particule; |
837 |
MG_CG_FORME* matrice=m_matrice; |
838 |
std::vector<MG_CG_FORME*> vector_forme_genere; |
839 |
std::vector<MG_CG_OPERATEUR*> vector_operateur_genere; |
840 |
vector_forme_genere.push_back(forme_inclusion); |
841 |
//--------------------------------------------------------------------------------------------------------------- |
842 |
//--------------------------------------------------------------------------------------------------------------- |
843 |
if(forme_inclusion->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
844 |
{ |
845 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
846 |
return FAIL; |
847 |
} |
848 |
|
849 |
//--------------------------------------------------------------------------------------------------------------- |
850 |
//--------------------------------------------------------------------------------------------------------------- |
851 |
MG_CG_FORME_VOLUME* forme_volume_inclusion = (MG_CG_FORME_VOLUME*)forme_inclusion; |
852 |
MG_CG_FORME_VOLUME* forme_volume_verif_grille=NULL; |
853 |
|
854 |
//--------------------------------------------------------------------------------------------------------------- |
855 |
//--------------------------------------------------------------------------------------------------------------- |
856 |
// Verification du positionnement |
857 |
if(positionnement_acceptable(forme_volume_inclusion->get_mg_volume())==FAIL) |
858 |
{ |
859 |
|
860 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
861 |
return FAIL; |
862 |
} |
863 |
//--------------------------------------------------------------------------------------------------------------- |
864 |
//--------------------------------------------------------------------------------------------------------------- |
865 |
// Verification de la position relative |
866 |
bool plan_x0yz;bool plan_x1yz;bool plan_xy0z;bool plan_xy1z;bool plan_xyz0;bool plan_xyz1; |
867 |
position_relative=position_relative_inclusion_ves(forme_volume_inclusion->get_mg_volume(),plan_x0yz,plan_x1yz,plan_xy0z,plan_xy1z,plan_xyz0,plan_xyz1); |
868 |
|
869 |
//--------------------------------------------------------------------------------------------------------------- |
870 |
//--------------------------------------------------------------------------------------------------------------- |
871 |
|
872 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::EXTERIEUR) |
873 |
{ |
874 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
875 |
return FAIL; |
876 |
} |
877 |
if(!m_intersection_bords_ves && position_relative==MSTRUCT::POSITION_RELATIVE::AU_BORD) |
878 |
{ |
879 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
880 |
return FAIL; |
881 |
} |
882 |
//--------------------------------------------------------------------------------------------------------------- |
883 |
//--------------------------------------------------------------------------------------------------------------- |
884 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::AU_BORD) |
885 |
{ |
886 |
MG_CG_OP_BOOL_INTERSECTION* op_inter=MG_CG::creer_MG_CG_OP_BOOL_INTERSECTION(m_mgcg_modele,MAGIC::SEMANTIQUECSG::INTERSECTION,forme_volume_inclusion,m_matrice); |
887 |
vector_operateur_genere.push_back(op_inter); |
888 |
if(op_inter->construire()==FAIL) |
889 |
{ |
890 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
891 |
return FAIL; |
892 |
} |
893 |
vector_forme_genere.push_back(op_inter->get_mgcg_forme_sortie()); |
894 |
if(op_inter->get_mgcg_forme_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
895 |
{ |
896 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
897 |
return FAIL; |
898 |
} |
899 |
forme_volume_inclusion=(MG_CG_FORME_VOLUME*)op_inter->get_mgcg_forme_sortie(); |
900 |
} |
901 |
//----------------------------------------------------------------------------------------------------------------------------- |
902 |
//----------------------------------------------------------------------------------------------------------------------------- |
903 |
MG_CG_OP_INCLUSION_MATRICE* op_inc_matrice=MG_CG::creer_MG_CG_OP_INCLUSION_MATRICE(m_mgcg_modele,MAGIC::SEMANTIQUECSG::FRAGMENT,forme_volume_inclusion,m_matrice); |
904 |
vector_operateur_genere.push_back(op_inc_matrice); |
905 |
|
906 |
if(op_inc_matrice->construire()==FAIL) |
907 |
{ |
908 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
909 |
return FAIL; |
910 |
} |
911 |
|
912 |
matrice=op_inc_matrice->get_mgcg_forme_matrice_sortie(); |
913 |
vector_forme_genere.push_back(matrice); |
914 |
vector_forme_genere.push_back(op_inc_matrice->get_mgcg_forme_inclusion_sortie()); |
915 |
|
916 |
|
917 |
if(op_inc_matrice->get_mgcg_forme_inclusion_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
918 |
{ |
919 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
920 |
return FAIL; |
921 |
} |
922 |
|
923 |
|
924 |
forme_volume_inclusion=(MG_CG_FORME_VOLUME*)op_inc_matrice->get_mgcg_forme_inclusion_sortie(); |
925 |
//------------------------------------------------------------------------------------------------------------- |
926 |
//----------------------------------------------------------------------------------------------------------------------------- |
927 |
|
928 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::INTERIEUR) |
929 |
{ |
930 |
|
931 |
if(distance_acceptable_bord_ves(forme_volume_inclusion->get_mg_volume())==FAIL) |
932 |
{ |
933 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
934 |
return FAIL; |
935 |
|
936 |
} |
937 |
} |
938 |
//----------------------------------------------------------------------------------------------------------------------------- |
939 |
//--------------------------------------------------------------------------------------------------- |
940 |
if(m_intersection_bords_ves) |
941 |
if(configuration_acceptable(forme_volume_inclusion,matrice)==FAIL) |
942 |
{ |
943 |
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
944 |
return FAIL; |
945 |
} |
946 |
|
947 |
//------------------------------------------------------------------------------------------------------------- |
948 |
//---------------------------------------------------------------------------------------------------------------------------- |
949 |
|
950 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::INTERIEUR) MG_CG::creer_MG_CG_INFO_STRING(forme_volume_inclusion,(char*)"POSITION_RELATIVE",(char*)"INTERIEUR"); |
951 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::AU_BORD) MG_CG::creer_MG_CG_INFO_STRING(forme_volume_inclusion,(char*)"POSITION_RELATIVE",(char*)"AU_BORD"); |
952 |
vector_inclusion_genere.push_back(forme_volume_inclusion); |
953 |
forme_volume_verif_grille=forme_volume_inclusion; |
954 |
volume_particule=OT_GEOMETRIE::get_volume(forme_volume_inclusion->get_mg_volume()); |
955 |
fraction_volumique_actuelle+=volume_particule; |
956 |
m_grille_volume_inclusion.inserer(forme_volume_verif_grille->get_mg_volume()); |
957 |
m_matrice=matrice; |
958 |
return OK; |
959 |
} |
960 |
|
961 |
|
962 |
//========================================================================================= |
963 |
//========================================================================================== |
964 |
|
965 |
bool MSTRUCT_GENERATEUR::positionnement_acceptable(MG_VOLUME* inclusion) |
966 |
{ |
967 |
TPL_MAP_ENTITE<MG_VOLUME*> map_volume_recherche; |
968 |
BOITE_3D boite_recherche = inclusion->get_boite_3D(); |
969 |
boite_recherche.change_grosseur(1.1); |
970 |
m_grille_volume_inclusion.rechercher(boite_recherche,map_volume_recherche); |
971 |
TPL_MAP_ENTITE<MG_VOLUME*>::ITERATEUR it_volume; |
972 |
MG_VOLUME* volume_recherche=map_volume_recherche.get_premier(it_volume); |
973 |
double distance; |
974 |
while(volume_recherche!=NULL) |
975 |
{ |
976 |
if(OT_GEOMETRIE::get_distance_min_mg_volume_mg_volume(inclusion,volume_recherche,distance)==FAIL) return FAIL; |
977 |
else |
978 |
{ |
979 |
if(distance<=m_distance_min+m_precision) return FAIL; |
980 |
else volume_recherche=map_volume_recherche.get_suivant(it_volume); |
981 |
} |
982 |
} |
983 |
return OK; |
984 |
} |
985 |
|
986 |
bool MSTRUCT_GENERATEUR::lien_topologique_entre(MG_ELEMENT_TOPOLOGIQUE* mg_ele_topo1, MG_ELEMENT_TOPOLOGIQUE* mg_ele_topo2) |
987 |
{ |
988 |
TPL_MAP_ENTITE<MG_SOMMET*> map_sommet_volume1; |
989 |
OT_GEOMETRIE::get_map_mg_sommet_sous_jacent(mg_ele_topo1,map_sommet_volume1); |
990 |
TPL_MAP_ENTITE<MG_SOMMET*> map_sommet_volume2; |
991 |
OT_GEOMETRIE::get_map_mg_sommet_sous_jacent(mg_ele_topo2,map_sommet_volume2); |
992 |
TPL_MAP_ENTITE<MG_SOMMET*>::ITERATEUR it_sommet; |
993 |
for(MG_SOMMET* sommet=map_sommet_volume1.get_premier(it_sommet);sommet!=NULL;sommet=map_sommet_volume1.get_suivant(it_sommet)) |
994 |
{ |
995 |
if(map_sommet_volume2.existe(sommet)) return true; |
996 |
} |
997 |
return false; |
998 |
} |
999 |
|
1000 |
void MSTRUCT_GENERATEUR::cree_vector_groupe_forme(std::string nom, std::vector< MG_CG_GROUPE_FORME* >& vector_groupe_forme, std::vector< double >* vector_epaisseur_couches) |
1001 |
{ |
1002 |
if(vector_epaisseur_couches==NULL) |
1003 |
{ |
1004 |
MG_CG_GROUPE_FORME* groupe_forme; |
1005 |
groupe_forme=MG_CG::creer_MG_CG_GROUPE_FORME(m_mgcg_modele,nom); |
1006 |
m_vector_mgcg_groupe_forme_inclusion.push_back(groupe_forme); |
1007 |
vector_groupe_forme.push_back(groupe_forme); |
1008 |
} |
1009 |
else |
1010 |
{ |
1011 |
MG_CG_GROUPE_FORME* groupe_forme; |
1012 |
groupe_forme=MG_CG::creer_MG_CG_GROUPE_FORME(m_mgcg_modele,nom); |
1013 |
m_vector_mgcg_groupe_forme_inclusion.push_back(groupe_forme); |
1014 |
vector_groupe_forme.push_back(groupe_forme); |
1015 |
for(int i=0;i<vector_epaisseur_couches->size();i++) |
1016 |
{ |
1017 |
char nom_couche[500]; |
1018 |
sprintf(nom_couche,"%s_%i",nom.c_str(),i); |
1019 |
groupe_forme=MG_CG::creer_MG_CG_GROUPE_FORME(m_mgcg_modele,nom_couche); |
1020 |
m_vector_mgcg_groupe_forme_inclusion.push_back(groupe_forme); |
1021 |
vector_groupe_forme.push_back(groupe_forme); |
1022 |
} |
1023 |
} |
1024 |
} |
1025 |
|
1026 |
int MSTRUCT_GENERATEUR::configurer_volume_mince(MG_CG_FORME* forme,double epaisseur) |
1027 |
{ |
1028 |
if(forme->get_type_forme()==MG_CG_FORME::TYPE_FORME::VOLUME) |
1029 |
{ |
1030 |
MG_VOLUME* volume = ((MG_CG_FORME_VOLUME*)forme)->get_mg_volume(); |
1031 |
configurer_volume_mince(volume,epaisseur); |
1032 |
} |
1033 |
if(forme->get_type_forme()==MG_CG_FORME::TYPE_FORME::MULTI_VOLUME) |
1034 |
{ |
1035 |
MG_CG_FORME_MULTI_VOLUME* forme_multi_volume = (MG_CG_FORME_MULTI_VOLUME*)forme; |
1036 |
std::map<long,MG_VOLUME*>::iterator it_volume; |
1037 |
for(MG_VOLUME* volume=forme_multi_volume->get_premier_mg_volume(it_volume);volume!=NULL;volume=forme_multi_volume->get_suivant_mg_volume(it_volume)) |
1038 |
{ |
1039 |
configurer_volume_mince(volume,epaisseur); |
1040 |
} |
1041 |
} |
1042 |
return 0; |
1043 |
} |
1044 |
|
1045 |
int MSTRUCT_GENERATEUR::configurer_volume_mince(MG_VOLUME* volume, double epaisseur) |
1046 |
{ |
1047 |
TPL_MAP_ENTITE<MG_FACE*> tpl_map_face; |
1048 |
OT_GEOMETRIE::get_map_mg_face_sous_jacent(volume,tpl_map_face); |
1049 |
if(tpl_map_face.get_nb()<2) return FAIL; |
1050 |
TPL_MAP_ENTITE<MG_FACE*>::ITERATEUR it_face1; |
1051 |
TPL_MAP_ENTITE<MG_FACE*>::ITERATEUR it_face2; |
1052 |
std::cout << "NB_FACE = " << tpl_map_face.get_nb() << std::endl; |
1053 |
while(tpl_map_face.get_nb()>=2) |
1054 |
{ |
1055 |
bool trouve=false; |
1056 |
MG_FACE* face1=tpl_map_face.get_premier(it_face1); |
1057 |
it_face2=it_face1; |
1058 |
MG_FACE* face2=tpl_map_face.get_suivant(it_face2); |
1059 |
while(trouve==false && face1!=NULL && face2!=NULL) |
1060 |
{ |
1061 |
double distance_moyenne; |
1062 |
double ecart_type_distance; |
1063 |
OT_GEOMETRIE::declage_mg_face_mg_face(face1,face2,distance_moyenne,ecart_type_distance,32); |
1064 |
std::cout << " Distance = " << distance_moyenne << " Std-dev = " << ecart_type_distance << " Epaisseur = " << epaisseur << std::endl; |
1065 |
if(OPERATEUR::egal(epaisseur,distance_moyenne,m_precision) && ecart_type_distance<m_precision) |
1066 |
{ |
1067 |
std::cout << " Correspondance : " << face1->get_id() << " , " << face2->get_id() << std::endl; |
1068 |
trouve=true; |
1069 |
bool face1_base=false; |
1070 |
bool face2_base=false; |
1071 |
if(face1_base==true) |
1072 |
{ |
1073 |
volume->ajouter_face_correspondante(face1,face2); |
1074 |
} |
1075 |
else if(face2_base==true) |
1076 |
{ |
1077 |
volume->ajouter_face_correspondante(face2,face1); |
1078 |
} |
1079 |
else |
1080 |
{ |
1081 |
double aire_face1 = OT_GEOMETRIE::get_aire(face1,m_precision); |
1082 |
double aire_face2 = OT_GEOMETRIE::get_aire(face2,m_precision); |
1083 |
if(aire_face1<aire_face2) |
1084 |
{ |
1085 |
volume->ajouter_face_correspondante(face1,face2); |
1086 |
} |
1087 |
else |
1088 |
{ |
1089 |
volume->ajouter_face_correspondante(face2,face1); |
1090 |
} |
1091 |
} |
1092 |
} |
1093 |
else face2=tpl_map_face.get_suivant(it_face2); |
1094 |
} |
1095 |
if(trouve) |
1096 |
{ |
1097 |
tpl_map_face.supprimer(face1); |
1098 |
tpl_map_face.supprimer(face2); |
1099 |
} |
1100 |
else tpl_map_face.supprimer(face1); |
1101 |
} |
1102 |
|
1103 |
return 0; |
1104 |
} |
1105 |
|
1106 |
|
1107 |
void MSTRUCT_GENERATEUR::active_affichage(fonction_affiche* fonc) |
1108 |
{ |
1109 |
fonc_affiche = fonc; |
1110 |
affichageactif = 1; |
1111 |
} |
1112 |
|
1113 |
void MSTRUCT_GENERATEUR::affiche(char* message) |
1114 |
{ |
1115 |
if(affichageactif==1) fonc_affiche(message); |
1116 |
} |