ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/geometrie/src/vct_sommet.cpp
Revision: 67
Committed: Tue Mar 25 15:59:01 2008 UTC (17 years, 1 month ago) by souaissa
Original Path: magic/lib/geometrie/geometrie/src/vct_sommet.cpp
File size: 5687 byte(s)
Log Message:
mise en conformité des noms de topologies dans la vectorisation

File Contents

# User Rev Content
1 souaissa 66 #include"gestionversion.h"
2     //---------------------------------------------------------------------------
3    
4    
5     #pragma hdrstop
6    
7     #include "vct_sommet.h"
8     #include "mg_sommet.h"
9     #include "mg_point.h"
10     #include "vct_point.h"
11     #include <iomanip>
12    
13     //---------------------------------------------------------------------------
14    
15     #pragma package(smart_init)
16    
17    
18    
19     VCT_SOMMET::VCT_SOMMET(MG_SOMMET* sommet):VCT_ELEMENT_TOPOLOGIQUE(sommet)
20     {
21    
22     MG_POINT* point=sommet->get_point();
23     VCT_POINT vct_point(point);
24 souaissa 67 vector<double2> LISTE_GEO_VECTEUR_SOMMET;
25 souaissa 66 point->get_param_NURBS(indx_premier_ptctr,nurbs_params) ;
26     vct_point.get_vectorisation(LISTE_GEO_VECTEUR_SOMMET);
27     LISTE_TOPO_VECTEUR_SOMMET=LISTE_GEO_VECTEUR_SOMMET;
28    
29 souaissa 67 //nb_geo_points=1;
30 souaissa 66 nb_topo_points=1;
31    
32     }
33    
34 souaissa 67
35 souaissa 66 VCT_SOMMET::VCT_SOMMET(VCT_SOMMET& mdd):VCT_ELEMENT_TOPOLOGIQUE(mdd.elem_topo)
36     {
37 souaissa 67 //LISTE_GEO_VECTEUR_SOMMET=mdd.LISTE_GEO_VECTEUR_SOMMET;
38 souaissa 66 LISTE_TOPO_VECTEUR_SOMMET=mdd.LISTE_TOPO_VECTEUR_SOMMET;
39     indx_premier_ptctr=mdd.indx_premier_ptctr;
40 souaissa 67 //nb_geo_points=mdd.nb_geo_points;
41 souaissa 66 nb_topo_points=mdd.nb_topo_points;
42     }
43    
44    
45     VCT_SOMMET::~ VCT_SOMMET()
46     {
47    
48     }
49    
50 souaissa 67 /*
51 souaissa 66 void VCT_SOMMET:: get_geo_barycentre(double2* xyz)
52     {
53     MG_POINT* point=((MG_SOMMET*)elem_topo)->get_point();
54     VCT_POINT vct_point(point);
55     vct_point.get_geo_barycentre(xyz);
56 souaissa 67 } */
57 souaissa 66
58    
59     void VCT_SOMMET:: get_topo_barycentre(double2* xyz)
60     {
61     MG_POINT* point=((MG_SOMMET*)elem_topo)->get_point();
62     VCT_POINT vct_point(point);
63     vct_point.get_geo_barycentre(xyz); //geo=topo pour un sommet
64     }
65    
66    
67     double2 VCT_SOMMET::get_inertie_au_centre_de_masse()
68     {
69     double2 val=0.;
70     return val;
71     }
72    
73    
74    
75     double2 VCT_SOMMET::get_inertie_au_point(double2* xyz)
76     {
77     double2 centre_de_masse[4];
78     double2 inertie_au_point_xyz;
79    
80     double2 inertie_au_centre_de_masse=get_inertie_au_centre_de_masse();
81    
82     this->get_topo_barycentre(centre_de_masse);
83    
84     double2 d_x=xyz[0]-centre_de_masse[0] ;
85     double2 d_y=xyz[1]-centre_de_masse[1] ;
86     double2 d_z=xyz[2]-centre_de_masse[2] ;
87     double2 d_w=xyz[3]-centre_de_masse[3] ;
88    
89     double2 dis_GXYZ=d_x*d_x+d_y*d_y+d_z*d_z+d_w*d_w;
90    
91     inertie_au_point_xyz=inertie_au_centre_de_masse+1*dis_GXYZ;
92    
93     return inertie_au_point_xyz;
94     }
95    
96    
97     void VCT_SOMMET:: get_topo_vectorisation(vector<double2>& lst)
98     {
99     lst=LISTE_TOPO_VECTEUR_SOMMET;
100     }
101    
102 souaissa 67 /*
103 souaissa 66 void VCT_SOMMET::get_geo_vectorisation(vector<double2>& lst)
104     {
105     lst=LISTE_GEO_VECTEUR_SOMMET;
106 souaissa 67 }*/
107     /*
108 souaissa 66 int VCT_SOMMET::get_nb_geo_points()
109     {
110     return nb_geo_points ;
111 souaissa 67 } */
112 souaissa 66
113     int VCT_SOMMET::get_nb_topo_points()
114     {
115     return nb_topo_points ;
116     }
117    
118    
119     void VCT_SOMMET::get_covariance(double2* cov)
120     {
121    
122     double2 baryc[4];
123     get_topo_barycentre(baryc);
124    
125     double2 *pt_au_centre_masse=new double2[nb_topo_points*4] ;
126    
127     for(int k=0;k<nb_topo_points;k++)
128     {
129     for(int j=0;j<3;j++){
130     double2 xjk= nurbs_params.get(4*k+indx_premier_ptctr+j);
131     pt_au_centre_masse[k*3+j]=xjk- baryc[j];
132     }
133     }
134     for(int i=0;i<9;i++)cov[i]=0.;
135    
136     for(int k=0;k<nb_topo_points;k++)
137 souaissa 67 {
138 souaissa 66
139     cov[0*3+0]= cov[0*3+0]+pt_au_centre_masse[k*3+0]*pt_au_centre_masse[k*3+0];
140     cov[0*3+1]= cov[0*3+1]+pt_au_centre_masse[k*3+0]*pt_au_centre_masse[k*3+1];
141     cov[0*3+2]= cov[0*3+2]+pt_au_centre_masse[k*3+0]*pt_au_centre_masse[k*3+2];
142     cov[1*3+1]= cov[1*3+1]+pt_au_centre_masse[k*3+1]*pt_au_centre_masse[k*3+1];
143     cov[1*3+2]= cov[1*3+2]+pt_au_centre_masse[k*3+1]*pt_au_centre_masse[k*3+2];
144     cov[2*3+2]= cov[2*3+2]+pt_au_centre_masse[k*3+2]*pt_au_centre_masse[k*3+2];
145 souaissa 67
146    
147 souaissa 66 }
148    
149    
150     cov[1*3+0]=cov[0*3+1] ;
151 souaissa 67 cov[2*3+0]=cov[0*3+2] ;
152     cov[2*3+1]=cov[1*3+2] ;
153 souaissa 66
154     for(int i=0;i<9;i++) cov[i]=1./nb_topo_points*cov[i];
155     delete [] pt_au_centre_masse;
156    
157     }
158    
159     void VCT_SOMMET::get_axes_dinertie(OT_VECTEUR_3D& vp1,OT_VECTEUR_3D& vp2,OT_VECTEUR_3D& vp3)
160     {
161    
162     }
163    
164     void VCT_SOMMET::enregistrer(ostream& o)
165     {
166     int compt=0;
167     o<<"%%"<<((MG_SOMMET*)elem_topo)->get_id()<<"="<<"(POINTS_CONTROL_SOMMET,"<< endl;
168     o<<"%%"<<((MG_ARETE*)elem_topo)->get_id()<<"="<<"(POLYGONE_DE_CONTROL_SOMMET,"<< endl;
169     compt=0;
170     for(unsigned int i=0;i<LISTE_TOPO_VECTEUR_SOMMET.size();i++)
171     {
172     o<<" % "<<setw(15)<<LISTE_TOPO_VECTEUR_SOMMET[i];//<< " % , ";
173     compt++;
174     if(compt==4) {
175     o<<endl;
176     compt=0;}
177     }
178     o<<")" <<endl;
179     }
180    
181    
182    
183     void VCT_SOMMET:: get_tenseur_inertie_au_cm(double2* tens)
184     {
185     double2 cov[9] ;
186     get_covariance(cov) ;
187     for(int i=0;i<9;i++) tens[i]=cov[i]*nb_topo_points;
188    
189     tens[0]=cov[4]+cov[8];
190     tens[4]=cov[0]+cov[8];
191     tens[8]=cov[0]+cov[4];
192    
193     for(int i=0;i<3;i++) {
194     for(int j=0;j<3;j++) {
195     if(i!=j)
196     tens[i*3+j]=-1*tens[i*3+j]; } }
197    
198     }
199    
200    
201    
202    
203    
204     void VCT_SOMMET::get_tenseur_inertie_au_pt(double2* xyz, double2* tens)
205     {
206     double2 tens1[9];
207     double2 centre_de_masse[4] ;
208     get_tenseur_inertie_au_cm(tens1);
209    
210     double2 a=xyz[0]-centre_de_masse[0] ;
211     double2 b=xyz[1]-centre_de_masse[1] ;
212     double2 c=xyz[2]-centre_de_masse[2] ;
213    
214     tens[0]=tens1[0]+b*b+c*c;
215     tens[4]=tens1[0]+a*a+c*c;
216     tens[8]=tens1[0]+a*a+b*b;
217    
218     tens[1]=tens1[0]-a*b;
219     tens[2]=tens1[0]-a*c;
220     tens[3]=tens1[1];
221     tens[5]=tens1[0]-b*c;
222     tens[6]=tens1[2];
223     tens[7]=tens1[5];
224    
225     }
226    
227    
228     void VCT_SOMMET:: get_tenseur_inertie_base_locale(double2* tens_loc)
229     {
230     // inertie calculé dans le repere globale
231     double2 cov[9] ;
232     double2 tens_glo[9] ;
233     get_covariance(cov) ;
234     get_tenseur_inertie_au_cm(tens_glo);
235    
236     for(int i=0;i<3;i++) {
237     for(int j=0;j<3;j++) {
238     tens_loc[i*3+j]=0.;
239     for(int k=0;k<3;k++){
240     for(int h=0;h<3;h++) {
241     tens_loc[i*3+j]=tens_loc[i*3+j]+cov[k*3+i]*tens_glo[k*3+h]*cov[h*3+j];
242     }}}
243     }
244    
245     }
246