ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/comparaison/src/vct_comparaison.cpp
Revision: 348
Committed: Fri Jun 29 20:17:43 2012 UTC (12 years, 10 months ago) by francois
Original Path: magic/lib/vectorisation/src/vct_comparaison.cpp
File size: 131471 byte(s)
Log Message:
Affichage des faces de references aussi à l'écran du comparateur

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