ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/step/src/stcylindrical.cpp
Revision: 5
Committed: Tue Jun 12 20:26:34 2007 UTC (17 years, 11 months ago)
Original Path: magic/lib/step/step/src/stcylindrical.cpp
File size: 9133 byte(s)
Log Message:

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     // stcylindrical.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 "stcylindrical.h"
28     #include "st_gestionnaire.h"
29     #include "constantegeo.h"
30    
31     #include <math.h>
32    
33    
34    
35    
36     ST_CYLINDRICAL::ST_CYLINDRICAL(long LigneCourante,std::string idori,long axis2,double ray):ST_SURFACE(LigneCourante,idori),id_axis2_placement_3d(axis2),rayon(ray)
37     {
38     }
39    
40     ST_CYLINDRICAL::ST_CYLINDRICAL(double *xyz,double *dirz,double *dirx,double ray):ST_SURFACE(),rayon(ray)
41     {
42     initialiser(xyz,dirz,dirx);
43     }
44    
45    
46     long ST_CYLINDRICAL::get_id_axis2_placement_3d(void)
47     {
48     return id_axis2_placement_3d;
49     }
50    
51     double ST_CYLINDRICAL::get_rayon(void)
52     {
53     return rayon;
54     }
55     void ST_CYLINDRICAL::evaluer(double *uv,double *xyz)
56     {
57     OT_VECTEUR_3D local(rayon*cos(uv[0]),rayon*sin(uv[0]),uv[1]);
58     OT_VECTEUR_3D global=origine+repere*local;
59     xyz[0]=global.get_x();
60     xyz[1]=global.get_y();
61     xyz[2]=global.get_z();
62     }
63     void ST_CYLINDRICAL::deriver(double *uv,double *xyzdu, double *xyzdv)
64     {
65     OT_VECTEUR_3D localu(-rayon*sin(uv[0]),rayon*cos(uv[0]),0.);
66     OT_VECTEUR_3D localv(0.,0.,1.);
67     OT_VECTEUR_3D globalu=repere*localu;
68     OT_VECTEUR_3D globalv=repere*localv;
69     xyzdu[0]=globalu.get_x();
70     xyzdu[1]=globalu.get_y();
71     xyzdu[2]=globalu.get_z();
72     xyzdv[0]=globalv.get_x();
73     xyzdv[1]=globalv.get_y();
74     xyzdv[2]=globalv.get_z();
75     }
76     void ST_CYLINDRICAL::deriver_seconde(double *uv,double* xyzduu,double* xyzduv,double* xyzdvv,double *xyz , double *xyzdu , double *xyzdv )
77     {
78     OT_VECTEUR_3D local(-rayon*cos(uv[0]),-rayon*sin(uv[0]),0.);
79     OT_VECTEUR_3D global=repere*local;
80     xyzduu[0]=global.get_x();
81     xyzduu[1]=global.get_y();
82     xyzduu[2]=global.get_z();
83     xyzduv[0]=0.;
84     xyzduv[1]=0.;
85     xyzduv[2]=0.;
86     xyzdvv[0]=0.;
87     xyzdvv[1]=0.;
88     xyzdvv[2]=0.;
89    
90     if ((xyzdu!=NULL) && (xyzdv!=NULL ) ) deriver(uv,xyzdu,xyzdv);
91     if (xyz!=NULL) evaluer(uv,xyz);
92     }
93     void ST_CYLINDRICAL::inverser(double *uv,double *xyz,double precision)
94     {
95     double sign;
96     OT_VECTEUR_3D global(xyz[0],xyz[1],xyz[2]);
97     OT_MATRICE_3D transpose_repere;
98     repere.transpose(transpose_repere);
99     OT_VECTEUR_3D vecteur=transpose_repere*(global-origine);
100     double valeur;
101     valeur=vecteur.get_x()/rayon;
102     if (valeur>1) valeur=1;
103     if (valeur<-1) valeur=-1;
104     uv[0]=acos(valeur);
105     sign=vecteur.get_y()/rayon;
106     if (sign<-0.000001) uv[0]= 2.*M_PI-uv[0];
107     uv[1]=vecteur.get_z();
108     }
109     int ST_CYLINDRICAL::est_periodique_u(void)
110     {
111     return 1;
112     }
113     int ST_CYLINDRICAL::est_periodique_v(void)
114     {
115     return 0;
116     }
117     double ST_CYLINDRICAL::get_periode_u(void)
118     {
119     return 2.*M_PI;
120     }
121     double ST_CYLINDRICAL::get_periode_v(void)
122     {
123     return 0;
124     }
125     double ST_CYLINDRICAL::get_umin(void)
126     {
127     return 0.;
128     }
129     double ST_CYLINDRICAL::get_umax(void)
130     {
131     return 2.*M_PI;
132     }
133     double ST_CYLINDRICAL::get_vmin(void)
134     {
135     return -1e300;
136     }
137     double ST_CYLINDRICAL::get_vmax(void)
138     {
139     return 1e300;
140     }
141    
142     void ST_CYLINDRICAL::initialiser(ST_GESTIONNAIRE *gest)
143     {
144     ST_AXIS2_PLACEMENT_3D* axe=gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d);
145     ST_DIRECTION* dirz=gest->lst_direction.getid(axe->get_id_direction1());
146     ST_DIRECTION* dirx=gest->lst_direction.getid(axe->get_id_direction2());
147     ST_POINT* point=gest->lst_point.getid(axe->get_id_point());
148     double xyz[3];
149     point->evaluer(xyz);
150     double *directz=dirz->get_direction();
151     double *directx=dirx->get_direction();
152     initialiser(xyz,directz,directx);
153     }
154    
155    
156    
157     void ST_CYLINDRICAL::initialiser(double *xyz,double *dirz,double *dirx)
158     {
159     double axex[3];
160     origine.change_x(xyz[0]);
161     origine.change_y(xyz[1]);
162     origine.change_z(xyz[2]);
163     OT_VECTEUR_3D z(dirz[0],dirz[1],dirz[2]);
164     z.norme();
165     if (dirx==NULL)
166     {
167     axex[0]=1.;
168     if (!(OPERATEUR::egal(z.get_z(),0.,0.0000001)))
169     {
170     axex[1]=0;
171     axex[2]=-axex[0]*z.get_x()/z.get_z();
172     }
173     else if (!(OPERATEUR::egal(z.get_y(),0.,0.0000001)))
174     {
175     axex[2]=0;
176     axex[1]=-axex[0]*z.get_x()/z.get_y();
177     }
178     else
179     {
180     axex[0]=0.;axex[1]=1.;axex[2]=0.;
181     }
182    
183     dirx=axex;
184     }
185     OT_VECTEUR_3D x(dirx[0],dirx[1],dirx[2]);
186     x.norme();
187     OT_VECTEUR_3D y=z&x;
188     repere.change_vecteur1(x);
189     repere.change_vecteur2(y);
190     repere.change_vecteur3(z);
191     }
192    
193    
194     int ST_CYLINDRICAL::get_type_geometrique(TPL_LISTE_ENTITE<double> &param)
195     {
196     param.ajouter(origine.get_x());
197     param.ajouter(origine.get_y());
198     param.ajouter(origine.get_z());
199     param.ajouter(repere.get_vecteur1().get_x());
200     param.ajouter(repere.get_vecteur1().get_y());
201     param.ajouter(repere.get_vecteur1().get_z());
202     param.ajouter(repere.get_vecteur3().get_x());
203     param.ajouter(repere.get_vecteur3().get_y());
204     param.ajouter(repere.get_vecteur3().get_z());
205     param.ajouter(rayon);
206     param.ajouter(rayon);
207     return MGCo_CYLINDRE;
208     }
209    
210    
211    
212     void ST_CYLINDRICAL::est_util(ST_GESTIONNAIRE* gest)
213     {
214     util=true;
215     ST_AXIS2_PLACEMENT_3D *axe=gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d);
216     axe->est_util(gest);
217     }
218    
219    
220     void ST_CYLINDRICAL::get_param_NURBS(TPL_LISTE_ENTITE<double> &param)
221     {
222     // For a plan the net controls point is
223     double uv[2];
224     double xyz[3];
225    
226     // The first parameter indicate the code access
227     param.ajouter(2);
228     // The follewing two parameters of the list indicate the orders of the net points
229    
230     param.ajouter(4);
231     param.ajouter(2);
232    
233     // The follewing two parameters indicate the number of rows and colons of the control points
234     // respectively to the two parameters directions
235    
236     param.ajouter(7);
237     param.ajouter(2);
238    
239     // this present the knot vector in the u-direction
240    
241     param.ajouter(0);
242     param.ajouter(0);
243     param.ajouter(0);
244     param.ajouter(0.25);
245     param.ajouter(0.5);
246     param.ajouter(0.5);
247     param.ajouter(0.75);
248     param.ajouter(1);
249     param.ajouter(1);
250     param.ajouter(1);
251    
252     //This present the knot vector in the v-direction
253    
254     param.ajouter(0);
255     param.ajouter(0);
256     param.ajouter(1);
257     param.ajouter(1);
258    
259     //evaluation pour umin cad la premiere cercle
260    
261    
262     // note that the cordinate of the control points are given in the homogeneous cordinates
263    
264    
265    
266    
267     for(int j=0;j<2;j++)
268     {
269    
270     double z_inf=10e6;
271     if (j==0)
272     z_inf=-z_inf;
273     if(j==1)
274     z_inf=z_inf;
275    
276     // The first control point have local cordinate (rayon,0)
277    
278     OT_VECTEUR_3D loc(rayon,0,z_inf);
279     OT_VECTEUR_3D glob=origine+repere*loc;
280    
281     xyz[0]=glob.get_x();
282     xyz[1]=glob.get_y();
283     xyz[2]=glob.get_z();
284    
285     param.ajouter(xyz[0]);
286     param.ajouter(xyz[1]);
287     param.ajouter(xyz[2]);
288     param.ajouter(1);
289    
290     // the second control point have such local cordinate (rayon,rayon)
291    
292     loc.change_y(rayon);
293     glob=origine+repere*loc;
294    
295     xyz[0]=glob.get_x();
296     xyz[1]=glob.get_y();
297     xyz[2]=glob.get_z();
298    
299     param.ajouter(xyz[0]);
300     param.ajouter(xyz[1]);
301     param.ajouter(xyz[2]);
302     param.ajouter(0.5);
303    
304     //the third control point have such local cordinate (-rayon,rayon)
305    
306     loc.change_x(-rayon);
307     glob=origine+repere*loc;
308    
309    
310     xyz[0]=glob.get_x();
311     xyz[1]=glob.get_y();
312     xyz[2]=glob.get_z();
313    
314     param.ajouter(xyz[0]);
315     param.ajouter(xyz[1]);
316     param.ajouter(xyz[2]);
317     param.ajouter(0.5);
318    
319     //The forth point have the local cordinate at(-rayon,rayon)
320    
321     loc.change_y(0);
322    
323     glob=origine+repere*loc;
324    
325     param.ajouter(xyz[0]);
326     param.ajouter(xyz[1]);
327     param.ajouter(xyz[2]);
328     param.ajouter(1);
329    
330    
331     //the fifth control point have the corfinate in the local cordinate (-rayon,-rayon)
332    
333    
334     loc.change_y(-rayon);
335    
336     glob=origine+repere*loc;
337    
338    
339     xyz[0]=glob.get_x();
340     xyz[1]=glob.get_y();
341     xyz[2]=glob.get_z();
342    
343     param.ajouter(xyz[0]);
344     param.ajouter(xyz[1]);
345     param.ajouter(xyz[2]);
346     param.ajouter(0.5);
347    
348     //The sixth control point have the cordiante in the local coordinate (rayon,-rayon)
349    
350     loc.change_x(rayon);
351    
352     glob=origine+repere*loc;
353    
354    
355     xyz[0]=glob.get_x();
356     xyz[1]=glob.get_y();
357     xyz[2]=glob.get_z();
358    
359     param.ajouter(xyz[0]);
360     param.ajouter(xyz[1]);
361     param.ajouter(xyz[2]);
362     param.ajouter(0.5);
363    
364     //The last control point have the same local cordinate with rhe first control point (rayon, 0)
365    
366     loc.change_y(0);
367    
368     glob=origine+repere*loc;
369    
370     xyz[0]=glob.get_x();
371     xyz[1]=glob.get_y();
372     xyz[2]=glob.get_z();
373    
374    
375     param.ajouter(xyz[0]);
376     param.ajouter(xyz[1]);
377     param.ajouter(xyz[2]);
378     param.ajouter(1);
379     }
380     }
381