ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/reconstruction/src/rec_brep.cpp
Revision: 1158
Committed: Thu Jun 13 22:18:49 2024 UTC (11 months, 1 week ago) by francois
File size: 24823 byte(s)
Log Message:
compatibilité Ubuntu 22.04
Suppression des refeences à Windows
Ajout d'une banière

File Contents

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