ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/step/src/stcircle.cpp
Revision: 283
Committed: Tue Sep 13 21:11:20 2011 UTC (13 years, 8 months ago) by francois
File size: 8349 byte(s)
Log Message:
structure de l'écriture

File Contents

# User Rev Content
1 francois 283 //------------------------------------------------------------
2     //------------------------------------------------------------
3     // MAGiC
4     // Jean Christophe Cuilli�re et Vincent FRANCOIS
5     // D�partement de G�nie M�canique - UQTR
6     //------------------------------------------------------------
7     // Le projet MAGIC est un projet de recherche du d�partement
8     // de g�nie m�canique de l'Universit� du Qu�bec �
9     // Trois Rivi�res
10     // Les librairies ne peuvent �tre utilis�es sans l'accord
11     // des auteurs (contact : francois@uqtr.ca)
12     //------------------------------------------------------------
13     //------------------------------------------------------------
14     //
15     // stcircle.cpp
16     //
17     //------------------------------------------------------------
18     //------------------------------------------------------------
19     // COPYRIGHT 2000
20     // Version du 02/03/2006 � 11H24
21     //------------------------------------------------------------
22     //------------------------------------------------------------
23    
24    
25     #include "gestionversion.h"
26    
27     #include "stcircle.h"
28     #include "st_gestionnaire.h"
29     #include "constantegeo.h"
30    
31     #include <math.h>
32    
33    
34    
35    
36    
37     ST_CIRCLE::ST_CIRCLE(long LigneCourante,std::string idori,long axis2,double ray):ST_COURBE(LigneCourante,idori),id_axis2_placement_3d(axis2),rayon(ray)
38     {
39     }
40    
41     ST_CIRCLE::ST_CIRCLE(double *xyz,double *nor,double ray):ST_COURBE(),rayon(ray)
42     {
43     initialiser(xyz,nor);
44     }
45    
46    
47     long ST_CIRCLE::get_id_axis2_placement_3d(void)
48     {
49     return id_axis2_placement_3d;
50     }
51    
52     double ST_CIRCLE::get_rayon(void)
53     {
54     return rayon;
55     }
56    
57     void ST_CIRCLE::evaluer(double t,double *xyz)
58     {
59     OT_VECTEUR_3D local(rayon*cos(t),rayon*sin(t),0.);
60     OT_VECTEUR_3D global=origine+repere*local;
61     xyz[0]=global.get_x();
62     xyz[1]=global.get_y();
63     xyz[2]=global.get_z();
64     }
65     void ST_CIRCLE::deriver(double t,double *dxyz)
66     {
67     OT_VECTEUR_3D local(-rayon*sin(t),rayon*cos(t),0.);
68     OT_VECTEUR_3D global=repere*local;
69     dxyz[0]=global.get_x();
70     dxyz[1]=global.get_y();
71     dxyz[2]=global.get_z();
72     }
73     void ST_CIRCLE::deriver_seconde(double t,double *ddxyz,double* dxyz ,double* xyz )
74     {
75     OT_VECTEUR_3D local(-rayon*cos(t),-rayon*sin(t),0.);
76     OT_VECTEUR_3D global=repere*local;
77     ddxyz[0]=global.get_x();
78     ddxyz[1]=global.get_y();
79     ddxyz[2]=global.get_z();
80     if (dxyz!=NULL) deriver(t,dxyz);
81     if (xyz!=NULL) evaluer(t,xyz);
82     }
83     void ST_CIRCLE::inverser(double& t,double *xyz,double precision)
84     {
85     double sign;
86     double valeur;
87     OT_VECTEUR_3D global(xyz[0],xyz[1],xyz[2]);
88     OT_MATRICE_3D transpose_repere;
89     repere.transpose(transpose_repere);
90     OT_VECTEUR_3D vecteur=transpose_repere*(global-origine);
91     valeur=vecteur.get_x()/rayon;
92     if (valeur>1) valeur=1;
93     if (valeur<-1) valeur=-1;
94     t=acos(valeur);
95     sign=vecteur.get_y()/rayon;
96     if (sign<-0.000001) t= 2.*M_PI-t;
97     }
98    
99     double ST_CIRCLE::get_tmin()
100     {
101     return 0.;
102     }
103     double ST_CIRCLE::get_tmax()
104     {
105     return 2.*M_PI;
106     }
107     double ST_CIRCLE::get_longueur(double t1,double t2,double precis)
108     {
109     return rayon*(t2-t1);
110     }
111     int ST_CIRCLE::est_periodique(void)
112     {
113     return 1;
114     }
115    
116     double ST_CIRCLE::get_periode(void)
117     {
118     return 2.*M_PI;
119     }
120    
121    
122     void ST_CIRCLE::initialiser(ST_GESTIONNAIRE *gest)
123     {
124     ST_AXIS2_PLACEMENT_3D* axe=gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d);
125     ST_DIRECTION* dirz=gest->lst_direction.getid(axe->get_id_direction1());
126     ST_DIRECTION* dirx=gest->lst_direction.getid(axe->get_id_direction2());
127     ST_POINT* point=gest->lst_point.getid(axe->get_id_point());
128     double xyz[3];
129     point->evaluer(xyz);
130     double *dirzval=dirz->get_direction();
131     double *dirxval=NULL;
132     if (dirx!=NULL) dirxval=dirx->get_direction();
133     initialiser(xyz,dirzval,dirxval);
134     }
135    
136     void ST_CIRCLE::initialiser(double *xyz,double *dirz,double *dirx)
137     {
138     origine.change_x(xyz[0]);
139     origine.change_y(xyz[1]);
140     origine.change_z(xyz[2]);
141     OT_VECTEUR_3D z(dirz[0],dirz[1],dirz[2]);
142     z.norme();
143     double vectmp[3];
144     if (dirx==NULL)
145     {
146     vectmp[0]=1.;
147     if (!(OPERATEUR::egal(z.get_z(),0.,0.0000001)))
148     {
149     vectmp[1]=0;
150     vectmp[2]=-vectmp[0]*z.get_x()/z.get_z();
151     }
152     else if (!(OPERATEUR::egal(z.get_y(),0.,0.0000001)))
153     {
154     vectmp[2]=0;
155     vectmp[1]=-vectmp[0]*z.get_x()/z.get_y();
156     }
157     else
158     {
159     vectmp[0]=0.;
160     vectmp[1]=1.;
161     vectmp[2]=0.;
162     }
163    
164     dirx=vectmp;
165     }
166     OT_VECTEUR_3D x(dirx[0],dirx[1],dirx[2]);
167     x.norme();
168     OT_VECTEUR_3D y=z&x;
169     repere.change_vecteur1(x);
170     repere.change_vecteur2(y);
171     repere.change_vecteur3(z);
172     }
173    
174     int ST_CIRCLE::get_type_geometrique(TPL_LISTE_ENTITE<double> &param)
175     {
176     param.ajouter(origine.get_x());
177     param.ajouter(origine.get_y());
178     param.ajouter(origine.get_z());
179     param.ajouter(repere.get_vecteur1().get_x());
180     param.ajouter(repere.get_vecteur1().get_y());
181     param.ajouter(repere.get_vecteur1().get_z());
182     param.ajouter(repere.get_vecteur3().get_x());
183     param.ajouter(repere.get_vecteur3().get_y());
184     param.ajouter(repere.get_vecteur3().get_z());
185     param.ajouter(rayon);
186     return MGCo_CIRCLE;
187     }
188    
189    
190    
191     void ST_CIRCLE::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> &param)
192     {
193     double xyz[3];
194     // The first parameter indicate the code access
195     param.ajouter(1);
196    
197     // The follewing two parameters of the list indicate the orders of the net points
198    
199     param.ajouter(4);
200     param.ajouter(0);
201    
202     // The follewing two parameters indicate the number of rows and colons of the control points
203     // respectively to the two parameters directions
204    
205     param.ajouter(7);
206     param.ajouter(0);
207    
208     // this present the knot vector in the u-direction
209    
210     param.ajouter(0);
211     param.ajouter(0);
212     param.ajouter(0);
213     param.ajouter(0.25);
214     param.ajouter(0.5);
215     param.ajouter(0.5);
216     param.ajouter(0.75);
217     param.ajouter(1);
218     param.ajouter(1);
219     param.ajouter(1);
220    
221     //the first control point
222    
223     OT_VECTEUR_3D loc(rayon,0,0);
224     OT_VECTEUR_3D glob=origine+repere*loc;
225    
226     xyz[0]=glob.get_x();
227     xyz[1]=glob.get_y();
228     xyz[2]=glob.get_z();
229    
230     param.ajouter(xyz[0]);
231     param.ajouter(xyz[1]);
232     param.ajouter(xyz[2]);
233     param.ajouter(1);
234    
235     // the second control point have such local cordinate (rayon,rayon)
236    
237     loc.change_y(rayon);
238     glob=origine+repere*loc;
239    
240     xyz[0]=glob.get_x();
241     xyz[1]=glob.get_y();
242     xyz[2]=glob.get_z();
243    
244     param.ajouter(xyz[0]);
245     param.ajouter(xyz[1]);
246     param.ajouter(xyz[2]);
247     param.ajouter(0.5);
248    
249     //the third control point have such local cordinate (-rayon,rayon)
250    
251     loc.change_x(-rayon);
252     glob=origine+repere*loc;
253    
254    
255     xyz[0]=glob.get_x();
256     xyz[1]=glob.get_y();
257     xyz[2]=glob.get_z();
258    
259     param.ajouter(xyz[0]);
260     param.ajouter(xyz[1]);
261     param.ajouter(xyz[2]);
262     param.ajouter(0.5);
263    
264     //The forth point have the local cordinate at(-rayon,rayon)
265    
266     loc.change_y(0);
267    
268     glob=origine+repere*loc;
269    
270     xyz[0]=glob.get_x();
271     xyz[1]=glob.get_y();
272     xyz[2]=glob.get_z();
273    
274     param.ajouter(xyz[0]);
275     param.ajouter(xyz[1]);
276     param.ajouter(xyz[2]);
277     param.ajouter(1);
278    
279    
280     //the fifth control point have the corfinate in the local cordinate (-rayon,-rayon)
281    
282    
283     loc.change_y(-rayon);
284    
285     glob=origine+repere*loc;
286    
287    
288     xyz[0]=glob.get_x();
289     xyz[1]=glob.get_y();
290     xyz[2]=glob.get_z();
291    
292     param.ajouter(xyz[0]);
293     param.ajouter(xyz[1]);
294     param.ajouter(xyz[2]);
295     param.ajouter(0.5);
296    
297     //The sixth control point have the cordiante in the local coordinate (rayon,-rayon)
298    
299     loc.change_x(rayon);
300    
301     glob=origine+repere*loc;
302    
303    
304     xyz[0]=glob.get_x();
305     xyz[1]=glob.get_y();
306     xyz[2]=glob.get_z();
307    
308     param.ajouter(xyz[0]);
309     param.ajouter(xyz[1]);
310     param.ajouter(xyz[2]);
311     param.ajouter(0.5);
312    
313     //The last control point have the same local cordinate with rhe first control point (rayon, 0)
314    
315     loc.change_y(0);
316    
317     glob=origine+repere*loc;
318    
319     xyz[0]=glob.get_x();
320     xyz[1]=glob.get_y();
321     xyz[2]=glob.get_z();
322    
323     param.ajouter(xyz[0]);
324     param.ajouter(xyz[1]);
325     param.ajouter(xyz[2]);
326     param.ajouter(1);
327    
328     indx_premier_ptctr=15;
329    
330     }
331    
332    
333    
334     void ST_CIRCLE::est_util(ST_GESTIONNAIRE* gest)
335     {
336     util=true;
337     ST_AXIS2_PLACEMENT_3D *axe=gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d);
338     axe->est_util(gest);
339     }
340