1 |
//------------------------------------------------------------ |
2 |
//------------------------------------------------------------ |
3 |
// MAGiC |
4 |
// Jean Christophe Cuilli�e et Vincent FRANCOIS |
5 |
// D�artement de G�ie M�anique - UQTR |
6 |
//------------------------------------------------------------ |
7 |
// Le projet MAGIC est un projet de recherche du d�artement |
8 |
// de g�ie m�anique de l'Universit�du Qu�ec � |
9 |
// Trois Rivi�es |
10 |
// Les librairies ne peuvent �re utilis�s sans l'accord |
11 |
// des auteurs (contact : francois@uqtr.ca) |
12 |
//------------------------------------------------------------ |
13 |
//------------------------------------------------------------ |
14 |
// |
15 |
// main.cpp |
16 |
// |
17 |
//------------------------------------------------------------ |
18 |
//------------------------------------------------------------ |
19 |
// COPYRIGHT 2000 |
20 |
// Version du 02/03/2006 �11H25 |
21 |
//------------------------------------------------------------ |
22 |
//------------------------------------------------------------ |
23 |
#include "gestionversion.h" |
24 |
|
25 |
|
26 |
#include <iostream> |
27 |
#include "ndata.h" |
28 |
#include "vtkdisplay.h" |
29 |
#include "mg_file.h" |
30 |
#include "occ_import.h" |
31 |
#include <map> |
32 |
//--------------------------------------------------------------------------- |
33 |
|
34 |
void affiche(char* message) |
35 |
{ |
36 |
std::cout << message << std::endl; |
37 |
|
38 |
} |
39 |
|
40 |
|
41 |
|
42 |
|
43 |
void affiche_maillage(color cnoeud,color csegment,color c2d,MG_MAILLAGE* mai,data_container &data) |
44 |
{ |
45 |
|
46 |
if (mai==NULL) return; |
47 |
properties ptr=data.getproppoints(); |
48 |
ptr.c=cnoeud; |
49 |
ptr.pointsize=6; |
50 |
data.setproppoints(ptr); |
51 |
|
52 |
LISTE_MG_NOEUD::iterator itn; |
53 |
for (MG_NOEUD* no=mai->get_premier_noeud(itn);no!=NULL;no=mai->get_suivant_noeud(itn)) |
54 |
{ |
55 |
double *xyz1=no->get_coord(); |
56 |
npoint p1(xyz1[0],xyz1[1],xyz1[2]); |
57 |
data.add_point(p1); |
58 |
} |
59 |
ptr=data.getproplines(); |
60 |
ptr.c=csegment; |
61 |
data.setproplines(ptr); |
62 |
LISTE_MG_SEGMENT::iterator its; |
63 |
for (MG_SEGMENT* seg=mai->get_premier_segment(its);seg!=NULL;seg=mai->get_suivant_segment(its)) |
64 |
{ |
65 |
if (seg->get_lien_topologie()!=NULL) |
66 |
if (seg->get_lien_topologie()->get_dimension()!=1) continue; |
67 |
|
68 |
double *xyz1=seg->get_noeud1()->get_coord(); |
69 |
double *xyz2=seg->get_noeud2()->get_coord(); |
70 |
npoint p1(xyz1[0],xyz1[1],xyz1[2]); |
71 |
npoint p2(xyz2[0],xyz2[1],xyz2[2]); |
72 |
line li; |
73 |
li.pts[0]=p1; |
74 |
li.pts[1]=p2; |
75 |
data.add_line(li); |
76 |
} |
77 |
ptr=data.getproptriangles(); |
78 |
ptr.c=c2d; |
79 |
ptr.edgeon=true; |
80 |
data.setproptriangles(ptr); |
81 |
LISTE_MG_TRIANGLE::iterator itt; |
82 |
for (MG_TRIANGLE* tri=mai->get_premier_triangle(itt);tri!=NULL;tri=mai->get_suivant_triangle(itt)) |
83 |
{ |
84 |
if (tri->get_lien_topologie()!=NULL) |
85 |
if (tri->get_lien_topologie()->get_dimension()!=2) continue; |
86 |
|
87 |
double *xyz1=tri->get_noeud1()->get_coord(); |
88 |
double *xyz2=tri->get_noeud2()->get_coord(); |
89 |
double *xyz3=tri->get_noeud3()->get_coord(); |
90 |
npoint p1(xyz1[0],xyz1[1],xyz1[2]); |
91 |
npoint p2(xyz2[0],xyz2[1],xyz2[2]); |
92 |
npoint p3(xyz3[0],xyz3[1],xyz3[2]); |
93 |
triangle tr; |
94 |
tr.pts[0]=p1; |
95 |
tr.pts[1]=p2; |
96 |
tr.pts[2]=p3; |
97 |
data.add_triangle(tr); |
98 |
} |
99 |
ptr=data.getpropquads(); |
100 |
ptr.c=c2d; |
101 |
ptr.edgeon=true; |
102 |
data.setpropquads(ptr); |
103 |
LISTE_MG_QUADRANGLE::iterator itq; |
104 |
for (MG_QUADRANGLE* qua=mai->get_premier_quadrangle(itq);qua!=NULL;qua=mai->get_suivant_quadrangle(itq)) |
105 |
{ |
106 |
if (qua->get_lien_topologie()!=NULL) |
107 |
if (qua->get_lien_topologie()->get_dimension()!=2) continue; |
108 |
|
109 |
double *xyz1=qua->get_noeud1()->get_coord(); |
110 |
double *xyz2=qua->get_noeud2()->get_coord(); |
111 |
double *xyz3=qua->get_noeud3()->get_coord(); |
112 |
double *xyz4=qua->get_noeud4()->get_coord(); |
113 |
npoint p1(xyz1[0],xyz1[1],xyz1[2]); |
114 |
npoint p2(xyz2[0],xyz2[1],xyz2[2]); |
115 |
npoint p3(xyz3[0],xyz3[1],xyz3[2]); |
116 |
npoint p4(xyz4[0],xyz4[1],xyz4[2]); |
117 |
quad qd; |
118 |
qd.pts[0]=p1; |
119 |
qd.pts[1]=p2; |
120 |
qd.pts[2]=p3; |
121 |
qd.pts[3]=p4; |
122 |
data.add_quad(qd); |
123 |
} |
124 |
LISTE_MG_TETRA::iterator ittr; |
125 |
for (MG_TETRA* tet=mai->get_premier_tetra(ittr);tet!=NULL;tet=mai->get_suivant_tetra(ittr)) |
126 |
{ |
127 |
double *xyz1=tet->get_noeud1()->get_coord(); |
128 |
double *xyz2=tet->get_noeud2()->get_coord(); |
129 |
double *xyz3=tet->get_noeud3()->get_coord(); |
130 |
double *xyz4=tet->get_noeud4()->get_coord(); |
131 |
npoint p1(xyz1[0],xyz1[1],xyz1[2]); |
132 |
npoint p2(xyz2[0],xyz2[1],xyz2[2]); |
133 |
npoint p3(xyz3[0],xyz3[1],xyz3[2]); |
134 |
npoint p4(xyz4[0],xyz4[1],xyz4[2]); |
135 |
triangle t1,t2,t3,t4; |
136 |
t1.pts[0]=p1; |
137 |
t1.pts[1]=p2; |
138 |
t1.pts[2]=p3; |
139 |
t2.pts[0]=p1; |
140 |
t2.pts[1]=p2; |
141 |
t2.pts[2]=p4; |
142 |
t3.pts[0]=p2; |
143 |
t3.pts[1]=p3; |
144 |
t3.pts[2]=p4; |
145 |
t4.pts[0]=p1; |
146 |
t4.pts[1]=p3; |
147 |
t4.pts[2]=p4; |
148 |
data.add_triangle(t1); |
149 |
data.add_triangle(t2); |
150 |
data.add_triangle(t3); |
151 |
data.add_triangle(t4); |
152 |
} |
153 |
LISTE_MG_HEXA::iterator ithe; |
154 |
for (MG_HEXA* hex=mai->get_premier_hexa(ithe);hex!=NULL;hex=mai->get_suivant_hexa(ithe)) |
155 |
{ |
156 |
double *xyz1=hex->get_noeud1()->get_coord(); |
157 |
double *xyz2=hex->get_noeud2()->get_coord(); |
158 |
double *xyz3=hex->get_noeud3()->get_coord(); |
159 |
double *xyz4=hex->get_noeud4()->get_coord(); |
160 |
double *xyz5=hex->get_noeud5()->get_coord(); |
161 |
double *xyz6=hex->get_noeud6()->get_coord(); |
162 |
double *xyz7=hex->get_noeud7()->get_coord(); |
163 |
double *xyz8=hex->get_noeud8()->get_coord(); |
164 |
npoint p1(xyz1[0],xyz1[1],xyz1[2]); |
165 |
npoint p2(xyz2[0],xyz2[1],xyz2[2]); |
166 |
npoint p3(xyz3[0],xyz3[1],xyz3[2]); |
167 |
npoint p4(xyz4[0],xyz4[1],xyz4[2]); |
168 |
npoint p5(xyz5[0],xyz5[1],xyz5[2]); |
169 |
npoint p6(xyz6[0],xyz6[1],xyz6[2]); |
170 |
npoint p7(xyz7[0],xyz7[1],xyz7[2]); |
171 |
npoint p8(xyz8[0],xyz8[1],xyz8[2]); |
172 |
quad q1,q2,q3,q4,q5,q6; |
173 |
q1.pts[0]=p1; |
174 |
q1.pts[1]=p2; |
175 |
q1.pts[2]=p3; |
176 |
q1.pts[3]=p4; |
177 |
q2.pts[0]=p5; |
178 |
q2.pts[1]=p6; |
179 |
q2.pts[2]=p7; |
180 |
q2.pts[3]=p8; |
181 |
q3.pts[0]=p2; |
182 |
q3.pts[1]=p3; |
183 |
q3.pts[2]=p7; |
184 |
q3.pts[3]=p6; |
185 |
q4.pts[0]=p3; |
186 |
q4.pts[1]=p4; |
187 |
q4.pts[2]=p8; |
188 |
q4.pts[3]=p7; |
189 |
q5.pts[0]=p4; |
190 |
q5.pts[1]=p1; |
191 |
q5.pts[2]=p5; |
192 |
q5.pts[3]=p8; |
193 |
q6.pts[0]=p1; |
194 |
q6.pts[1]=p2; |
195 |
q6.pts[2]=p6; |
196 |
q6.pts[3]=p5; |
197 |
data.add_quad(q1); |
198 |
data.add_quad(q2); |
199 |
data.add_quad(q3); |
200 |
data.add_quad(q4); |
201 |
data.add_quad(q5); |
202 |
data.add_quad(q6); |
203 |
} |
204 |
|
205 |
/* |
206 |
properties ptr=data.getproptriangles(); |
207 |
ptr.c=cface; |
208 |
ptr.edgeon=false; |
209 |
data.setproptriangles(ptr); |
210 |
ptr=data.getpropquads(); |
211 |
ptr.c=cface; |
212 |
ptr.edgeon=false; |
213 |
data.setpropquads(ptr); |
214 |
|
215 |
LISTE_MG_FACE::iterator itf; |
216 |
for (MG_FACE* face=geo->get_premier_face(itf);face!=NULL;face=geo->get_suivant_face(itf)) |
217 |
{ |
218 |
double xg=0.,yg=0.,zg=0.,deno=0.; |
219 |
int nbtri=face->get_lien_maillage()->get_nb(); |
220 |
for (int i=0;i<nbtri;i++) |
221 |
{ |
222 |
MG_ELEMENT_MAILLAGE* ele=face->get_lien_maillage()->get(i); |
223 |
color c=cface; |
224 |
int nbccf=ele->get_lien_topologie()->get_nb_ccf(); |
225 |
for (int i=0;i<nbccf;i++) |
226 |
{ |
227 |
char typ[2]; |
228 |
ele->get_lien_topologie()->get_type_ccf(i,typ); |
229 |
if (typ[0]=='D') c=cdeplacement; |
230 |
if (typ[0]=='R') c=cdeplacement; |
231 |
if (typ[0]=='F') c=cforce; |
232 |
if (typ[0]=='P') c=cpression; |
233 |
if (typ[0]=='T') c=ctemperature; |
234 |
if (typ[0]=='f') c=cflux; |
235 |
} |
236 |
if (ele->get_type_entite()==IDMG_TRIANGLE) |
237 |
{ |
238 |
properties ptr=data.getproptriangles(); |
239 |
ptr.c=c; |
240 |
data.setproptriangles(ptr); |
241 |
MG_TRIANGLE* tri=(MG_TRIANGLE*)ele; |
242 |
if (mai->get_mg_triangleid(tri->get_id())!=tri) continue; |
243 |
double *xyz1=tri->get_noeud1()->get_coord(); |
244 |
double *xyz2=tri->get_noeud2()->get_coord(); |
245 |
double *xyz3=tri->get_noeud3()->get_coord(); |
246 |
npoint p1(xyz1[0],xyz1[1],xyz1[2]); |
247 |
npoint p2(xyz2[0],xyz2[1],xyz2[2]); |
248 |
npoint p3(xyz3[0],xyz3[1],xyz3[2]); |
249 |
triangle tr; |
250 |
tr.pts[0]=p1; |
251 |
tr.pts[1]=p2; |
252 |
tr.pts[2]=p3; |
253 |
data.add_triangle(tr); |
254 |
OT_VECTEUR_3D vec1(xyz1,xyz2); |
255 |
OT_VECTEUR_3D vec2(xyz1,xyz3); |
256 |
OT_VECTEUR_3D sur=vec1&vec2; |
257 |
xg=xg+0.3333333333*(xyz1[0]+xyz2[0]+xyz3[0])*sur.get_longueur(); |
258 |
yg=yg+0.3333333333*(xyz1[1]+xyz2[1]+xyz3[1])*sur.get_longueur(); |
259 |
zg=zg+0.3333333333*(xyz1[2]+xyz2[2]+xyz3[2])*sur.get_longueur(); |
260 |
deno=deno+sur.get_longueur(); |
261 |
} |
262 |
if (ele->get_type_entite()==IDMG_QUADRANGLE) |
263 |
{ |
264 |
ptr=data.getpropquads(); |
265 |
ptr.c=c; |
266 |
data.setpropquads(ptr); |
267 |
MG_QUADRANGLE* qua=(MG_QUADRANGLE*)ele; |
268 |
if (mai->get_mg_quadrangleid(qua->get_id())!=qua) continue; |
269 |
double *xyz1=qua->get_noeud1()->get_coord(); |
270 |
double *xyz2=qua->get_noeud2()->get_coord(); |
271 |
double *xyz3=qua->get_noeud3()->get_coord(); |
272 |
double *xyz4=qua->get_noeud4()->get_coord(); |
273 |
npoint p1(xyz1[0],xyz1[1],xyz1[2]); |
274 |
npoint p2(xyz2[0],xyz2[1],xyz2[2]); |
275 |
npoint p3(xyz3[0],xyz3[1],xyz3[2]); |
276 |
npoint p4(xyz4[0],xyz4[1],xyz4[2]); |
277 |
quad qd; |
278 |
qd.pts[0]=p1; |
279 |
qd.pts[1]=p2; |
280 |
qd.pts[2]=p3; |
281 |
qd.pts[3]=p4; |
282 |
data.add_quad(qd); |
283 |
OT_VECTEUR_3D vec1(xyz1,xyz2); |
284 |
OT_VECTEUR_3D vec2(xyz1,xyz3); |
285 |
OT_VECTEUR_3D vec3(xyz1,xyz4); |
286 |
OT_VECTEUR_3D sur=vec1&vec2; |
287 |
OT_VECTEUR_3D sur2=vec2&vec3; |
288 |
xg=xg+0.3333333333*(xyz1[0]+xyz2[0]+xyz3[0])*sur.get_longueur(); |
289 |
yg=yg+0.3333333333*(xyz1[1]+xyz2[1]+xyz3[1])*sur.get_longueur(); |
290 |
zg=zg+0.3333333333*(xyz1[2]+xyz2[2]+xyz3[2])*sur.get_longueur(); |
291 |
xg=xg+0.3333333333*(xyz1[0]+xyz4[0]+xyz3[0])*sur2.get_longueur(); |
292 |
yg=yg+0.3333333333*(xyz1[1]+xyz4[1]+xyz3[1])*sur2.get_longueur(); |
293 |
zg=zg+0.3333333333*(xyz1[2]+xyz4[2]+xyz3[2])*sur2.get_longueur(); |
294 |
deno=deno+sur.get_longueur()+sur2.get_longueur(); |
295 |
} |
296 |
} |
297 |
xg=xg/deno; |
298 |
yg=yg/deno; |
299 |
zg=zg/deno; |
300 |
std::map<double,MG_ELEMENT_MAILLAGE*> classe; |
301 |
for (int i=0;i<nbtri;i++) |
302 |
{ |
303 |
MG_ELEMENT_MAILLAGE* ele=face->get_lien_maillage()->get(i); |
304 |
if (ele->get_type_entite()==IDMG_TRIANGLE) |
305 |
{ |
306 |
MG_TRIANGLE* tri=(MG_TRIANGLE*)ele; |
307 |
if (mai->get_mg_triangleid(tri->get_id())!=tri) continue; |
308 |
double *xyz1=tri->get_noeud1()->get_coord(); |
309 |
double *xyz2=tri->get_noeud2()->get_coord(); |
310 |
double *xyz3=tri->get_noeud3()->get_coord(); |
311 |
double x=0.3333333333*(xyz1[0]+xyz2[0]+xyz3[0]); |
312 |
double y=0.3333333333*(xyz1[1]+xyz2[1]+xyz3[1]); |
313 |
double z=0.3333333333*(xyz1[2]+xyz2[2]+xyz3[2]); |
314 |
OT_VECTEUR_3D vec(x-xg,y-yg,z-zg); |
315 |
classe.insert(std::pair<double,MG_ELEMENT_MAILLAGE*>(vec.get_longueur2(),tri)); |
316 |
} |
317 |
if (ele->get_type_entite()==IDMG_QUADRANGLE) |
318 |
{ |
319 |
MG_QUADRANGLE* qua=(MG_QUADRANGLE*)ele; |
320 |
if (mai->get_mg_quadrangleid(qua->get_id())!=qua) continue; |
321 |
double *xyz1=qua->get_noeud1()->get_coord(); |
322 |
double *xyz2=qua->get_noeud2()->get_coord(); |
323 |
double *xyz3=qua->get_noeud3()->get_coord(); |
324 |
double *xyz4=qua->get_noeud4()->get_coord(); |
325 |
double x=0.25*(xyz1[0]+xyz2[0]+xyz3[0]+xyz4[0]); |
326 |
double y=0.25*(xyz1[1]+xyz2[1]+xyz3[1]+xyz4[1]); |
327 |
double z=0.25*(xyz1[2]+xyz2[2]+xyz3[2]+xyz4[2]); |
328 |
OT_VECTEUR_3D vec(x-xg,y-yg,z-zg); |
329 |
classe.insert(std::pair<double,MG_ELEMENT_MAILLAGE*>(vec.get_longueur2(),qua)); |
330 |
} |
331 |
} |
332 |
if (classe.size()>0) |
333 |
{ |
334 |
MG_ELEMENT_MAILLAGE *ele=classe.begin()->second; |
335 |
if (ele->get_type_entite()==IDMG_TRIANGLE) |
336 |
{ |
337 |
MG_TRIANGLE *tri=(MG_TRIANGLE*)ele; |
338 |
double *xyz1=tri->get_noeud1()->get_coord(); |
339 |
double *xyz2=tri->get_noeud2()->get_coord(); |
340 |
double *xyz3=tri->get_noeud3()->get_coord(); |
341 |
npoint p(0.3333333333*(xyz1[0]+xyz2[0]+xyz3[0]),0.3333333333*(xyz1[1]+xyz2[1]+xyz3[1]),0.3333333333*(xyz1[2]+xyz2[2]+xyz3[2])); |
342 |
point pp; |
343 |
pp.pts=p; |
344 |
char mess[255]; |
345 |
if (idori==false) sprintf(mess,"F%lu",face->get_id()); else sprintf(mess,"%s",face->get_idoriginal().c_str()); |
346 |
pp.info=mess; |
347 |
std::pair<point,color> tmp(pp,ctext); |
348 |
data.add_text(2,tmp); |
349 |
} |
350 |
if (ele->get_type_entite()==IDMG_QUADRANGLE) |
351 |
{ |
352 |
MG_QUADRANGLE *qua=(MG_QUADRANGLE*)ele; |
353 |
double *xyz1=qua->get_noeud1()->get_coord(); |
354 |
double *xyz2=qua->get_noeud2()->get_coord(); |
355 |
double *xyz3=qua->get_noeud3()->get_coord(); |
356 |
double *xyz4=qua->get_noeud4()->get_coord(); |
357 |
npoint p(0.25*(xyz1[0]+xyz2[0]+xyz3[0]+xyz4[0]),0.25*(xyz1[1]+xyz2[1]+xyz3[1]+xyz4[1]),0.25*(xyz1[2]+xyz2[2]+xyz3[2]+xyz4[2])); |
358 |
point pp; |
359 |
pp.pts=p; |
360 |
char mess[255]; |
361 |
if (idori==false) sprintf(mess,"F%lu",face->get_id()); else sprintf(mess,"%s",face->get_idoriginal().c_str()); |
362 |
pp.info=mess; |
363 |
std::pair<point,color> tmp(pp,ctext); |
364 |
data.add_text(2,tmp); |
365 |
} |
366 |
} |
367 |
} |
368 |
|
369 |
ptr=data.getproplines(); |
370 |
ptr.c=carete; |
371 |
ptr.thickness=2; |
372 |
data.setproplines(ptr); |
373 |
|
374 |
LISTE_MG_ARETE::iterator ita; |
375 |
for (MG_ARETE* are=geo->get_premier_arete(ita);are!=NULL;are=geo->get_suivant_arete(ita)) |
376 |
{ |
377 |
int nbseg=are->get_lien_maillage()->get_nb(); |
378 |
double xg=0.,yg=0.,zg=0.,deno=0.; |
379 |
for (int i=0;i<nbseg;i++) |
380 |
{ |
381 |
MG_SEGMENT* seg=(MG_SEGMENT*)are->get_lien_maillage()->get(i); |
382 |
if (mai->get_mg_segmentid(seg->get_id())!=seg) continue; |
383 |
color c=carete; |
384 |
int nbccf=seg->get_lien_topologie()->get_nb_ccf(); |
385 |
for (int i=0;i<nbccf;i++) |
386 |
{ |
387 |
char typ[2]; |
388 |
seg->get_lien_topologie()->get_type_ccf(i,typ); |
389 |
if (typ[0]=='D') c=cdeplacement; |
390 |
if (typ[0]=='R') c=cdeplacement; |
391 |
if (typ[0]=='F') c=cforce; |
392 |
if (typ[0]=='P') c=cpression; |
393 |
if (typ[0]=='T') c=ctemperature; |
394 |
if (typ[0]=='f') c=cflux; |
395 |
} |
396 |
ptr=data.getproplines(); |
397 |
ptr.c=c; |
398 |
ptr.thickness=2; |
399 |
data.setproplines(ptr); |
400 |
double *xyz1=seg->get_noeud1()->get_coord(); |
401 |
double *xyz2=seg->get_noeud2()->get_coord(); |
402 |
npoint p1(xyz1[0],xyz1[1],xyz1[2]); |
403 |
npoint p2(xyz2[0],xyz2[1],xyz2[2]); |
404 |
line li; |
405 |
li.pts[0]=p1; |
406 |
li.pts[1]=p2; |
407 |
data.add_line(li); |
408 |
OT_VECTEUR_3D vec(xyz1,xyz2); |
409 |
xg=xg+0.5*(xyz1[0]+xyz2[0])*vec.get_longueur(); |
410 |
yg=yg+0.5*(xyz1[1]+xyz2[1])*vec.get_longueur(); |
411 |
zg=zg+0.5*(xyz1[2]+xyz2[2])*vec.get_longueur(); |
412 |
deno=deno+vec.get_longueur(); |
413 |
} |
414 |
xg=xg/deno; |
415 |
yg=yg/deno; |
416 |
zg=zg/deno; |
417 |
std::map<double,MG_SEGMENT*> classeseg; |
418 |
for (int i=0;i<nbseg;i++) |
419 |
{ |
420 |
MG_SEGMENT* seg=(MG_SEGMENT*)are->get_lien_maillage()->get(i); |
421 |
if (mai->get_mg_segmentid(seg->get_id())!=seg) continue; |
422 |
double *xyz1=seg->get_noeud1()->get_coord(); |
423 |
double *xyz2=seg->get_noeud2()->get_coord(); |
424 |
double x=0.5*(xyz1[0]+xyz2[0]); |
425 |
double y=0.5*(xyz1[1]+xyz2[1]); |
426 |
double z=0.5*(xyz1[2]+xyz2[2]); |
427 |
OT_VECTEUR_3D vec(x-xg,y-yg,z-zg); |
428 |
classeseg.insert(std::pair<double,MG_SEGMENT*>(vec.get_longueur2(),seg)); |
429 |
} |
430 |
if (classeseg.size()>0) |
431 |
{ |
432 |
MG_SEGMENT* seg=classeseg.begin()->second; |
433 |
double *xyz1=seg->get_noeud1()->get_coord(); |
434 |
double *xyz2=seg->get_noeud2()->get_coord(); |
435 |
npoint p(0.5*(xyz1[0]+xyz2[0]),0.5*(xyz1[1]+xyz2[1]),0.5*(xyz1[2]+xyz2[2])); |
436 |
point pp; |
437 |
pp.pts=p; |
438 |
char mess[255]; |
439 |
if (idori==false) sprintf(mess,"E%lu",are->get_id()); else sprintf(mess,"%s",are->get_idoriginal().c_str()); |
440 |
pp.info=mess; |
441 |
std::pair<point,color> tmp(pp,ctext); |
442 |
data.add_text(1,tmp); |
443 |
} |
444 |
} |
445 |
|
446 |
|
447 |
ptr=data.getproppoints(); |
448 |
ptr.c=carete; |
449 |
ptr.pointsize=10; |
450 |
data.setproppoints(ptr); |
451 |
LISTE_MG_SOMMET::iterator its; |
452 |
for (MG_SOMMET* som=geo->get_premier_sommet(its);som!=NULL;som=geo->get_suivant_sommet(its)) |
453 |
{ |
454 |
int nbpoint=som->get_lien_maillage()->get_nb(); |
455 |
for (int i=0;i<nbpoint;i++) |
456 |
{ |
457 |
MG_NOEUD* nd=(MG_NOEUD*)som->get_lien_maillage()->get(i); |
458 |
if (mai->get_mg_noeudid(nd->get_id())!=nd) continue; |
459 |
color c=carete; |
460 |
int nbccf=nd->get_lien_topologie()->get_nb_ccf(); |
461 |
for (int i=0;i<nbccf;i++) |
462 |
{ |
463 |
char typ[2]; |
464 |
nd->get_lien_topologie()->get_type_ccf(i,typ); |
465 |
if (typ[0]=='D') c=cdeplacement; |
466 |
if (typ[0]=='R') c=cdeplacement; |
467 |
if (typ[0]=='F') c=cforce; |
468 |
if (typ[0]=='P') c=cpression; |
469 |
if (typ[0]=='T') c=ctemperature; |
470 |
if (typ[0]=='f') c=cflux; |
471 |
} |
472 |
ptr=data.getproppoints(); |
473 |
ptr.c=c; |
474 |
data.setproppoints(ptr); |
475 |
double *xyz1=nd->get_coord(); |
476 |
npoint p1(xyz1[0],xyz1[1],xyz1[2]); |
477 |
data.add_point(p1); |
478 |
point pp; |
479 |
pp.pts=p1; |
480 |
char mess[255]; |
481 |
if (idori==false) sprintf(mess,"V%lu",som->get_id()); else sprintf(mess,"%s",som->get_idoriginal().c_str()); |
482 |
pp.info=mess; |
483 |
std::pair<point,color> tmp(pp,ctext); |
484 |
data.add_text(0,tmp); |
485 |
} |
486 |
} |
487 |
|
488 |
*/ |
489 |
|
490 |
|
491 |
}; |
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
int main(int argc,char **argv) |
500 |
{ |
501 |
color cbase=color(0,0,0); |
502 |
color cnoeud(0,0,255); |
503 |
color csegment(255,0,0); |
504 |
color c2D(125,0,0); |
505 |
/* |
506 |
char chemin[1000]; |
507 |
sprintf(chemin,"%s/.vtkdisplay",getenv("HOME")); |
508 |
FILE *in=fopen(chemin,"rt"); |
509 |
if (in!=NULL) |
510 |
{ |
511 |
char mess[255]; |
512 |
fgets(mess,255,in); |
513 |
int R,G,B; |
514 |
int nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
515 |
if (nb==3) base=color(R,G,B); |
516 |
if (!feof(in)) |
517 |
{ |
518 |
fgets(mess,255,in); |
519 |
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
520 |
if (nb==3) cface=color(R,G,B); |
521 |
if (!feof(in)) |
522 |
{ |
523 |
fgets(mess,255,in); |
524 |
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
525 |
if (nb==3) carete=color(R,G,B); |
526 |
if (!feof(in)) |
527 |
{ |
528 |
fgets(mess,255,in); |
529 |
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
530 |
if (nb==3) ctext=color(R,G,B); |
531 |
if (!feof(in)) |
532 |
{ |
533 |
fgets(mess,255,in); |
534 |
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
535 |
if (nb==3) cdeplacement=color(R,G,B); |
536 |
if (!feof(in)) |
537 |
{ |
538 |
fgets(mess,255,in); |
539 |
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
540 |
if (nb==3) cforce=color(R,G,B); |
541 |
if (!feof(in)) |
542 |
{ |
543 |
fgets(mess,255,in); |
544 |
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
545 |
if (nb==3) cpression=color(R,G,B); |
546 |
if (!feof(in)) |
547 |
{ |
548 |
fgets(mess,255,in); |
549 |
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
550 |
if (nb==3) ctemperature=color(R,G,B); |
551 |
if (!feof(in)) |
552 |
{ |
553 |
fgets(mess,255,in); |
554 |
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
555 |
if (nb==3) cflux=color(R,G,B); |
556 |
|
557 |
} |
558 |
} |
559 |
|
560 |
} |
561 |
|
562 |
} |
563 |
} |
564 |
} |
565 |
} |
566 |
} |
567 |
fclose(in); |
568 |
}*/ |
569 |
printf("******************************\n"); |
570 |
printf("* Visualization *\n"); |
571 |
printf("* by *\n"); |
572 |
printf("* Jean-Christophe Cuillière *\n"); |
573 |
printf("* and *\n"); |
574 |
printf("* Vincent Francois *\n"); |
575 |
printf("* ERICCA-UQTR *\n"); |
576 |
printf("******************************\n\n\n"); |
577 |
|
578 |
|
579 |
|
580 |
if (!((argc==2) || (argc==3))) |
581 |
{ |
582 |
printf("Visumaillage.exe - Bad number arguments\n visumagic.exe fichier [numero du maillage]\n\n"); |
583 |
return 0; |
584 |
|
585 |
} |
586 |
char fichier[255]; |
587 |
strcpy(fichier,argv[1]); |
588 |
|
589 |
char *p=strchr(fichier,'.'); |
590 |
char extension[255]; |
591 |
strcpy(extension,p+1); |
592 |
|
593 |
MG_FILE gest(fichier); |
594 |
|
595 |
|
596 |
int num=0; |
597 |
if (argc==3) num=atoi(argv[2]); |
598 |
MG_MAILLAGE* mai=gest.get_mg_maillage(num); |
599 |
data_container data; |
600 |
|
601 |
printf("\n\n"); |
602 |
printf("Command on keyboard : \n"); |
603 |
printf(" e : End of vizualisation\n"); |
604 |
printf(" r : Reset Camera\n"); |
605 |
printf(" v : Nodes visible on/off\n"); |
606 |
printf(" l : Segments visible on/off\n"); |
607 |
printf(" t : Triangles/quadrangles visible on/off\n"); |
608 |
printf(" j : Save camera on current directory\n"); |
609 |
printf(" k : Load camera from current directory\n"); |
610 |
printf(" w : Wireframe\n"); |
611 |
printf(" s : Modelframe\n"); |
612 |
printf(" - : Decrease text size\n"); |
613 |
printf(" + : Increase text size\n"); |
614 |
|
615 |
char titre [500]; |
616 |
strcpy(titre,"Visumaillage "); |
617 |
strcat(titre,fichier); |
618 |
if (mai!=NULL) affiche_maillage(cnoeud,csegment,c2D,mai,data); |
619 |
|
620 |
vtkdisplay d(cbase,titre); |
621 |
|
622 |
|
623 |
|
624 |
|
625 |
d.init_data(data); |
626 |
d.display(); |
627 |
|
628 |
|
629 |
return 0; |
630 |
} |
631 |
|
632 |
|
633 |
|
634 |
|