ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/step/src/stconical.cpp
Revision: 5
Committed: Tue Jun 12 20:26:34 2007 UTC (17 years, 11 months ago)
Original Path: magic/lib/step/step/src/stconical.cpp
File size: 12599 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     // stconical.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 "stconical.h"
28     #include "st_gestionnaire.h"
29     #include "constantegeo.h"
30     #include <math.h>
31    
32    
33    
34    
35    
36     ST_CONICAL::ST_CONICAL(long LigneCourante,std::string idori,long axis2,double ray,double ang):ST_SURFACE(LigneCourante,idori),id_axis2_placement_3d(axis2),rayon(ray),angle(ang)
37     {
38     }
39    
40     ST_CONICAL::ST_CONICAL(double *xyz,double *dirz,double *dirx,double ray,double ang):ST_SURFACE(),rayon(ray),angle(ang)
41     {
42     initialiser(xyz,dirz,dirx);
43     }
44    
45    
46     long ST_CONICAL::get_id_axis2_placement_3d(void)
47     {
48     return id_axis2_placement_3d;
49     }
50     double ST_CONICAL::get_rayon(void)
51     {
52     return rayon;
53     }
54     double ST_CONICAL::get_angle(void)
55     {
56     return angle;
57     }
58     void ST_CONICAL::evaluer(double *uv,double *xyz)
59     {
60     OT_VECTEUR_3D local((rayon+uv[1]*tan(angle))*cos(uv[0]),(rayon+uv[1]*tan(angle))*sin(uv[0]),uv[1]);
61     OT_VECTEUR_3D global=origine+repere*local;
62     xyz[0]=global.get_x();
63     xyz[1]=global.get_y();
64     xyz[2]=global.get_z();
65     }
66     void ST_CONICAL::deriver(double *uv,double *xyzdu, double *xyzdv)
67     {
68     OT_VECTEUR_3D localu(-(rayon+uv[1]*tan(angle))*sin(uv[0]),(rayon+uv[1]*tan(angle))*cos(uv[0]),0.);
69     OT_VECTEUR_3D localv(tan(angle)*cos(uv[0]),tan(angle)*sin(uv[0]),1.);
70     OT_VECTEUR_3D globalu=repere*localu;
71     OT_VECTEUR_3D globalv=repere*localv;
72     xyzdu[0]=globalu.get_x();
73     xyzdu[1]=globalu.get_y();
74     xyzdu[2]=globalu.get_z();
75     xyzdv[0]=globalv.get_x();
76     xyzdv[1]=globalv.get_y();
77     xyzdv[2]=globalv.get_z();
78     }
79     void ST_CONICAL::deriver_seconde(double *uv,double* xyzduu,double* xyzduv,double* xyzdvv,double *xyz , double *xyzdu , double *xyzdv )
80     {
81     OT_VECTEUR_3D localuu(-(rayon+uv[1]*tan(angle))*cos(uv[0]),-(rayon+uv[1]*tan(angle))*sin(uv[0]),0.);
82     OT_VECTEUR_3D localuv(-tan(angle)*sin(uv[0]),tan(angle)*cos(uv[0]),0.);
83     OT_VECTEUR_3D globaluu=repere*localuu;
84     OT_VECTEUR_3D globaluv=repere*localuv;
85     xyzduu[0]=globaluu.get_x();
86     xyzduu[1]=globaluu.get_y();
87     xyzduu[2]=globaluu.get_z();
88     xyzduv[0]=globaluv.get_x();
89     xyzduv[1]=globaluv.get_y();
90     xyzduv[2]=globaluv.get_z();
91     xyzdvv[0]=0.;
92     xyzdvv[1]=0.;
93     xyzdvv[2]=0.;
94     if ((xyzdu!=NULL) && (xyzdv!=NULL ) ) deriver(uv,xyzdu,xyzdv);
95     if (xyz!=NULL) evaluer(uv,xyz);
96     }
97     void ST_CONICAL::inverser(double *uv,double *xyz,double precision)
98     {
99     double sign;
100     OT_VECTEUR_3D global(xyz[0],xyz[1],xyz[2]);
101     OT_MATRICE_3D transpose_repere;
102     repere.transpose(transpose_repere);
103     OT_VECTEUR_3D vecteur=transpose_repere*(global-origine);
104     uv[1]=vecteur.get_z();
105     double valeur;
106     valeur=vecteur.get_x()/(rayon+uv[1]*tan(angle));
107     if (valeur>1) valeur=1;
108     if (valeur<-1) valeur=-1;
109     uv[0]=acos(valeur);
110     sign=vecteur.get_y()/(rayon+uv[1]*tan(angle));
111     if (sign<-0.000001) uv[0]= 2.*M_PI-uv[0];
112     }
113     int ST_CONICAL::est_periodique_u(void)
114     {
115     return 1;
116     }
117     int ST_CONICAL::est_periodique_v(void)
118     {
119     return 0;
120     }
121     double ST_CONICAL::get_periode_u(void)
122     {
123     return 2.*M_PI;
124     }
125     double ST_CONICAL::get_periode_v(void)
126     {
127     return 0;
128     }
129     double ST_CONICAL::get_umin(void)
130     {
131     return 0.;
132     }
133     double ST_CONICAL::get_umax(void)
134     {
135     return 2.*M_PI;
136     }
137     double ST_CONICAL::get_vmin(void)
138     {
139     return -1e300;
140     }
141     double ST_CONICAL::get_vmax(void)
142     {
143     return 1e300;
144     }
145    
146     void ST_CONICAL::initialiser(ST_GESTIONNAIRE *gest)
147     {
148     ST_AXIS2_PLACEMENT_3D* axe=gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d);
149     ST_DIRECTION* dirz=gest->lst_direction.getid(axe->get_id_direction1());
150     ST_DIRECTION* dirx=gest->lst_direction.getid(axe->get_id_direction2());
151     ST_POINT* point=gest->lst_point.getid(axe->get_id_point());
152     double xyz[3];
153     point->evaluer(xyz);
154     double *dirnorm=dirz->get_direction();
155     double *directx=dirx->get_direction();
156     initialiser(xyz,dirnorm,directx);
157     }
158    
159     void ST_CONICAL::initialiser(double *xyz,double *dirz,double *dirx)
160     {
161     double axex[3];
162     origine.change_x(xyz[0]);
163     origine.change_y(xyz[1]);
164     origine.change_z(xyz[2]);
165     OT_VECTEUR_3D z(dirz[0],dirz[1],dirz[2]);
166     z.norme();
167     if (dirx==NULL)
168     {
169     axex[0]=1.;
170     if (!(OPERATEUR::egal(z.get_z(),0.,0.0000001)))
171     {
172     axex[1]=0;
173     axex[2]=-axex[0]*z.get_x()/z.get_z();
174     }
175     else if (!(OPERATEUR::egal(z.get_y(),0.,0.0000001)))
176     {
177     axex[2]=0;
178     axex[1]=-axex[0]*z.get_x()/z.get_y();
179     }
180     else
181     {
182     axex[0]=0.;axex[1]=1.;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_CONICAL::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     param.ajouter(cos(angle));
210     param.ajouter(sin(angle));
211     return MGCo_CONE;
212     }
213    
214     void ST_CONICAL::est_util(ST_GESTIONNAIRE* gest)
215     {
216     util=true;
217     gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d)->est_util(gest);
218     }
219    
220    
221    
222    
223     void ST_CONICAL::get_param_NURBS(TPL_LISTE_ENTITE<double> &param)
224     {
225     double xyz[3];
226     // The first parameter indicate the code access
227     param.ajouter(2);
228    
229     // The follewing two parameters of the list indicate the orders of the net points
230    
231     param.ajouter(2);
232     param.ajouter(4);
233    
234     // The follewing two parameters indicate the number of rows and colons of the control points
235     // respectively to the two parameters directions
236    
237     param.ajouter(2);
238     param.ajouter(7);
239    
240     // this present the knot vector in the u-direction
241    
242     param.ajouter(0);
243     param.ajouter(0);
244     param.ajouter(0);
245     param.ajouter(0.25);
246     param.ajouter(0.5);
247     param.ajouter(0.5);
248     param.ajouter(0.75);
249     param.ajouter(1);
250     param.ajouter(1);
251     param.ajouter(1);
252    
253     //This present the knot vector in the v-direction
254    
255     param.ajouter(0);
256     param.ajouter(0);
257     param.ajouter(1);
258     param.ajouter(1);
259    
260     //for the circle the controls points are as follow:
261    
262     //the first control point is placed at the cordinate point (rayon,0)
263    
264     //================================================================
265     //sommmt de la cone
266     //================================================================
267     //the control point at the sommet of the cone
268     double z_sommet_cone= -rayon/tan(angle) ;
269     OT_VECTEUR_3D loc(0,0,z_sommet_cone);
270     OT_VECTEUR_3D glob=origine+repere*loc;
271    
272     double x_som=glob.get_x();
273     double y_som=glob.get_y();
274     double z_som=glob.get_z();
275    
276     //================================================================
277     //the first control point is placed at the cordinate point (rayon,0)
278     //================================================================
279    
280     double Z_inf=(10e6-rayon)/fabs(tan(angle));
281     double r= Z_inf*tan(angle);
282    
283    
284     loc.change_x(r);
285     loc.change_y(0);
286     loc.change_z(Z_inf);
287    
288     glob=origine+repere*loc;
289    
290    
291     xyz[0]=glob.get_x();
292     xyz[1]=glob.get_y();
293     xyz[2]=glob.get_z();
294    
295     param.ajouter(xyz[0]);
296     param.ajouter(xyz[1]);
297     param.ajouter(xyz[2]);
298     param.ajouter(1);
299    
300     //================================================================
301     //sommmt de la cone
302     //================================================================
303     param.ajouter(x_som);
304     param.ajouter(y_som);
305     param.ajouter(z_som);
306     param.ajouter(1);
307     //================================================================
308     // the second control point have such local cordinate (rayon,rayon)
309     //================================================================
310     loc.change_y(r);
311     glob=origine+repere*loc;
312    
313     xyz[0]=glob.get_x();
314     xyz[1]=glob.get_y();
315     xyz[2]=glob.get_z();
316    
317     param.ajouter(xyz[0]);
318     param.ajouter(xyz[1]);
319     param.ajouter(xyz[2]);
320     param.ajouter(0.5);
321    
322     //================================================================
323     //sommmt de la cone
324     //================================================================
325     param.ajouter(x_som);
326     param.ajouter(y_som);
327     param.ajouter(z_som);
328     param.ajouter(0.5);
329     //================================================================
330     //the third control point have such local cordinate (-rayon,rayon)
331     //================================================================
332     loc.change_x(-r);
333     glob=origine+repere*loc;
334    
335    
336     xyz[0]=glob.get_x();
337     xyz[1]=glob.get_y();
338     xyz[2]=glob.get_z();
339    
340     param.ajouter(xyz[0]);
341     param.ajouter(xyz[1]);
342     param.ajouter(xyz[2]);
343     param.ajouter(0.5);
344     //================================================================
345     //sommmt de la cone
346     //================================================================
347     param.ajouter(x_som);
348     param.ajouter(y_som);
349     param.ajouter(z_som);
350     param.ajouter(0.5);
351     //================================================================
352     //The forth point have the local cordinate at(-rayon,rayon)
353     //================================================================
354    
355     loc.change_y(0);
356    
357     glob=origine+repere*loc;
358    
359     xyz[0]=glob.get_x();
360     xyz[1]=glob.get_y();
361     xyz[2]=glob.get_z();
362    
363     param.ajouter(xyz[0]);
364     param.ajouter(xyz[1]);
365     param.ajouter(xyz[2]);
366     param.ajouter(1);
367     //================================================================
368     //sommmt de la cone
369     //================================================================
370     param.ajouter(x_som);
371     param.ajouter(y_som);
372     param.ajouter(z_som);
373     param.ajouter(1);
374     //================================================================
375     //the fifth control point have the corfinate in the local cordinate (-rayon,-rayon)
376     //================================================================
377     loc.change_y(-r);
378     glob=origine+repere*loc;
379    
380     xyz[0]=glob.get_x();
381     xyz[1]=glob.get_y();
382     xyz[2]=glob.get_z();
383    
384     param.ajouter(xyz[0]);
385     param.ajouter(xyz[1]);
386     param.ajouter(xyz[2]);
387     param.ajouter(0.5);
388     //================================================================
389     //sommmt de la cone
390     //================================================================
391     param.ajouter(x_som);
392     param.ajouter(y_som);
393     param.ajouter(z_som);
394     param.ajouter(1);
395     //================================================================
396     //The sixth control point have the cordiante in the local coordinate (rayon,-rayon)
397     //================================================================
398     loc.change_x(r);
399    
400     glob=origine+repere*loc;
401    
402    
403     xyz[0]=glob.get_x();
404     xyz[1]=glob.get_y();
405     xyz[2]=glob.get_z();
406    
407     param.ajouter(xyz[0]);
408     param.ajouter(xyz[1]);
409     param.ajouter(xyz[2]);
410     param.ajouter(0.5);
411     //================================================================
412     //sommmt de la cone
413     //================================================================
414     param.ajouter(x_som);
415     param.ajouter(y_som);
416     param.ajouter(z_som);
417     param.ajouter(0.5);
418     //================================================================
419     //The last control point have the same local cordinate with rhe first control point (rayon, 0)
420     //================================================================
421     loc.change_y(0);
422    
423     glob=origine+repere*loc;
424    
425    
426     xyz[0]=glob.get_x();
427     xyz[1]=glob.get_y();
428     xyz[2]=glob.get_z();
429    
430     param.ajouter(xyz[0]);
431     param.ajouter(xyz[1]);
432     param.ajouter(xyz[2]);
433     param.ajouter(1);
434     //================================================================
435     //sommmt de la cone
436     //================================================================
437     param.ajouter(x_som);
438     param.ajouter(y_som);
439     param.ajouter(z_som);
440     param.ajouter(1);
441     //================================================================
442    
443    
444     }
445