ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/app/compare/src/visumain.cpp
Revision: 363
Committed: Thu Oct 18 22:12:03 2012 UTC (12 years, 6 months ago) by francois
File size: 22952 byte(s)
Log Message:
Mise a jour pour publi sur la comparaison

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