ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/vct_face.cpp
Revision: 66
Committed: Wed Mar 19 16:45:26 2008 UTC (17 years, 1 month ago) by souaissa
Original Path: magic/lib/geometrie/geometrie/src/vct_face.cpp
File size: 22724 byte(s)
Log Message:
reorganisation des classes de vectorisation. Situation normalement final pour le doc de khaled

File Contents

# User Rev Content
1 souaissa 66 #include "gestionversion.h"
2     //---------------------------------------------------------------------------
3    
4    
5     #pragma hdrstop
6    
7     #include "vct_face.h"
8     #include "mg_face.h"
9     #include "mg_surface.h"
10    
11     #include "mg_arete.h"
12     #include "ot_mathematique.h"
13     #include <math>
14     #include <iomanip>
15     #include "sld_fonction.h"
16    
17     //---------------------------------------------------------------------------
18    
19     #pragma package(smart_init)
20    
21    
22    
23     VCT_FACE::VCT_FACE(MG_FACE* face):VCT_ELEMENT_TOPOLOGIQUE(face)
24     {
25    
26     MG_SURFACE* surf=((MG_FACE*)elem_topo)->get_surface();
27     //VCT_SURFACE vct_surf(surf);
28     vct_surf=new VCT_SURFACE(surf);
29     nb_pts_surf=vct_surf->get_nb_points();
30     vct_surf->get_vectorisation(LISTE_GEO_VECTEUR_FACE);
31     int indx1_premier,indx2_premier;
32     nb_geo_points=0;
33     nb_topo_points=0;
34    
35     //TPL_LISTE_ENTITE<double> surf_param;
36    
37     //surf->get_param_NURBS(indx1_premier,surf_param);
38     //for(int i=indx1_premier;i<surf_param.get_nb();i++)
39     //LISTE_POINTS_CTRS.ajouter(surf_param.get(i));
40    
41     int nb_boucle=((MG_FACE*)elem_topo)->get_nb_mg_boucle();
42     for(int j=0;j<nb_boucle;j++)
43     {
44     MG_BOUCLE* Boucle = ((MG_FACE*)elem_topo)->get_mg_boucle(j);
45     int nbarete = Boucle->get_nb_mg_coarete();
46     for (int w =0; w<nbarete;w++)
47     {
48     TPL_LISTE_ENTITE<double> contr_param;
49     vector<double2> list_geo_temp;
50     vector<double2> liste_topo_temp;
51    
52     MG_COARETE* coArete = Boucle->get_mg_coarete(w);
53     MG_ARETE* Arete = coArete->get_arete();
54     Arete->get_param_NURBS(indx2_premier,contr_param);
55     for(int i=indx2_premier;i<contr_param.get_nb();i++)// -4
56     LISTE_POINTS_CTRS.insert(LISTE_POINTS_CTRS.end(),contr_param.get(i));
57     VCT_ARETE vct_aret(Arete);
58    
59     int nb_pts_crb=vct_aret.get_nb_geo_points();
60     nb_geo_points+=nb_pts_crb;
61     vct_aret.get_geo_vectorisation(list_geo_temp);
62     vct_aret.get_topo_vectorisation(liste_topo_temp) ;
63     int nb_pts_art=vct_aret.get_nb_topo_points();
64     nb_topo_points+=nb_pts_art;//-1
65     //nt nb_lst=liste_topo_temp.size();
66     //insertion de la vectorisation des aretes
67     //la vectorisation de la topologie d<une face
68     //revient a la vectorisation topologique de ces aretes
69     for(unsigned int i=0;i<liste_topo_temp.size();i++)
70     {
71     LISTE_TOPO_VECTEURS_CONTOURS.insert(LISTE_TOPO_VECTEURS_CONTOURS.end(),liste_topo_temp[i]);
72     LISTE_TOPO_VECTEUR_FACE.insert(LISTE_TOPO_VECTEUR_FACE.end(),liste_topo_temp[i]);
73     }
74     //insertion de la vectorisation des courbes
75     //elle permettra de rajouter la vectorisation des courbes a la vectorisation
76     //de la surface pour le momment je la vois une grande utilite
77     // for(unsigned int i=0;i<list_geo_temp.size();i++)
78     // {
79     // LISTE_GEO_VECTEURS_CONTOURS.insert(LISTE_GEO_VECTEURS_CONTOURS.end(),list_geo_temp[i]);
80     // LISTE_GEO_VECTEUR_FACE.insert(LISTE_GEO_VECTEUR_FACE.end(),list_geo_temp[i]);
81     // }
82    
83     }
84    
85     }
86     nb_geo_points+=nb_pts_surf;
87     //nb_topo_points+=nb_pts_surf;
88     }
89    
90    
91    
92     VCT_FACE::VCT_FACE(VCT_FACE& mdd):VCT_ELEMENT_TOPOLOGIQUE(mdd.elem_topo)
93     {
94     LISTE_GEO_VECTEUR_FACE=mdd.LISTE_GEO_VECTEUR_FACE;
95     LISTE_TOPO_VECTEUR_FACE=mdd.LISTE_TOPO_VECTEUR_FACE;
96     LISTE_GEO_VECTEURS_CONTOURS=mdd.LISTE_GEO_VECTEURS_CONTOURS;
97     LISTE_TOPO_VECTEURS_CONTOURS=mdd.LISTE_TOPO_VECTEURS_CONTOURS;
98     nb_geo_points=mdd.nb_geo_points;
99     nb_topo_points=mdd.nb_geo_points;
100     //vct_surf=mdd.get_vct_surface();
101     }
102    
103    
104     VCT_FACE::~ VCT_FACE()
105     {
106     delete vct_surf;
107     }
108    
109    
110     VCT_SURFACE* VCT_FACE::get_vct_surface()
111     {
112     return vct_surf;
113     }
114    
115     void VCT_FACE::get_topo_vectorisation(vector<double2>& lst)
116     {
117     lst= LISTE_TOPO_VECTEUR_FACE;
118     }
119    
120     void VCT_FACE::get_geo_vectorisation(vector<double2>& lst)
121     {
122     lst=LISTE_GEO_VECTEUR_FACE;
123     }
124    
125     void VCT_FACE::get_vectorisation_topo_contr(vector<double2>& lst)
126     {
127     lst= LISTE_TOPO_VECTEURS_CONTOURS ;
128     }
129    
130     void VCT_FACE::get_vectorisation_geo_contr(vector<double2>& lst)
131     {
132     lst= LISTE_GEO_VECTEURS_CONTOURS;
133     }
134    
135     OT_TNS<double2,4> VCT_FACE:: get_tenseur_metrique_surface()
136     {
137     OT_TNS<double2,4> tns_met(LISTE_GEO_VECTEUR_FACE);
138     double2 eps=1e-2;
139     for(int i=0;i<tns_met.nb_lgns();i++)
140     for(int j=0;j<tns_met.nb_cols();j++)
141     if (fabs(tns_met(i,j))<eps)tns_met(i,j)=0;
142     return tns_met;
143     }
144    
145     OT_TNS<double2,4> VCT_FACE:: get_tenseur_metrique_aretes()
146     {
147     OT_TNS<double2,4> tns_met(LISTE_TOPO_VECTEUR_FACE);
148     double2 eps=1e-2;
149     for(int i=0;i<tns_met.nb_lgns();i++)
150     for(int j=0;j<tns_met.nb_cols();j++)
151     if (fabs(tns_met(i,j))<eps)tns_met(i,j)=0;
152     return tns_met;
153     }
154    
155    
156    
157    
158    
159    
160    
161    
162    
163     void VCT_FACE::get_geo_barycentre(double2* xyz)
164     {
165    
166     // MG_SURFACE* surf=((MG_FACE*)elem_topo)->get_surface();
167     // VCT_SURFACE vct_surf(surf);
168     vct_surf->get_geo_barycentre(xyz);
169     }
170    
171     void VCT_FACE::get_topo_barycentre(double2* xyz)
172     {
173    
174     for(int i=0;i<4;i++)xyz[i]=0.;
175    
176     for(int i=0;i<nb_topo_points;i++)
177     {
178     xyz[0]= xyz[0]+LISTE_POINTS_CTRS[4*i];
179     xyz[1]= xyz[1]+LISTE_POINTS_CTRS[4*i+1];
180     xyz[2]= xyz[2]+LISTE_POINTS_CTRS[4*i+2];
181     xyz[3]= xyz[3]+LISTE_POINTS_CTRS[4*i+3];
182     }
183    
184    
185     xyz[0]=(1./nb_topo_points)*xyz[0];
186     xyz[1]=(1./nb_topo_points)*xyz[1];
187     xyz[2]=(1./nb_topo_points)*xyz[2];
188     xyz[3]=(1./nb_topo_points)*xyz[3];
189     }
190    
191    
192     double2 VCT_FACE::get_inertie_au_centre_de_masse()
193     {
194    
195     double2 inirtia_face=0. ;
196     double2 centre_masse_face[4];
197     get_topo_barycentre(centre_masse_face);
198    
199     for(int i=0;i<nb_topo_points;i++)
200     {
201     for(int j=0;j<4;j++){
202     double2 xji= LISTE_POINTS_CTRS[4*i+j];
203     xji=xji- centre_masse_face[j];
204     inirtia_face=inirtia_face+xji*xji;
205     }
206    
207     }
208    
209     return inirtia_face;
210    
211     }
212    
213    
214    
215     double2 VCT_FACE:: get_inertie_au_point(double2* xyz)
216     {
217    
218     double2 centre_de_masse[4];
219     double2 inertie_au_point_xyz;
220    
221     double2 inertie_au_centre_de_masse=get_inertie_au_centre_de_masse();
222    
223     this->get_topo_barycentre(centre_de_masse);
224    
225    
226     double2 d_x=xyz[0]-centre_de_masse[0] ;
227     double2 d_y=xyz[1]-centre_de_masse[1] ;
228     double2 d_z=xyz[2]-centre_de_masse[2] ;
229     double2 d_w=xyz[3]-centre_de_masse[3] ;
230    
231     double2 dis_GXYZ=d_x*d_x+d_y*d_y+d_z*d_z+d_w*d_w;
232    
233     inertie_au_point_xyz=inertie_au_centre_de_masse+nb_topo_points*dis_GXYZ; //nb_topo_points : ici elle represente la masse totale
234    
235     return inertie_au_point_xyz;
236     }
237    
238    
239    
240     int VCT_FACE::get_nb_geo_points()
241     {
242     return nb_geo_points ;
243     }
244    
245     int VCT_FACE::get_nb_topo_points()
246     {
247     return nb_topo_points ;
248     }
249    
250    
251     void VCT_FACE::get_covariance(double2* cov)
252     {
253     // la covariance tient en compte des points de ctrs de la surface et des aretes.
254     double2 bary[4];
255    
256     get_topo_barycentre(bary);
257    
258     double2 *pt_au_centre_masse=new double2[nb_topo_points*3] ;
259    
260     for(int k=0;k<nb_topo_points;k++)
261     {
262     for(int j=0;j<3;j++){
263     double2 xjk= LISTE_POINTS_CTRS[4*k+j];
264     pt_au_centre_masse[k*3+j]=xjk- bary[j];
265     }
266     }
267    
268    
269    
270     for(int i=0;i<9;i++)cov[i]=0.;
271    
272     for(int k=0;k<nb_topo_points;k++)
273     {
274     cov[0*3+0]= cov[0*3+0]+pt_au_centre_masse[k*3+0]*pt_au_centre_masse[k*3+0];
275     cov[0*3+1]= cov[0*3+1]+pt_au_centre_masse[k*3+0]*pt_au_centre_masse[k*3+1];
276     cov[0*3+2]= cov[0*3+2]+pt_au_centre_masse[k*3+0]*pt_au_centre_masse[k*3+2];
277     cov[1*3+1]= cov[1*3+1]+pt_au_centre_masse[k*3+1]*pt_au_centre_masse[k*3+1];
278     cov[1*3+2]= cov[1*3+2]+pt_au_centre_masse[k*3+1]*pt_au_centre_masse[k*3+2];
279     cov[2*3+2]= cov[2*3+2]+pt_au_centre_masse[k*3+2]*pt_au_centre_masse[k*3+2];
280     }
281    
282     cov[1*3+0]=cov[0*3+1] ;
283     cov[2*3+0]=cov[0*3+2] ;
284     cov[2*3+1]=cov[1*3+2] ;
285    
286     for(int i=0;i<9;i++) cov[i]=1./(nb_topo_points)*cov[i];
287     delete [] pt_au_centre_masse;
288    
289     }
290    
291    
292     void VCT_FACE::get_axes_dinertie(OT_VECTEUR_3D& vp1,OT_VECTEUR_3D& vp2,OT_VECTEUR_3D& vp3)
293     {
294     int n=3, nrot;
295     OT_MATRICE_3D m_cov;
296     int fait=-1;
297     double *ccov;
298     double2 cov[9];
299     get_covariance(cov);
300     for(int i=0;i<9;i++)
301     {
302     double x =cov[i].get_x() ;
303     if (fabs(x)<1e-14)
304     cov[i]=0.;
305    
306     }
307    
308    
309     #define cov(i,j)(*(cov+i*3+j))
310    
311    
312     if(cov(0,0).get_x()==0.&&cov(1,0).get_x()==0.&&cov(2,0).get_x()==0.)
313     {
314     ccov=new double[4];
315     vp1[0]=1.;
316     vp1[1]=0.;
317     vp1[2]=0.;
318     for(int i=0;i<2;i++){
319     for(int j=0;j<2;j++)
320     ccov[i*2+j]=cov[(i+1)*3+j].get_x();
321     }
322     n=2;
323     fait=0;
324     }
325     if(cov(0,1).get_x()==0.&&cov(1,1).get_x()==0.&&cov(2,1).get_x()==0.)
326     {
327     ccov=new double[4];
328     vp2[0]=0.;
329     vp2[1]=1.;
330     vp2[2]=0.;
331     for(int i=0;i<2;i++){
332     for(int j=0;j<2;j++){
333     if(j==0)
334     ccov[i*2+j]=cov[i*3+j].get_x();
335     if(j==1)
336     ccov[i*2+j]=cov[i*3+j+1].get_x();
337     }
338     }
339     n=2;
340     fait=1;
341     }
342     if(cov(0,2).get_x()==0.&&cov(1,2).get_x()==0.&&cov(2,2).get_x()==0.)
343     {
344     ccov=new double[4];
345     vp3[0]=0.;
346     vp3[1]=0.;
347     vp3[2]=1.;
348    
349     for(int i=0;i<2;i++){
350     for(int j=0;j<2;j++)
351     ccov[i*2+j]=cov[i*3+j].get_x();
352     }
353     n=2;
354     fait=2;
355     }
356    
357     if(fait==-1)
358     {
359     ccov=new double[9];
360     for(int i=0;i<3;i++){
361     for(int j=0;j<3;j++)
362     ccov[i*3+j]=cov[i*3+j].get_x();
363     }
364     fait=3;
365     n=3;
366     }
367    
368     double* v=new double[n*n]; //matrice vect_ppre
369     double* d=new double[n]; //val_ppre
370    
371     m_cov.jacobi(ccov,d,v,n,nrot);
372    
373     switch(fait)
374     {
375     case 0: {
376     vp2[0]= 0;vp2[1]= v[0];vp2[2]= v[2];
377     vp3[0]= 0;vp3[1]= v[1];vp3[2]= v[3];
378     break;
379     }
380     case 1: {
381     vp1[0]= v[0];vp1[1]=0 ;vp1[2]= v[2];
382     vp3[0]= v[1];vp3[1]=0 ;vp3[2]= v[3];
383     break;
384     }
385     case 2: {
386     vp1[0]= v[0];vp1[1]=v[2] ;vp1[2]= 0;
387     vp2[0]= v[1];vp2[1]=v[3] ;vp2[2]= 0;
388     break;
389     }
390     default: {
391     vp1[0]= v[0];vp1[1]=v[3] ;vp1[2]=v[6];
392     vp2[0]= v[1];vp2[1]=v[4] ;vp2[2]=v[7];
393     vp3[0]= v[2];vp3[1]=v[5] ;vp3[2]=v[8];
394     break;
395     }
396    
397     }
398    
399     for(int idx=0;idx<3;idx++)
400     {
401     if(fabs(vp1[idx])<0.01) vp1[idx]=0;
402     if(fabs(vp2[idx])<0.01) vp2[idx]=0;
403     if(fabs(vp3[idx])<0.01) vp3[idx]=0;
404     }
405    
406    
407     delete[]d;
408     delete[]v;
409     delete[]ccov;
410     # undef cov
411    
412     }
413    
414    
415    
416     void VCT_FACE:: get_tenseur_inertie_au_cm(double2* tens) //repere globale
417     {
418     // inertie calculé dans le repere globale
419     double2 cov[9] ;
420     get_covariance(cov) ;
421     for(int i=0;i<9;i++) tens[i]=-1*cov[i]*nb_topo_points;
422    
423     tens[0]=(cov[4]+cov[8])*nb_topo_points;
424     tens[4]=(cov[0]+cov[8])*nb_topo_points;
425     tens[8]=(cov[0]+cov[4])*nb_topo_points;
426    
427     }
428    
429    
430     void VCT_FACE:: get_tenseur_inertie_au_pt(double2* xyz, double2* tens)
431     {
432     double2 tens1[9];
433     double2 centre_de_masse[4] ;
434     get_tenseur_inertie_au_cm(tens1);
435    
436     double2 a=xyz[0]-centre_de_masse[0] ;
437     double2 b=xyz[1]-centre_de_masse[1] ;
438     double2 c=xyz[2]-centre_de_masse[2] ;
439    
440     tens[0]=tens1[0]+b*b+c*c;
441     tens[4]=tens1[0]+a*a+c*c;
442     tens[8]=tens1[0]+a*a+b*b;
443    
444     tens[1]=tens1[0]-a*b;
445     tens[2]=tens1[0]-a*c;
446     tens[3]=tens1[1];
447     tens[5]=tens1[0]-b*c;
448     tens[6]=tens1[2];
449     tens[7]=tens1[5];
450    
451     }
452    
453    
454     void VCT_FACE::get_tenseur_inertie_base_locale(double2* tens_loc)
455     {
456     // inertie calculé dans le repere globale
457     OT_VECTEUR_3D v1,v2, v3 ;
458     double2 cov[9] ;
459     double2 tens_glo[9] ;
460     double I_GLOB[9];
461    
462     get_axes_dinertie(v1,v2,v3);
463     get_tenseur_inertie_au_cm(tens_glo);
464     for(int i=0;i<9;i++)
465     {
466     double2 val=tens_glo[i];
467     I_GLOB[i]= val.get_x();
468     }
469     OT_MATRICE_3D P(v1,v2,v3),I(I_GLOB),Pt,ILOC;
470     Pt=P.inverse();
471    
472     ILOC=Pt*I;
473     ILOC=ILOC*P;
474    
475    
476     for(int i=0;i<3;i++) {
477     for(int j=0;j<3;j++) {
478    
479     tens_loc[i*3+j]=ILOC(i,j); }
480    
481     }
482    
483     }
484    
485    
486    
487    
488     void VCT_FACE::get_tenseur_inertie_prprt_face( double2* g1g2,double2* tens2,const VCT_FACE& vct_f)
489     {
490     OT_VECTEUR_3D v1,v2,v3,w1,w2,w3,G1G2;
491    
492     double2 Iw[9];
493     double Iww[9];
494     double2 G1[4];
495     double2 G2[4];
496    
497     this->get_axes_dinertie(v1,v2,v3);
498     vct_f.get_axes_dinertie(w1,w2,w3);
499     OT_MATRICE_3D P(v1,v2,v3),pt,IV;
500     OT_MATRICE_3D Q(w1,w2,w3),qt,R,Rt;
501     pt=P.inverse();
502     qt=Q.inverse();
503     R=pt*Q;
504     Rt=qt*P;
505     vct_f.get_tenseur_inertie_base_locale(Iw);
506    
507     for(int i=0;i<9;i++)
508     {
509     double2 val=Iw[i];
510     Iww[i]= val.get_x();
511     }
512    
513     OT_MATRICE_3D IW(Iww);
514     IV=R*IW;
515     IV=IV*Rt;
516    
517    
518    
519    
520     this->get_topo_barycentre(G1);
521     vct_f.get_topo_barycentre(G2);
522     for(int i=0;i<3;i++)
523     {
524     G1G2[i]=G2[i].get_x()-G1[i].get_x();
525     }
526    
527     OT_VECTEUR_3D G1G2_loc=pt*G1G2;
528    
529     for(int i=0;i<3;i++)
530     {
531     g1g2[i]=G1G2_loc[i];
532     }
533    
534     OT_MATRICE_3D I_CONC;
535    
536     I_CONC(0,0)=nb_topo_points*(G1G2_loc[1]*G1G2_loc[1]+G1G2_loc[2]*G1G2_loc[2]);
537     I_CONC(0,1)=-1*nb_topo_points*(G1G2_loc[0]*G1G2_loc[1]);
538     I_CONC(0,2)=-1*nb_topo_points*(G1G2_loc[0]*G1G2_loc[2]);
539     I_CONC(1,0)=-1*nb_topo_points*(G1G2_loc[0]*G1G2_loc[1]);
540     I_CONC(1,1)=nb_topo_points*(G1G2_loc[0]*G1G2_loc[0]+G1G2_loc[2]*G1G2_loc[2]);
541     I_CONC(1,2)=-1*nb_topo_points*(G1G2_loc[1]*G1G2_loc[2]);
542     I_CONC(2,0)=-1*nb_topo_points*(G1G2_loc[0]*G1G2_loc[2]);
543     I_CONC(2,1)=-1*nb_topo_points*(G1G2_loc[1]*G1G2_loc[2]);
544     I_CONC(2,2)=nb_topo_points*(G1G2_loc[0]*G1G2_loc[0]+G1G2_loc[1]*G1G2_loc[1]);
545    
546     IV=IV+I_CONC;
547    
548     for(int i=0;i<3;i++)
549     for(int j=0;j<3;j++) {
550     tens2[i*3+j]=IV(i,j);
551     }
552    
553    
554    
555    
556     }
557    
558    
559    
560    
561    
562    
563    
564    
565    
566    
567    
568    
569     ostream& operator <<(ostream& os,const VCT_FACE& vct_f)
570     {
571     vct_f.enregistrer(os) ;
572     return os;
573     }
574    
575     //==========================================================================
576     //Visualisation
577     //==========================================================================
578    
579    
580    
581    
582    
583    
584     void VCT_FACE::enregistrer(std::ostream& ost)
585     {
586    
587     double2 cmasse[4];
588    
589     //ost<<"__FACE "<<((MG_FACE*)elem_topo)->get_id()<< endl;
590     vct_surf->enregistrer(ost);
591    
592    
593     int nb_boucle=((MG_FACE*)elem_topo)->get_nb_mg_boucle();
594    
595     for(int j=0;j<nb_boucle;j++)
596     {
597     MG_BOUCLE* Boucle = ((MG_FACE*)elem_topo)->get_mg_boucle(j);
598     int nb_arete = Boucle->get_nb_mg_coarete();
599     for (int w =0; w<nb_arete;w++)
600     {
601     vector<double2> temp_vct;
602     MG_COARETE* coArete = Boucle->get_mg_coarete(w);
603     MG_ARETE* Arete = coArete->get_arete();
604     VCT_ARETE vct_art(Arete);
605     vct_art.enregistrer(ost);
606    
607     }
608     }
609    
610    
611     ost<<setfill('=')<<setw(99)<<'='<<endl;
612    
613     get_topo_barycentre(cmasse) ;
614     ost<<"(*)"<<((MG_FACE*)elem_topo)->get_id()<<"="<<"CENTRE DE MASSE: "<<endl;
615     ost<<setfill('=')<<setw(99)<<'='<<endl;
616     for(unsigned int i=0;i<4;i++)
617     {
618     ost<<setfill(' ')<<setw(15)<<cmasse[i]<<endl;
619     }
620     /*ost<<setfill('=')<<setw(99)<<'='<<endl;
621     double2 inert_cm=get_inertie_au_centre_de_masse();
622     ost<<"(*)"<<((MG_FACE*)elem_topo)->get_id()<<"="<<"INERTIE AU CM: "<<endl;
623     ost<<setfill('=')<<setw(99)<<'='<<endl;
624     ost<< inert_cm<<endl; */
625    
626     double2 cov[9];
627     ost<<setfill('=')<<setw(99)<<'='<<endl;
628     get_covariance(cov) ;
629     ost<<((MG_FACE*)elem_topo)->get_id()<<"="<<"MATRICE DE COV: "<<endl;
630     ost<<setfill('=')<<setw(99)<<'='<<endl;
631     for(unsigned int i=0;i<3;i++)
632     {
633     for(unsigned int j=0;j<3;j++)
634    
635     ost<<setfill(' ')<<setw(15)<<cov[3*i+j] ;
636     ost<<endl;
637     }
638     ost<<setfill('=')<<setw(99)<<'='<<endl;
639     OT_VECTEUR_3D v1,v2,v3;
640     ost<<"AXES D INERTIE: "<<endl;
641     ost<<setfill('=')<<setw(99)<<'='<<endl;
642     get_axes_dinertie(v1,v2,v3) ;
643     for(unsigned int j=0;j<3;j++)
644     ost<<setfill(' ')<<setw(15)<<v1[j]<<setw(15)<<v2[j]<<setw(15)<<v3[j]<<endl;
645    
646     /*
647     ost<<"(*)"<<((MG_FACE*)elem_topo)->get_id()<<"="<<"TENS D INERTIE: "<<endl;
648    
649     ost<<setfill('=')<<setw(99)<<'='<<endl;
650     get_tenseur_inertie_au_cm(tens) ;
651     ost<<setfill('=')<<setw(99)<<'='<<endl;
652     for(unsigned int i=0;i<3;i++) {
653     for(unsigned int j=0;j<3;j++)
654     ost<<setfill(' ')<<setw(15)<<tens[3*i+j] ;
655     ost<<endl; }
656    
657     ost<<setfill('=')<<setw(99)<<'='<<endl;*/
658    
659     ost<<setfill('=')<<setw(99)<<'='<<endl;
660     double2 tens[9];
661     get_tenseur_inertie_base_locale(tens);
662    
663     ost<<((MG_FACE*)elem_topo)->get_id()<<"="<<"TENS D INERTIE LOCALE: "<<endl;
664    
665    
666     ost<<setfill('=')<<setw(99)<<'='<<endl;
667     for(unsigned int i=0;i<3;i++) {
668     for(unsigned int j=0;j<3;j++)
669     ost<<setfill(' ')<<setw(15)<<tens[3*i+j] ;
670     ost<<endl; }
671    
672     ost<<setfill('=')<<setw(99)<<'='<<endl;
673     int nbpts=LISTE_POINTS_CTRS.size();
674     int cmpt=0;
675     for(int i=0;i<nbpts;i++)
676     {
677     ost<<setfill(' ')<<setw(15)<<LISTE_POINTS_CTRS[i] ;
678     cmpt++;
679     if(cmpt==4)
680     {
681     ost<<endl;
682     cmpt=0;
683     }
684    
685     }
686     ost<<setfill('=')<<setw(99)<<'='<<endl;
687     }
688    
689    
690     /***********
691     void VCT_FACE::enregistrer(std::ostream& ost)
692     {
693    
694     double2 cmasse[4];
695    
696     vct_surf->enregistrer(ost);
697    
698     OT_TNS<double2,4> tns1,tns2;
699    
700    
701    
702     int compt=0;
703     //ost<<setfill('=')<<setw(99)<<'='<<endl;
704     int taille= LISTE_TOPO_VECTEUR_FACE.size();
705     for(int i=0;i<taille;i++)
706     {
707     ost<<LISTE_TOPO_VECTEUR_FACE[i]<<setw(18);
708     compt++;
709     if (compt==4) {compt=0; ost<<endl; }
710     }
711     int nb_boucle=((MG_FACE*)elem_topo)->get_nb_mg_boucle();
712    
713     for(int j=0;j<nb_boucle;j++)
714     {
715     MG_BOUCLE* Boucle = ((MG_FACE*)elem_topo)->get_mg_boucle(j);
716     int nb_arete = Boucle->get_nb_mg_coarete();
717     for (int w =0; w<nb_arete;w++)
718     {
719     vector<double2> temp_vct;
720     MG_COARETE* coArete = Boucle->get_mg_coarete(w);
721     MG_ARETE* Arete = coArete->get_arete();
722     VCT_ARETE vct_art(Arete);
723     vct_art.enregistrer(ost);
724    
725     }
726     }
727    
728     ost<<"TENSEUR METRIQUE FACES"<<endl;
729     tns1=get_tenseur_metrique_surface();
730     ost<<tns1<<endl;
731     ost<<"TENSEUR METRIQUE ARETES"<<endl;
732     tns2=get_tenseur_metrique_aretes();
733     ost<<tns2<<endl;
734    
735     /*
736     char* sld_file= "C:\\temp\\cb1.SLDPRT";
737     SLD_FONCTION f_sld;
738     CComPtr <ISldWorks> swApp;
739     CComPtr <IModelDoc2> swModel;
740     CComQIPtr<IPartDoc> swPart;
741     CComQIPtr<ISketchPoint> swSkPoint;
742     CComQIPtr<ISketchSegment> swSksegm;
743    
744     f_sld.Connection();
745     f_sld.OuvrirFichier(sld_file);
746    
747     swApp = f_sld.swApp;
748     swModel=f_sld.swModel;
749     swPart = swModel;
750    
751     CComVariant vBodyArr;
752     swPart->GetBodies2(swSolidBody, VARIANT_TRUE, &vBodyArr);
753    
754     SAFEARRAY* psaBody = V_ARRAY(&vBodyArr);
755     LPDISPATCH* pBodyDispArray = NULL;
756     long nBodyHighIndex = -1;
757     long nBodyCount = -1;
758     SafeArrayAccessData(psaBody, (void **) &pBodyDispArray);
759     SafeArrayGetUBound(psaBody, 1, &nBodyHighIndex);
760     nBodyCount = nBodyHighIndex + 1;
761     /* for (int i = 0; i < nBodyCount; i++)
762     {
763     CComQIPtr <IBody2> pBody;
764     pBody = pBodyDispArray[i];
765     CComPtr <IFace2> face;
766     CComPtr <IFace2> suivantface;
767     CComPtr <ISurface> surf;
768     long nbFaces;
769     pBody->GetFaceCount(&nbFaces);
770     pBody->IGetFirstFace(&face);
771    
772     for(int f=0;f<nbFaces;f++)// boucle sur les faces
773     {
774    
775     CComPtr <ILoop2> loope;
776     CComPtr <ILoop2> nextloope;
777     face->IGetFirstLoop(&loope);
778     long nbloop = -1;
779     face->GetLoopCount(&nbloop);
780     for (int l = 0;l<nbloop;l++)
781     {
782     // maintenant les aretes
783     CComPtr <ICoEdge> Coarete;
784     CComPtr <ICoEdge> nextCoarete;
785     loope->IGetFirstCoEdge(&Coarete);
786     long nbCoarete = -1;
787     loope->GetEdgeCount(&nbCoarete);
788     for (int coa=0;coa<nbCoarete;coa++)
789     {
790     CComPtr <IEdge> arete;
791     Coarete->IGetEdge(&arete);
792     swModel->SetAddToDB(1);
793     swModel->Insert3DSketch2(0);
794     double x1=0;
795     double y1=0.002;
796     double z1=0.01;
797     double x2=0;
798     double y2=0.002;
799     double z2=0.02;
800    
801    
802    
803     //=======================
804     CComPtr <IVertex> Sommet1;
805     CComPtr <IVertex> Sommet2;
806    
807     arete->IGetStartVertex(&Sommet1);
808     arete->IGetEndVertex(&Sommet2);
809    
810    
811    
812     //=======================
813    
814    
815     swModel->ICreatePoint2(x1,y1,z1);
816     swModel->ICreatePoint2(x2,y2,z2);
817     swModel->ICreateLine2(x1,y1,z1,x2,y2,z2);
818    
819     swModel->SetAddToDB(0);
820     swModel->Insert3DSketch2(1);
821     Coarete->IGetNext(&nextCoarete);
822     Coarete = nextCoarete;
823     nextCoarete.Release();
824     } // next CoEdge
825    
826     loope->IGetNext(&nextloope);
827     loope = nextloope;
828    
829    
830     } // next loop
831    
832     face->IGetNextFace(&suivantface);
833     face = suivantface;
834    
835     } // next face
836    
837    
838     } // next body /
839     //Set swSkPoint = swmodel.CreatePoint2(param(j - 2), param(j - 1), param(j))
840     // set swSketchSeg2 = swmodel.CreateLine2(paramm(3 * r * numu + 3 * s), paramm(3 * r * numu + 3 * s + 1), paramm(3 * r * numu + 3 * s + 2), paramm(3 * r * numu + 3 * (s + 1)), paramm(3 * r * numu + 3 * (s + 1) + 1), paramm(3 * r * numu + 3 * (s + 1) + 2))
841     swModel->SetAddToDB(1);
842     swModel->Insert3DSketch2(0);
843     for(int i=0;i<nb_topo_points;i++)
844     {
845     double x1=0.001*LISTE_POINTS_CTRS.get(4*i);
846     double y1=0.001*LISTE_POINTS_CTRS.get(4*i+1);
847     double z1=0.001*LISTE_POINTS_CTRS.get(4*i+2);
848     swModel->ICreatePoint2(x1,y1,z1);
849     }
850    
851     swModel->SetAddToDB(0);
852     swModel->Insert3DSketch2(1);
853    
854    
855    
856    
857    
858     } **************/
859    
860    
861    
862    
863    
864    
865