MAGiC  V5.0
Mailleurs Automatiques de Géometries intégrés à la Cao
stconical.cpp
Aller à la documentation de ce fichier.
1 //####//------------------------------------------------------------
2 //####//------------------------------------------------------------
3 //####// MAGiC
4 //####// Jean Christophe Cuilliere et Vincent FRANCOIS
5 //####// Departement de Genie Mecanique - UQTR
6 //####//------------------------------------------------------------
7 //####// MAGIC est un projet de recherche de l equipe ERICCA
8 //####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres
9 //####// http://www.uqtr.ca/ericca
10 //####// http://www.uqtr.ca/
11 //####//------------------------------------------------------------
12 //####//------------------------------------------------------------
13 //####//
14 //####// stconical.cpp
15 //####//
16 //####//------------------------------------------------------------
17 //####//------------------------------------------------------------
18 //####// COPYRIGHT 2000-2024
19 //####// jeu 13 jun 2024 11:53:59 EDT
20 //####//------------------------------------------------------------
21 //####//------------------------------------------------------------
22 
23 
24 
25 #include "stconical.h"
26 #include "st_gestionnaire.h"
27 #include "constantegeo.h"
28 #include <math.h>
29 
30 
31 
32 
33 
34 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)
35 {
36 }
37 
38 ST_CONICAL::ST_CONICAL(double *xyz,double *dirz,double *dirx,double ray,double ang):ST_SURFACE(),rayon(ray),angle(ang)
39 {
40  initialiser(xyz,dirz,dirx);
41 }
42 
43 
45 {
46  return id_axis2_placement_3d;
47 }
49 {
50  return rayon;
51 }
53 {
54  return angle;
55 }
56 void ST_CONICAL::evaluer(double *uv,double *xyz)
57 {
58  OT_VECTEUR_3D local((rayon+uv[1]*tan(angle))*cos(uv[0]),(rayon+uv[1]*tan(angle))*sin(uv[0]),uv[1]);
59  OT_VECTEUR_3D global=origine+repere*local;
60  xyz[0]=global.get_x();
61  xyz[1]=global.get_y();
62  xyz[2]=global.get_z();
63 }
64 void ST_CONICAL::deriver(double *uv,double *xyzdu, double *xyzdv)
65 {
66  OT_VECTEUR_3D localu(-(rayon+uv[1]*tan(angle))*sin(uv[0]),(rayon+uv[1]*tan(angle))*cos(uv[0]),0.);
67  OT_VECTEUR_3D localv(tan(angle)*cos(uv[0]),tan(angle)*sin(uv[0]),1.);
68  OT_VECTEUR_3D globalu=repere*localu;
69  OT_VECTEUR_3D globalv=repere*localv;
70  xyzdu[0]=globalu.get_x();
71  xyzdu[1]=globalu.get_y();
72  xyzdu[2]=globalu.get_z();
73  xyzdv[0]=globalv.get_x();
74  xyzdv[1]=globalv.get_y();
75  xyzdv[2]=globalv.get_z();
76 }
77 void ST_CONICAL::deriver_seconde(double *uv,double* xyzduu,double* xyzduv,double* xyzdvv,double *xyz , double *xyzdu , double *xyzdv )
78 {
79  OT_VECTEUR_3D localuu(-(rayon+uv[1]*tan(angle))*cos(uv[0]),-(rayon+uv[1]*tan(angle))*sin(uv[0]),0.);
80  OT_VECTEUR_3D localuv(-tan(angle)*sin(uv[0]),tan(angle)*cos(uv[0]),0.);
81  OT_VECTEUR_3D globaluu=repere*localuu;
82  OT_VECTEUR_3D globaluv=repere*localuv;
83  xyzduu[0]=globaluu.get_x();
84  xyzduu[1]=globaluu.get_y();
85  xyzduu[2]=globaluu.get_z();
86  xyzduv[0]=globaluv.get_x();
87  xyzduv[1]=globaluv.get_y();
88  xyzduv[2]=globaluv.get_z();
89  xyzdvv[0]=0.;
90  xyzdvv[1]=0.;
91  xyzdvv[2]=0.;
92  if ((xyzdu!=NULL) && (xyzdv!=NULL ) ) deriver(uv,xyzdu,xyzdv);
93  if (xyz!=NULL) evaluer(uv,xyz);
94 }
95 void ST_CONICAL::inverser(double *uv,double *xyz,double precision)
96 {
97  double sign;
98  OT_VECTEUR_3D global(xyz[0],xyz[1],xyz[2]);
99  OT_MATRICE_3D transpose_repere;
100  repere.transpose(transpose_repere);
101  OT_VECTEUR_3D vecteur=transpose_repere*(global-origine);
102  uv[1]=vecteur.get_z();
103  double valeur;
104  valeur=vecteur.get_x()/(rayon+uv[1]*tan(angle));
105  if (valeur>1) valeur=1;
106  if (valeur<-1) valeur=-1;
107  uv[0]=acos(valeur);
108  sign=vecteur.get_y()/(rayon+uv[1]*tan(angle));
109  if (sign<-0.000001) uv[0]= 2.*M_PI-uv[0];
110 }
112 {
113  return 1;
114 }
116 {
117  return 0;
118 }
120 {
121  return 2.*M_PI;
122 }
124 {
125  return 0;
126 }
128 {
129  return 0.;
130 }
132 {
133  return 2.*M_PI;
134 }
136 {
137  return -1e300;
138 }
140 {
141  return 1e300;
142 }
143 
145 {
149  ST_POINT* point=gest->lst_point.getid(axe->get_id_point());
150  double xyz[3];
151  point->evaluer(xyz);
152  double *dirnorm=dirz->get_direction();
153  double *directx=dirx->get_direction();
154  initialiser(xyz,dirnorm,directx);
155 }
156 
157 void ST_CONICAL::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;
193 }
194 
195 
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));
212 }
213 
215 {
216  util=true;
218 }
219 
220 
221 
222 
223 void ST_CONICAL::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> &param)
224 {
225  double xyz[3];
226  param.ajouter(2);
227 
228 
229  param.ajouter(2);
230  param.ajouter(4);
231 
232 
233  param.ajouter(2);
234  param.ajouter(7);
235 
236  param.ajouter(0);
237  param.ajouter(0);
238  param.ajouter(1);
239  param.ajouter(1);
240 
241 
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 
255 
256 
257 
258  double z_sommet_cone= -rayon/tan(angle) ;
259  OT_VECTEUR_3D loc(0,0,z_sommet_cone);
260  OT_VECTEUR_3D glob=origine+repere*loc;
261 
262  double x_som=glob.get_x();
263  double y_som=glob.get_y();
264  double z_som=glob.get_z();
265 
266 
267  double Z_inf=(10e6-rayon)/fabs(tan(angle));
268  double r= Z_inf*tan(angle);
269 
270 
271  loc.change_x(r);
272  loc.change_y(0);
273  loc.change_z(Z_inf);
274 
275  glob=origine+repere*loc;
276 
277 
278  xyz[0]=glob.get_x();
279  xyz[1]=glob.get_y();
280  xyz[2]=glob.get_z();
281 
282  param.ajouter(xyz[0]);
283  param.ajouter(xyz[1]);
284  param.ajouter(xyz[2]);
285  param.ajouter(1);
286 
287  param.ajouter(x_som);
288  param.ajouter(y_som);
289  param.ajouter(z_som);
290  param.ajouter(1);
291  loc.change_y(r);
292  glob=origine+repere*loc;
293 
294  xyz[0]=glob.get_x();
295  xyz[1]=glob.get_y();
296  xyz[2]=glob.get_z();
297 
298  param.ajouter(xyz[0]);
299  param.ajouter(xyz[1]);
300  param.ajouter(xyz[2]);
301  param.ajouter(0.5);
302 
303  param.ajouter(x_som);
304  param.ajouter(y_som);
305  param.ajouter(z_som);
306  param.ajouter(0.5);
307  loc.change_x(-r);
308  glob=origine+repere*loc;
309 
310 
311  xyz[0]=glob.get_x();
312  xyz[1]=glob.get_y();
313  xyz[2]=glob.get_z();
314 
315  param.ajouter(xyz[0]);
316  param.ajouter(xyz[1]);
317  param.ajouter(xyz[2]);
318  param.ajouter(0.5);
319  param.ajouter(x_som);
320  param.ajouter(y_som);
321  param.ajouter(z_som);
322  param.ajouter(0.5);
323 
324  loc.change_y(0);
325 
326  glob=origine+repere*loc;
327 
328  xyz[0]=glob.get_x();
329  xyz[1]=glob.get_y();
330  xyz[2]=glob.get_z();
331 
332  param.ajouter(xyz[0]);
333  param.ajouter(xyz[1]);
334  param.ajouter(xyz[2]);
335  param.ajouter(1);
336  param.ajouter(x_som);
337  param.ajouter(y_som);
338  param.ajouter(z_som);
339  param.ajouter(1);
340  loc.change_y(-r);
341  glob=origine+repere*loc;
342 
343  xyz[0]=glob.get_x();
344  xyz[1]=glob.get_y();
345  xyz[2]=glob.get_z();
346 
347  param.ajouter(xyz[0]);
348  param.ajouter(xyz[1]);
349  param.ajouter(xyz[2]);
350  param.ajouter(0.5);
351  param.ajouter(x_som);
352  param.ajouter(y_som);
353  param.ajouter(z_som);
354  param.ajouter(1);
355  loc.change_x(r);
356 
357  glob=origine+repere*loc;
358 
359 
360  xyz[0]=glob.get_x();
361  xyz[1]=glob.get_y();
362  xyz[2]=glob.get_z();
363 
364  param.ajouter(xyz[0]);
365  param.ajouter(xyz[1]);
366  param.ajouter(xyz[2]);
367  param.ajouter(0.5);
368  param.ajouter(x_som);
369  param.ajouter(y_som);
370  param.ajouter(z_som);
371  param.ajouter(0.5);
372  loc.change_y(0);
373 
374  glob=origine+repere*loc;
375 
376 
377  xyz[0]=glob.get_x();
378  xyz[1]=glob.get_y();
379  xyz[2]=glob.get_z();
380 
381  param.ajouter(xyz[0]);
382  param.ajouter(xyz[1]);
383  param.ajouter(xyz[2]);
384  param.ajouter(1);
385  param.ajouter(x_som);
386  param.ajouter(y_som);
387  param.ajouter(z_som);
388  param.ajouter(1);
389 
390  indx_premier_ptctr=19;
391 
392 }
393 
ST_AXIS2_PLACEMENT_3D::get_id_direction2
virtual long get_id_direction2(void)
Definition: staxis2place3d.cpp:47
ST_CONICAL::inverser
virtual void inverser(double *uv, double *xyz, double precision=1e-6)
Definition: stconical.cpp:95
ST_CONICAL::get_param_NURBS
virtual void get_param_NURBS(int &indx_premier_ptctr, TPL_LISTE_ENTITE< double > &param)
Definition: stconical.cpp:223
ST_GESTIONNAIRE
Definition: st_gestionnaire.h:55
OT_VECTEUR_3D::change_z
virtual void change_z(double z)
Definition: ot_mathematique.cpp:444
ST_AXIS2_PLACEMENT_3D
Definition: staxis2place3d.h:32
OT_MATRICE_3D::change_vecteur3
void change_vecteur3(OT_VECTEUR_3D v)
Definition: ot_mathematique.cpp:810
ST_GESTIONNAIRE::lst_direction
TPL_MAP_ENTITE< class ST_DIRECTION * > lst_direction
Definition: st_gestionnaire.h:90
stconical.h
ST_CONICAL::initialiser
virtual void initialiser(class ST_GESTIONNAIRE *gest)
Definition: stconical.cpp:144
ST_CONICAL::id_axis2_placement_3d
long id_axis2_placement_3d
Definition: stconical.h:66
st_gestionnaire.h
GEOMETRIE::CONST::Co_CONE
@ Co_CONE
Definition: constantegeo.h:32
ST_CONICAL::angle
double angle
Definition: stconical.h:68
ST_POINT::evaluer
virtual void evaluer(double *xyz)
Definition: st_point.cpp:50
OT_VECTEUR_3D::change_y
virtual void change_y(double y)
Definition: ot_mathematique.cpp:439
ST_CONICAL::get_id_axis2_placement_3d
virtual long get_id_axis2_placement_3d(void)
Definition: stconical.cpp:44
ST_AXIS2_PLACEMENT_3D::est_util
virtual void est_util(class ST_GESTIONNAIRE *gest)
Definition: staxis2place3d.cpp:53
OT_MATRICE_3D::get_vecteur1
OT_VECTEUR_3D & get_vecteur1(void)
Definition: ot_mathematique.cpp:814
OT_VECTEUR_3D::get_x
virtual double get_x(void) const
Definition: ot_mathematique.cpp:417
OT_MATRICE_3D::transpose
void transpose(OT_MATRICE_3D &res) const
Definition: ot_mathematique.cpp:750
ST_GESTIONNAIRE::lst_point
TPL_MAP_ENTITE< class ST_POINT * > lst_point
Definition: st_gestionnaire.h:91
ST_CONICAL::get_umax
virtual double get_umax(void)
Definition: stconical.cpp:131
ST_DIRECTION
Definition: stdirection.h:32
ST_POINT
Definition: st_point.h:30
ST_CONICAL::ST_CONICAL
ST_CONICAL(long LigneCourante, std::string idori, long axis2d, double rayon, double angle)
Definition: stconical.cpp:34
ST_CONICAL::est_periodique_u
virtual int est_periodique_u(void)
Definition: stconical.cpp:111
ST_CONICAL::rayon
double rayon
Definition: stconical.h:67
ST_CONICAL::get_umin
virtual double get_umin(void)
Definition: stconical.cpp:127
ST_CONICAL::get_vmin
virtual double get_vmin(void)
Definition: stconical.cpp:135
ST_CONICAL::get_periode_v
virtual double get_periode_v(void)
Definition: stconical.cpp:123
OPERATEUR::egal
static int egal(double a, double b, double eps)
Definition: ot_mathematique.cpp:1629
OT_MATRICE_3D
Definition: ot_mathematique.h:160
constantegeo.h
OT_MATRICE_3D::get_vecteur3
OT_VECTEUR_3D & get_vecteur3(void)
Definition: ot_mathematique.cpp:822
TPL_LISTE_ENTITE::ajouter
virtual void ajouter(X x)
Definition: tpl_liste_entite.h:38
ST_AXIS2_PLACEMENT_3D::get_id_point
virtual long get_id_point(void)
Definition: staxis2place3d.cpp:37
OT_MATRICE_3D::change_vecteur2
void change_vecteur2(OT_VECTEUR_3D v)
Definition: ot_mathematique.cpp:806
OT_VECTEUR_3D::norme
virtual void norme(void)
Definition: ot_mathematique.cpp:494
ST_CONICAL::est_util
virtual void est_util(class ST_GESTIONNAIRE *gest)
Definition: stconical.cpp:214
ST_GESTIONNAIRE::lst_axis2_placement_3d
TPL_MAP_ENTITE< class ST_AXIS2_PLACEMENT_3D * > lst_axis2_placement_3d
Definition: st_gestionnaire.h:81
ST_SURFACE
Definition: st_surface.h:29
ST_AXIS2_PLACEMENT_3D::get_id_direction1
virtual long get_id_direction1(void)
Definition: staxis2place3d.cpp:42
OT_VECTEUR_3D::get_y
virtual double get_y(void) const
Definition: ot_mathematique.cpp:423
acos
double2 acos(double2 &val)
Definition: ot_doubleprecision.cpp:224
OT_VECTEUR_3D
Definition: ot_mathematique.h:94
ST_DIRECTION::get_direction
virtual double * get_direction(void)
Definition: stdirection.cpp:42
TPL_MAP_ENTITE::getid
virtual X getid(unsigned long num)
Definition: tpl_map_entite.h:96
ST_CONICAL::repere
OT_MATRICE_3D repere
Definition: stconical.h:69
ST_CONICAL::get_angle
virtual double get_angle(void)
Definition: stconical.cpp:52
ST_CONICAL::get_vmax
virtual double get_vmax(void)
Definition: stconical.cpp:139
OT_VECTEUR_3D::get_z
virtual double get_z(void) const
Definition: ot_mathematique.cpp:429
ST_CONICAL::deriver_seconde
virtual void deriver_seconde(double *uv, double *xyzduu, double *xyzduv, double *xyzdvv, double *xyz=NULL, double *xyzdu=NULL, double *xyzdv=NULL)
Definition: stconical.cpp:77
TPL_LISTE_ENTITE< double >
ST_CONICAL::get_type_geometrique
virtual int get_type_geometrique(TPL_LISTE_ENTITE< double > &param)
Definition: stconical.cpp:196
ST_CONICAL::est_periodique_v
virtual int est_periodique_v(void)
Definition: stconical.cpp:115
ST_CONICAL::get_rayon
virtual double get_rayon(void)
Definition: stconical.cpp:48
ST_IDENTIFICATEUR::util
bool util
Definition: st_ident.h:46
ST_CONICAL::get_periode_u
virtual double get_periode_u(void)
Definition: stconical.cpp:119
ST_CONICAL::origine
OT_VECTEUR_3D origine
Definition: stconical.h:70
cos
double2 cos(double2 &val)
Definition: ot_doubleprecision.cpp:206
ST_CONICAL::evaluer
virtual void evaluer(double *uv, double *xyz)
Definition: stconical.cpp:56
ST_CONICAL::deriver
virtual void deriver(double *uv, double *xyzdu, double *xyzdv)
Definition: stconical.cpp:64
tan
double2 tan(double2 &val)
Definition: ot_doubleprecision.cpp:311
OT_MATRICE_3D::change_vecteur1
void change_vecteur1(OT_VECTEUR_3D v)
Definition: ot_mathematique.cpp:802
OT_VECTEUR_3D::change_x
virtual void change_x(double x)
Definition: ot_mathematique.cpp:434
sin
double2 sin(double2 &val)
Definition: ot_doubleprecision.cpp:250