MAGiC  V5.0
Mailleurs Automatiques de Géometries intégrés à la Cao
stcircle.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 //####// stcircle.cpp
15 //####//
16 //####//------------------------------------------------------------
17 //####//------------------------------------------------------------
18 //####// COPYRIGHT 2000-2024
19 //####// jeu 13 jun 2024 11:53:59 EDT
20 //####//------------------------------------------------------------
21 //####//------------------------------------------------------------
22 
23 
24 
25 #include "stcircle.h"
26 #include "st_gestionnaire.h"
27 #include "constantegeo.h"
28 
29 #include <math.h>
30 
31 
32 
33 
34 
35 ST_CIRCLE::ST_CIRCLE(long LigneCourante,std::string idori,long axis2,double ray):ST_COURBE(LigneCourante,idori),id_axis2_placement_3d(axis2),rayon(ray)
36 {
37 }
38 
39 ST_CIRCLE::ST_CIRCLE(double *xyz,double *nor,double ray):ST_COURBE(),rayon(ray)
40 {
41  initialiser(xyz,nor);
42 }
43 
44 
46 {
47  return id_axis2_placement_3d;
48 }
49 
51 {
52  return rayon;
53 }
54 
55 void ST_CIRCLE::evaluer(double t,double *xyz)
56 {
57  OT_VECTEUR_3D local(rayon*cos(t),rayon*sin(t),0.);
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_CIRCLE::deriver(double t,double *dxyz)
64 {
65  OT_VECTEUR_3D local(-rayon*sin(t),rayon*cos(t),0.);
66  OT_VECTEUR_3D global=repere*local;
67  dxyz[0]=global.get_x();
68  dxyz[1]=global.get_y();
69  dxyz[2]=global.get_z();
70 }
71 void ST_CIRCLE::deriver_seconde(double t,double *ddxyz,double* dxyz ,double* xyz )
72 {
73  OT_VECTEUR_3D local(-rayon*cos(t),-rayon*sin(t),0.);
74  OT_VECTEUR_3D global=repere*local;
75  ddxyz[0]=global.get_x();
76  ddxyz[1]=global.get_y();
77  ddxyz[2]=global.get_z();
78  if (dxyz!=NULL) deriver(t,dxyz);
79  if (xyz!=NULL) evaluer(t,xyz);
80 }
81 void ST_CIRCLE::inverser(double& t,double *xyz,double precision)
82 {
83  double sign;
84  double valeur;
85  OT_VECTEUR_3D global(xyz[0],xyz[1],xyz[2]);
86  OT_MATRICE_3D transpose_repere;
87  repere.transpose(transpose_repere);
88  OT_VECTEUR_3D vecteur=transpose_repere*(global-origine);
89  valeur=vecteur.get_x()/rayon;
90  if (valeur>1) valeur=1;
91  if (valeur<-1) valeur=-1;
92  t=acos(valeur);
93  sign=vecteur.get_y()/rayon;
94  if (sign<-0.000001) t= 2.*M_PI-t;
95 }
96 
98 {
99  return 0.;
100 }
102 {
103  return 2.*M_PI;
104 }
105 double ST_CIRCLE::get_longueur(double t1,double t2,double precis)
106 {
107  return rayon*(t2-t1);
108 }
110 {
111  return 1;
112 }
113 
115 {
116  return 2.*M_PI;
117 }
118 
119 
121 {
125  ST_POINT* point=gest->lst_point.getid(axe->get_id_point());
126  double xyz[3];
127  point->evaluer(xyz);
128  double *dirzval=dirz->get_direction();
129  double *dirxval=NULL;
130  if (dirx!=NULL) dirxval=dirx->get_direction();
131  initialiser(xyz,dirzval,dirxval);
132 }
133 
134 void ST_CIRCLE::initialiser(double *xyz,double *dirz,double *dirx)
135 {
136  origine.change_x(xyz[0]);
137  origine.change_y(xyz[1]);
138  origine.change_z(xyz[2]);
139  OT_VECTEUR_3D z(dirz[0],dirz[1],dirz[2]);
140  z.norme();
141  double vectmp[3];
142  if (dirx==NULL)
143  {
144  vectmp[0]=1.;
145  if (!(OPERATEUR::egal(z.get_z(),0.,0.0000001)))
146  {
147  vectmp[1]=0;
148  vectmp[2]=-vectmp[0]*z.get_x()/z.get_z();
149  }
150  else if (!(OPERATEUR::egal(z.get_y(),0.,0.0000001)))
151  {
152  vectmp[2]=0;
153  vectmp[1]=-vectmp[0]*z.get_x()/z.get_y();
154  }
155  else
156  {
157  vectmp[0]=0.;
158  vectmp[1]=1.;
159  vectmp[2]=0.;
160  }
161 
162  dirx=vectmp;
163  }
164  OT_VECTEUR_3D x(dirx[0],dirx[1],dirx[2]);
165  x.norme();
166  OT_VECTEUR_3D y=z&x;
170 }
171 
173 {
174  param.ajouter(origine.get_x());
175  param.ajouter(origine.get_y());
176  param.ajouter(origine.get_z());
177  param.ajouter(repere.get_vecteur1().get_x());
178  param.ajouter(repere.get_vecteur1().get_y());
179  param.ajouter(repere.get_vecteur1().get_z());
180  param.ajouter(repere.get_vecteur3().get_x());
181  param.ajouter(repere.get_vecteur3().get_y());
182  param.ajouter(repere.get_vecteur3().get_z());
183  param.ajouter(rayon);
185 }
186 
187 
188 
189 void ST_CIRCLE::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> &param)
190 {
191  double xyz[3];
192  param.ajouter(1);
193 
194 
195  param.ajouter(4);
196  param.ajouter(0);
197 
198 
199  param.ajouter(7);
200  param.ajouter(0);
201 
202 
203  param.ajouter(0);
204  param.ajouter(0);
205  param.ajouter(0);
206  param.ajouter(0.25);
207  param.ajouter(0.5);
208  param.ajouter(0.5);
209  param.ajouter(0.75);
210  param.ajouter(1);
211  param.ajouter(1);
212  param.ajouter(1);
213 
214 
215  OT_VECTEUR_3D loc(rayon,0,0);
216  OT_VECTEUR_3D glob=origine+repere*loc;
217 
218  xyz[0]=glob.get_x();
219  xyz[1]=glob.get_y();
220  xyz[2]=glob.get_z();
221 
222  param.ajouter(xyz[0]);
223  param.ajouter(xyz[1]);
224  param.ajouter(xyz[2]);
225  param.ajouter(1);
226 
227 
228  loc.change_y(rayon);
229  glob=origine+repere*loc;
230 
231  xyz[0]=glob.get_x();
232  xyz[1]=glob.get_y();
233  xyz[2]=glob.get_z();
234 
235  param.ajouter(xyz[0]);
236  param.ajouter(xyz[1]);
237  param.ajouter(xyz[2]);
238  param.ajouter(0.5);
239 
240 
241  loc.change_x(-rayon);
242  glob=origine+repere*loc;
243 
244 
245  xyz[0]=glob.get_x();
246  xyz[1]=glob.get_y();
247  xyz[2]=glob.get_z();
248 
249  param.ajouter(xyz[0]);
250  param.ajouter(xyz[1]);
251  param.ajouter(xyz[2]);
252  param.ajouter(0.5);
253 
254 
255  loc.change_y(0);
256 
257  glob=origine+repere*loc;
258 
259  xyz[0]=glob.get_x();
260  xyz[1]=glob.get_y();
261  xyz[2]=glob.get_z();
262 
263  param.ajouter(xyz[0]);
264  param.ajouter(xyz[1]);
265  param.ajouter(xyz[2]);
266  param.ajouter(1);
267 
268 
269 
270 
271  loc.change_y(-rayon);
272 
273  glob=origine+repere*loc;
274 
275 
276  xyz[0]=glob.get_x();
277  xyz[1]=glob.get_y();
278  xyz[2]=glob.get_z();
279 
280  param.ajouter(xyz[0]);
281  param.ajouter(xyz[1]);
282  param.ajouter(xyz[2]);
283  param.ajouter(0.5);
284 
285 
286  loc.change_x(rayon);
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(0.5);
299 
300 
301  loc.change_y(0);
302 
303  glob=origine+repere*loc;
304 
305  xyz[0]=glob.get_x();
306  xyz[1]=glob.get_y();
307  xyz[2]=glob.get_z();
308 
309  param.ajouter(xyz[0]);
310  param.ajouter(xyz[1]);
311  param.ajouter(xyz[2]);
312  param.ajouter(1);
313 
314  indx_premier_ptctr=15;
315 
316 }
317 
318 
319 
321 {
322  util=true;
324  axe->est_util(gest);
325 }
326 
ST_AXIS2_PLACEMENT_3D::get_id_direction2
virtual long get_id_direction2(void)
Definition: staxis2place3d.cpp:47
ST_GESTIONNAIRE
Definition: st_gestionnaire.h:55
OT_VECTEUR_3D::change_z
virtual void change_z(double z)
Definition: ot_mathematique.cpp:444
ST_CIRCLE::evaluer
virtual void evaluer(double t, double *xyz)
Definition: stcircle.cpp:55
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
ST_CIRCLE::deriver_seconde
virtual void deriver_seconde(double t, double *ddxyz, double *dxyz=NULL, double *xyz=NULL)
Definition: stcircle.cpp:71
st_gestionnaire.h
ST_CIRCLE::id_axis2_placement_3d
long id_axis2_placement_3d
Definition: stcircle.h:64
ST_CIRCLE::get_type_geometrique
virtual int get_type_geometrique(TPL_LISTE_ENTITE< double > &param)
Definition: stcircle.cpp:172
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_AXIS2_PLACEMENT_3D::est_util
virtual void est_util(class ST_GESTIONNAIRE *gest)
Definition: staxis2place3d.cpp:53
ST_CIRCLE::deriver
virtual void deriver(double t, double *xyz)
Definition: stcircle.cpp:63
ST_CIRCLE::est_util
virtual void est_util(class ST_GESTIONNAIRE *gest)
Definition: stcircle.cpp:320
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_DIRECTION
Definition: stdirection.h:32
ST_CIRCLE::get_rayon
virtual double get_rayon(void)
Definition: stcircle.cpp:50
ST_POINT
Definition: st_point.h:30
ST_CIRCLE::get_periode
virtual double get_periode(void)
Definition: stcircle.cpp:114
ST_CIRCLE::ST_CIRCLE
ST_CIRCLE(long LigneCourante, std::string idori, long axis2d, double ray)
Definition: stcircle.cpp:35
ST_CIRCLE::initialiser
virtual void initialiser(class ST_GESTIONNAIRE *gest)
Definition: stcircle.cpp:120
ST_CIRCLE::inverser
virtual void inverser(double &t, double *xyz, double precision=1e-6)
Definition: stcircle.cpp:81
ST_CIRCLE::get_longueur
virtual double get_longueur(double t1, double t2, double precis=1e6)
Definition: stcircle.cpp:105
ST_CIRCLE::repere
OT_MATRICE_3D repere
Definition: stcircle.h:66
OPERATEUR::egal
static int egal(double a, double b, double eps)
Definition: ot_mathematique.cpp:1629
OT_MATRICE_3D
Definition: ot_mathematique.h:160
ST_CIRCLE::est_periodique
virtual int est_periodique(void)
Definition: stcircle.cpp:109
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
ST_CIRCLE::get_tmin
virtual double get_tmin()
Definition: stcircle.cpp:97
OT_VECTEUR_3D::norme
virtual void norme(void)
Definition: ot_mathematique.cpp:494
ST_GESTIONNAIRE::lst_axis2_placement_3d
TPL_MAP_ENTITE< class ST_AXIS2_PLACEMENT_3D * > lst_axis2_placement_3d
Definition: st_gestionnaire.h:81
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
ST_CIRCLE::get_id_axis2_placement_3d
virtual long get_id_axis2_placement_3d(void)
Definition: stcircle.cpp:45
acos
double2 acos(double2 &val)
Definition: ot_doubleprecision.cpp:224
OT_VECTEUR_3D
Definition: ot_mathematique.h:94
ST_CIRCLE::get_tmax
virtual double get_tmax()
Definition: stcircle.cpp:101
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_CIRCLE::origine
OT_VECTEUR_3D origine
Definition: stcircle.h:67
OT_VECTEUR_3D::get_z
virtual double get_z(void) const
Definition: ot_mathematique.cpp:429
ST_CIRCLE::get_param_NURBS
virtual void get_param_NURBS(int &indx_premier_ptctr, TPL_LISTE_ENTITE< double > &param)
Definition: stcircle.cpp:189
TPL_LISTE_ENTITE< double >
stcircle.h
ST_IDENTIFICATEUR::util
bool util
Definition: st_ident.h:46
ST_CIRCLE::rayon
double rayon
Definition: stcircle.h:65
cos
double2 cos(double2 &val)
Definition: ot_doubleprecision.cpp:206
GEOMETRIE::CONST::Co_CIRCLE
@ Co_CIRCLE
Definition: constantegeo.h:32
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
ST_COURBE
Definition: st_courbe.h:33
sin
double2 sin(double2 &val)
Definition: ot_doubleprecision.cpp:250