ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/reconstruction/src/rec_brep.cpp
Revision: 5
Committed: Tue Jun 12 20:26:34 2007 UTC (17 years, 11 months ago)
Original Path: magic/lib/reconstruction/reconstruction/src/Rec_BREP.cpp
File size: 23484 byte(s)
Log Message:

File Contents

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