ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/step/src/stconical.cpp
Revision: 283
Committed: Tue Sep 13 21:11:20 2011 UTC (13 years, 8 months ago) by francois
File size: 13185 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     // 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.;
183     axex[1]=1.;
184     axex[2]=0.;
185     }
186    
187     dirx=axex;
188     }
189     OT_VECTEUR_3D x(dirx[0],dirx[1],dirx[2]);
190     x.norme();
191     OT_VECTEUR_3D y=z&x;
192     repere.change_vecteur1(x);
193     repere.change_vecteur2(y);
194     repere.change_vecteur3(z);
195     }
196    
197    
198     int ST_CONICAL::get_type_geometrique(TPL_LISTE_ENTITE<double> &param)
199     {
200     param.ajouter(origine.get_x());
201     param.ajouter(origine.get_y());
202     param.ajouter(origine.get_z());
203     param.ajouter(repere.get_vecteur1().get_x());
204     param.ajouter(repere.get_vecteur1().get_y());
205     param.ajouter(repere.get_vecteur1().get_z());
206     param.ajouter(repere.get_vecteur3().get_x());
207     param.ajouter(repere.get_vecteur3().get_y());
208     param.ajouter(repere.get_vecteur3().get_z());
209     param.ajouter(rayon);
210     param.ajouter(rayon);
211     param.ajouter(cos(angle));
212     param.ajouter(sin(angle));
213     return MGCo_CONE;
214     }
215    
216     void ST_CONICAL::est_util(ST_GESTIONNAIRE* gest)
217     {
218     util=true;
219     gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d)->est_util(gest);
220     }
221    
222    
223    
224    
225     void ST_CONICAL::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> &param)
226     {
227     double xyz[3];
228     // The first parameter indicate the code access
229     param.ajouter(2);
230    
231     // The follewing two parameters of the list indicate the orders of the net points
232    
233     param.ajouter(2);
234     param.ajouter(4);
235    
236     // The follewing two parameters indicate the number of rows and colons of the control points
237     // respectively to the two parameters directions
238    
239     param.ajouter(2);
240     param.ajouter(7);
241    
242     // this present the knot vector in the u-direction
243     param.ajouter(0);
244     param.ajouter(0);
245     param.ajouter(1);
246     param.ajouter(1);
247    
248    
249     //This present the knot vector in the v-direction
250    
251     param.ajouter(0);
252     param.ajouter(0);
253     param.ajouter(0);
254     param.ajouter(0.25);
255     param.ajouter(0.5);
256     param.ajouter(0.5);
257     param.ajouter(0.75);
258     param.ajouter(1);
259     param.ajouter(1);
260     param.ajouter(1);
261    
262     //for the circle the controls points are as follow:
263    
264     //the first control point is placed at the cordinate point (rayon,0)
265    
266     //================================================================
267     //sommmt de la cone
268    
269     //le sens positif de z du repere locale est tjre dans le sens de l,ouverture de la cone
270     //l,orogine du repere est plac� sur le circle de base
271     //================================================================
272     //the control point at the sommet of the cone
273    
274     double z_sommet_cone= -rayon/tan(angle) ;
275     OT_VECTEUR_3D loc(0,0,z_sommet_cone);
276     OT_VECTEUR_3D glob=origine+repere*loc;
277    
278     double x_som=glob.get_x();
279     double y_som=glob.get_y();
280     double z_som=glob.get_z();
281    
282     //================================================================
283     //the first control point is placed at the cordinate point (rayon,0)
284     //================================================================
285    
286     double Z_inf=(10e6-rayon)/fabs(tan(angle));
287     double r= Z_inf*tan(angle);
288    
289    
290     loc.change_x(r);
291     loc.change_y(0);
292     loc.change_z(Z_inf);
293    
294     glob=origine+repere*loc;
295    
296    
297     xyz[0]=glob.get_x();
298     xyz[1]=glob.get_y();
299     xyz[2]=glob.get_z();
300    
301     param.ajouter(xyz[0]);
302     param.ajouter(xyz[1]);
303     param.ajouter(xyz[2]);
304     param.ajouter(1);
305    
306     //================================================================
307     //sommmt de la cone
308     //================================================================
309     param.ajouter(x_som);
310     param.ajouter(y_som);
311     param.ajouter(z_som);
312     param.ajouter(1);
313     //================================================================
314     // the second control point have such local cordinate (rayon,rayon)
315     //================================================================
316     loc.change_y(r);
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(0.5);
327    
328     //================================================================
329     //sommmt de la cone
330     //================================================================
331     param.ajouter(x_som);
332     param.ajouter(y_som);
333     param.ajouter(z_som);
334     param.ajouter(0.5);
335     //================================================================
336     //the third control point have such local cordinate (-rayon,rayon)
337     //================================================================
338     loc.change_x(-r);
339     glob=origine+repere*loc;
340    
341    
342     xyz[0]=glob.get_x();
343     xyz[1]=glob.get_y();
344     xyz[2]=glob.get_z();
345    
346     param.ajouter(xyz[0]);
347     param.ajouter(xyz[1]);
348     param.ajouter(xyz[2]);
349     param.ajouter(0.5);
350     //================================================================
351     //sommmt de la cone
352     //================================================================
353     param.ajouter(x_som);
354     param.ajouter(y_som);
355     param.ajouter(z_som);
356     param.ajouter(0.5);
357     //================================================================
358     //The forth point have the local cordinate at(-rayon,rayon)
359     //================================================================
360    
361     loc.change_y(0);
362    
363     glob=origine+repere*loc;
364    
365     xyz[0]=glob.get_x();
366     xyz[1]=glob.get_y();
367     xyz[2]=glob.get_z();
368    
369     param.ajouter(xyz[0]);
370     param.ajouter(xyz[1]);
371     param.ajouter(xyz[2]);
372     param.ajouter(1);
373     //================================================================
374     //sommmt de la cone
375     //================================================================
376     param.ajouter(x_som);
377     param.ajouter(y_som);
378     param.ajouter(z_som);
379     param.ajouter(1);
380     //================================================================
381     //the fifth control point have the corfinate in the local cordinate (-rayon,-rayon)
382     //================================================================
383     loc.change_y(-r);
384     glob=origine+repere*loc;
385    
386     xyz[0]=glob.get_x();
387     xyz[1]=glob.get_y();
388     xyz[2]=glob.get_z();
389    
390     param.ajouter(xyz[0]);
391     param.ajouter(xyz[1]);
392     param.ajouter(xyz[2]);
393     param.ajouter(0.5);
394     //================================================================
395     //sommmt de la cone
396     //================================================================
397     param.ajouter(x_som);
398     param.ajouter(y_som);
399     param.ajouter(z_som);
400     param.ajouter(1);
401     //================================================================
402     //The sixth control point have the cordiante in the local coordinate (rayon,-rayon)
403     //================================================================
404     loc.change_x(r);
405    
406     glob=origine+repere*loc;
407    
408    
409     xyz[0]=glob.get_x();
410     xyz[1]=glob.get_y();
411     xyz[2]=glob.get_z();
412    
413     param.ajouter(xyz[0]);
414     param.ajouter(xyz[1]);
415     param.ajouter(xyz[2]);
416     param.ajouter(0.5);
417     //================================================================
418     //sommmt de la cone
419     //================================================================
420     param.ajouter(x_som);
421     param.ajouter(y_som);
422     param.ajouter(z_som);
423     param.ajouter(0.5);
424     //================================================================
425     //The last control point have the same local cordinate with rhe first control point (rayon, 0)
426     //================================================================
427     loc.change_y(0);
428    
429     glob=origine+repere*loc;
430    
431    
432     xyz[0]=glob.get_x();
433     xyz[1]=glob.get_y();
434     xyz[2]=glob.get_z();
435    
436     param.ajouter(xyz[0]);
437     param.ajouter(xyz[1]);
438     param.ajouter(xyz[2]);
439     param.ajouter(1);
440     //================================================================
441     //sommmt de la cone
442     //================================================================
443     param.ajouter(x_som);
444     param.ajouter(y_som);
445     param.ajouter(z_som);
446     param.ajouter(1);
447     //================================================================
448    
449     indx_premier_ptctr=19;
450    
451     }
452