ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/app/mgoperation/src/visuorigine.cpp
Revision: 792
Committed: Mon Mar 21 21:35:52 2016 UTC (9 years, 2 months ago) by francois
File size: 10921 byte(s)
Log Message:
tag des noeuds pouvant former une arete lors du post traitement de topo_optis
+ noueau visualisateur des ORIGINE qui permet de voir aussi les tag origines des noeuds, GMSH ne le fait pas.

File Contents

# User Rev Content
1 francois 792 //------------------------------------------------------------
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     #ifdef WINDOWS_VERSION
25     #include "fenetre.h"
26     #endif
27    
28     #pragma hdrstop
29     #include <iostream>
30     #include "ndisplay.h"
31     #include "nutil.h"
32     #include "mg_file.h"
33     #include "occ_import.h"
34     #include <map>
35     //---------------------------------------------------------------------------
36    
37     void affiche(char* message)
38     {
39     #ifdef WINDOWS_VERSION
40     Form1->Memo1->Lines->Add(message);
41     #else
42     std::cout << message << std::endl;
43     #endif
44     }
45    
46    
47    
48    
49     void affiche_structure(color cface,color carete,color ctext,color cdeplacement,color cforce,color cpression,color ctemperature, color cflux,MG_MAILLAGE* mai,data_container &data)
50     {
51     vector<color> tabcouleur;
52     color one(191,253,181);
53     color two(255,160,0);
54     color three(253,35,16);
55     color four(255,200,0);
56     color five(0,216,255);
57     color six(0,52,255);
58     color seven(0,176,255);
59     color eight(228,255,0);
60     color nine(0,116,255);
61     color ten(188,255,0);
62     color eleven(184,0,255);
63     color twelve(255,120,0);
64     tabcouleur.push_back(one);
65     tabcouleur.push_back(two);
66     tabcouleur.push_back(three);
67     tabcouleur.push_back(four);
68     tabcouleur.push_back(five);
69     tabcouleur.push_back(six);
70     tabcouleur.push_back(seven);
71     tabcouleur.push_back(eight);
72     tabcouleur.push_back(nine);
73     tabcouleur.push_back(ten);
74     tabcouleur.push_back(eleven);
75     tabcouleur.push_back(twelve);
76    
77    
78     properties ptr=data.getproptriangles();
79     ptr.c=cface;
80     ptr.edgeon=true;
81     ptr.edgecolor=carete;
82     ptr.edgethickness=1;
83     data.setproptriangles(ptr);
84     LISTE_MG_TRIANGLE::iterator ittri;
85     for (MG_TRIANGLE* tri=mai->get_premier_triangle(ittri);tri!=NULL;tri=mai->get_suivant_triangle(ittri))
86     {
87     properties ptr=data.getproptriangles();
88    
89     ptr.c=tabcouleur[(tri->get_origine()-1000)/10];
90     data.setproptriangles(ptr);
91     double *xyz1=tri->get_noeud1()->get_coord();
92     double *xyz2=tri->get_noeud2()->get_coord();
93     double *xyz3=tri->get_noeud3()->get_coord();
94     npoint p1(xyz1[0],xyz1[1],xyz1[2]);
95     npoint p2(xyz2[0],xyz2[1],xyz2[2]);
96     npoint p3(xyz3[0],xyz3[1],xyz3[2]);
97     triangle tr;
98     tr.pts[0]=p1;
99     tr.pts[1]=p2;
100     tr.pts[2]=p3;
101     data.add_triangle(tr);
102     OT_VECTEUR_3D vec1(xyz1,xyz2);
103     OT_VECTEUR_3D vec2(xyz1,xyz3);
104     OT_VECTEUR_3D sur=vec1&vec2;
105     double xg=0.,yg=0.,zg=0.,deno=0.;
106     xg=xg+0.3333333333*(xyz1[0]+xyz2[0]+xyz3[0])*sur.get_longueur();
107     yg=yg+0.3333333333*(xyz1[1]+xyz2[1]+xyz3[1])*sur.get_longueur();
108     zg=zg+0.3333333333*(xyz1[2]+xyz2[2]+xyz3[2])*sur.get_longueur();
109     deno=deno+sur.get_longueur();
110     xg=xg/deno;
111     yg=yg/deno;
112     zg=zg/deno;
113     npoint p(xg,yg,zg);
114     point pp;
115     pp.pts=p;
116     char mess[255];
117     sprintf(mess,"%lu",tri->get_id());
118     pp.info=mess;
119     std::pair<point,color> tmp(pp,ctext);
120     //data.add_text(2,tmp);
121     }
122    
123     ptr=data.getpropquads();
124     ptr.c=cface;
125     ptr.edgeon=true;
126     ptr.edgecolor=carete;
127     ptr.edgethickness=1;
128     data.setpropquads(ptr);
129     LISTE_MG_QUADRANGLE::iterator itqua;
130     for (MG_QUADRANGLE* qua=mai->get_premier_quadrangle(itqua);qua!=NULL;qua=mai->get_suivant_quadrangle(itqua))
131     {
132     properties ptr=data.getpropquads();
133    
134     ptr.c=tabcouleur[(qua->get_origine()-1000)/10];
135     data.setpropquads(ptr);
136     double *xyz1=qua->get_noeud1()->get_coord();
137     double *xyz2=qua->get_noeud2()->get_coord();
138     double *xyz3=qua->get_noeud3()->get_coord();
139     double *xyz4=qua->get_noeud4()->get_coord();
140     npoint p1(xyz1[0],xyz1[1],xyz1[2]);
141     npoint p2(xyz2[0],xyz2[1],xyz2[2]);
142     npoint p3(xyz3[0],xyz3[1],xyz3[2]);
143     npoint p4(xyz4[0],xyz4[1],xyz4[2]);
144     quad qu;
145     qu.pts[0]=p1;
146     qu.pts[1]=p2;
147     qu.pts[2]=p3;
148     qu.pts[3]=p4;
149     data.add_quad(qu);
150     OT_VECTEUR_3D vec1(xyz1,xyz2);
151     OT_VECTEUR_3D vec2(xyz1,xyz3);
152     OT_VECTEUR_3D sur=vec1&vec2;
153     double xg=0.,yg=0.,zg=0.,deno=0.;
154     xg=xg+0.25*(xyz1[0]+xyz2[0]+xyz3[0]+xyz4[0])*sur.get_longueur();
155     yg=yg+0.25*(xyz1[1]+xyz2[1]+xyz3[1]+xyz4[1])*sur.get_longueur();
156     zg=zg+0.25*(xyz1[2]+xyz2[2]+xyz3[2]+xyz4[2])*sur.get_longueur();
157     deno=deno+sur.get_longueur();
158     xg=xg/deno;
159     yg=yg/deno;
160     zg=zg/deno;
161     npoint p(xg,yg,zg);
162     point pp;
163     pp.pts=p;
164     char mess[255];
165     sprintf(mess,"%lu",qua->get_id());
166     pp.info=mess;
167     std::pair<point,color> tmp(pp,ctext);
168     //data.add_text(2,tmp);
169     }
170    
171     ptr=data.getproplines();
172     ptr.c=carete;
173     ptr.edgethickness=2;
174     data.setproplines(ptr);
175     LISTE_MG_SEGMENT::iterator itseg;
176     for (MG_SEGMENT* seg=mai->get_premier_segment(itseg);seg!=NULL;seg=mai->get_suivant_segment(itseg))
177     {
178     if (seg->get_lien_topologie()!=NULL)
179     if (seg->get_lien_topologie()->get_dimension()!=1) continue;
180     properties ptr=data.getproplines();
181     ptr.c=tabcouleur[(seg->get_origine()-1000)/10];
182     data.setproplines(ptr);
183     double *xyz1=seg->get_noeud1()->get_coord();
184     double *xyz2=seg->get_noeud2()->get_coord();
185     npoint p1(xyz1[0],xyz1[1],xyz1[2]);
186     npoint p2(xyz2[0],xyz2[1],xyz2[2]);
187     line li;
188     li.pts[0]=p1;
189     li.pts[1]=p2;
190     data.add_line(li);
191     OT_VECTEUR_3D vec1(xyz1,xyz2);
192     double xg=0.,yg=0.,zg=0.,deno=0.;
193     xg=xg+0.5*(xyz1[0]+xyz2[0])*vec1.get_longueur();
194     yg=yg+0.5*(xyz1[1]+xyz2[1])*vec1.get_longueur();
195     zg=zg+0.5*(xyz1[2]+xyz2[2])*vec1.get_longueur();
196     deno=deno+vec1.get_longueur();
197     xg=xg/deno;
198     yg=yg/deno;
199     zg=zg/deno;
200     npoint p(xg,yg,zg);
201     point pp;
202     pp.pts=p;
203     char mess[255];
204     sprintf(mess,"%lu",seg->get_id());
205     pp.info=mess;
206     std::pair<point,color> tmp(pp,ctext);
207     //data.add_text(1,tmp);
208     }
209    
210    
211    
212     ptr=data.getproppoints();
213     ptr.pointsize=10;
214     data.setproppoints(ptr);
215     LISTE_MG_NOEUD::iterator itno;
216     for (MG_NOEUD* no=mai->get_premier_noeud(itno);no!=NULL;no=mai->get_suivant_noeud(itno))
217     {
218     properties ptr=data.getproppoints();
219     ptr.c=tabcouleur[(no->get_origine()-1000)/10];
220     data.setproppoints(ptr);
221     double *xyz=no->get_coord();
222     npoint p1(xyz[0],xyz[1],xyz[2]);
223     data.add_point(p1);
224     char mess[255];
225     sprintf(mess,"%lu",no->get_id());
226     point pp;
227     pp.pts=p1;
228     pp.info=mess;
229     std::pair<point,color> tmp(pp,ctext);
230     //data.add_text(0,tmp);
231     }
232    
233     };
234    
235    
236    
237    
238    
239    
240    
241     #ifdef WINDOWS_VERSION
242     int amain(int argc,char **argv)
243     #else
244     int main(int argc,char **argv)
245     #endif
246     {
247     color base=color(0,0,0);
248     color carete(255,255,255);
249     color cface(125,125,125);
250     color ctext(255,255,255);
251     color cdeplacement(255,151,1);
252     color cforce(255,1,1);
253     color cpression(33,249,13);
254     color ctemperature(246,07,193);
255     color cflux(252,250,03);
256    
257     char chemin[1000];
258     sprintf(chemin,"%s/.vtkdisplay",getenv("HOME"));
259     FILE *in=fopen(chemin,"rt");
260     if (in!=NULL)
261     {
262     char mess[255];
263     fgets(mess,255,in);
264     int R,G,B;
265     int nb=sscanf(mess,"%d %d %d",&R,&G,&B);
266     if (nb==3) base=color(R,G,B);
267     if (!feof(in))
268     {
269     fgets(mess,255,in);
270     nb=sscanf(mess,"%d %d %d",&R,&G,&B);
271     if (nb==3) cface=color(R,G,B);
272     if (!feof(in))
273     {
274     fgets(mess,255,in);
275     nb=sscanf(mess,"%d %d %d",&R,&G,&B);
276     if (nb==3) carete=color(R,G,B);
277     if (!feof(in))
278     {
279     fgets(mess,255,in);
280     nb=sscanf(mess,"%d %d %d",&R,&G,&B);
281     if (nb==3) ctext=color(R,G,B);
282     if (!feof(in))
283     {
284     fgets(mess,255,in);
285     nb=sscanf(mess,"%d %d %d",&R,&G,&B);
286     if (nb==3) cdeplacement=color(R,G,B);
287     if (!feof(in))
288     {
289     fgets(mess,255,in);
290     nb=sscanf(mess,"%d %d %d",&R,&G,&B);
291     if (nb==3) cforce=color(R,G,B);
292     if (!feof(in))
293     {
294     fgets(mess,255,in);
295     nb=sscanf(mess,"%d %d %d",&R,&G,&B);
296     if (nb==3) cpression=color(R,G,B);
297     if (!feof(in))
298     {
299     fgets(mess,255,in);
300     nb=sscanf(mess,"%d %d %d",&R,&G,&B);
301     if (nb==3) ctemperature=color(R,G,B);
302     if (!feof(in))
303     {
304     fgets(mess,255,in);
305     nb=sscanf(mess,"%d %d %d",&R,&G,&B);
306     if (nb==3) cflux=color(R,G,B);
307    
308     }
309     }
310    
311     }
312    
313     }
314     }
315     }
316     }
317     }
318     fclose(in);
319     }
320     printf("******************************\n");
321     printf("* Origine Visualization *\n");
322     printf("* by *\n");
323     printf("* Jean-Christophe Cuillière *\n");
324     printf("* and *\n");
325     printf("* Vincent Francois *\n");
326     printf("* ERICCA-UQTR *\n");
327     printf("******************************\n\n\n");
328    
329    
330    
331     if (!((argc==2) || (argc==3)))
332     {
333     printf("Visumagic syntax error - Bad number arguments\n\n");
334     return 0;
335    
336     }
337     char fichier[255];
338     strcpy(fichier,argv[1]);
339    
340     char *p=strchr(fichier,'.');
341     char extension[255];
342     strcpy(extension,p+1);
343    
344     MG_GESTIONNAIRE *gest;
345     MG_FILE* gest2=new MG_FILE(fichier);
346     gest=gest2;
347    
348    
349     int num=0;
350     if (argc==3) num=atoi(argv[2]);
351     data_container data;
352     MG_MAILLAGE* mai=gest->get_mg_maillage(num);
353     char titre [500];
354     printf("\n\n");
355     printf("Command on keyboard : \n");
356     printf(" e : End of vizualisation\n");
357     printf(" r : Reset Camera\n");
358     printf(" 1 : Vertex Numbers visible on/off\n");
359     printf(" 4 : Edge Numbers visible on/off\n");
360     printf(" 7 : Face Numbers visible on/off\n");
361     printf(" v : Vertices visible on/off\n");
362     printf(" l : Edges visible on/off\n");
363     printf(" t : Faces visible on/off\n");
364     printf(" j : Save camera on current directory\n");
365     printf(" k : Load camera from current directory\n");
366     printf(" w : Wireframe\n");
367     printf(" s : Modelframe\n");
368     printf(" - : Decrease text size\n");
369     printf(" + : Increase text size\n");
370    
371     strcpy(titre,"Visuorimagic ");
372     strcat(titre,fichier);
373     if (mai!=NULL) affiche_structure(cface,carete,ctext,cdeplacement,cforce,cpression,ctemperature,cflux,mai,data);
374     delete gest;
375    
376     ndisplay d(base,titre);
377    
378    
379    
380    
381     d.init_data(data);
382     d.display(true);
383    
384    
385     return 0;
386     }
387    
388    
389    
390     #pragma package(smart_init)