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

File Contents

# User Rev Content
1 francois 283 //---------------------------------------------------------------------------
2     #include"gestionversion.h"
3    
4     #pragma hdrstop
5     #include <string.h>
6     #include "vct_comparaison.h"
7     #include "vct_volume.h"
8     #include "vct_face.h"
9     #include "vct_surface.h"
10     #include <iomanip>
11     #include "vct_outils.h"
12     #include "constantegeo.h"
13     #include "mg_geometrie_outils.h"
14     #include "ot_cpu.h"
15    
16     //---------------------------------------------------------------------------
17    
18     #pragma package(smart_init)
19    
20    
21     VCT_COMPARAISON::VCT_COMPARAISON(MG_GESTIONNAIRE *gst1,MG_GEOMETRIE *mgeo1,MG_GESTIONNAIRE *gst2,MG_GEOMETRIE *mgeo2):mggeo1(mgeo1),mggeo2(mgeo2),gest1(gst1),gest2(gst2),affichageactif(0)
22     {
23     MG_VOLUME*vol1=mggeo1->get_mg_volume(0);
24     MG_VOLUME*vol2=mggeo2->get_mg_volume(0);
25     eps=mggeo1->get_valeur_precision();
26     }
27    
28     VCT_COMPARAISON::~VCT_COMPARAISON()
29     {
30     }
31    
32     void VCT_COMPARAISON::active_affichage(void (*fonc)(char*))
33     {
34     affiche=fonc;
35     affichageactif=1;
36     }
37    
38    
39     void VCT_COMPARAISON::compare(VCT_COMPARAISON_RESULTAT &cmp,MG_VOLUME* vol1,MG_VOLUME* vol2,OT_CPU *cpu)
40     {
41     if (vol1==NULL) vol1=mggeo1->get_mg_volume(0);
42     if (vol2==NULL) vol2=mggeo2->get_mg_volume(0);
43     if (affichageactif==1)
44     {
45     char mess[300];
46     sprintf(mess," Fichier 1 : %d faces",mggeo1->get_nb_mg_face());
47     affiche((char*)mess);
48     sprintf(mess," Fichier 2 : %d faces",mggeo2->get_nb_mg_face());
49     affiche((char*)mess);
50     affiche((char*)" Recherche de similarité");
51     }
52     trouve_similarite();
53     if (cpu!=NULL) cpu->ajouter_etape("Similarite");
54     if (affichageactif==1)
55     {
56     char mess[300];
57     sprintf(mess," Nombre de paires de faces similaires : %d",similarite.get_nb()/2);
58     affiche((char*)mess);
59     affiche((char*)" Recherche d'identite");
60     }
61     trouve_identite();
62     if (cpu!=NULL) cpu->ajouter_etape("Identite");
63     if (affichageactif==1)
64     {
65     char mess[300];
66     sprintf(mess," Nombre de paires de faces identiques : %d",identite.get_nb()/2);
67     affiche((char*)mess);
68     affiche((char*)" Recherche de localisation");
69     }
70     trouve_localise(cmp);
71     if (cpu!=NULL) cpu->ajouter_etape("Localisation");
72     if (affichageactif==1)
73     {
74     char mess[300];
75 francois 348 sprintf(mess," Face de reference 1 : %lu ",cmp.get_face_reference1()->get_id());
76     affiche((char*)mess);
77     sprintf(mess," Face de reference 2 : %lu ",cmp.get_face_reference2()->get_id());
78     affiche((char*)mess);
79 francois 283 sprintf(mess," Matrice de changement de repere : %lf %lf %lf %lf",transformation(0,0).get_x(),transformation(0,1).get_x(),transformation(0,2).get_x(),transformation(0,3).get_x());
80     affiche((char*)mess);
81     sprintf(mess," : %lf %lf %lf %lf",transformation(1,0).get_x(),transformation(1,1).get_x(),transformation(1,2).get_x(),transformation(1,3).get_x());
82     affiche((char*)mess);
83     sprintf(mess," R1 vers R2 : %lf %lf %lf %lf",transformation(2,0).get_x(),transformation(2,1).get_x(),transformation(2,2).get_x(),transformation(2,3).get_x());
84     affiche((char*)mess);
85     sprintf(mess," : %lf %lf %lf %lf",transformation(3,0).get_x(),transformation(3,1).get_x(),transformation(3,2).get_x(),transformation(3,3).get_x());
86     affiche((char*)mess);
87    
88     sprintf(mess," Nombre de paires de faces localisées : %d",localise.get_nb()/2);
89     affiche((char*)mess);
90     affiche((char*)" Recherche des arêtes et des sommets correspondants");
91     }
92     affecter_les_couleurs(localise);
93     identifie_correspondance(cmp);
94     if (cpu!=NULL) cpu->ajouter_etape("Correspondance");
95     if (affichageactif==1) affiche((char*)" Recherche des modifications partielles");
96     trouve_modification_partielle(cmp);
97     if (cpu!=NULL) cpu->ajouter_etape("Modifications partielles");
98     }
99    
100 francois 351
101    
102 francois 283 void VCT_COMPARAISON::trouve_similarite(void)
103     {
104     int nb_face1=mggeo1->get_nb_mg_face();
105     int nb_face2=mggeo2->get_nb_mg_face();
106     similarite.vide();
107     for (int i=0;i<nb_face1; i++)
108     {
109     MG_FACE* face1=mggeo1->get_mg_face(i);
110     MG_SURFACE*surf1=face1->get_surface();
111     int nb_top1_pts= face1->get_vectorisation().get_nb_points();
112     int nb_geo1_pts= surf1->get_vectorisation().get_nb_points();
113    
114     OT_TENSEUR *tns1_face=face1->get_vectorisation().get_tenseur_metrique();
115     OT_TENSEUR *tns1_surf=surf1->get_vectorisation().get_tenseur_metrique();
116 francois 363 for (int j=0;j<nb_face2;j++)
117 francois 283 {
118     MG_FACE* face2=mggeo2->get_mg_face(j);
119     MG_SURFACE*surf2=face2->get_surface();
120     int nb_top2_pts= face2->get_vectorisation().get_nb_points();
121     int nb_geo2_pts= surf2->get_vectorisation().get_nb_points();
122     OT_TENSEUR* tns2_face=face2->get_vectorisation().get_tenseur_metrique();
123     OT_TENSEUR* tns2_surf=surf2->get_vectorisation().get_tenseur_metrique();
124 francois 363 if (nb_geo1_pts==nb_geo2_pts&&nb_top1_pts==nb_top2_pts)
125 francois 283 {
126     if (tns1_face->est_til_equivalent(*tns2_face))
127     {
128     if (tns1_surf->est_til_equivalent(*tns2_surf))
129     {
130     similarite.ajouter(face1->get_id());
131     similarite.ajouter(face2->get_id());
132     }
133     }
134     }
135     }
136     }
137     }
138    
139     void VCT_COMPARAISON::trouve_identite(void)
140     {
141     identite.vide();
142     int nbpaire=similarite.get_nb()/2;
143     for (int i=0;i<nbpaire;i++)
144     {
145     MG_FACE* face1=mggeo1->get_mg_faceid(similarite.get(2*i));
146     MG_SURFACE*surf1=face1->get_surface();
147     MG_FACE* face2=mggeo2->get_mg_faceid(similarite.get(2*i+1));
148     MG_SURFACE*surf2=face1->get_surface();
149     OT_TENSEUR *tns1_face=face1->get_vectorisation().get_tenseur_inertie_base_locale_4d();
150     OT_TENSEUR *tns1_surf=surf1->get_vectorisation().get_tenseur_inertie_base_locale_4d();
151     OT_TENSEUR *tns2_face=face2->get_vectorisation().get_tenseur_inertie_base_locale_4d();
152     OT_TENSEUR *tns2_surf=surf2->get_vectorisation().get_tenseur_inertie_base_locale_4d();
153     if (tns1_face->est_til_equivalent(*tns2_face))
154     if (tns1_surf->est_til_equivalent(*tns2_surf))
155     {
156     identite.ajouter(face1->get_id());
157     identite.ajouter(face2->get_id());
158     }
159     }
160     }
161     void VCT_COMPARAISON::trouve_localise(VCT_COMPARAISON_RESULTAT &cmp)
162     {
163    
164     localise.vide();
165     TPL_LISTE_ENTITE<int> localisetmp;
166     int nbpaire=identite.get_nb()/2.;
167     if (nbpaire==0)
168     {
169     OT_TENSEUR tmp(4,4);
170     tmp.identite();
171     transformation=tmp;
172     transformation_inverse=tmp;
173 francois 351 return;
174 francois 283 }
175     int *paire=new int[nbpaire];
176     for (int i=0;i<nbpaire;i++)
177     paire[i]=0;
178     for (int ident=0;ident<nbpaire;ident++)
179     {
180     if (paire[ident]==1) continue;
181     MG_FACE* faceref1=mggeo1->get_mg_faceid(identite.get(2*ident));
182     MG_FACE* faceref2=mggeo2->get_mg_faceid(identite.get(2*ident+1));
183     OT_TENSEUR tnsref1(3,3);
184     OT_TENSEUR tnsref2(3,3);
185     std::vector<OT_TENSEUR> list;
186     recale_repere_reference(faceref1,faceref2,list);
187     int nbessai=list.size()/2;
188     for (int essai=0;essai<nbessai;essai++)
189     {
190     localisetmp.vide();
191     int *pairetmp=new int[nbpaire];
192     for (int i=0;i<nbpaire;i++)
193     pairetmp[i]=0;
194     OT_VECTEUR_3DD *baryref1=faceref1->get_vectorisation().get_barycentre_3d();
195     OT_VECTEUR_3DD *baryref2=faceref2->get_vectorisation().get_barycentre_3d();
196     OT_TENSEUR tnsref1=list[essai*2];
197     OT_TENSEUR tnsref2=list[essai*2+1];
198     OT_TENSEUR tnsrefinv1=tnsref1.transpose();
199     OT_TENSEUR tnsrefinv2=tnsref2.transpose();
200     for (int i=0;i<nbpaire;i++)
201     {
202     MG_FACE* face1=mggeo1->get_mg_faceid(identite.get(2*i));
203     MG_FACE* face2=mggeo2->get_mg_faceid(identite.get(2*i+1));
204     OT_TENSEUR *tns1=face1->get_vectorisation().get_base_locale_3d();
205     OT_TENSEUR trans1=tns1->transpose();
206     trans1=trans1*tnsref1;
207     OT_TENSEUR tns2=trans1.transpose();
208     tns2=tnsref2*tns2;
209     OT_TENSEUR *iner2=face2->get_vectorisation().get_tenseur_inertie_3d();
210     OT_TENSEUR *inerloc2=face2->get_vectorisation().get_tenseur_inertie_base_locale_3d();
211     OT_TENSEUR inerloc2prime=tns2.transpose();
212     inerloc2prime=inerloc2prime*(*iner2);
213     inerloc2prime=inerloc2prime*tns2;
214     OT_VECTEUR_3DD *bary1=face1->get_vectorisation().get_barycentre_3d();
215     OT_VECTEUR_3DD baryloc1=(*bary1)-(*baryref1);
216     baryloc1=tnsrefinv1*baryloc1;
217     OT_VECTEUR_3DD *bary2=face2->get_vectorisation().get_barycentre_3d();
218     OT_VECTEUR_3DD baryloc2=(*bary2)-(*baryref2);
219     baryloc2=tnsrefinv2*baryloc2;
220     if (inerloc2prime.est_til_equivalent(*inerloc2))
221     if (baryloc1==baryloc2)
222     {
223     localisetmp.ajouter(face1->get_id());
224     localisetmp.ajouter(face2->get_id());
225     pairetmp[i]=1;
226     }
227     }
228     if (localisetmp.get_nb()>localise.get_nb())
229     {
230     int n=localisetmp.get_nb();
231     localise.vide();
232     for (int i=0;i<n;i++)
233     localise.ajouter(localisetmp.get(i));
234     for (int i=0;i<nbpaire;i++)
235     paire[i]=pairetmp[i];
236     ident=0;
237     transformation=calcul_transformation(*baryref1,*baryref2,tnsref1,tnsref2);
238 francois 347 cmp.change_face_reference1(faceref1);
239     cmp.change_face_reference2(faceref2);
240 francois 283 }
241     delete [] pairetmp;
242     }
243     }
244     delete [] paire;
245     transformation_inverse=transformation.inverse_homogene();
246     OT_VECTEUR_3D vec1(transformation(0,0).get_x(),transformation(1,0).get_x(),transformation(2,0).get_x());
247     OT_VECTEUR_3D vec2(transformation(0,1).get_x(),transformation(1,1).get_x(),transformation(2,1).get_x());
248     OT_VECTEUR_3D vec3(transformation(0,2).get_x(),transformation(1,2).get_x(),transformation(2,2).get_x());
249     OT_VECTEUR_3D vec4(transformation(0,3).get_x(),transformation(1,3).get_x(),transformation(2,3).get_x());
250     cmp.initialise_changement_repere(vec1,vec2,vec3,vec4);
251 francois 351 for (int i=0;i<similarite.get_nb();i++)
252     cmp.ajouter_similarite(similarite.get(i));
253     for (int i=0;i<identite.get_nb();i++)
254     cmp.ajouter_identite(identite.get(i));
255     for (int i=0;i<localise.get_nb();i++)
256     cmp.ajouter_localise_face(localise.get(i));
257 francois 283 }
258     void VCT_COMPARAISON::identifie_correspondance(VCT_COMPARAISON_RESULTAT &cmp)
259     {
260     int sommetparfait=0,areteparfait=0;
261     int nbpaire=localise.get_nb()/2.;
262     for (int i=0;i<nbpaire;i++)
263     {
264     MG_FACE* face1=mggeo1->get_mg_faceid(localise.get(2*i));
265     MG_FACE* face2=mggeo2->get_mg_faceid(localise.get(2*i+1));
266     CORRESPONDANCE cor(face1,face2,CORRESPONDANCE::PARFAITE);
267     cmp.ajouter_liste_topologie(cor);
268     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,face1);
269     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_CONSERVEE,face2);
270     identifie_topologie_sous_jacente(cmp,face1,face2,sommetparfait,areteparfait);
271     }
272     if (affichageactif==1)
273     {
274     char mess[300];
275     sprintf(mess," Nombre de paires de sommets localisés : %d",sommetparfait);
276     affiche((char*)mess);
277     sprintf(mess," Nombre de paires d'aretes localisées : %d",areteparfait);
278     affiche((char*)mess);
279     }
280     }
281    
282     void VCT_COMPARAISON::identifie_topologie_sous_jacente(VCT_COMPARAISON_RESULTAT &cmp,MG_FACE* face1,MG_FACE* face2,int& sommetparfait,int& areteparfait)
283     {
284     double2 UN(1.0);
285     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD > tabsom1;
286     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD > tabsom2;
287     std::multimap<OT_VECTEUR_3DD,MG_ARETE*,lessOT_VECTEUR_3DD > tabare1;
288     std::multimap<OT_VECTEUR_3DD,MG_ARETE*,lessOT_VECTEUR_3DD > tabare2;
289     int nb_boucle=face1->get_nb_mg_boucle();
290     for (int i=0;i<nb_boucle;i++)
291     {
292     MG_BOUCLE* bou1=face1->get_mg_boucle(i);
293     int nb_arete=bou1->get_nb_mg_coarete();
294     for (int j=0;j<nb_arete;j++)
295     {
296     MG_ARETE *are=bou1->get_mg_coarete(j)->get_arete();
297     OT_VECTEUR_3DD *bary=are->get_vectorisation().get_barycentre_3d();
298     std::pair<OT_VECTEUR_3DD,MG_ARETE*> tmp(*bary,are);
299     tabare1.insert(tmp);
300     MG_SOMMET *som1=are->get_cosommet1()->get_sommet();
301     double xyz[3];
302     som1->get_point()->evaluer(xyz);
303     OT_VECTEUR_3DD vec(xyz[0],xyz[1],xyz[2]);
304     std::pair<OT_VECTEUR_3DD,MG_SOMMET*> tmp2(vec,som1);
305     tabsom1.insert(tmp2);
306     MG_SOMMET *som2=are->get_cosommet2()->get_sommet();
307     som2->get_point()->evaluer(xyz);
308     OT_VECTEUR_3DD vec2(xyz[0],xyz[1],xyz[2]);
309     std::pair<OT_VECTEUR_3DD,MG_SOMMET*> tmp3(vec2,som2);
310     tabsom1.insert(tmp3);
311     }
312     MG_BOUCLE* bou2=face2->get_mg_boucle(i);
313     nb_arete=bou1->get_nb_mg_coarete();
314     for (int j=0;j<nb_arete;j++)
315     {
316     MG_ARETE *are=bou2->get_mg_coarete(j)->get_arete();
317     OT_VECTEUR_3DD *bary=are->get_vectorisation().get_barycentre_3d();
318     OT_VECTEUR_4DD baryhomo(bary->get_x(),bary->get_y(),bary->get_z(),UN);
319     OT_VECTEUR_4DD barytranshomo=transformation_inverse*baryhomo;
320     OT_VECTEUR_3DD barytrans(barytranshomo.get_x(),barytranshomo.get_y(),barytranshomo.get_z());
321     double2 w=UN/barytranshomo.get_w();
322     barytrans=barytrans*w;
323     std::pair<OT_VECTEUR_3DD,MG_ARETE*> tmp(barytrans,are);
324     tabare2.insert(tmp);
325     MG_SOMMET *som1=are->get_cosommet1()->get_sommet();
326     double xyz[3];
327     som1->get_point()->evaluer(xyz);
328     OT_VECTEUR_4DD vechomo(xyz[0],xyz[1],xyz[2],1.);
329     OT_VECTEUR_4DD vectranshomo=transformation_inverse*vechomo;
330     OT_VECTEUR_3DD vectrans(vectranshomo.get_x(),vectranshomo.get_y(),vectranshomo.get_z());
331     w=UN/vectranshomo.get_w();
332     vectrans=vectrans*w;
333     std::pair<OT_VECTEUR_3DD,MG_SOMMET*> tmp2(vectrans,som1);
334     tabsom2.insert(tmp2);
335     MG_SOMMET *som2=are->get_cosommet2()->get_sommet();
336     som2->get_point()->evaluer(xyz);
337     OT_VECTEUR_4DD vechomo2(xyz[0],xyz[1],xyz[2],1.);
338     OT_VECTEUR_4DD vectranshomo2=transformation_inverse*vechomo2;
339     OT_VECTEUR_3DD vectrans2(vectranshomo2.get_x(),vectranshomo2.get_y(),vectranshomo2.get_z());
340     w=UN/vectranshomo2.get_w();
341     vectrans2=vectrans2*w;
342     std::pair<OT_VECTEUR_3DD,MG_SOMMET*> tmp3(vectrans2,som2);
343     tabsom2.insert(tmp3);
344     }
345     //arete
346     std::multimap<OT_VECTEUR_3DD,MG_ARETE*,lessOT_VECTEUR_3DD >::iterator it1;
347     std::multimap<OT_VECTEUR_3DD,MG_ARETE*,lessOT_VECTEUR_3DD >::iterator it2;
348     it1=tabare1.begin();
349     int ok=0;
350     if (it1==tabare1.end()) ok=1;
351     while (ok==0)
352     {
353     MG_ARETE* are1=(*it1).second;
354     OT_VECTEUR_3DD bary1=(*it1).first;
355     int nb_top1_pts= are1->get_vectorisation().get_nb_points();
356     int nb_geo1_pts= are1->get_courbe()->get_vectorisation().get_nb_points();
357     OT_TENSEUR *tns1_metrique_are=are1->get_vectorisation().get_tenseur_metrique();
358     OT_TENSEUR *tns1_metrique_crb=are1->get_courbe()->get_vectorisation().get_tenseur_metrique();
359     OT_TENSEUR *tns1_inertie_are=are1->get_vectorisation().get_tenseur_inertie_base_locale_4d();
360     OT_TENSEUR *tns1_inertie_crb=are1->get_courbe()->get_vectorisation().get_tenseur_inertie_base_locale_4d();
361     it2=tabare2.find(bary1);
362     int ok2=0;
363     do
364     {
365     if (it2==tabare2.end()) ok2=1;
366     else
367     {
368     MG_ARETE* are2=(*it2).second;
369     OT_VECTEUR_3DD bary2=(*it2).first;
370     if (!(bary2==bary1)) ok2=1;
371     else
372     {
373     int nb_top2_pts= are2->get_vectorisation().get_nb_points();
374     int nb_geo2_pts= are2->get_courbe()->get_vectorisation().get_nb_points();
375     OT_TENSEUR *tns2_metrique_are=are2->get_vectorisation().get_tenseur_metrique();
376     OT_TENSEUR *tns2_metrique_crb=are2->get_courbe()->get_vectorisation().get_tenseur_metrique();
377     OT_TENSEUR *tns2_inertie_are=are2->get_vectorisation().get_tenseur_inertie_base_locale_4d();
378     OT_TENSEUR *tns2_inertie_crb=are2->get_courbe()->get_vectorisation().get_tenseur_inertie_base_locale_4d();
379     if (nb_top1_pts==nb_top2_pts)
380     if (nb_geo1_pts==nb_geo2_pts)
381     if (tns1_metrique_are->est_til_equivalent(*tns2_metrique_are))
382     if (tns1_metrique_crb->est_til_equivalent(*tns2_metrique_crb))
383     if (tns1_inertie_are->est_til_equivalent(*tns2_inertie_are))
384     if (tns1_inertie_crb->est_til_equivalent(*tns2_inertie_crb))
385     {
386     CORRESPONDANCE cor(are1,are2,CORRESPONDANCE::PARFAITE);
387     int res=cmp.ajouter_liste_topologie(cor);
388     if (res==1)
389     {
390     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,are1);
391     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_CONSERVEE,are2);
392 francois 351 cmp.ajouter_localise_arete(are1->get_id());
393     cmp.ajouter_localise_arete(are2->get_id());
394     areteparfait++;
395 francois 283 }
396     }
397     it2++;
398     }
399     }
400     }
401     while (ok2==0);
402     it1++;
403     if (it1==tabare1.end()) ok=1;
404     }
405    
406     //sommet
407     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD >::iterator its1;
408     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD >::iterator its2;
409     its1=tabsom1.begin();
410     ok=0;
411     do
412     {
413     MG_SOMMET* som=(*its1).second;
414     its2=tabsom2.find((*its1).first);
415     if (its2!=tabsom2.end())
416     {
417     CORRESPONDANCE cor((*its1).second,(*its2).second,CORRESPONDANCE::PARFAITE);
418     int res=cmp.ajouter_liste_topologie(cor);
419     if (res==1)
420     {
421     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,(*its1).second);
422     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_CONSERVEE,(*its2).second);
423 francois 351 cmp.ajouter_localise_sommet(((*its1).second)->get_id());
424     cmp.ajouter_localise_sommet(((*its2).second)->get_id());
425 francois 283 sommetparfait++;
426     }
427     }
428     its1++;
429     if (its1==tabsom1.end()) ok=1;
430     }
431     while (ok==0);
432     }
433     }
434    
435     void VCT_COMPARAISON::trouve_modification_partielle(VCT_COMPARAISON_RESULTAT &cmp)
436     {
437     double2 ZERO(0.);
438     double2 UN(1.);
439     int sommetpartiel=0,aretepartiel=0,facepartiel=0;
440     //tableau des entites qui n'ont pas pu associees
441     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD > tabsom1;
442     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD > tabsom2;
443     std::multimap<int,MG_ARETE* > tabare1;
444     std::multimap<int,MG_ARETE* > tabare2;
445     std::multimap<int,MG_FACE* > tabface1;
446     std::multimap<int,MG_FACE*> tabface2;
447    
448     LISTE_MG_SOMMET::iterator itsom;
449     LISTE_MG_ARETE::iterator itare;
450     LISTE_MG_FACE::iterator itface;
451     for (MG_SOMMET* som=mggeo1->get_premier_sommet(itsom);som!=NULL;som=mggeo1->get_suivant_sommet(itsom))
452     {
453     unsigned long num=cmp.get_liste_correspondance_modifie(som->get_id());
454     if (num==0)
455     {
456     double xyz[3];
457     som->get_point()->evaluer(xyz);
458     OT_VECTEUR_3DD vec(xyz[0],xyz[1],xyz[2]);
459     std::pair<OT_VECTEUR_3DD,MG_SOMMET*> tmp(vec,som);
460     tabsom1.insert(tmp);
461     }
462     }
463     for (MG_ARETE* are=mggeo1->get_premier_arete(itare);are!=NULL;are=mggeo1->get_suivant_arete(itare))
464     {
465     unsigned long num=cmp.get_liste_correspondance_modifie(are->get_id());
466     if (num==0)
467     {
468     TPL_LISTE_ENTITE<double> param;
469     int typecrb=are->get_courbe()->get_type_geometrique(param);
470     std::pair<int,MG_ARETE*> tmp(typecrb,are);
471     tabare1.insert(tmp);
472     }
473     }
474     for (MG_FACE* face=mggeo1->get_premier_face(itface);face!=NULL;face=mggeo1->get_suivant_face(itface))
475     {
476     unsigned long num=cmp.get_liste_correspondance_modifie(face->get_id());
477     if (num==0)
478     {
479     TPL_LISTE_ENTITE<double> param;
480     int typesurf=face->get_surface()->get_type_geometrique(param);
481     std::pair<int,MG_FACE*> tmp(typesurf,face);
482     tabface1.insert(tmp);
483     }
484     }
485     for (MG_SOMMET* som=mggeo2->get_premier_sommet(itsom);som!=NULL;som=mggeo2->get_suivant_sommet(itsom))
486     {
487     unsigned long num=cmp.get_liste_correspondance_origine(som->get_id());
488     if (num==0)
489     {
490     double xyz[3];
491     som->get_point()->evaluer(xyz);
492     OT_VECTEUR_4DD vec(xyz[0],xyz[1],xyz[2],1.);
493     OT_VECTEUR_4DD vectranshomo=transformation_inverse*vec;
494     OT_VECTEUR_3DD vectrans(vectranshomo.get_x(),vectranshomo.get_y(),vectranshomo.get_z());
495     double2 w=UN/vectranshomo.get_w();
496     vectrans=vectrans*w;
497     std::pair<OT_VECTEUR_3DD,MG_SOMMET*> tmp(vectrans,som);
498     tabsom2.insert(tmp);
499     }
500     }
501     for (MG_ARETE* are=mggeo2->get_premier_arete(itare);are!=NULL;are=mggeo2->get_suivant_arete(itare))
502     {
503     unsigned long num=cmp.get_liste_correspondance_origine(are->get_id());
504     if (num==0)
505     {
506     TPL_LISTE_ENTITE<double> param;
507     int typecrb=are->get_courbe()->get_type_geometrique(param);
508     std::pair<int,MG_ARETE*> tmp(typecrb,are);
509     tabare2.insert(tmp);
510     }
511     }
512     for (MG_FACE* face=mggeo2->get_premier_face(itface);face!=NULL;face=mggeo2->get_suivant_face(itface))
513     {
514     unsigned long num=cmp.get_liste_correspondance_origine(face->get_id());
515     if (num==0)
516     {
517     TPL_LISTE_ENTITE<double> param;
518     int typesurf=face->get_surface()->get_type_geometrique(param);
519     std::pair<int,MG_FACE*> tmp(typesurf,face);
520     tabface2.insert(tmp);
521     }
522     }
523     //analyse sommet
524     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD >::iterator its1;
525     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD >::iterator its2;
526     its1=tabsom1.begin();
527     int ok=0;
528     if (tabsom1.size()==0) ok=1;
529     while (ok==0)
530     {
531     its2=tabsom2.find((*its1).first);
532     if (its2!=tabsom2.end())
533     {
534     CORRESPONDANCE cor((*its1).second,(*its2).second,CORRESPONDANCE::MODIFIE);
535     cmp.ajouter_liste_topologie(cor);
536     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,(*its1).second);
537     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_CONSERVEE,(*its2).second);
538 francois 351 sommetpartiel++;
539 francois 283 }
540     its1++;
541     if (its1==tabsom1.end()) ok=1;
542     }
543     //analyse arete
544     std::multimap<int,MG_ARETE* >::iterator ita1;
545     std::multimap<int,MG_ARETE* >::iterator ita2;
546     ita1=tabare1.begin();
547     ok=0;
548     if (tabare1.size()==0) ok=1;
549     while (ok==0)
550     {
551     MG_ARETE* are1=(*ita1).second;
552     int typecrb1=(*ita1).first;
553     int nb_geo1_pts= are1->get_courbe()->get_vectorisation().get_nb_points();
554     OT_TENSEUR *tns1_metrique_crb=are1->get_courbe()->get_vectorisation().get_tenseur_metrique();
555     OT_TENSEUR *tns1_inertie_crb=are1->get_courbe()->get_vectorisation().get_tenseur_inertie_base_locale_4d();
556     ita2=tabare2.find(typecrb1);
557     int ok2=0;
558     do
559     {
560     if (ita2==tabare2.end()) ok2=1;
561     else
562     {
563     MG_ARETE* are2=(*ita2).second;
564     int typecrb2=(*ita2).first;
565     if (!(typecrb2==typecrb1)) ok2=1;
566     else
567     {
568     int nb_geo2_pts= are2->get_courbe()->get_vectorisation().get_nb_points();
569     OT_TENSEUR *tns2_metrique_crb=are2->get_courbe()->get_vectorisation().get_tenseur_metrique();
570     OT_TENSEUR *tns2_inertie_crb=are2->get_courbe()->get_vectorisation().get_tenseur_inertie_base_locale_4d();
571     if (nb_geo1_pts==nb_geo2_pts)
572     if (tns1_metrique_crb->est_til_equivalent(*tns2_metrique_crb))
573     if (tns1_inertie_crb->est_til_equivalent(*tns2_inertie_crb))
574     if (localise_courbe(are1->get_courbe(),are2->get_courbe()))
575     {
576     CORRESPONDANCE cor(are1,are2,CORRESPONDANCE::MODIFIE);
577     cmp.ajouter_liste_topologie(cor);
578     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,are1);
579     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_CONSERVEE,are2);
580 francois 351 cmp.ajouter_modifie_arete(are1->get_id());
581     cmp.ajouter_modifie_arete(are2->get_id());
582 francois 283 aretepartiel++;
583     }
584     ita2++;
585     }
586     }
587     }
588     while (ok2==0);
589     ita1++;
590     if (ita1==tabare1.end()) ok=1;
591     }
592    
593     //analyse face
594     std::multimap<int,MG_FACE* >::iterator itf1;
595     std::multimap<int,MG_FACE* >::iterator itf2;
596     itf1=tabface1.begin();
597     ok=0;
598     if (tabface1.size()==0) ok=1;
599     while (ok==0)
600     {
601     MG_FACE* face1=(*itf1).second;
602     int typefac1=(*itf1).first;
603     int nb_geo1_pts= face1->get_surface()->get_vectorisation().get_nb_points();
604     OT_TENSEUR *tns1_metrique_surface=face1->get_surface()->get_vectorisation().get_tenseur_metrique();
605     OT_TENSEUR *tns1_inertie_surface=face1->get_surface()->get_vectorisation().get_tenseur_inertie_base_locale_4d();
606     itf2=tabface2.find(typefac1);
607     int ok2=0;
608     do
609     {
610     if (itf2==tabface2.end()) ok2=1;
611     else
612     {
613     MG_FACE* face2=(*itf2).second;
614     int typefac2=(*itf2).first;
615     if (typefac1!=typefac2) ok2=1;
616     else
617     {
618     int nb_geo2_pts= face2->get_surface()->get_vectorisation().get_nb_points();
619     OT_TENSEUR *tns2_metrique_surface=face2->get_surface()->get_vectorisation().get_tenseur_metrique();
620     OT_TENSEUR *tns2_inertie_surface=face2->get_surface()->get_vectorisation().get_tenseur_inertie_base_locale_4d();
621     if (nb_geo1_pts==nb_geo2_pts)
622     //if (tns1_metrique_surface->est_til_equivalent(*tns2_metrique_surface))
623     //if (tns1_inertie_surface->est_til_equivalent(*tns2_inertie_surface))
624     if (localise_surface(face1->get_surface(),face2->get_surface()))
625     {
626     CORRESPONDANCE cor(face1,face2,CORRESPONDANCE::MODIFIE);
627     cmp.ajouter_liste_topologie(cor);
628     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,face1);
629     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_CONSERVEE,face2);
630 francois 351 cmp.ajouter_modifie_face(face1->get_id());
631     cmp.ajouter_modifie_face(face2->get_id());
632 francois 283 facepartiel++;
633     }
634     itf2++;
635     }
636     }
637     }
638     while (ok2==0);
639     itf1++;
640     if (itf1==tabface1.end()) ok=1;
641     }
642     //fin remplissage cmp
643     for (its1=tabsom1.begin();its1!=tabsom1.end();its1++)
644     {
645     unsigned long num=cmp.get_liste_correspondance_modifie((*its1).second->get_id());
646     if (num==0) cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_DISPARUE,(*its1).second);
647     }
648     for (its1=tabsom2.begin();its1!=tabsom2.end();its1++)
649     {
650     unsigned long num=cmp.get_liste_correspondance_origine((*its1).second->get_id());
651     if (num==0) cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_APPARUE,(*its1).second);
652     }
653     for (ita1=tabare1.begin();ita1!=tabare1.end();ita1++)
654     {
655     unsigned long num=cmp.get_liste_correspondance_modifie((*ita1).second->get_id());
656     if (num==0) cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_DISPARUE,(*ita1).second);
657     }
658     for (ita1=tabare2.begin();ita1!=tabare2.end();ita1++)
659     {
660     unsigned long num=cmp.get_liste_correspondance_origine((*ita1).second->get_id());
661     if (num==0) cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_APPARUE,(*ita1).second);
662     }
663     for (itf1=tabface1.begin();itf1!=tabface1.end();itf1++)
664     {
665     unsigned long num=cmp.get_liste_correspondance_modifie((*itf1).second->get_id());
666     if (num==0) cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_DISPARUE,(*itf1).second);
667     }
668     for (itf1=tabface2.begin();itf1!=tabface2.end();itf1++)
669     {
670     unsigned long num=cmp.get_liste_correspondance_origine((*itf1).second->get_id());
671     if (num==0) cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_APPARUE,(*itf1).second);
672     }
673     if (affichageactif==1)
674     {
675     char mess[300];
676     sprintf(mess," Nombre de paires de sommets : %d",sommetpartiel);
677     affiche((char*)mess);
678     sprintf(mess," Nombre de paires d'aretes : %d",aretepartiel);
679     affiche((char*)mess);
680     sprintf(mess," Nombre de paires de faces : %d",facepartiel);
681     affiche((char*)mess);
682     }
683    
684     }
685    
686    
687     int VCT_COMPARAISON::localise_courbe(MG_COURBE *crb1,MG_COURBE *crb2)
688     {
689     double xyz1[3],xyz2[3],xyz3[3],xyz[3];
690     double t=0.5*(crb2->get_tmax()+crb2->get_tmin());
691     double dt=(crb2->get_tmax()-crb2->get_tmin())/max(fabs(crb2->get_tmax()),fabs(crb2->get_tmin()));
692     crb2->evaluer(t,xyz1);
693     t=t+dt;
694     crb2->evaluer(t,xyz2);
695     t=t+dt;
696     crb2->evaluer(t,xyz3);
697     change_point_inverse(xyz1);
698     change_point_inverse(xyz2);
699     change_point_inverse(xyz3);
700     OT_VECTEUR_3D vec(xyz1,xyz3);
701     crb1->inverser(t,xyz1);
702     crb1->evaluer(t,xyz);
703     OT_VECTEUR_3D vec1(xyz,xyz1);
704     if (vec1.get_longueur()>eps) return 0;
705     crb1->inverser(t,xyz2);
706     crb1->evaluer(t,xyz);
707     OT_VECTEUR_3D vec2(xyz,xyz2);
708     if (vec2.get_longueur()>eps) return 0;
709     crb1->inverser(t,xyz3);
710     crb1->evaluer(t,xyz);
711     OT_VECTEUR_3D vec3(xyz,xyz3);
712     if (vec3.get_longueur()>eps) return 0;
713     return 1;
714     }
715    
716     int VCT_COMPARAISON::localise_surface(MG_SURFACE *surf1,MG_SURFACE *surf2)
717     {
718     double du=surf2->get_umax()-surf2->get_umin();
719     double dv=surf2->get_vmax()-surf2->get_vmin();
720     du=du/max(fabs(surf2->get_umax()),fabs(surf2->get_umin()));
721     dv=dv/max(fabs(surf2->get_vmax()),fabs(surf2->get_vmin()));
722     double ou=0.5*(surf2->get_umax()+surf2->get_umin());
723     double ov=0.5*(surf2->get_vmax()+surf2->get_vmin());
724     for (int i=0;i<3;i++)
725     for (int j=0;j<3;j++)
726     {
727     double uv[2],xyz[3];
728     uv[0]=ou+i*du;
729     uv[1]=ov+j*dv;
730     surf2->evaluer(uv,xyz);
731     change_point_inverse(xyz);
732     double xyz1[3];
733     surf1->inverser(uv,xyz);
734     surf1->evaluer(uv,xyz1);
735     OT_VECTEUR_3D vec(xyz,xyz1);
736     if (vec.get_longueur()>eps) return 0;
737     }
738     return 1;
739     }
740    
741    
742    
743     void VCT_COMPARAISON::change_point_inverse(double *xyz)
744     {
745     double2 UN(1.);
746     OT_VECTEUR_4DD vec(xyz[0],xyz[1],xyz[2],1.);
747     OT_VECTEUR_4DD vectranshomo=transformation_inverse*vec;
748     OT_VECTEUR_3DD vectrans(vectranshomo.get_x(),vectranshomo.get_y(),vectranshomo.get_z());
749     double2 w=UN/vectranshomo.get_w();
750     vectrans=vectrans*w;
751     xyz[0]=vectrans.get_x().get_x();
752     xyz[1]=vectrans.get_y().get_x();
753     xyz[2]=vectrans.get_z().get_x();
754     }
755    
756     void VCT_COMPARAISON::change_point(double *xyz)
757     {
758     double2 UN(1.);
759     OT_VECTEUR_4DD vec(xyz[0],xyz[1],xyz[2],1.);
760     OT_VECTEUR_4DD vectranshomo=transformation*vec;
761     OT_VECTEUR_3DD vectrans(vectranshomo.get_x(),vectranshomo.get_y(),vectranshomo.get_z());
762     double2 w=UN/vectranshomo.get_w();
763     vectrans=vectrans*w;
764     xyz[0]=vectrans.get_x().get_x();
765     xyz[1]=vectrans.get_y().get_x();
766     xyz[2]=vectrans.get_z().get_x();
767     }
768    
769    
770    
771     OT_TENSEUR VCT_COMPARAISON::calcul_transformation(OT_VECTEUR_3DD &bary1,OT_VECTEUR_3DD &bary2,OT_TENSEUR &tns1,OT_TENSEUR &tns2)
772     {
773     double2 zero(0.),un(1.);
774     OT_TENSEUR t1(4,4);
775     t1(0,0)=tns1(0,0);
776     t1(1,0)=tns1(1,0);
777     t1(2,0)=tns1(2,0);
778     t1(3,0)=zero;
779     t1(0,1)=tns1(0,1);
780     t1(1,1)=tns1(1,1);
781     t1(2,1)=tns1(2,1);
782     t1(3,1)=zero;
783     t1(0,2)=tns1(0,2);
784     t1(1,2)=tns1(1,2);
785     t1(2,2)=tns1(2,2);
786     t1(3,2)=zero;
787     t1(0,3)=bary1.get_x();
788     t1(1,3)=bary1.get_y();
789     t1(2,3)=bary1.get_z();
790     t1(3,3)=un;
791     OT_TENSEUR t2(4,4);
792     t2(0,0)=tns2(0,0);
793     t2(1,0)=tns2(1,0);
794     t2(2,0)=tns2(2,0);
795     t2(3,0)=zero;
796     t2(0,1)=tns2(0,1);
797     t2(1,1)=tns2(1,1);
798     t2(2,1)=tns2(2,1);
799     t2(3,1)=zero;
800     t2(0,2)=tns2(0,2);
801     t2(1,2)=tns2(1,2);
802     t2(2,2)=tns2(2,2);
803     t2(3,2)=zero;
804     t2(0,3)=bary2.get_x();
805     t2(1,3)=bary2.get_y();
806     t2(2,3)=bary2.get_z();
807     t2(3,3)=un;
808     OT_TENSEUR t1inv=t1.inverse_homogene();
809     OT_TENSEUR trans=t2*t1inv;
810     return trans;
811     }
812    
813     void VCT_COMPARAISON::recale_repere_reference(MG_FACE* faceref1,MG_FACE* faceref2,vector<OT_TENSEUR> &list)
814     {
815     OT_TENSEUR tnsref1(3,3),tnsref2(3,3);
816     double2 zero(0.);
817     // repere1
818     OT_VECTEUR_3DD *bary1=faceref1->get_vectorisation().get_barycentre_3d();
819     double xyz1[3]={bary1->get_x().get_x(),bary1->get_y().get_x(),bary1->get_z().get_x()};
820     MG_GEOMETRIE_OUTILS ot;
821     double uvproj1[2],xyzproj1[3];
822     ot.projete(xyz1,faceref1,uvproj1,xyzproj1);
823     double normal1[3];
824     faceref1->calcul_normale_unitaire(uvproj1,normal1);
825     double2 normal12[3];
826     normal12[0]=normal1[0];
827     normal12[1]=normal1[1];
828     normal12[2]=normal1[2];
829     OT_VECTEUR_3DD nor1(normal12);
830     int sens1=faceref1->get_mg_coface(0)->get_orientation();
831     nor1=sens1*nor1;
832     OT_TENSEUR *axe1=faceref1->get_vectorisation().get_base_locale_3d();
833     int n13=-1;
834     int signe13=1;
835     double2 limit1(0.);
836     for (int i=0;i<3;i++)
837     {
838     OT_VECTEUR_3DD veci;
839     veci[0]=(*axe1)(0,i);
840     veci[1]=(*axe1)(1,i);
841     veci[2]=(*axe1)(2,i);
842     double2 ps=veci*nor1;
843     if (f2abs(ps)>limit1)
844     {
845     n13=i;
846     if (ps<zero) signe13=-1;
847     limit1=f2abs(ps);
848     }
849     }
850     int n11,n12;
851     if (n13==0) {
852     n11=1;
853     n12=2;
854     }
855     if (n13==1) {
856     n11=0;
857     n12=2;
858     }
859     if (n13==2) {
860     n11=0;
861     n12=1;
862     }
863     OT_TENSEUR *inertie_base_locale1=faceref1->get_vectorisation().get_tenseur_inertie_base_locale_3d();
864     if ((*inertie_base_locale1)(n11,n11)<(*inertie_base_locale1)(n12,n12)) {
865     int tmp=n11;
866     n11=n12;
867     n12=tmp;
868     }
869     OT_VECTEUR_3DD x11((*axe1)(0,n11),(*axe1)(1,n11),(*axe1)(2,n11));
870     OT_VECTEUR_3DD x13((*axe1)(0,n13)*signe13,(*axe1)(1,n13)*signe13,(*axe1)(2,n13)*signe13);
871     OT_VECTEUR_3DD x12=x13 & x11;
872     (tnsref1)(0,0)=x11.get_x();
873     (tnsref1)(1,0)=x11.get_y();
874     (tnsref1)(2,0)=x11.get_z();
875     (tnsref1)(0,1)=x12.get_x();
876     (tnsref1)(1,1)=x12.get_y();
877     (tnsref1)(2,1)=x12.get_z();
878     (tnsref1)(0,2)=x13.get_x();
879     (tnsref1)(1,2)=x13.get_y();
880     (tnsref1)(2,2)=x13.get_z();
881     int nbtest1=1;
882 francois 361 if ((*inertie_base_locale1)(n11,n11)==(*inertie_base_locale1)(n12,n12)) nbtest1=2; //nbtest1=2;
883 francois 283 for (int test1=0;test1<nbtest1;test1++)
884     {
885     if (test1==1)
886     {
887     OT_VECTEUR_3DD x11((*axe1)(0,n12),(*axe1)(1,n12),(*axe1)(2,n12));
888     OT_VECTEUR_3DD x12=x13 & x11;
889     (tnsref1)(0,0)=x11.get_x();
890     (tnsref1)(1,0)=x11.get_y();
891     (tnsref1)(2,0)=x11.get_z();
892     (tnsref1)(0,1)=x12.get_x();
893     (tnsref1)(1,1)=x12.get_y();
894     (tnsref1)(2,1)=x12.get_z();
895     (tnsref1)(0,2)=x13.get_x();
896     (tnsref1)(1,2)=x13.get_y();
897     (tnsref1)(2,2)=x13.get_z();
898     }
899     OT_TENSEUR inv1=tnsref1.transpose();
900     int nbpt1=faceref1->get_vectorisation().get_points_controle().size();
901     OT_VECTEUR_3DD bary1xp,bary1yp,bary1xn,bary1yn;
902     int xp1=0,yp1=0,xn1=0,yn1=0;
903     for (int i=0;i<nbpt1;i++)
904     {
905     OT_VECTEUR_4DD pt=faceref1->get_vectorisation().get_points_controle()[i];
906     OT_VECTEUR_3DD point(pt[0],pt[1],pt[2]);
907     point=point-(*bary1);
908     point=inv1*point;
909     if (point.get_x()>zero)
910     {
911     bary1xp=bary1xp+point;
912     xp1++;
913     }
914     if (point.get_x()<zero)
915     {
916     bary1xn=bary1xn+point;
917     xn1++;
918     }
919     if (point.get_y()>zero)
920     {
921     bary1yp=bary1yp+point;
922     yp1++;
923     }
924     if (point.get_y()<zero)
925     {
926     bary1xn=bary1xn+point;
927     yn1++;
928     }
929     }
930     bary1xp=bary1xp/xp1;
931     bary1xn=bary1xn/xn1;
932     bary1yp=bary1yp/yp1;
933     bary1yp=bary1yp/yn1;
934     //repere2
935     OT_VECTEUR_3DD *bary2=faceref2->get_vectorisation().get_barycentre_3d();
936     double xyz2[3]={bary2->get_x().get_x(),bary2->get_y().get_x(),bary2->get_z().get_x()};
937     double uvproj2[2],xyzproj2[3];
938     ot.projete(xyz2,faceref2,uvproj2,xyzproj2);
939     double normal2[3];
940     faceref2->calcul_normale_unitaire(uvproj2,normal2);
941     double2 normal22[3];
942     normal22[0]=normal2[0];
943     normal22[1]=normal2[1];
944     normal22[2]=normal2[2];
945     OT_VECTEUR_3DD nor2(normal22);
946     int sens2=faceref2->get_mg_coface(0)->get_orientation();
947     nor2=sens2*nor2;
948     OT_TENSEUR *axe2=faceref2->get_vectorisation().get_base_locale_3d();
949     int n23=-1;
950     int signe23=1;
951     double2 limit2(0.);
952     for (int i=0;i<3;i++)
953     {
954     OT_VECTEUR_3DD veci;
955     veci[0]=(*axe2)(0,i);
956     veci[1]=(*axe2)(1,i);
957     veci[2]=(*axe2)(2,i);
958     double2 ps=veci*nor2;
959     if (f2abs(ps)>limit2)
960     {
961     n23=i;
962     if (ps<zero) signe23=-1;
963     limit2=f2abs(ps);
964     }
965     }
966     int n21,n22;
967     if (n23==0) {
968     n21=1;
969     n22=2;
970     }
971     if (n23==1) {
972     n21=0;
973     n22=2;
974     }
975     if (n23==2) {
976     n21=0;
977     n22=1;
978     }
979     OT_TENSEUR *inertie_base_locale2=faceref2->get_vectorisation().get_tenseur_inertie_base_locale_3d();
980     if ((*inertie_base_locale2)(n21,n21)<(*inertie_base_locale2)(n22,n22)) {
981     int tmp=n21;
982     n21=n22;
983     n22=tmp;
984     }
985     OT_VECTEUR_3DD x21((*axe2)(0,n21),(*axe2)(1,n21),(*axe2)(2,n21));
986     OT_VECTEUR_3DD x23((*axe2)(0,n23)*signe23,(*axe2)(1,n23)*signe23,(*axe2)(2,n23)*signe23);
987     OT_VECTEUR_3DD x22=x23 & x21;
988     (tnsref2)(0,0)=x21.get_x();
989     (tnsref2)(1,0)=x21.get_y();
990     (tnsref2)(2,0)=x21.get_z();
991     (tnsref2)(0,1)=x22.get_x();
992     (tnsref2)(1,1)=x22.get_y();
993     (tnsref2)(2,1)=x22.get_z();
994     (tnsref2)(0,2)=x23.get_x();
995     (tnsref2)(1,2)=x23.get_y();
996     (tnsref2)(2,2)=x23.get_z();
997     int nbtest2=1;
998     if ((*inertie_base_locale2)(n21,n21)==(*inertie_base_locale2)(n22,n22)) nbtest1=0; //nbtest2=2;
999     for (int test2=0;test2<nbtest2;test2++)
1000     {
1001     if (test2==1)
1002     {
1003     OT_VECTEUR_3DD x21((*axe1)(0,n22),(*axe1)(1,n22),(*axe1)(2,n22));
1004     OT_VECTEUR_3DD x22=x23 & x21;
1005     (tnsref2)(0,0)=x21.get_x();
1006     (tnsref2)(1,0)=x21.get_y();
1007     (tnsref2)(2,0)=x21.get_z();
1008     (tnsref2)(0,1)=x22.get_x();
1009     (tnsref2)(1,1)=x22.get_y();
1010     (tnsref2)(2,1)=x22.get_z();
1011     (tnsref2)(0,2)=x23.get_x();
1012     (tnsref2)(1,2)=x23.get_y();
1013     (tnsref2)(2,2)=x23.get_z();
1014     }
1015     OT_TENSEUR inv2=tnsref2.transpose();
1016     int nbpt2=faceref2->get_vectorisation().get_points_controle().size();
1017     OT_VECTEUR_3DD bary2xp,bary2yp,bary2xn,bary2yn;
1018     int xp2=0,yp2=0,xn2=0,yn2=0;
1019     for (int i=0;i<nbpt2;i++)
1020     {
1021     OT_VECTEUR_4DD pt=faceref2->get_vectorisation().get_points_controle()[i];
1022     OT_VECTEUR_3DD point(pt[0],pt[1],pt[2]);
1023     point=point-(*bary2);
1024     point=inv2*point;
1025     if (point.get_x()>zero)
1026     {
1027     bary2xp=bary2xp+point;
1028     xp2++;
1029     }
1030     if (point.get_x()<zero)
1031     {
1032     bary2xn=bary2xn+point;
1033     xn2++;
1034     }
1035     if (point.get_y()>zero)
1036     {
1037     bary2yp=bary2yp+point;
1038     yp2++;
1039     }
1040     if (point.get_y()<zero)
1041     {
1042     bary2xn=bary2xn+point;
1043     yn2++;
1044     }
1045     }
1046     bary2xp=bary2xp/xp2;
1047     bary2xn=bary2xn/xn2;
1048     bary2yp=bary2yp/yp2;
1049     bary2yp=bary2yp/yn2;
1050    
1051     if ((bary2xp==bary1xp) && (bary2xn==bary1xn) && (bary2yp==bary1yp) && (bary2yn==bary1yn))
1052     {
1053     list.insert(list.end(),tnsref1);
1054     list.insert(list.end(),tnsref2);
1055     }
1056     OT_VECTEUR_3DD vnul(zero,zero,zero);
1057     bary2xp=vnul;
1058     bary2xn=vnul;
1059     bary2yp=vnul;
1060     bary2yp=vnul;
1061    
1062     tnsref2(0,0)=zero-tnsref2(0,0);
1063     tnsref2(1,0)=zero-tnsref2(1,0);
1064     tnsref2(2,0)=zero-tnsref2(2,0);
1065     tnsref2(0,1)=zero-tnsref2(0,1);
1066     tnsref2(1,1)=zero-tnsref2(1,1);
1067     tnsref2(2,1)=zero-tnsref2(2,1);
1068    
1069     inv2=tnsref2.transpose();
1070     xp2=0,yp2=0,xn2=0,yn2=0;
1071     for (int i=0;i<nbpt2;i++)
1072     {
1073     OT_VECTEUR_4DD pt=faceref2->get_vectorisation().get_points_controle()[i];
1074     OT_VECTEUR_3DD point(pt[0],pt[1],pt[2]);
1075     point=point-(*bary2);
1076     point=inv2*point;
1077     if (point.get_x()>zero)
1078     {
1079     bary2xp=bary2xp+point;
1080     xp2++;
1081     }
1082     if (point.get_x()<zero)
1083     {
1084     bary2xn=bary2xn+point;
1085     xn2++;
1086     }
1087     if (point.get_y()>zero)
1088     {
1089     bary2yp=bary2yp+point;
1090     yp2++;
1091     }
1092     if (point.get_y()<zero)
1093     {
1094     bary2xn=bary2xn+point;
1095     yn2++;
1096     }
1097     }
1098     bary2xp=bary2xp/xp2;
1099     bary2xn=bary2xn/xn2;
1100     bary2yp=bary2yp/yp2;
1101     bary2yp=bary2yp/yn2;
1102     if ((bary2xp==bary1xp) && (bary2xn==bary1xn) && (bary2yp==bary1yp) && (bary2yn==bary1yn))
1103     {
1104     list.insert(list.end(),tnsref1);
1105     list.insert(list.end(),tnsref2);
1106     }
1107     }
1108     }
1109    
1110     }
1111    
1112    
1113     void VCT_COMPARAISON::choisir_une_couleur(double& val)
1114     {
1115     unsigned char r=rand() % 255;
1116     unsigned char g=rand() % 255;
1117     unsigned char b=rand() % 255;
1118     val=0.;
1119     unsigned char* p =(unsigned char*)&val;
1120     *p=r;
1121     p++;
1122     *p=g;
1123     p++;
1124     *p=b;
1125    
1126     }
1127    
1128    
1129     double VCT_COMPARAISON::recherche_couleur(MG_ELEMENT_TOPOLOGIQUE* ele)
1130     {
1131     double val=-1;
1132     int nbccf=ele->get_nb_ccf();
1133     for (int i=0;i<nbccf;i++)
1134     {
1135     char nom[10];
1136     ele->get_type_ccf(i,nom);
1137     if (strcmp(nom,"Cc")==0) val=ele->get_valeur_ccf(i);
1138     }
1139     return val;
1140     }
1141    
1142     void VCT_COMPARAISON::supprime_couleur(MG_ELEMENT_TOPOLOGIQUE* ele)
1143     {
1144     int nbccf=ele->get_nb_ccf();
1145     for (int i=0;i<nbccf;i++)
1146     {
1147     char nom[10];
1148     ele->get_type_ccf(i,nom);
1149     if (strcmp(nom,"Cc")==0) {
1150     ele->supprimer_ccf(i);
1151     nbccf--;
1152     i--;
1153     }
1154     }
1155     }
1156    
1157     void VCT_COMPARAISON::affecter_les_couleurs(TPL_LISTE_ENTITE<int>& liste)
1158     {
1159     int nb_face1=mggeo1->get_nb_mg_face();
1160     for (int i=0;i<nb_face1;i++)
1161     supprime_couleur(mggeo1->get_mg_face(i));
1162     int nb_face2=mggeo2->get_nb_mg_face();
1163     for (int i=0;i<nb_face2;i++)
1164     supprime_couleur(mggeo2->get_mg_face(i));
1165     TPL_LISTE_ENTITE<double> lst_val;
1166     int nbpaire=liste.get_nb()/2;
1167     for (int i=0;i<nbpaire;i++)
1168     {
1169     MG_FACE* ele1=mggeo1->get_mg_faceid(liste.get(2*i));
1170     MG_FACE* ele2=mggeo2->get_mg_faceid(liste.get(2*i+1));
1171     double val1=recherche_couleur(ele1);
1172     double val2=recherche_couleur(ele2);
1173     double val;
1174     if (val1<0.)
1175     {
1176     if (val2<0.)
1177     {
1178     do
1179     {
1180     choisir_une_couleur(val);
1181     }
1182     while (lst_val.est_dans_la_liste(val));
1183     lst_val.ajouter(val);
1184     }
1185     else val=val2;
1186     }
1187     else val=val1;
1188     if (val1<0.) ele1->ajouter_ccf((char*)"Cc",val);
1189     if (val2<0.) ele2->ajouter_ccf((char*)"Cc",val);
1190     }
1191     }
1192    
1193    
1194    
1195    
1196    
1197    
1198    
1199    
1200    
1201    
1202    
1203    
1204    
1205    
1206     #ifdef TA_GUEULE
1207     void VCT_COMPARAISON::compare_les_deux_geometries(int affiche_couleur)
1208     {
1209     int nb_face1=mggeo1->get_nb_mg_face();
1210     int nb_face2=mggeo2->get_nb_mg_face();
1211    
1212     for (int i=0;i<nb_face1; i++)
1213     {
1214     OT_VECTEUR_4DD Dv1,Dv2,G1,G2;
1215     OT_TENSEUR V1(4),V2(4);
1216     MG_FACE* face1=mggeo1->get_mg_face(i);
1217     MG_SURFACE*surf1=face1->get_surface();
1218     G1=surf1->get_vectorisation().calcule_barycentre(T1);
1219     G1=surf1->get_vectorisation().get_nouveau_pt(T1,G1);
1220     int id1=face1->get_id();
1221     OT_TENSEUR tns1_face(4),tns1_surf(4);
1222     OT_TENSEUR ttns1_face(4),ttns1_surf(4);
1223     int nb_top1_pts= face1->get_vectorisation().get_nb_points();
1224     int nb_geo1_pts= surf1->get_vectorisation().get_nb_points();
1225    
1226     face1->get_vectorisation().calcule_axes_dinertie(T1,Dv1,V1);
1227     tns1_face=face1->get_vectorisation().calcule_tenseur_metrique();
1228     tns1_surf=surf1->get_vectorisation().calcule_tenseur_metrique();
1229    
1230     ttns1_face=face1->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
1231     ttns1_surf=surf1->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
1232     vector<double2> ifac1;
1233     vector<double2>isurf1;
1234     for (int r=0;r<4;r++)
1235     {
1236     ifac1.insert( ifac1.end(), ttns1_face(r,r));
1237     isurf1.insert( isurf1.end(), ttns1_surf(r,r));
1238     }
1239     int cmpt=0;
1240     for (int j=0;j<nb_face2;j++)
1241     {
1242     MG_FACE* face2=mggeo2->get_mg_face(j);
1243     MG_SURFACE*surf2=face2->get_surface();
1244     G2=surf2->get_vectorisation().calcule_barycentre(T2);
1245     int id2=face2->get_id();
1246     OT_TENSEUR tns2_face(4),tns2_surf(4);
1247     OT_TENSEUR ttns2_face(4),ttns2_surf(4);
1248     int nb_top2_pts= face2->get_vectorisation().get_nb_points();
1249     int nb_geo2_pts= surf2->get_vectorisation().get_nb_points();
1250    
1251     face2->get_vectorisation().calcule_axes_dinertie(T2,Dv1,V1);
1252     tns2_face=face2->get_vectorisation().calcule_tenseur_metrique();
1253     tns2_surf=surf2->get_vectorisation().calcule_tenseur_metrique();
1254    
1255     ttns2_face=face2->get_vectorisation().calcule_tenseur_inertie_base_locale(T2);
1256     ttns2_surf=surf2->get_vectorisation().calcule_tenseur_inertie_base_locale(T2);
1257     vector<double2> ifac2;
1258     vector<double2> isurf2;
1259     for (int r=0;r<4;r++)
1260     {
1261     ifac2.insert( ifac2.end(), ttns2_face(r,r));
1262     isurf2.insert( isurf2.end(), ttns2_surf(r,r));
1263     }
1264    
1265     if (nb_geo1_pts==nb_geo2_pts&&nb_top1_pts==nb_top2_pts)
1266     {
1267     if (tns1_face.est_til_equivalent(tns2_face))
1268     {
1269     verifier_le_repere(V1,V2,ifac1,ifac2);
1270     if (tns1_surf.est_til_equivalent(tns2_surf))
1271     {
1272     similarite.ajouter(id1);
1273     similarite.ajouter(id2);
1274     vector<unsigned int> indx1,indx2;
1275     if (ttns1_face.listes_equivalentes(isurf1,isurf2,indx2))
1276     {
1277     if (G1==G2)
1278     {
1279     surf_ident.ajouter(id1);
1280     surf_ident.ajouter(id2);
1281     }
1282    
1283     if (ttns1_face.listes_equivalentes(ifac1,ifac2,indx1))
1284     {
1285     sim_double.ajouter(id1) ;
1286     sim_double.ajouter(id2) ;
1287     cmpt++;
1288     }
1289     }
1290    
1291     }
1292     }
1293     }
1294     }
1295    
1296     nb_sim.ajouter(cmpt);
1297     }
1298    
1299     if (sim_double.get_nb()==0)
1300     {
1301     sim_double=surf_ident;
1302     }
1303     if (affiche_couleur) this->affecter_les_couleurs(23);
1304     }
1305    
1306    
1307    
1308     void VCT_COMPARAISON::trouver_les_identites(int affiche_couleur)
1309     {
1310    
1311     TPL_LISTE_ENTITE<int> lst_fin;
1312     TPL_LISTE_ENTITE<int> lst;
1313     this->compare_les_deux_geometries(0);
1314     int nb_face1=mggeo1->get_nb_mg_face();
1315     int nb_face2=mggeo2->get_nb_mg_face();
1316    
1317    
1318    
1319    
1320     this->trouve_face_de_reference(face_ref1,face_ref2);//,ls,lst_fin
1321    
1322     OT_VECTEUR_4DD Dv,Dv1,Dv2,G1ref,G2ref,g1g2;
1323     OT_TENSEUR V(4),V1(4),V2(4);
1324     OT_VECTEUR_4DD g1_ref,g2_ref;
1325     MG_FACE* face1_ref=mggeo1->get_mg_faceid(face_ref1);
1326     //MG_SURFACE* surf1_ref=face1_ref->get_surface();
1327     //G1ref= surf1_ref->get_vectorisation().calcule_barycentre(T1);
1328     G1ref= face1_ref->get_vectorisation().calcule_barycentre(T1);
1329     G1ref= face1_ref->get_vectorisation().get_nouveau_pt(T1,G1ref);
1330     //face1_ref->get_vectorisation().calcule_axes_dinertie(T1,Dv1,V1);
1331     /*
1332     for(int r=0;r<4;r++) {
1333     for(int s=0;s<4;s++) {
1334     g1_ref[r]= g1_ref[r]+V1(s,r)*G1[s];
1335     }
1336     }
1337     */
1338    
1339     MG_FACE* face2_ref=mggeo2->get_mg_faceid(face_ref2);
1340     //face2_ref->get_vectorisation().calcule_axes_dinertie(T2,Dv2,V2);
1341     //MG_SURFACE* surf2_ref=face2_ref->get_surface();
1342     //G2ref= surf2_ref->get_vectorisation().calcule_barycentre(T2);
1343     G2ref= face2_ref->get_vectorisation().calcule_barycentre(T2);
1344     /*
1345     for(int r=0;r<4;r++) {
1346     for(int s=0;s<4;s++) {
1347     g2_ref[r]= g2_ref[r]+V2(s,r)*G2[s];
1348     }
1349     }
1350     */
1351    
1352     OT_VECTEUR_4DD g1refg1,g2refg2;
1353    
1354    
1355    
1356     for (int i=0;i<nb_face1;i++)
1357     {
1358    
1359     OT_VECTEUR_4DD g1,G1;
1360     MG_FACE* face1=mggeo1->get_mg_face(i);
1361     int id1=face1->get_id();
1362     G1= face1->get_vectorisation().calcule_barycentre(T1);
1363     G1= face1->get_vectorisation().get_nouveau_pt(T1,G1);
1364     /*
1365     for(int r=0;r<4;r++) {
1366     for(int s=0;s<4;s++) {
1367     g1[r]= g1[r]+V1(s,r)*G1[s];
1368     }
1369     }
1370     */
1371     g1refg1=G1-G1ref;
1372     g1refg1=face1->get_vectorisation().get_nouveau_pt(T1,g1refg1);
1373     //g1refg1=g1-g1_ref;
1374     // num2=list.get(2*i+1);
1375     for (int j=0;j<nb_face2;j++)
1376     {
1377    
1378     OT_VECTEUR_4DD g2,G2,g12refg2;
1379    
1380     MG_FACE* face2=mggeo2->get_mg_face(j);
1381     int id2=face2->get_id();
1382     G2= face2->get_vectorisation().calcule_barycentre(T2);
1383    
1384     /* for(int r=0;r<4;r++) {
1385     for(int s=0;s<4;s++) {
1386     g2[r]= g2[r]+V2(s,r)*G2[s];
1387     }
1388     }
1389     */
1390     //OT_VECTEUR_4DD g2refg2=g2-g2_ref;
1391     // g12refg2=G2-G2ref;
1392     OT_VECTEUR_4DD g2refg2=G2-G2ref;
1393     //OT_VECTEUR_4DD dif= g1refg1-g2refg2;
1394     //double2 prec=1e-6;
1395     // if(dif[0].get_fabs()<=prec&&dif[1].get_fabs()<=prec&&dif[2].get_fabs()<=prec&&dif[3].get_fabs()<=prec)
1396     if (g2refg2==g1refg1)
1397     {
1398     identite.ajouter(id1);
1399     identite.ajouter(id2);
1400    
1401     break;
1402     }
1403     }
1404     }
1405    
1406    
1407    
1408    
1409     if (affiche_couleur) this->affecter_les_couleurs(1);
1410    
1411     }
1412    
1413    
1414    
1415     void VCT_COMPARAISON::compare_les_deux_geometries_vectoriellement(int affiche_couleur)
1416     {
1417     int nb_face1=mggeo1->get_nb_mg_face();
1418     int nb_face2=mggeo2->get_nb_mg_face();
1419     similarite.vide();
1420     for (int i=0;i<nb_face1; i++)
1421     {
1422     MG_FACE* face1=mggeo1->get_mg_face(i);
1423     MG_SURFACE*surf1=face1->get_surface();
1424     int id1=face1->get_id();
1425     OT_TENSEUR tns1_face(4),tns1_surf(4);
1426     OT_TENSEUR ttns1_face(4),ttns1_surf(4);
1427     int nb_top1_pts= face1->get_vectorisation().get_nb_points();
1428     int nb_geo1_pts= surf1->get_vectorisation().get_nb_points();
1429    
1430     tns1_face=face1->get_vectorisation().calcule_tenseur_metrique();
1431     tns1_surf=surf1->get_vectorisation().calcule_tenseur_metrique();
1432    
1433     for (int j=0;j<nb_face2;j++)
1434     {
1435     MG_FACE* face2=mggeo2->get_mg_face(j);
1436     MG_SURFACE*surf2=face2->get_surface();
1437     int id2=face2->get_id();
1438     OT_TENSEUR tns2_face(4),tns2_surf(4);
1439     OT_TENSEUR ttns2_face(4),ttns2_surf(4);
1440     int nb_top2_pts= face2->get_vectorisation().get_nb_points();
1441     int nb_geo2_pts= surf2->get_vectorisation().get_nb_points();
1442     tns2_face=face2->get_vectorisation().calcule_tenseur_metrique();
1443     tns2_surf=surf2->get_vectorisation().calcule_tenseur_metrique();
1444    
1445     if (nb_geo1_pts==nb_geo2_pts&&nb_top1_pts==nb_top2_pts)
1446     {
1447     if (tns1_face.est_til_equivalent(tns2_face))
1448     {
1449     if (tns1_surf.est_til_equivalent(tns2_surf))
1450     {
1451     similarite.ajouter(id1);
1452     similarite.ajouter(id2);
1453     }
1454     }
1455     }
1456     }
1457     }
1458     if (affiche_couleur)this->affecter_les_couleurs(21);
1459    
1460     }
1461    
1462     void VCT_COMPARAISON::compare_les_deux_geometries_inertiellement (int affiche_couleur)
1463     {
1464    
1465    
1466     int nb_face1=mggeo1->get_nb_mg_face();
1467     int nb_face2=mggeo2->get_nb_mg_face();
1468     ssimilarite.vide();
1469     for (int i=0;i<nb_face1; i++)
1470     {
1471     MG_FACE* face1=mggeo1->get_mg_face(i);
1472     MG_SURFACE*surf1=face1->get_surface();
1473     int id1=face1->get_id();
1474     OT_TENSEUR tns1_face(4),tns1_surf(4);
1475     int nb_top1_pts= face1->get_vectorisation().get_nb_points();
1476     int nb_geo1_pts= surf1->get_vectorisation().get_nb_points();
1477    
1478     tns1_face=face1->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
1479     tns1_surf=surf1->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
1480     vector<double2> ifac1;
1481     vector<double2>isurf1;
1482     for (int r=0;r<4;r++)
1483     {
1484     ifac1.insert( ifac1.end(), tns1_face(r,r));
1485     isurf1.insert( isurf1.end(), tns1_surf(r,r));
1486     }
1487    
1488     for (int j=0;j<nb_face2;j++)
1489     {
1490    
1491     MG_FACE* face2=mggeo2->get_mg_face(j);
1492     MG_SURFACE*surf2=face2->get_surface();
1493     int id2=face2->get_id();
1494     OT_TENSEUR tns2_face(4),tns2_surf(4);
1495     int nb_top2_pts= face2->get_vectorisation().get_nb_points();
1496     int nb_geo2_pts= surf2->get_vectorisation().get_nb_points();
1497     *tns2_face=face2->get_vectorisation().get_tenseur_inertie_base_locale();
1498     *tns2_surf=surf2->get_vectorisation().get_tenseur_inertie_base_locale();
1499     vector<double2> ifac2;
1500     vector<double2> isurf2;
1501     for (int r=0;r<4;r++)
1502     {
1503     ifac2.insert( ifac2.end(), *tns2_face(r,r));
1504     isurf2.insert( isurf2.end(), *tns2_surf(r,r));
1505     }
1506    
1507     if (nb_geo1_pts==nb_geo2_pts&&nb_top1_pts==nb_top2_pts)
1508     {
1509     vector<unsigned int> indx1,indx2;
1510     if (tns1_face.listes_equivalentes(ifac1,ifac2,indx1))
1511     {
1512     if (tns1_face.listes_equivalentes(isurf1,isurf2,indx2))
1513     {
1514     ssimilarite.ajouter(id1);
1515     ssimilarite.ajouter(id2);
1516     }
1517     }
1518     }
1519    
1520     }
1521    
1522     }
1523    
1524     if (affiche_couleur)affecter_les_couleurs(22);
1525     }
1526    
1527     void VCT_COMPARAISON::compare_une_geometrie_inertiellement(int modele)
1528     {
1529    
1530    
1531     TPL_LISTE_ENTITE<int> ssim_tmp;
1532    
1533     MG_GESTIONNAIRE *gst1;
1534     MG_GEOMETRIE *mgeo1 ;
1535     int laquelle;
1536    
1537     switch (modele)
1538     {
1539     case 1:
1540     {
1541     gst1=gest1;
1542     mgeo1=mggeo1;
1543     laquelle=31;
1544     break;
1545     }
1546     case 2:
1547     {
1548     gst1=gest2;
1549     mgeo1=mggeo2;
1550     laquelle=32;
1551     break;
1552     }
1553    
1554     }
1555    
1556     int nb_face1=mgeo1->get_nb_mg_face();
1557    
1558     for (int i=0;i<nb_face1; i++)
1559     {
1560     MG_FACE* face1=mgeo1->get_mg_face(i);
1561     MG_SURFACE*surf1=face1->get_surface();
1562     int id1=face1->get_id();
1563     OT_TENSEUR tns1_face(4),tns1_surf(4);
1564     int nb_top1_pts= face1->get_vectorisation().get_nb_points();
1565     int nb_geo1_pts= surf1->get_vectorisation().get_nb_points();
1566    
1567     tns1_face=face1->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
1568     tns1_surf=surf1->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
1569     vector<double2> ifac1;
1570     vector<double2>isurf1;
1571     for (int r=0;r<4;r++)
1572     {
1573     ifac1.insert( ifac1.end(), tns1_face(r,r));
1574     isurf1.insert( isurf1.end(), tns1_surf(r,r));
1575     }
1576    
1577     for (int j=0;j<nb_face1;j++)
1578     {
1579    
1580     MG_FACE* face2=mgeo1->get_mg_face(j);
1581     MG_SURFACE*surf2=face2->get_surface();
1582     int id2=face2->get_id();
1583     OT_TENSEUR tns2_face(4),tns2_surf(4);
1584     int nb_top2_pts= face2->get_vectorisation().get_nb_points();
1585     int nb_geo2_pts= surf2->get_vectorisation().get_nb_points();
1586     tns2_face=face2->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
1587     tns2_surf=surf2->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
1588     vector<double2> ifac2;
1589     vector<double2> isurf2;
1590     for (int r=0;r<4;r++)
1591     {
1592     ifac2.insert( ifac2.end(), tns2_face(r,r));
1593     isurf2.insert( isurf2.end(), tns2_surf(r,r));
1594     }
1595    
1596     if (nb_geo1_pts==nb_geo2_pts&&nb_top1_pts==nb_top2_pts)
1597     {
1598     vector<unsigned int> indx1,indx2;
1599     if (tns1_face.listes_equivalentes(ifac1,ifac2,indx1))
1600     {
1601     if (tns1_face.listes_equivalentes(isurf1,isurf2,indx2))
1602     {
1603     ssim_tmp.ajouter(id1);
1604     ssim_tmp.ajouter(id2);
1605     }
1606     }
1607     }
1608    
1609     }
1610    
1611     }
1612     if (modele==1) ssim1=ssim_tmp;
1613     if (modele==2) ssim2=ssim_tmp;
1614    
1615     affecter_les_couleurs(laquelle);
1616     }
1617    
1618    
1619    
1620    
1621     TPL_LISTE_ENTITE<int> VCT_COMPARAISON::get_liste_des_identitees()
1622     {
1623     return identite;
1624     }
1625    
1626     TPL_LISTE_ENTITE<int> VCT_COMPARAISON::get_liste_des_simalarite_vectorielle(int type_comparais)
1627     {
1628     TPL_LISTE_ENTITE<int> lst_tmp;
1629     switch ( type_comparais)
1630     {
1631     case 12:
1632     lst_tmp= similarite;
1633     case 1:
1634     lst_tmp= sim1;
1635     case 2:
1636     lst_tmp= sim2;
1637     }
1638     return lst_tmp;
1639     }
1640    
1641     TPL_LISTE_ENTITE<int> VCT_COMPARAISON::get_liste_des_simalarite_inertielle(int type_comparais)
1642     {
1643     TPL_LISTE_ENTITE<int> lst_tmp;
1644     switch ( type_comparais)
1645     {
1646     case 12:
1647     lst_tmp= ssimilarite;
1648     case 1:
1649     lst_tmp= ssim1;
1650     case 2:
1651     lst_tmp= ssim2;
1652     }
1653     return lst_tmp;
1654     }
1655    
1656    
1657     void VCT_COMPARAISON::affecter_les_couleurs(int niveau)
1658     {
1659     //randomize();
1660     int nb_face_ident=similarite.get_nb()/2;
1661     int nb_face_identt=ssimilarite.get_nb()/2;
1662     int nb_face_iden=identite.get_nb()/2;
1663     double val;
1664     TPL_LISTE_ENTITE<int> lst;
1665     TPL_LISTE_ENTITE<double> lst_val;
1666     int num1,num2,num1_avant ;
1667     if (niveau==1) //pour afficher les identites entre le deux mod�les
1668     {
1669     for (int i=0;i< nb_face_iden;i++)
1670     {
1671     num1=identite.get(2*i) ;
1672     num2=identite.get(2*i+1) ;
1673     if (i>0) num1_avant= identite.get(2*(i-1));
1674     MG_FACE* face1=mggeo1->get_mg_faceid(num1);
1675     MG_FACE* face2=mggeo2->get_mg_faceid(num2);
1676    
1677     if (i==0)
1678     {
1679     choisir_une_couleur(val);
1680     while (lst_val.est_dans_la_liste(val))
1681     {
1682     choisir_une_couleur(val);
1683     }
1684     face1->ajouter_ccf("Cc",val);
1685     face2->ajouter_ccf("Cc",val);
1686     lst_val.ajouter(val);
1687     }
1688    
1689     if (i>0)
1690     {
1691     if (num1!=num1_avant)
1692     {
1693     choisir_une_couleur(val);
1694     while (lst_val.est_dans_la_liste(val))
1695     {
1696     choisir_une_couleur(val);
1697     }
1698     face1->ajouter_ccf("Cc",val);
1699     face2->ajouter_ccf("Cc",val);
1700     lst_val.ajouter(val);
1701     }
1702     else {
1703     face2->ajouter_ccf("Cc",val);
1704     }
1705    
1706     }
1707     }
1708    
1709     }
1710    
1711     if (niveau==21||niveau==22||niveau==23) //pour afficher la similarite entre le deux mod�le vectoriellement ou inertiellement
1712     {
1713     TPL_LISTE_ENTITE<int> simu;
1714     if (niveau==21)simu=similarite;
1715     if (niveau==22) simu=ssimilarite;
1716     if (niveau==23) simu=sim_double;
1717     TPL_LISTE_ENTITE<int> llst1;
1718     TPL_LISTE_ENTITE<int> llst2;
1719     int nb_face_sim=simu.get_nb()/2.;
1720     for (int i=0;i< nb_face_sim;i++)
1721     {
1722     TPL_LISTE_ENTITE<int> lst1;
1723     TPL_LISTE_ENTITE<int> lst2;
1724     TPL_LISTE_ENTITE<int> llst3;
1725     num1=simu.get(2*i) ;
1726     if (!llst1.est_dans_la_liste(num1))
1727     {
1728     num2=simu.get(2*i+1) ;
1729     lst1.ajouter(num1);
1730     lst2.ajouter(num2);
1731     llst1.ajouter(num1);
1732     llst2.ajouter(num2);
1733     for (int j=1;j< nb_face_sim;j++)
1734     {
1735     int Num1=simu.get(2*j) ;
1736     int Num2=simu.get(2*j+1) ;
1737    
1738     if (num1==Num1)
1739     {
1740     llst3.ajouter(Num2);
1741     }
1742     if (num2==Num2||llst3.est_dans_la_liste(Num2))
1743     {
1744     if (!lst1.est_dans_la_liste(Num1)) {
1745     lst1.ajouter(Num1);
1746     llst1.ajouter(Num1);
1747     }
1748     if (!lst2.est_dans_la_liste(Num2)) {
1749     lst2.ajouter(Num2);
1750     llst2.ajouter(Num2);
1751     }
1752     }
1753    
1754     }
1755    
1756     choisir_une_couleur(val);
1757     while (lst_val.est_dans_la_liste(val))
1758     {
1759     choisir_une_couleur(val);
1760     }
1761     lst_val.ajouter(val);
1762     int nb1=lst1.get_nb();
1763     int nb2=lst2.get_nb();
1764     for (int i=0;i<nb1;i++)
1765     {
1766     int n1=lst1.get(i);
1767     MG_FACE* face1=mggeo1->get_mg_faceid(n1);
1768     face1->ajouter_ccf("Cc",val);
1769     }
1770     for (int i=0;i<nb2;i++)
1771     {
1772     int n2=lst2.get(i);
1773     MG_FACE* face2=mggeo2->get_mg_faceid(n2);
1774     face2->ajouter_ccf("Cc",val);
1775     }
1776    
1777     }
1778     }
1779    
1780    
1781     }
1782    
1783     if (niveau== 31||niveau==32) //pour afficher la similarite dans le premier mod�le ou le second modele
1784     {
1785    
1786     MG_GEOMETRIE *mgeo1 ;
1787     int laquelle;
1788    
1789     switch (niveau)
1790     {
1791     case 31:
1792     {
1793     mgeo1=mggeo1;
1794     laquelle=31;
1795     break;
1796     }
1797     case 32:
1798     {
1799     mgeo1=mggeo2;
1800     laquelle=32;
1801     break;
1802     }
1803    
1804     }
1805    
1806    
1807     for (int i=0;i< nb_face_identt;i++)
1808     {
1809     num1=ssimilarite.get(2*i) ;
1810     num2=ssimilarite.get(2*i+1) ;
1811    
1812     if (i>0) num1_avant= ssimilarite.get(2*(i-1));
1813     MG_FACE* face1=mgeo1->get_mg_faceid(num1);
1814     MG_FACE* face2=mgeo1->get_mg_faceid(num2);
1815     if (!lst.est_dans_la_liste(num2))
1816     {
1817     if (i==0)
1818     {
1819     choisir_une_couleur(val);
1820     while (lst_val.est_dans_la_liste(val))
1821     {
1822     choisir_une_couleur(val);
1823     }
1824     face1->ajouter_ccf("Cc",val);
1825     if (num1!=num2) face2->ajouter_ccf("Cc",val);
1826     lst.ajouter(num2);
1827     lst_val.ajouter(val);
1828     }
1829    
1830     if (i>0)
1831     {
1832     if (num1!=num1_avant)
1833     {
1834     choisir_une_couleur(val);
1835     while (lst_val.est_dans_la_liste(val))
1836     {
1837     choisir_une_couleur(val);
1838     }
1839     face1->ajouter_ccf("Cc",val);
1840     if (num1!=num2) face2->ajouter_ccf("Cc",val);
1841     lst.ajouter(num2);
1842     lst_val.ajouter(val);
1843     }
1844     else {
1845     if (num1!=num2) face2->ajouter_ccf("Cc",val);
1846     lst.ajouter(num2);
1847     }
1848    
1849     }
1850     }
1851     }
1852    
1853    
1854     }
1855    
1856    
1857     }
1858    
1859    
1860     void VCT_COMPARAISON::choisir_une_couleur(double& val)
1861     {
1862     //randomize();
1863    
1864     unsigned char r=rand() % 255;
1865     unsigned char g=rand() % 255;
1866     unsigned char b=rand() % 255;
1867     val=0.;
1868     unsigned char* p =(unsigned char*)&val;
1869    
1870     *p=r;
1871     p++;
1872     *p=g;
1873     p++;
1874     *p=b;
1875    
1876     }
1877    
1878    
1879     void VCT_COMPARAISON::trouve_face_de_reference(int &face_ref1,int &face_ref2)// ,TPL_LISTE_ENTITE<int>& list
1880     {
1881    
1882     /*
1883     int nb_simdble=sim_double.get_nb()/2 ;
1884    
1885     int num1,num2 ;
1886    
1887    
1888     OT_VECTEUR_4DD Dv,Dv1,Dv2,G1,G2,g1g2;
1889     OT_TENSEUR V(4),V1(4),V2(4);
1890    
1891    
1892     int nbsim=nb_sim.get_nb();
1893     int *t=new int [nbsim];
1894     int *tt=new int [nbsim];
1895     for(int i=0;i<nbsim;i++)
1896     {
1897     // t[i]= nb_sim.get(i);
1898     t[i]= i;
1899     int nbre_faces_simil=nb_sim.get(i);
1900     tt[i]=nbre_faces_simil;
1901    
1902     }
1903     int pos_min,pos_max;
1904     int min,max;
1905     int trouve=0;
1906    
1907     for (int i=0;i<nbsim;i++)
1908     {
1909    
1910     for(int j=0;j<nbsim;j++)
1911     {
1912     if(tt[j]<tt[i])
1913     {
1914     int tmp= tt[i];
1915    
1916     tt[i]= tt[j];
1917     tt[j]= tmp;
1918     t[i]=j;
1919     t[j]=i;
1920     }
1921     }
1922     }
1923    
1924    
1925     //pos_max=t[1];
1926    
1927     if(tt[0]==1)
1928     {
1929     pos_min=t[0];
1930     MG_FACE* fref=mggeo1->get_mg_face(pos_min);
1931     face_ref1= fref->get_id();
1932     for(int i=0;i<nb_simdble;i++){
1933     if (sim_double.get(2*i)==face_ref1)
1934     face_ref2=sim_double.get(2*i+1);
1935     }
1936     return;
1937     }
1938    
1939    
1940     int pos1=0;
1941     int pos2=0;
1942    
1943     int tr=0;
1944     trouve=0;
1945     while(trouve==0&&tr<nbsim-1)
1946     {
1947     pos_min=t[tr];
1948     pos_max=t[tr+1];
1949    
1950     OT_VECTEUR_4DD g1_ref,g2_ref,G1_ref,G2_ref;
1951     MG_FACE* face1_ref=mggeo1->get_mg_face(pos_min);
1952     MG_SURFACE* surf1_ref=face1_ref->get_surface();
1953     int id1=face1_ref->get_id();
1954     face1_ref->get_vectorisation().calcule_axes_dinertie(T1,Dv1,V1);
1955     G1_ref= face1_ref->get_vectorisation().calcule_barycentre(T1);
1956     /*
1957     for(int r=0;r<4;r++) {
1958     for(int s=0;s<4;s++) {
1959     g1_ref[r]= g1_ref[r]+V1(s,r)*G1_ref[s];
1960     }
1961     }
1962     /
1963     g1_ref=face1_ref->get_vectorisation().get_nouveau_pt(T1,G1_ref);
1964     /* OT_TENSEUR ttns1_face=face1_ref->get_vectorisation().calcule_tenseur_inertie_base_locale();
1965     vector<double2> ifac1;
1966     for(int r=0;r<4;r++)
1967     {
1968     ifac1.insert( ifac2.end(), ttns1_face(r,r));
1969     } /
1970    
1971     MG_FACE* face12_ref=mggeo1->get_mg_face(pos_max);
1972     face12_ref->get_vectorisation().calcule_axes_dinertie(T2,Dv2,V2);
1973     int id2=face12_ref->get_id();
1974     G2_ref= face12_ref->get_vectorisation().calcule_barycentre(T2);
1975     /*
1976     for(int r=0;r<4;r++) {
1977     for(int s=0;s<4;s++) {
1978     g2_ref[r]= g2_ref[r]+V1(s,r)*G2_ref[s];
1979     }
1980     }
1981     /
1982     g2_ref=face12_ref->get_vectorisation().get_nouveau_pt(T1,G2_ref);
1983    
1984     OT_VECTEUR_4DD g12_ref= g2_ref -g1_ref;
1985    
1986    
1987     OT_VECTEUR_4DD g1refg1,g2refg2;
1988     TPL_LISTE_ENTITE<int> lst1,lst2;
1989     for(int k=0;k<nb_simdble;k++)
1990     {
1991     if(sim_double.get(2*k)==id1)
1992     lst1.ajouter( sim_double.get(2*k+1));
1993     if(sim_double.get(2*k)==id2)
1994     lst2.ajouter(sim_double.get(2*k+1));
1995     }
1996    
1997    
1998    
1999    
2000     for(int i=0;i<lst1.get_nb();i++)
2001     {
2002    
2003     int num1=lst1.get(i);
2004     OT_VECTEUR_4DD g1,G1;
2005     MG_FACE* face1=mggeo2->get_mg_faceid(num1);
2006     face1->get_vectorisation().calcule_axes_dinertie(T2,Dv2,V2);
2007     G1= face1->get_vectorisation().calcule_barycentre(T2);
2008     /*
2009     for(int r=0;r<4;r++) {
2010     for(int s=0;s<4;s++) {
2011     g1[r]= g1[r]+V2(s,r)*G1[s];
2012     }
2013     }
2014     /
2015     // g1refg1=g1-g1_ref;
2016     // num2=list.get(2*i+1);
2017     for(int j=0;j<lst2.get_nb();j++)
2018     {
2019     int num2=lst2.get(j);
2020     OT_VECTEUR_4DD g2;
2021     MG_FACE* face2=mggeo2->get_mg_faceid(num2);
2022     G2= face2->get_vectorisation().calcule_barycentre(T2);
2023     /*
2024     for(int r=0;r<4;r++) {
2025     for(int s=0;s<4;s++) {
2026     g2[r]= g2[r]+V2(s,r)*G2[s];
2027     }
2028     }
2029     /
2030     //OT_VECTEUR_4DD g2g1=g2-g1;
2031     OT_VECTEUR_4DD g2g1=G2-G1;
2032     if(g2g1==g12_ref)
2033     {
2034     // lst_fin.ajouter(num1);
2035     // lst_fin.ajouter(num2);
2036     face_ref1=id1;
2037     face_ref2=num1;
2038     trouve=1;
2039     break;
2040     }
2041     }
2042     if(trouve) break;
2043     }
2044     tr++;
2045     }
2046     delete [] t;
2047     delete [] tt;
2048     */
2049    
2050     int p=0;
2051     int h=0;
2052     int not_trouve=0;
2053     while (!not_trouve)
2054     {
2055     MG_FACE* face1Ref=mggeo1->get_mg_faceid(sim_double.get(p));
2056     MG_SURFACE* surf1Ref=face1Ref->get_surface();
2057     OT_VECTEUR_4DD G1=surf1Ref->get_vectorisation().calcule_barycentre(T1);
2058     G1= surf1Ref->get_vectorisation().get_nouveau_pt(T1,G1);
2059    
2060     int idRef1=face1Ref->get_id();
2061    
2062     int k=0;
2063     while (idRef1==sim_double.get(2*k+h))
2064     {
2065     MG_FACE* face2Ref=mggeo2->get_mg_faceid(sim_double.get(2*k+1));
2066     int idRef2=face2Ref->get_id();
2067     MG_SURFACE* surf2Ref=face2Ref->get_surface();
2068     OT_VECTEUR_4DD G2=surf2Ref->get_vectorisation().calcule_barycentre(T2);
2069     // if (G1==G2)
2070     if (surfaces_sont_elles_identiques(face1Ref,face2Ref))
2071     {
2072     face_ref1=idRef1;
2073     face_ref2=idRef2;
2074     not_trouve=1;
2075     break;
2076     }
2077     k++;
2078     p=p+2;
2079     }
2080     h=p;
2081     }
2082     }
2083    
2084    
2085     void VCT_COMPARAISON::verifier_le_repere(OT_TENSEUR& rep1,OT_TENSEUR& rep2,vector<double2>& inert1,vector<double2>& inert2)
2086     {
2087     TPL_LISTE_ENTITE<int> lst;
2088     for (int i=0;i<4;i++)
2089     {
2090     double2 val1=inert1[i];
2091     for (int j=0;j<4;j++)
2092     {
2093     if (!lst.est_dans_la_liste(j+4))
2094     {
2095     double2 val2=inert2[j];
2096     if (val1==val2)
2097     {
2098     lst.ajouter(i);
2099     lst.ajouter(j+4);
2100     break;
2101     }
2102     }
2103     }
2104     }
2105    
2106    
2107     }
2108    
2109    
2110     int VCT_COMPARAISON::comparer_aretes_faces(MG_FACE* f_ref1,MG_FACE* f_ref2,MG_FACE* face1,MG_FACE* face2,TPL_LISTE_ENTITE<int>& aretes_ident,TPL_LISTE_ENTITE<int>& aretes_sim)
2111     {
2112    
2113    
2114     int nb_boucle1=face1->get_nb_mg_boucle();
2115     int nb_boucle2=face2->get_nb_mg_boucle();
2116     TPL_LISTE_ENTITE<int> lst1_artes_delamemecourbe;
2117     TPL_LISTE_ENTITE<int> lst2_artes_delamemecourbe;
2118     TPL_LISTE_ENTITE<int> arte1_trouvee;
2119     TPL_LISTE_ENTITE<int> arte2_trouvee;
2120     OT_VECTEUR_4DD VZER(0.,0.,0.,0.);
2121     //-----------------------------------------------------------------------------
2122     OT_VECTEUR_4DD Dv1,Dv2,G1,gf1,gf2,G2;
2123     OT_TENSEUR V1(4),V2(4);
2124    
2125     //f_ref1->get_vectorisation().calcule_axes_dinertie(T1,Dv1,V1);
2126     //G1=f_ref1->get_vectorisation().calcule_barycentre(T1);
2127    
2128     MG_SURFACE* surf1_ref=f_ref1->get_surface();
2129     G1=surf1_ref->get_vectorisation().calcule_barycentre(T1);
2130     G1=surf1_ref->get_vectorisation().get_nouveau_pt(T1,G1);
2131     // for(int r=0;r<4;r++) {
2132     // for(int s=0;s<4;s++) {
2133     // gf1[r]= gf1[r]+V1(s,r)*G1[s];
2134     // }
2135     // }
2136    
2137     //f_ref2->get_vectorisation().calcule_axes_dinertie(T2,Dv2,V2);
2138     //G2=f_ref2->get_vectorisation().calcule_barycentre(T2);
2139     MG_SURFACE* surf2_ref= f_ref2->get_surface();
2140     G2=surf1_ref->get_vectorisation().calcule_barycentre(T2);
2141    
2142     // for(int r=0;r<4;r++) {
2143     // for(int s=0;s<4;s++) {
2144     // gf2[r]= gf2[r]+V2(s,r)*G2[s];
2145     // }
2146     // }
2147    
2148     //---------------------------------------------------------------------------
2149     /* for(int j1=0;j1<nb_boucle1;j1++)
2150     {
2151     MG_BOUCLE* Boucle1 = face1->get_mg_boucle(j1);
2152     int nbarete1 = Boucle1->get_nb_mg_coarete();
2153     for (int w1 =0; w1<nbarete1;w1++)
2154     {
2155     double xyz1[3];
2156     double xyz2[3];
2157     vector<double2> viarte1,vicrbe1;
2158     OT_TENSEUR tns_arete1(4),tns_courbe1(4);
2159     OT_TENSEUR tm1_art(4),tm1_crb(4);
2160     MG_COARETE* coArete1 = Boucle1->get_mg_coarete(w1);
2161     MG_ARETE* arete1 = coArete1->get_arete();
2162     int id_art1=arete1->get_id();
2163     MG_COURBE* courbe1=arete1->get_courbe();
2164     int nb_top1_pts= arete1->get_vectorisation().get_nb_points();
2165     int nb_geo1_pts= courbe1->get_vectorisation().get_nb_points();
2166     tm1_art=arete1->get_vectorisation().calcule_tenseur_metrique();
2167     tm1_crb=courbe1->get_vectorisation().calcule_tenseur_metrique();
2168     tns_arete1=arete1->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
2169     tns_courbe1=courbe1->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
2170    
2171     for(int r=0;r<4;r++)
2172     {
2173     viarte1.insert( viarte1.end(), tns_arete1(r,r));
2174     vicrbe1.insert( vicrbe1.end(), tns_courbe1(r,r));
2175     }
2176     for(int j2=0;j2<nb_boucle2;j2++)
2177     {
2178     MG_BOUCLE* Boucle2 = face2->get_mg_boucle(j2);
2179     int nbarete2 = Boucle2->get_nb_mg_coarete();
2180     for (int w2 =0; w2<nbarete2;w2++)
2181     {
2182     double xyz1[3];
2183     double xyz2[3];
2184     vector<double2> viarte2,vicrbe2;
2185     OT_TENSEUR tns_arete2(4),tns_courbe2(4);
2186     OT_TENSEUR tm2_art(4),tm2_crb(4);
2187     MG_COARETE* coArete2 = Boucle2->get_mg_coarete(w2);
2188     MG_ARETE* arete2 = coArete2->get_arete();
2189     int id_art2=arete2->get_id();
2190     MG_COURBE* courbe2=arete2->get_courbe();
2191     int nb_top2_pts= arete2->get_vectorisation().get_nb_points();
2192     int nb_geo2_pts= courbe2->get_vectorisation().get_nb_points();
2193     tm2_art=arete2->get_vectorisation().calcule_tenseur_metrique();
2194     tm2_crb=courbe2->get_vectorisation().calcule_tenseur_metrique();
2195     tns_arete2=arete2->get_vectorisation().calcule_tenseur_inertie_base_locale(T2);
2196     tns_courbe2=courbe2->get_vectorisation().calcule_tenseur_inertie_base_locale(T2);
2197    
2198     for(int r=0;r<4;r++)
2199     {
2200     viarte2.insert( viarte2.end(), tns_arete1(r,r));
2201     vicrbe2.insert( vicrbe2.end(), tns_courbe1(r,r));
2202     }
2203     if((nb_geo1_pts==nb_geo2_pts)&&(nb_top1_pts==nb_top2_pts))
2204     {
2205     if(tm1_art.est_til_equivalent(tm2_art))
2206     {
2207     if(tm1_crb.est_til_equivalent(tm2_crb))
2208     {
2209     if(tns_courbe1==tns_courbe2)
2210     {
2211     lst1_artes_delamemecourbe.ajouter(id_art1);
2212     lst2_artes_delamemecourbe.ajouter(id_art2);
2213     }
2214     }
2215     }
2216    
2217    
2218     }
2219    
2220    
2221     }
2222     }
2223     }
2224     }
2225    
2226     vector<OT_VECTEUR_4DD> lst1_barycentre;
2227     vector<OT_VECTEUR_4DD> lst2_barycentre;
2228     TPL_LISTE_ENTITE<int> lst1,lst2;
2229     for(int i1=0;i1<lst2_artes_delamemecourbe.get_nb();i1++)
2230     {
2231     int id21=lst2_artes_delamemecourbe.get(i1);
2232     MG_ARETE* art2=mggeo2->get_mg_areteid(id21);
2233     OT_VECTEUR_4DD G2=art2->get_vectorisation().calcule_barycentre(T2);
2234     if(!lst2.est_dans_la_liste(id21))
2235     {
2236     lst2_barycentre.insert(lst2_barycentre.end(),G2);
2237     for(int i2=0;i2<lst2_artes_delamemecourbe.get_nb();i2++)
2238     {
2239     int id22=lst2_artes_delamemecourbe.get(i2);
2240     int id1=lst1_artes_delamemecourbe.get(i2);REMAILLEUR
2241     if(!lst1.est_dans_la_liste(id1))
2242     {
2243     if(id21==id22)
2244     {
2245     MG_ARETE* art1=mggeo1->get_mg_areteid(id1);
2246     OT_VECTEUR_4DD G1=art1->get_vectorisation().calcule_barycentre(T1);
2247     G1=art1->get_vectorisation().get_nouveau_pt(T1,G1);
2248     lst1_barycentre.insert(lst1_barycentre.end(),G1);
2249     lst1.ajouter(id1);
2250     }
2251     }
2252     }
2253     lst2.ajouter(id21);
2254     }
2255     }
2256    
2257    
2258     vector<double2> NOR1,NOR2;
2259     vector<OT_VECTEUR_4DD> vi,vj;
2260     OT_VECTEUR_4DD g1=lst1_barycentre[0];
2261     for(int k=0;k<lst1_barycentre.size();k++)
2262     {
2263     OT_VECTEUR_4DD gigj_1=lst1_barycentre[k]-g1;
2264    
2265     double2 nor1=gigj_1.norme();
2266     OT_VECTEUR_4DD gigj_2=lst1_barycentre[k]-g1;
2267     double2 nor2=gigj_2.norme();
2268     }
2269     for(int k=0;k<lst1_barycentre.size();k++)
2270     {
2271     OT_VECTEUR_4DD gigj_1=lst1_barycentre[k]-g1;
2272     vi.insert(vi.end(),gigj_1);
2273     double2 nor1=gigj_1.norme();
2274     NOR1.insert(NOR1.end(),nor1);
2275     OT_VECTEUR_4DD gigj_2=lst1_barycentre[k]-g1;
2276     vj.insert(vj.end(),gigj_2);
2277     double2 nor2=gigj_2.norme();
2278     NOR2.insert(NOR2.end(),nor2);
2279     }
2280    
2281     double2 min1=NOR1[0];
2282     double2 min2=NOR2[0];
2283     int *t1=new int[lst1.get_nb()];
2284     int *t2=new int[lst2.get_nb()];
2285    
2286     for(int r=0;r<lst1.get_nb();r++)
2287     {
2288     t1[r]=lst1.get(r);
2289     t2[r]=lst2.get(r);
2290     for(int s=0;s<lst1.get_nb();s++)
2291     {
2292     if (NOR1[s]<NOR1[r])
2293     {
2294     double2 tmp1=NOR1[r];
2295     NOR1[r]=NOR1[s];
2296     NOR1[s]=tmp1;
2297     t1[r]=t1[s];
2298     }
2299    
2300     if (NOR2[s]<NOR2[r])
2301     {
2302     double2 tmp2=NOR2[r];
2303     NOR2[r]=NOR2[s];
2304     NOR2[s]=tmp2;
2305     t2[r]=t2[s];
2306     }
2307     }
2308     } */
2309     //---------------------------------------------------------------------------
2310     int nb_aretes=0;
2311     for (int j1=0;j1<nb_boucle1;j1++)
2312     {
2313     MG_BOUCLE* Boucle1 = face1->get_mg_boucle(j1);
2314     int nbarete1 = Boucle1->get_nb_mg_coarete();
2315     nb_aretes+=nbarete1;
2316     for (int w1 =0; w1<nbarete1;w1++)
2317     {
2318     double xyz1[3];
2319     double xyz2[3];
2320     OT_TENSEUR tns_arete1(4),tns_courbe1(4);
2321     OT_TENSEUR tm1_art(4),tm1_crb(4);
2322     MG_COARETE* coArete1 = Boucle1->get_mg_coarete(w1);
2323     MG_ARETE* arete1 = coArete1->get_arete();
2324     int id_art1=arete1->get_id();
2325    
2326     MG_COURBE* courbe1=arete1->get_courbe();
2327    
2328     int nb_top1_pts= arete1->get_vectorisation().get_nb_points();
2329     int nb_geo1_pts= courbe1->get_vectorisation().get_nb_points();
2330    
2331     tm1_art=arete1->get_vectorisation().calcule_tenseur_metrique();
2332     tm1_crb=courbe1->get_vectorisation().calcule_tenseur_metrique();
2333    
2334     MG_COSOMMET* csomt1_art1= arete1->get_cosommet1();
2335     MG_COSOMMET* csomt2_art1= arete1->get_cosommet2();
2336     MG_SOMMET* som1_art1= csomt1_art1->get_sommet();
2337     MG_SOMMET* som2_art1= csomt2_art1->get_sommet();
2338     MG_POINT* pt1=som1_art1->get_point();
2339     MG_POINT* pt2=som2_art1->get_point();
2340     pt1->evaluer(xyz1);
2341     OT_VECTEUR_4DD PT11(xyz1[0],xyz1[1],xyz1[2],0);
2342     pt2->evaluer(xyz2);
2343     OT_VECTEUR_4DD PT12(xyz2[0],xyz2[1],xyz2[2],0);
2344     //----------------------------------------------------------------------
2345     OT_VECTEUR_4DD B1,g1;
2346     B1=courbe1->get_vectorisation().calcule_barycentre(T1);
2347     OT_VECTEUR_4DD G1S1=B1-PT11;
2348    
2349     B1=courbe1->get_vectorisation().get_nouveau_pt(T1,B1);
2350     G1S1=courbe1->get_vectorisation().get_nouveau_pt(T1,G1S1);
2351     // for(int r=0;r<4;r++) {
2352     // for(int s=0;s<4;s++)
2353     // g1[r]= g1[r]+V1(s,r)*B1[s];
2354     // }
2355     //----------------------------------------------------------------------
2356    
2357     tns_arete1=arete1->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
2358     tns_courbe1=courbe1->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
2359     vector<double2> viarte1,vicrbe1;
2360     for (int r=0;r<4;r++)
2361     {
2362     viarte1.insert( viarte1.end(), tns_arete1(r,r));
2363     vicrbe1.insert( vicrbe1.end(), tns_courbe1(r,r));
2364     }
2365     int compt_aretes_modif=0;
2366     for (int j2=0;j2<nb_boucle2;j2++)
2367     {
2368     if (arte1_trouvee.est_dans_la_liste(id_art1)) break;
2369     MG_BOUCLE* Boucle2 = face2->get_mg_boucle(j2);
2370     int nbarete2 = Boucle2->get_nb_mg_coarete();
2371     for (int w2 =0; w2<nbarete2;w2++)
2372     {
2373     if (arte1_trouvee.est_dans_la_liste(id_art1)) break;
2374     OT_TENSEUR tns_arete2(4),tns_courbe2(4);
2375     OT_TENSEUR tm2_art(4),tm2_crb(4);
2376     MG_COARETE* coArete2 = Boucle2->get_mg_coarete(w2);
2377     MG_ARETE* arete2 = coArete2->get_arete();
2378     MG_COURBE* courbe2=arete2->get_courbe();
2379     int id_art2=arete2->get_id();
2380     MG_COSOMMET* csomt1_art2= arete2->get_cosommet1();
2381     MG_COSOMMET* csomt2_art2= arete2->get_cosommet2();
2382     MG_SOMMET* som1_art2= csomt1_art2->get_sommet();
2383     MG_SOMMET* som2_art2= csomt2_art2->get_sommet();
2384     MG_POINT* pt2=som1_art2->get_point();
2385     pt2->evaluer(xyz1);
2386     OT_VECTEUR_4DD PT21(xyz1[0],xyz1[1],xyz1[2],0);
2387     MG_POINT* pt3=som2_art2->get_point();
2388     pt3->evaluer(xyz2);
2389     OT_VECTEUR_4DD PT22(xyz2[0],xyz2[1],xyz2[2],0);
2390     //----------------------------------------------------------------------
2391     OT_VECTEUR_4DD B2,g2;
2392     B2=courbe2->get_vectorisation().calcule_barycentre(T2);
2393     OT_VECTEUR_4DD G2S2=B2-PT21;
2394     OT_VECTEUR_4DD G2S3=B2-PT22;
2395     OT_VECTEUR_4DD B1B2=B2-B1;
2396     OT_VECTEUR_4DD D1= G1S1^G2S2;
2397     OT_VECTEUR_4DD D2= G1S1^G2S3;
2398     // OT_VECTEUR_4DD D3= B1B2^G2S3;
2399     // for(int r=0;r<4;r++) {
2400     // for(int s=0;s<4;s++)
2401     // g2[r]= g2[r]+V2(s,r)*B2[s];
2402     // }
2403     //---------------------------------------------------------------------- MG_COURBE* courbe2=arete2->get_courbe();
2404    
2405     int nb_top2_pts= arete2->get_vectorisation().get_nb_points();
2406     int nb_geo2_pts= courbe2->get_vectorisation().get_nb_points();
2407    
2408     tm2_art=arete2->get_vectorisation().calcule_tenseur_metrique();
2409     tm2_crb=courbe2->get_vectorisation().calcule_tenseur_metrique();
2410    
2411     tns_arete2=arete2->get_vectorisation().calcule_tenseur_inertie_base_locale(T2);
2412     tns_courbe2=courbe2->get_vectorisation().calcule_tenseur_inertie_base_locale(T2);
2413    
2414     vector<double2> viarte2,vicrbe2;
2415     for (int r=0;r<4;r++)
2416     {
2417     viarte2.insert( viarte2.end(), tns_arete2(r,r));
2418     vicrbe2.insert( vicrbe2.end(), tns_courbe2(r,r));
2419     }
2420    
2421     if (nb_geo1_pts==nb_geo2_pts&&nb_top1_pts==nb_top2_pts)
2422     {
2423     if (tm1_art.est_til_equivalent(tm2_art))
2424     {
2425     if (tm1_crb.est_til_equivalent(tm2_crb))
2426     {
2427     vector<unsigned int> indx1,indx2;
2428     int identique=-1;
2429     //if(tns_arete1==tns_arete2)//.listes_equivalentes(viarte1,viarte2,indx1))
2430     //{
2431     if (tns_courbe1==tns_courbe2)//tns_arete1.listes_equivalentes(vicrbe1,vicrbe2,indx2))
2432     {
2433     OT_VECTEUR_4DD v1=B1-G1;
2434     OT_VECTEUR_4DD v2=B2-G2;
2435     //OT_VECTEUR_4DD v1=gf1-g1;
2436     //OT_VECTEUR_4DD v2=gf2-g2;
2437     //if(v1==v2||((D1==VZER||D2==VZER)))
2438     if (courbes_sont_elles_identiques(arete1,arete2))
2439     {
2440     if (!arte2_trouvee.est_dans_la_liste(id_art2))
2441     {
2442     aretes_ident.ajouter(j1) ;
2443     aretes_ident.ajouter(id_art1) ;
2444     aretes_ident.ajouter(j2) ;
2445     aretes_ident.ajouter(id_art2) ;
2446     arte1_trouvee.ajouter(id_art1);
2447     arte2_trouvee.ajouter(id_art2);
2448     identique=1;
2449     }
2450    
2451    
2452     }
2453    
2454     }
2455     // }
2456     if (identique>0) break;
2457     if (identique<0)
2458     {
2459     aretes_sim.ajouter(j1) ;
2460     aretes_sim.ajouter(id_art1) ;
2461     aretes_sim.ajouter(j2) ;
2462     aretes_sim.ajouter(id_art2) ;
2463     identique=-1;
2464     }
2465     }
2466     }
2467     } // aretes2
2468    
2469     } //boucle2
2470    
2471     // }//condition 1 //aretes_identiques
2472     }
2473    
2474     }
2475     }
2476    
2477     if (nb_aretes==aretes_ident.get_nb()/2) return 1;
2478     else return 0;
2479    
2480     }
2481    
2482     void VCT_COMPARAISON::identifier_aretes_face_modifiee(MG_FACE* face1,MG_FACE* face2,TPL_LISTE_ENTITE<int>& aretes_identiques,
2483     TPL_LISTE_ENTITE<int>&aretes_simil,TPL_LISTE_ENTITE<int>&lst_corrsp_sommets,TPL_LISTE_ENTITE<int>& aret1_conservees,
2484     TPL_LISTE_ENTITE<int>& aret1_disparues,TPL_LISTE_ENTITE<int>& aret2_conservees ,TPL_LISTE_ENTITE<int>& aret2_nouvelles ,
2485     TPL_LISTE_ENTITE<int>& aret_partielles)
2486     {
2487    
2488     int nb_boucle1=face1->get_nb_mg_boucle();
2489     int nb_boucle2=face2->get_nb_mg_boucle();
2490    
2491    
2492     int cmpt_arete=0;
2493    
2494     TPL_LISTE_ENTITE<int> boucle_face1;
2495     TPL_LISTE_ENTITE<int> boucle_face2;
2496    
2497     TPL_LISTE_ENTITE<int> aretes_ident_face1;
2498     TPL_LISTE_ENTITE<int> aretes_ident_face2;
2499     TPL_LISTE_ENTITE<int> aretes_face1;
2500     TPL_LISTE_ENTITE<int> aretes_face2;
2501     TPL_LISTE_ENTITE<int> aretes_dif_face2;
2502     TPL_LISTE_ENTITE<int> aretes_sim_face1;
2503     TPL_LISTE_ENTITE<int> aretes_sim_face2;
2504     TPL_LISTE_ENTITE<int> lst_sommet1;
2505     TPL_LISTE_ENTITE<int> lst_sommet2;
2506    
2507     for (int b=0;b<lst_corrsp_sommets.get_nb()/2;b++)
2508     {
2509     lst_sommet1.ajouter( lst_corrsp_sommets.get(2*b));
2510     lst_sommet2.ajouter( lst_corrsp_sommets.get(2*b+1));
2511     }
2512    
2513     for (int b=0;b<aretes_identiques.get_nb()/4;b++)
2514     {
2515     int b1= aretes_identiques.get(4*b) ;
2516     int b2= aretes_identiques.get(4*b+2) ;
2517     int art1= aretes_identiques.get(4*b+1);
2518     int art2= aretes_identiques.get(4*b+3);
2519     boucle_face1.ajouter( aretes_identiques.get(4*b));
2520     boucle_face2.ajouter( aretes_identiques.get(4*b+2));
2521     aretes_ident_face1.ajouter(aretes_identiques.get(4*b+1));
2522     aretes_ident_face2.ajouter(aretes_identiques.get(4*b+3));
2523     aret1_conservees.ajouter(art1);
2524     aret2_conservees.ajouter(art2);
2525    
2526     }
2527    
2528    
2529     for (int j1=0;j1<nb_boucle1;j1++)
2530     {
2531     MG_BOUCLE* Boucle1 = face1->get_mg_boucle(j1);
2532     int nbarete1 = Boucle1->get_nb_mg_coarete();
2533    
2534     for (int w1=0; w1<nbarete1;w1++)
2535     {
2536     MG_COARETE* coArete1 = Boucle1->get_mg_coarete(w1);
2537     MG_ARETE* arete1 = coArete1->get_arete();
2538     int id_art1=arete1->get_id();
2539     if (!aretes_ident_face1.est_dans_la_liste(id_art1))
2540     {
2541     aret1_disparues.ajouter(id_art1);
2542     }
2543     }
2544     }
2545    
2546     for (int j2=0;j2<nb_boucle2;j2++)
2547     {
2548     MG_BOUCLE* Boucle2 = face2->get_mg_boucle(j2);
2549     int nbarete2 = Boucle2->get_nb_mg_coarete();
2550     for (int w2=0; w2<nbarete2;w2++)
2551     {
2552     MG_COARETE* coArete2 = Boucle2->get_mg_coarete(w2);
2553     MG_ARETE* arete2 = coArete2->get_arete();
2554     int id_art2=arete2->get_id();
2555     if (!aretes_ident_face2.est_dans_la_liste(id_art2))
2556     {
2557     aret2_nouvelles.ajouter(id_art2);
2558     }
2559    
2560     }
2561     }
2562     /*
2563     for(int b=0;b<aretes_simil.get_nb()/4;b++)
2564     {
2565     aretes_sim_face1.ajouter(aretes_simil.get(4*b+1));
2566     aretes_sim_face2.ajouter(aretes_simil.get(4*b+3));
2567     }
2568    
2569     MG_FACE* Face_ref1=mggeo1->get_mg_faceid(face_ref1) ;
2570     MG_FACE* Face_ref2=mggeo2->get_mg_faceid(face_ref2) ;
2571    
2572     for(int j1=0;j1<nb_boucle1;j1++)
2573     {
2574     MG_BOUCLE* Boucle1 = face1->get_mg_boucle(j1);
2575     int nbarete1 = Boucle1->get_nb_mg_coarete();
2576     TPL_LISTE_ENTITE<int> lst_aret1_modif;
2577     TPL_LISTE_ENTITE<int> lst_aret2_modif;
2578     TPL_LISTE_ENTITE<int> lst_art1_partiel;
2579     TPL_LISTE_ENTITE<int> lst_art2_partiel;
2580     int compt1=0;
2581     int boucle;
2582     int start_boucle,end_boucle;
2583     int cmpt=0;
2584     TPL_LISTE_ENTITE<int> arete_boucle1;
2585     TPL_LISTE_ENTITE<int> arete_boucle2;
2586    
2587     if(boucle_face1.est_dans_la_liste(j1))
2588     {
2589     for(int k=0;k<boucle_face1.get_nb();k++)
2590     {
2591     if (j1==boucle_face1.get(k))
2592     {
2593     int art1=aretes_ident_face1.get(k);
2594     int art2= aretes_ident_face2.get(k);
2595     arete_boucle1.ajouter(aretes_ident_face1.get(k));
2596     arete_boucle2.ajouter(aretes_ident_face2.get(k));
2597     boucle=boucle_face2.get(k);
2598     }
2599     }
2600     }
2601    
2602     for (int w1=0; w1<nbarete1;w1++)
2603     {
2604    
2605     MG_COARETE* coArete1 = Boucle1->get_mg_coarete(w1);
2606     MG_ARETE* arete1 = coArete1->get_arete();
2607     int id_art=arete1->get_id();
2608     int trouv=-1;
2609     for (int w1=0; w1<arete_boucle1.get_nb();w1++)
2610     {
2611     int id_art1=arete_boucle1.get(w1);
2612     int id_art2=arete_boucle2.get(w1);
2613    
2614     if(id_art1==id_art)
2615     {
2616     aret1_conservees.ajouter(id_art1);
2617     aret2_conservees.ajouter(id_art2);
2618     trouv=1;
2619     break;
2620     }
2621     }
2622     if(trouv<0)
2623     {
2624     //if(!aretes_sim_face1.est_dans_la_liste(id_art1))
2625     aret1_disparues.ajouter(id_art);
2626     //lst_aret1_modif.ajouter(id_art1);
2627     }
2628    
2629     }
2630    
2631     // for(int j2=0;j2<nb_boucle2;j2++)
2632     // {
2633     // MG_BOUCLE* Boucle2 = face2->get_mg_boucle(j2);
2634     MG_BOUCLE* Boucle2 = face2->get_mg_boucle(boucle);
2635     int nbarete2 = Boucle2->get_nb_mg_coarete();
2636    
2637     for (int w2=0; w2<nbarete2;w2++)
2638     {
2639     MG_COARETE* coArete2 = Boucle2->get_mg_coarete(w2);
2640     MG_ARETE* arete2 = coArete2->get_arete();
2641     int id_art2=arete2->get_id();
2642     if(!arete_boucle2.est_dans_la_liste(id_art2))
2643     {
2644     aret2_nouvelles.ajouter(id_art2);
2645     //lst_aret2_modif.ajouter(id_art2);
2646     //for(int is=0;is<aretes_sim_face2.get_nb();is++)
2647     //{
2648     //if(aretes_sim_face2.get(is)==id_art2)
2649     // {
2650     // aret2_partielles.ajouter(id_art2);
2651     // }
2652     // }
2653    
2654     }
2655     // else
2656    
2657     // aret2_conservees.ajouter(id_art2);
2658     }
2659    
2660     //verifier parmi les deux listes des aretes modifiees
2661     //celles qui sont nouvelles ou partiellements modifees
2662     /*
2663     for(int m1=0;m1<lst_aret1_modif.get_nb();m1++)
2664     {
2665     int id_art1=lst_aret1_modif.get(m1);
2666     MG_ARETE* art1=mggeo1->get_mg_areteid(id_art1);
2667    
2668     OT_TENSEUR tm1_art(4),tm1_crb(4);
2669     MG_COURBE* courbe1=art1->get_courbe();
2670     tm1_art=art1->get_vectorisation().calcule_tenseur_metrique();
2671     tm1_crb=courbe1->get_vectorisation().calcule_tenseur_metrique();
2672    
2673    
2674     MG_COSOMMET* csomt1_art1= art1->get_cosommet1();
2675     MG_COSOMMET* csomt2_art1= art1->get_cosommet2();
2676     MG_SOMMET* som1_art1= csomt1_art1->get_sommet();
2677     MG_SOMMET* som2_art1= csomt2_art1->get_sommet();
2678     int id_som11= som1_art1->get_id();
2679     int id_som21= som2_art1->get_id();
2680     int s11_ou_s21;
2681     if(lst_sommet1.est_dans_la_liste(id_som11)) s11_ou_s21=1;
2682     if(lst_sommet1.est_dans_la_liste(id_som21)) s11_ou_s21=2;
2683    
2684     if(lst_sommet1.est_dans_la_liste(id_som11)||lst_sommet1.est_dans_la_liste(id_som21))
2685     {
2686     for(int m2=0;m2<lst_aret2_modif.get_nb();m2++)
2687     {
2688     int id_art2=lst_aret2_modif.get(m2);
2689     MG_ARETE* art2=mggeo2->get_mg_areteid(id_art2);
2690     OT_TENSEUR tm2_art(4),tm2_crb(4);
2691     MG_COURBE* courbe2=art2->get_courbe();
2692     tm2_art=art1->get_vectorisation().calcule_tenseur_metrique();
2693     tm2_crb=courbe2->get_vectorisation().calcule_tenseur_metrique();
2694    
2695     MG_COSOMMET* csomt1_art2= art2->get_cosommet1();
2696     MG_COSOMMET* csomt2_art2= art2->get_cosommet2();
2697     MG_SOMMET* som1_art2= csomt1_art2->get_sommet();
2698     MG_SOMMET* som2_art2= csomt2_art2->get_sommet();
2699     int id_som12= som1_art2->get_id();
2700     int id_som22= som2_art2->get_id();
2701     int s12_ou_s22;
2702     if(lst_sommet2.est_dans_la_liste(id_som12)) s12_ou_s22=1;
2703     if(lst_sommet2.est_dans_la_liste(id_som22)) s12_ou_s22=2;
2704    
2705     //if(lst_sommet2.est_dans_la_liste(id_som12)||lst_sommet2.est_dans_la_liste(id_som22))
2706     // {
2707     if(tm1_art.est_til_equivalent(tm2_art)&&tm1_crb.est_til_equivalent(tm2_crb))
2708     {
2709     aret_partielles.ajouter(id_art1);
2710     aret_partielles.ajouter(id_art2);
2711     lst_art1_partiel.ajouter(id_art1);
2712     lst_art2_partiel.ajouter(id_art2);
2713     if (s11_ou_s21==1&&s12_ou_s22==1)
2714     {
2715     aret_partielles.ajouter(id_som11);
2716     }
2717     if (s11_ou_s21==2&&s12_ou_s22==1)
2718     {
2719     aret_partielles.ajouter(id_som21);
2720     }
2721     if (s12_ou_s22==1&&s12_ou_s22==2)
2722     {
2723     aret_partielles.ajouter(id_som12);
2724     }
2725     if (s12_ou_s22==2&&s12_ou_s22==2)
2726     {
2727     aret_partielles.ajouter(id_som22);
2728     }
2729    
2730     }
2731     // }
2732    
2733     }
2734     }
2735     } // for m1=
2736    
2737    
2738    
2739     for(int m1=0;m1<lst_aret1_modif.get_nb();m1++)
2740     {
2741     int id_art1=lst_aret1_modif.get(m1);
2742     if( !lst_art1_partiel.est_dans_la_liste(id_art1))
2743     aret1_disparues.ajouter(id_art1);
2744     }
2745     for(int m2=0;m2<lst_aret1_modif.get_nb();m2++)
2746     {
2747     int id_art2=lst_aret2_modif.get(m2);
2748     if( !lst_art2_partiel.est_dans_la_liste(id_art2))
2749     aret2_nouvelles.ajouter(id_art2);
2750     } /
2751    
2752     } //boucle_face1
2753    
2754    
2755     for(int j2=0;j2<nb_boucle2;j2++)
2756     {
2757     MG_BOUCLE* Boucle2 = face2->get_mg_boucle(j2);
2758    
2759     if (!boucle_face2.est_dans_la_liste(j2))
2760     {
2761     int nbarete2 = Boucle2->get_nb_mg_coarete();
2762     for (int w2=0; w2<nbarete2;w2++)
2763     {
2764     MG_COARETE* coArete2 = Boucle2->get_mg_coarete(w2);
2765     MG_ARETE* arete2 = coArete2->get_arete();
2766     int id_art2=arete2->get_id();
2767     aret2_nouvelles.ajouter(id_art2);
2768    
2769     }
2770     }
2771     }//boucle j2
2772     */
2773    
2774    
2775     }
2776    
2777    
2778    
2779     void VCT_COMPARAISON::identifier_les_modifications_appliquees(VCT_COMPARAISON_RESULTAT& Results)
2780     {
2781    
2782     TPL_LISTE_ENTITE<int> face1_conservees;
2783     TPL_LISTE_ENTITE<int> face2_conservees;
2784     TPL_LISTE_ENTITE<int> faces_nouvelles;
2785    
2786     TPL_LISTE_ENTITE<int> aret_ident;
2787     TPL_LISTE_ENTITE<int> aret_modif;
2788     int nb_face1=mggeo1->get_nb_mg_face();
2789     int nb_face2=mggeo2->get_nb_mg_face();
2790     TPL_LISTE_ENTITE<int> lst_face1,lst_face2,lst_facloc1,lst_facloc2,dif1,dif2;
2791    
2792    
2793     TPL_LISTE_ENTITE<int> faces1_partiellement_modf;
2794     TPL_LISTE_ENTITE<int> faces2_partiellement_modf;
2795     TPL_LISTE_ENTITE<int> Aret1_conservees;
2796     TPL_LISTE_ENTITE<int> Aret1_disparues;
2797     TPL_LISTE_ENTITE<int> Aret2_conservees ;
2798     TPL_LISTE_ENTITE<int> Aret2_nouvelles ;
2799     TPL_LISTE_ENTITE<int> Aret2_partielles ;
2800     TPL_LISTE_ENTITE<int> face1_disparues;
2801     for (int i=0;i<nb_face1;i++)
2802     {
2803     OT_VECTEUR_4DD g1,G1;
2804     MG_FACE* face1=mggeo1->get_mg_face(i);
2805     int id1=face1->get_id();
2806     lst_face1.ajouter(id1);
2807     }
2808    
2809     for (int i=0;i<nb_face2;i++)
2810     {
2811     OT_VECTEUR_4DD g1,G1;
2812     MG_FACE* face2=mggeo2->get_mg_face(i);
2813     int id2=face2->get_id();
2814     lst_face2.ajouter(id2);
2815     }
2816    
2817    
2818    
2819     MG_FACE* Face_ref1=mggeo1->get_mg_faceid(face_ref1) ;
2820     MG_FACE* Face_ref2=mggeo2->get_mg_faceid(face_ref2) ;
2821     int nb_faces_identique=identite.get_nb()/2;
2822     for (int i=0;i<nb_faces_identique;i++)
2823     {
2824     CORRESPONDANCE CORRESP;
2825     int face1_id=identite.get(2*i);
2826     int face2_id=identite.get(2*i+1);
2827     MG_FACE* Face1=mggeo1->get_mg_faceid(face1_id);
2828     MG_FACE* Face2=mggeo2->get_mg_faceid(face2_id);
2829     face1_conservees.ajouter(face1_id);
2830     face2_conservees.ajouter(face2_id);
2831     Results.ajouter_liste_topologie(ORIGINE_CONSERVEE,Face1);
2832     Results.ajouter_liste_topologie(MODIFIE_CONSERVEE,Face2);
2833     CORRESP.eleorigine=Face1;
2834     CORRESP.elemodifie=Face2;
2835     Results.ajouter_liste_topologie(CORRESP);
2836    
2837     //----------------------------------------
2838     TPL_LISTE_ENTITE<int> aretes_identiques;
2839     TPL_LISTE_ENTITE<int> aretes_similaires;
2840    
2841     //------------------------------------------
2842     this->comparer_aretes_faces(Face_ref1,Face_ref2,Face1,Face2,aretes_identiques,aretes_similaires);
2843    
2844     int nb_aretes_trouvees=aretes_identiques.get_nb()/4;
2845    
2846     if (nb_aretes_trouvees)
2847     {
2848     CORRESPONDANCE corsp;
2849     for (int i1=0;i1<nb_aretes_trouvees;i1++)
2850     {
2851     int art1_id=aretes_identiques.get(4*i1+1);
2852     MG_ARETE*art1_cons=mggeo1->get_mg_areteid(art1_id);
2853     Results.ajouter_liste_topologie(ORIGINE_CONSERVEE,art1_cons);
2854     int art2_id=aretes_identiques.get(4*i1+3);
2855     MG_ARETE*art2_cons=mggeo2->get_mg_areteid(art2_id);
2856     Results.ajouter_liste_topologie(MODIFIE_CONSERVEE,art2_cons);
2857    
2858     corsp.eleorigine=art1_cons;
2859     corsp.elemodifie=art2_cons;
2860     Results.ajouter_liste_topologie(corsp);
2861     }
2862     }
2863    
2864    
2865     }
2866    
2867     TPL_LISTE_ENTITE<int> lst_corrsp_sommets;
2868     this->identifier_les_sommets(Face_ref1,Face_ref2,lst_corrsp_sommets,Results);
2869    
2870    
2871     for (int t=0;t<lst_face1.get_nb();t++)
2872     {
2873     if (!face1_conservees.est_dans_la_liste(lst_face1.get(t)) )
2874     dif1.ajouter(lst_face1.get(t));
2875     }
2876     for (int it=0;it<lst_face2.get_nb();it++)
2877     {
2878     if (!face2_conservees.est_dans_la_liste(lst_face2.get(it)))
2879     dif2.ajouter(lst_face2.get(it));
2880     }
2881    
2882    
2883     for (int i=0;i<dif1.get_nb();i++)
2884     {
2885     int Num1=dif1.get(i);
2886     MG_FACE* face1=mggeo1->get_mg_faceid(Num1);
2887     MG_SURFACE* surf1=face1->get_surface();
2888     OT_VECTEUR_4DD G1=face1->get_vectorisation().calcule_barycentre(T1);
2889     G1=surf1->get_vectorisation().get_nouveau_pt(T1,G1);
2890     for (int j=0;j<dif2.get_nb();j++)
2891     {
2892     int Num2=dif2.get(j);
2893     TPL_LISTE_ENTITE<int> aretes_identiques;
2894     TPL_LISTE_ENTITE<int> aretes_similaires;
2895     TPL_LISTE_ENTITE<int> aretes_conservees;
2896     TPL_LISTE_ENTITE<int> nouvelles_aretes ;
2897     TPL_LISTE_ENTITE<int> aret1_conservees;
2898     TPL_LISTE_ENTITE<int> aret1_disparues;
2899     TPL_LISTE_ENTITE<int> aret2_conservees ;
2900     TPL_LISTE_ENTITE<int> aret2_nouvelles ;
2901     TPL_LISTE_ENTITE<int> aret2_partielles ;
2902    
2903     MG_FACE* face2=mggeo2->get_mg_faceid(Num2);
2904     MG_SURFACE* surf2=face2->get_surface();
2905     OT_VECTEUR_4DD G2=face2->get_vectorisation().calcule_barycentre(T2);
2906     // if(!faces1_partiellement_modf.est_dans_la_liste(Num1))
2907     // {
2908    
2909     if (surfaces_sont_elles_identiques(face1,face2)) //G1==G2
2910     {
2911     comparer_aretes_faces(Face_ref1,Face_ref2,face1,face2,aretes_identiques,aretes_similaires);
2912     int nb_aretes_trouvees=aretes_identiques.get_nb()/2;
2913     if (nb_aretes_trouvees)
2914     identifier_aretes_face_modifiee(face1,face2,aretes_identiques,aretes_similaires,lst_corrsp_sommets,aret1_conservees,aret1_disparues,aret2_conservees ,aret2_nouvelles ,aret2_partielles);
2915     int id_face2=face2->get_id();
2916    
2917     if (nb_aretes_trouvees)
2918     {
2919     // if (!face2_conservees.est_dans_la_liste(Num2))
2920     // {
2921     CORRESPONDANCE CORRESP_FACE;
2922     Results.ajouter_liste_topologie(ORIGINE_CONSERVEE,face1);
2923     Results.ajouter_liste_topologie(MODIFIE_CONSERVEE,face2);
2924     CORRESP_FACE.eleorigine=face1;
2925     CORRESP_FACE.elemodifie=face2;
2926     Results.ajouter_liste_topologie(CORRESP_FACE);
2927     face1_conservees.ajouter(Num1);
2928     face2_conservees.ajouter(Num2);
2929    
2930     for (int i1=0;i1<aret1_conservees.get_nb();i1++)
2931     {
2932     int art1_id=aret1_conservees.get(i1);
2933     Aret1_conservees.ajouter(art1_id);
2934     MG_ARETE*art1_cons=mggeo1->get_mg_areteid(art1_id);
2935     Results.ajouter_liste_topologie(ORIGINE_CONSERVEE,art1_cons);
2936     int art2_id= aret2_conservees.get(i1) ;
2937     Aret2_conservees.ajouter(art2_id);
2938     MG_ARETE*art2_cons=mggeo2->get_mg_areteid(art2_id);
2939     Results.ajouter_liste_topologie(MODIFIE_CONSERVEE,art2_cons);
2940     CORRESPONDANCE CORRESP;
2941     CORRESP.eleorigine=art1_cons;
2942     CORRESP.elemodifie=art2_cons;
2943     Results.ajouter_liste_topologie(CORRESP);
2944     }
2945    
2946     for (int i1=0;i1<aret1_disparues.get_nb();i1++)
2947     {
2948     int art_dsp=aret1_disparues.get(i1) ;
2949     Aret1_disparues.ajouter(art_dsp);
2950     //MG_ARETE*art_disp=mggeo1->get_mg_areteid(art_dsp);
2951     //Results.ajouter_liste_topologie(ORIGINE_DISPARUE,art_disp);
2952     }
2953    
2954     for (int i1=0;i1<aret2_nouvelles.get_nb();i1++)
2955     {
2956     int art_nv= aret2_nouvelles.get(i1) ;
2957     Aret2_nouvelles.ajouter(art_nv);
2958     //MG_ARETE*art_app=mggeo2->get_mg_areteid(art_nv);
2959     //Results.ajouter_liste_topologie(MODIFIE_APPARUE,art_app);
2960     }
2961     //for(int i1=0;i1<aret2_partielles.get_nb()/2;i1++){
2962     // int art1_prt=aret2_partielles.get(2*i1);
2963     // int art2_prt=aret2_partielles.get(2*i1+1);
2964    
2965     //il faut metttre les points des sous artes avec leurs correspondances;
2966    
2967     //Results.ajouter_liste_topologie(MODIFIE_APPARUE,art_app);
2968    
2969     // Aret2_partielles.ajouter(art1_prt);
2970     // }
2971     faces1_partiellement_modf.ajouter(Num1);
2972     faces2_partiellement_modf.ajouter(Num2);
2973     // }//verid
2974     }// if()nb_aretes_trouvees
2975    
2976     } //if (G1==G2)
2977     // }
2978     }
2979     }
2980    
2981    
2982    
2983    
2984    
2985     for (int i=0;i<Aret2_nouvelles.get_nb();i++)
2986     {
2987     int art_nouv=Aret2_nouvelles.get(i);
2988     if (! Aret2_conservees.est_dans_la_liste(Aret2_nouvelles.get(i)))
2989     {
2990     MG_ARETE*art_app=mggeo2->get_mg_areteid(art_nouv);
2991     Results.ajouter_liste_topologie(MODIFIE_APPARUE,art_app);
2992     }
2993     }
2994    
2995     for (int i=0;i<Aret1_disparues.get_nb();i++)
2996     {
2997     int art_nouv=Aret1_disparues.get(i);
2998     if (! Aret1_conservees.est_dans_la_liste(Aret1_disparues.get(i)))
2999     {
3000     MG_ARETE*art_disp=mggeo1->get_mg_areteid(art_nouv);
3001     Results.ajouter_liste_topologie(ORIGINE_DISPARUE,art_disp);
3002     }
3003     }
3004    
3005    
3006     for (int j=0;j<dif2.get_nb();j++)
3007     {
3008     if (!face2_conservees.est_dans_la_liste(dif2.get(j)))
3009     {
3010     int nouv_face=dif2.get(j);
3011     faces_nouvelles.ajouter(nouv_face);
3012     MG_FACE* Face_Nouvelle=mggeo2->get_mg_faceid(nouv_face);
3013     Results.ajouter_liste_topologie(MODIFIE_APPARUE,Face_Nouvelle);
3014     int nb_boucle2=Face_Nouvelle->get_nb_mg_boucle();
3015    
3016     for (int j=0;j<nb_boucle2;j++)
3017     {
3018     MG_BOUCLE* Boucle2 = Face_Nouvelle->get_mg_boucle(j);
3019     int nbarete2 = Boucle2->get_nb_mg_coarete();
3020     for (int w2=0;w2<nbarete2;w2++)
3021     {
3022     MG_COARETE* coArete2 = Boucle2->get_mg_coarete(w2);
3023     MG_ARETE* arete_nouvelle = coArete2->get_arete();
3024     Results.ajouter_liste_topologie(MODIFIE_APPARUE,arete_nouvelle);
3025     MG_COSOMMET* cosommt1= arete_nouvelle->get_cosommet1();
3026     MG_COSOMMET* cosommt2= arete_nouvelle->get_cosommet2();
3027     MG_SOMMET* nouveau_sommet1= cosommt1->get_sommet();
3028     MG_SOMMET* nouveau_sommet2= cosommt2->get_sommet();
3029     Results.ajouter_liste_topologie(MODIFIE_APPARUE,nouveau_sommet1);
3030     Results.ajouter_liste_topologie(MODIFIE_APPARUE,nouveau_sommet2);
3031     }
3032     }
3033     }
3034     }
3035    
3036     for (int i1=0;i1<nb_face1;i1++)
3037     {
3038     MG_FACE*face1=mggeo1->get_mg_face(i1);
3039     int face1_id=face1->get_id();
3040     if (!face1_conservees.est_dans_la_liste(face1_id))
3041     {
3042     Results.ajouter_liste_topologie(ORIGINE_DISPARUE,face1);
3043     int nb_boucle1=face1->get_nb_mg_boucle();
3044     for (int j1=0;j1<nb_boucle1;j1++)
3045     {
3046     MG_BOUCLE* Boucle1 = face1->get_mg_boucle(j1);
3047     int nbarete1 = Boucle1->get_nb_mg_coarete();
3048     for (int w1 =0; w1<nbarete1;w1++)
3049     {
3050     MG_COARETE* coArete1 = Boucle1->get_mg_coarete(w1);
3051     MG_ARETE* arete1 = coArete1->get_arete();
3052     int id_art1=arete1->get_id();
3053     Results.ajouter_liste_topologie(ORIGINE_DISPARUE,arete1);
3054    
3055     }
3056     }
3057     }
3058     }
3059    
3060     for (int i=0;i<nb_face1;i++)
3061     {
3062     MG_FACE* face1=mggeo1->get_mg_face(i);
3063     MG_SURFACE* surf1=face1->get_surface();
3064     int id1=face1->get_id();
3065     if (!face1_conservees.est_dans_la_liste(id1))
3066     {
3067     OT_TENSEUR tns1_surf(4),tns2_surf(4);
3068     tns1_surf=surf1->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
3069     vector<double2> isurf1;
3070     for (int r=0;r<4;r++)
3071     {
3072     isurf1.insert( isurf1.end(), tns1_surf(r,r));
3073     }
3074     for (int j=0;j<nb_face2;j++)
3075     {
3076     MG_FACE* face2=mggeo2->get_mg_face(j);
3077     MG_SURFACE* surf2=face2->get_surface();
3078     int id2=face2->get_id();
3079     CORRESPONDANCE CORRESP_FACE;
3080     OT_VECTEUR_4DD G1=surf1->get_vectorisation().calcule_barycentre(T1);
3081     OT_VECTEUR_4DD G2=surf2->get_vectorisation().calcule_barycentre(T2);
3082     G1=surf1->get_vectorisation().get_nouveau_pt(T1,G1);
3083     tns2_surf=surf2->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
3084     vector<double2> isurf2;
3085     for (int r=0;r<4;r++)
3086     {
3087     isurf2.insert( isurf2.end(), tns1_surf(r,r));
3088     }
3089     vector<unsigned int> indx1;
3090     if (tns1_surf.listes_equivalentes(isurf1,isurf2,indx1))
3091     {
3092     if (G1==G2)
3093     {
3094     Results.ajouter_liste_topologie(ORIGINE_CONSERVEE,face1);
3095     Results.ajouter_liste_topologie(MODIFIE_CONSERVEE,face2);
3096     CORRESP_FACE.eleorigine=face1;
3097     CORRESP_FACE.elemodifie=face2;
3098     Results.ajouter_liste_topologie(CORRESP_FACE);
3099    
3100     }
3101     }
3102     }
3103     }
3104     }
3105    
3106     identite.vide();
3107     for (int i=0;i<face1_conservees.get_nb();i++)
3108     {
3109     identite.ajouter( face1_conservees.get(i));
3110     identite.ajouter( face2_conservees.get(i));
3111     }
3112     this->affecter_les_couleurs(1);
3113    
3114     }
3115    
3116     int VCT_COMPARAISON::surfaces_sont_elles_identiques(MG_FACE* face1,MG_FACE* face2)
3117     {
3118     MG_SURFACE* surf1=face1->get_surface();
3119     MG_SURFACE* surf2=face2->get_surface();
3120     vector<double2> isurf1,isurf2;
3121     vector<unsigned int> indx1;
3122     TPL_LISTE_ENTITE<double> parm1,parm2;
3123     OT_VECTEUR_4DD Dv1,Dv2,axe3;
3124     OT_VECTEUR_4DD VNUL(0.,0.,0.,0.);
3125     double2 ZER=0.;
3126     OT_TENSEUR tm1_surf(4),tm2_surf(4),tns1_surf(4),tns2_surf(4),V1(4),V2(4);
3127     OT_VECTEUR_4DD G1=surf1->get_vectorisation().calcule_barycentre(T1);
3128     G1=surf1->get_vectorisation().get_nouveau_pt(T1,G1);
3129     tns1_surf=surf1->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
3130     OT_VECTEUR_4DD G2=surf2->get_vectorisation().calcule_barycentre(T2);
3131     tns2_surf=surf2->get_vectorisation().calcule_tenseur_inertie_base_locale(T2);
3132     tm1_surf=surf1->get_vectorisation().calcule_tenseur_metrique();
3133     tm2_surf=surf2->get_vectorisation().calcule_tenseur_metrique();
3134    
3135     surf1->get_vectorisation().calcule_axes_dinertie(T1,Dv1,V1);
3136     surf2->get_vectorisation().calcule_axes_dinertie(T2,Dv2,V2);
3137    
3138     for (int r=0;r<4;r++)
3139     {
3140     isurf1.insert( isurf1.end(), tns1_surf(r,r));
3141     isurf2.insert( isurf2.end(), tns2_surf(r,r));
3142     }
3143    
3144     if (surf2->get_type_geometrique(parm2)==MGCo_PLAN)
3145     {
3146     axe3[0]= parm2.get(3);
3147     axe3[1]= parm2.get(4);
3148     axe3[2]= parm2.get(5);
3149     axe3[3]= 0;
3150     G1=face1->get_vectorisation().calcule_barycentre(T1);
3151     G2=face2->get_vectorisation().calcule_barycentre(T2);
3152    
3153     }
3154     if (surf2->get_type_geometrique(parm1)==MGCo_CYLINDRE||surf2->get_type_geometrique(parm2)==MGCo_CONE)
3155     {
3156     axe3[0]= parm2.get(3);
3157     axe3[1]= parm2.get(4);
3158     axe3[2]= parm2.get(5);
3159     axe3[3]= 0;
3160     }
3161     //axe3=surf1->get_vectorisation().get_nouveau_pt(T1,axe3);
3162     double2 d1=axe3[0]*G1[0]+axe3[1]*G1[1]+axe3[2]*G1[3];
3163     double2 d2=axe3[0]*G2[0]+axe3[1]*G2[1]+axe3[2]*G2[3];
3164    
3165     if (tm1_surf.est_til_equivalent(tm2_surf))
3166     {
3167     if (tns1_surf.listes_equivalentes(isurf1,isurf2,indx1))
3168     {
3169     OT_VECTEUR_4DD G1G2= G1-G2;
3170     double2 mm=G1G2*axe3;
3171     if (ZER==mm)
3172     {
3173     return 1;
3174     }
3175     }
3176     }
3177     return 0;
3178     }
3179    
3180    
3181     int VCT_COMPARAISON::courbes_sont_elles_identiques(MG_ARETE* arete1,MG_ARETE* arete2)
3182     {
3183     MG_COURBE* courb1=arete1->get_courbe();
3184     MG_COURBE* courb2=arete2->get_courbe();
3185     vector<double2> icourb1,icourb2;
3186     vector<unsigned int> indx1;
3187     TPL_LISTE_ENTITE<double> parm1,parm2;
3188     OT_VECTEUR_4DD Dv1,Dv2,axe3;
3189     OT_VECTEUR_4DD VNUL(0.,0.,0.,0.);
3190     double2 ZER=0.;
3191     OT_TENSEUR tm1_surf(4),tm2_surf(4),tns1_surf(4),tns2_surf(4),V1(4),V2(4);
3192     OT_VECTEUR_4DD G1=courb1->get_vectorisation().calcule_barycentre(T1);
3193     G1=courb1->get_vectorisation().get_nouveau_pt(T1,G1);
3194     tns1_surf=courb1->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
3195     OT_VECTEUR_4DD G2=courb2->get_vectorisation().calcule_barycentre(T2);
3196     tns2_surf=courb2->get_vectorisation().calcule_tenseur_inertie_base_locale(T2);
3197     tm1_surf=courb1->get_vectorisation().calcule_tenseur_metrique();
3198     tm2_surf=courb2->get_vectorisation().calcule_tenseur_metrique();
3199    
3200     courb1->get_vectorisation().calcule_axes_dinertie(T1,Dv1,V1);
3201     courb2->get_vectorisation().calcule_axes_dinertie(T2,Dv2,V2);
3202    
3203     for (int r=0;r<4;r++)
3204     {
3205     icourb1.insert( icourb1.end(), tns1_surf(r,r));
3206     icourb2.insert( icourb2.end(), tns2_surf(r,r));
3207     }
3208    
3209     if (courb2->get_type_geometrique(parm2)==MGCo_LINE)
3210     {
3211     axe3[0]= parm2.get(3);
3212     axe3[1]= parm2.get(4);
3213     axe3[2]= parm2.get(5);
3214     axe3[3]= 0;
3215     G1=arete1->get_vectorisation().calcule_barycentre(T1);
3216     G2=arete2->get_vectorisation().calcule_barycentre(T2);
3217    
3218     }
3219     if (courb2->get_type_geometrique(parm1)==MGCo_CIRCLE||courb2->get_type_geometrique(parm2)==MGCo_ELLIPSE)
3220     {
3221     axe3[0]= parm2.get(3);
3222     axe3[1]= parm2.get(4);
3223     axe3[2]= parm2.get(5);
3224     axe3[3]= 0;
3225     }
3226    
3227     if (tm1_surf.est_til_equivalent(tm2_surf))
3228     {
3229     if (tns1_surf.listes_equivalentes(icourb1,icourb2,indx1))
3230     {
3231     OT_VECTEUR_4DD G1G2= G1-G2;
3232     OT_VECTEUR_4DD mm=G1G2^axe3;
3233     if (VNUL==mm)
3234     {
3235     return 1;
3236     }
3237     }
3238     }
3239     return 0;
3240    
3241    
3242    
3243    
3244     }
3245    
3246    
3247    
3248    
3249    
3250    
3251     void VCT_COMPARAISON::identifier_les_sommets(MG_FACE* face1_ref,MG_FACE* face2_ref,TPL_LISTE_ENTITE<int>& lst_corrsp_sommets,VCT_COMPARAISON_RESULTAT& Results)
3252     {
3253    
3254     OT_VECTEUR_4DD Dv1,Dv2,G1,gf1,gf2,G2;
3255     OT_TENSEUR V1(4),V2(4);
3256     TPL_LISTE_ENTITE<int> lst1_som_trouve;
3257     TPL_LISTE_ENTITE<int> lst2_som_trouve;
3258     face1_ref->get_vectorisation().calcule_axes_dinertie(T1,Dv1,V1);
3259     G1=face1_ref->get_vectorisation().calcule_barycentre(T1);
3260    
3261     /*
3262     for(int r=0;r<4;r++) {
3263     for(int s=0;s<4;s++) {
3264     gf1[r]= gf1[r]+V1(s,r)*G1[s];
3265     }
3266     } */
3267    
3268     face2_ref->get_vectorisation().calcule_axes_dinertie(T2,Dv2,V2);
3269     G2=face2_ref->get_vectorisation().calcule_barycentre(T2);
3270     /*
3271     for(int r=0;r<4;r++) {
3272     for(int s=0;s<4;s++) {
3273     gf2[r]= gf2[r]+V2(s,r)*G2[s];
3274     }
3275     } */
3276    
3277     int nb_sommet1= mggeo1->get_nb_mg_sommet();
3278     int nb_sommet2= mggeo2->get_nb_mg_sommet();
3279    
3280    
3281    
3282     for (int i=0;i<nb_sommet1;i++)
3283     {
3284     double xyz1[3];
3285     OT_VECTEUR_4DD S1,s1, G1G1REF;
3286     MG_SOMMET *som1=mggeo1->get_mg_sommet(i);
3287     MG_POINT* pt1=som1->get_point();
3288     int som1_id=som1->get_id();
3289     pt1->evaluer(xyz1);
3290     for (int t=0;t<3;t++) s1[t]=xyz1[t];
3291     G1G1REF=s1-G1;
3292     G1G1REF=face1_ref->get_vectorisation().get_nouveau_pt(T1,G1G1REF);
3293     /*
3294     for(int r=0;r<4;r++) {
3295     for(int s=0;s<4;s++) {
3296     S1[r]= S1[r]+V1(s,r)*s1[s];
3297     }
3298     } */
3299    
3300    
3301     for (int j=0;j<nb_sommet2;j++)
3302     {
3303     double xyz2[3];
3304     OT_VECTEUR_4DD S2,s2,G2G2REF;
3305     MG_SOMMET *som2=mggeo2->get_mg_sommet(j);
3306     MG_POINT* pt2=som2->get_point();
3307     int som2_id=som2->get_id();
3308     if ( lst1_som_trouve.est_dans_la_liste(som1_id)) break;
3309    
3310     pt2->evaluer(xyz2);
3311     for (int t=0;t<3;t++) s2[t]=xyz2[t];
3312     G2G2REF=s2-G2;
3313     /*
3314     for(int r=0;r<4;r++) {
3315     for(int s=0;s<4;s++) {
3316     S2[r]= S2[r]+V2(s,r)*s2[s];
3317     }
3318     } */
3319    
3320     if (G1G1REF==G2G2REF)
3321     {
3322     Results.ajouter_liste_topologie(ORIGINE_CONSERVEE,som1);
3323     Results.ajouter_liste_topologie(MODIFIE_CONSERVEE,som2);
3324     CORRESPONDANCE CORRESP;
3325     CORRESP.eleorigine=som1;
3326     CORRESP.elemodifie=som2;
3327     Results.ajouter_liste_topologie(CORRESP);
3328     lst_corrsp_sommets.ajouter(som1_id);
3329     lst_corrsp_sommets.ajouter(som2_id);
3330     lst1_som_trouve.ajouter(som1_id);
3331     lst2_som_trouve.ajouter(som2_id);
3332     }
3333    
3334     }
3335    
3336    
3337    
3338     }
3339    
3340    
3341     for (int i=0;i<nb_sommet1;i++)
3342     {
3343     MG_SOMMET *som=mggeo1->get_mg_sommet(i);
3344     int som_id=som->get_id();
3345     if (! lst1_som_trouve.est_dans_la_liste(som_id))
3346     {
3347    
3348     Results.ajouter_liste_topologie(ORIGINE_DISPARUE,som);
3349    
3350     }
3351    
3352     }
3353    
3354     for (int i=0;i<nb_sommet2;i++)
3355     {
3356     MG_SOMMET *som=mggeo2->get_mg_sommet(i);
3357     int som_id=som->get_id();
3358     if (! lst2_som_trouve.est_dans_la_liste(som_id))
3359     {
3360    
3361     Results.ajouter_liste_topologie(MODIFIE_APPARUE,som);
3362    
3363     }
3364    
3365     }
3366    
3367     }
3368    
3369    
3370    
3371    
3372    
3373     void VCT_COMPARAISON::get_syteme_daxes_globale()
3374     {
3375    
3376     OT_VECTEUR_4DD Dv1,Dv2,Dw,G1,G2,G1G2;
3377     OT_TENSEUR p(4),q(4),pT,qT;
3378     int nb_face1=mggeo1->get_nb_mg_face();
3379     int nb_face2=mggeo1->get_nb_mg_face();
3380     OT_VECTEUR_4DD VNul(0.,0.,0.,0.);
3381     double2 cof=-1;
3382     int plan=-1;
3383     for (int i=3;i<nb_face1;i++)
3384     {
3385     OT_TENSEUR inertie_face1(4);
3386     vector<double2> iface1;
3387     MG_FACE* face1=mggeo1->get_mg_face(i);
3388     int id_face1=face1->get_id();
3389     face1->get_vectorisation().calcule_axes_dinertie(T1,Dv1,p);
3390     pT=p.transpose();
3391     G1= face1->get_vectorisation().calcule_barycentre(T1);
3392     inertie_face1=face1->get_vectorisation().calcule_tenseur_inertie_base_locale(T1);
3393     vector<OT_VECTEUR_4DD>& list_points1=face1->get_vectorisation().get_points_controle();
3394     vector<OT_VECTEUR_4DD>& list_vecteurs1=face1->get_vectorisation().get_vecteurs();
3395     OT_VECTEUR_4DD Normal1(0.,0.,0.,0.),N1;
3396     OT_VECTEUR_4DD axe11,axe12,axe13;
3397     int cmpt=0;
3398    
3399     OT_VECTEUR_4DD v11= list_vecteurs1[0];
3400     int nb_vecteur1=list_vecteurs1.size();
3401     for (unsigned int pi=0;pi<nb_vecteur1-1;pi++)
3402     {
3403    
3404     OT_VECTEUR_4DD v2= list_vecteurs1[pi+1];
3405     if (pi==0)
3406     Normal1=v11^v2;
3407     if (pi>0)
3408     N1=v11^v2;
3409     OT_VECTEUR_4DD colineaire= Normal1^N1;
3410     if (colineaire==VNul)
3411     {
3412     cmpt++;
3413     }
3414     }
3415     vector<OT_VECTEUR_4DD> axes1;
3416     if ( cmpt== list_vecteurs1.size()-1)
3417     {
3418     plan=1;
3419     axe11=list_vecteurs1[0];
3420     axe12=Normal1^axe11;
3421     axe13=Normal1;
3422     axes1.insert(axes1.end(),axe11);
3423     axes1.insert(axes1.end(),axe12);
3424     axes1.insert(axes1.end(),axe13);
3425     }
3426    
3427     VCT_OUTILS VOUTIL(4);
3428     OT_MATRICE_3D sys_axes1=VOUTIL.get_system_axes(G1,axes1,list_points1) ;
3429    
3430     for (int r=0;r<4;r++)
3431     {
3432     iface1.insert( iface1.end(), inertie_face1(r,r));
3433     }
3434    
3435     for (int j=4;j<nb_face2;j++)
3436     {
3437     OT_TENSEUR inertie_face2(4);
3438     vector<double2> iface2;
3439     MG_FACE* face2=mggeo2->get_mg_face(j);
3440     int id_face2=face2->get_id();
3441     face2->get_vectorisation().calcule_axes_dinertie(T2,Dv2,q);
3442     G2= face2->get_vectorisation().calcule_barycentre(T2);
3443     qT=q.transpose();
3444     inertie_face2=face2->get_vectorisation().calcule_tenseur_inertie_base_locale(T2);
3445     vector<OT_VECTEUR_4DD>& list_points2=face2->get_vectorisation().get_points_controle();
3446     vector<OT_VECTEUR_4DD>& list_vecteurs2=face2->get_vectorisation().get_vecteurs();
3447     OT_VECTEUR_4DD Normal2(0.,0.,0.,0.),N1;
3448     OT_VECTEUR_4DD axe21,axe22,axe23;
3449     int cmpt=0;
3450     OT_VECTEUR_4DD v21= list_vecteurs2[0];
3451     int nb_vecteur2=list_vecteurs2.size();
3452     for (unsigned int pj=0;pj<nb_vecteur2-1;pj++)
3453     {
3454     OT_VECTEUR_4DD v2= list_vecteurs2[pj+1];
3455     if (pj==0)
3456     Normal2=v21^v2;
3457     if (pj>0)
3458     N1=v21^v2;
3459     OT_VECTEUR_4DD colineaire= Normal2^N1;
3460     if (colineaire==VNul)
3461     {
3462     cmpt++;
3463     }
3464     }
3465     vector<OT_VECTEUR_4DD> axes2;
3466     if ( cmpt== list_vecteurs2.size()-1)
3467     {
3468     plan=1;
3469     axe21=list_vecteurs2[0];
3470     axe22=Normal2^axe21;
3471     axe23=Normal2;
3472     axes2.insert(axes2.end(),axe21);
3473     axes2.insert(axes2.end(),axe22);
3474     axes2.insert(axes2.end(),axe23);
3475     }
3476    
3477     VCT_OUTILS VOUTIL(4);
3478     OT_MATRICE_3D sys_axes2=VOUTIL.get_system_axes(G2,axes2,list_points2) ;
3479    
3480     OT_MATRICE_3D T= sys_axes2*sys_axes1.transpose();
3481    
3482    
3483    
3484    
3485    
3486     /*
3487     for(int r=0;r<4;r++)
3488     {
3489     iface2.insert( iface2.end(), inertie_face2(r,r));
3490     }
3491     vector<unsigned int> indx1,indx2;
3492     OT_TENSEUR T=q*pT;
3493    
3494     if(inertie_face2.listes_equivalentes(iface1,iface2,indx1))
3495     {
3496    
3497     for(int ii=0;ii<list_points1.size();ii++)
3498     {
3499     OT_VECTEUR_4DD pt1= list_points1[ii];
3500     OT_VECTEUR_4DD pt11;
3501    
3502     for(int r=0;r<4;r++)
3503     {
3504     for(int s=0;s<4;s++)
3505     pt11[r]=pt11[r]+T(r,s)*G1[s];
3506     }
3507    
3508     for(int jj=0;jj<list_points2.size();jj++)
3509     {
3510     OT_VECTEUR_4DD pt2= list_points2[jj];
3511     OT_VECTEUR_4DD pt22;
3512     for(int r=0;r<4;r++)
3513     {
3514     for(int s=0;s<4;s++)
3515     pt22[r]=pt22[r]+T(r,s)*G2[s];
3516     }
3517     if(pt11==G2)
3518     {
3519     int g=0;
3520     }
3521    
3522    
3523     }
3524    
3525    
3526    
3527     }
3528    
3529    
3530     } */
3531    
3532    
3533     }
3534     }
3535    
3536    
3537     }
3538    
3539    
3540    
3541    
3542    
3543     std::ostream& operator <<(std::ostream& os,VCT_COMPARAISON& vct_cmp)
3544     {
3545     vct_cmp.enregistrer(os) ;
3546     return os;
3547     }
3548    
3549    
3550    
3551    
3552    
3553     void VCT_COMPARAISON::enregistrer(ostream& os)
3554     {
3555     os<<"COMPARAISON VECTORIELLE DE DEUX GEOMETRIES"<<endl;
3556     int nb_cl=2;
3557     int nb_lg=similarite.get_nb()/2;
3558     os<<"FACES_PREMIERE_GEOMETRIE : ";
3559     for (int j=0;j<nb_lg;j++)
3560     os<<setw(5)<<similarite.get(j*nb_cl+0);
3561     os<<endl;
3562     os<<"FACES_SECONDE_GEOMETRIE : ";
3563     for (int j=0;j<nb_lg;j++)
3564     os<<setw(5)<<similarite.get(j*nb_cl+1);
3565     os<<endl;
3566    
3567     //affecter_une_couleur();
3568    
3569    
3570     }
3571    
3572    
3573    
3574     int VCT_COMPARAISON::modele_a_change_de_repere()
3575     {
3576     int nb_sommet1= mggeo1->get_nb_mg_sommet();
3577     int nb_sommet2= mggeo2->get_nb_mg_sommet();
3578    
3579     int trouve=0;
3580     int cmt=0;
3581     for (int i=0;i<nb_sommet1;i++)
3582     {
3583     double xyz1[3];
3584     OT_VECTEUR_4DD S1,s1;
3585     MG_SOMMET *som1=
3586     mggeo1->get_mg_sommet(i);
3587     MG_POINT* pt1=som1->get_point();
3588     int som1_id=som1->get_id();
3589     pt1->evaluer(xyz1);
3590     for (int t=0;t<3;t++) s1[t]=xyz1[t];
3591    
3592    
3593     for (int j=0;j<nb_sommet2;j++)
3594     {
3595     double xyz2[3];
3596     OT_VECTEUR_4DD S2,s2;
3597     MG_SOMMET *som2=mggeo2->get_mg_sommet(j);
3598     MG_POINT* pt2=som2->get_point();
3599     int som2_id=som2->get_id();
3600     pt2->evaluer(xyz2);
3601     for (int t=0;t<3;t++) s2[t]=xyz2[t];
3602    
3603    
3604     if (s1==s2)
3605     {
3606     trouve=1;
3607     break;
3608     }
3609    
3610     }
3611     if (trouve==-1) return trouve;
3612     }
3613    
3614    
3615     return trouve;
3616    
3617     }
3618    
3619     #endif