ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/mg_coque.cpp
Revision: 906
Committed: Mon Nov 13 22:30:18 2017 UTC (7 years, 6 months ago) by couturad
File size: 6420 byte(s)
Log Message:
Nouveau opencascade commit 1

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 couturad 906
86     int MG_COQUE::get_type(void)
87     {
88     return TYPE_ELEMENT_TOPOLOGIQUE::COQUE;
89     }
90    
91 francois 283 void MG_COQUE::get_topologie_sousjacente(TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> *lst)
92     {
93     int nbcoq=lst_coquille.size();
94     for (int i=0;i<nbcoq;i++)
95     {
96     MG_COQUILLE* coq=lst_coquille[i];
97     int nbface=coq->get_nb_mg_coface();
98     for (int j=0;j<nbface;j++)
99     {
100     MG_FACE* face=coq->get_mg_coface(j)->get_face();
101     lst->ajouter(face);
102     face->get_topologie_sousjacente(lst);
103     }
104     }
105     }
106 francois 763 void MG_COQUE::enregistrer(std::ostream& o,double version)
107 francois 283 {
108     o << "%" << get_id() << "=COQUE(" << get_idoriginal() << ",(";
109     for (unsigned int i=0;i<lst_coquille.size();i++)
110     {
111     o << "$" << lst_coquille[i]->get_id();
112     if (i!=lst_coquille.size()-1) o << ",";
113     else o << ")";
114     }
115     int nb=get_nb_ccf();
116 francois 794 if (version<2)
117     {
118 francois 283 o << "," << num_materiau << "," << nb;
119     if (nb!=0)
120     {
121     o << ",(";
122     for (int i=0;i<nb;i++)
123     {
124     char nom[3];
125     get_type_ccf(i,nom);
126     o << "(" << nom << "," << get_valeur_ccf(i) << ")";
127     if (i!=nb-1) o << "," ;
128     }
129     o << ")";
130     }
131     o << ");" << std::endl;
132 francois 794 }
133     else
134     {
135     o << "," ;
136     enregistrer_ccf(o,version);
137     o << ");" << std::endl;
138     }
139 francois 283
140 francois 794 }
141    
142 gervaislavoie 328 void MG_COQUE::orienter(class MG_MAILLAGE* mai)
143     {
144     double point[3]; // Coordonnées X, Y et Z du point d'orientation
145     int nbccf=get_nb_ccf();
146     for (int k=0;k<nbccf;k++)
147     {
148     char typeccf[2];
149     get_type_ccf(k,typeccf);
150     if (typeccf[0]=='C')
151     {
152     if (typeccf[1]=='x') point[0]=get_valeur_ccf(k);
153     if (typeccf[1]=='y') point[1]=get_valeur_ccf(k);
154     if (typeccf[1]=='z') point[2]=get_valeur_ccf(k);
155     }
156     }
157     double dist_min=1e300;
158     MG_NOEUD* noeud_plus_pres;
159     LISTE_MG_NOEUD::iterator it;
160     for (MG_NOEUD* noeud_actuel=mai->get_premier_noeud(it);noeud_actuel;noeud_actuel=mai->get_suivant_noeud(it))
161     {
162     double *xyz_actuel=noeud_actuel->get_coord();
163     OT_VECTEUR_3D vec_actuel(xyz_actuel,point);
164     double distance_actuelle=vec_actuel.get_longueur();
165     if (distance_actuelle<dist_min)
166     {
167     dist_min=distance_actuelle;
168     noeud_plus_pres=noeud_actuel;
169     }
170     }
171     MG_TRIANGLE* tri=(MG_TRIANGLE*)noeud_plus_pres->get_lien_triangle()->get(0);
172     MG_NOEUD* no1;
173     MG_NOEUD* no2;
174     MG_NOEUD* no3;
175    
176     no1=tri->get_noeud1();
177     no2=tri->get_noeud2();
178     no3=tri->get_noeud3();
179    
180     MG_FACE* face=(MG_FACE*)(tri->get_lien_topologie());
181     double *xyzn1=no1->get_coord();
182     double *xyzn2=no2->get_coord();
183     double *xyzn3=no3->get_coord();
184    
185     // Pour vérifier l'ordre des vecteurs pour le calcul de la normale d'un triangle
186     double uv[2];
187     face->inverser(uv,xyzn1); // Changement de système de coordonnées
188     double normale[3];
189     face->calcul_normale_unitaire(uv,normale);
190    
191     OT_VECTEUR_3D vec1(xyzn1,xyzn3);
192     OT_VECTEUR_3D vec2(xyzn1,xyzn2);
193     OT_VECTEUR_3D norm=vec1&vec2; // Normale au triangle
194     norm.norme();
195     double ps=norm*normale;
196     double *xyz_plus_pres=noeud_plus_pres->get_coord();
197     OT_VECTEUR_3D vec_plus_pres(xyz_plus_pres,point);
198     vec_plus_pres.norme();
199     ps=norm*vec_plus_pres;
200     ps=norm*vec_plus_pres;
201    
202     if (ps<0) // Il faut inverser le signe de la coface
203     {
204     int nbcofaces=get_mg_coquille(0)->get_nb_mg_coface();
205     for (int i=0;i<nbcofaces;i++)
206     {
207     MG_COFACE* cof=get_mg_coquille(0)->get_mg_coface(i);
208     int signe=cof->get_orientation();
209 gervaislavoie 332 MG_FACE* f=cof->get_face();
210     cof->change(f,-1*signe);
211 gervaislavoie 328 }
212     }
213     }
214 francois 632 BOITE_3D MG_COQUE::get_boite_3D(int pas_echantillon)
215     {
216     BOITE_3D boitevol;
217     int nb_coquille=get_nb_mg_coquille();
218     for (int i=0;i<nb_coquille;i++)
219     {
220     MG_COQUILLE* coq=get_mg_coquille(i);
221     int nb_face=coq->get_nb_mg_coface();
222     for (int j=0;j<nb_face;j++)
223     {
224     MG_FACE* face=coq->get_mg_coface(j)->get_face();
225     BOITE_3D tmp=face->get_boite_3D(pas_echantillon);
226     if ((i==0) && (j==0)) boitevol=tmp;
227     else boitevol=tmp+boitevol;
228     }
229     }
230     return boitevol;
231     }
232 francois 283 void MG_COQUE::change_num_materiau(int num)
233     {
234     num_materiau=num;
235     }
236    
237     int MG_COQUE::get_num_materiau(void)
238     {
239     return num_materiau;
240     }
241    
242     VCT& MG_COQUE::get_vectorisation(void)
243     {
244     VCT *p=NULL;
245     return *p;
246     }