1 |
francois |
1123 |
//------------------------------------------------------------ |
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_hexa.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_pyramide.h" |
27 |
|
|
#include "mg_maillage.h" |
28 |
|
|
|
29 |
|
|
MG_PYRAMIDE::MG_PYRAMIDE(unsigned long num,MG_ELEMENT_TOPOLOGIQUE* topo,class MG_NOEUD *mgnoeud1,class MG_NOEUD *mgnoeud2,class MG_NOEUD *mgnoeud3,class MG_NOEUD *mgnoeud4,class MG_NOEUD *mgnoeud5,class MG_TRIANGLE* mgtriangle1,MG_TRIANGLE* mgtriangle2,MG_TRIANGLE* mgtriangle3,MG_TRIANGLE* mgtriangle4,class MG_QUADRANGLE* mgquadrangle1,int origine):MG_ELEMENT_MAILLAGE(num,topo,origine),noeud1(mgnoeud1),noeud2(mgnoeud2),noeud3(mgnoeud3),noeud4(mgnoeud4),noeud5(mgnoeud5),triangle1(mgtriangle1),triangle2(mgtriangle2),triangle3(mgtriangle3),triangle4(mgtriangle4),quadrangle1(mgquadrangle1) |
30 |
|
|
{ |
31 |
|
|
init_pyramide(); |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
MG_PYRAMIDE::MG_PYRAMIDE(MG_ELEMENT_TOPOLOGIQUE* topo,class MG_NOEUD *mgnoeud1,class MG_NOEUD *mgnoeud2,class MG_NOEUD *mgnoeud3,class MG_NOEUD *mgnoeud4,class MG_NOEUD *mgnoeud5,class MG_TRIANGLE* mgtriangle1,MG_TRIANGLE* mgtriangle2,MG_TRIANGLE* mgtriangle3,MG_TRIANGLE* mgtriangle4,class MG_QUADRANGLE* mgquadrangle1,int origine):MG_ELEMENT_MAILLAGE(topo,origine),noeud1(mgnoeud1),noeud2(mgnoeud2),noeud3(mgnoeud3),noeud4(mgnoeud4),noeud5(mgnoeud5),triangle1(mgtriangle1),triangle2(mgtriangle2),triangle3(mgtriangle3),triangle4(mgtriangle4),quadrangle1(mgquadrangle1) |
35 |
|
|
{ |
36 |
|
|
init_pyramide(); |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
|
40 |
|
|
MG_PYRAMIDE::MG_PYRAMIDE(MG_PYRAMIDE& mdd):MG_ELEMENT_MAILLAGE(mdd),noeud1(mdd.noeud1),noeud2(mdd.noeud2),noeud3(mdd.noeud3),noeud4(mdd.noeud4),noeud5(mdd.noeud5),triangle1(mdd.triangle1),triangle2(mdd.triangle2),triangle3(mdd.triangle3),triangle4(mdd.triangle4),quadrangle1(mdd.quadrangle1) |
41 |
|
|
{ |
42 |
|
|
init_pyramide(); |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
|
46 |
|
|
MG_PYRAMIDE* MG_PYRAMIDE::dupliquer(MG_MAILLAGE *mgmai,long decalage) |
47 |
|
|
{ |
48 |
|
|
MG_NOEUD* nd1=mgmai->get_mg_noeudid(noeud1->get_id()+decalage); |
49 |
|
|
MG_NOEUD* nd2=mgmai->get_mg_noeudid(noeud2->get_id()+decalage); |
50 |
|
|
MG_NOEUD* nd3=mgmai->get_mg_noeudid(noeud3->get_id()+decalage); |
51 |
|
|
MG_NOEUD* nd4=mgmai->get_mg_noeudid(noeud4->get_id()+decalage); |
52 |
|
|
MG_NOEUD* nd5=mgmai->get_mg_noeudid(noeud5->get_id()+decalage); |
53 |
|
|
MG_TRIANGLE* tri1=mgmai->get_mg_triangleid(triangle1->get_id()+decalage); |
54 |
|
|
MG_TRIANGLE* tri2=mgmai->get_mg_triangleid(triangle2->get_id()+decalage); |
55 |
|
|
MG_TRIANGLE* tri3=mgmai->get_mg_triangleid(triangle3->get_id()+decalage); |
56 |
|
|
MG_TRIANGLE* tri4=mgmai->get_mg_triangleid(triangle4->get_id()+decalage); |
57 |
|
|
MG_QUADRANGLE* quad1=mgmai->get_mg_quadrangleid(quadrangle1->get_id()+decalage); |
58 |
|
|
MG_PYRAMIDE* pyr=new MG_PYRAMIDE(this->get_id()+decalage,liaison_topologique,nd1,nd2,nd3,nd4,nd5,tri1,tri2,tri3,tri4,quad1,MAGIC::ORIGINE::DUPLIQUER); |
59 |
|
|
mgmai->ajouter_mg_pyramide(pyr); |
60 |
|
|
return pyr; |
61 |
|
|
} |
62 |
|
|
|
63 |
|
|
MG_PYRAMIDE::~MG_PYRAMIDE() |
64 |
|
|
{ |
65 |
|
|
if (noeud1!=NULL) noeud1->get_lien_pyramide()->supprimer(this); |
66 |
|
|
if (noeud2!=NULL) noeud2->get_lien_pyramide()->supprimer(this); |
67 |
|
|
if (noeud3!=NULL) noeud3->get_lien_pyramide()->supprimer(this); |
68 |
|
|
if (noeud4!=NULL) noeud4->get_lien_pyramide()->supprimer(this); |
69 |
|
|
if (noeud5!=NULL) noeud5->get_lien_pyramide()->supprimer(this); |
70 |
|
|
unsigned long noeudminid=std::min(noeud1->get_id(),noeud2->get_id()); |
71 |
|
|
noeudminid=std::min(noeudminid,noeud3->get_id()); |
72 |
|
|
noeudminid=std::min(noeudminid,noeud4->get_id()); |
73 |
|
|
noeudminid=std::min(noeudminid,noeud5->get_id()); |
74 |
|
|
if (noeud1!=NULL) |
75 |
|
|
if (noeud1->get_id()==noeudminid) noeud1->get_lien_petit_pyramide()->supprimer(this); |
76 |
|
|
if (noeud2!=NULL) |
77 |
|
|
if (noeud2->get_id()==noeudminid) noeud2->get_lien_petit_pyramide()->supprimer(this); |
78 |
|
|
if (noeud3!=NULL) |
79 |
|
|
if (noeud3->get_id()==noeudminid) noeud3->get_lien_petit_pyramide()->supprimer(this); |
80 |
|
|
if (noeud4!=NULL) |
81 |
|
|
if (noeud4->get_id()==noeudminid) noeud4->get_lien_petit_pyramide()->supprimer(this); |
82 |
|
|
if (noeud5!=NULL) |
83 |
|
|
if (noeud5->get_id()==noeudminid) noeud5->get_lien_petit_pyramide()->supprimer(this); |
84 |
|
|
if (triangle1!=NULL) { |
85 |
|
|
triangle1->decrementer(); |
86 |
|
|
triangle1->get_lien_pyramide()->supprimer(this); |
87 |
|
|
} |
88 |
|
|
if (triangle2!=NULL) { |
89 |
|
|
triangle2->decrementer(); |
90 |
|
|
triangle2->get_lien_pyramide()->supprimer(this); |
91 |
|
|
} |
92 |
|
|
if (triangle3!=NULL) { |
93 |
|
|
triangle3->decrementer(); |
94 |
|
|
triangle3->get_lien_pyramide()->supprimer(this); |
95 |
|
|
} |
96 |
|
|
if (triangle4!=NULL) { |
97 |
|
|
triangle4->decrementer(); |
98 |
|
|
triangle4->get_lien_pyramide()->supprimer(this); |
99 |
|
|
} |
100 |
|
|
if (quadrangle1!=NULL) { |
101 |
|
|
quadrangle1->decrementer(); |
102 |
|
|
quadrangle1->get_lien_pyramide()->supprimer(this); |
103 |
|
|
} |
104 |
|
|
if (liaison_topologique!=NULL) |
105 |
|
|
if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_maillage()->supprimer(this); |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
void MG_PYRAMIDE::init_pyramide(void) |
109 |
|
|
{ |
110 |
|
|
if (noeud1!=NULL) noeud1->get_lien_pyramide()->ajouter(this); |
111 |
|
|
if (noeud2!=NULL) noeud2->get_lien_pyramide()->ajouter(this); |
112 |
|
|
if (noeud3!=NULL) noeud3->get_lien_pyramide()->ajouter(this); |
113 |
|
|
if (noeud4!=NULL) noeud4->get_lien_pyramide()->ajouter(this); |
114 |
|
|
if (noeud5!=NULL) noeud5->get_lien_pyramide()->ajouter(this); |
115 |
|
|
unsigned long noeudminid=std::min(noeud1->get_id(),noeud2->get_id()); |
116 |
|
|
noeudminid=std::min(noeudminid,noeud3->get_id()); |
117 |
|
|
noeudminid=std::min(noeudminid,noeud4->get_id()); |
118 |
|
|
noeudminid=std::min(noeudminid,noeud5->get_id()); |
119 |
|
|
if (noeud1!=NULL) |
120 |
|
|
if (noeud1->get_id()==noeudminid) noeud1->get_lien_petit_pyramide()->ajouter(this); |
121 |
|
|
if (noeud2!=NULL) |
122 |
|
|
if (noeud2->get_id()==noeudminid) noeud2->get_lien_petit_pyramide()->ajouter(this); |
123 |
|
|
if (noeud3!=NULL) |
124 |
|
|
if (noeud3->get_id()==noeudminid) noeud3->get_lien_petit_pyramide()->ajouter(this); |
125 |
|
|
if (noeud4!=NULL) |
126 |
|
|
if (noeud4->get_id()==noeudminid) noeud4->get_lien_petit_pyramide()->ajouter(this); |
127 |
|
|
if (noeud5!=NULL) |
128 |
|
|
if (noeud5->get_id()==noeudminid) noeud5->get_lien_petit_pyramide()->ajouter(this); |
129 |
|
|
if (triangle1!=NULL) { |
130 |
|
|
triangle1->incrementer(); |
131 |
|
|
triangle1->get_lien_pyramide()->ajouter(this); |
132 |
|
|
} |
133 |
|
|
if (triangle2!=NULL) { |
134 |
|
|
triangle2->incrementer(); |
135 |
|
|
triangle2->get_lien_pyramide()->ajouter(this); |
136 |
|
|
} |
137 |
|
|
if (triangle3!=NULL) { |
138 |
|
|
triangle3->incrementer(); |
139 |
|
|
triangle3->get_lien_pyramide()->ajouter(this); |
140 |
|
|
} |
141 |
|
|
if (triangle4!=NULL) { |
142 |
|
|
triangle4->incrementer(); |
143 |
|
|
triangle4->get_lien_pyramide()->ajouter(this); |
144 |
|
|
} |
145 |
|
|
if (quadrangle1!=NULL) { |
146 |
|
|
quadrangle1->incrementer(); |
147 |
|
|
quadrangle1->get_lien_pyramide()->ajouter(this); |
148 |
|
|
} |
149 |
|
|
|
150 |
|
|
if (liaison_topologique==NULL) return; |
151 |
|
|
if (liaison_topologique->get_dimension()==3) liaison_topologique->get_lien_maillage()->ajouter(this); |
152 |
|
|
} |
153 |
|
|
|
154 |
|
|
|
155 |
|
|
int MG_PYRAMIDE::get_type_entite(void) |
156 |
|
|
{ |
157 |
|
|
return IDMG_PYRAMIDE; |
158 |
|
|
} |
159 |
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
MG_NOEUD* MG_PYRAMIDE::get_noeud1(void) |
165 |
|
|
{ |
166 |
|
|
return noeud1; |
167 |
|
|
} |
168 |
|
|
|
169 |
|
|
MG_NOEUD* MG_PYRAMIDE::get_noeud2(void) |
170 |
|
|
{ |
171 |
|
|
return noeud2; |
172 |
|
|
} |
173 |
|
|
|
174 |
|
|
MG_NOEUD* MG_PYRAMIDE::get_noeud3(void) |
175 |
|
|
{ |
176 |
|
|
return noeud3; |
177 |
|
|
} |
178 |
|
|
|
179 |
|
|
MG_NOEUD* MG_PYRAMIDE::get_noeud4(void) |
180 |
|
|
{ |
181 |
|
|
return noeud4; |
182 |
|
|
} |
183 |
|
|
MG_NOEUD* MG_PYRAMIDE::get_noeud5(void) |
184 |
|
|
{ |
185 |
|
|
return noeud5; |
186 |
|
|
} |
187 |
|
|
|
188 |
|
|
|
189 |
|
|
MG_QUADRANGLE* MG_PYRAMIDE::get_quadrangle1(void) |
190 |
|
|
{ |
191 |
|
|
return quadrangle1; |
192 |
|
|
} |
193 |
|
|
|
194 |
|
|
MG_TRIANGLE* MG_PYRAMIDE::get_triangle1(void) |
195 |
|
|
{ |
196 |
|
|
return triangle1; |
197 |
|
|
} |
198 |
|
|
|
199 |
|
|
MG_TRIANGLE* MG_PYRAMIDE::get_triangle2(void) |
200 |
|
|
{ |
201 |
|
|
return triangle2; |
202 |
|
|
} |
203 |
|
|
MG_TRIANGLE* MG_PYRAMIDE::get_triangle3(void) |
204 |
|
|
{ |
205 |
|
|
return triangle3; |
206 |
|
|
} |
207 |
|
|
|
208 |
|
|
MG_TRIANGLE* MG_PYRAMIDE::get_triangle4(void) |
209 |
|
|
{ |
210 |
|
|
return triangle4; |
211 |
|
|
} |
212 |
|
|
|
213 |
|
|
void MG_PYRAMIDE::inverse_sens(void) |
214 |
|
|
{ |
215 |
|
|
MG_NOEUD* noeud=noeud4; |
216 |
|
|
noeud4=noeud2; |
217 |
|
|
noeud2=noeud; |
218 |
|
|
MG_TRIANGLE* triangle=triangle1; |
219 |
|
|
triangle1=triangle4; |
220 |
|
|
triangle4=triangle; |
221 |
|
|
triangle=triangle2; |
222 |
|
|
triangle2=triangle3; |
223 |
|
|
triangle3=triangle; |
224 |
|
|
} |
225 |
|
|
|
226 |
|
|
|
227 |
|
|
int MG_PYRAMIDE::get_dimension(void) |
228 |
|
|
{ |
229 |
|
|
return 3; |
230 |
|
|
} |
231 |
|
|
|
232 |
|
|
|
233 |
|
|
BOITE_3D MG_PYRAMIDE::get_boite_3D(void) |
234 |
|
|
{ |
235 |
|
|
double coo1[3]; |
236 |
|
|
double coo2[3]; |
237 |
|
|
double coo3[3]; |
238 |
|
|
double coo4[3]; |
239 |
|
|
double coo5[3]; |
240 |
|
|
coo1[0]=noeud1->get_x(); |
241 |
|
|
coo1[1]=noeud1->get_y(); |
242 |
|
|
coo1[2]=noeud1->get_z(); |
243 |
|
|
coo2[0]=noeud2->get_x(); |
244 |
|
|
coo2[1]=noeud2->get_y(); |
245 |
|
|
coo2[2]=noeud2->get_z(); |
246 |
|
|
coo3[0]=noeud3->get_x(); |
247 |
|
|
coo3[1]=noeud3->get_y(); |
248 |
|
|
coo3[2]=noeud3->get_z(); |
249 |
|
|
coo4[0]=noeud4->get_x(); |
250 |
|
|
coo4[1]=noeud4->get_y(); |
251 |
|
|
coo4[2]=noeud4->get_z(); |
252 |
|
|
coo5[0]=noeud5->get_x(); |
253 |
|
|
coo5[1]=noeud5->get_y(); |
254 |
|
|
coo5[2]=noeud5->get_z(); |
255 |
|
|
double xmin,ymin,zmin,xmax,ymax,zmax; |
256 |
|
|
xmin=std::min(coo1[0],coo2[0]); |
257 |
|
|
xmin=std::min(xmin,coo3[0]); |
258 |
|
|
xmin=std::min(xmin,coo4[0]); |
259 |
|
|
xmin=std::min(xmin,coo5[0]); |
260 |
|
|
xmax=std::max(coo1[0],coo2[0]); |
261 |
|
|
xmax=std::max(xmax,coo3[0]); |
262 |
|
|
xmax=std::max(xmax,coo4[0]); |
263 |
|
|
xmax=std::max(xmax,coo5[0]); |
264 |
|
|
ymin=std::min(coo1[1],coo2[1]); |
265 |
|
|
ymin=std::min(ymin,coo3[1]); |
266 |
|
|
ymin=std::min(ymin,coo4[1]); |
267 |
|
|
ymin=std::min(ymin,coo5[1]); |
268 |
|
|
ymax=std::max(coo1[1],coo2[1]); |
269 |
|
|
ymax=std::max(ymax,coo3[1]); |
270 |
|
|
ymax=std::max(ymax,coo4[1]); |
271 |
|
|
ymax=std::max(ymax,coo5[1]); |
272 |
|
|
zmin=std::min(coo1[2],coo2[2]); |
273 |
|
|
zmin=std::min(zmin,coo3[2]); |
274 |
|
|
zmin=std::min(zmin,coo4[2]); |
275 |
|
|
zmin=std::min(zmin,coo5[2]); |
276 |
|
|
zmax=std::max(coo1[2],coo2[2]); |
277 |
|
|
zmax=std::max(zmax,coo3[2]); |
278 |
|
|
zmax=std::max(zmax,coo4[2]); |
279 |
|
|
zmax=std::max(zmax,coo5[2]); |
280 |
|
|
BOITE_3D boite(xmin,ymin,zmin,xmax,ymax,zmax); |
281 |
|
|
return boite; |
282 |
|
|
} |
283 |
|
|
void MG_PYRAMIDE::extrapoler_solution_noeud(void) |
284 |
|
|
{ |
285 |
|
|
for (int j=0;j<MAX_TYPE_SOLUTION;j++) |
286 |
|
|
{ |
287 |
|
|
noeud1->change_solution(solution[j],j); |
288 |
|
|
noeud2->change_solution(solution[j],j); |
289 |
|
|
noeud3->change_solution(solution[j],j); |
290 |
|
|
noeud4->change_solution(solution[j],j); |
291 |
|
|
noeud5->change_solution(solution[j],j); |
292 |
|
|
} |
293 |
|
|
} |
294 |
|
|
|
295 |
|
|
void MG_PYRAMIDE::enregistrer(std::ostream& o,double version) |
296 |
|
|
{ |
297 |
|
|
if ((liaison_topologique==NULL) && (MG_MAILLAGE::DIMENSIONMAILLAGESANSTOPO!=3)) return; |
298 |
|
|
if (liaison_topologique==NULL) o << "%" << get_id() << "=PYRAMIDE(NULL,$" << noeud1->get_id() << ",$" << noeud2->get_id() << ",$" << noeud3->get_id() << ",$" << noeud4->get_id() << ",$" << noeud5->get_id() << "," << origine_creation << ");" << std::endl; |
299 |
|
|
else if (liaison_topologique->get_dimension()==3) o << "%" << get_id() << "=PYRAMIDE($"<< get_lien_topologie()->get_id() << ",$" << noeud1->get_id() << ",$" << noeud2->get_id() << ",$" << noeud3->get_id() << ",$" << noeud4->get_id() << ",$" <<noeud5->get_id() << "," << origine_creation << ");" << std::endl; |
300 |
|
|
} |
301 |
|
|
|
302 |
|
|
|
303 |
|
|
|
304 |
|
|
|
305 |
|
|
|
306 |
|
|
|