ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/reconstruction/src/rec_brep.cpp
Revision: 38
Committed: Mon Aug 20 20:39:35 2007 UTC (17 years, 8 months ago) by francois
Original Path: magic/lib/reconstruction/reconstruction/src/Rec_BREP.cpp
File size: 23860 byte(s)
Log Message:
Modifcation de borhen juin 2007

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 francois 38 double Epsilon = OT_VECTEUR_3D(xmax-xmin,ymax-ymin,zmax-zmin).get_longueur()/10.0;
204 5
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 francois 38 for (int k =0; k < liste_noeuds1.get_nb();k++)
240 5 {
241 francois 38 FEM_NOEUD* noeud=liste_noeuds1.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_noeuds1.get_nb(),Epsilon);
245     for (int k =0; k < liste_noeuds1.get_nb();k++)
246     {
247     FEM_NOEUD* noeud=liste_noeuds1.get(k);
248     fonction.Projeter_Point_Plan_Idealisee(noeud->get_x(),noeud->get_y(),noeud->get_z());
249     fonction.Pt_Proj_Surface_Ideal();
250     double xx = fonction.Pnt_Proj_Surface_Ideal(1);
251     double yy = fonction.Pnt_Proj_Surface_Ideal(2);
252     double zz = fonction.Pnt_Proj_Surface_Ideal(3);
253     double distanc_pt_plan = OT_VECTEUR_3D(noeud->get_x()-xx,noeud->get_y()-yy,noeud->get_z()-zz).get_longueur();
254     if(distanc_pt_plan>(Epsilon/10))
255     {
256     changement_volume = 100.0;
257 5
258 francois 38 }
259    
260 5 }
261    
262    
263    
264 francois 38 }
265 5
266 francois 38 if(changement_volume>0.01)
267 5 {
268 francois 38 test = 0;
269     //goto face_non_idealise;
270     }
271 5
272 francois 38 if(changement_volume<=0.01)
273     {
274 5
275 francois 38 /*if(i==0)
276 5 {
277    
278 francois 38
279    
280 5 int nb_triangle = face->get_lien_fem_maillage()->get_nb();
281     TPL_MAP_ENTITE<FEM_NOEUD*> liste_noeuds;
282    
283     for (int j =0; j<nb_triangle;j++)
284     {
285     FEM_TRIANGLE* mgtri=(FEM_TRIANGLE*)face->get_lien_fem_maillage()->get(j);
286     if (!fem_maillage0->contient(mgtri)) continue;
287     if (mgtri->get_nb_fem_noeud()==3)
288     {
289     FEM_NOEUD* noeud0=mgtri->get_fem_noeud(0);
290     FEM_NOEUD* noeud1=mgtri->get_fem_noeud(1);
291     FEM_NOEUD* noeud2=mgtri->get_fem_noeud(2);
292     liste_noeuds.ajouter(noeud0);
293     liste_noeuds.ajouter(noeud1);
294     liste_noeuds.ajouter(noeud2);
295     }
296     if (mgtri->get_nb_fem_noeud()==6)
297     {
298     FEM_NOEUD* noeud0=mgtri->get_fem_noeud(0);
299     FEM_NOEUD* noeud1=mgtri->get_fem_noeud(1);
300     FEM_NOEUD* noeud2=mgtri->get_fem_noeud(2);
301     FEM_NOEUD* noeud3=mgtri->get_fem_noeud(3);
302     FEM_NOEUD* noeud4=mgtri->get_fem_noeud(4);
303     FEM_NOEUD* noeud5=mgtri->get_fem_noeud(5);
304     liste_noeuds.ajouter(noeud0);
305     liste_noeuds.ajouter(noeud1);
306     liste_noeuds.ajouter(noeud2);
307     liste_noeuds.ajouter(noeud3);
308     liste_noeuds.ajouter(noeud4);
309     liste_noeuds.ajouter(noeud5);
310     }
311     }
312    
313    
314     //double moy_depl =0;
315     for (int k =0; k < liste_noeuds.get_nb();k++)
316     {
317     FEM_NOEUD* noeud=liste_noeuds.get(k);
318     int nb_noeud_maillage = fem_maillage0->get_nb_fem_noeud();
319     for (int l =0; l < nb_noeud_maillage;l++)
320     {
321     FEM_NOEUD* noeud0=fem_maillage0->get_fem_noeud(l);
322     if(noeud0 == noeud)
323     {
324     FEM_NOEUD* noeud1 = fem_maillage1->get_fem_noeud(l);
325    
326     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();
327     //moy_depl = moy_depl + depl;
328     if(depl >= erreur_idealisation)
329     {
330     test = 0;
331     goto Deplacement_important;
332     }
333    
334     }
335     }
336     }
337    
338    
339 francois 38
340 5 Deplacement_important:
341     }
342 francois 38 */
343 5
344 francois 38
345 5 if(i!=0)
346     {
347     //test =1;
348     int nb_contour = face->get_nb_mg_boucle();
349     for(int j = 0; j<nb_contour; j++)
350     {
351     MG_BOUCLE* Boucle = face->get_mg_boucle(j);
352     int nb_arete_boucle = Boucle->get_nb_mg_coarete();
353     for(int k = 0; k<nb_arete_boucle; k++)
354     {
355     MG_COARETE* coArete = Boucle->get_mg_coarete(k);
356     MG_ARETE* Arete = coArete->get_arete();
357     for(int l = 0; l<i; l++)
358     {
359     if(faces[l] == 1)
360     {
361     MG_FACE* face_tab = mggeo->get_mg_face(l);
362     int nb_contour_face_tab = face_tab->get_nb_mg_boucle();
363     for(int m = 0; m<nb_contour_face_tab; m++)
364     {
365     MG_BOUCLE* Boucle_face_tab = face_tab->get_mg_boucle(m);
366     int nb_arete_boucle_face_tab = Boucle_face_tab->get_nb_mg_coarete();
367     for(int n = 0; n<nb_arete_boucle_face_tab; n++)
368     {
369     MG_COARETE* coArete_face_tab = Boucle_face_tab->get_mg_coarete(n);
370     MG_ARETE* Arete_face_tab = coArete_face_tab->get_arete();
371     if (Arete == Arete_face_tab)
372     {
373     test = 0;
374     goto face_adjacente;
375     }
376     }
377     }
378     }
379     }
380     }
381     }
382    
383     face_adjacente:
384 francois 38 /*
385 5 if(test == 1)
386     {
387    
388     int nb_triangle = face->get_lien_fem_maillage()->get_nb();
389     TPL_MAP_ENTITE<FEM_NOEUD*> liste_noeuds;
390    
391     for (int j =0; j<nb_triangle;j++)
392     {
393     FEM_TRIANGLE* mgtri=(FEM_TRIANGLE*)face->get_lien_fem_maillage()->get(j);
394     if (!fem_maillage0->contient(mgtri)) continue;
395     if (mgtri->get_nb_fem_noeud()==3)
396     {
397     FEM_NOEUD* noeud0=mgtri->get_fem_noeud(0);
398     FEM_NOEUD* noeud1=mgtri->get_fem_noeud(1);
399     FEM_NOEUD* noeud2=mgtri->get_fem_noeud(2);
400     liste_noeuds.ajouter(noeud0);
401     liste_noeuds.ajouter(noeud1);
402     liste_noeuds.ajouter(noeud2);
403     }
404     if (mgtri->get_nb_fem_noeud()==6)
405     {
406     FEM_NOEUD* noeud0=mgtri->get_fem_noeud(0);
407     FEM_NOEUD* noeud1=mgtri->get_fem_noeud(1);
408     FEM_NOEUD* noeud2=mgtri->get_fem_noeud(2);
409     FEM_NOEUD* noeud3=mgtri->get_fem_noeud(3);
410     FEM_NOEUD* noeud4=mgtri->get_fem_noeud(4);
411     FEM_NOEUD* noeud5=mgtri->get_fem_noeud(5);
412     liste_noeuds.ajouter(noeud0);
413     liste_noeuds.ajouter(noeud1);
414     liste_noeuds.ajouter(noeud2);
415     liste_noeuds.ajouter(noeud3);
416     liste_noeuds.ajouter(noeud4);
417     liste_noeuds.ajouter(noeud5);
418     }
419     }
420    
421    
422     double moy_depl =0;
423     for (int k =0; k < liste_noeuds.get_nb();k++)
424     {
425     FEM_NOEUD* noeud=liste_noeuds.get(k);
426     int nb_noeud_maillage = fem_maillage0->get_nb_fem_noeud();
427     for (int l =0; l < nb_noeud_maillage;l++)
428     {
429     FEM_NOEUD* noeud0=fem_maillage0->get_fem_noeud(l);
430     if(noeud0 == noeud)
431     {
432     FEM_NOEUD* noeud1 = fem_maillage1->get_fem_noeud(l);
433    
434    
435     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();
436     //moy_depl = moy_depl + depl;
437     if(depl >= erreur_idealisation)
438     {
439     test = 0;
440     goto Deplacement_important1;
441     }
442     }
443     }
444     }
445    
446    
447 francois 38
448 5 Deplacement_important1:
449    
450 francois 38 }*/
451     }
452 5 }
453    
454     //face_non_idealise:
455    
456     ////////////////////////////////////////////////////////////////////////
457    
458     faces[i] = test;
459    
460     if(test == 1)
461     {
462     REC_FACE Reconst(fem_maillage0, fem_maillage1, Idealiser, test, faces);
463     Reconst.Reconstruire(face);
464     fonction.Ajouter_face_Coquille();
465     }
466    
467    
468     }// fin for
469    
470    
471    
472    
473     for (int i =0; i<nb_face;i++)
474     {
475     MG_FACE* face = mggeo->get_mg_face(i);
476     test = faces[i];
477    
478     if(test == 0)
479     {
480     REC_FACE Reconst(fem_maillage0, fem_maillage1, Idealiser, test, faces);
481     Reconst.Reconstruire(face);
482     fonction.Ajouter_face_Coquille();
483     }
484     }
485    
486    
487     }// fin else (idealiser == 1)
488    
489    
490     delete [] faces;
491    
492    
493    
494    
495     }
496    
497     void REC_BREP::Enregistrer(char *path)
498     {
499     OCC_FONCTION fonction;
500     fonction.Enregistrer(path);
501     }
502    
503    
504    
505    
506    
507    
508    
509    
510