ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/step/src/stcylindrical.cpp
Revision: 283
Committed: Tue Sep 13 21:11:20 2011 UTC (13 years, 8 months ago) by francois
File size: 9844 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     // 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.;
181     axex[1]=1.;
182     axex[2]=0.;
183     }
184    
185     dirx=axex;
186     }
187     OT_VECTEUR_3D x(dirx[0],dirx[1],dirx[2]);
188     x.norme();
189     OT_VECTEUR_3D y=z&x;
190     repere.change_vecteur1(x);
191     repere.change_vecteur2(y);
192     repere.change_vecteur3(z);
193     }
194    
195    
196     int ST_CYLINDRICAL::get_type_geometrique(TPL_LISTE_ENTITE<double> &param)
197     {
198     param.ajouter(origine.get_x());
199     param.ajouter(origine.get_y());
200     param.ajouter(origine.get_z());
201     param.ajouter(repere.get_vecteur1().get_x());
202     param.ajouter(repere.get_vecteur1().get_y());
203     param.ajouter(repere.get_vecteur1().get_z());
204     param.ajouter(repere.get_vecteur3().get_x());
205     param.ajouter(repere.get_vecteur3().get_y());
206     param.ajouter(repere.get_vecteur3().get_z());
207     param.ajouter(rayon);
208     param.ajouter(rayon);
209     return MGCo_CYLINDRE;
210     }
211    
212    
213    
214     void ST_CYLINDRICAL::est_util(ST_GESTIONNAIRE* gest)
215     {
216     util=true;
217     ST_AXIS2_PLACEMENT_3D *axe=gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d);
218     axe->est_util(gest);
219     }
220    
221    
222     void ST_CYLINDRICAL::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> &param)
223     {
224     // For a plan the net controls point is
225     double uv[2];
226     double xyz[3];
227    
228     // The first parameter indicate the code access
229     param.ajouter(2);
230     // The follewing two parameters of the list indicate the orders of the net points
231    
232     param.ajouter(4);
233     param.ajouter(2);
234    
235     // The follewing two parameters indicate the number of rows and colons of the control points
236     // respectively to the two parameters directions
237    
238     param.ajouter(7);
239     param.ajouter(2);
240    
241     // this present the knot vector in the u-direction
242    
243     param.ajouter(0);
244     param.ajouter(0);
245     param.ajouter(0);
246     param.ajouter(0.25);
247     param.ajouter(0.5);
248     param.ajouter(0.5);
249     param.ajouter(0.75);
250     param.ajouter(1);
251     param.ajouter(1);
252     param.ajouter(1);
253    
254     //This present the knot vector in the v-direction
255    
256     param.ajouter(0);
257     param.ajouter(0);
258     param.ajouter(1);
259     param.ajouter(1);
260    
261     //evaluation pour umin cad la premiere cercle
262    
263    
264     // note that the cordinate of the control points are given in the homogeneous cordinates
265    
266    
267    
268    
269     for (int j=0;j<2;j++)
270     {
271    
272     double z_inf=10e6;
273     if (j==0)
274     z_inf=-z_inf;
275    
276     if (j==1)
277     z_inf=z_inf;
278    
279    
280     // The first control point have local cordinate (rayon,0)
281    
282     OT_VECTEUR_3D loc(rayon,0,z_inf);
283     OT_VECTEUR_3D glob=origine+repere*loc;
284    
285     xyz[0]=glob.get_x();
286     xyz[1]=glob.get_y();
287     xyz[2]=glob.get_z();
288    
289     param.ajouter(xyz[0]);
290     param.ajouter(xyz[1]);
291     param.ajouter(xyz[2]);
292     param.ajouter(1);
293    
294     // the second control point have such local cordinate (rayon,rayon)
295    
296     loc.change_y(rayon);
297     glob=origine+repere*loc;
298    
299     xyz[0]=glob.get_x();
300     xyz[1]=glob.get_y();
301     xyz[2]=glob.get_z();
302    
303     param.ajouter(xyz[0]);
304     param.ajouter(xyz[1]);
305     param.ajouter(xyz[2]);
306     param.ajouter(0.5);
307    
308     //the third control point have such local cordinate (-rayon,rayon)
309    
310     loc.change_x(-rayon);
311     glob=origine+repere*loc;
312    
313    
314     xyz[0]=glob.get_x();
315     xyz[1]=glob.get_y();
316     xyz[2]=glob.get_z();
317    
318     param.ajouter(xyz[0]);
319     param.ajouter(xyz[1]);
320     param.ajouter(xyz[2]);
321     param.ajouter(0.5);
322    
323     //The forth point have the local cordinate at(-rayon,rayon)
324    
325     loc.change_y(0);
326    
327     glob=origine+repere*loc;
328    
329     xyz[0]=glob.get_x();
330     xyz[1]=glob.get_y();
331     xyz[2]=glob.get_z();
332    
333     param.ajouter(xyz[0]);
334     param.ajouter(xyz[1]);
335     param.ajouter(xyz[2]);
336     param.ajouter(1);
337    
338    
339     //the fifth control point have the corfinate in the local cordinate (-rayon,-rayon)
340    
341    
342     loc.change_y(-rayon);
343    
344     glob=origine+repere*loc;
345    
346    
347     xyz[0]=glob.get_x();
348     xyz[1]=glob.get_y();
349     xyz[2]=glob.get_z();
350    
351     param.ajouter(xyz[0]);
352     param.ajouter(xyz[1]);
353     param.ajouter(xyz[2]);
354     param.ajouter(0.5);
355    
356     //The sixth control point have the cordiante in the local coordinate (rayon,-rayon)
357    
358     loc.change_x(rayon);
359    
360     glob=origine+repere*loc;
361    
362    
363     xyz[0]=glob.get_x();
364     xyz[1]=glob.get_y();
365     xyz[2]=glob.get_z();
366    
367     param.ajouter(xyz[0]);
368     param.ajouter(xyz[1]);
369     param.ajouter(xyz[2]);
370     param.ajouter(0.5);
371    
372     //The last control point have the same local cordinate with rhe first control point (rayon, 0)
373    
374     loc.change_y(0);
375    
376     glob=origine+repere*loc;
377    
378     xyz[0]=glob.get_x();
379     xyz[1]=glob.get_y();
380     xyz[2]=glob.get_z();
381    
382    
383     param.ajouter(xyz[0]);
384     param.ajouter(xyz[1]);
385     param.ajouter(xyz[2]);
386     param.ajouter(1);
387     }
388    
389     indx_premier_ptctr=19;
390     }
391