ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/mg_coque.cpp
Revision: 794
Committed: Wed Apr 6 17:39:34 2016 UTC (9 years, 1 month ago) by francois
File size: 6343 byte(s)
Log Message:
bug resolu a a propos de la non prise en compte du versionnage des fichiers magic pour les coques et les poutres

File Contents

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