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