ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/comparaison/src/vct_comparaison.cpp
Revision: 747
Committed: Tue Oct 6 19:53:22 2015 UTC (9 years, 7 months ago) by francois
File size: 48148 byte(s)
Log Message:
gestion du multivolume a l'importation des fichiers OCC avec triangulation associée

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 francois 433 mggeo2->construit_vectorisation();
27 francois 283 }
28    
29     VCT_COMPARAISON::~VCT_COMPARAISON()
30     {
31     }
32    
33     void VCT_COMPARAISON::active_affichage(void (*fonc)(char*))
34     {
35     affiche=fonc;
36     affichageactif=1;
37     }
38    
39    
40     void VCT_COMPARAISON::compare(VCT_COMPARAISON_RESULTAT &cmp,MG_VOLUME* vol1,MG_VOLUME* vol2,OT_CPU *cpu)
41     {
42     if (vol1==NULL) vol1=mggeo1->get_mg_volume(0);
43     if (vol2==NULL) vol2=mggeo2->get_mg_volume(0);
44     if (affichageactif==1)
45     {
46 francois 366 #ifndef USE_ENGLISH
47 francois 283 char mess[300];
48     sprintf(mess," Fichier 1 : %d faces",mggeo1->get_nb_mg_face());
49     affiche((char*)mess);
50     sprintf(mess," Fichier 2 : %d faces",mggeo2->get_nb_mg_face());
51     affiche((char*)mess);
52     affiche((char*)" Recherche de similarité");
53 francois 366 #else
54     char mess[300];
55     sprintf(mess," File A : %d faces",mggeo1->get_nb_mg_face());
56     affiche((char*)mess);
57     sprintf(mess," File B : %d faces",mggeo2->get_nb_mg_face());
58     affiche((char*)mess);
59     affiche((char*)" Similar faces research");
60     #endif
61 francois 283 }
62     trouve_similarite();
63 francois 366 #ifndef USE_ENGLISH
64 francois 283 if (cpu!=NULL) cpu->ajouter_etape("Similarite");
65     if (affichageactif==1)
66     {
67     char mess[300];
68     sprintf(mess," Nombre de paires de faces similaires : %d",similarite.get_nb()/2);
69     affiche((char*)mess);
70     affiche((char*)" Recherche d'identite");
71     }
72 francois 366 #else
73     if (cpu!=NULL) cpu->ajouter_etape("Similar faces");
74     if (affichageactif==1)
75     {
76     char mess[300];
77     sprintf(mess," Number of similar faces : %d",similarite.get_nb()/2);
78     affiche((char*)mess);
79     affiche((char*)" Identical faces reseach");
80     }
81     #endif
82 francois 283 trouve_identite();
83 francois 366 #ifndef USE_ENGLISH
84 francois 283 if (cpu!=NULL) cpu->ajouter_etape("Identite");
85     if (affichageactif==1)
86     {
87     char mess[300];
88     sprintf(mess," Nombre de paires de faces identiques : %d",identite.get_nb()/2);
89     affiche((char*)mess);
90     affiche((char*)" Recherche de localisation");
91     }
92 francois 366 #else
93     if (cpu!=NULL) cpu->ajouter_etape("Identical faces");
94     if (affichageactif==1)
95     {
96     char mess[300];
97     sprintf(mess," Nunber of identical faces : %d",identite.get_nb()/2);
98     affiche((char*)mess);
99     affiche((char*)" Localized faces research");
100     }
101     #endif
102 francois 283 trouve_localise(cmp);
103 francois 366 #ifndef USE_ENGLISH
104 francois 283 if (cpu!=NULL) cpu->ajouter_etape("Localisation");
105     if (affichageactif==1)
106     {
107     char mess[300];
108 francois 348 sprintf(mess," Face de reference 1 : %lu ",cmp.get_face_reference1()->get_id());
109     affiche((char*)mess);
110     sprintf(mess," Face de reference 2 : %lu ",cmp.get_face_reference2()->get_id());
111     affiche((char*)mess);
112 francois 283 sprintf(mess," Matrice de changement de repere : %lf %lf %lf %lf",transformation(0,0).get_x(),transformation(0,1).get_x(),transformation(0,2).get_x(),transformation(0,3).get_x());
113     affiche((char*)mess);
114     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());
115     affiche((char*)mess);
116     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());
117     affiche((char*)mess);
118     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());
119     affiche((char*)mess);
120    
121     sprintf(mess," Nombre de paires de faces localisées : %d",localise.get_nb()/2);
122     affiche((char*)mess);
123     affiche((char*)" Recherche des arêtes et des sommets correspondants");
124 francois 366 }
125     #else
126     if (cpu!=NULL) cpu->ajouter_etape("Localized faces");
127     if (affichageactif==1)
128     {
129     char mess[300];
130     sprintf(mess," Reference face A : %lu ",cmp.get_face_reference1()->get_id());
131     affiche((char*)mess);
132     sprintf(mess," Reference face B : %lu ",cmp.get_face_reference2()->get_id());
133     affiche((char*)mess);
134     sprintf(mess," Transfom matrix : %lf %lf %lf %lf",transformation(0,0).get_x(),transformation(0,1).get_x(),transformation(0,2).get_x(),transformation(0,3).get_x());
135     affiche((char*)mess);
136     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());
137     affiche((char*)mess);
138     sprintf(mess," RA to RB : %lf %lf %lf %lf",transformation(2,0).get_x(),transformation(2,1).get_x(),transformation(2,2).get_x(),transformation(2,3).get_x());
139     affiche((char*)mess);
140     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());
141     affiche((char*)mess);
142    
143     sprintf(mess," Number of localized faces : %d",localise.get_nb()/2);
144     affiche((char*)mess);
145     affiche((char*)" Vertices and egdes correspondense research ");
146     }
147     #endif
148 francois 283 identifie_correspondance(cmp);
149 francois 366 #ifndef USE_ENGLISH
150 francois 283 if (cpu!=NULL) cpu->ajouter_etape("Correspondance");
151     if (affichageactif==1) affiche((char*)" Recherche des modifications partielles");
152 francois 366 if (affichageactif==1)
153     {
154     char mess[300];
155     sprintf(mess," Nombre de paires de sommets localisés : %d",sommetparfait);
156     affiche((char*)mess);
157     sprintf(mess," Nombre de paires d'aretes localisées : %d",areteparfait);
158     affiche((char*)mess);
159     }
160     #else
161     if (cpu!=NULL) cpu->ajouter_etape("Correspondence");
162     if (affichageactif==1) affiche((char*)" Partial modification research");
163     if (affichageactif==1)
164     {
165     char mess[300];
166     sprintf(mess," Number of localized vertices : %d",sommetparfait);
167     affiche((char*)mess);
168     sprintf(mess," Number of localized edges : %d",areteparfait);
169     affiche((char*)mess);
170     }
171     #endif
172 francois 283 trouve_modification_partielle(cmp);
173 francois 366 #ifndef USE_ENGLISH
174 francois 283 if (cpu!=NULL) cpu->ajouter_etape("Modifications partielles");
175 francois 366 if (affichageactif==1)
176     {
177     char mess[300];
178     sprintf(mess," Nombre de paires de sommets : %d",sommetpartiel);
179     affiche((char*)mess);
180     sprintf(mess," Nombre de paires d'aretes : %d",aretepartiel);
181     affiche((char*)mess);
182     sprintf(mess," Nombre de paires de faces : %d",facepartiel);
183     affiche((char*)mess);
184     }
185     #else
186     if (cpu!=NULL) cpu->ajouter_etape("Partial modification");
187     if (affichageactif==1)
188     {
189     char mess[300];
190     sprintf(mess," Partial modification vectices : %d",sommetpartiel);
191     affiche((char*)mess);
192     sprintf(mess," Partial modification edges : %d",aretepartiel);
193     affiche((char*)mess);
194     sprintf(mess," Partial modification faces : %d",facepartiel);
195     affiche((char*)mess);
196     }
197     #endif
198    
199 francois 283 }
200    
201 francois 351
202    
203 francois 283 void VCT_COMPARAISON::trouve_similarite(void)
204     {
205     int nb_face1=mggeo1->get_nb_mg_face();
206     int nb_face2=mggeo2->get_nb_mg_face();
207     similarite.vide();
208     for (int i=0;i<nb_face1; i++)
209     {
210     MG_FACE* face1=mggeo1->get_mg_face(i);
211     MG_SURFACE*surf1=face1->get_surface();
212     int nb_top1_pts= face1->get_vectorisation().get_nb_points();
213     int nb_geo1_pts= surf1->get_vectorisation().get_nb_points();
214    
215     OT_TENSEUR *tns1_face=face1->get_vectorisation().get_tenseur_metrique();
216     OT_TENSEUR *tns1_surf=surf1->get_vectorisation().get_tenseur_metrique();
217 francois 363 for (int j=0;j<nb_face2;j++)
218 francois 283 {
219     MG_FACE* face2=mggeo2->get_mg_face(j);
220     MG_SURFACE*surf2=face2->get_surface();
221     int nb_top2_pts= face2->get_vectorisation().get_nb_points();
222     int nb_geo2_pts= surf2->get_vectorisation().get_nb_points();
223     OT_TENSEUR* tns2_face=face2->get_vectorisation().get_tenseur_metrique();
224     OT_TENSEUR* tns2_surf=surf2->get_vectorisation().get_tenseur_metrique();
225 francois 363 if (nb_geo1_pts==nb_geo2_pts&&nb_top1_pts==nb_top2_pts)
226 francois 283 {
227     if (tns1_face->est_til_equivalent(*tns2_face))
228     {
229     if (tns1_surf->est_til_equivalent(*tns2_surf))
230     {
231     similarite.ajouter(face1->get_id());
232     similarite.ajouter(face2->get_id());
233     }
234     }
235     }
236     }
237     }
238     }
239    
240     void VCT_COMPARAISON::trouve_identite(void)
241     {
242     identite.vide();
243     int nbpaire=similarite.get_nb()/2;
244     for (int i=0;i<nbpaire;i++)
245     {
246     MG_FACE* face1=mggeo1->get_mg_faceid(similarite.get(2*i));
247     MG_SURFACE*surf1=face1->get_surface();
248     MG_FACE* face2=mggeo2->get_mg_faceid(similarite.get(2*i+1));
249     MG_SURFACE*surf2=face1->get_surface();
250     OT_TENSEUR *tns1_face=face1->get_vectorisation().get_tenseur_inertie_base_locale_4d();
251     OT_TENSEUR *tns1_surf=surf1->get_vectorisation().get_tenseur_inertie_base_locale_4d();
252     OT_TENSEUR *tns2_face=face2->get_vectorisation().get_tenseur_inertie_base_locale_4d();
253     OT_TENSEUR *tns2_surf=surf2->get_vectorisation().get_tenseur_inertie_base_locale_4d();
254     if (tns1_face->est_til_equivalent(*tns2_face))
255     if (tns1_surf->est_til_equivalent(*tns2_surf))
256     {
257     identite.ajouter(face1->get_id());
258     identite.ajouter(face2->get_id());
259     }
260     }
261     }
262     void VCT_COMPARAISON::trouve_localise(VCT_COMPARAISON_RESULTAT &cmp)
263     {
264    
265     localise.vide();
266     TPL_LISTE_ENTITE<int> localisetmp;
267     int nbpaire=identite.get_nb()/2.;
268     if (nbpaire==0)
269     {
270     OT_TENSEUR tmp(4,4);
271     tmp.identite();
272     transformation=tmp;
273     transformation_inverse=tmp;
274 francois 351 return;
275 francois 283 }
276     int *paire=new int[nbpaire];
277     for (int i=0;i<nbpaire;i++)
278     paire[i]=0;
279     for (int ident=0;ident<nbpaire;ident++)
280     {
281     if (paire[ident]==1) continue;
282     MG_FACE* faceref1=mggeo1->get_mg_faceid(identite.get(2*ident));
283     MG_FACE* faceref2=mggeo2->get_mg_faceid(identite.get(2*ident+1));
284     OT_TENSEUR tnsref1(3,3);
285     OT_TENSEUR tnsref2(3,3);
286     std::vector<OT_TENSEUR> list;
287     recale_repere_reference(faceref1,faceref2,list);
288     int nbessai=list.size()/2;
289     for (int essai=0;essai<nbessai;essai++)
290     {
291     localisetmp.vide();
292     int *pairetmp=new int[nbpaire];
293     for (int i=0;i<nbpaire;i++)
294     pairetmp[i]=0;
295     OT_VECTEUR_3DD *baryref1=faceref1->get_vectorisation().get_barycentre_3d();
296     OT_VECTEUR_3DD *baryref2=faceref2->get_vectorisation().get_barycentre_3d();
297     OT_TENSEUR tnsref1=list[essai*2];
298     OT_TENSEUR tnsref2=list[essai*2+1];
299     OT_TENSEUR tnsrefinv1=tnsref1.transpose();
300     OT_TENSEUR tnsrefinv2=tnsref2.transpose();
301     for (int i=0;i<nbpaire;i++)
302     {
303     MG_FACE* face1=mggeo1->get_mg_faceid(identite.get(2*i));
304     MG_FACE* face2=mggeo2->get_mg_faceid(identite.get(2*i+1));
305     OT_TENSEUR *tns1=face1->get_vectorisation().get_base_locale_3d();
306     OT_TENSEUR trans1=tns1->transpose();
307     trans1=trans1*tnsref1;
308     OT_TENSEUR tns2=trans1.transpose();
309     tns2=tnsref2*tns2;
310     OT_TENSEUR *iner2=face2->get_vectorisation().get_tenseur_inertie_3d();
311     OT_TENSEUR *inerloc2=face2->get_vectorisation().get_tenseur_inertie_base_locale_3d();
312     OT_TENSEUR inerloc2prime=tns2.transpose();
313     inerloc2prime=inerloc2prime*(*iner2);
314     inerloc2prime=inerloc2prime*tns2;
315     OT_VECTEUR_3DD *bary1=face1->get_vectorisation().get_barycentre_3d();
316     OT_VECTEUR_3DD baryloc1=(*bary1)-(*baryref1);
317     baryloc1=tnsrefinv1*baryloc1;
318     OT_VECTEUR_3DD *bary2=face2->get_vectorisation().get_barycentre_3d();
319     OT_VECTEUR_3DD baryloc2=(*bary2)-(*baryref2);
320     baryloc2=tnsrefinv2*baryloc2;
321     if (inerloc2prime.est_til_equivalent(*inerloc2))
322     if (baryloc1==baryloc2)
323     {
324     localisetmp.ajouter(face1->get_id());
325     localisetmp.ajouter(face2->get_id());
326     pairetmp[i]=1;
327     }
328     }
329     if (localisetmp.get_nb()>localise.get_nb())
330     {
331     int n=localisetmp.get_nb();
332     localise.vide();
333     for (int i=0;i<n;i++)
334     localise.ajouter(localisetmp.get(i));
335     for (int i=0;i<nbpaire;i++)
336     paire[i]=pairetmp[i];
337     ident=0;
338     transformation=calcul_transformation(*baryref1,*baryref2,tnsref1,tnsref2);
339 francois 347 cmp.change_face_reference1(faceref1);
340     cmp.change_face_reference2(faceref2);
341 francois 283 }
342     delete [] pairetmp;
343     }
344     }
345     delete [] paire;
346     transformation_inverse=transformation.inverse_homogene();
347     OT_VECTEUR_3D vec1(transformation(0,0).get_x(),transformation(1,0).get_x(),transformation(2,0).get_x());
348     OT_VECTEUR_3D vec2(transformation(0,1).get_x(),transformation(1,1).get_x(),transformation(2,1).get_x());
349     OT_VECTEUR_3D vec3(transformation(0,2).get_x(),transformation(1,2).get_x(),transformation(2,2).get_x());
350     OT_VECTEUR_3D vec4(transformation(0,3).get_x(),transformation(1,3).get_x(),transformation(2,3).get_x());
351     cmp.initialise_changement_repere(vec1,vec2,vec3,vec4);
352 francois 351 for (int i=0;i<similarite.get_nb();i++)
353     cmp.ajouter_similarite(similarite.get(i));
354     for (int i=0;i<identite.get_nb();i++)
355     cmp.ajouter_identite(identite.get(i));
356     for (int i=0;i<localise.get_nb();i++)
357     cmp.ajouter_localise_face(localise.get(i));
358 francois 283 }
359 francois 366
360    
361 francois 283 void VCT_COMPARAISON::identifie_correspondance(VCT_COMPARAISON_RESULTAT &cmp)
362     {
363 francois 366 sommetparfait=0;areteparfait=0;
364 francois 283 int nbpaire=localise.get_nb()/2.;
365     for (int i=0;i<nbpaire;i++)
366     {
367     MG_FACE* face1=mggeo1->get_mg_faceid(localise.get(2*i));
368     MG_FACE* face2=mggeo2->get_mg_faceid(localise.get(2*i+1));
369     CORRESPONDANCE cor(face1,face2,CORRESPONDANCE::PARFAITE);
370     cmp.ajouter_liste_topologie(cor);
371     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,face1);
372     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_CONSERVEE,face2);
373     identifie_topologie_sous_jacente(cmp,face1,face2,sommetparfait,areteparfait);
374     }
375 francois 366
376 francois 283 }
377    
378     void VCT_COMPARAISON::identifie_topologie_sous_jacente(VCT_COMPARAISON_RESULTAT &cmp,MG_FACE* face1,MG_FACE* face2,int& sommetparfait,int& areteparfait)
379     {
380     double2 UN(1.0);
381     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD > tabsom1;
382     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD > tabsom2;
383     std::multimap<OT_VECTEUR_3DD,MG_ARETE*,lessOT_VECTEUR_3DD > tabare1;
384     std::multimap<OT_VECTEUR_3DD,MG_ARETE*,lessOT_VECTEUR_3DD > tabare2;
385     int nb_boucle=face1->get_nb_mg_boucle();
386     for (int i=0;i<nb_boucle;i++)
387     {
388     MG_BOUCLE* bou1=face1->get_mg_boucle(i);
389     int nb_arete=bou1->get_nb_mg_coarete();
390     for (int j=0;j<nb_arete;j++)
391     {
392     MG_ARETE *are=bou1->get_mg_coarete(j)->get_arete();
393     OT_VECTEUR_3DD *bary=are->get_vectorisation().get_barycentre_3d();
394     std::pair<OT_VECTEUR_3DD,MG_ARETE*> tmp(*bary,are);
395     tabare1.insert(tmp);
396     MG_SOMMET *som1=are->get_cosommet1()->get_sommet();
397     double xyz[3];
398     som1->get_point()->evaluer(xyz);
399     OT_VECTEUR_3DD vec(xyz[0],xyz[1],xyz[2]);
400     std::pair<OT_VECTEUR_3DD,MG_SOMMET*> tmp2(vec,som1);
401     tabsom1.insert(tmp2);
402     MG_SOMMET *som2=are->get_cosommet2()->get_sommet();
403     som2->get_point()->evaluer(xyz);
404     OT_VECTEUR_3DD vec2(xyz[0],xyz[1],xyz[2]);
405     std::pair<OT_VECTEUR_3DD,MG_SOMMET*> tmp3(vec2,som2);
406     tabsom1.insert(tmp3);
407     }
408     MG_BOUCLE* bou2=face2->get_mg_boucle(i);
409     nb_arete=bou1->get_nb_mg_coarete();
410     for (int j=0;j<nb_arete;j++)
411     {
412     MG_ARETE *are=bou2->get_mg_coarete(j)->get_arete();
413     OT_VECTEUR_3DD *bary=are->get_vectorisation().get_barycentre_3d();
414     OT_VECTEUR_4DD baryhomo(bary->get_x(),bary->get_y(),bary->get_z(),UN);
415     OT_VECTEUR_4DD barytranshomo=transformation_inverse*baryhomo;
416     OT_VECTEUR_3DD barytrans(barytranshomo.get_x(),barytranshomo.get_y(),barytranshomo.get_z());
417     double2 w=UN/barytranshomo.get_w();
418     barytrans=barytrans*w;
419     std::pair<OT_VECTEUR_3DD,MG_ARETE*> tmp(barytrans,are);
420     tabare2.insert(tmp);
421     MG_SOMMET *som1=are->get_cosommet1()->get_sommet();
422     double xyz[3];
423     som1->get_point()->evaluer(xyz);
424     OT_VECTEUR_4DD vechomo(xyz[0],xyz[1],xyz[2],1.);
425     OT_VECTEUR_4DD vectranshomo=transformation_inverse*vechomo;
426     OT_VECTEUR_3DD vectrans(vectranshomo.get_x(),vectranshomo.get_y(),vectranshomo.get_z());
427     w=UN/vectranshomo.get_w();
428     vectrans=vectrans*w;
429     std::pair<OT_VECTEUR_3DD,MG_SOMMET*> tmp2(vectrans,som1);
430     tabsom2.insert(tmp2);
431     MG_SOMMET *som2=are->get_cosommet2()->get_sommet();
432     som2->get_point()->evaluer(xyz);
433     OT_VECTEUR_4DD vechomo2(xyz[0],xyz[1],xyz[2],1.);
434     OT_VECTEUR_4DD vectranshomo2=transformation_inverse*vechomo2;
435     OT_VECTEUR_3DD vectrans2(vectranshomo2.get_x(),vectranshomo2.get_y(),vectranshomo2.get_z());
436     w=UN/vectranshomo2.get_w();
437     vectrans2=vectrans2*w;
438     std::pair<OT_VECTEUR_3DD,MG_SOMMET*> tmp3(vectrans2,som2);
439     tabsom2.insert(tmp3);
440     }
441     //arete
442     std::multimap<OT_VECTEUR_3DD,MG_ARETE*,lessOT_VECTEUR_3DD >::iterator it1;
443     std::multimap<OT_VECTEUR_3DD,MG_ARETE*,lessOT_VECTEUR_3DD >::iterator it2;
444     it1=tabare1.begin();
445     int ok=0;
446     if (it1==tabare1.end()) ok=1;
447     while (ok==0)
448     {
449     MG_ARETE* are1=(*it1).second;
450     OT_VECTEUR_3DD bary1=(*it1).first;
451     int nb_top1_pts= are1->get_vectorisation().get_nb_points();
452     int nb_geo1_pts= are1->get_courbe()->get_vectorisation().get_nb_points();
453     OT_TENSEUR *tns1_metrique_are=are1->get_vectorisation().get_tenseur_metrique();
454     OT_TENSEUR *tns1_metrique_crb=are1->get_courbe()->get_vectorisation().get_tenseur_metrique();
455     OT_TENSEUR *tns1_inertie_are=are1->get_vectorisation().get_tenseur_inertie_base_locale_4d();
456     OT_TENSEUR *tns1_inertie_crb=are1->get_courbe()->get_vectorisation().get_tenseur_inertie_base_locale_4d();
457     it2=tabare2.find(bary1);
458     int ok2=0;
459     do
460     {
461     if (it2==tabare2.end()) ok2=1;
462     else
463     {
464     MG_ARETE* are2=(*it2).second;
465     OT_VECTEUR_3DD bary2=(*it2).first;
466     if (!(bary2==bary1)) ok2=1;
467     else
468     {
469     int nb_top2_pts= are2->get_vectorisation().get_nb_points();
470     int nb_geo2_pts= are2->get_courbe()->get_vectorisation().get_nb_points();
471     OT_TENSEUR *tns2_metrique_are=are2->get_vectorisation().get_tenseur_metrique();
472     OT_TENSEUR *tns2_metrique_crb=are2->get_courbe()->get_vectorisation().get_tenseur_metrique();
473     OT_TENSEUR *tns2_inertie_are=are2->get_vectorisation().get_tenseur_inertie_base_locale_4d();
474     OT_TENSEUR *tns2_inertie_crb=are2->get_courbe()->get_vectorisation().get_tenseur_inertie_base_locale_4d();
475     if (nb_top1_pts==nb_top2_pts)
476     if (nb_geo1_pts==nb_geo2_pts)
477     if (tns1_metrique_are->est_til_equivalent(*tns2_metrique_are))
478     if (tns1_metrique_crb->est_til_equivalent(*tns2_metrique_crb))
479     if (tns1_inertie_are->est_til_equivalent(*tns2_inertie_are))
480     if (tns1_inertie_crb->est_til_equivalent(*tns2_inertie_crb))
481     {
482     CORRESPONDANCE cor(are1,are2,CORRESPONDANCE::PARFAITE);
483     int res=cmp.ajouter_liste_topologie(cor);
484     if (res==1)
485     {
486     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,are1);
487     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_CONSERVEE,are2);
488 francois 351 cmp.ajouter_localise_arete(are1->get_id());
489     cmp.ajouter_localise_arete(are2->get_id());
490     areteparfait++;
491 francois 283 }
492     }
493     it2++;
494     }
495     }
496     }
497     while (ok2==0);
498     it1++;
499     if (it1==tabare1.end()) ok=1;
500     }
501    
502     //sommet
503     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD >::iterator its1;
504     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD >::iterator its2;
505     its1=tabsom1.begin();
506     ok=0;
507     do
508     {
509     MG_SOMMET* som=(*its1).second;
510     its2=tabsom2.find((*its1).first);
511     if (its2!=tabsom2.end())
512     {
513     CORRESPONDANCE cor((*its1).second,(*its2).second,CORRESPONDANCE::PARFAITE);
514     int res=cmp.ajouter_liste_topologie(cor);
515     if (res==1)
516     {
517     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,(*its1).second);
518     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_CONSERVEE,(*its2).second);
519 francois 351 cmp.ajouter_localise_sommet(((*its1).second)->get_id());
520     cmp.ajouter_localise_sommet(((*its2).second)->get_id());
521 francois 283 sommetparfait++;
522     }
523     }
524     its1++;
525     if (its1==tabsom1.end()) ok=1;
526     }
527     while (ok==0);
528     }
529     }
530    
531     void VCT_COMPARAISON::trouve_modification_partielle(VCT_COMPARAISON_RESULTAT &cmp)
532     {
533     double2 ZERO(0.);
534     double2 UN(1.);
535 francois 366 sommetpartiel=0;aretepartiel=0;facepartiel=0;
536 francois 283 //tableau des entites qui n'ont pas pu associees
537     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD > tabsom1;
538     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD > tabsom2;
539     std::multimap<int,MG_ARETE* > tabare1;
540     std::multimap<int,MG_ARETE* > tabare2;
541     std::multimap<int,MG_FACE* > tabface1;
542     std::multimap<int,MG_FACE*> tabface2;
543    
544     LISTE_MG_SOMMET::iterator itsom;
545     LISTE_MG_ARETE::iterator itare;
546     LISTE_MG_FACE::iterator itface;
547     for (MG_SOMMET* som=mggeo1->get_premier_sommet(itsom);som!=NULL;som=mggeo1->get_suivant_sommet(itsom))
548     {
549     unsigned long num=cmp.get_liste_correspondance_modifie(som->get_id());
550     if (num==0)
551     {
552     double xyz[3];
553     som->get_point()->evaluer(xyz);
554     OT_VECTEUR_3DD vec(xyz[0],xyz[1],xyz[2]);
555     std::pair<OT_VECTEUR_3DD,MG_SOMMET*> tmp(vec,som);
556     tabsom1.insert(tmp);
557     }
558     }
559     for (MG_ARETE* are=mggeo1->get_premier_arete(itare);are!=NULL;are=mggeo1->get_suivant_arete(itare))
560     {
561     unsigned long num=cmp.get_liste_correspondance_modifie(are->get_id());
562     if (num==0)
563     {
564     TPL_LISTE_ENTITE<double> param;
565     int typecrb=are->get_courbe()->get_type_geometrique(param);
566     std::pair<int,MG_ARETE*> tmp(typecrb,are);
567     tabare1.insert(tmp);
568     }
569     }
570     for (MG_FACE* face=mggeo1->get_premier_face(itface);face!=NULL;face=mggeo1->get_suivant_face(itface))
571     {
572     unsigned long num=cmp.get_liste_correspondance_modifie(face->get_id());
573     if (num==0)
574     {
575     TPL_LISTE_ENTITE<double> param;
576     int typesurf=face->get_surface()->get_type_geometrique(param);
577     std::pair<int,MG_FACE*> tmp(typesurf,face);
578     tabface1.insert(tmp);
579     }
580     }
581     for (MG_SOMMET* som=mggeo2->get_premier_sommet(itsom);som!=NULL;som=mggeo2->get_suivant_sommet(itsom))
582     {
583     unsigned long num=cmp.get_liste_correspondance_origine(som->get_id());
584     if (num==0)
585     {
586     double xyz[3];
587     som->get_point()->evaluer(xyz);
588     OT_VECTEUR_4DD vec(xyz[0],xyz[1],xyz[2],1.);
589     OT_VECTEUR_4DD vectranshomo=transformation_inverse*vec;
590     OT_VECTEUR_3DD vectrans(vectranshomo.get_x(),vectranshomo.get_y(),vectranshomo.get_z());
591     double2 w=UN/vectranshomo.get_w();
592     vectrans=vectrans*w;
593     std::pair<OT_VECTEUR_3DD,MG_SOMMET*> tmp(vectrans,som);
594     tabsom2.insert(tmp);
595     }
596     }
597     for (MG_ARETE* are=mggeo2->get_premier_arete(itare);are!=NULL;are=mggeo2->get_suivant_arete(itare))
598     {
599     unsigned long num=cmp.get_liste_correspondance_origine(are->get_id());
600     if (num==0)
601     {
602     TPL_LISTE_ENTITE<double> param;
603     int typecrb=are->get_courbe()->get_type_geometrique(param);
604     std::pair<int,MG_ARETE*> tmp(typecrb,are);
605     tabare2.insert(tmp);
606     }
607     }
608     for (MG_FACE* face=mggeo2->get_premier_face(itface);face!=NULL;face=mggeo2->get_suivant_face(itface))
609     {
610     unsigned long num=cmp.get_liste_correspondance_origine(face->get_id());
611     if (num==0)
612     {
613     TPL_LISTE_ENTITE<double> param;
614     int typesurf=face->get_surface()->get_type_geometrique(param);
615     std::pair<int,MG_FACE*> tmp(typesurf,face);
616     tabface2.insert(tmp);
617     }
618     }
619     //analyse sommet
620     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD >::iterator its1;
621     std::map<OT_VECTEUR_3DD,MG_SOMMET*,lessOT_VECTEUR_3DD >::iterator its2;
622     its1=tabsom1.begin();
623     int ok=0;
624     if (tabsom1.size()==0) ok=1;
625     while (ok==0)
626     {
627     its2=tabsom2.find((*its1).first);
628     if (its2!=tabsom2.end())
629     {
630     CORRESPONDANCE cor((*its1).second,(*its2).second,CORRESPONDANCE::MODIFIE);
631     cmp.ajouter_liste_topologie(cor);
632     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,(*its1).second);
633     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_CONSERVEE,(*its2).second);
634 francois 351 sommetpartiel++;
635 francois 283 }
636     its1++;
637     if (its1==tabsom1.end()) ok=1;
638     }
639     //analyse arete
640     std::multimap<int,MG_ARETE* >::iterator ita1;
641     std::multimap<int,MG_ARETE* >::iterator ita2;
642     ita1=tabare1.begin();
643     ok=0;
644     if (tabare1.size()==0) ok=1;
645     while (ok==0)
646     {
647     MG_ARETE* are1=(*ita1).second;
648     int typecrb1=(*ita1).first;
649     int nb_geo1_pts= are1->get_courbe()->get_vectorisation().get_nb_points();
650     OT_TENSEUR *tns1_metrique_crb=are1->get_courbe()->get_vectorisation().get_tenseur_metrique();
651     OT_TENSEUR *tns1_inertie_crb=are1->get_courbe()->get_vectorisation().get_tenseur_inertie_base_locale_4d();
652     ita2=tabare2.find(typecrb1);
653     int ok2=0;
654     do
655     {
656     if (ita2==tabare2.end()) ok2=1;
657     else
658     {
659     MG_ARETE* are2=(*ita2).second;
660     int typecrb2=(*ita2).first;
661     if (!(typecrb2==typecrb1)) ok2=1;
662     else
663     {
664     int nb_geo2_pts= are2->get_courbe()->get_vectorisation().get_nb_points();
665     OT_TENSEUR *tns2_metrique_crb=are2->get_courbe()->get_vectorisation().get_tenseur_metrique();
666     OT_TENSEUR *tns2_inertie_crb=are2->get_courbe()->get_vectorisation().get_tenseur_inertie_base_locale_4d();
667     if (nb_geo1_pts==nb_geo2_pts)
668     if (tns1_metrique_crb->est_til_equivalent(*tns2_metrique_crb))
669     if (tns1_inertie_crb->est_til_equivalent(*tns2_inertie_crb))
670     if (localise_courbe(are1->get_courbe(),are2->get_courbe()))
671     {
672     CORRESPONDANCE cor(are1,are2,CORRESPONDANCE::MODIFIE);
673     cmp.ajouter_liste_topologie(cor);
674     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,are1);
675     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_CONSERVEE,are2);
676 francois 351 cmp.ajouter_modifie_arete(are1->get_id());
677     cmp.ajouter_modifie_arete(are2->get_id());
678 francois 283 aretepartiel++;
679     }
680     ita2++;
681     }
682     }
683     }
684     while (ok2==0);
685     ita1++;
686     if (ita1==tabare1.end()) ok=1;
687     }
688    
689     //analyse face
690     std::multimap<int,MG_FACE* >::iterator itf1;
691     std::multimap<int,MG_FACE* >::iterator itf2;
692     itf1=tabface1.begin();
693     ok=0;
694     if (tabface1.size()==0) ok=1;
695     while (ok==0)
696     {
697     MG_FACE* face1=(*itf1).second;
698     int typefac1=(*itf1).first;
699     int nb_geo1_pts= face1->get_surface()->get_vectorisation().get_nb_points();
700     OT_TENSEUR *tns1_metrique_surface=face1->get_surface()->get_vectorisation().get_tenseur_metrique();
701     OT_TENSEUR *tns1_inertie_surface=face1->get_surface()->get_vectorisation().get_tenseur_inertie_base_locale_4d();
702     itf2=tabface2.find(typefac1);
703     int ok2=0;
704     do
705     {
706     if (itf2==tabface2.end()) ok2=1;
707     else
708     {
709     MG_FACE* face2=(*itf2).second;
710     int typefac2=(*itf2).first;
711     if (typefac1!=typefac2) ok2=1;
712     else
713     {
714     int nb_geo2_pts= face2->get_surface()->get_vectorisation().get_nb_points();
715     OT_TENSEUR *tns2_metrique_surface=face2->get_surface()->get_vectorisation().get_tenseur_metrique();
716     OT_TENSEUR *tns2_inertie_surface=face2->get_surface()->get_vectorisation().get_tenseur_inertie_base_locale_4d();
717     if (nb_geo1_pts==nb_geo2_pts)
718     //if (tns1_metrique_surface->est_til_equivalent(*tns2_metrique_surface))
719     //if (tns1_inertie_surface->est_til_equivalent(*tns2_inertie_surface))
720     if (localise_surface(face1->get_surface(),face2->get_surface()))
721     {
722     CORRESPONDANCE cor(face1,face2,CORRESPONDANCE::MODIFIE);
723     cmp.ajouter_liste_topologie(cor);
724     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_CONSERVEE,face1);
725     cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_CONSERVEE,face2);
726 francois 351 cmp.ajouter_modifie_face(face1->get_id());
727     cmp.ajouter_modifie_face(face2->get_id());
728 francois 283 facepartiel++;
729     }
730     itf2++;
731     }
732     }
733     }
734     while (ok2==0);
735     itf1++;
736     if (itf1==tabface1.end()) ok=1;
737     }
738     //fin remplissage cmp
739     for (its1=tabsom1.begin();its1!=tabsom1.end();its1++)
740     {
741     unsigned long num=cmp.get_liste_correspondance_modifie((*its1).second->get_id());
742     if (num==0) cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_DISPARUE,(*its1).second);
743     }
744     for (its1=tabsom2.begin();its1!=tabsom2.end();its1++)
745     {
746     unsigned long num=cmp.get_liste_correspondance_origine((*its1).second->get_id());
747     if (num==0) cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_APPARUE,(*its1).second);
748     }
749     for (ita1=tabare1.begin();ita1!=tabare1.end();ita1++)
750     {
751     unsigned long num=cmp.get_liste_correspondance_modifie((*ita1).second->get_id());
752     if (num==0) cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_DISPARUE,(*ita1).second);
753     }
754     for (ita1=tabare2.begin();ita1!=tabare2.end();ita1++)
755     {
756     unsigned long num=cmp.get_liste_correspondance_origine((*ita1).second->get_id());
757     if (num==0) cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_APPARUE,(*ita1).second);
758     }
759     for (itf1=tabface1.begin();itf1!=tabface1.end();itf1++)
760     {
761     unsigned long num=cmp.get_liste_correspondance_modifie((*itf1).second->get_id());
762     if (num==0) cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::ORIGINE_DISPARUE,(*itf1).second);
763     }
764     for (itf1=tabface2.begin();itf1!=tabface2.end();itf1++)
765     {
766     unsigned long num=cmp.get_liste_correspondance_origine((*itf1).second->get_id());
767     if (num==0) cmp.ajouter_liste_topologie(VCT_COMPARAISON_RESULTAT::MODIFIE_APPARUE,(*itf1).second);
768     }
769 francois 366
770 francois 283
771     }
772    
773    
774     int VCT_COMPARAISON::localise_courbe(MG_COURBE *crb1,MG_COURBE *crb2)
775     {
776     double xyz1[3],xyz2[3],xyz3[3],xyz[3];
777     double t=0.5*(crb2->get_tmax()+crb2->get_tmin());
778     double dt=(crb2->get_tmax()-crb2->get_tmin())/max(fabs(crb2->get_tmax()),fabs(crb2->get_tmin()));
779     crb2->evaluer(t,xyz1);
780     t=t+dt;
781     crb2->evaluer(t,xyz2);
782     t=t+dt;
783     crb2->evaluer(t,xyz3);
784     change_point_inverse(xyz1);
785     change_point_inverse(xyz2);
786     change_point_inverse(xyz3);
787     OT_VECTEUR_3D vec(xyz1,xyz3);
788     crb1->inverser(t,xyz1);
789     crb1->evaluer(t,xyz);
790     OT_VECTEUR_3D vec1(xyz,xyz1);
791     if (vec1.get_longueur()>eps) return 0;
792     crb1->inverser(t,xyz2);
793     crb1->evaluer(t,xyz);
794     OT_VECTEUR_3D vec2(xyz,xyz2);
795     if (vec2.get_longueur()>eps) return 0;
796     crb1->inverser(t,xyz3);
797     crb1->evaluer(t,xyz);
798     OT_VECTEUR_3D vec3(xyz,xyz3);
799     if (vec3.get_longueur()>eps) return 0;
800     return 1;
801     }
802    
803     int VCT_COMPARAISON::localise_surface(MG_SURFACE *surf1,MG_SURFACE *surf2)
804     {
805     double du=surf2->get_umax()-surf2->get_umin();
806     double dv=surf2->get_vmax()-surf2->get_vmin();
807     du=du/max(fabs(surf2->get_umax()),fabs(surf2->get_umin()));
808     dv=dv/max(fabs(surf2->get_vmax()),fabs(surf2->get_vmin()));
809     double ou=0.5*(surf2->get_umax()+surf2->get_umin());
810     double ov=0.5*(surf2->get_vmax()+surf2->get_vmin());
811     for (int i=0;i<3;i++)
812     for (int j=0;j<3;j++)
813     {
814     double uv[2],xyz[3];
815     uv[0]=ou+i*du;
816     uv[1]=ov+j*dv;
817     surf2->evaluer(uv,xyz);
818     change_point_inverse(xyz);
819     double xyz1[3];
820     surf1->inverser(uv,xyz);
821     surf1->evaluer(uv,xyz1);
822     OT_VECTEUR_3D vec(xyz,xyz1);
823     if (vec.get_longueur()>eps) return 0;
824     }
825     return 1;
826     }
827    
828    
829    
830     void VCT_COMPARAISON::change_point_inverse(double *xyz)
831     {
832     double2 UN(1.);
833     OT_VECTEUR_4DD vec(xyz[0],xyz[1],xyz[2],1.);
834     OT_VECTEUR_4DD vectranshomo=transformation_inverse*vec;
835     OT_VECTEUR_3DD vectrans(vectranshomo.get_x(),vectranshomo.get_y(),vectranshomo.get_z());
836     double2 w=UN/vectranshomo.get_w();
837     vectrans=vectrans*w;
838     xyz[0]=vectrans.get_x().get_x();
839     xyz[1]=vectrans.get_y().get_x();
840     xyz[2]=vectrans.get_z().get_x();
841     }
842    
843     void VCT_COMPARAISON::change_point(double *xyz)
844     {
845     double2 UN(1.);
846     OT_VECTEUR_4DD vec(xyz[0],xyz[1],xyz[2],1.);
847     OT_VECTEUR_4DD vectranshomo=transformation*vec;
848     OT_VECTEUR_3DD vectrans(vectranshomo.get_x(),vectranshomo.get_y(),vectranshomo.get_z());
849     double2 w=UN/vectranshomo.get_w();
850     vectrans=vectrans*w;
851     xyz[0]=vectrans.get_x().get_x();
852     xyz[1]=vectrans.get_y().get_x();
853     xyz[2]=vectrans.get_z().get_x();
854     }
855    
856    
857    
858     OT_TENSEUR VCT_COMPARAISON::calcul_transformation(OT_VECTEUR_3DD &bary1,OT_VECTEUR_3DD &bary2,OT_TENSEUR &tns1,OT_TENSEUR &tns2)
859     {
860     double2 zero(0.),un(1.);
861     OT_TENSEUR t1(4,4);
862     t1(0,0)=tns1(0,0);
863     t1(1,0)=tns1(1,0);
864     t1(2,0)=tns1(2,0);
865     t1(3,0)=zero;
866     t1(0,1)=tns1(0,1);
867     t1(1,1)=tns1(1,1);
868     t1(2,1)=tns1(2,1);
869     t1(3,1)=zero;
870     t1(0,2)=tns1(0,2);
871     t1(1,2)=tns1(1,2);
872     t1(2,2)=tns1(2,2);
873     t1(3,2)=zero;
874     t1(0,3)=bary1.get_x();
875     t1(1,3)=bary1.get_y();
876     t1(2,3)=bary1.get_z();
877     t1(3,3)=un;
878     OT_TENSEUR t2(4,4);
879     t2(0,0)=tns2(0,0);
880     t2(1,0)=tns2(1,0);
881     t2(2,0)=tns2(2,0);
882     t2(3,0)=zero;
883     t2(0,1)=tns2(0,1);
884     t2(1,1)=tns2(1,1);
885     t2(2,1)=tns2(2,1);
886     t2(3,1)=zero;
887     t2(0,2)=tns2(0,2);
888     t2(1,2)=tns2(1,2);
889     t2(2,2)=tns2(2,2);
890     t2(3,2)=zero;
891     t2(0,3)=bary2.get_x();
892     t2(1,3)=bary2.get_y();
893     t2(2,3)=bary2.get_z();
894     t2(3,3)=un;
895     OT_TENSEUR t1inv=t1.inverse_homogene();
896     OT_TENSEUR trans=t2*t1inv;
897     return trans;
898     }
899    
900     void VCT_COMPARAISON::recale_repere_reference(MG_FACE* faceref1,MG_FACE* faceref2,vector<OT_TENSEUR> &list)
901     {
902     OT_TENSEUR tnsref1(3,3),tnsref2(3,3);
903     double2 zero(0.);
904     // repere1
905     OT_VECTEUR_3DD *bary1=faceref1->get_vectorisation().get_barycentre_3d();
906     double xyz1[3]={bary1->get_x().get_x(),bary1->get_y().get_x(),bary1->get_z().get_x()};
907     MG_GEOMETRIE_OUTILS ot;
908     double uvproj1[2],xyzproj1[3];
909     ot.projete(xyz1,faceref1,uvproj1,xyzproj1);
910     double normal1[3];
911     faceref1->calcul_normale_unitaire(uvproj1,normal1);
912     double2 normal12[3];
913     normal12[0]=normal1[0];
914     normal12[1]=normal1[1];
915     normal12[2]=normal1[2];
916     OT_VECTEUR_3DD nor1(normal12);
917     int sens1=faceref1->get_mg_coface(0)->get_orientation();
918     nor1=sens1*nor1;
919     OT_TENSEUR *axe1=faceref1->get_vectorisation().get_base_locale_3d();
920     int n13=-1;
921     int signe13=1;
922     double2 limit1(0.);
923     for (int i=0;i<3;i++)
924     {
925     OT_VECTEUR_3DD veci;
926     veci[0]=(*axe1)(0,i);
927     veci[1]=(*axe1)(1,i);
928     veci[2]=(*axe1)(2,i);
929     double2 ps=veci*nor1;
930     if (f2abs(ps)>limit1)
931     {
932     n13=i;
933     if (ps<zero) signe13=-1;
934     limit1=f2abs(ps);
935     }
936     }
937     int n11,n12;
938     if (n13==0) {
939     n11=1;
940     n12=2;
941     }
942     if (n13==1) {
943     n11=0;
944     n12=2;
945     }
946     if (n13==2) {
947     n11=0;
948     n12=1;
949     }
950     OT_TENSEUR *inertie_base_locale1=faceref1->get_vectorisation().get_tenseur_inertie_base_locale_3d();
951     if ((*inertie_base_locale1)(n11,n11)<(*inertie_base_locale1)(n12,n12)) {
952     int tmp=n11;
953     n11=n12;
954     n12=tmp;
955     }
956     OT_VECTEUR_3DD x11((*axe1)(0,n11),(*axe1)(1,n11),(*axe1)(2,n11));
957     OT_VECTEUR_3DD x13((*axe1)(0,n13)*signe13,(*axe1)(1,n13)*signe13,(*axe1)(2,n13)*signe13);
958     OT_VECTEUR_3DD x12=x13 & x11;
959     (tnsref1)(0,0)=x11.get_x();
960     (tnsref1)(1,0)=x11.get_y();
961     (tnsref1)(2,0)=x11.get_z();
962     (tnsref1)(0,1)=x12.get_x();
963     (tnsref1)(1,1)=x12.get_y();
964     (tnsref1)(2,1)=x12.get_z();
965     (tnsref1)(0,2)=x13.get_x();
966     (tnsref1)(1,2)=x13.get_y();
967     (tnsref1)(2,2)=x13.get_z();
968     int nbtest1=1;
969 francois 361 if ((*inertie_base_locale1)(n11,n11)==(*inertie_base_locale1)(n12,n12)) nbtest1=2; //nbtest1=2;
970 francois 283 for (int test1=0;test1<nbtest1;test1++)
971     {
972     if (test1==1)
973     {
974     OT_VECTEUR_3DD x11((*axe1)(0,n12),(*axe1)(1,n12),(*axe1)(2,n12));
975     OT_VECTEUR_3DD x12=x13 & x11;
976     (tnsref1)(0,0)=x11.get_x();
977     (tnsref1)(1,0)=x11.get_y();
978     (tnsref1)(2,0)=x11.get_z();
979     (tnsref1)(0,1)=x12.get_x();
980     (tnsref1)(1,1)=x12.get_y();
981     (tnsref1)(2,1)=x12.get_z();
982     (tnsref1)(0,2)=x13.get_x();
983     (tnsref1)(1,2)=x13.get_y();
984     (tnsref1)(2,2)=x13.get_z();
985     }
986     OT_TENSEUR inv1=tnsref1.transpose();
987     int nbpt1=faceref1->get_vectorisation().get_points_controle().size();
988     OT_VECTEUR_3DD bary1xp,bary1yp,bary1xn,bary1yn;
989     int xp1=0,yp1=0,xn1=0,yn1=0;
990     for (int i=0;i<nbpt1;i++)
991     {
992     OT_VECTEUR_4DD pt=faceref1->get_vectorisation().get_points_controle()[i];
993     OT_VECTEUR_3DD point(pt[0],pt[1],pt[2]);
994     point=point-(*bary1);
995     point=inv1*point;
996     if (point.get_x()>zero)
997     {
998     bary1xp=bary1xp+point;
999     xp1++;
1000     }
1001     if (point.get_x()<zero)
1002     {
1003     bary1xn=bary1xn+point;
1004     xn1++;
1005     }
1006     if (point.get_y()>zero)
1007     {
1008     bary1yp=bary1yp+point;
1009     yp1++;
1010     }
1011     if (point.get_y()<zero)
1012     {
1013     bary1xn=bary1xn+point;
1014     yn1++;
1015     }
1016     }
1017     bary1xp=bary1xp/xp1;
1018     bary1xn=bary1xn/xn1;
1019     bary1yp=bary1yp/yp1;
1020     bary1yp=bary1yp/yn1;
1021     //repere2
1022     OT_VECTEUR_3DD *bary2=faceref2->get_vectorisation().get_barycentre_3d();
1023     double xyz2[3]={bary2->get_x().get_x(),bary2->get_y().get_x(),bary2->get_z().get_x()};
1024     double uvproj2[2],xyzproj2[3];
1025     ot.projete(xyz2,faceref2,uvproj2,xyzproj2);
1026     double normal2[3];
1027     faceref2->calcul_normale_unitaire(uvproj2,normal2);
1028     double2 normal22[3];
1029     normal22[0]=normal2[0];
1030     normal22[1]=normal2[1];
1031     normal22[2]=normal2[2];
1032     OT_VECTEUR_3DD nor2(normal22);
1033     int sens2=faceref2->get_mg_coface(0)->get_orientation();
1034     nor2=sens2*nor2;
1035     OT_TENSEUR *axe2=faceref2->get_vectorisation().get_base_locale_3d();
1036     int n23=-1;
1037     int signe23=1;
1038     double2 limit2(0.);
1039     for (int i=0;i<3;i++)
1040     {
1041     OT_VECTEUR_3DD veci;
1042     veci[0]=(*axe2)(0,i);
1043     veci[1]=(*axe2)(1,i);
1044     veci[2]=(*axe2)(2,i);
1045     double2 ps=veci*nor2;
1046     if (f2abs(ps)>limit2)
1047     {
1048     n23=i;
1049     if (ps<zero) signe23=-1;
1050     limit2=f2abs(ps);
1051     }
1052     }
1053     int n21,n22;
1054     if (n23==0) {
1055     n21=1;
1056     n22=2;
1057     }
1058     if (n23==1) {
1059     n21=0;
1060     n22=2;
1061     }
1062     if (n23==2) {
1063     n21=0;
1064     n22=1;
1065     }
1066     OT_TENSEUR *inertie_base_locale2=faceref2->get_vectorisation().get_tenseur_inertie_base_locale_3d();
1067     if ((*inertie_base_locale2)(n21,n21)<(*inertie_base_locale2)(n22,n22)) {
1068     int tmp=n21;
1069     n21=n22;
1070     n22=tmp;
1071     }
1072     OT_VECTEUR_3DD x21((*axe2)(0,n21),(*axe2)(1,n21),(*axe2)(2,n21));
1073     OT_VECTEUR_3DD x23((*axe2)(0,n23)*signe23,(*axe2)(1,n23)*signe23,(*axe2)(2,n23)*signe23);
1074     OT_VECTEUR_3DD x22=x23 & x21;
1075     (tnsref2)(0,0)=x21.get_x();
1076     (tnsref2)(1,0)=x21.get_y();
1077     (tnsref2)(2,0)=x21.get_z();
1078     (tnsref2)(0,1)=x22.get_x();
1079     (tnsref2)(1,1)=x22.get_y();
1080     (tnsref2)(2,1)=x22.get_z();
1081     (tnsref2)(0,2)=x23.get_x();
1082     (tnsref2)(1,2)=x23.get_y();
1083     (tnsref2)(2,2)=x23.get_z();
1084     int nbtest2=1;
1085     if ((*inertie_base_locale2)(n21,n21)==(*inertie_base_locale2)(n22,n22)) nbtest1=0; //nbtest2=2;
1086     for (int test2=0;test2<nbtest2;test2++)
1087     {
1088     if (test2==1)
1089     {
1090     OT_VECTEUR_3DD x21((*axe1)(0,n22),(*axe1)(1,n22),(*axe1)(2,n22));
1091     OT_VECTEUR_3DD x22=x23 & x21;
1092     (tnsref2)(0,0)=x21.get_x();
1093     (tnsref2)(1,0)=x21.get_y();
1094     (tnsref2)(2,0)=x21.get_z();
1095     (tnsref2)(0,1)=x22.get_x();
1096     (tnsref2)(1,1)=x22.get_y();
1097     (tnsref2)(2,1)=x22.get_z();
1098     (tnsref2)(0,2)=x23.get_x();
1099     (tnsref2)(1,2)=x23.get_y();
1100     (tnsref2)(2,2)=x23.get_z();
1101     }
1102     OT_TENSEUR inv2=tnsref2.transpose();
1103     int nbpt2=faceref2->get_vectorisation().get_points_controle().size();
1104     OT_VECTEUR_3DD bary2xp,bary2yp,bary2xn,bary2yn;
1105     int xp2=0,yp2=0,xn2=0,yn2=0;
1106     for (int i=0;i<nbpt2;i++)
1107     {
1108     OT_VECTEUR_4DD pt=faceref2->get_vectorisation().get_points_controle()[i];
1109     OT_VECTEUR_3DD point(pt[0],pt[1],pt[2]);
1110     point=point-(*bary2);
1111     point=inv2*point;
1112     if (point.get_x()>zero)
1113     {
1114     bary2xp=bary2xp+point;
1115     xp2++;
1116     }
1117     if (point.get_x()<zero)
1118     {
1119     bary2xn=bary2xn+point;
1120     xn2++;
1121     }
1122     if (point.get_y()>zero)
1123     {
1124     bary2yp=bary2yp+point;
1125     yp2++;
1126     }
1127     if (point.get_y()<zero)
1128     {
1129     bary2xn=bary2xn+point;
1130     yn2++;
1131     }
1132     }
1133     bary2xp=bary2xp/xp2;
1134     bary2xn=bary2xn/xn2;
1135     bary2yp=bary2yp/yp2;
1136     bary2yp=bary2yp/yn2;
1137    
1138     if ((bary2xp==bary1xp) && (bary2xn==bary1xn) && (bary2yp==bary1yp) && (bary2yn==bary1yn))
1139     {
1140     list.insert(list.end(),tnsref1);
1141     list.insert(list.end(),tnsref2);
1142     }
1143     OT_VECTEUR_3DD vnul(zero,zero,zero);
1144     bary2xp=vnul;
1145     bary2xn=vnul;
1146     bary2yp=vnul;
1147     bary2yp=vnul;
1148    
1149     tnsref2(0,0)=zero-tnsref2(0,0);
1150     tnsref2(1,0)=zero-tnsref2(1,0);
1151     tnsref2(2,0)=zero-tnsref2(2,0);
1152     tnsref2(0,1)=zero-tnsref2(0,1);
1153     tnsref2(1,1)=zero-tnsref2(1,1);
1154     tnsref2(2,1)=zero-tnsref2(2,1);
1155    
1156     inv2=tnsref2.transpose();
1157     xp2=0,yp2=0,xn2=0,yn2=0;
1158     for (int i=0;i<nbpt2;i++)
1159     {
1160     OT_VECTEUR_4DD pt=faceref2->get_vectorisation().get_points_controle()[i];
1161     OT_VECTEUR_3DD point(pt[0],pt[1],pt[2]);
1162     point=point-(*bary2);
1163     point=inv2*point;
1164     if (point.get_x()>zero)
1165     {
1166     bary2xp=bary2xp+point;
1167     xp2++;
1168     }
1169     if (point.get_x()<zero)
1170     {
1171     bary2xn=bary2xn+point;
1172     xn2++;
1173     }
1174     if (point.get_y()>zero)
1175     {
1176     bary2yp=bary2yp+point;
1177     yp2++;
1178     }
1179     if (point.get_y()<zero)
1180     {
1181     bary2xn=bary2xn+point;
1182     yn2++;
1183     }
1184     }
1185     bary2xp=bary2xp/xp2;
1186     bary2xn=bary2xn/xn2;
1187     bary2yp=bary2yp/yp2;
1188     bary2yp=bary2yp/yn2;
1189     if ((bary2xp==bary1xp) && (bary2xn==bary1xn) && (bary2yp==bary1yp) && (bary2yn==bary1yn))
1190     {
1191     list.insert(list.end(),tnsref1);
1192     list.insert(list.end(),tnsref2);
1193     }
1194     }
1195     }
1196    
1197     }
1198    
1199    
1200    
1201    
1202    
1203    
1204    
1205    
1206    
1207    
1208    
1209    
1210