1 |
francois |
283 |
//--------------------------------------------------------------------------- |
2 |
|
|
|
3 |
|
|
#include "gestionversion.h" |
4 |
|
|
#include <math.h> |
5 |
|
|
#include "remailleur.h" |
6 |
|
|
#include "mg_gestionnaire.h" |
7 |
|
|
#include "mailleur3d.h" |
8 |
|
|
#include "mailleur0d.h" |
9 |
|
|
#include "mailleur1d.h" |
10 |
|
|
#include "mailleur2d.h" |
11 |
|
|
#include "ot_mathematique.h" |
12 |
|
|
#include "mg_geometrie_outils.h" |
13 |
|
|
//--------------------------------------------------------------------------- |
14 |
|
|
#pragma package(smart_init) |
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
REMAILLEUR::REMAILLEUR(class MG_GESTIONNAIRE* g1,MG_GESTIONNAIRE* g2,MG_GEOMETRIE* geo1,MG_GEOMETRIE* geo2,class FCT_TAILLE* fct_taille1,FCT_TAILLE* fct_taille2,MG_MAILLAGE* mori,MG_MAILLAGE* mmodi,VCT_COMPARAISON_RESULTAT& cmp):gestorigine(g1),gestmodifie(g2),carteori(fct_taille1),cartemod(fct_taille2),rescmp(cmp),maiorigine(mori),maimodifie(mmodi),geoorigine(geo1),geomodifie(geo2) |
21 |
|
|
{ |
22 |
|
|
int nbvolume=geomodifie->get_nb_mg_volume(); |
23 |
|
|
lsttrifront=new TPL_LISTE_ENTITE<MG_TRIANGLE*>[nbvolume]; |
24 |
|
|
} |
25 |
|
|
|
26 |
|
|
REMAILLEUR::~REMAILLEUR() |
27 |
|
|
{ |
28 |
|
|
//TPL_MAP_ENTITE<class MG_SEGMENT_FRONTIERE*>::ITERATEUR it; |
29 |
|
|
//for (MG_SEGMENT_FRONTIERE* seg=lstsegfront.get_premier(it);seg!=NULL;seg=lstsegfront.get_suivant(it) ) delete seg; |
30 |
|
|
delete octree; |
31 |
|
|
delete [] lsttrifront; |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
void REMAILLEUR::maille(MG_GROUPE_TOPOLOGIQUE* mggt) |
36 |
|
|
{ |
37 |
|
|
maille(20); |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
void REMAILLEUR::maille(int etape) |
41 |
|
|
{ |
42 |
|
|
//etape 0 initialisation |
43 |
|
|
initialise_octree(); |
44 |
|
|
//etape 1 Destruction des entites autour des entites disparues |
45 |
|
|
if (etape<1) return; |
46 |
|
|
affiche((char*)" Destruction autour des disparitions"); |
47 |
|
|
TPL_MAP_ENTITE<MG_ELEMENT_MAILLAGE*> lstdetruire; |
48 |
|
|
int nb=rescmp.get_nb_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_DISPARUE); |
49 |
|
|
for (int i=0;i<nb;i++) |
50 |
|
|
{ |
51 |
|
|
MG_ELEMENT_TOPOLOGIQUE* ele=rescmp.get_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_DISPARUE,i); |
52 |
|
|
int dim=ele->get_dimension(); |
53 |
|
|
if (dim==0) |
54 |
|
|
{ |
55 |
|
|
MG_SOMMET* som=(MG_SOMMET*)ele; |
56 |
|
|
int nblien=som->get_lien_maillage()->get_nb(); |
57 |
|
|
for (int j=0;j<nblien;j++) |
58 |
|
|
{ |
59 |
|
|
MG_NOEUD* no=(MG_NOEUD*)som->get_lien_maillage()->get(j); |
60 |
|
|
if (maiorigine->get_mg_noeudid(no->get_id())!=NULL) lstdetruire.ajouter(no); |
61 |
|
|
} |
62 |
|
|
} |
63 |
|
|
if (dim==1) |
64 |
|
|
{ |
65 |
|
|
MG_ARETE* are=(MG_ARETE*)ele; |
66 |
|
|
int nblien=are->get_lien_maillage()->get_nb(); |
67 |
|
|
for (int j=0;j<nblien;j++) |
68 |
|
|
{ |
69 |
|
|
MG_SEGMENT* seg=(MG_SEGMENT*)are->get_lien_maillage()->get(j); |
70 |
|
|
if (maiorigine->get_mg_segmentid(seg->get_id())!=NULL) |
71 |
|
|
{ |
72 |
|
|
lstdetruire.ajouter(seg->get_noeud1()); |
73 |
|
|
lstdetruire.ajouter(seg->get_noeud2()); |
74 |
|
|
} |
75 |
|
|
} |
76 |
|
|
} |
77 |
|
|
if (dim==2) |
78 |
|
|
{ |
79 |
|
|
MG_FACE* face=(MG_FACE*)ele; |
80 |
|
|
int nblien=face->get_lien_maillage()->get_nb(); |
81 |
|
|
for (int j=0;j<nblien;j++) |
82 |
|
|
{ |
83 |
|
|
MG_TRIANGLE* tri=(MG_TRIANGLE*)face->get_lien_maillage()->get(j); |
84 |
|
|
if (maiorigine->get_mg_triangleid(tri->get_id())!=NULL) |
85 |
|
|
{ |
86 |
|
|
lstdetruire.ajouter(tri->get_noeud1()); |
87 |
|
|
lstdetruire.ajouter(tri->get_noeud2()); |
88 |
|
|
lstdetruire.ajouter(tri->get_noeud3()); |
89 |
|
|
} |
90 |
|
|
} |
91 |
|
|
} |
92 |
|
|
} |
93 |
|
|
TPL_MAP_ENTITE<MG_ELEMENT_MAILLAGE*>::ITERATEUR it; |
94 |
|
|
for (MG_NOEUD* no=(MG_NOEUD*)lstdetruire.get_premier(it);no!=NULL;no=(MG_NOEUD*)lstdetruire.get_suivant(it)) |
95 |
|
|
{ |
96 |
|
|
double ereelle=0.; |
97 |
|
|
int nbseg=no->get_lien_segment()->get_nb(); |
98 |
|
|
for (int i=0;i<nbseg;i++) |
99 |
|
|
ereelle=ereelle+no->get_lien_segment()->get(i)->get_longueur(); |
100 |
|
|
ereelle=ereelle/nbseg; |
101 |
|
|
detruit_noeud(no,2*ereelle); |
102 |
|
|
} |
103 |
|
|
//etape 2 : transfert des noeuds de sommets; |
104 |
|
|
if (etape<2) return; |
105 |
|
|
affiche((char*)" Transfert sommet"); |
106 |
|
|
nb=rescmp.get_nb_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE); |
107 |
|
|
for (int i=0;i<nb;i++) |
108 |
|
|
{ |
109 |
|
|
MG_ELEMENT_TOPOLOGIQUE* ele=rescmp.get_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,i); |
110 |
|
|
int dim=ele->get_dimension(); |
111 |
|
|
if (dim==0) |
112 |
|
|
{ |
113 |
|
|
MG_SOMMET* som=(MG_SOMMET*)ele; |
114 |
|
|
int nblien=som->get_lien_maillage()->get_nb(); |
115 |
|
|
for (int j=0;j<nblien;j++) |
116 |
|
|
{ |
117 |
|
|
MG_NOEUD* no=(MG_NOEUD*)som->get_lien_maillage()->get(j); |
118 |
|
|
if ((maiorigine->get_mg_noeudid(no->get_id())!=NULL) && (no->get_nouveau_numero()==CONSERVE)) |
119 |
|
|
{ |
120 |
|
|
MG_SOMMET* nvsom=geomodifie->get_mg_sommetid(rescmp.get_liste_correspondance_modifie(som->get_id())); |
121 |
|
|
transfert_noeud(no,nvsom); |
122 |
|
|
} |
123 |
|
|
} |
124 |
|
|
|
125 |
|
|
} |
126 |
|
|
} |
127 |
|
|
// etape 3 maillage 0d |
128 |
|
|
if (etape<3) return; |
129 |
|
|
affiche((char*)" MAILLAGE 0D"); |
130 |
|
|
MAILLEUR0D m0d(maimodifie,geomodifie); |
131 |
|
|
m0d.adapte(); |
132 |
|
|
// etape 4 destruction autour des nouveaux sommets |
133 |
|
|
if (etape<4) return; |
134 |
|
|
affiche((char*)" Destruction autour des nouveaux sommets"); |
135 |
|
|
lstdetruire.vide(); |
136 |
|
|
nb=rescmp.get_nb_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_APPARUE); |
137 |
|
|
for (int i=0;i<nb;i++) |
138 |
|
|
{ |
139 |
|
|
MG_ELEMENT_TOPOLOGIQUE* ele=rescmp.get_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_APPARUE,i); |
140 |
|
|
int dim=ele->get_dimension(); |
141 |
|
|
if (dim==0) |
142 |
|
|
{ |
143 |
|
|
MG_SOMMET* som=(MG_SOMMET*)ele; |
144 |
|
|
int nblien=som->get_lien_maillage()->get_nb(); |
145 |
|
|
for (int j=0;j<nblien;j++) |
146 |
|
|
{ |
147 |
|
|
MG_NOEUD* no=(MG_NOEUD*)som->get_lien_maillage()->get(j); |
148 |
|
|
if (maimodifie->get_mg_noeudid(no->get_id())!=NULL) lstdetruire.ajouter(no); |
149 |
|
|
} |
150 |
|
|
} |
151 |
|
|
} |
152 |
|
|
for (MG_ELEMENT_MAILLAGE* ele=lstdetruire.get_premier(it);ele!=NULL;ele=lstdetruire.get_suivant(it)) |
153 |
|
|
{ |
154 |
|
|
detruit_noeud(ele,-1,1); |
155 |
|
|
} |
156 |
|
|
// etape 5 transferts des segments d arete |
157 |
|
|
if (etape<5) return; |
158 |
|
|
/*affiche(" Transfert arete"); |
159 |
|
|
nb=rescmp.get_nb_liste_topologie(ORIGINE_CONSERVEE); |
160 |
|
|
for (int i=0;i<nb;i++) |
161 |
|
|
{ |
162 |
|
|
MG_ELEMENT_TOPOLOGIQUE* ele=rescmp.get_liste_topologie(ORIGINE_CONSERVEE,i); |
163 |
|
|
int dim=ele->get_dimension(); |
164 |
|
|
if (dim==1) |
165 |
|
|
{ |
166 |
|
|
MG_ARETE* are=(MG_ARETE*)ele; |
167 |
|
|
int nblien=are->get_lien_maillage()->get_nb(); |
168 |
|
|
for (int j=0;j<nblien;j++) |
169 |
|
|
{ |
170 |
|
|
MG_SEGMENT* seg=(MG_SEGMENT*)are->get_lien_maillage()->get(j); |
171 |
|
|
if ((maiorigine->get_mg_segmentid(seg->get_id())!=NULL)) |
172 |
|
|
{ |
173 |
|
|
MG_NOEUD* n1=seg->get_noeud1(); |
174 |
|
|
MG_NOEUD* n2=seg->get_noeud2(); |
175 |
|
|
if (n1->get_nouveau_numero()==CONSERVE) |
176 |
|
|
if (n2->get_nouveau_numero()==CONSERVE) |
177 |
|
|
{ |
178 |
|
|
MG_ARETE* nvare=geomodifie->get_mg_areteid(rescmp.get_liste_correspondance(are->get_id())); |
179 |
|
|
MG_NOEUD* nv1=get_liste_correspondance(n1); |
180 |
|
|
MG_NOEUD* nv2=get_liste_correspondance(n2); |
181 |
|
|
if (nv1==NULL) nv1=transfert_noeud(n1,nvare); |
182 |
|
|
if (nv2==NULL) nv2=transfert_noeud(n2,nvare); |
183 |
|
|
MG_SEGMENT *seg=new MG_SEGMENT(nvare,nv1,nv2,IMPOSE); |
184 |
|
|
maimodifie->ajouter_mg_segment(seg); |
185 |
|
|
} |
186 |
|
|
} |
187 |
|
|
} |
188 |
|
|
|
189 |
|
|
} |
190 |
|
|
} |
191 |
|
|
*/ |
192 |
|
|
affiche((char*)" Creation des blocs de maille 1D"); |
193 |
|
|
int nbarete=geomodifie->get_nb_mg_arete(); |
194 |
|
|
nb=rescmp.get_nb_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE); |
195 |
|
|
for (int i=0;i<nb;i++) |
196 |
|
|
{ |
197 |
|
|
MG_ELEMENT_TOPOLOGIQUE* ele=rescmp.get_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,i); |
198 |
|
|
int dim=ele->get_dimension(); |
199 |
|
|
if (dim==1) |
200 |
|
|
{ |
201 |
|
|
multimap<unsigned long,MG_SEGMENT*,less <unsigned long> > lstseg; |
202 |
|
|
MG_ARETE* arete=(MG_ARETE*)ele; |
203 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR ittet; |
204 |
|
|
for (MG_ELEMENT_MAILLAGE* ele=arete->get_lien_maillage()->get_premier(ittet);ele!=NULL;ele=arete->get_lien_maillage()->get_suivant(ittet)) |
205 |
|
|
{ |
206 |
|
|
MG_SEGMENT* seg=(MG_SEGMENT*)ele; |
207 |
|
|
if ((maiorigine->get_mg_segmentid(seg->get_id())!=NULL)) |
208 |
|
|
{ |
209 |
|
|
MG_NOEUD* n1=seg->get_noeud1(); |
210 |
|
|
MG_NOEUD* n2=seg->get_noeud2(); |
211 |
|
|
if (n1->get_nouveau_numero()==CONSERVE) |
212 |
|
|
if (n2->get_nouveau_numero()==CONSERVE) |
213 |
|
|
{ |
214 |
|
|
seg->change_nouveau_numero(NONTRAITE); |
215 |
|
|
pair<unsigned long,MG_SEGMENT*> tmp(n1->get_id(),seg); |
216 |
|
|
lstseg.insert(tmp); |
217 |
|
|
pair<unsigned long,MG_SEGMENT*> tmp2(n2->get_id(),seg); |
218 |
|
|
lstseg.insert(tmp2); |
219 |
|
|
} |
220 |
|
|
} |
221 |
|
|
} |
222 |
|
|
|
223 |
|
|
cree_bloc_maille(lstseg,arete); |
224 |
|
|
} |
225 |
|
|
} |
226 |
|
|
// etape 6 Maillage des aretes |
227 |
|
|
if (etape<6) return; |
228 |
|
|
affiche((char*)" MAILLAGE 1D"); |
229 |
|
|
int nbare=geomodifie->get_nb_mg_arete(); |
230 |
|
|
for (int i=0;i<nbare;i++) |
231 |
|
|
{ |
232 |
|
|
MG_ARETE* arete=geomodifie->get_mg_arete(i); |
233 |
|
|
TPL_LISTE_ENTITE<double> param; |
234 |
|
|
int typeface=arete->get_courbe()->get_type_geometrique(param); |
235 |
|
|
multimap<unsigned long,BLOC_MAILLE_1D*,less <unsigned long> >::iterator it=lstb1d.begin(); |
236 |
|
|
while (it!=lstb1d.end()) |
237 |
|
|
{ |
238 |
|
|
BLOC_MAILLE_1D *b1d=(*it).second; |
239 |
|
|
if ((b1d->etat==NONATTACHE) && (b1d->type==typeface)) |
240 |
|
|
{ |
241 |
|
|
MG_NOEUD* no1=b1d->lst[0]->get_noeud1(); |
242 |
|
|
MG_NOEUD* no2=b1d->lst[0]->get_noeud2(); |
243 |
|
|
double xyz1[3],xyz2[3],xyz[3]; |
244 |
|
|
transfert_coord(no1->get_coord(),xyz1); |
245 |
|
|
transfert_coord(no2->get_coord(),xyz2); |
246 |
|
|
double t1,t2; |
247 |
|
|
arete->inverser(t1,xyz1); |
248 |
|
|
arete->inverser(t2,xyz2); |
249 |
|
|
int sensidentique=1; |
250 |
|
|
OT_VECTEUR_3D vec(xyz1,xyz2); |
251 |
|
|
vec.norme(); |
252 |
|
|
double dxyz1[3]; |
253 |
|
|
arete->deriver(t1,dxyz1); |
254 |
|
|
OT_VECTEUR_3D dvec(dxyz1); |
255 |
|
|
dvec.norme(); |
256 |
|
|
double ps=dvec*vec; |
257 |
|
|
if (ps <0) sensidentique=0; |
258 |
|
|
if (sensidentique==0) |
259 |
|
|
{ |
260 |
|
|
double t=t1; |
261 |
|
|
t1=t2; |
262 |
|
|
t2=t; |
263 |
|
|
double xyz[3]; |
264 |
|
|
xyz[0]=xyz1[0]; |
265 |
|
|
xyz[1]=xyz1[1]; |
266 |
|
|
xyz[2]=xyz1[2]; |
267 |
|
|
xyz1[0]=xyz2[0]; |
268 |
|
|
xyz1[1]=xyz2[1]; |
269 |
|
|
xyz1[2]=xyz2[2]; |
270 |
|
|
xyz2[0]=xyz[0]; |
271 |
|
|
xyz2[1]=xyz[1]; |
272 |
|
|
xyz2[2]=xyz[2]; |
273 |
|
|
} |
274 |
|
|
if (arete->get_courbe()->est_periodique()==1) |
275 |
|
|
{ |
276 |
|
|
//if (t1<arete->get_tmin()) t1=t1+arete->get_courbe()->get_periode(); |
277 |
|
|
if (t2<t1+1e-6) t2=t2+arete->get_courbe()->get_periode(); |
278 |
|
|
} |
279 |
|
|
double xyz1tmp[3],xyz2tmp[3]; |
280 |
|
|
arete->evaluer(t1,xyz1tmp); |
281 |
|
|
arete->evaluer(t2,xyz2tmp); |
282 |
|
|
OT_VECTEUR_3D vec1(xyz1,xyz1tmp); |
283 |
|
|
OT_VECTEUR_3D vec2(xyz2,xyz2tmp); |
284 |
|
|
double metrique[9]; |
285 |
|
|
cartemod->evaluer(xyz1,metrique); |
286 |
|
|
double eps=(1./sqrt(metrique[0])*1e-6); |
287 |
|
|
double t=0.5*(t1+t2); |
288 |
|
|
if ((vec1.get_longueur()<eps)&&(vec2.get_longueur()<eps)) |
289 |
|
|
{ |
290 |
|
|
if (arete->get_courbe()->est_periodique()==1) |
291 |
|
|
if (t<arete->get_tmin()) t=t+arete->get_courbe()->get_periode(); |
292 |
|
|
if ((t>=arete->get_tmin()) && (t<=arete->get_tmax())) |
293 |
|
|
{ |
294 |
|
|
int nbseg=b1d->lst.size(); |
295 |
|
|
b1d->etat=ATTACHE; |
296 |
|
|
for (int i=0;i<nbseg;i++) |
297 |
|
|
{ |
298 |
|
|
MG_SEGMENT *seg=b1d->lst[i]; |
299 |
|
|
MG_NOEUD* no1=seg->get_noeud1(); |
300 |
|
|
MG_NOEUD* no2=seg->get_noeud2(); |
301 |
|
|
double xyz1[3],xy2[3]; |
302 |
|
|
transfert_coord(no1->get_coord(),xyz1); |
303 |
|
|
transfert_coord(no2->get_coord(),xyz2); |
304 |
|
|
MG_NOEUD* nv1=get_liste_correspondance(no1); |
305 |
|
|
MG_NOEUD* nv2=get_liste_correspondance(no2); |
306 |
|
|
if (nv1==NULL) nv1=transfert_noeud(no1,arete); |
307 |
|
|
if (nv2==NULL) nv2=transfert_noeud(no2,arete); |
308 |
|
|
MG_SEGMENT *nvseg; |
309 |
|
|
if (sensidentique==1) |
310 |
|
|
nvseg=new MG_SEGMENT(arete,nv1,nv2,IMPOSE); |
311 |
|
|
else |
312 |
|
|
nvseg=new MG_SEGMENT(arete,nv2,nv1,IMPOSE); |
313 |
|
|
maimodifie->ajouter_mg_segment(nvseg); |
314 |
|
|
} |
315 |
|
|
} |
316 |
|
|
} |
317 |
|
|
} |
318 |
|
|
it++; |
319 |
|
|
} |
320 |
francois |
446 |
MAILLEUR1D m1d(maimodifie,geomodifie,cartemod,arete); |
321 |
francois |
283 |
m1d.adapte(); |
322 |
|
|
} |
323 |
|
|
//cree_quadtree(maimodifie,quad,&lstsegfront); |
324 |
|
|
// etape 7 Destruction autour des nouveaux segments |
325 |
|
|
if (etape<7) return; |
326 |
|
|
affiche((char*)" Destruction autour des nouvelles aretes"); |
327 |
|
|
lstdetruire.vide(); |
328 |
|
|
/*nb=rescmp.get_nb_liste_topologie(MODIFIE_APPARUE); |
329 |
|
|
for (int i=0;i<nb;i++) |
330 |
|
|
{ |
331 |
|
|
MG_ELEMENT_TOPOLOGIQUE* ele=rescmp.get_liste_topologie(MODIFIE_APPARUE,i); |
332 |
|
|
int dim=ele->get_dimension(); |
333 |
|
|
if (dim==1) |
334 |
|
|
{ |
335 |
|
|
MG_ARETE* are=(MG_ARETE*)ele; |
336 |
|
|
int nblien=are->get_lien_maillage()->get_nb(); |
337 |
|
|
for (int j=0;j<nblien;j++) |
338 |
|
|
{ |
339 |
|
|
MG_SEGMENT* seg=(MG_SEGMENT*)are->get_lien_maillage()->get(j); |
340 |
|
|
if (maimodifie->get_mg_segmentid(seg->get_id())!=NULL) |
341 |
|
|
{ |
342 |
|
|
lstnoeuddetruire.ajouter(seg->get_noeud1()); |
343 |
|
|
lstnoeuddetruire.ajouter(seg->get_noeud2()); |
344 |
|
|
} |
345 |
|
|
} |
346 |
|
|
} |
347 |
|
|
}*/ |
348 |
|
|
LISTE_MG_SEGMENT::iterator itnvseg; |
349 |
|
|
for (MG_SEGMENT* seg=maimodifie->get_premier_segment(itnvseg);seg!=NULL;seg=maimodifie->get_suivant_segment(itnvseg)) |
350 |
|
|
{ |
351 |
|
|
if (seg->get_origine()==MAILLEUR_AUTO) |
352 |
|
|
{ |
353 |
|
|
lstdetruire.ajouter(seg); |
354 |
|
|
} |
355 |
|
|
} |
356 |
|
|
for (MG_ELEMENT_MAILLAGE* ele=lstdetruire.get_premier(it);ele!=NULL;ele=lstdetruire.get_suivant(it)) |
357 |
|
|
{ |
358 |
|
|
detruit_noeud(ele,-1,2); |
359 |
|
|
} |
360 |
|
|
|
361 |
|
|
// etape 8 Creation des blocs de mailles 2D |
362 |
|
|
if (etape<8) return; |
363 |
|
|
affiche((char*)" Creation des blocs de maille 2D"); |
364 |
|
|
nb=rescmp.get_nb_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE); |
365 |
|
|
for (int i=0;i<nb;i++) |
366 |
|
|
{ |
367 |
|
|
MG_ELEMENT_TOPOLOGIQUE* ele=rescmp.get_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,i); |
368 |
|
|
int dim=ele->get_dimension(); |
369 |
|
|
if (dim==2) |
370 |
|
|
{ |
371 |
|
|
multimap<unsigned long,MG_TRIANGLE*,less <unsigned long> > lsttri; |
372 |
|
|
MG_FACE* face=(MG_FACE*)ele; |
373 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR ittet; |
374 |
|
|
int compteur=0,compteur2=0; |
375 |
|
|
for (MG_ELEMENT_MAILLAGE* ele=face->get_lien_maillage()->get_premier(ittet);ele!=NULL;ele=face->get_lien_maillage()->get_suivant(ittet)) |
376 |
|
|
{ |
377 |
|
|
MG_TRIANGLE* tri=(MG_TRIANGLE*)ele; |
378 |
|
|
if ((maiorigine->get_mg_triangleid(tri->get_id())!=NULL)) |
379 |
|
|
{ |
380 |
|
|
MG_NOEUD* n1=tri->get_noeud1(); |
381 |
|
|
MG_NOEUD* n2=tri->get_noeud2(); |
382 |
|
|
MG_NOEUD* n3=tri->get_noeud3(); |
383 |
|
|
compteur2++; |
384 |
|
|
if (n1->get_nouveau_numero()==CONSERVE) |
385 |
|
|
if (n2->get_nouveau_numero()==CONSERVE) |
386 |
|
|
if (n3->get_nouveau_numero()==CONSERVE) |
387 |
|
|
{ |
388 |
|
|
tri->change_nouveau_numero(NONTRAITE); |
389 |
|
|
pair<unsigned long,MG_TRIANGLE*> tmp(n1->get_id(),tri); |
390 |
|
|
lsttri.insert(tmp); |
391 |
|
|
pair<unsigned long,MG_TRIANGLE*> tmp2(n2->get_id(),tri); |
392 |
|
|
lsttri.insert(tmp2); |
393 |
|
|
pair<unsigned long,MG_TRIANGLE*> tmp3(n3->get_id(),tri); |
394 |
|
|
lsttri.insert(tmp3); |
395 |
|
|
compteur++; |
396 |
|
|
} |
397 |
|
|
} |
398 |
|
|
} |
399 |
|
|
|
400 |
|
|
cree_bloc_maille(lsttri,face); |
401 |
|
|
} |
402 |
|
|
} |
403 |
|
|
// etape 9 MAILLAGE 2D |
404 |
|
|
if (etape<9) return; |
405 |
|
|
affiche((char*)" MAILLAGE 2D"); |
406 |
|
|
nbfacemod=geomodifie->get_nb_mg_face(); |
407 |
|
|
for (int i=0;i<nbfacemod;i++) |
408 |
|
|
{ |
409 |
|
|
MG_GEOMETRIE_OUTILS ot; |
410 |
|
|
TPL_LISTE_ENTITE<MG_TRIANGLE*> lsttricontraint; |
411 |
|
|
MG_FACE* face=geomodifie->get_mg_face(i); |
412 |
|
|
TPL_LISTE_ENTITE<double> param; |
413 |
|
|
int typeface=face->get_surface()->get_type_geometrique(param); |
414 |
|
|
multimap<unsigned long,BLOC_MAILLE_2D*,less <unsigned long> >::iterator it=lstb2d.begin(); |
415 |
|
|
while (it!=lstb2d.end()) |
416 |
|
|
{ |
417 |
|
|
BLOC_MAILLE_2D *b2d=(*it).second; |
418 |
|
|
if ((b2d->etat==NONATTACHE) && (b2d->type==typeface)) |
419 |
|
|
{ |
420 |
|
|
MG_NOEUD* no1=b2d->lst[0]->get_noeud1(); |
421 |
|
|
MG_NOEUD* no2=b2d->lst[0]->get_noeud2(); |
422 |
|
|
MG_NOEUD* no3=b2d->lst[0]->get_noeud3(); |
423 |
|
|
double uv[2],uv1[2],uv2[2],uv3[2]; |
424 |
|
|
double xyz1[3],xyz2[3],xyz3[3]; |
425 |
|
|
transfert_coord(no1->get_coord(),xyz1); |
426 |
|
|
transfert_coord(no2->get_coord(),xyz2); |
427 |
|
|
transfert_coord(no3->get_coord(),xyz3); |
428 |
|
|
face->inverser(uv1,xyz1); |
429 |
|
|
face->inverser(uv2,xyz2); |
430 |
|
|
face->inverser(uv3,xyz3); |
431 |
francois |
317 |
if (face->get_surface()->est_periodique_u()==1) |
432 |
|
|
{ |
433 |
|
|
double eps=1e-10*face->get_surface()->get_periode_u(); |
434 |
|
|
if (uv1[0]<-eps) uv1[0]=uv1[0]+face->get_surface()->get_periode_u(); |
435 |
|
|
if (uv1[0]>face->get_surface()->get_periode_u()-eps) uv1[0]=uv1[0]-face->get_surface()->get_periode_u(); |
436 |
|
|
if (uv2[0]<-eps) uv2[0]=uv2[0]+face->get_surface()->get_periode_u(); |
437 |
|
|
if (uv2[0]>face->get_surface()->get_periode_u()-eps) uv2[0]=uv2[0]-face->get_surface()->get_periode_u(); |
438 |
|
|
if (uv3[0]<-eps) uv3[0]=uv3[0]+face->get_surface()->get_periode_u(); |
439 |
|
|
if (uv3[0]>face->get_surface()->get_periode_u()-eps) uv3[0]=uv3[0]-face->get_surface()->get_periode_u(); |
440 |
|
|
} |
441 |
|
|
if (face->get_surface()->est_periodique_v()==1) |
442 |
|
|
{ |
443 |
|
|
double eps=1e-10*face->get_surface()->get_periode_v(); |
444 |
|
|
if (uv1[1]<-eps) uv1[1]=uv1[1]+face->get_surface()->get_periode_v(); |
445 |
|
|
if (uv1[1]>face->get_surface()->get_periode_v()-eps) uv1[1]=uv1[1]-face->get_surface()->get_periode_v(); |
446 |
|
|
if (uv2[1]<-eps) uv2[1]=uv2[1]+face->get_surface()->get_periode_v(); |
447 |
|
|
if (uv2[1]>face->get_surface()->get_periode_v()-eps) uv2[1]=uv2[1]-face->get_surface()->get_periode_v(); |
448 |
|
|
if (uv3[1]<-eps) uv3[1]=uv3[1]+face->get_surface()->get_periode_v(); |
449 |
|
|
if (uv3[1]>face->get_surface()->get_periode_v()-eps) uv3[1]=uv3[1]-face->get_surface()->get_periode_v(); |
450 |
|
|
} |
451 |
|
|
|
452 |
francois |
283 |
double xyz1tmp[3]; |
453 |
|
|
face->evaluer(uv1,xyz1tmp); |
454 |
|
|
double xyz2tmp[3]; |
455 |
|
|
face->evaluer(uv2,xyz2tmp); |
456 |
|
|
double xyz3tmp[3]; |
457 |
|
|
face->evaluer(uv3,xyz3tmp); |
458 |
|
|
OT_VECTEUR_3D vec1(xyz1,xyz1tmp); |
459 |
|
|
OT_VECTEUR_3D vec2(xyz2,xyz2tmp); |
460 |
|
|
OT_VECTEUR_3D vec3(xyz3,xyz3tmp); |
461 |
|
|
double metrique[9]; |
462 |
|
|
cartemod->evaluer(xyz1,metrique); |
463 |
|
|
double eps=(1./sqrt(metrique[0])*1e-6); |
464 |
|
|
if (vec1.get_longueur()<eps) |
465 |
|
|
if (vec2.get_longueur()<eps) |
466 |
|
|
if (vec3.get_longueur()<eps) |
467 |
|
|
{ |
468 |
|
|
OT_DECALAGE_PARAMETRE deca(face->get_surface()->get_periode_u(),face->get_surface()->get_periode_v()); |
469 |
|
|
double du=deca.calcul_decalage_parametre_u(uv1[0]); |
470 |
|
|
double dv=deca.calcul_decalage_parametre_v(uv1[1]); |
471 |
|
|
uv[0]=0.333333333333333333*(deca.decalage_parametre_u(uv1[0],du)+deca.decalage_parametre_u(uv2[0],du)+deca.decalage_parametre_u(uv3[0],du)); |
472 |
|
|
uv[1]=0.333333333333333333*(deca.decalage_parametre_v(uv1[1],dv)+deca.decalage_parametre_v(uv2[1],dv)+deca.decalage_parametre_v(uv3[1],dv)); |
473 |
|
|
uv[0]=deca.decalage_parametre_u(uv[0],-du); |
474 |
|
|
uv[1]=deca.decalage_parametre_v(uv[1],-dv); |
475 |
|
|
double dist=ot.calcule_distance_contour_face_uv(uv,face); |
476 |
|
|
if (dist>0.) |
477 |
|
|
{ |
478 |
|
|
int sensidentique=1; |
479 |
|
|
OT_VECTEUR_3D vec12(xyz1,xyz2); |
480 |
|
|
OT_VECTEUR_3D vec13(xyz1,xyz3); |
481 |
|
|
double normal[3]; |
482 |
|
|
face->calcul_normale_unitaire(uv1,normal); |
483 |
|
|
OT_VECTEUR_3D nor=vec13 & vec12; |
484 |
|
|
nor.norme(); |
485 |
|
|
if ((nor*normal)<0.) sensidentique=0; |
486 |
|
|
int nbtri=b2d->lst.size(); |
487 |
|
|
b2d->etat=ATTACHE; |
488 |
|
|
//cout << " attachment du bloc " << b2d->face->get_id(); |
489 |
|
|
for (int i=0;i<nbtri;i++) |
490 |
|
|
{ |
491 |
|
|
MG_TRIANGLE *tri=b2d->lst[i]; |
492 |
|
|
MG_NOEUD* no1=tri->get_noeud1(); |
493 |
|
|
MG_NOEUD* no2=tri->get_noeud2(); |
494 |
|
|
MG_NOEUD* no3=tri->get_noeud3(); |
495 |
|
|
double xyz1[3],xy2[3],xyz3[3]; |
496 |
|
|
transfert_coord(no1->get_coord(),xyz1); |
497 |
|
|
transfert_coord(no2->get_coord(),xyz2); |
498 |
|
|
transfert_coord(no3->get_coord(),xyz3); |
499 |
|
|
MG_NOEUD* nvno1=new MG_NOEUD(NULL,xyz1[0],xyz1[1],xyz1[2],IMPOSE); |
500 |
|
|
MG_NOEUD* nvno2=new MG_NOEUD(NULL,xyz2[0],xyz2[1],xyz2[2],IMPOSE); |
501 |
|
|
MG_NOEUD* nvno3=new MG_NOEUD(NULL,xyz3[0],xyz3[1],xyz3[2],IMPOSE); |
502 |
|
|
MG_TRIANGLE* nvtri; |
503 |
|
|
if (sensidentique==1) |
504 |
|
|
nvtri=new MG_TRIANGLE(NULL,nvno1,nvno2,nvno3,NULL,NULL,NULL,IMPOSE); |
505 |
|
|
else |
506 |
|
|
nvtri=new MG_TRIANGLE(NULL,nvno2,nvno1,nvno3,NULL,NULL,NULL,IMPOSE); |
507 |
|
|
lsttricontraint.ajouter(nvtri); |
508 |
|
|
nvno1->change_nouveau_numero(no1->get_id()); |
509 |
|
|
nvno2->change_nouveau_numero(no2->get_id()); |
510 |
|
|
nvno3->change_nouveau_numero(no3->get_id()); |
511 |
|
|
} |
512 |
|
|
} |
513 |
|
|
} |
514 |
|
|
} |
515 |
|
|
it++; |
516 |
|
|
} |
517 |
francois |
446 |
MAILLEUR2D m2d(maimodifie,geomodifie,cartemod,face); |
518 |
francois |
283 |
char mess[50]; |
519 |
|
|
sprintf(mess," Face %i identificateur %lu",i,face->get_id()); |
520 |
|
|
affiche(mess); |
521 |
|
|
m2d.maille(face,NULL,&(lsttricontraint)); |
522 |
|
|
int nbtricon=lsttricontraint.get_nb(); |
523 |
|
|
for (int i=0;i<nbtricon;i++) |
524 |
|
|
{ |
525 |
|
|
MG_TRIANGLE* tri=lsttricontraint.get(0); |
526 |
|
|
MG_NOEUD* noeud1=tri->get_noeud1(); |
527 |
|
|
MG_NOEUD* noeud2=tri->get_noeud2(); |
528 |
|
|
MG_NOEUD* noeud3=tri->get_noeud3(); |
529 |
|
|
lsttricontraint.supprimer(tri); |
530 |
|
|
delete tri; |
531 |
|
|
delete noeud1; |
532 |
|
|
delete noeud2; |
533 |
|
|
delete noeud3; |
534 |
|
|
} |
535 |
|
|
} |
536 |
|
|
multimap<unsigned long,BLOC_MAILLE_2D*,less <unsigned long> >::iterator itfin2=lstb2d.begin(); |
537 |
|
|
while (itfin2!=lstb2d.end()) |
538 |
|
|
{ |
539 |
|
|
delete (*itfin2).second; |
540 |
|
|
itfin2++; |
541 |
|
|
} |
542 |
|
|
cree_liste_frontiere(maimodifie); |
543 |
|
|
// etape 10 Destruction autour des nouveaux triangles |
544 |
|
|
if (etape<10) return; |
545 |
|
|
affiche((char*)" Destruction autour des nouvelles faces"); |
546 |
|
|
lstdetruire.vide(); |
547 |
|
|
LISTE_MG_TRIANGLE::iterator itnvtri; |
548 |
|
|
for (MG_TRIANGLE* tri=maimodifie->get_premier_triangle(itnvtri);tri!=NULL;tri=maimodifie->get_suivant_triangle(itnvtri)) |
549 |
|
|
{ |
550 |
|
|
if (tri->get_origine()==MAILLEUR_AUTO) |
551 |
|
|
{ |
552 |
|
|
lstdetruire.ajouter(tri); |
553 |
|
|
} |
554 |
|
|
} |
555 |
|
|
for (MG_ELEMENT_MAILLAGE* ele=lstdetruire.get_premier(it);ele!=NULL;ele=lstdetruire.get_suivant(it)) |
556 |
|
|
{ |
557 |
|
|
detruit_noeud(ele,-1,3); |
558 |
|
|
} |
559 |
|
|
// etape 11 Creation des blocs de mailles 3D |
560 |
|
|
if (etape<11) return; |
561 |
|
|
affiche((char*)" Creation des blocs de maille 3D"); |
562 |
|
|
int nbvolume=geoorigine->get_nb_mg_volume(); |
563 |
|
|
for (int i=0;i<nbvolume;i++) |
564 |
|
|
{ |
565 |
|
|
multimap<unsigned long,MG_TETRA*,less <unsigned long> > lsttet; |
566 |
|
|
MG_VOLUME* vol=geoorigine->get_mg_volume(i); |
567 |
|
|
int nblien=vol->get_lien_maillage()->get_nb(); |
568 |
|
|
TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR ittet; |
569 |
|
|
for (MG_ELEMENT_MAILLAGE* ele=vol->get_lien_maillage()->get_premier(ittet);ele!=NULL;ele=vol->get_lien_maillage()->get_suivant(ittet)) |
570 |
|
|
{ |
571 |
|
|
MG_TETRA* tet=(MG_TETRA*)ele; |
572 |
|
|
if ((maiorigine->get_mg_tetraid(tet->get_id())!=NULL)) |
573 |
|
|
{ |
574 |
|
|
MG_NOEUD* n1=tet->get_noeud1(); |
575 |
|
|
MG_NOEUD* n2=tet->get_noeud2(); |
576 |
|
|
MG_NOEUD* n3=tet->get_noeud3(); |
577 |
|
|
MG_NOEUD* n4=tet->get_noeud4(); |
578 |
|
|
if (n1->get_nouveau_numero()==CONSERVE) |
579 |
|
|
if (n2->get_nouveau_numero()==CONSERVE) |
580 |
|
|
if (n3->get_nouveau_numero()==CONSERVE) |
581 |
|
|
if (n4->get_nouveau_numero()==CONSERVE) |
582 |
|
|
{ |
583 |
|
|
tet->change_nouveau_numero(NONTRAITE); |
584 |
|
|
pair<unsigned long,MG_TETRA*> tmp(n1->get_id(),tet); |
585 |
|
|
lsttet.insert(tmp); |
586 |
|
|
pair<unsigned long,MG_TETRA*> tmp2(n2->get_id(),tet); |
587 |
|
|
lsttet.insert(tmp2); |
588 |
|
|
pair<unsigned long,MG_TETRA*> tmp3(n3->get_id(),tet); |
589 |
|
|
lsttet.insert(tmp3); |
590 |
|
|
pair<unsigned long,MG_TETRA*> tmp4(n4->get_id(),tet); |
591 |
|
|
lsttet.insert(tmp4); |
592 |
|
|
} |
593 |
|
|
} |
594 |
|
|
|
595 |
|
|
} |
596 |
|
|
cree_bloc_maille(lsttet,vol); |
597 |
|
|
} |
598 |
|
|
// etape 12 Maillage 3D |
599 |
|
|
if (etape<12) return; |
600 |
|
|
affiche((char*)" MAILLEUR 3D"); |
601 |
|
|
nbvolume=geomodifie->get_nb_mg_volume(); |
602 |
|
|
for (int i=0;i<nbvolume;i++) |
603 |
|
|
{ |
604 |
|
|
TPL_LISTE_ENTITE<MG_TETRA*> lsttetcontraint; |
605 |
|
|
MG_VOLUME* vol=geomodifie->get_mg_volume(i); |
606 |
|
|
multimap<unsigned long,BLOC_MAILLE_3D*,less <unsigned long> >::iterator it=lstb3d.begin(); |
607 |
|
|
while (it!=lstb3d.end()) |
608 |
|
|
{ |
609 |
|
|
BLOC_MAILLE_3D *b3d=(*it).second; |
610 |
|
|
if (b3d->etat==NONATTACHE) |
611 |
|
|
{ |
612 |
|
|
MG_NOEUD* no1=b3d->lst[0]->get_noeud1(); |
613 |
|
|
MG_NOEUD* no2=b3d->lst[0]->get_noeud2(); |
614 |
|
|
MG_NOEUD* no3=b3d->lst[0]->get_noeud3(); |
615 |
|
|
MG_NOEUD* no4=b3d->lst[0]->get_noeud4(); |
616 |
|
|
double xyz1[3],xyz2[3],xyz3[3],xyz4[3],xyz[3]; |
617 |
|
|
transfert_coord(no1->get_coord(),xyz1); |
618 |
|
|
transfert_coord(no2->get_coord(),xyz2); |
619 |
|
|
transfert_coord(no3->get_coord(),xyz3); |
620 |
|
|
transfert_coord(no4->get_coord(),xyz4); |
621 |
|
|
xyz[0]=0.25*(xyz1[0]+xyz2[0]+xyz3[0]+xyz4[0]); |
622 |
|
|
xyz[1]=0.25*(xyz1[1]+xyz2[1]+xyz3[1]+xyz4[1]); |
623 |
|
|
xyz[2]=0.25*(xyz1[2]+xyz2[2]+xyz3[2]+xyz4[2]); |
624 |
|
|
int res=point_appartient_volume(xyz,i); |
625 |
|
|
if (res==1) |
626 |
|
|
{ |
627 |
|
|
int nbtet=b3d->lst.size(); |
628 |
|
|
b3d->etat=ATTACHE; |
629 |
|
|
//cout << "bloc recupere " << b3d->get_id() << endl; |
630 |
|
|
for (int j=0;j<nbtet;j++) |
631 |
|
|
{ |
632 |
|
|
MG_TETRA *tet=b3d->lst[j]; |
633 |
|
|
MG_NOEUD* no1=tet->get_noeud1(); |
634 |
|
|
MG_NOEUD* no2=tet->get_noeud2(); |
635 |
|
|
MG_NOEUD* no3=tet->get_noeud3(); |
636 |
|
|
MG_NOEUD* no4=tet->get_noeud4(); |
637 |
|
|
double xyz1[3],xy2[3],xyz3[3],xyz4[3]; |
638 |
|
|
transfert_coord(no1->get_coord(),xyz1); |
639 |
|
|
transfert_coord(no2->get_coord(),xyz2); |
640 |
|
|
transfert_coord(no3->get_coord(),xyz3); |
641 |
|
|
transfert_coord(no4->get_coord(),xyz4); |
642 |
|
|
MG_NOEUD* nvno1=new MG_NOEUD(NULL,xyz1[0],xyz1[1],xyz1[2],IMPOSE); |
643 |
|
|
MG_NOEUD* nvno2=new MG_NOEUD(NULL,xyz2[0],xyz2[1],xyz2[2],IMPOSE); |
644 |
|
|
MG_NOEUD* nvno3=new MG_NOEUD(NULL,xyz3[0],xyz3[1],xyz3[2],IMPOSE); |
645 |
|
|
MG_NOEUD* nvno4=new MG_NOEUD(NULL,xyz4[0],xyz4[1],xyz4[2],IMPOSE); |
646 |
|
|
MG_TETRA* nvtet=new MG_TETRA(NULL,nvno1,nvno2,nvno3,nvno4,NULL,NULL,NULL,NULL,IMPOSE); |
647 |
|
|
lsttetcontraint.ajouter(nvtet); |
648 |
|
|
nvno1->change_nouveau_numero(no1->get_id()); |
649 |
|
|
nvno2->change_nouveau_numero(no2->get_id()); |
650 |
|
|
nvno3->change_nouveau_numero(no3->get_id()); |
651 |
|
|
nvno4->change_nouveau_numero(no4->get_id()); |
652 |
|
|
nvtet->change_nouveau_numero(tet->get_id()); |
653 |
|
|
} |
654 |
|
|
} |
655 |
|
|
} |
656 |
|
|
it++; |
657 |
|
|
} |
658 |
francois |
446 |
MAILLEUR3D m3d(maimodifie,geomodifie,cartemod,vol); |
659 |
francois |
283 |
char mess[50]; |
660 |
|
|
sprintf(mess," Volume %i identificateur %lu",i,vol->get_id()); |
661 |
|
|
affiche(mess); |
662 |
francois |
425 |
m3d.active_affichage(affiche2); |
663 |
francois |
283 |
m3d.maille(vol,NULL,&(lsttetcontraint)); |
664 |
|
|
int nbtetcon=lsttetcontraint.get_nb(); |
665 |
|
|
for (int i=0;i<nbtetcon;i++) |
666 |
|
|
{ |
667 |
|
|
MG_TETRA* tet=lsttetcontraint.get(0); |
668 |
|
|
MG_NOEUD* noeud1=tet->get_noeud1(); |
669 |
|
|
MG_NOEUD* noeud2=tet->get_noeud2(); |
670 |
|
|
MG_NOEUD* noeud3=tet->get_noeud3(); |
671 |
|
|
MG_NOEUD* noeud4=tet->get_noeud4(); |
672 |
|
|
lsttetcontraint.supprimer(tet); |
673 |
|
|
delete tet; |
674 |
|
|
delete noeud1; |
675 |
|
|
delete noeud2; |
676 |
|
|
delete noeud3; |
677 |
|
|
delete noeud4; |
678 |
|
|
} |
679 |
|
|
} |
680 |
|
|
multimap<unsigned long,BLOC_MAILLE_3D*,less <unsigned long> >::iterator itfin3=lstb3d.begin(); |
681 |
|
|
while (itfin3!=lstb3d.end()) |
682 |
|
|
{ |
683 |
|
|
delete (*itfin3).second; |
684 |
|
|
itfin3++; |
685 |
|
|
} |
686 |
|
|
// etape 13 Recuperation des correspondances |
687 |
|
|
if (etape<13) return; |
688 |
|
|
affiche((char*)" Sauvegarde des correspondances"); |
689 |
|
|
LISTE_MG_NOEUD::iterator itnoeud; |
690 |
|
|
for (MG_NOEUD* noeud=maimodifie->get_premier_noeud(itnoeud);noeud!=NULL;noeud=maimodifie->get_suivant_noeud(itnoeud)) |
691 |
|
|
{ |
692 |
|
|
if (noeud->get_origine()==IMPOSE) |
693 |
|
|
rescmp.ajouter_correspondance(noeud->get_nouveau_numero(),noeud->get_id()); |
694 |
|
|
} |
695 |
|
|
LISTE_MG_TETRA::iterator ittet; |
696 |
|
|
for (MG_TETRA* tet=maimodifie->get_premier_tetra(ittet);tet!=NULL;tet=maimodifie->get_suivant_tetra(ittet)) |
697 |
|
|
{ |
698 |
|
|
if (tet->get_origine()==IMPOSE) |
699 |
|
|
rescmp.ajouter_correspondance(tet->get_nouveau_numero(),tet->get_id()); |
700 |
|
|
} |
701 |
|
|
|
702 |
|
|
} |
703 |
|
|
|
704 |
|
|
|
705 |
|
|
void REMAILLEUR::initialise_octree(void) |
706 |
|
|
{ |
707 |
francois |
467 |
BOITE_3D boite=carteori->get_boite_3D(); |
708 |
|
|
double xmin=boite.get_xmin(); |
709 |
|
|
double ymin=boite.get_ymin(); |
710 |
|
|
double zmin=boite.get_zmin(); |
711 |
|
|
double xmax=boite.get_xmax(); |
712 |
|
|
double ymax=boite.get_ymax(); |
713 |
|
|
double zmax=boite.get_zmax(); |
714 |
|
|
octree=new TPL_OCTREE_FCT<MG_NOEUD*,FCT_TAILLE >; |
715 |
|
|
octree->initialiser(*carteori,xmin,ymin,zmin,xmax,ymax,zmax); |
716 |
francois |
283 |
LISTE_MG_NOEUD::iterator it; |
717 |
|
|
for (MG_NOEUD* noeud=maiorigine->get_premier_noeud(it);noeud!=NULL;noeud=maiorigine->get_suivant_noeud(it)) |
718 |
|
|
{ |
719 |
|
|
noeud->change_nouveau_numero(CONSERVE); |
720 |
|
|
octree->inserer(noeud); |
721 |
|
|
} |
722 |
|
|
|
723 |
|
|
} |
724 |
|
|
|
725 |
|
|
void REMAILLEUR::detruit_noeud(MG_ELEMENT_MAILLAGE* elebase,double distance,int type) |
726 |
|
|
{ |
727 |
|
|
if (elebase->get_origine()!=MAILLEUR_AUTO) return; |
728 |
|
|
double xyz[3]; |
729 |
|
|
double distmin; |
730 |
|
|
OT_VECTEUR_3D direction; |
731 |
|
|
if (type==0) |
732 |
|
|
{ |
733 |
|
|
MG_NOEUD* no=(MG_NOEUD*)elebase; |
734 |
|
|
OT_VECTEUR_3D vecnoeud(no->get_coord()); |
735 |
|
|
//OT_VECTEUR_3D vecnoeud2=rescmp.change_coord_mod_ori(vecnoeud); |
736 |
|
|
OT_VECTEUR_3D vecnoeud2=vecnoeud; |
737 |
|
|
xyz[0]=vecnoeud2.get_x(); |
738 |
|
|
xyz[1]=vecnoeud2.get_y(); |
739 |
|
|
xyz[2]=vecnoeud2.get_z(); |
740 |
|
|
} |
741 |
|
|
if (type==1) |
742 |
|
|
{ |
743 |
|
|
MG_NOEUD* no=(MG_NOEUD*)elebase; |
744 |
|
|
OT_VECTEUR_3D vecnoeud(no->get_coord()); |
745 |
|
|
OT_VECTEUR_3D vecnoeud2=rescmp.change_coord_mod_ori(vecnoeud); |
746 |
|
|
xyz[0]=vecnoeud2.get_x(); |
747 |
|
|
xyz[1]=vecnoeud2.get_y(); |
748 |
|
|
xyz[2]=vecnoeud2.get_z(); |
749 |
|
|
} |
750 |
|
|
if (type==2) |
751 |
|
|
{ |
752 |
|
|
MG_SEGMENT* seg=(MG_SEGMENT*)elebase; |
753 |
|
|
OT_VECTEUR_3D vecnoeud1(seg->get_noeud1()->get_coord()); |
754 |
|
|
OT_VECTEUR_3D vecnoeud2(seg->get_noeud2()->get_coord()); |
755 |
|
|
OT_VECTEUR_3D vecnoeud=0.5*(vecnoeud1+vecnoeud2); |
756 |
|
|
OT_VECTEUR_3D vecnoeud3=rescmp.change_coord_mod_ori(vecnoeud); |
757 |
|
|
xyz[0]=vecnoeud3.get_x(); |
758 |
|
|
xyz[1]=vecnoeud3.get_y(); |
759 |
|
|
xyz[2]=vecnoeud3.get_z(); |
760 |
|
|
direction=vecnoeud2-vecnoeud1; |
761 |
|
|
distmin=direction.get_longueur()/2.; |
762 |
|
|
direction.norme(); |
763 |
|
|
} |
764 |
|
|
if (type==3) |
765 |
|
|
{ |
766 |
|
|
MG_TRIANGLE* tri=(MG_TRIANGLE*)elebase; |
767 |
|
|
OT_VECTEUR_3D vecnoeud1(tri->get_noeud1()->get_coord()); |
768 |
|
|
OT_VECTEUR_3D vecnoeud2(tri->get_noeud2()->get_coord()); |
769 |
|
|
OT_VECTEUR_3D vecnoeud3(tri->get_noeud3()->get_coord()); |
770 |
|
|
OT_VECTEUR_3D vecnoeud=0.3333333333333333*(vecnoeud1+vecnoeud2+vecnoeud3); |
771 |
|
|
OT_VECTEUR_3D vecnoeud4=rescmp.change_coord_mod_ori(vecnoeud); |
772 |
|
|
xyz[0]=vecnoeud4.get_x(); |
773 |
|
|
xyz[1]=vecnoeud4.get_y(); |
774 |
|
|
xyz[2]=vecnoeud4.get_z(); |
775 |
|
|
distmin=std::max((vecnoeud-vecnoeud1).get_longueur(),(vecnoeud-vecnoeud2).get_longueur()); |
776 |
|
|
distmin=std::max((vecnoeud-vecnoeud3).get_longueur(),distmin); |
777 |
|
|
direction=(vecnoeud3-vecnoeud1)&(vecnoeud2-vecnoeud1); |
778 |
|
|
direction.norme(); |
779 |
|
|
} |
780 |
|
|
TPL_MAP_ENTITE<MG_NOEUD*> lst; |
781 |
|
|
double Ea,Eb; |
782 |
|
|
if (type!=0) |
783 |
|
|
{ |
784 |
|
|
double m[9]; |
785 |
|
|
carteori->evaluer(xyz,m); |
786 |
|
|
Ea=1./sqrt(m[0]); |
787 |
|
|
} |
788 |
|
|
octree->rechercher(xyz[0],xyz[1],xyz[2],2*Ea,lst); |
789 |
|
|
double alpha=1.05; |
790 |
|
|
distmin=distmin*alpha; |
791 |
|
|
LISTE_MG_NOEUD::iterator it; |
792 |
|
|
for (MG_NOEUD* noeud=lst.get_premier(it);noeud!=NULL;noeud=lst.get_suivant(it)) |
793 |
|
|
{ |
794 |
|
|
double *xyztmp=noeud->get_coord(); |
795 |
|
|
OT_VECTEUR_3D vec(xyz,xyztmp); |
796 |
|
|
if (type!=0) |
797 |
|
|
{ |
798 |
|
|
double m[9]; |
799 |
|
|
carteori->evaluer(xyztmp,m); |
800 |
|
|
Eb=1./sqrt(m[0]); |
801 |
|
|
distance=std::max(1.5*Ea,1.5*Eb); |
802 |
|
|
distance=std::max(distance,2.6*fabs(Ea-Eb)); |
803 |
|
|
} |
804 |
|
|
if (type==2) |
805 |
|
|
{ |
806 |
|
|
double cosinus=vec*direction/vec.get_longueur(); |
807 |
|
|
double sinus=sqrt(1-cosinus*cosinus); |
808 |
|
|
double facteur; |
809 |
|
|
if (OPERATEUR::egal(cosinus,0.,0.000001)) facteur=distance; |
810 |
|
|
else |
811 |
|
|
{ |
812 |
|
|
double delta=sinus*sinus+4.*distance*distance/distmin/distmin*cosinus*cosinus; |
813 |
|
|
facteur=(-sinus+sqrt(delta))/2./distance/cosinus/cosinus*distmin*distmin; |
814 |
|
|
distance=facteur; |
815 |
|
|
} |
816 |
|
|
} |
817 |
|
|
if (type==3) |
818 |
|
|
{ |
819 |
|
|
double sinus=vec*direction/vec.get_longueur(); |
820 |
|
|
if (sinus>-0.0000001) |
821 |
|
|
{ |
822 |
|
|
double cosinus=sqrt(1-sinus*sinus); |
823 |
|
|
double facteur; |
824 |
|
|
if (OPERATEUR::egal(cosinus,0.,0.000001)) facteur=distance; |
825 |
|
|
else |
826 |
|
|
{ |
827 |
|
|
double delta=sinus*sinus+4*distance*distance/distmin/distmin*cosinus*cosinus; |
828 |
|
|
facteur=(-sinus+sqrt(delta))/2./distance/cosinus/cosinus*distmin*distmin; |
829 |
|
|
distance=facteur; |
830 |
|
|
} |
831 |
|
|
} |
832 |
|
|
|
833 |
|
|
} |
834 |
|
|
if (vec.get_longueur()<distance) |
835 |
|
|
{ |
836 |
|
|
noeud->change_nouveau_numero(DETRUIT); |
837 |
|
|
} |
838 |
|
|
|
839 |
|
|
} |
840 |
|
|
|
841 |
|
|
} |
842 |
|
|
|
843 |
|
|
|
844 |
|
|
/*void REMAILLEUR::cree_quadtree(MG_MAILLAGE* mai,TPL_QUADTREE<MG_SEGMENT_FRONTIERE*,MG_NOEUD*> **quad,TPL_MAP_ENTITE<MG_SEGMENT_FRONTIERE*> *lstsegfront) |
845 |
|
|
{ |
846 |
|
|
int nbface=mai->get_mg_geometrie()->get_nb_mg_face(); |
847 |
|
|
for (int i=0;i<nbface;i++) |
848 |
|
|
{ |
849 |
|
|
((quad[i]))=new TPL_QUADTREE<MG_SEGMENT_FRONTIERE*,MG_NOEUD*>; |
850 |
|
|
TPL_LISTE_ENTITE<MG_NOEUD*> lstn; |
851 |
|
|
double umax=-1e300; |
852 |
|
|
double vmax=-1e300; |
853 |
|
|
double umin=1e300; |
854 |
|
|
double vmin=1e300; |
855 |
|
|
MG_FACE* face=mai->get_mg_geometrie()->get_mg_face(i); |
856 |
|
|
int nbboucle=face->get_nb_mg_boucle(); |
857 |
|
|
int nbsegfravant=lstsegfront->get_nb(); |
858 |
|
|
for (int j=0;j<nbboucle;j++) |
859 |
|
|
{ |
860 |
|
|
MG_BOUCLE* bou=face->get_mg_boucle(j); |
861 |
|
|
int nbarete=bou->get_nb_mg_coarete(); |
862 |
|
|
for (int k=0;k<nbarete;k++) |
863 |
|
|
{ |
864 |
|
|
MG_ARETE* are=bou->get_mg_coarete(k)->get_arete(); |
865 |
|
|
int nbseg=are->get_lien_maillage()->get_nb(); |
866 |
|
|
for (int l=0;l<nbseg;l++) |
867 |
|
|
{ |
868 |
|
|
MG_SEGMENT* seg=(MG_SEGMENT*)are->get_lien_maillage()->get(l); |
869 |
|
|
if (mai->get_mg_segmentid(seg->get_id())==NULL) continue; |
870 |
|
|
double *xyz=seg->get_noeud1()->get_coord(); |
871 |
|
|
double uv[2]; |
872 |
|
|
face->inverser(uv,xyz); |
873 |
|
|
seg->get_noeud1()->change_u(uv[0]); |
874 |
|
|
seg->get_noeud1()->change_v(uv[1]); |
875 |
|
|
xyz=seg->get_noeud2()->get_coord(); |
876 |
|
|
face->inverser(uv,xyz); |
877 |
|
|
seg->get_noeud2()->change_u(uv[0]); |
878 |
|
|
seg->get_noeud2()->change_v(uv[1]); |
879 |
|
|
lstn.ajouter(seg->get_noeud2()); |
880 |
|
|
if (uv[0]<umin) umin=uv[0]; |
881 |
|
|
if (uv[0]>umax) umax=uv[0]; |
882 |
|
|
if (uv[1]<vmin) vmin=uv[1]; |
883 |
|
|
if (uv[1]>vmax) vmax=uv[1]; |
884 |
|
|
MG_SEGMENT_FRONTIERE* segfr=new MG_SEGMENT_FRONTIERE(seg); |
885 |
|
|
lstsegfront->ajouter(segfr); |
886 |
|
|
} |
887 |
|
|
} |
888 |
|
|
} |
889 |
|
|
double periodeenu=face->get_surface()->get_periode_u(); |
890 |
|
|
double periodeenv=face->get_surface()->get_periode_v(); |
891 |
|
|
if (periodeenu!=0.0) |
892 |
|
|
{ |
893 |
|
|
umin=0.; |
894 |
|
|
umax=periodeenu; |
895 |
|
|
} |
896 |
|
|
else |
897 |
|
|
{ |
898 |
|
|
double diff=umax-umin; |
899 |
|
|
umin=umin-0.125*diff; |
900 |
|
|
umax=umax+0.125*diff; |
901 |
|
|
} |
902 |
|
|
if (periodeenv!=0.0) |
903 |
|
|
{ |
904 |
|
|
vmin=0.; |
905 |
|
|
vmax=periodeenv; |
906 |
|
|
} |
907 |
|
|
else |
908 |
|
|
{ |
909 |
|
|
double diff=vmax-vmin; |
910 |
|
|
vmin=vmin-0.125*diff; |
911 |
|
|
vmax=vmax+0.125*diff; |
912 |
|
|
} |
913 |
|
|
(quad[i])->initialiser(&lstn,1,umin,vmin,umax,vmax,face->get_surface()->get_periode_u(),face->get_surface()->get_periode_v()); |
914 |
|
|
int nbsegfr=lstsegfront->get_nb(); |
915 |
|
|
for (int j=nbsegfravant;j<nbsegfr;j++) |
916 |
|
|
{ |
917 |
|
|
double *uv=lstsegfront->get(j)->get_uv1(); |
918 |
|
|
uv[0]=lstsegfront->get(j)->get_segment()->get_noeud1()->get_u(); |
919 |
|
|
uv[1]=lstsegfront->get(j)->get_segment()->get_noeud1()->get_v(); |
920 |
|
|
uv=lstsegfront->get(j)->get_uv2(); |
921 |
|
|
uv[0]=lstsegfront->get(j)->get_segment()->get_noeud2()->get_u(); |
922 |
|
|
uv[1]=lstsegfront->get(j)->get_segment()->get_noeud2()->get_v(); |
923 |
|
|
(quad[i])->inserer( lstsegfront->get(j)); |
924 |
|
|
} |
925 |
|
|
} |
926 |
|
|
|
927 |
|
|
} |
928 |
|
|
*/ |
929 |
|
|
void REMAILLEUR::cree_liste_frontiere(MG_MAILLAGE* mai) |
930 |
|
|
{ |
931 |
|
|
int nbvolume=mai->get_mg_geometrie()->get_nb_mg_volume(); |
932 |
|
|
for (int i=0;i<nbvolume;i++) |
933 |
|
|
{ |
934 |
|
|
MG_VOLUME* vol=mai->get_mg_geometrie()->get_mg_volume(i); |
935 |
|
|
int nbco=vol->get_nb_mg_coquille(); |
936 |
|
|
for (int j=0;j<nbco;j++) |
937 |
|
|
{ |
938 |
|
|
MG_COQUILLE* coq=vol->get_mg_coquille(j); |
939 |
|
|
int nbface=coq->get_nb_mg_coface(); |
940 |
|
|
for (int k=0;k<nbface;k++) |
941 |
|
|
{ |
942 |
|
|
MG_FACE* face=coq->get_mg_coface(k)->get_face(); |
943 |
|
|
int nbseg=face->get_lien_maillage()->get_nb(); |
944 |
|
|
for (int l=0;l<nbseg;l++) |
945 |
|
|
{ |
946 |
|
|
MG_TRIANGLE* tri=(MG_TRIANGLE*)face->get_lien_maillage()->get(l); |
947 |
|
|
if (mai->get_mg_triangleid(tri->get_id())==NULL) continue; |
948 |
|
|
lsttrifront[i].ajouter(tri); |
949 |
|
|
} |
950 |
|
|
} |
951 |
|
|
} |
952 |
|
|
|
953 |
|
|
|
954 |
|
|
} |
955 |
|
|
} |
956 |
|
|
|
957 |
|
|
|
958 |
|
|
|
959 |
|
|
void REMAILLEUR::ajouter_liste_correspondance_noeud(MG_NOEUD* n1,MG_NOEUD* n2) |
960 |
|
|
{ |
961 |
|
|
CORRESPONDANCENOEUD corr(n1,n2); |
962 |
|
|
pair<unsigned long,CORRESPONDANCENOEUD> tmp(n1->get_id(),corr); |
963 |
|
|
lstcorrnoeud.insert(tmp); |
964 |
|
|
} |
965 |
|
|
|
966 |
|
|
MG_NOEUD* REMAILLEUR::get_liste_correspondance(MG_NOEUD* n1) |
967 |
|
|
{ |
968 |
|
|
MG_NOEUD *n2=NULL; |
969 |
|
|
std::map<unsigned long,CORRESPONDANCENOEUD,std::less<unsigned long> >::iterator j=lstcorrnoeud.find(n1->get_id()); |
970 |
|
|
if (j!=lstcorrnoeud.end()) |
971 |
|
|
n2=(*j).second.noeudmod; |
972 |
|
|
return n2; |
973 |
|
|
} |
974 |
|
|
|
975 |
|
|
|
976 |
|
|
MG_NOEUD* REMAILLEUR::transfert_noeud(MG_NOEUD* no,MG_ELEMENT_TOPOLOGIQUE* ele) |
977 |
|
|
{ |
978 |
|
|
double *xyz=no->get_coord(); |
979 |
|
|
OT_VECTEUR_3D pt(xyz); |
980 |
|
|
OT_VECTEUR_3D nvpt=rescmp.change_coord_ori_mod(pt); |
981 |
|
|
MG_NOEUD* noeud=new MG_NOEUD(ele,nvpt.get_x(),nvpt.get_y(),nvpt.get_z(),IMPOSE); |
982 |
|
|
maimodifie->ajouter_mg_noeud(noeud); |
983 |
|
|
ajouter_liste_correspondance_noeud(no,noeud); |
984 |
|
|
noeud->change_nouveau_numero(no->get_id()); |
985 |
|
|
return noeud; |
986 |
|
|
} |
987 |
|
|
|
988 |
|
|
void REMAILLEUR::transfert_coord(double *xyz,double *xyz2) |
989 |
|
|
{ |
990 |
|
|
OT_VECTEUR_3D pt(xyz); |
991 |
|
|
OT_VECTEUR_3D nvpt=rescmp.change_coord_ori_mod(pt); |
992 |
|
|
xyz2[0]=nvpt.get_x(); |
993 |
|
|
xyz2[1]=nvpt.get_y(); |
994 |
|
|
xyz2[2]=nvpt.get_z(); |
995 |
|
|
return; |
996 |
|
|
} |
997 |
|
|
|
998 |
|
|
void REMAILLEUR::cree_bloc_maille(multimap<unsigned long,MG_SEGMENT*,less <unsigned long> > &lst,MG_ARETE* arete) |
999 |
|
|
{ |
1000 |
|
|
while (lst.size()>0) |
1001 |
|
|
{ |
1002 |
|
|
multimap<unsigned long,MG_SEGMENT*,less <unsigned long> >::iterator it=lst.begin(); |
1003 |
|
|
MG_SEGMENT* seg=(*it).second; |
1004 |
|
|
lst.erase(it); |
1005 |
|
|
TPL_LISTE_ENTITE<double> param; |
1006 |
|
|
BLOC_MAILLE_1D *b1d=new BLOC_MAILLE_1D(arete,arete->get_courbe()->get_type_geometrique(param)); |
1007 |
|
|
pair<unsigned long,BLOC_MAILLE_1D*> tmp(b1d->get_id(),b1d); |
1008 |
|
|
lstb1d.insert(tmp); |
1009 |
|
|
b1d->lst.push_back(seg); |
1010 |
|
|
seg->change_nouveau_numero(TRAITE); |
1011 |
|
|
char mess[255]; |
1012 |
|
|
sprintf(mess," Arete %lu , Bloc %d",arete->get_id(),lstb1d.size()); |
1013 |
|
|
//affiche(mess); |
1014 |
|
|
int num=0; |
1015 |
|
|
while (num!=b1d->lst.size()) |
1016 |
|
|
{ |
1017 |
|
|
MG_SEGMENT* itseg=b1d->lst[num++]; |
1018 |
|
|
MG_SEGMENT* seg=trouve_segment(lst,itseg->get_noeud1()); |
1019 |
|
|
while (seg!=NULL) |
1020 |
|
|
{ |
1021 |
|
|
if (seg->get_nouveau_numero()==NONTRAITE) |
1022 |
|
|
{ |
1023 |
|
|
b1d->lst.push_back(seg); |
1024 |
|
|
seg->change_nouveau_numero(TRAITE); |
1025 |
|
|
} |
1026 |
|
|
seg=trouve_segment(lst,itseg->get_noeud1()); |
1027 |
|
|
} |
1028 |
|
|
seg=trouve_segment(lst,itseg->get_noeud2()); |
1029 |
|
|
while (seg!=NULL) |
1030 |
|
|
{ |
1031 |
|
|
if (seg->get_nouveau_numero()==NONTRAITE) |
1032 |
|
|
{ |
1033 |
|
|
b1d->lst.push_back(seg); |
1034 |
|
|
seg->change_nouveau_numero(TRAITE); |
1035 |
|
|
} |
1036 |
|
|
seg=trouve_segment(lst,itseg->get_noeud2()); |
1037 |
|
|
} |
1038 |
|
|
} |
1039 |
|
|
|
1040 |
|
|
sprintf(mess," Segment %d ",b1d->lst.size()); |
1041 |
|
|
//affiche(mess); |
1042 |
|
|
} |
1043 |
|
|
} |
1044 |
|
|
|
1045 |
|
|
void REMAILLEUR::cree_bloc_maille(multimap<unsigned long,MG_TRIANGLE*,less <unsigned long> > &lst,MG_FACE* face) |
1046 |
|
|
{ |
1047 |
|
|
while (lst.size()>0) |
1048 |
|
|
{ |
1049 |
|
|
multimap<unsigned long,MG_TRIANGLE*,less <unsigned long> >::iterator it=lst.begin(); |
1050 |
|
|
MG_TRIANGLE* tri=(*it).second; |
1051 |
|
|
lst.erase(it); |
1052 |
|
|
TPL_LISTE_ENTITE<double> param; |
1053 |
|
|
BLOC_MAILLE_2D *b2d=new BLOC_MAILLE_2D(geoorigine->get_mg_faceid(face->get_id()),face->get_surface()->get_type_geometrique(param)); |
1054 |
|
|
pair<unsigned long,BLOC_MAILLE_2D*> tmp(b2d->get_id(),b2d); |
1055 |
|
|
lstb2d.insert(tmp); |
1056 |
|
|
b2d->lst.push_back(tri); |
1057 |
|
|
tri->change_nouveau_numero(TRAITE); |
1058 |
|
|
char mess[255]; |
1059 |
|
|
sprintf(mess," Face %lu , Bloc %d",face->get_id(),lstb2d.size()); |
1060 |
|
|
//affiche(mess); |
1061 |
|
|
int num=0; |
1062 |
|
|
while (num!=b2d->lst.size()) |
1063 |
|
|
{ |
1064 |
|
|
MG_TRIANGLE* ittri=b2d->lst[num++]; |
1065 |
|
|
MG_TRIANGLE* tri=trouve_triangle(lst,ittri->get_noeud1()); |
1066 |
|
|
while (tri!=NULL) |
1067 |
|
|
{ |
1068 |
|
|
if (tri->get_nouveau_numero()==NONTRAITE) |
1069 |
|
|
{ |
1070 |
|
|
b2d->lst.push_back(tri); |
1071 |
|
|
tri->change_nouveau_numero(TRAITE); |
1072 |
|
|
} |
1073 |
|
|
tri=trouve_triangle(lst,ittri->get_noeud1()); |
1074 |
|
|
} |
1075 |
|
|
tri=trouve_triangle(lst,ittri->get_noeud2()); |
1076 |
|
|
while (tri!=NULL) |
1077 |
|
|
{ |
1078 |
|
|
if (tri->get_nouveau_numero()==NONTRAITE) |
1079 |
|
|
{ |
1080 |
|
|
b2d->lst.push_back(tri); |
1081 |
|
|
tri->change_nouveau_numero(TRAITE); |
1082 |
|
|
} |
1083 |
|
|
tri=trouve_triangle(lst,ittri->get_noeud2()); |
1084 |
|
|
} |
1085 |
|
|
tri=trouve_triangle(lst,ittri->get_noeud3()); |
1086 |
|
|
while (tri!=NULL) |
1087 |
|
|
{ |
1088 |
|
|
if (tri->get_nouveau_numero()==NONTRAITE) |
1089 |
|
|
{ |
1090 |
|
|
b2d->lst.push_back(tri); |
1091 |
|
|
tri->change_nouveau_numero(TRAITE); |
1092 |
|
|
} |
1093 |
|
|
tri=trouve_triangle(lst,ittri->get_noeud3()); |
1094 |
|
|
} |
1095 |
|
|
} |
1096 |
|
|
|
1097 |
|
|
sprintf(mess," Triangle %d ",b2d->lst.size()); |
1098 |
|
|
//affiche(mess); |
1099 |
|
|
} |
1100 |
|
|
} |
1101 |
|
|
|
1102 |
|
|
void REMAILLEUR::cree_bloc_maille(multimap<unsigned long,MG_TETRA*,less <unsigned long> > &lst,MG_VOLUME* vol) |
1103 |
|
|
{ |
1104 |
|
|
while (lst.size()>0) |
1105 |
|
|
{ |
1106 |
|
|
multimap<unsigned long,MG_TETRA*,less <unsigned long> >::iterator it=lst.begin(); |
1107 |
|
|
MG_TETRA* tet=(*it).second; |
1108 |
|
|
lst.erase(it); |
1109 |
|
|
BLOC_MAILLE_3D *b3d=new BLOC_MAILLE_3D(geoorigine->get_mg_volumeid(vol->get_id())); |
1110 |
|
|
pair<unsigned long,BLOC_MAILLE_3D*> tmp(b3d->get_id(),b3d); |
1111 |
|
|
lstb3d.insert(tmp); |
1112 |
|
|
b3d->lst.push_back(tet); |
1113 |
|
|
tet->change_nouveau_numero(TRAITE); |
1114 |
|
|
char mess[255]; |
1115 |
|
|
sprintf(mess," Volume %lu , Bloc %d",vol->get_id(),lstb3d.size()); |
1116 |
|
|
//affiche(mess); |
1117 |
|
|
int num=0; |
1118 |
|
|
while (num!=b3d->lst.size()) |
1119 |
|
|
{ |
1120 |
|
|
MG_TETRA* ittet=b3d->lst[num++]; |
1121 |
|
|
MG_TETRA* tet=trouve_tetra(lst,ittet->get_noeud1()); |
1122 |
|
|
while (tet!=NULL) |
1123 |
|
|
{ |
1124 |
|
|
if (tet->get_nouveau_numero()==NONTRAITE) |
1125 |
|
|
{ |
1126 |
|
|
b3d->lst.push_back(tet); |
1127 |
|
|
tet->change_nouveau_numero(TRAITE); |
1128 |
|
|
} |
1129 |
|
|
tet=trouve_tetra(lst,ittet->get_noeud1()); |
1130 |
|
|
} |
1131 |
|
|
tet=trouve_tetra(lst,ittet->get_noeud2()); |
1132 |
|
|
while (tet!=NULL) |
1133 |
|
|
{ |
1134 |
|
|
if (tet->get_nouveau_numero()==NONTRAITE) |
1135 |
|
|
{ |
1136 |
|
|
b3d->lst.push_back(tet); |
1137 |
|
|
tet->change_nouveau_numero(TRAITE); |
1138 |
|
|
} |
1139 |
|
|
tet=trouve_tetra(lst,ittet->get_noeud2()); |
1140 |
|
|
} |
1141 |
|
|
tet=trouve_tetra(lst,ittet->get_noeud3()); |
1142 |
|
|
while (tet!=NULL) |
1143 |
|
|
{ |
1144 |
|
|
if (tet->get_nouveau_numero()==NONTRAITE) |
1145 |
|
|
{ |
1146 |
|
|
b3d->lst.push_back(tet); |
1147 |
|
|
tet->change_nouveau_numero(TRAITE); |
1148 |
|
|
} |
1149 |
|
|
tet=trouve_tetra(lst,ittet->get_noeud3()); |
1150 |
|
|
} |
1151 |
|
|
tet=trouve_tetra(lst,ittet->get_noeud4()); |
1152 |
|
|
while (tet!=NULL) |
1153 |
|
|
{ |
1154 |
|
|
if (tet->get_nouveau_numero()==NONTRAITE) |
1155 |
|
|
{ |
1156 |
|
|
b3d->lst.push_back(tet); |
1157 |
|
|
tet->change_nouveau_numero(TRAITE); |
1158 |
|
|
} |
1159 |
|
|
tet=trouve_tetra(lst,ittet->get_noeud4()); |
1160 |
|
|
} |
1161 |
|
|
} |
1162 |
|
|
|
1163 |
|
|
sprintf(mess," Tetra %d ",b3d->lst.size()); |
1164 |
|
|
//affiche(mess); |
1165 |
|
|
} |
1166 |
|
|
} |
1167 |
|
|
|
1168 |
|
|
|
1169 |
|
|
MG_SEGMENT* REMAILLEUR::trouve_segment(multimap<unsigned long,MG_SEGMENT*,less <unsigned long> > &lst,MG_NOEUD* no) |
1170 |
|
|
{ |
1171 |
|
|
MG_SEGMENT* seg=NULL; |
1172 |
|
|
unsigned long id=no->get_id(); |
1173 |
|
|
multimap<unsigned long,MG_SEGMENT*,less <unsigned long> >::iterator it=lst.find(id); |
1174 |
|
|
if (it!=lst.end()) |
1175 |
|
|
{ |
1176 |
|
|
seg=(*it).second; |
1177 |
|
|
lst.erase(it); |
1178 |
|
|
} |
1179 |
|
|
return seg; |
1180 |
|
|
} |
1181 |
|
|
|
1182 |
|
|
MG_TRIANGLE* REMAILLEUR::trouve_triangle(multimap<unsigned long,MG_TRIANGLE*,less <unsigned long> > &lst,MG_NOEUD* no) |
1183 |
|
|
{ |
1184 |
|
|
MG_TRIANGLE* tri=NULL; |
1185 |
|
|
unsigned long id=no->get_id(); |
1186 |
|
|
multimap<unsigned long,MG_TRIANGLE*,less <unsigned long> >::iterator it=lst.find(id); |
1187 |
|
|
if (it!=lst.end()) |
1188 |
|
|
{ |
1189 |
|
|
tri=(*it).second; |
1190 |
|
|
lst.erase(it); |
1191 |
|
|
} |
1192 |
|
|
return tri; |
1193 |
|
|
} |
1194 |
|
|
|
1195 |
|
|
MG_TETRA* REMAILLEUR::trouve_tetra(multimap<unsigned long,MG_TETRA*,less <unsigned long> > &lst,MG_NOEUD* no) |
1196 |
|
|
{ |
1197 |
|
|
MG_TETRA* tet=NULL; |
1198 |
|
|
unsigned long id=no->get_id(); |
1199 |
|
|
multimap<unsigned long,MG_TETRA*,less <unsigned long> >::iterator it=lst.find(id); |
1200 |
|
|
if (it!=lst.end()) |
1201 |
|
|
{ |
1202 |
|
|
tet=(*it).second; |
1203 |
|
|
lst.erase(it); |
1204 |
|
|
} |
1205 |
|
|
return tet; |
1206 |
|
|
} |
1207 |
|
|
|
1208 |
|
|
int REMAILLEUR::point_appartient_volume(double *xyz,int numvol) |
1209 |
|
|
{ |
1210 |
|
|
int ok=0; |
1211 |
|
|
int i=0; |
1212 |
|
|
multimap<double,double,less<double> > intersection; |
1213 |
|
|
OT_VECTEUR_3D vecteur_dir; |
1214 |
|
|
while (ok==0) |
1215 |
|
|
|
1216 |
|
|
{ |
1217 |
|
|
int ok2=0; |
1218 |
|
|
while (ok2==0) |
1219 |
|
|
{ |
1220 |
|
|
MG_TRIANGLE* tri=lsttrifront[numvol].get(i); |
1221 |
|
|
MG_NOEUD* no1=tri->get_noeud1(); |
1222 |
|
|
MG_NOEUD* no2=tri->get_noeud2(); |
1223 |
|
|
MG_NOEUD* no3=tri->get_noeud3(); |
1224 |
|
|
double xb=(no1->get_x()+no2->get_x()+no3->get_x())/3.; |
1225 |
|
|
double yb=(no1->get_y()+no2->get_y()+no3->get_y())/3.; |
1226 |
|
|
double zb=(no1->get_z()+no2->get_z()+no3->get_z())/3.; |
1227 |
|
|
OT_VECTEUR_3D directeur(xb-xyz[0],yb-xyz[1],zb-xyz[2]); |
1228 |
|
|
directeur.norme(); |
1229 |
|
|
vecteur_dir=directeur; |
1230 |
|
|
OT_VECTEUR_3D n1n3(no1->get_coord(),no3->get_coord()); |
1231 |
|
|
OT_VECTEUR_3D n1n2(no1->get_coord(),no2->get_coord()); |
1232 |
|
|
OT_VECTEUR_3D n=n1n3&n1n2; |
1233 |
|
|
n.norme(); |
1234 |
|
|
double ps1=n*directeur; |
1235 |
|
|
if (fabs(ps1)<1e-6) i++; |
1236 |
|
|
else ok2=1; |
1237 |
|
|
} |
1238 |
|
|
ok2=0; |
1239 |
|
|
intersection.clear(); |
1240 |
|
|
for (int j=0;j<lsttrifront[numvol].get_nb();j++) |
1241 |
|
|
{ |
1242 |
|
|
MG_TRIANGLE* tri=lsttrifront[numvol].get(j); |
1243 |
|
|
|
1244 |
|
|
double t; |
1245 |
|
|
int res=inter_droite_triangle(xyz,vecteur_dir,tri,&t); |
1246 |
|
|
if (res==2) { |
1247 |
|
|
ok2=1; |
1248 |
|
|
break; |
1249 |
|
|
} |
1250 |
|
|
if (res==1) |
1251 |
|
|
{ |
1252 |
|
|
pair<double,double> tmp(t,t); |
1253 |
|
|
intersection.insert(tmp); |
1254 |
|
|
} |
1255 |
|
|
} |
1256 |
|
|
if (ok2==0) ok=1; |
1257 |
|
|
i++; |
1258 |
|
|
|
1259 |
|
|
} |
1260 |
|
|
multimap<double,double,less <double> >::iterator it=intersection.begin(); |
1261 |
|
|
int nbinterneg=0; |
1262 |
|
|
double tavant=1e308; |
1263 |
|
|
while (it!=intersection.end()) |
1264 |
|
|
{ |
1265 |
|
|
if ((*it).second<0.) |
1266 |
|
|
{ |
1267 |
|
|
double t=(*it).second; |
1268 |
|
|
if (!(OPERATEUR::egal(t,tavant,1e-6))) |
1269 |
|
|
nbinterneg++; |
1270 |
|
|
tavant=t; |
1271 |
|
|
} |
1272 |
|
|
it++; |
1273 |
|
|
} |
1274 |
|
|
if (nbinterneg%2==1) return 1; |
1275 |
|
|
return 0; |
1276 |
|
|
} |
1277 |
|
|
|
1278 |
|
|
|
1279 |
|
|
int REMAILLEUR::inter_droite_triangle(double *xyz,double *dir,MG_TRIANGLE* tri,double *t) |
1280 |
|
|
{ |
1281 |
|
|
int inter=0; |
1282 |
|
|
MG_NOEUD *noeud1=tri->get_noeud1(); |
1283 |
|
|
MG_NOEUD *noeud2=tri->get_noeud2(); |
1284 |
|
|
MG_NOEUD *noeud3=tri->get_noeud3(); |
1285 |
|
|
OT_VECTEUR_3D g1(noeud2->get_x()-noeud1->get_x(),noeud2->get_y()-noeud1->get_y(),noeud2->get_z()-noeud1->get_z()); |
1286 |
|
|
OT_VECTEUR_3D g2(noeud3->get_x()-noeud1->get_x(),noeud3->get_y()-noeud1->get_y(),noeud3->get_z()-noeud1->get_z()); |
1287 |
|
|
OT_VECTEUR_3D g3(dir); |
1288 |
|
|
OT_MATRICE_3D systeme(g1,g2,g3); |
1289 |
|
|
double det=systeme.get_determinant(); |
1290 |
|
|
double eps=0.333333333333*(g1.diff()+g2.diff()+g3.diff()); |
1291 |
|
|
eps=eps*eps*0.0018; |
1292 |
|
|
if (OPERATEUR::egal(det,0.0,eps)==true) |
1293 |
|
|
{ |
1294 |
|
|
OT_VECTEUR_3D g3b(xyz[0]-noeud1->get_x(),xyz[1]-noeud1->get_y(),xyz[2]-noeud1->get_z()); |
1295 |
|
|
OT_MATRICE_3D systeme2(g1,g2,g3b); |
1296 |
|
|
double det2=systeme2.get_determinant(); |
1297 |
|
|
double eps2=0.333333333333*(g1.diff()+g2.diff()+g3b.diff()); |
1298 |
|
|
eps2=18.*eps2*eps2*eps2*1e-6; |
1299 |
|
|
if (OPERATEUR::egal(det2,0.0,eps)==true) // cas 2D |
1300 |
|
|
{ |
1301 |
|
|
return 2; |
1302 |
|
|
} |
1303 |
|
|
else return 0; |
1304 |
|
|
} |
1305 |
|
|
else |
1306 |
|
|
{ |
1307 |
|
|
double x,y,z; |
1308 |
|
|
x=1.0/det*(g2.get_y()*g3.get_z()-g2.get_z()*g3.get_y()); |
1309 |
|
|
y=1.0/det*(g3.get_x()*g2.get_z()-g2.get_x()*g3.get_z()); |
1310 |
|
|
z=1.0/det*(g2.get_x()*g3.get_y()-g2.get_y()*g3.get_x()); |
1311 |
|
|
OT_VECTEUR_3D g1b(x,y,z); |
1312 |
|
|
x=1.0/det*(g3.get_y()*g1.get_z()-g1.get_y()*g3.get_z()); |
1313 |
|
|
y=1.0/det*(g1.get_x()*g3.get_z()-g3.get_x()*g1.get_z()); |
1314 |
|
|
z=1.0/det*(g3.get_x()*g1.get_y()-g1.get_x()*g3.get_y()); |
1315 |
|
|
OT_VECTEUR_3D g2b(x,y,z); |
1316 |
|
|
x=1.0/det*(g1.get_y()*g2.get_z()-g1.get_z()*g2.get_y()); |
1317 |
|
|
y=1.0/det*(g2.get_x()*g1.get_z()-g1.get_x()*g2.get_z()); |
1318 |
|
|
z=1.0/det*(g1.get_x()*g2.get_y()-g1.get_y()*g2.get_x()); |
1319 |
|
|
OT_VECTEUR_3D g3b(x,y,z); |
1320 |
|
|
OT_VECTEUR_3D n1n4(xyz[0]-noeud1->get_x(),xyz[1]-noeud1->get_y(),xyz[2]-noeud1->get_z()); |
1321 |
|
|
double alpha1=n1n4*g1b; |
1322 |
|
|
double alpha2=n1n4*g2b; |
1323 |
|
|
double alpha3=-(n1n4*g3b); |
1324 |
|
|
double alpha4=1-alpha1-alpha2; |
1325 |
|
|
double eps=0.000001; |
1326 |
|
|
if ((alpha1>-eps) && (alpha1<1.+eps)) |
1327 |
|
|
if ((alpha2>-eps) && (alpha2<1.+eps)) |
1328 |
|
|
if ((alpha4>-eps) && (alpha4<1.+eps)) { |
1329 |
|
|
*t=alpha3; |
1330 |
|
|
return 1; |
1331 |
|
|
} |
1332 |
|
|
return 0; |
1333 |
|
|
} |
1334 |
|
|
|
1335 |
|
|
} |