ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/step/src/stconical.cpp
Revision: 19
Committed: Wed Jun 20 17:47:45 2007 UTC (17 years, 10 months ago) by francois
Original Path: magic/lib/step/step/src/stconical.cpp
File size: 12795 byte(s)
Log Message:
ajout d'un index dans les 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     // 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 francois 19 void ST_CONICAL::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> &param)
224 5 {
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 francois 19 param.ajouter(0);
242     param.ajouter(0);
243     param.ajouter(1);
244     param.ajouter(1);
245 5
246 francois 19
247     //This present the knot vector in the v-direction
248    
249 5 param.ajouter(0);
250     param.ajouter(0);
251     param.ajouter(0);
252     param.ajouter(0.25);
253     param.ajouter(0.5);
254     param.ajouter(0.5);
255     param.ajouter(0.75);
256     param.ajouter(1);
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 francois 19
267     //le sens positif de z du repere locale est tjre dans le sens de l,ouverture de la cone
268     //l,orogine du repere est placé sur le circle de base
269 5 //================================================================
270     //the control point at the sommet of the cone
271 francois 19
272 5 double z_sommet_cone= -rayon/tan(angle) ;
273     OT_VECTEUR_3D loc(0,0,z_sommet_cone);
274     OT_VECTEUR_3D glob=origine+repere*loc;
275    
276     double x_som=glob.get_x();
277     double y_som=glob.get_y();
278     double z_som=glob.get_z();
279    
280     //================================================================
281     //the first control point is placed at the cordinate point (rayon,0)
282     //================================================================
283    
284     double Z_inf=(10e6-rayon)/fabs(tan(angle));
285     double r= Z_inf*tan(angle);
286    
287    
288     loc.change_x(r);
289     loc.change_y(0);
290     loc.change_z(Z_inf);
291    
292     glob=origine+repere*loc;
293    
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(1);
303    
304     //================================================================
305     //sommmt de la cone
306     //================================================================
307     param.ajouter(x_som);
308     param.ajouter(y_som);
309     param.ajouter(z_som);
310     param.ajouter(1);
311     //================================================================
312     // the second control point have such local cordinate (rayon,rayon)
313     //================================================================
314     loc.change_y(r);
315     glob=origine+repere*loc;
316    
317     xyz[0]=glob.get_x();
318     xyz[1]=glob.get_y();
319     xyz[2]=glob.get_z();
320    
321     param.ajouter(xyz[0]);
322     param.ajouter(xyz[1]);
323     param.ajouter(xyz[2]);
324     param.ajouter(0.5);
325    
326     //================================================================
327     //sommmt de la cone
328     //================================================================
329     param.ajouter(x_som);
330     param.ajouter(y_som);
331     param.ajouter(z_som);
332     param.ajouter(0.5);
333     //================================================================
334     //the third control point have such local cordinate (-rayon,rayon)
335     //================================================================
336     loc.change_x(-r);
337     glob=origine+repere*loc;
338    
339    
340     xyz[0]=glob.get_x();
341     xyz[1]=glob.get_y();
342     xyz[2]=glob.get_z();
343    
344     param.ajouter(xyz[0]);
345     param.ajouter(xyz[1]);
346     param.ajouter(xyz[2]);
347     param.ajouter(0.5);
348     //================================================================
349     //sommmt de la cone
350     //================================================================
351     param.ajouter(x_som);
352     param.ajouter(y_som);
353     param.ajouter(z_som);
354     param.ajouter(0.5);
355     //================================================================
356     //The forth point have the local cordinate at(-rayon,rayon)
357     //================================================================
358    
359     loc.change_y(0);
360    
361     glob=origine+repere*loc;
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(1);
371     //================================================================
372     //sommmt de la cone
373     //================================================================
374     param.ajouter(x_som);
375     param.ajouter(y_som);
376     param.ajouter(z_som);
377     param.ajouter(1);
378     //================================================================
379     //the fifth control point have the corfinate in the local cordinate (-rayon,-rayon)
380     //================================================================
381     loc.change_y(-r);
382     glob=origine+repere*loc;
383    
384     xyz[0]=glob.get_x();
385     xyz[1]=glob.get_y();
386     xyz[2]=glob.get_z();
387    
388     param.ajouter(xyz[0]);
389     param.ajouter(xyz[1]);
390     param.ajouter(xyz[2]);
391     param.ajouter(0.5);
392     //================================================================
393     //sommmt de la cone
394     //================================================================
395     param.ajouter(x_som);
396     param.ajouter(y_som);
397     param.ajouter(z_som);
398     param.ajouter(1);
399     //================================================================
400     //The sixth control point have the cordiante in the local coordinate (rayon,-rayon)
401     //================================================================
402     loc.change_x(r);
403    
404     glob=origine+repere*loc;
405    
406    
407     xyz[0]=glob.get_x();
408     xyz[1]=glob.get_y();
409     xyz[2]=glob.get_z();
410    
411     param.ajouter(xyz[0]);
412     param.ajouter(xyz[1]);
413     param.ajouter(xyz[2]);
414     param.ajouter(0.5);
415     //================================================================
416     //sommmt de la cone
417     //================================================================
418     param.ajouter(x_som);
419     param.ajouter(y_som);
420     param.ajouter(z_som);
421     param.ajouter(0.5);
422     //================================================================
423     //The last control point have the same local cordinate with rhe first control point (rayon, 0)
424     //================================================================
425     loc.change_y(0);
426    
427     glob=origine+repere*loc;
428    
429    
430     xyz[0]=glob.get_x();
431     xyz[1]=glob.get_y();
432     xyz[2]=glob.get_z();
433    
434     param.ajouter(xyz[0]);
435     param.ajouter(xyz[1]);
436     param.ajouter(xyz[2]);
437     param.ajouter(1);
438     //================================================================
439     //sommmt de la cone
440     //================================================================
441     param.ajouter(x_som);
442     param.ajouter(y_som);
443     param.ajouter(z_som);
444     param.ajouter(1);
445     //================================================================
446    
447 francois 19 indx_premier_ptctr=19;
448 5
449     }
450