ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/mtu/src/mg_coque.cpp
Revision: 1180
Committed: Fri Sep 20 20:10:22 2024 UTC (8 months ago) by francois
File size: 6425 byte(s)
Log Message:
Correction dans la quadratisation sans geometrie

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     //####// mg_coque.cpp
15     //####//
16     //####//------------------------------------------------------------
17     //####//------------------------------------------------------------
18     //####// COPYRIGHT 2000-2024
19     //####// jeu 13 jun 2024 11:58:54 EDT
20     //####//------------------------------------------------------------
21     //####//------------------------------------------------------------
22 francois 283
23    
24     #include "gestionversion.h"
25     #include "mg_coque.h"
26 gervaislavoie 328 #include "mg_maillage.h"
27     #include "ot_mathematique.h"
28 francois 283
29     MG_COQUE::MG_COQUE(std::string idori,unsigned long num):MG_ELEMENT_TOPOLOGIQUE(num,idori),num_materiau(-1)
30     {
31     }
32    
33     MG_COQUE::MG_COQUE(std::string idori):MG_ELEMENT_TOPOLOGIQUE(idori),num_materiau(-1)
34     {
35     }
36    
37     MG_COQUE::MG_COQUE(MG_COQUE& mdd):MG_ELEMENT_TOPOLOGIQUE(mdd),lst_coquille(mdd.lst_coquille)
38     {
39     }
40    
41     MG_COQUE::~MG_COQUE()
42     {
43     }
44    
45     void MG_COQUE::ajouter_mg_coquille(class MG_COQUILLE* mgcoq)
46     {
47     lst_coquille.insert(lst_coquille.end(),mgcoq);
48     }
49    
50     void MG_COQUE::supprimer_mg_coquille(class MG_COQUILLE* mgcoq)
51     {
52     std::vector<MG_COQUILLE*>::iterator i;
53     for (i=lst_coquille.begin();i!=lst_coquille.end();i++)
54     {
55     if ((*i)==mgcoq)
56     {
57     lst_coquille.erase(i);
58     return;
59     }
60     }
61     }
62    
63    
64 francois 1180 bool MG_COQUE::est_une_topo_element(void)
65 francois 581 {
66     return false;
67     }
68    
69 francois 283 int MG_COQUE::get_nb_mg_coquille(void)
70     {
71     return lst_coquille.size();
72     }
73    
74     MG_COQUILLE* MG_COQUE::get_mg_coquille(int num)
75     {
76     return lst_coquille[num];
77     }
78    
79     int MG_COQUE::get_dimension(void)
80     {
81     return 2;
82     }
83 couturad 906
84     int MG_COQUE::get_type(void)
85     {
86     return TYPE_ELEMENT_TOPOLOGIQUE::COQUE;
87     }
88    
89 francois 283 void MG_COQUE::get_topologie_sousjacente(TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> *lst)
90     {
91     int nbcoq=lst_coquille.size();
92     for (int i=0;i<nbcoq;i++)
93     {
94     MG_COQUILLE* coq=lst_coquille[i];
95     int nbface=coq->get_nb_mg_coface();
96     for (int j=0;j<nbface;j++)
97     {
98     MG_FACE* face=coq->get_mg_coface(j)->get_face();
99     lst->ajouter(face);
100     face->get_topologie_sousjacente(lst);
101     }
102     }
103     }
104 francois 763 void MG_COQUE::enregistrer(std::ostream& o,double version)
105 francois 283 {
106     o << "%" << get_id() << "=COQUE(" << get_idoriginal() << ",(";
107     for (unsigned int i=0;i<lst_coquille.size();i++)
108     {
109     o << "$" << lst_coquille[i]->get_id();
110     if (i!=lst_coquille.size()-1) o << ",";
111     else o << ")";
112     }
113     int nb=get_nb_ccf();
114 francois 794 if (version<2)
115     {
116 francois 283 o << "," << num_materiau << "," << nb;
117     if (nb!=0)
118     {
119     o << ",(";
120     for (int i=0;i<nb;i++)
121     {
122     char nom[3];
123     get_type_ccf(i,nom);
124     o << "(" << nom << "," << get_valeur_ccf(i) << ")";
125     if (i!=nb-1) o << "," ;
126     }
127     o << ")";
128     }
129     o << ");" << std::endl;
130 francois 794 }
131     else
132     {
133     o << "," ;
134     enregistrer_ccf(o,version);
135     o << ");" << std::endl;
136     }
137 francois 283
138 francois 794 }
139    
140 gervaislavoie 328 void MG_COQUE::orienter(class MG_MAILLAGE* mai)
141     {
142     double point[3]; // Coordonnées X, Y et Z du point d'orientation
143     int nbccf=get_nb_ccf();
144     for (int k=0;k<nbccf;k++)
145     {
146     char typeccf[2];
147     get_type_ccf(k,typeccf);
148     if (typeccf[0]=='C')
149     {
150     if (typeccf[1]=='x') point[0]=get_valeur_ccf(k);
151     if (typeccf[1]=='y') point[1]=get_valeur_ccf(k);
152     if (typeccf[1]=='z') point[2]=get_valeur_ccf(k);
153     }
154     }
155     double dist_min=1e300;
156     MG_NOEUD* noeud_plus_pres;
157     LISTE_MG_NOEUD::iterator it;
158     for (MG_NOEUD* noeud_actuel=mai->get_premier_noeud(it);noeud_actuel;noeud_actuel=mai->get_suivant_noeud(it))
159     {
160     double *xyz_actuel=noeud_actuel->get_coord();
161     OT_VECTEUR_3D vec_actuel(xyz_actuel,point);
162     double distance_actuelle=vec_actuel.get_longueur();
163     if (distance_actuelle<dist_min)
164     {
165     dist_min=distance_actuelle;
166     noeud_plus_pres=noeud_actuel;
167     }
168     }
169     MG_TRIANGLE* tri=(MG_TRIANGLE*)noeud_plus_pres->get_lien_triangle()->get(0);
170     MG_NOEUD* no1;
171     MG_NOEUD* no2;
172     MG_NOEUD* no3;
173    
174     no1=tri->get_noeud1();
175     no2=tri->get_noeud2();
176     no3=tri->get_noeud3();
177    
178     MG_FACE* face=(MG_FACE*)(tri->get_lien_topologie());
179     double *xyzn1=no1->get_coord();
180     double *xyzn2=no2->get_coord();
181     double *xyzn3=no3->get_coord();
182    
183     // Pour vérifier l'ordre des vecteurs pour le calcul de la normale d'un triangle
184     double uv[2];
185     face->inverser(uv,xyzn1); // Changement de système de coordonnées
186     double normale[3];
187     face->calcul_normale_unitaire(uv,normale);
188    
189     OT_VECTEUR_3D vec1(xyzn1,xyzn3);
190     OT_VECTEUR_3D vec2(xyzn1,xyzn2);
191     OT_VECTEUR_3D norm=vec1&vec2; // Normale au triangle
192     norm.norme();
193     double ps=norm*normale;
194     double *xyz_plus_pres=noeud_plus_pres->get_coord();
195     OT_VECTEUR_3D vec_plus_pres(xyz_plus_pres,point);
196     vec_plus_pres.norme();
197     ps=norm*vec_plus_pres;
198     ps=norm*vec_plus_pres;
199    
200     if (ps<0) // Il faut inverser le signe de la coface
201     {
202     int nbcofaces=get_mg_coquille(0)->get_nb_mg_coface();
203     for (int i=0;i<nbcofaces;i++)
204     {
205     MG_COFACE* cof=get_mg_coquille(0)->get_mg_coface(i);
206     int signe=cof->get_orientation();
207 gervaislavoie 332 MG_FACE* f=cof->get_face();
208     cof->change(f,-1*signe);
209 gervaislavoie 328 }
210     }
211     }
212 francois 1095 BOITE_3D MG_COQUE::get_boite_3D(void)
213 francois 632 {
214     BOITE_3D boitevol;
215     int nb_coquille=get_nb_mg_coquille();
216     for (int i=0;i<nb_coquille;i++)
217     {
218     MG_COQUILLE* coq=get_mg_coquille(i);
219     int nb_face=coq->get_nb_mg_coface();
220     for (int j=0;j<nb_face;j++)
221     {
222     MG_FACE* face=coq->get_mg_coface(j)->get_face();
223 francois 1095 BOITE_3D tmp=face->get_boite_3D();
224 francois 632 if ((i==0) && (j==0)) boitevol=tmp;
225     else boitevol=tmp+boitevol;
226     }
227     }
228     return boitevol;
229     }
230 francois 283 void MG_COQUE::change_num_materiau(int num)
231     {
232     num_materiau=num;
233     }
234    
235     int MG_COQUE::get_num_materiau(void)
236     {
237     return num_materiau;
238     }
239    
240     VCT& MG_COQUE::get_vectorisation(void)
241     {
242     VCT *p=NULL;
243     return *p;
244     }