1 |
francois |
1158 |
//####//------------------------------------------------------------ |
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 |
couturad |
919 |
#include "mstruct_generateur.h" |
23 |
couturad |
968 |
#include "mstruct_definition.h" |
24 |
couturad |
919 |
#include "mg_cg_modele.h" |
25 |
|
|
#include "mg_gestionnaire.h" |
26 |
|
|
#include "mg_cg.h" |
27 |
couturad |
951 |
#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 |
couturad |
919 |
|
36 |
couturad |
951 |
|
37 |
|
|
MSTRUCT_GENERATEUR::MSTRUCT_GENERATEUR(MG_GESTIONNAIRE* mg_gestionnaire,char* nom_mgcg_modele) |
38 |
couturad |
919 |
{ |
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 |
couturad |
966 |
m_grille_init=false; |
46 |
couturad |
919 |
} |
47 |
|
|
|
48 |
couturad |
966 |
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 |
couturad |
951 |
MSTRUCT_GENERATEUR::~MSTRUCT_GENERATEUR(void) |
90 |
couturad |
919 |
{ |
91 |
|
|
} |
92 |
|
|
|
93 |
couturad |
951 |
MG_GESTIONNAIRE* MSTRUCT_GENERATEUR::get_mg_gestionnaire(void) |
94 |
couturad |
919 |
{ |
95 |
|
|
return m_mg_gestionnaire; |
96 |
|
|
} |
97 |
|
|
|
98 |
couturad |
951 |
MG_CG_MODELE* MSTRUCT_GENERATEUR::get_mgcg_modele(void) |
99 |
couturad |
919 |
{ |
100 |
|
|
return m_mgcg_modele; |
101 |
|
|
} |
102 |
|
|
|
103 |
couturad |
951 |
void MSTRUCT_GENERATEUR::change_mgcg_modele(MG_CG_MODELE* mgcg_modele) |
104 |
couturad |
919 |
{ |
105 |
|
|
m_mgcg_modele=mgcg_modele; |
106 |
|
|
} |
107 |
|
|
|
108 |
couturad |
951 |
void MSTRUCT_GENERATEUR::change_boite3d_ves(BOITE_3D boite3d_ves) |
109 |
|
|
{ |
110 |
|
|
m_boite3d_ves=boite3d_ves; |
111 |
|
|
} |
112 |
couturad |
919 |
|
113 |
couturad |
951 |
void MSTRUCT_GENERATEUR::change_boite3d_distribution(BOITE_3D boite3d_distribution) |
114 |
couturad |
929 |
{ |
115 |
couturad |
951 |
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 |
couturad |
966 |
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 |
couturad |
951 |
void MSTRUCT_GENERATEUR::initialiser_grille(void) |
186 |
|
|
{ |
187 |
|
|
if(!m_grille_init) |
188 |
couturad |
966 |
{ |
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 |
couturad |
951 |
} |
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 |
francois |
1095 |
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 |
couturad |
951 |
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 |
couturad |
968 |
if(m_boite3d_ves.contient(boite_inclusion.get_xmax(),boite_inclusion.get_ymax(),boite_inclusion.get_zmax())) return MSTRUCT::POSITION_RELATIVE::INTERIEUR; |
210 |
couturad |
951 |
|
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 |
couturad |
968 |
if(!m_boite3d_ves.contient(boite_inclusion.get_xmax(),boite_inclusion.get_ymax(),boite_inclusion.get_zmax())) return MSTRUCT::POSITION_RELATIVE::EXTERIEUR; |
219 |
couturad |
951 |
|
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 |
couturad |
968 |
return MSTRUCT::POSITION_RELATIVE::AU_BORD; |
227 |
couturad |
951 |
} |
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 |
francois |
1075 |
return true; |
316 |
couturad |
951 |
} |
317 |
|
|
|
318 |
|
|
bool MSTRUCT_GENERATEUR::distance_acceptable_bord_ves(MG_VOLUME* mgvolume) |
319 |
|
|
{ |
320 |
couturad |
968 |
BOITE_3D boite_volume=OT_GEOMETRIE::get_boite_3D(mgvolume); |
321 |
couturad |
951 |
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 |
couturad |
966 |
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 |
couturad |
951 |
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 |
francois |
1082 |
//vector_forme_genere.push_back(boite_frac_vol); |
504 |
couturad |
951 |
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 |
couturad |
968 |
if(position_relative_inc!=position_relative_ext || position_relative_ext==MSTRUCT::POSITION_RELATIVE::EXTERIEUR) |
557 |
couturad |
951 |
{ |
558 |
|
|
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
559 |
|
|
return FAIL; |
560 |
|
|
} |
561 |
couturad |
968 |
if(!m_intersection_bords_ves && position_relative_ext==MSTRUCT::POSITION_RELATIVE::AU_BORD) |
562 |
couturad |
951 |
{ |
563 |
|
|
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
564 |
|
|
return FAIL; |
565 |
|
|
} |
566 |
couturad |
968 |
if(position_relative_ext==MSTRUCT::POSITION_RELATIVE::AU_BORD) |
567 |
couturad |
951 |
{ |
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 |
couturad |
968 |
if(position_relative_ext==MSTRUCT::POSITION_RELATIVE::AU_BORD) |
677 |
couturad |
951 |
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 |
couturad |
968 |
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 |
couturad |
951 |
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 |
couturad |
968 |
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 |
couturad |
951 |
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 |
couturad |
968 |
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 |
couturad |
951 |
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 |
francois |
1082 |
m_mgcg_modele->supprimer_mgcg_formeid(boite_frac_vol->get_id()); |
757 |
couturad |
951 |
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+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 |
couturad |
968 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::EXTERIEUR) |
771 |
couturad |
951 |
{ |
772 |
|
|
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
773 |
|
|
return FAIL; |
774 |
|
|
} |
775 |
couturad |
968 |
if(!m_intersection_bords_ves && position_relative==MSTRUCT::POSITION_RELATIVE::AU_BORD) |
776 |
couturad |
951 |
{ |
777 |
|
|
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
778 |
|
|
return FAIL; |
779 |
|
|
} |
780 |
couturad |
968 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::AU_BORD) |
781 |
couturad |
951 |
{ |
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 |
couturad |
968 |
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 |
couturad |
951 |
vector_inclusion_genere.push_back(forme_volume_inclusion); |
821 |
|
|
forme_volume_verif_grille=forme_volume_inclusion; |
822 |
|
|
} |
823 |
|
|
fraction_volumique_actuelle+=volume_particule; |
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 |
|
|
double volume_particule; |
835 |
|
|
MG_CG_FORME* matrice=m_matrice; |
836 |
|
|
std::vector<MG_CG_FORME*> vector_forme_genere; |
837 |
|
|
std::vector<MG_CG_OPERATEUR*> vector_operateur_genere; |
838 |
|
|
vector_forme_genere.push_back(forme_inclusion); |
839 |
|
|
if(forme_inclusion->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
840 |
|
|
{ |
841 |
|
|
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
842 |
|
|
return FAIL; |
843 |
|
|
} |
844 |
|
|
MG_CG_FORME_VOLUME* forme_volume_inclusion = (MG_CG_FORME_VOLUME*)forme_inclusion; |
845 |
|
|
MG_CG_FORME_VOLUME* forme_volume_verif_grille=NULL; |
846 |
|
|
// Verification du positionnement |
847 |
|
|
if(positionnement_acceptable(forme_volume_inclusion->get_mg_volume())==FAIL) |
848 |
|
|
{ |
849 |
|
|
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
850 |
|
|
return FAIL; |
851 |
|
|
} |
852 |
|
|
// Verification de la position relative |
853 |
|
|
bool plan_x0yz;bool plan_x1yz;bool plan_xy0z;bool plan_xy1z;bool plan_xyz0;bool plan_xyz1; |
854 |
|
|
position_relative=position_relative_inclusion_ves(forme_volume_inclusion->get_mg_volume(),plan_x0yz,plan_x1yz,plan_xy0z,plan_xy1z,plan_xyz0,plan_xyz1); |
855 |
couturad |
968 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::EXTERIEUR) |
856 |
couturad |
951 |
{ |
857 |
|
|
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
858 |
|
|
return FAIL; |
859 |
|
|
} |
860 |
couturad |
968 |
if(!m_intersection_bords_ves && position_relative==MSTRUCT::POSITION_RELATIVE::AU_BORD) |
861 |
couturad |
951 |
{ |
862 |
|
|
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
863 |
|
|
return FAIL; |
864 |
|
|
} |
865 |
couturad |
968 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::AU_BORD) |
866 |
couturad |
951 |
{ |
867 |
|
|
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); |
868 |
|
|
vector_operateur_genere.push_back(op_inter); |
869 |
|
|
if(op_inter->construire()==FAIL) |
870 |
|
|
{ |
871 |
|
|
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
872 |
|
|
return FAIL; |
873 |
|
|
} |
874 |
|
|
vector_forme_genere.push_back(op_inter->get_mgcg_forme_sortie()); |
875 |
|
|
if(op_inter->get_mgcg_forme_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
876 |
|
|
{ |
877 |
|
|
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
878 |
|
|
return FAIL; |
879 |
|
|
} |
880 |
|
|
forme_volume_inclusion=(MG_CG_FORME_VOLUME*)op_inter->get_mgcg_forme_sortie(); |
881 |
|
|
} |
882 |
|
|
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); |
883 |
|
|
vector_operateur_genere.push_back(op_inc_matrice); |
884 |
|
|
if(op_inc_matrice->construire()==FAIL) |
885 |
|
|
{ |
886 |
|
|
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
887 |
|
|
return FAIL; |
888 |
|
|
} |
889 |
|
|
matrice=op_inc_matrice->get_mgcg_forme_matrice_sortie(); |
890 |
|
|
vector_forme_genere.push_back(matrice); |
891 |
|
|
vector_forme_genere.push_back(op_inc_matrice->get_mgcg_forme_inclusion_sortie()); |
892 |
|
|
if(op_inc_matrice->get_mgcg_forme_inclusion_sortie()->get_type_forme()!=MG_CG_FORME::TYPE_FORME::VOLUME) |
893 |
|
|
{ |
894 |
|
|
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
895 |
|
|
return FAIL; |
896 |
|
|
} |
897 |
|
|
forme_volume_inclusion=(MG_CG_FORME_VOLUME*)op_inc_matrice->get_mgcg_forme_inclusion_sortie(); |
898 |
couturad |
968 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::INTERIEUR) |
899 |
couturad |
951 |
{ |
900 |
|
|
if(distance_acceptable_bord_ves(forme_volume_inclusion->get_mg_volume())==FAIL) |
901 |
|
|
{ |
902 |
|
|
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
903 |
|
|
return FAIL; |
904 |
|
|
} |
905 |
|
|
} |
906 |
couturad |
993 |
if(m_intersection_bords_ves) |
907 |
|
|
if(configuration_acceptable(forme_volume_inclusion,matrice)==FAIL) |
908 |
|
|
{ |
909 |
|
|
echec_insertion_inclusion(vector_forme_genere,vector_operateur_genere); |
910 |
|
|
return FAIL; |
911 |
|
|
} |
912 |
couturad |
968 |
if(position_relative==MSTRUCT::POSITION_RELATIVE::INTERIEUR) MG_CG::creer_MG_CG_INFO_STRING(forme_volume_inclusion,(char*)"POSITION_RELATIVE",(char*)"INTERIEUR"); |
913 |
|
|
if(position_relative==MSTRUCT::POSITION_RELATIVE::AU_BORD) MG_CG::creer_MG_CG_INFO_STRING(forme_volume_inclusion,(char*)"POSITION_RELATIVE",(char*)"AU_BORD"); |
914 |
couturad |
951 |
vector_inclusion_genere.push_back(forme_volume_inclusion); |
915 |
|
|
forme_volume_verif_grille=forme_volume_inclusion; |
916 |
|
|
volume_particule=OT_GEOMETRIE::get_volume(forme_volume_inclusion->get_mg_volume()); |
917 |
|
|
fraction_volumique_actuelle+=volume_particule; |
918 |
|
|
m_grille_volume_inclusion.inserer(forme_volume_verif_grille->get_mg_volume()); |
919 |
|
|
m_matrice=matrice; |
920 |
|
|
return OK; |
921 |
|
|
} |
922 |
|
|
|
923 |
|
|
|
924 |
|
|
bool MSTRUCT_GENERATEUR::positionnement_acceptable(MG_VOLUME* inclusion) |
925 |
|
|
{ |
926 |
|
|
TPL_MAP_ENTITE<MG_VOLUME*> map_volume_recherche; |
927 |
|
|
BOITE_3D boite_recherche = inclusion->get_boite_3D(); |
928 |
|
|
boite_recherche.change_grosseur(1.1); |
929 |
|
|
m_grille_volume_inclusion.rechercher(boite_recherche,map_volume_recherche); |
930 |
|
|
TPL_MAP_ENTITE<MG_VOLUME*>::ITERATEUR it_volume; |
931 |
|
|
MG_VOLUME* volume_recherche=map_volume_recherche.get_premier(it_volume); |
932 |
|
|
double distance; |
933 |
|
|
while(volume_recherche!=NULL) |
934 |
|
|
{ |
935 |
|
|
if(OT_GEOMETRIE::get_distance_min_mg_volume_mg_volume(inclusion,volume_recherche,distance)==FAIL) return FAIL; |
936 |
|
|
else |
937 |
|
|
{ |
938 |
couturad |
968 |
if(distance<=m_distance_min+m_precision) return FAIL; |
939 |
couturad |
951 |
else volume_recherche=map_volume_recherche.get_suivant(it_volume); |
940 |
|
|
} |
941 |
|
|
} |
942 |
|
|
return OK; |
943 |
|
|
} |
944 |
|
|
|
945 |
|
|
bool MSTRUCT_GENERATEUR::lien_topologique_entre(MG_ELEMENT_TOPOLOGIQUE* mg_ele_topo1, MG_ELEMENT_TOPOLOGIQUE* mg_ele_topo2) |
946 |
|
|
{ |
947 |
|
|
TPL_MAP_ENTITE<MG_SOMMET*> map_sommet_volume1; |
948 |
|
|
OT_GEOMETRIE::get_map_mg_sommet_sous_jacent(mg_ele_topo1,map_sommet_volume1); |
949 |
|
|
TPL_MAP_ENTITE<MG_SOMMET*> map_sommet_volume2; |
950 |
|
|
OT_GEOMETRIE::get_map_mg_sommet_sous_jacent(mg_ele_topo2,map_sommet_volume2); |
951 |
|
|
TPL_MAP_ENTITE<MG_SOMMET*>::ITERATEUR it_sommet; |
952 |
|
|
for(MG_SOMMET* sommet=map_sommet_volume1.get_premier(it_sommet);sommet!=NULL;sommet=map_sommet_volume1.get_suivant(it_sommet)) |
953 |
|
|
{ |
954 |
|
|
if(map_sommet_volume2.existe(sommet)) return true; |
955 |
|
|
} |
956 |
|
|
return false; |
957 |
|
|
} |
958 |
|
|
|
959 |
|
|
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) |
960 |
|
|
{ |
961 |
|
|
if(vector_epaisseur_couches==NULL) |
962 |
|
|
{ |
963 |
|
|
MG_CG_GROUPE_FORME* groupe_forme; |
964 |
|
|
groupe_forme=MG_CG::creer_MG_CG_GROUPE_FORME(m_mgcg_modele,nom); |
965 |
|
|
m_vector_mgcg_groupe_forme_inclusion.push_back(groupe_forme); |
966 |
|
|
vector_groupe_forme.push_back(groupe_forme); |
967 |
|
|
} |
968 |
|
|
else |
969 |
|
|
{ |
970 |
|
|
MG_CG_GROUPE_FORME* groupe_forme; |
971 |
|
|
groupe_forme=MG_CG::creer_MG_CG_GROUPE_FORME(m_mgcg_modele,nom); |
972 |
|
|
m_vector_mgcg_groupe_forme_inclusion.push_back(groupe_forme); |
973 |
|
|
vector_groupe_forme.push_back(groupe_forme); |
974 |
|
|
for(int i=0;i<vector_epaisseur_couches->size();i++) |
975 |
|
|
{ |
976 |
|
|
char nom_couche[500]; |
977 |
|
|
sprintf(nom_couche,"%s_%i",nom.c_str(),i); |
978 |
|
|
groupe_forme=MG_CG::creer_MG_CG_GROUPE_FORME(m_mgcg_modele,nom_couche); |
979 |
|
|
m_vector_mgcg_groupe_forme_inclusion.push_back(groupe_forme); |
980 |
|
|
vector_groupe_forme.push_back(groupe_forme); |
981 |
|
|
} |
982 |
|
|
} |
983 |
|
|
} |
984 |
|
|
|
985 |
|
|
int MSTRUCT_GENERATEUR::configurer_volume_mince(MG_CG_FORME* forme,double epaisseur) |
986 |
|
|
{ |
987 |
|
|
if(forme->get_type_forme()==MG_CG_FORME::TYPE_FORME::VOLUME) |
988 |
|
|
{ |
989 |
|
|
MG_VOLUME* volume = ((MG_CG_FORME_VOLUME*)forme)->get_mg_volume(); |
990 |
|
|
configurer_volume_mince(volume,epaisseur); |
991 |
|
|
} |
992 |
|
|
if(forme->get_type_forme()==MG_CG_FORME::TYPE_FORME::MULTI_VOLUME) |
993 |
|
|
{ |
994 |
|
|
MG_CG_FORME_MULTI_VOLUME* forme_multi_volume = (MG_CG_FORME_MULTI_VOLUME*)forme; |
995 |
|
|
std::map<long,MG_VOLUME*>::iterator it_volume; |
996 |
|
|
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)) |
997 |
|
|
{ |
998 |
|
|
configurer_volume_mince(volume,epaisseur); |
999 |
|
|
} |
1000 |
|
|
} |
1001 |
francois |
1075 |
return 0; |
1002 |
couturad |
951 |
} |
1003 |
|
|
|
1004 |
|
|
int MSTRUCT_GENERATEUR::configurer_volume_mince(MG_VOLUME* volume, double epaisseur) |
1005 |
|
|
{ |
1006 |
|
|
TPL_MAP_ENTITE<MG_FACE*> tpl_map_face; |
1007 |
|
|
OT_GEOMETRIE::get_map_mg_face_sous_jacent(volume,tpl_map_face); |
1008 |
|
|
if(tpl_map_face.get_nb()<2) return FAIL; |
1009 |
|
|
TPL_MAP_ENTITE<MG_FACE*>::ITERATEUR it_face1; |
1010 |
|
|
TPL_MAP_ENTITE<MG_FACE*>::ITERATEUR it_face2; |
1011 |
|
|
std::cout << "NB_FACE = " << tpl_map_face.get_nb() << std::endl; |
1012 |
|
|
while(tpl_map_face.get_nb()>=2) |
1013 |
|
|
{ |
1014 |
|
|
bool trouve=false; |
1015 |
|
|
MG_FACE* face1=tpl_map_face.get_premier(it_face1); |
1016 |
|
|
it_face2=it_face1; |
1017 |
|
|
MG_FACE* face2=tpl_map_face.get_suivant(it_face2); |
1018 |
|
|
while(trouve==false && face1!=NULL && face2!=NULL) |
1019 |
|
|
{ |
1020 |
|
|
double distance_moyenne; |
1021 |
|
|
double ecart_type_distance; |
1022 |
|
|
OT_GEOMETRIE::declage_mg_face_mg_face(face1,face2,distance_moyenne,ecart_type_distance,32); |
1023 |
|
|
std::cout << " Distance = " << distance_moyenne << " Std-dev = " << ecart_type_distance << " Epaisseur = " << epaisseur << std::endl; |
1024 |
|
|
if(OPERATEUR::egal(epaisseur,distance_moyenne,m_precision) && ecart_type_distance<m_precision) |
1025 |
|
|
{ |
1026 |
|
|
std::cout << " Correspondance : " << face1->get_id() << " , " << face2->get_id() << std::endl; |
1027 |
|
|
trouve=true; |
1028 |
|
|
bool face1_base=false; |
1029 |
|
|
bool face2_base=false; |
1030 |
|
|
if(face1_base==true) |
1031 |
|
|
{ |
1032 |
|
|
volume->ajouter_face_correspondante(face1,face2); |
1033 |
|
|
} |
1034 |
|
|
else if(face2_base==true) |
1035 |
|
|
{ |
1036 |
|
|
volume->ajouter_face_correspondante(face2,face1); |
1037 |
|
|
} |
1038 |
|
|
else |
1039 |
|
|
{ |
1040 |
|
|
double aire_face1 = OT_GEOMETRIE::get_aire(face1,m_precision); |
1041 |
|
|
double aire_face2 = OT_GEOMETRIE::get_aire(face2,m_precision); |
1042 |
|
|
if(aire_face1<aire_face2) |
1043 |
|
|
{ |
1044 |
|
|
volume->ajouter_face_correspondante(face1,face2); |
1045 |
|
|
} |
1046 |
|
|
else |
1047 |
|
|
{ |
1048 |
|
|
volume->ajouter_face_correspondante(face2,face1); |
1049 |
|
|
} |
1050 |
|
|
} |
1051 |
|
|
} |
1052 |
|
|
else face2=tpl_map_face.get_suivant(it_face2); |
1053 |
|
|
} |
1054 |
|
|
if(trouve) |
1055 |
|
|
{ |
1056 |
|
|
tpl_map_face.supprimer(face1); |
1057 |
|
|
tpl_map_face.supprimer(face2); |
1058 |
|
|
} |
1059 |
|
|
else tpl_map_face.supprimer(face1); |
1060 |
|
|
} |
1061 |
francois |
1075 |
|
1062 |
|
|
return 0; |
1063 |
couturad |
951 |
} |
1064 |
|
|
|
1065 |
|
|
|
1066 |
|
|
void MSTRUCT_GENERATEUR::active_affichage(fonction_affiche* fonc) |
1067 |
|
|
{ |
1068 |
couturad |
929 |
fonc_affiche = fonc; |
1069 |
|
|
affichageactif = 1; |
1070 |
|
|
} |
1071 |
|
|
|
1072 |
couturad |
951 |
void MSTRUCT_GENERATEUR::affiche(char* message) |
1073 |
couturad |
929 |
{ |
1074 |
|
|
if(affichageactif==1) fonc_affiche(message); |
1075 |
|
|
} |