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 |
|
|
//####// visumagic.cpp |
15 |
|
|
//####// |
16 |
|
|
//####//------------------------------------------------------------ |
17 |
|
|
//####//------------------------------------------------------------ |
18 |
|
|
//####// COPYRIGHT 2000-2024 |
19 |
|
|
//####// jeu 13 jun 2024 11:57:20 EDT |
20 |
|
|
//####//------------------------------------------------------------ |
21 |
|
|
//####//------------------------------------------------------------ |
22 |
francois |
353 |
#include "gestionversion.h" |
23 |
|
|
|
24 |
francois |
1061 |
|
25 |
francois |
353 |
#include <iostream> |
26 |
francois |
1157 |
#include "ndata.hxx" |
27 |
|
|
#include "vtkdisplay.hxx" |
28 |
francois |
353 |
#include "mg_file.h" |
29 |
francois |
356 |
#include "occ_import.h" |
30 |
francois |
353 |
#include <map> |
31 |
|
|
|
32 |
|
|
void affiche(char* message) |
33 |
|
|
{ |
34 |
|
|
std::cout << message << std::endl; |
35 |
francois |
1061 |
|
36 |
francois |
353 |
} |
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
francois |
654 |
void affiche_structure(color cface,color carete,color ctext,color cdeplacement,color cforce,color cpression,color ctemperature, color cflux,MG_GEOMETRIE* geo,MG_MAILLAGE* mai,data_container &data,bool idori) |
42 |
francois |
353 |
{ |
43 |
|
|
properties ptr=data.getproptriangles(); |
44 |
|
|
ptr.c=cface; |
45 |
|
|
ptr.edgeon=false; |
46 |
|
|
data.setproptriangles(ptr); |
47 |
francois |
576 |
ptr=data.getpropquads(); |
48 |
|
|
ptr.c=cface; |
49 |
|
|
ptr.edgeon=false; |
50 |
|
|
data.setpropquads(ptr); |
51 |
|
|
|
52 |
francois |
353 |
LISTE_MG_FACE::iterator itf; |
53 |
|
|
for (MG_FACE* face=geo->get_premier_face(itf);face!=NULL;face=geo->get_suivant_face(itf)) |
54 |
|
|
{ |
55 |
|
|
double xg=0.,yg=0.,zg=0.,deno=0.; |
56 |
|
|
int nbtri=face->get_lien_maillage()->get_nb(); |
57 |
|
|
for (int i=0;i<nbtri;i++) |
58 |
|
|
{ |
59 |
francois |
576 |
MG_ELEMENT_MAILLAGE* ele=face->get_lien_maillage()->get(i); |
60 |
francois |
654 |
color c=cface; |
61 |
|
|
int nbccf=ele->get_lien_topologie()->get_nb_ccf(); |
62 |
|
|
for (int i=0;i<nbccf;i++) |
63 |
|
|
{ |
64 |
|
|
char typ[2]; |
65 |
|
|
ele->get_lien_topologie()->get_type_ccf(i,typ); |
66 |
|
|
if (typ[0]=='D') c=cdeplacement; |
67 |
|
|
if (typ[0]=='R') c=cdeplacement; |
68 |
|
|
if (typ[0]=='F') c=cforce; |
69 |
|
|
if (typ[0]=='P') c=cpression; |
70 |
|
|
if (typ[0]=='T') c=ctemperature; |
71 |
|
|
if (typ[0]=='f') c=cflux; |
72 |
|
|
} |
73 |
francois |
1151 |
if (ele->get_type_entite()==MAGIC::TYPE_ENTITE::IDMG_TRIANGLE) |
74 |
francois |
576 |
{ |
75 |
francois |
654 |
properties ptr=data.getproptriangles(); |
76 |
|
|
ptr.c=c; |
77 |
|
|
data.setproptriangles(ptr); |
78 |
|
|
MG_TRIANGLE* tri=(MG_TRIANGLE*)ele; |
79 |
francois |
576 |
if (mai->get_mg_triangleid(tri->get_id())!=tri) continue; |
80 |
|
|
double *xyz1=tri->get_noeud1()->get_coord(); |
81 |
|
|
double *xyz2=tri->get_noeud2()->get_coord(); |
82 |
|
|
double *xyz3=tri->get_noeud3()->get_coord(); |
83 |
|
|
npoint p1(xyz1[0],xyz1[1],xyz1[2]); |
84 |
|
|
npoint p2(xyz2[0],xyz2[1],xyz2[2]); |
85 |
|
|
npoint p3(xyz3[0],xyz3[1],xyz3[2]); |
86 |
|
|
triangle tr; |
87 |
|
|
tr.pts[0]=p1; |
88 |
|
|
tr.pts[1]=p2; |
89 |
|
|
tr.pts[2]=p3; |
90 |
|
|
data.add_triangle(tr); |
91 |
|
|
OT_VECTEUR_3D vec1(xyz1,xyz2); |
92 |
|
|
OT_VECTEUR_3D vec2(xyz1,xyz3); |
93 |
|
|
OT_VECTEUR_3D sur=vec1&vec2; |
94 |
|
|
xg=xg+0.3333333333*(xyz1[0]+xyz2[0]+xyz3[0])*sur.get_longueur(); |
95 |
|
|
yg=yg+0.3333333333*(xyz1[1]+xyz2[1]+xyz3[1])*sur.get_longueur(); |
96 |
|
|
zg=zg+0.3333333333*(xyz1[2]+xyz2[2]+xyz3[2])*sur.get_longueur(); |
97 |
|
|
deno=deno+sur.get_longueur(); |
98 |
|
|
} |
99 |
francois |
1151 |
if (ele->get_type_entite()==MAGIC::TYPE_ENTITE::IDMG_QUADRANGLE) |
100 |
francois |
576 |
{ |
101 |
francois |
654 |
ptr=data.getpropquads(); |
102 |
|
|
ptr.c=c; |
103 |
|
|
data.setpropquads(ptr); |
104 |
|
|
MG_QUADRANGLE* qua=(MG_QUADRANGLE*)ele; |
105 |
francois |
576 |
if (mai->get_mg_quadrangleid(qua->get_id())!=qua) continue; |
106 |
|
|
double *xyz1=qua->get_noeud1()->get_coord(); |
107 |
|
|
double *xyz2=qua->get_noeud2()->get_coord(); |
108 |
|
|
double *xyz3=qua->get_noeud3()->get_coord(); |
109 |
|
|
double *xyz4=qua->get_noeud4()->get_coord(); |
110 |
|
|
npoint p1(xyz1[0],xyz1[1],xyz1[2]); |
111 |
|
|
npoint p2(xyz2[0],xyz2[1],xyz2[2]); |
112 |
|
|
npoint p3(xyz3[0],xyz3[1],xyz3[2]); |
113 |
|
|
npoint p4(xyz4[0],xyz4[1],xyz4[2]); |
114 |
|
|
quad qd; |
115 |
|
|
qd.pts[0]=p1; |
116 |
|
|
qd.pts[1]=p2; |
117 |
|
|
qd.pts[2]=p3; |
118 |
|
|
qd.pts[3]=p4; |
119 |
|
|
data.add_quad(qd); |
120 |
|
|
OT_VECTEUR_3D vec1(xyz1,xyz2); |
121 |
|
|
OT_VECTEUR_3D vec2(xyz1,xyz3); |
122 |
|
|
OT_VECTEUR_3D vec3(xyz1,xyz4); |
123 |
|
|
OT_VECTEUR_3D sur=vec1&vec2; |
124 |
|
|
OT_VECTEUR_3D sur2=vec2&vec3; |
125 |
|
|
xg=xg+0.3333333333*(xyz1[0]+xyz2[0]+xyz3[0])*sur.get_longueur(); |
126 |
|
|
yg=yg+0.3333333333*(xyz1[1]+xyz2[1]+xyz3[1])*sur.get_longueur(); |
127 |
|
|
zg=zg+0.3333333333*(xyz1[2]+xyz2[2]+xyz3[2])*sur.get_longueur(); |
128 |
|
|
xg=xg+0.3333333333*(xyz1[0]+xyz4[0]+xyz3[0])*sur2.get_longueur(); |
129 |
|
|
yg=yg+0.3333333333*(xyz1[1]+xyz4[1]+xyz3[1])*sur2.get_longueur(); |
130 |
|
|
zg=zg+0.3333333333*(xyz1[2]+xyz4[2]+xyz3[2])*sur2.get_longueur(); |
131 |
|
|
deno=deno+sur.get_longueur()+sur2.get_longueur(); |
132 |
|
|
} |
133 |
francois |
353 |
} |
134 |
|
|
xg=xg/deno; |
135 |
|
|
yg=yg/deno; |
136 |
|
|
zg=zg/deno; |
137 |
francois |
576 |
std::map<double,MG_ELEMENT_MAILLAGE*> classe; |
138 |
francois |
353 |
for (int i=0;i<nbtri;i++) |
139 |
|
|
{ |
140 |
francois |
576 |
MG_ELEMENT_MAILLAGE* ele=face->get_lien_maillage()->get(i); |
141 |
francois |
1151 |
if (ele->get_type_entite()==MAGIC::TYPE_ENTITE::IDMG_TRIANGLE) |
142 |
francois |
576 |
{ |
143 |
|
|
MG_TRIANGLE* tri=(MG_TRIANGLE*)ele; |
144 |
|
|
if (mai->get_mg_triangleid(tri->get_id())!=tri) continue; |
145 |
|
|
double *xyz1=tri->get_noeud1()->get_coord(); |
146 |
|
|
double *xyz2=tri->get_noeud2()->get_coord(); |
147 |
|
|
double *xyz3=tri->get_noeud3()->get_coord(); |
148 |
|
|
double x=0.3333333333*(xyz1[0]+xyz2[0]+xyz3[0]); |
149 |
|
|
double y=0.3333333333*(xyz1[1]+xyz2[1]+xyz3[1]); |
150 |
|
|
double z=0.3333333333*(xyz1[2]+xyz2[2]+xyz3[2]); |
151 |
|
|
OT_VECTEUR_3D vec(x-xg,y-yg,z-zg); |
152 |
|
|
classe.insert(std::pair<double,MG_ELEMENT_MAILLAGE*>(vec.get_longueur2(),tri)); |
153 |
|
|
} |
154 |
francois |
1151 |
if (ele->get_type_entite()==MAGIC::TYPE_ENTITE::IDMG_QUADRANGLE) |
155 |
francois |
576 |
{ |
156 |
|
|
MG_QUADRANGLE* qua=(MG_QUADRANGLE*)ele; |
157 |
|
|
if (mai->get_mg_quadrangleid(qua->get_id())!=qua) continue; |
158 |
|
|
double *xyz1=qua->get_noeud1()->get_coord(); |
159 |
|
|
double *xyz2=qua->get_noeud2()->get_coord(); |
160 |
|
|
double *xyz3=qua->get_noeud3()->get_coord(); |
161 |
|
|
double *xyz4=qua->get_noeud4()->get_coord(); |
162 |
|
|
double x=0.25*(xyz1[0]+xyz2[0]+xyz3[0]+xyz4[0]); |
163 |
|
|
double y=0.25*(xyz1[1]+xyz2[1]+xyz3[1]+xyz4[1]); |
164 |
|
|
double z=0.25*(xyz1[2]+xyz2[2]+xyz3[2]+xyz4[2]); |
165 |
|
|
OT_VECTEUR_3D vec(x-xg,y-yg,z-zg); |
166 |
|
|
classe.insert(std::pair<double,MG_ELEMENT_MAILLAGE*>(vec.get_longueur2(),qua)); |
167 |
|
|
} |
168 |
|
|
} |
169 |
|
|
if (classe.size()>0) |
170 |
|
|
{ |
171 |
|
|
MG_ELEMENT_MAILLAGE *ele=classe.begin()->second; |
172 |
francois |
1151 |
if (ele->get_type_entite()==MAGIC::TYPE_ENTITE::IDMG_TRIANGLE) |
173 |
francois |
576 |
{ |
174 |
|
|
MG_TRIANGLE *tri=(MG_TRIANGLE*)ele; |
175 |
francois |
353 |
double *xyz1=tri->get_noeud1()->get_coord(); |
176 |
|
|
double *xyz2=tri->get_noeud2()->get_coord(); |
177 |
|
|
double *xyz3=tri->get_noeud3()->get_coord(); |
178 |
francois |
576 |
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])); |
179 |
|
|
point pp; |
180 |
|
|
pp.pts=p; |
181 |
|
|
char mess[255]; |
182 |
|
|
if (idori==false) sprintf(mess,"F%lu",face->get_id()); else sprintf(mess,"%s",face->get_idoriginal().c_str()); |
183 |
|
|
pp.info=mess; |
184 |
|
|
std::pair<point,color> tmp(pp,ctext); |
185 |
|
|
data.add_text(2,tmp); |
186 |
francois |
353 |
} |
187 |
francois |
1151 |
if (ele->get_type_entite()==MAGIC::TYPE_ENTITE::IDMG_QUADRANGLE) |
188 |
francois |
576 |
{ |
189 |
|
|
MG_QUADRANGLE *qua=(MG_QUADRANGLE*)ele; |
190 |
|
|
double *xyz1=qua->get_noeud1()->get_coord(); |
191 |
|
|
double *xyz2=qua->get_noeud2()->get_coord(); |
192 |
|
|
double *xyz3=qua->get_noeud3()->get_coord(); |
193 |
|
|
double *xyz4=qua->get_noeud4()->get_coord(); |
194 |
|
|
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])); |
195 |
|
|
point pp; |
196 |
|
|
pp.pts=p; |
197 |
|
|
char mess[255]; |
198 |
|
|
if (idori==false) sprintf(mess,"F%lu",face->get_id()); else sprintf(mess,"%s",face->get_idoriginal().c_str()); |
199 |
|
|
pp.info=mess; |
200 |
|
|
std::pair<point,color> tmp(pp,ctext); |
201 |
|
|
data.add_text(2,tmp); |
202 |
|
|
} |
203 |
francois |
356 |
} |
204 |
francois |
353 |
} |
205 |
|
|
|
206 |
|
|
ptr=data.getproplines(); |
207 |
|
|
ptr.c=carete; |
208 |
|
|
ptr.thickness=2; |
209 |
|
|
data.setproplines(ptr); |
210 |
|
|
|
211 |
|
|
LISTE_MG_ARETE::iterator ita; |
212 |
|
|
for (MG_ARETE* are=geo->get_premier_arete(ita);are!=NULL;are=geo->get_suivant_arete(ita)) |
213 |
|
|
{ |
214 |
|
|
int nbseg=are->get_lien_maillage()->get_nb(); |
215 |
|
|
double xg=0.,yg=0.,zg=0.,deno=0.; |
216 |
|
|
for (int i=0;i<nbseg;i++) |
217 |
|
|
{ |
218 |
|
|
MG_SEGMENT* seg=(MG_SEGMENT*)are->get_lien_maillage()->get(i); |
219 |
francois |
654 |
if (mai->get_mg_segmentid(seg->get_id())!=seg) continue; |
220 |
|
|
color c=carete; |
221 |
|
|
int nbccf=seg->get_lien_topologie()->get_nb_ccf(); |
222 |
|
|
for (int i=0;i<nbccf;i++) |
223 |
|
|
{ |
224 |
|
|
char typ[2]; |
225 |
|
|
seg->get_lien_topologie()->get_type_ccf(i,typ); |
226 |
|
|
if (typ[0]=='D') c=cdeplacement; |
227 |
|
|
if (typ[0]=='R') c=cdeplacement; |
228 |
|
|
if (typ[0]=='F') c=cforce; |
229 |
|
|
if (typ[0]=='P') c=cpression; |
230 |
|
|
if (typ[0]=='T') c=ctemperature; |
231 |
|
|
if (typ[0]=='f') c=cflux; |
232 |
|
|
} |
233 |
|
|
ptr=data.getproplines(); |
234 |
|
|
ptr.c=c; |
235 |
|
|
ptr.thickness=2; |
236 |
|
|
data.setproplines(ptr); |
237 |
|
|
double *xyz1=seg->get_noeud1()->get_coord(); |
238 |
francois |
353 |
double *xyz2=seg->get_noeud2()->get_coord(); |
239 |
|
|
npoint p1(xyz1[0],xyz1[1],xyz1[2]); |
240 |
|
|
npoint p2(xyz2[0],xyz2[1],xyz2[2]); |
241 |
|
|
line li; |
242 |
|
|
li.pts[0]=p1; |
243 |
|
|
li.pts[1]=p2; |
244 |
|
|
data.add_line(li); |
245 |
|
|
OT_VECTEUR_3D vec(xyz1,xyz2); |
246 |
|
|
xg=xg+0.5*(xyz1[0]+xyz2[0])*vec.get_longueur(); |
247 |
|
|
yg=yg+0.5*(xyz1[1]+xyz2[1])*vec.get_longueur(); |
248 |
|
|
zg=zg+0.5*(xyz1[2]+xyz2[2])*vec.get_longueur(); |
249 |
|
|
deno=deno+vec.get_longueur(); |
250 |
|
|
} |
251 |
|
|
xg=xg/deno; |
252 |
|
|
yg=yg/deno; |
253 |
|
|
zg=zg/deno; |
254 |
|
|
std::map<double,MG_SEGMENT*> classeseg; |
255 |
|
|
for (int i=0;i<nbseg;i++) |
256 |
|
|
{ |
257 |
|
|
MG_SEGMENT* seg=(MG_SEGMENT*)are->get_lien_maillage()->get(i); |
258 |
francois |
358 |
if (mai->get_mg_segmentid(seg->get_id())!=seg) continue; |
259 |
francois |
353 |
double *xyz1=seg->get_noeud1()->get_coord(); |
260 |
|
|
double *xyz2=seg->get_noeud2()->get_coord(); |
261 |
|
|
double x=0.5*(xyz1[0]+xyz2[0]); |
262 |
|
|
double y=0.5*(xyz1[1]+xyz2[1]); |
263 |
|
|
double z=0.5*(xyz1[2]+xyz2[2]); |
264 |
|
|
OT_VECTEUR_3D vec(x-xg,y-yg,z-zg); |
265 |
|
|
classeseg.insert(std::pair<double,MG_SEGMENT*>(vec.get_longueur2(),seg)); |
266 |
|
|
} |
267 |
francois |
358 |
if (classeseg.size()>0) |
268 |
francois |
356 |
{ |
269 |
|
|
MG_SEGMENT* seg=classeseg.begin()->second; |
270 |
|
|
double *xyz1=seg->get_noeud1()->get_coord(); |
271 |
|
|
double *xyz2=seg->get_noeud2()->get_coord(); |
272 |
|
|
npoint p(0.5*(xyz1[0]+xyz2[0]),0.5*(xyz1[1]+xyz2[1]),0.5*(xyz1[2]+xyz2[2])); |
273 |
|
|
point pp; |
274 |
|
|
pp.pts=p; |
275 |
|
|
char mess[255]; |
276 |
|
|
if (idori==false) sprintf(mess,"E%lu",are->get_id()); else sprintf(mess,"%s",are->get_idoriginal().c_str()); |
277 |
|
|
pp.info=mess; |
278 |
|
|
std::pair<point,color> tmp(pp,ctext); |
279 |
|
|
data.add_text(1,tmp); |
280 |
|
|
} |
281 |
francois |
353 |
} |
282 |
|
|
|
283 |
|
|
|
284 |
|
|
ptr=data.getproppoints(); |
285 |
|
|
ptr.c=carete; |
286 |
francois |
358 |
ptr.pointsize=10; |
287 |
francois |
353 |
data.setproppoints(ptr); |
288 |
|
|
LISTE_MG_SOMMET::iterator its; |
289 |
|
|
for (MG_SOMMET* som=geo->get_premier_sommet(its);som!=NULL;som=geo->get_suivant_sommet(its)) |
290 |
|
|
{ |
291 |
|
|
int nbpoint=som->get_lien_maillage()->get_nb(); |
292 |
|
|
for (int i=0;i<nbpoint;i++) |
293 |
|
|
{ |
294 |
|
|
MG_NOEUD* nd=(MG_NOEUD*)som->get_lien_maillage()->get(i); |
295 |
francois |
358 |
if (mai->get_mg_noeudid(nd->get_id())!=nd) continue; |
296 |
francois |
654 |
color c=carete; |
297 |
|
|
int nbccf=nd->get_lien_topologie()->get_nb_ccf(); |
298 |
|
|
for (int i=0;i<nbccf;i++) |
299 |
|
|
{ |
300 |
|
|
char typ[2]; |
301 |
|
|
nd->get_lien_topologie()->get_type_ccf(i,typ); |
302 |
|
|
if (typ[0]=='D') c=cdeplacement; |
303 |
|
|
if (typ[0]=='R') c=cdeplacement; |
304 |
|
|
if (typ[0]=='F') c=cforce; |
305 |
|
|
if (typ[0]=='P') c=cpression; |
306 |
|
|
if (typ[0]=='T') c=ctemperature; |
307 |
|
|
if (typ[0]=='f') c=cflux; |
308 |
|
|
} |
309 |
|
|
ptr=data.getproppoints(); |
310 |
|
|
ptr.c=c; |
311 |
|
|
data.setproppoints(ptr); |
312 |
|
|
double *xyz1=nd->get_coord(); |
313 |
francois |
353 |
npoint p1(xyz1[0],xyz1[1],xyz1[2]); |
314 |
|
|
data.add_point(p1); |
315 |
|
|
point pp; |
316 |
|
|
pp.pts=p1; |
317 |
|
|
char mess[255]; |
318 |
francois |
356 |
if (idori==false) sprintf(mess,"V%lu",som->get_id()); else sprintf(mess,"%s",som->get_idoriginal().c_str()); |
319 |
francois |
353 |
pp.info=mess; |
320 |
|
|
std::pair<point,color> tmp(pp,ctext); |
321 |
|
|
data.add_text(0,tmp); |
322 |
|
|
} |
323 |
|
|
} |
324 |
|
|
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
}; |
329 |
|
|
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
|
|
int main(int argc,char **argv) |
337 |
|
|
{ |
338 |
|
|
color base=color(0,0,0); |
339 |
|
|
color carete(255,255,255); |
340 |
|
|
color cface(125,125,125); |
341 |
|
|
color ctext(255,255,255); |
342 |
francois |
654 |
color cdeplacement(255,151,1); |
343 |
|
|
color cforce(255,1,1); |
344 |
|
|
color cpression(33,249,13); |
345 |
|
|
color ctemperature(246,07,193); |
346 |
|
|
color cflux(252,250,03); |
347 |
|
|
|
348 |
francois |
353 |
char chemin[1000]; |
349 |
|
|
sprintf(chemin,"%s/.vtkdisplay",getenv("HOME")); |
350 |
|
|
FILE *in=fopen(chemin,"rt"); |
351 |
|
|
if (in!=NULL) |
352 |
|
|
{ |
353 |
|
|
char mess[255]; |
354 |
|
|
fgets(mess,255,in); |
355 |
|
|
int R,G,B; |
356 |
|
|
int nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
357 |
|
|
if (nb==3) base=color(R,G,B); |
358 |
|
|
if (!feof(in)) |
359 |
|
|
{ |
360 |
|
|
fgets(mess,255,in); |
361 |
|
|
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
362 |
|
|
if (nb==3) cface=color(R,G,B); |
363 |
|
|
if (!feof(in)) |
364 |
|
|
{ |
365 |
|
|
fgets(mess,255,in); |
366 |
|
|
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
367 |
|
|
if (nb==3) carete=color(R,G,B); |
368 |
|
|
if (!feof(in)) |
369 |
|
|
{ |
370 |
|
|
fgets(mess,255,in); |
371 |
|
|
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
372 |
|
|
if (nb==3) ctext=color(R,G,B); |
373 |
francois |
654 |
if (!feof(in)) |
374 |
|
|
{ |
375 |
|
|
fgets(mess,255,in); |
376 |
|
|
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
377 |
|
|
if (nb==3) cdeplacement=color(R,G,B); |
378 |
|
|
if (!feof(in)) |
379 |
|
|
{ |
380 |
|
|
fgets(mess,255,in); |
381 |
|
|
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
382 |
|
|
if (nb==3) cforce=color(R,G,B); |
383 |
|
|
if (!feof(in)) |
384 |
|
|
{ |
385 |
|
|
fgets(mess,255,in); |
386 |
|
|
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
387 |
|
|
if (nb==3) cpression=color(R,G,B); |
388 |
|
|
if (!feof(in)) |
389 |
|
|
{ |
390 |
|
|
fgets(mess,255,in); |
391 |
|
|
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
392 |
|
|
if (nb==3) ctemperature=color(R,G,B); |
393 |
|
|
if (!feof(in)) |
394 |
|
|
{ |
395 |
|
|
fgets(mess,255,in); |
396 |
|
|
nb=sscanf(mess,"%d %d %d",&R,&G,&B); |
397 |
|
|
if (nb==3) cflux=color(R,G,B); |
398 |
|
|
|
399 |
|
|
} |
400 |
|
|
} |
401 |
|
|
|
402 |
|
|
} |
403 |
|
|
|
404 |
|
|
} |
405 |
|
|
} |
406 |
francois |
353 |
} |
407 |
|
|
} |
408 |
|
|
} |
409 |
|
|
fclose(in); |
410 |
|
|
} |
411 |
|
|
printf("******************************\n"); |
412 |
|
|
printf("* Visualization *\n"); |
413 |
|
|
printf("* by *\n"); |
414 |
|
|
printf("* Jean-Christophe Cuillière *\n"); |
415 |
|
|
printf("* and *\n"); |
416 |
|
|
printf("* Vincent Francois *\n"); |
417 |
|
|
printf("* ERICCA-UQTR *\n"); |
418 |
|
|
printf("******************************\n\n\n"); |
419 |
|
|
|
420 |
francois |
356 |
|
421 |
|
|
|
422 |
cuillier |
354 |
if (!((argc==2) || (argc==3))) |
423 |
francois |
353 |
{ |
424 |
francois |
1061 |
printf("Visumagic syntax error - Bad number arguments\n visumagic.exe fichier [numero du maillage]\n\n"); |
425 |
francois |
353 |
return 0; |
426 |
|
|
|
427 |
|
|
} |
428 |
francois |
356 |
char fichier[255]; |
429 |
|
|
strcpy(fichier,argv[1]); |
430 |
|
|
|
431 |
|
|
char *p=strchr(fichier,'.'); |
432 |
|
|
char extension[255]; |
433 |
|
|
strcpy(extension,p+1); |
434 |
|
|
|
435 |
|
|
bool idori; |
436 |
|
|
MG_GESTIONNAIRE *gest; |
437 |
|
|
if ((strcmp(extension,"step")==0) || (strcmp(extension,"stp")==0) || (strcmp(extension,"STP")==0) || (strcmp(extension,"STEP")==0)) |
438 |
|
|
{ |
439 |
|
|
MG_GESTIONNAIRE *gest2=new MG_GESTIONNAIRE; |
440 |
|
|
OCC_IMPORT occimport; |
441 |
francois |
652 |
MG_GEOMETRIE* mggeo=occimport.importer(*gest2,fichier,FICHIERSTEP,1e-6) ; |
442 |
francois |
356 |
occimport.importer(*gest2,mggeo,1,2); |
443 |
|
|
gest=gest2; |
444 |
francois |
358 |
idori=false; |
445 |
|
|
if (strcmp(argv[argc-1],"-s")==0) |
446 |
|
|
{ |
447 |
|
|
*(p+1)='m'; |
448 |
|
|
*(p+2)='a'; |
449 |
|
|
*(p+3)='g'; |
450 |
|
|
*(p+4)='i'; |
451 |
|
|
*(p+5)='c'; |
452 |
|
|
*(p+6)=0; |
453 |
|
|
gest->enregistrer(fichier); |
454 |
|
|
} |
455 |
francois |
356 |
} |
456 |
|
|
else |
457 |
|
|
{ |
458 |
|
|
MG_FILE* gest2=new MG_FILE(fichier); |
459 |
|
|
gest=gest2; |
460 |
|
|
idori=false; |
461 |
|
|
} |
462 |
francois |
358 |
|
463 |
francois |
353 |
|
464 |
|
|
int num=0; |
465 |
|
|
if (argc==3) num=atoi(argv[2]); |
466 |
|
|
MG_GEOMETRIE* geo=gest->get_mg_geometrie(num); |
467 |
|
|
data_container data; |
468 |
francois |
358 |
MG_MAILLAGE* mai=NULL; |
469 |
|
|
int nbmai=gest->get_nb_mg_maillage(); |
470 |
|
|
bool sommet=false,arete=false,face=false; |
471 |
|
|
for (int i=0;i<nbmai;i++) |
472 |
|
|
{ |
473 |
|
|
bool sommettmp=false,aretetmp=false,facetmp=false; |
474 |
|
|
MG_MAILLAGE* maitmp=gest->get_mg_maillage(i); |
475 |
|
|
if (maitmp->get_nb_mg_noeud()>0) sommettmp=true; |
476 |
|
|
if (maitmp->get_nb_mg_segment()>0) aretetmp=true; |
477 |
|
|
if (maitmp->get_nb_mg_triangle()>0) facetmp=true; |
478 |
|
|
int nbtruetmp=0,nbtrue=0; |
479 |
|
|
if (sommet==true) nbtrue++; |
480 |
|
|
if (arete==true) nbtrue++; |
481 |
|
|
if (face==true) nbtrue++; |
482 |
|
|
if (sommettmp==true) nbtruetmp++; |
483 |
|
|
if (aretetmp==true) nbtruetmp++; |
484 |
|
|
if (facetmp==true) nbtruetmp++; |
485 |
|
|
if (nbtruetmp>nbtrue) |
486 |
|
|
{ |
487 |
|
|
mai=maitmp; |
488 |
|
|
sommet=sommettmp; |
489 |
|
|
arete=aretetmp; |
490 |
|
|
face=facetmp; |
491 |
|
|
} |
492 |
|
|
} |
493 |
francois |
353 |
printf("\n\n"); |
494 |
|
|
printf("Command on keyboard : \n"); |
495 |
|
|
printf(" e : End of vizualisation\n"); |
496 |
|
|
printf(" r : Reset Camera\n"); |
497 |
|
|
printf(" 1 : Vertex Numbers visible on/off\n"); |
498 |
|
|
printf(" 4 : Edge Numbers visible on/off\n"); |
499 |
|
|
printf(" 7 : Face Numbers visible on/off\n"); |
500 |
|
|
printf(" v : Vertices visible on/off\n"); |
501 |
|
|
printf(" l : Edges visible on/off\n"); |
502 |
|
|
printf(" t : Faces visible on/off\n"); |
503 |
|
|
printf(" j : Save camera on current directory\n"); |
504 |
|
|
printf(" k : Load camera from current directory\n"); |
505 |
|
|
printf(" w : Wireframe\n"); |
506 |
|
|
printf(" s : Modelframe\n"); |
507 |
francois |
358 |
printf(" - : Decrease text size\n"); |
508 |
|
|
printf(" + : Increase text size\n"); |
509 |
francois |
1116 |
printf(" 5 : Clipping plane off\n"); |
510 |
|
|
printf(" 8 : Clipping plane forward\n"); |
511 |
|
|
printf(" 9 : Clipping plane backward\n"); |
512 |
francois |
353 |
|
513 |
francois |
356 |
char titre [500]; |
514 |
francois |
353 |
strcpy(titre,"Visumagic "); |
515 |
francois |
356 |
strcat(titre,fichier); |
516 |
francois |
654 |
if (mai!=NULL) affiche_structure(cface,carete,ctext,cdeplacement,cforce,cpression,ctemperature,cflux,geo,mai,data,idori); |
517 |
francois |
356 |
delete gest; |
518 |
francois |
353 |
|
519 |
francois |
1061 |
vtkdisplay d(base,titre); |
520 |
francois |
353 |
|
521 |
|
|
|
522 |
|
|
|
523 |
|
|
|
524 |
|
|
d.init_data(data); |
525 |
francois |
1018 |
d.display(); |
526 |
francois |
353 |
|
527 |
francois |
356 |
|
528 |
francois |
353 |
return 0; |
529 |
|
|
} |
530 |
|
|
|
531 |
|
|
|
532 |
|
|
|
533 |
francois |
1061 |
|