ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/step/src/stcircle.cpp
Revision: 57
Committed: Fri Sep 28 20:53:02 2007 UTC (17 years, 7 months ago) by souaissa
Original Path: magic/lib/step/step/src/stcircle.cpp
File size: 8093 byte(s)
Log Message:
bug dans get_param_nurbs

File Contents

# User Rev Content
1 5 //------------------------------------------------------------
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.;vectmp[1]=1.;vectmp[2]=0.;
160     }
161    
162     dirx=vectmp;
163     }
164     OT_VECTEUR_3D x(dirx[0],dirx[1],dirx[2]);
165     x.norme();
166     OT_VECTEUR_3D y=z&x;
167     repere.change_vecteur1(x);
168     repere.change_vecteur2(y);
169     repere.change_vecteur3(z);
170     }
171    
172     int ST_CIRCLE::get_type_geometrique(TPL_LISTE_ENTITE<double> &param)
173     {
174     param.ajouter(origine.get_x());
175     param.ajouter(origine.get_y());
176     param.ajouter(origine.get_z());
177     param.ajouter(repere.get_vecteur1().get_x());
178     param.ajouter(repere.get_vecteur1().get_y());
179     param.ajouter(repere.get_vecteur1().get_z());
180     param.ajouter(repere.get_vecteur3().get_x());
181     param.ajouter(repere.get_vecteur3().get_y());
182     param.ajouter(repere.get_vecteur3().get_z());
183     param.ajouter(rayon);
184     return MGCo_CIRCLE;
185     }
186    
187    
188    
189 francois 19 void ST_CIRCLE::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> &param)
190 5 {
191     double xyz[3];
192     // The first parameter indicate the code access
193     param.ajouter(1);
194    
195     // The follewing two parameters of the list indicate the orders of the net points
196    
197     param.ajouter(4);
198     param.ajouter(0);
199    
200     // The follewing two parameters indicate the number of rows and colons of the control points
201     // respectively to the two parameters directions
202    
203     param.ajouter(7);
204     param.ajouter(0);
205    
206     // this present the knot vector in the u-direction
207    
208     param.ajouter(0);
209     param.ajouter(0);
210     param.ajouter(0);
211     param.ajouter(0.25);
212     param.ajouter(0.5);
213     param.ajouter(0.5);
214     param.ajouter(0.75);
215     param.ajouter(1);
216     param.ajouter(1);
217     param.ajouter(1);
218    
219     //the first control point
220    
221     OT_VECTEUR_3D loc(rayon,0,0);
222     OT_VECTEUR_3D glob=origine+repere*loc;
223    
224     xyz[0]=glob.get_x();
225     xyz[1]=glob.get_y();
226     xyz[2]=glob.get_z();
227    
228     param.ajouter(xyz[0]);
229     param.ajouter(xyz[1]);
230     param.ajouter(xyz[2]);
231     param.ajouter(1);
232    
233     // the second control point have such local cordinate (rayon,rayon)
234    
235     loc.change_y(rayon);
236     glob=origine+repere*loc;
237    
238     xyz[0]=glob.get_x();
239     xyz[1]=glob.get_y();
240     xyz[2]=glob.get_z();
241    
242     param.ajouter(xyz[0]);
243     param.ajouter(xyz[1]);
244     param.ajouter(xyz[2]);
245     param.ajouter(0.5);
246    
247     //the third control point have such local cordinate (-rayon,rayon)
248    
249     loc.change_x(-rayon);
250     glob=origine+repere*loc;
251    
252    
253     xyz[0]=glob.get_x();
254     xyz[1]=glob.get_y();
255     xyz[2]=glob.get_z();
256    
257     param.ajouter(xyz[0]);
258     param.ajouter(xyz[1]);
259     param.ajouter(xyz[2]);
260     param.ajouter(0.5);
261    
262     //The forth point have the local cordinate at(-rayon,rayon)
263    
264     loc.change_y(0);
265    
266     glob=origine+repere*loc;
267    
268 souaissa 57 xyz[0]=glob.get_x();
269     xyz[1]=glob.get_y();
270     xyz[2]=glob.get_z();
271    
272 5 param.ajouter(xyz[0]);
273     param.ajouter(xyz[1]);
274     param.ajouter(xyz[2]);
275     param.ajouter(1);
276    
277    
278     //the fifth control point have the corfinate in the local cordinate (-rayon,-rayon)
279    
280    
281     loc.change_y(-rayon);
282    
283     glob=origine+repere*loc;
284    
285    
286     xyz[0]=glob.get_x();
287     xyz[1]=glob.get_y();
288     xyz[2]=glob.get_z();
289    
290     param.ajouter(xyz[0]);
291     param.ajouter(xyz[1]);
292     param.ajouter(xyz[2]);
293     param.ajouter(0.5);
294    
295     //The sixth control point have the cordiante in the local coordinate (rayon,-rayon)
296    
297     loc.change_x(rayon);
298    
299     glob=origine+repere*loc;
300    
301    
302     xyz[0]=glob.get_x();
303     xyz[1]=glob.get_y();
304     xyz[2]=glob.get_z();
305    
306     param.ajouter(xyz[0]);
307     param.ajouter(xyz[1]);
308     param.ajouter(xyz[2]);
309     param.ajouter(0.5);
310    
311     //The last control point have the same local cordinate with rhe first control point (rayon, 0)
312    
313     loc.change_y(0);
314    
315     glob=origine+repere*loc;
316    
317 souaissa 57 xyz[0]=glob.get_x();
318     xyz[1]=glob.get_y();
319     xyz[2]=glob.get_z();
320    
321 5 param.ajouter(xyz[0]);
322     param.ajouter(xyz[1]);
323     param.ajouter(xyz[2]);
324     param.ajouter(1);
325    
326 francois 19 indx_premier_ptctr=15;
327    
328 5 }
329    
330    
331    
332     void ST_CIRCLE::est_util(ST_GESTIONNAIRE* gest)
333     {
334     util=true;
335     ST_AXIS2_PLACEMENT_3D *axe=gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d);
336     axe->est_util(gest);
337     }
338