ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/app/compare/src/visumain.cpp
Revision: 353
Committed: Mon Aug 6 19:16:47 2012 UTC (12 years, 9 months ago) by francois
File size: 22286 byte(s)
Log Message:
Visu pour comparateur + visu generale des fichiers magic + correction importation triangulation dans OCC

File Contents

# User Rev Content
1 francois 351 //------------------------------------------------------------
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 "vtkdisplay.h"
31     #include "nutil.h"
32     #include "mg_file.h"
33     #include <map>
34     //---------------------------------------------------------------------------
35    
36     void affiche(char* message)
37     {
38     #ifdef WINDOWS_VERSION
39     Form1->Memo1->Lines->Add(message);
40     #else
41     std::cout << message << std::endl;
42     #endif
43     }
44    
45    
46    
47     struct groupe_couleur
48     {
49     int num;
50     std::map<unsigned long,unsigned long> A;
51     std::map<unsigned long,unsigned long> B;
52     bool est_dans_A(unsigned long val)
53     {
54     std::map<unsigned long,unsigned long>::iterator it=A.find(val);
55     if (it!=A.end()) return true;
56     return false;
57     };
58     bool est_dans_B(unsigned long val)
59     {
60     std::map<unsigned long,unsigned long>::iterator it=B.find(val);
61     if (it!=B.end()) return true;
62     return false;
63     };
64     };
65    
66    
67    
68     struct data_fichier
69     {
70     std::string nomA;
71     std::string nomB;
72     std::map<int,groupe_couleur> list_face_similaire;
73     std::map<int,groupe_couleur> list_face_identique;
74     std::map<int,groupe_couleur> list_face_localise;
75     std::map<int,groupe_couleur> list_arete_localise;
76     std::map<int,groupe_couleur> list_sommet_localise;
77     std::map<int,groupe_couleur> list_face_modifie;
78     std::map<int,groupe_couleur> list_arete_modifie;
79     };
80    
81    
82     void ini_couleur(std::vector<color> &tabcoul,int dim)
83     {
84     int ecart=255/(dim+1);
85     std::map<int,int> list;
86     for (int i=0;i<dim*dim*dim;i++)
87     {
88     int r=rand()%dim+1;
89     int g=rand()%dim+1;
90     int b=rand()%dim+1;
91     int c=r*ecart+255*g*ecart+255*255*b*ecart;
92     std::pair<int,int> tmp(c,c);
93     std::pair<std::map<int,int>::iterator,bool> ret=list.insert(tmp);
94     if (ret.second==false) i--;
95     else
96     {
97     color cc(r*ecart,g*ecart,b*ecart);
98     tabcoul.push_back(cc);
99     }
100     }
101     }
102    
103    
104    
105     void ajouter_liste_couleur(std::map<int,groupe_couleur> &list,unsigned long valA,unsigned long valB)
106     {
107     static int num_couleur=0;
108     std::map<int,groupe_couleur>::iterator it;
109     for (it=list.begin();it!=list.end();it++)
110     {
111     bool res=it->second.est_dans_A(valA);
112     if (res==true)
113     {
114     it->second.A.insert(std::pair<unsigned long,unsigned long>(valA,valA));
115     it->second.B.insert(std::pair<unsigned long,unsigned long>(valB,valB));
116     return;
117     }
118    
119     res=it->second.est_dans_B(valB);
120     if (res==true)
121     {
122     it->second.A.insert(std::pair<unsigned long,unsigned long>(valA,valA));
123     it->second.B.insert(std::pair<unsigned long,unsigned long>(valB,valB));
124     return;
125     }
126    
127     }
128     groupe_couleur gc;
129     std::pair<std::map<int,groupe_couleur>::iterator,bool> ret=list.insert(std::pair<int,groupe_couleur>(num_couleur,gc));
130     ret.first->second.num=num_couleur;
131     ret.first->second.A.insert(std::pair<unsigned long,unsigned long>(valA,valA));
132     ret.first->second.B.insert(std::pair<unsigned long,unsigned long>(valB,valB));
133     num_couleur++;
134     }
135    
136    
137     void lire_fichier(char *nom,data_fichier &data)
138     {
139     FILE* in=fopen(nom,"rt");
140    
141     while (!feof(in))
142     {
143     char mess[255],mess2[255];
144     fgets(mess,255,in);
145     if (strlen(mess)>1)
146     if (mess[0]=='/')
147     if (mess[1]=='/') continue;
148     if (strcmp(mess,"Model A:\n")==0)
149     {
150     fgets(mess,255,in);
151     sscanf(mess,"%s",mess2);
152     data.nomA=mess2;
153     }
154     else if (strcmp(mess,"Model B:\n")==0)
155     {
156     fgets(mess,255,in);
157     sscanf(mess,"%s",mess2);
158     data.nomB=mess2;
159     }
160     else
161     {
162     char mot1[255],mot2[255],mot3[255];
163     int nb;
164     int n=sscanf(mess,"%d %s %s %s",&nb,mot1,mot2,mot3);
165     std::map<int,groupe_couleur> *list=NULL;
166     if (n>2)
167     {
168     if (strcmp(mot1,"Similar")==0)
169     if (strcmp(mot2,"faces")==0)
170     list= &(data.list_face_similaire);
171     if (strcmp(mot1,"Identical")==0)
172     if (strcmp(mot2,"faces")==0)
173     list= &(data.list_face_identique);
174     if (strcmp(mot1,"Localized")==0)
175     if (strcmp(mot2,"identical")==0)
176     if (strcmp(mot3,"faces")==0)
177     list=&(data.list_face_localise);
178     if (strcmp(mot1,"Localized")==0)
179     if (strcmp(mot2,"identical")==0)
180     if (strcmp(mot3,"edges")==0)
181     list=&(data.list_arete_localise);
182     if (strcmp(mot1,"Localized")==0)
183     if (strcmp(mot2,"identical")==0)
184     if (strcmp(mot3,"vertices")==0)
185     list=&(data.list_sommet_localise);
186     if (strcmp(mot1,"Localized")==0)
187     if (strcmp(mot2,"modified")==0)
188     if (strcmp(mot3,"faces")==0)
189     list=&(data.list_face_modifie);
190     if (strcmp(mot1,"Localized")==0)
191     if (strcmp(mot2,"modified")==0)
192     if (strcmp(mot3,"edges")==0)
193     list=&(data.list_arete_modifie);
194     if (list!=NULL)
195     for (int i=0;i<nb;i++)
196     {
197     fgets(mess,255,in);
198     unsigned long valA,valB;
199     sscanf(mess,"%lu %lu%",&valA,&valB);
200     ajouter_liste_couleur(*list,valA,valB);
201     }
202     }
203     }
204    
205    
206    
207     }
208    
209    
210    
211     fclose(in);
212     }
213    
214    
215 francois 353 void affiche_structure(color base,MG_GEOMETRIE* geo,bool A,std::vector<color> &tabcoul,data_container &data, std::map<int,groupe_couleur> &list_face, std::map<int,groupe_couleur> &list_arete, std::map<int,groupe_couleur> &list_sommet)
216 francois 351 {
217     unsigned long nb1=geo->get_mg_face(geo->get_nb_mg_face()-1)->get_id();
218     unsigned long nb2=geo->get_mg_arete(geo->get_nb_mg_arete()-1)->get_id();
219     unsigned long nb3=geo->get_mg_sommet(geo->get_nb_mg_sommet()-1)->get_id();
220     int nbid=nb1;
221     if (nb2>nbid) nbid=nb2;
222     if (nb3>nbid) nbid=nb3;
223     nbid=nbid+5;
224     bool affiche[nbid];
225     for (int i=0;i<nbid;i++)
226     affiche[i]=false;
227     std::map<int,groupe_couleur>::iterator it;
228     for (it=list_face.begin();it!=list_face.end();it++)
229     {
230     groupe_couleur gc=it->second;
231     properties ptr=data.getproptriangles();
232 francois 353 ptr.c=color(tabcoul[gc.num].R,tabcoul[gc.num].G,tabcoul[gc.num].B,255);
233 francois 351 ptr.edgeon=false;
234     data.setproptriangles(ptr);
235     std::map<unsigned long,unsigned long>::iterator it2;
236     std::map<unsigned long,unsigned long> *tmp;
237     if (A==true) tmp=&(gc.A);
238     else tmp=&(gc.B);
239    
240     for (it2=tmp->begin();it2!=tmp->end();it2++)
241     {
242     MG_FACE* face=geo->get_mg_faceid(it2->second);
243     affiche[face->get_id()]=true;
244 francois 353 double xg=0.,yg=0.,zg=0.,deno=0.;
245 francois 351 int nbtri=face->get_lien_maillage()->get_nb();
246     for (int i=0;i<nbtri;i++)
247     {
248     MG_TRIANGLE* tri=(MG_TRIANGLE*)face->get_lien_maillage()->get(i);
249     double *xyz1=tri->get_noeud1()->get_coord();
250     double *xyz2=tri->get_noeud2()->get_coord();
251     double *xyz3=tri->get_noeud3()->get_coord();
252     npoint p1(xyz1[0],xyz1[1],xyz1[2]);
253     npoint p2(xyz2[0],xyz2[1],xyz2[2]);
254     npoint p3(xyz3[0],xyz3[1],xyz3[2]);
255     triangle tr;
256     tr.pts[0]=p1;
257     tr.pts[1]=p2;
258     tr.pts[2]=p3;
259     data.add_triangle(tr);
260 francois 353 OT_VECTEUR_3D vec1(xyz1,xyz2);
261     OT_VECTEUR_3D vec2(xyz1,xyz3);
262     OT_VECTEUR_3D sur=vec1&vec2;
263     xg=xg+0.3333333333*(xyz1[0]+xyz2[0]+xyz3[0])*sur.get_longueur();
264     yg=yg+0.3333333333*(xyz1[1]+xyz2[1]+xyz3[1])*sur.get_longueur();
265     zg=zg+0.3333333333*(xyz1[2]+xyz2[2]+xyz3[2])*sur.get_longueur();
266     deno=deno+sur.get_longueur();
267 francois 351 }
268 francois 353 xg=xg/deno;
269     yg=yg/deno;
270     zg=zg/deno;
271     std::map<double,MG_TRIANGLE*> classetri;
272     for (int i=0;i<nbtri;i++)
273     {
274     MG_TRIANGLE* tri=(MG_TRIANGLE*)face->get_lien_maillage()->get(i);
275     double *xyz1=tri->get_noeud1()->get_coord();
276     double *xyz2=tri->get_noeud2()->get_coord();
277     double *xyz3=tri->get_noeud3()->get_coord();
278     double x=0.3333333333*(xyz1[0]+xyz2[0]+xyz3[0]);
279     double y=0.3333333333*(xyz1[1]+xyz2[1]+xyz3[1]);
280     double z=0.3333333333*(xyz1[2]+xyz2[2]+xyz3[2]);
281     OT_VECTEUR_3D vec(x-xg,y-yg,z-zg);
282     classetri.insert(std::pair<double,MG_TRIANGLE*>(vec.get_longueur2(),tri));
283     }
284     MG_TRIANGLE *tri=classetri.begin()->second;
285     double *xyz1=tri->get_noeud1()->get_coord();
286     double *xyz2=tri->get_noeud2()->get_coord();
287     double *xyz3=tri->get_noeud3()->get_coord();
288     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]));
289     point pp;
290     pp.pts=p;
291     char mess[255];
292     sprintf(mess,"F%lu",face->get_id());
293     pp.info=mess;
294     color cc=color(255-ptr.c.R,255-ptr.c.G,255-ptr.c.B);
295     std::pair<point,color> tmp(pp,cc);
296     data.add_text(2,tmp);
297 francois 351 }
298     }
299     properties ptr=data.getproptriangles();
300 francois 353 ptr.c=base;
301 francois 351 ptr.edgeon=false;
302     data.setproptriangles(ptr);
303     LISTE_MG_FACE::iterator itface;
304     for (MG_FACE* face=geo->get_premier_face(itface);face!=NULL;face=geo->get_suivant_face(itface))
305     {
306     if (affiche[face->get_id()]==true) continue;
307     affiche[face->get_id()]=true;
308     int nbtri=face->get_lien_maillage()->get_nb();
309 francois 353 double xg=0.,yg=0.,zg=0.,deno=0.;
310 francois 351 for (int i=0;i<nbtri;i++)
311     {
312     MG_TRIANGLE* tri=(MG_TRIANGLE*)face->get_lien_maillage()->get(i);
313     double *xyz1=tri->get_noeud1()->get_coord();
314     double *xyz2=tri->get_noeud2()->get_coord();
315     double *xyz3=tri->get_noeud3()->get_coord();
316     npoint p1(xyz1[0],xyz1[1],xyz1[2]);
317     npoint p2(xyz2[0],xyz2[1],xyz2[2]);
318     npoint p3(xyz3[0],xyz3[1],xyz3[2]);
319     triangle tr;
320     tr.pts[0]=p1;
321     tr.pts[1]=p2;
322     tr.pts[2]=p3;
323     data.add_triangle(tr);
324 francois 353 OT_VECTEUR_3D vec1(xyz1,xyz2);
325     OT_VECTEUR_3D vec2(xyz1,xyz3);
326     OT_VECTEUR_3D sur=vec1&vec2;
327     xg=xg+0.3333333333*(xyz1[0]+xyz2[0]+xyz3[0])*sur.get_longueur();
328     yg=yg+0.3333333333*(xyz1[1]+xyz2[1]+xyz3[1])*sur.get_longueur();
329     zg=zg+0.3333333333*(xyz1[2]+xyz2[2]+xyz3[2])*sur.get_longueur();
330     deno=deno+sur.get_longueur();
331 francois 351 }
332 francois 353 xg=xg/deno;
333     yg=yg/deno;
334     zg=zg/deno;
335     std::map<double,MG_TRIANGLE*> classetri;
336     for (int i=0;i<nbtri;i++)
337     {
338     MG_TRIANGLE* tri=(MG_TRIANGLE*)face->get_lien_maillage()->get(i);
339     double *xyz1=tri->get_noeud1()->get_coord();
340     double *xyz2=tri->get_noeud2()->get_coord();
341     double *xyz3=tri->get_noeud3()->get_coord();
342     double x=0.3333333333*(xyz1[0]+xyz2[0]+xyz3[0]);
343     double y=0.3333333333*(xyz1[1]+xyz2[1]+xyz3[1]);
344     double z=0.3333333333*(xyz1[2]+xyz2[2]+xyz3[2]);
345     OT_VECTEUR_3D vec(x-xg,y-yg,z-zg);
346     classetri.insert(std::pair<double,MG_TRIANGLE*>(vec.get_longueur2(),tri));
347     }
348     MG_TRIANGLE *tri=classetri.begin()->second;
349     double *xyz1=tri->get_noeud1()->get_coord();
350     double *xyz2=tri->get_noeud2()->get_coord();
351     double *xyz3=tri->get_noeud3()->get_coord();
352     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]));
353     point pp;
354     pp.pts=p;
355     char mess[255];
356     sprintf(mess,"F%lu",face->get_id());
357     pp.info=mess;
358     color cc=color(255-ptr.c.R,255-ptr.c.G,255-ptr.c.B);
359     std::pair<point,color> tmp(pp,cc);
360     data.add_text(2,tmp);
361     }
362 francois 351
363    
364     for (it=list_arete.begin();it!=list_arete.end();it++)
365     {
366     groupe_couleur gc=it->second;
367     properties ptr=data.getproplines();
368     ptr.c=tabcoul[gc.num];
369     ptr.thickness=5;
370     data.setproplines(ptr);
371     std::map<unsigned long,unsigned long>::iterator it2;
372     std::map<unsigned long,unsigned long> *tmp;
373     if (A==true) tmp=&(gc.A);
374     else tmp=&(gc.B);
375    
376     for (it2=tmp->begin();it2!=tmp->end();it2++)
377     {
378     MG_ARETE* are=geo->get_mg_areteid(it2->second);
379     affiche[are->get_id()]=true;
380     int nbseg=are->get_lien_maillage()->get_nb();
381 francois 353 double xg=0.,yg=0.,zg=0.,deno=0.;
382 francois 351 for (int i=0;i<nbseg;i++)
383     {
384     MG_SEGMENT* seg=(MG_SEGMENT*)are->get_lien_maillage()->get(i);
385     double *xyz1=seg->get_noeud1()->get_coord();
386     double *xyz2=seg->get_noeud2()->get_coord();
387     npoint p1(xyz1[0],xyz1[1],xyz1[2]);
388     npoint p2(xyz2[0],xyz2[1],xyz2[2]);
389     line li;
390     li.pts[0]=p1;
391     li.pts[1]=p2;
392     data.add_line(li);
393 francois 353 OT_VECTEUR_3D vec(xyz1,xyz2);
394     xg=xg+0.5*(xyz1[0]+xyz2[0])*vec.get_longueur();
395     yg=yg+0.5*(xyz1[1]+xyz2[1])*vec.get_longueur();
396     zg=zg+0.5*(xyz1[2]+xyz2[2])*vec.get_longueur();
397     deno=deno+vec.get_longueur();
398 francois 351 }
399 francois 353 xg=xg/deno;
400     yg=yg/deno;
401     zg=zg/deno;
402     std::map<double,MG_SEGMENT*> classeseg;
403     for (int i=0;i<nbseg;i++)
404     {
405     MG_SEGMENT* seg=(MG_SEGMENT*)are->get_lien_maillage()->get(i);
406     double *xyz1=seg->get_noeud1()->get_coord();
407     double *xyz2=seg->get_noeud2()->get_coord();
408     double x=0.5*(xyz1[0]+xyz2[0]);
409     double y=0.5*(xyz1[1]+xyz2[1]);
410     double z=0.5*(xyz1[2]+xyz2[2]);
411     OT_VECTEUR_3D vec(x-xg,y-yg,z-zg);
412     classeseg.insert(std::pair<double,MG_SEGMENT*>(vec.get_longueur2(),seg));
413     }
414     MG_SEGMENT* seg=classeseg.begin()->second;
415     double *xyz1=seg->get_noeud1()->get_coord();
416     double *xyz2=seg->get_noeud2()->get_coord();
417     npoint p(0.5*(xyz1[0]+xyz2[0]),0.5*(xyz1[1]+xyz2[1]),0.5*(xyz1[2]+xyz2[2]));
418     point pp;
419     pp.pts=p;
420     char mess[255];
421     sprintf(mess,"E%lu",are->get_id());
422     pp.info=mess;
423     color cc=color(ptr.c.R,ptr.c.G,ptr.c.B);
424     std::pair<point,color> tmp(pp,cc);
425     data.add_text(1,tmp);
426 francois 351 }
427     }
428     ptr=data.getproplines();
429 francois 353 ptr.c=color(255-base.R,255-base.G,255-base.B);
430 francois 351 ptr.thickness=2;
431     data.setproplines(ptr);
432     LISTE_MG_ARETE::iterator itare;
433     for (MG_ARETE* are=geo->get_premier_arete(itare);are!=NULL;are=geo->get_suivant_arete(itare))
434     {
435     if (affiche[are->get_id()]==true) continue;
436     affiche[are->get_id()]=true;
437     int nbseg=are->get_lien_maillage()->get_nb();
438 francois 353 double xg=0.,yg=0.,zg=0.,deno=0.;
439     for (int i=0;i<nbseg;i++)
440 francois 351 {
441     MG_SEGMENT* seg=(MG_SEGMENT*)are->get_lien_maillage()->get(i);
442     double *xyz1=seg->get_noeud1()->get_coord();
443     double *xyz2=seg->get_noeud2()->get_coord();
444     npoint p1(xyz1[0],xyz1[1],xyz1[2]);
445     npoint p2(xyz2[0],xyz2[1],xyz2[2]);
446     line li;
447     li.pts[0]=p1;
448     li.pts[1]=p2;
449     data.add_line(li);
450 francois 353 OT_VECTEUR_3D vec(xyz1,xyz2);
451     xg=xg+0.5*(xyz1[0]+xyz2[0])*vec.get_longueur();
452     yg=yg+0.5*(xyz1[1]+xyz2[1])*vec.get_longueur();
453     zg=zg+0.5*(xyz1[2]+xyz2[2])*vec.get_longueur();
454     deno=deno+vec.get_longueur();
455 francois 351 }
456 francois 353 xg=xg/deno;
457     yg=yg/deno;
458     zg=zg/deno;
459     std::map<double,MG_SEGMENT*> classeseg;
460     for (int i=0;i<nbseg;i++)
461     {
462     MG_SEGMENT* seg=(MG_SEGMENT*)are->get_lien_maillage()->get(i);
463     double *xyz1=seg->get_noeud1()->get_coord();
464     double *xyz2=seg->get_noeud2()->get_coord();
465     double x=0.5*(xyz1[0]+xyz2[0]);
466     double y=0.5*(xyz1[1]+xyz2[1]);
467     double z=0.5*(xyz1[2]+xyz2[2]);
468     OT_VECTEUR_3D vec(x-xg,y-yg,z-zg);
469     classeseg.insert(std::pair<double,MG_SEGMENT*>(vec.get_longueur2(),seg));
470     }
471     MG_SEGMENT* seg=classeseg.begin()->second;
472     double *xyz1=seg->get_noeud1()->get_coord();
473     double *xyz2=seg->get_noeud2()->get_coord();
474     npoint p(0.5*(xyz1[0]+xyz2[0]),0.5*(xyz1[1]+xyz2[1]),0.5*(xyz1[2]+xyz2[2]));
475     point pp;
476     pp.pts=p;
477     char mess[255];
478     sprintf(mess,"E%lu",are->get_id());
479     pp.info=mess;
480     color cc=color(ptr.c.R,ptr.c.G,ptr.c.B);
481     std::pair<point,color> tmp(pp,cc);
482     data.add_text(1,tmp);
483     }
484 francois 351
485    
486     for (it=list_sommet.begin();it!=list_sommet.end();it++)
487     {
488     groupe_couleur gc=it->second;
489     properties ptr=data.getproppoints();
490     ptr.c=tabcoul[gc.num];
491     ptr.pointsize=15;
492     data.setproppoints(ptr);
493     std::map<unsigned long,unsigned long>::iterator it2;
494     std::map<unsigned long,unsigned long> *tmp;
495     if (A==true) tmp=&(gc.A);
496     else tmp=&(gc.B);
497    
498     for (it2=tmp->begin();it2!=tmp->end();it2++)
499     {
500     MG_SOMMET* som=geo->get_mg_sommetid(it2->second);
501     affiche[som->get_id()]=true;
502     int nbpoint=som->get_lien_maillage()->get_nb();
503     for (int i=0;i<nbpoint;i++)
504     {
505     MG_NOEUD* nd=(MG_NOEUD*)som->get_lien_maillage()->get(i);
506     double *xyz1=nd->get_coord();
507     npoint p1(xyz1[0],xyz1[1],xyz1[2]);
508     data.add_point(p1);
509 francois 353 point pp;
510     pp.pts=p1;
511     char mess[255];
512     sprintf(mess,"V%lu",som->get_id());
513     pp.info=mess;
514     color cc=color(ptr.c.R,ptr.c.G,ptr.c.B);
515     std::pair<point,color> tmp(pp,cc);
516     data.add_text(0,tmp);
517 francois 351 }
518     }
519     }
520     ptr=data.getproppoints();
521 francois 353 ptr.c=color(255-base.R,255-base.G,255-base.B);
522 francois 351 ptr.pointsize=4;
523    
524     data.setproppoints(ptr);
525     LISTE_MG_SOMMET::iterator itsom;
526     for (MG_SOMMET* som=geo->get_premier_sommet(itsom);som!=NULL;som=geo->get_suivant_sommet(itsom))
527     {
528     if (affiche[som->get_id()]==true) continue;
529     affiche[som->get_id()]=true;
530     int nbpoint=som->get_lien_maillage()->get_nb();
531     for (int i=0;i<nbpoint;i++)
532     {
533     MG_NOEUD* nd=(MG_NOEUD*)som->get_lien_maillage()->get(i);
534     double *xyz1=nd->get_coord();
535     npoint p1(xyz1[0],xyz1[1],xyz1[2]);
536     data.add_point(p1);
537 francois 353 point pp;
538     pp.pts=p1;
539     char mess[255];
540     sprintf(mess,"V%lu",som->get_id());
541     pp.info=mess;
542     color cc=color(ptr.c.R,ptr.c.G,ptr.c.B);
543     std::pair<point,color> tmp(pp,cc);
544     data.add_text(0,tmp);
545 francois 351 }
546    
547     }
548    
549    
550    
551     };
552    
553    
554    
555    
556    
557    
558    
559     #ifdef WINDOWS_VERSION
560     int amain(int argc,char **argv)
561     #else
562     int main(int argc,char **argv)
563     #endif
564     {
565 francois 353 color base=color(0,0,0);
566     char chemin[1000];
567     sprintf(chemin,"%s/.vtkdisplay",getenv("HOME"));
568     FILE *in=fopen(chemin,"rt");
569     if (in!=NULL)
570     {
571     char mess[255];
572     fgets(mess,255,in);
573     int R,G,B;
574     sscanf(mess,"%d %d %d",&R,&G,&B);
575     base=color(R,G,B);
576     fclose(in);
577     }
578 francois 351 printf("******************************\n");
579     printf("* Comparison visualization *\n");
580     printf("* by *\n");
581     printf("* Jean-Christophe Cuillière *\n");
582     printf("* and *\n");
583     printf("* Vincent Francois *\n");
584     printf("* ERICCA-UQTR *\n");
585     printf("******************************\n\n\n");
586    
587     if (argc!=4)
588     {
589     printf("Visucompare syntax error - Bad number arguments\n\n");
590     return 0;
591    
592     }
593     if (!((strcmp(argv[1],"A")==0) || (strcmp(argv[1],"B")==0)))
594     {
595     printf("Visucompare syntax error - first argument not valid : %s\n\n",argv[1]);
596     return 0;
597    
598     }
599    
600     if (!( (strcmp(argv[2],"S")==0) || (strcmp(argv[2],"M")==0) || (strcmp(argv[2],"I")==0)|| (strcmp(argv[2],"L")==0) ))
601     {
602     printf("Visucompare syntax error - Second argument not valid : %s\n\n",argv[2]);
603     return 0;
604    
605     }
606    
607    
608     std::map<int,groupe_couleur> list_vide;
609     std::vector<color> tabcoul;
610     ini_couleur(tabcoul,10);
611    
612     data_fichier df;
613     lire_fichier(argv[3],df);
614     bool A;
615     MG_FILE *gest;
616     if (strcmp(argv[1],"A")==0) {printf("Reading file A\n");gest=new MG_FILE((char*)df.nomA.c_str());A=true;}
617     else if (strcmp(argv[1],"B")==0) {printf("Reading file B\n");gest=new MG_FILE((char*)df.nomB.c_str());A=false;}
618    
619     printf(" Number of color group :\n");
620     if (strcmp(argv[2],"S")==0) printf(" Similar faces : %d Visible\n",df.list_face_similaire.size()); else printf(" Similar faces : %d\n",df.list_face_similaire.size());
621     if (strcmp(argv[2],"I")==0) printf(" Identical faces : %d Visible\n",df.list_face_identique.size()); else printf(" Identical faces : %d\n",df.list_face_identique.size());
622     if (strcmp(argv[2],"L")==0) printf(" Localized faces : %d Visible\n",df.list_face_localise.size()); else printf(" Localized faces : %d\n",df.list_face_localise.size());
623     if (strcmp(argv[2],"L")==0) printf(" Localized edges : %d Visible\n",df.list_arete_localise.size()); else printf(" Localized faces : %d\n",df.list_face_localise.size());
624     if (strcmp(argv[2],"L")==0) printf(" Localized vertices : %d Visible\n",df.list_sommet_localise.size()); else printf(" Localized faces : %d\n",df.list_face_localise.size());
625     if (strcmp(argv[2],"M")==0) printf(" Modified faces : %d Visible\n",df.list_face_modifie.size()); else printf(" Modified faces : %d \n",df.list_face_modifie.size());
626     if (strcmp(argv[2],"M")==0) printf(" Modified edges : %d Visible\n",df.list_arete_modifie.size()); else printf(" Modified edges : %d\n",df.list_arete_modifie.size());
627    
628    
629     MG_GEOMETRIE* geo=gest->get_mg_geometrie(0);
630     data_container data;
631    
632    
633 francois 353 if (strcmp(argv[2],"M")==0) affiche_structure(base,geo,A,tabcoul,data,df.list_face_modifie,df.list_arete_modifie,list_vide);
634     if (strcmp(argv[2],"I")==0) affiche_structure(base,geo,A,tabcoul,data,df.list_face_identique,list_vide,list_vide);
635     if (strcmp(argv[2],"S")==0) affiche_structure(base,geo,A,tabcoul,data,df.list_face_similaire,list_vide,list_vide);
636     if (strcmp(argv[2],"L")==0) affiche_structure(base,geo,A,tabcoul,data,df.list_face_localise,df.list_arete_localise,df.list_sommet_localise);
637    
638     printf("\n\n");
639     printf("Command on keyboard : \n");
640     printf(" e : End of vizualisation\n");
641     printf(" r : Reset Camera\n");
642     printf(" 1 : Vertex Numbers visible on/off\n");
643     printf(" 4 : Edge Numbers visible on/off\n");
644     printf(" 7 : Face Numbers visible on/off\n");
645     printf(" v : Vertices visible on/off\n");
646     printf(" l : Edges visible on/off\n");
647     printf(" t : Faces visible on/off\n");
648     printf(" j : Save camera on current directory\n");
649     printf(" k : Load camera from current directory\n");
650     printf(" w : Wireframe\n");
651     printf(" s : Modelframe\n");
652    
653 francois 351 char titre [255];
654     strcpy(titre,"Visucompare File ");
655     strcat(titre,argv[1]);
656     strcat(titre," ");
657     strcat(titre,argv[2]);
658     strcat(titre," ");
659     strcat(titre,argv[3]);
660    
661    
662     delete gest;
663 francois 353 vtkdisplay d(base,titre);
664 francois 351
665    
666    
667    
668     d.init_data(data);
669     d.display(true);
670    
671     return 0;
672     }
673    
674    
675    
676     #pragma package(smart_init)