ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/reconstruction/src/rec_brep.cpp
Revision: 740
Committed: Wed Sep 30 22:24:50 2015 UTC (9 years, 7 months ago) by couturad
File size: 23876 byte(s)
Log Message:
Ajout d'assemblage dans un arbre caractéristique
Modification de la gestion des id de occ avec retro-compatibilité
script adaptable au assemblage

File Contents

# User Rev Content
1 5 //---------------------------------------------------------------------------
2     #include "gestionversion.h"
3    
4     #pragma hdrstop
5    
6 francois 481 #include "occ_fonction.h"
7     #include "rec_brep.h"
8 5 #include "ot_mathematique.h"
9 francois 481 #include "rec_face_nurbs.h"
10 5 #include "fem_maillage.h"
11     #include "tpl_map_entite.h"
12     #include "math.h"
13     #include "constantegeo.h"
14     //---------------------------------------------------------------------------
15    
16     #pragma package(smart_init)
17    
18    
19 couturad 740 REC_BREP::REC_BREP(FEM_MAILLAGE* fem_mai, int Idealise, OCC_FONCTION_RECONSTRUCTION& fonc):fem_maillage(fem_mai), Idealiser(Idealise), fonction(fonc)
20 5 {
21    
22     }
23    
24     REC_BREP::~REC_BREP()
25     {
26    
27     }
28    
29 louhichi 211 void REC_BREP::Reconstruire(double coef)
30 5 {
31    
32 louhichi 211
33 5 fonction.Creer_Coquille();
34 louhichi 211 MG_GEOMETRIE* mggeo = fem_maillage->get_mg_geometrie();
35 5 int nb_face = mggeo->get_nb_mg_face();
36     int test = 0;
37    
38     int *faces=new int[nb_face];
39     for (int i =0; i<nb_face;i++)
40     {
41     faces[i] = 0;
42     }
43    
44    
45    
46    
47     if(Idealiser == 0)
48     {
49     for (int i =0; i<nb_face;i++)
50     {
51     MG_FACE* face = mggeo->get_mg_face(i);
52 louhichi 211 REC_FACE Reconst(fem_maillage, Idealiser, fonction, test, faces);
53     Reconst.Reconstruire(face, coef);
54 5 fonction.Ajouter_face_Coquille();
55     }
56     }
57    
58    
59    
60    
61     else
62     {
63    
64    
65     for (int i =0; i<nb_face;i++)
66     {
67    
68     MG_FACE* face = mggeo->get_mg_face(i);
69    
70     test = 1;
71    
72     MG_SURFACE* surface = face->get_surface();
73     TPL_LISTE_ENTITE <double> Parametres;
74     int type_surface = surface->get_type_geometrique(Parametres);
75    
76     double changement_volume = 0.0;
77    
78     int nb_triangle = face->get_lien_fem_maillage()->get_nb();
79     TPL_MAP_ENTITE<FEM_NOEUD*> liste_noeuds0;
80     for (int j =0; j<nb_triangle;j++)
81     {
82 francois 309 FEM_ELEMENT2* mgtri=(FEM_ELEMENT2*)face->get_lien_fem_maillage()->get(j);
83 louhichi 211 if (!fem_maillage->contient(mgtri)) continue;
84 5 if (mgtri->get_nb_fem_noeud()==3)
85     {
86     FEM_NOEUD* noeud0=mgtri->get_fem_noeud(0);
87     FEM_NOEUD* noeud1=mgtri->get_fem_noeud(1);
88     FEM_NOEUD* noeud2=mgtri->get_fem_noeud(2);
89     liste_noeuds0.ajouter(noeud0);
90     liste_noeuds0.ajouter(noeud1);
91     liste_noeuds0.ajouter(noeud2);
92     }
93     if (mgtri->get_nb_fem_noeud()==6)
94     {
95     FEM_NOEUD* noeud0=mgtri->get_fem_noeud(0);
96     FEM_NOEUD* noeud1=mgtri->get_fem_noeud(1);
97     FEM_NOEUD* noeud2=mgtri->get_fem_noeud(2);
98     FEM_NOEUD* noeud3=mgtri->get_fem_noeud(3);
99     FEM_NOEUD* noeud4=mgtri->get_fem_noeud(4);
100     FEM_NOEUD* noeud5=mgtri->get_fem_noeud(5);
101     liste_noeuds0.ajouter(noeud0);
102     liste_noeuds0.ajouter(noeud1);
103     liste_noeuds0.ajouter(noeud2);
104     liste_noeuds0.ajouter(noeud3);
105     liste_noeuds0.ajouter(noeud4);
106     liste_noeuds0.ajouter(noeud5);
107     }
108     }
109    
110     if(type_surface != MGCo_PLAN)
111     {
112     for (int k =0; k < liste_noeuds0.get_nb();k++)
113     {
114     FEM_NOEUD* noeud=liste_noeuds0.get(k);
115     fonction.Ajouter_Point_Array_Ideal(noeud->get_x(),noeud->get_y(),noeud->get_z(),k+1);
116     }
117     fonction.Determiner_Param_Boite(liste_noeuds0.get_nb());
118    
119     double x0 = fonction.Get_Param_Boite(1);
120     double y0 = fonction.Get_Param_Boite(2);
121     double z0 = fonction.Get_Param_Boite(3);
122    
123     OT_VECTEUR_3D Vect_Boite01 (fonction.Get_Param_Boite(4),fonction.Get_Param_Boite(5),fonction.Get_Param_Boite(6));
124     OT_VECTEUR_3D Vect_Boite02 (fonction.Get_Param_Boite(7),fonction.Get_Param_Boite(8),fonction.Get_Param_Boite(9));
125     OT_VECTEUR_3D Vect_Boite03 (fonction.Get_Param_Boite(10),fonction.Get_Param_Boite(11),fonction.Get_Param_Boite(12));
126    
127     double volume_boite0 = Vect_Boite01.get_longueur()* Vect_Boite02.get_longueur()* Vect_Boite03.get_longueur();
128    
129    
130    
131     TPL_MAP_ENTITE<FEM_NOEUD*> liste_noeuds1;
132    
133     for (int j =0; j<nb_triangle;j++)
134     {
135 francois 309 FEM_ELEMENT2* mgtri=(FEM_ELEMENT2*)face->get_lien_fem_maillage()->get(j);
136 louhichi 211 if (!fem_maillage->contient(mgtri)) continue;
137 5 if (mgtri->get_nb_fem_noeud()==3)
138     {
139     FEM_NOEUD* noeud0=mgtri->get_fem_noeud(0);
140     FEM_NOEUD* noeud1=mgtri->get_fem_noeud(1);
141     FEM_NOEUD* noeud2=mgtri->get_fem_noeud(2);
142     liste_noeuds1.ajouter(noeud0);
143     liste_noeuds1.ajouter(noeud1);
144     liste_noeuds1.ajouter(noeud2);
145     }
146     if (mgtri->get_nb_fem_noeud()==6)
147     {
148     FEM_NOEUD* noeud0=mgtri->get_fem_noeud(0);
149     FEM_NOEUD* noeud1=mgtri->get_fem_noeud(1);
150     FEM_NOEUD* noeud2=mgtri->get_fem_noeud(2);
151     FEM_NOEUD* noeud3=mgtri->get_fem_noeud(3);
152     FEM_NOEUD* noeud4=mgtri->get_fem_noeud(4);
153     FEM_NOEUD* noeud5=mgtri->get_fem_noeud(5);
154     liste_noeuds1.ajouter(noeud0);
155     liste_noeuds1.ajouter(noeud1);
156     liste_noeuds1.ajouter(noeud2);
157     liste_noeuds1.ajouter(noeud3);
158     liste_noeuds1.ajouter(noeud4);
159     liste_noeuds1.ajouter(noeud5);
160     }
161     }
162    
163     for (int k =0; k < liste_noeuds0.get_nb();k++)
164     {
165     FEM_NOEUD* noeud=liste_noeuds1.get(k);
166 louhichi 211 fonction.Ajouter_Point_Array_Ideal(noeud->get_x(coef),noeud->get_y(coef),noeud->get_z(coef),k+1);
167 5 }
168     fonction.Determiner_Param_Boite(liste_noeuds0.get_nb());
169    
170     double x1 = fonction.Get_Param_Boite(1);
171     double y1 = fonction.Get_Param_Boite(2);
172     double z1 = fonction.Get_Param_Boite(3);
173    
174     OT_VECTEUR_3D Vect_Boite11 (fonction.Get_Param_Boite(4),fonction.Get_Param_Boite(5),fonction.Get_Param_Boite(6));
175     OT_VECTEUR_3D Vect_Boite12 (fonction.Get_Param_Boite(7),fonction.Get_Param_Boite(8),fonction.Get_Param_Boite(9));
176     OT_VECTEUR_3D Vect_Boite13 (fonction.Get_Param_Boite(10),fonction.Get_Param_Boite(11),fonction.Get_Param_Boite(12));
177    
178     double volume_boite1 = Vect_Boite11.get_longueur()* Vect_Boite12.get_longueur()* Vect_Boite13.get_longueur();
179    
180     changement_volume = ((volume_boite1-volume_boite0)/volume_boite0);
181    
182     }
183    
184    
185     double xmin = 1e308, ymin = 1e308, zmin = 1e308;
186     double xmax = -1e308, ymax = -1e308, zmax = -1e308;
187    
188     for (int k =0; k < liste_noeuds0.get_nb();k++)
189     {
190     FEM_NOEUD* noeud=liste_noeuds0.get(k);
191     double* xyz=noeud->get_coord();
192     if (xyz[0]>xmax) xmax=xyz[0];
193     if (xyz[0]<xmin) xmin=xyz[0];
194     if (xyz[1]>ymax) ymax=xyz[1];
195     if (xyz[1]<ymin) ymin=xyz[1];
196     if (xyz[2]>zmax) zmax=xyz[2];
197     if (xyz[2]<zmin) zmin=xyz[2];
198     }
199    
200    
201     double erreur_idealisation = OT_VECTEUR_3D(xmax-xmin,ymax-ymin,zmax-zmin).get_longueur()/1000.0;
202 francois 38 double Epsilon = OT_VECTEUR_3D(xmax-xmin,ymax-ymin,zmax-zmin).get_longueur()/10.0;
203 5
204     if(type_surface == MGCo_PLAN)
205     {
206     TPL_MAP_ENTITE<FEM_NOEUD*> liste_noeuds1;
207    
208     for (int j =0; j<nb_triangle;j++)
209     {
210 francois 309 FEM_ELEMENT2* mgtri=(FEM_ELEMENT2*)face->get_lien_fem_maillage()->get(j);
211 louhichi 211 if (!fem_maillage->contient(mgtri)) continue;
212 5 if (mgtri->get_nb_fem_noeud()==3)
213     {
214     FEM_NOEUD* noeud0=mgtri->get_fem_noeud(0);
215     FEM_NOEUD* noeud1=mgtri->get_fem_noeud(1);
216     FEM_NOEUD* noeud2=mgtri->get_fem_noeud(2);
217     liste_noeuds1.ajouter(noeud0);
218     liste_noeuds1.ajouter(noeud1);
219     liste_noeuds1.ajouter(noeud2);
220     }
221     if (mgtri->get_nb_fem_noeud()==6)
222     {
223     FEM_NOEUD* noeud0=mgtri->get_fem_noeud(0);
224     FEM_NOEUD* noeud1=mgtri->get_fem_noeud(1);
225     FEM_NOEUD* noeud2=mgtri->get_fem_noeud(2);
226     FEM_NOEUD* noeud3=mgtri->get_fem_noeud(3);
227     FEM_NOEUD* noeud4=mgtri->get_fem_noeud(4);
228     FEM_NOEUD* noeud5=mgtri->get_fem_noeud(5);
229     liste_noeuds1.ajouter(noeud0);
230     liste_noeuds1.ajouter(noeud1);
231     liste_noeuds1.ajouter(noeud2);
232     liste_noeuds1.ajouter(noeud3);
233     liste_noeuds1.ajouter(noeud4);
234     liste_noeuds1.ajouter(noeud5);
235     }
236     }
237    
238 francois 38 for (int k =0; k < liste_noeuds1.get_nb();k++)
239 5 {
240 francois 38 FEM_NOEUD* noeud=liste_noeuds1.get(k);
241 louhichi 211 fonction.Ajouter_Point_Array_Ideal(noeud->get_x(coef),noeud->get_y(coef),noeud->get_z(coef),k+1);
242 francois 38 }
243     fonction.Determiner_Plan(liste_noeuds1.get_nb(),Epsilon);
244     for (int k =0; k < liste_noeuds1.get_nb();k++)
245     {
246     FEM_NOEUD* noeud=liste_noeuds1.get(k);
247 louhichi 211 fonction.Projeter_Point_Plan_Idealisee(noeud->get_x(coef),noeud->get_y(coef),noeud->get_z(coef));
248 francois 38 fonction.Pt_Proj_Surface_Ideal();
249     double xx = fonction.Pnt_Proj_Surface_Ideal(1);
250     double yy = fonction.Pnt_Proj_Surface_Ideal(2);
251     double zz = fonction.Pnt_Proj_Surface_Ideal(3);
252 louhichi 211 double distanc_pt_plan = OT_VECTEUR_3D(noeud->get_x(coef)-xx,noeud->get_y(coef)-yy,noeud->get_z(coef)-zz).get_longueur();
253 francois 38 if(distanc_pt_plan>(Epsilon/10))
254     {
255     changement_volume = 100.0;
256 5
257 francois 38 }
258    
259 5 }
260    
261    
262    
263 francois 38 }
264 5
265 francois 38 if(changement_volume>0.01)
266 5 {
267 francois 38 test = 0;
268     //goto face_non_idealise;
269     }
270 5
271 francois 38 if(changement_volume<=0.01)
272     {
273 5
274 francois 38 /*if(i==0)
275 5 {
276    
277 francois 38
278    
279 5 int nb_triangle = face->get_lien_fem_maillage()->get_nb();
280     TPL_MAP_ENTITE<FEM_NOEUD*> liste_noeuds;
281    
282     for (int j =0; j<nb_triangle;j++)
283     {
284     FEM_TRIANGLE* mgtri=(FEM_TRIANGLE*)face->get_lien_fem_maillage()->get(j);
285     if (!fem_maillage0->contient(mgtri)) continue;
286     if (mgtri->get_nb_fem_noeud()==3)
287     {
288     FEM_NOEUD* noeud0=mgtri->get_fem_noeud(0);
289     FEM_NOEUD* noeud1=mgtri->get_fem_noeud(1);
290     FEM_NOEUD* noeud2=mgtri->get_fem_noeud(2);
291     liste_noeuds.ajouter(noeud0);
292     liste_noeuds.ajouter(noeud1);
293     liste_noeuds.ajouter(noeud2);
294     }
295     if (mgtri->get_nb_fem_noeud()==6)
296     {
297     FEM_NOEUD* noeud0=mgtri->get_fem_noeud(0);
298     FEM_NOEUD* noeud1=mgtri->get_fem_noeud(1);
299     FEM_NOEUD* noeud2=mgtri->get_fem_noeud(2);
300     FEM_NOEUD* noeud3=mgtri->get_fem_noeud(3);
301     FEM_NOEUD* noeud4=mgtri->get_fem_noeud(4);
302     FEM_NOEUD* noeud5=mgtri->get_fem_noeud(5);
303     liste_noeuds.ajouter(noeud0);
304     liste_noeuds.ajouter(noeud1);
305     liste_noeuds.ajouter(noeud2);
306     liste_noeuds.ajouter(noeud3);
307     liste_noeuds.ajouter(noeud4);
308     liste_noeuds.ajouter(noeud5);
309     }
310     }
311    
312    
313     //double moy_depl =0;
314     for (int k =0; k < liste_noeuds.get_nb();k++)
315     {
316     FEM_NOEUD* noeud=liste_noeuds.get(k);
317     int nb_noeud_maillage = fem_maillage0->get_nb_fem_noeud();
318     for (int l =0; l < nb_noeud_maillage;l++)
319     {
320     FEM_NOEUD* noeud0=fem_maillage0->get_fem_noeud(l);
321     if(noeud0 == noeud)
322     {
323     FEM_NOEUD* noeud1 = fem_maillage1->get_fem_noeud(l);
324    
325     double depl = OT_VECTEUR_3D(noeud1->get_x()-noeud0->get_x(),noeud1->get_y()-noeud0->get_y(),noeud1->get_z()-noeud0->get_z()).get_longueur();
326     //moy_depl = moy_depl + depl;
327     if(depl >= erreur_idealisation)
328     {
329     test = 0;
330     goto Deplacement_important;
331     }
332    
333     }
334     }
335     }
336    
337    
338 francois 38
339 5 Deplacement_important:
340     }
341 francois 38 */
342 5
343 francois 38
344 5 if(i!=0)
345     {
346     //test =1;
347     int nb_contour = face->get_nb_mg_boucle();
348     for(int j = 0; j<nb_contour; j++)
349     {
350     MG_BOUCLE* Boucle = face->get_mg_boucle(j);
351     int nb_arete_boucle = Boucle->get_nb_mg_coarete();
352     for(int k = 0; k<nb_arete_boucle; k++)
353     {
354     MG_COARETE* coArete = Boucle->get_mg_coarete(k);
355     MG_ARETE* Arete = coArete->get_arete();
356     for(int l = 0; l<i; l++)
357     {
358     if(faces[l] == 1)
359     {
360     MG_FACE* face_tab = mggeo->get_mg_face(l);
361     int nb_contour_face_tab = face_tab->get_nb_mg_boucle();
362     for(int m = 0; m<nb_contour_face_tab; m++)
363     {
364     MG_BOUCLE* Boucle_face_tab = face_tab->get_mg_boucle(m);
365     int nb_arete_boucle_face_tab = Boucle_face_tab->get_nb_mg_coarete();
366     for(int n = 0; n<nb_arete_boucle_face_tab; n++)
367     {
368     MG_COARETE* coArete_face_tab = Boucle_face_tab->get_mg_coarete(n);
369     MG_ARETE* Arete_face_tab = coArete_face_tab->get_arete();
370     if (Arete == Arete_face_tab)
371     {
372     test = 0;
373     goto face_adjacente;
374     }
375     }
376     }
377     }
378     }
379     }
380     }
381    
382 louhichi 211 face_adjacente:int test=1;
383 francois 38 /*
384 5 if(test == 1)
385     {
386    
387     int nb_triangle = face->get_lien_fem_maillage()->get_nb();
388     TPL_MAP_ENTITE<FEM_NOEUD*> liste_noeuds;
389    
390     for (int j =0; j<nb_triangle;j++)
391     {
392     FEM_TRIANGLE* mgtri=(FEM_TRIANGLE*)face->get_lien_fem_maillage()->get(j);
393     if (!fem_maillage0->contient(mgtri)) continue;
394     if (mgtri->get_nb_fem_noeud()==3)
395     {
396     FEM_NOEUD* noeud0=mgtri->get_fem_noeud(0);
397     FEM_NOEUD* noeud1=mgtri->get_fem_noeud(1);
398     FEM_NOEUD* noeud2=mgtri->get_fem_noeud(2);
399     liste_noeuds.ajouter(noeud0);
400     liste_noeuds.ajouter(noeud1);
401     liste_noeuds.ajouter(noeud2);
402     }
403     if (mgtri->get_nb_fem_noeud()==6)
404     {
405     FEM_NOEUD* noeud0=mgtri->get_fem_noeud(0);
406     FEM_NOEUD* noeud1=mgtri->get_fem_noeud(1);
407     FEM_NOEUD* noeud2=mgtri->get_fem_noeud(2);
408     FEM_NOEUD* noeud3=mgtri->get_fem_noeud(3);
409     FEM_NOEUD* noeud4=mgtri->get_fem_noeud(4);
410     FEM_NOEUD* noeud5=mgtri->get_fem_noeud(5);
411     liste_noeuds.ajouter(noeud0);
412     liste_noeuds.ajouter(noeud1);
413     liste_noeuds.ajouter(noeud2);
414     liste_noeuds.ajouter(noeud3);
415     liste_noeuds.ajouter(noeud4);
416     liste_noeuds.ajouter(noeud5);
417     }
418     }
419    
420    
421     double moy_depl =0;
422     for (int k =0; k < liste_noeuds.get_nb();k++)
423     {
424     FEM_NOEUD* noeud=liste_noeuds.get(k);
425     int nb_noeud_maillage = fem_maillage0->get_nb_fem_noeud();
426     for (int l =0; l < nb_noeud_maillage;l++)
427     {
428     FEM_NOEUD* noeud0=fem_maillage0->get_fem_noeud(l);
429     if(noeud0 == noeud)
430     {
431     FEM_NOEUD* noeud1 = fem_maillage1->get_fem_noeud(l);
432    
433    
434     double depl = OT_VECTEUR_3D(noeud1->get_x()-noeud0->get_x(),noeud1->get_y()-noeud0->get_y(),noeud1->get_z()-noeud0->get_z()).get_longueur();
435     //moy_depl = moy_depl + depl;
436     if(depl >= erreur_idealisation)
437     {
438     test = 0;
439     goto Deplacement_important1;
440     }
441     }
442     }
443     }
444    
445    
446 francois 38
447 5 Deplacement_important1:
448    
449 francois 38 }*/
450 louhichi 211 }
451 5 }
452    
453     //face_non_idealise:
454    
455     ////////////////////////////////////////////////////////////////////////
456    
457     faces[i] = test;
458    
459     if(test == 1)
460     {
461 louhichi 211 REC_FACE Reconst(fem_maillage, Idealiser, fonction, test, faces);
462     Reconst.Reconstruire(face, coef);
463 5 fonction.Ajouter_face_Coquille();
464     }
465    
466    
467     }// fin for
468    
469    
470    
471    
472     for (int i =0; i<nb_face;i++)
473     {
474     MG_FACE* face = mggeo->get_mg_face(i);
475     test = faces[i];
476    
477     if(test == 0)
478     {
479 louhichi 211 REC_FACE Reconst(fem_maillage, Idealiser, fonction, test, faces);
480     Reconst.Reconstruire(face, coef);
481 5 fonction.Ajouter_face_Coquille();
482     }
483     }
484    
485    
486     }// fin else (idealiser == 1)
487    
488    
489     delete [] faces;
490    
491    
492    
493    
494     }
495    
496     void REC_BREP::Enregistrer(char *path)
497     {
498 louhichi 211 //OCC_FONCTION fonction;
499 5 fonction.Enregistrer(path);
500     }
501    
502    
503    
504    
505    
506    
507    
508    
509