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