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