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