ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/step/src/stplane.cpp
Revision: 253
Committed: Tue Jul 13 19:40:46 2010 UTC (14 years, 10 months ago) by francois
File size: 7415 byte(s)
Log Message:
changement de hiearchie et utilisation de ccmake + mise a jour

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     // stplane.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 <stdlib.h>
28     #include <math.h>
29     #include "st_ident.h"
30     #include "stplane.h"
31     #include "st_gestionnaire.h"
32     #include "stdirection.h"
33     #include "st_point.h"
34     #include "constantegeo.h"
35    
36    
37    
38    
39     ST_PLANE::ST_PLANE(long LigneCourante,std::string idori,long axis2_placement_3d):ST_SURFACE(LigneCourante,idori), id_axis2_placement_3d(axis2_placement_3d)
40     {
41     }
42    
43     ST_PLANE::ST_PLANE(double *xyz,double *direction):ST_SURFACE()
44     {
45     initialiser(xyz,direction);
46     }
47    
48     long ST_PLANE::get_id_axis2_placement_3d(void)
49     {
50     return id_axis2_placement_3d;
51     }
52    
53     void ST_PLANE::calcul_parametre(void)
54     {
55     OT_VECTEUR_3D vec_normal(normal);
56     vec_normal.norme();
57     if (!(OPERATEUR::egal(vec_normal.get_x(),0.,0.000001)))
58     {
59     dir1[0]=vec_normal.get_y();
60     dir1[1]=(-vec_normal.get_x());
61     dir1[2]=0.;
62     }
63     else if (!(OPERATEUR::egal(vec_normal.get_y(),0.,0.000001)))
64     {
65     dir1[0]=0.;
66     dir1[1]=(-vec_normal.get_z());
67     dir1[2]=vec_normal.get_y();
68     }
69     else
70     {
71     dir1[0]=vec_normal.get_z();
72     dir1[1]=0.;
73     dir1[2]=0.;
74     }
75     OT_VECTEUR_3D vec_dir1(dir1);
76     vec_dir1.norme();
77     OT_VECTEUR_3D vec_dir2=vec_normal&vec_dir1;
78     dir2[0]=vec_dir2.get_x();
79     dir2[1]=vec_dir2.get_y();
80     dir2[2]=vec_dir2.get_z();
81     }
82    
83     void ST_PLANE::evaluer(double *uv,double *xyz)
84     {
85     xyz[0]=origine.get_x()+uv[0]*dir1[0]+uv[1]*dir2[0];
86     xyz[1]=origine.get_y()+uv[0]*dir1[1]+uv[1]*dir2[1];
87     xyz[2]=origine.get_z()+uv[0]*dir1[2]+uv[1]*dir2[2];
88     }
89     void ST_PLANE::deriver(double *uv,double *xyzdu, double *xyzdv)
90     {
91     xyzdu[0]=dir1[0];
92     xyzdu[1]=dir1[1];
93     xyzdu[2]=dir1[2];
94     xyzdv[0]=dir2[0];
95     xyzdv[1]=dir2[1];
96     xyzdv[2]=dir2[2];
97     }
98     void ST_PLANE::deriver_seconde(double *uv,double* xyzduu,double* xyzduv,double* xyzdvv,double *xyz , double *xyzdu , double *xyzdv )
99     {
100     xyzduu[0]=0.;
101     xyzduu[1]=0.;
102     xyzduu[2]=0.;
103     xyzduv[0]=0.;
104     xyzduv[1]=0.;
105     xyzduv[2]=0.;
106     xyzdvv[0]=0.;
107     xyzdvv[1]=0.;
108     xyzdvv[2]=0.;
109     evaluer(uv,xyz);
110     deriver(uv,xyzdu,xyzdv);
111     }
112     void ST_PLANE::inverser(double *uv,double *xyz,double precision)
113     {
114     double coord[3];
115     int n1,n2;
116     coord[0]=xyz[0]-origine.get_x();
117     coord[1]=xyz[1]-origine.get_y();
118     coord[2]=xyz[2]-origine.get_z();;
119     double det=dir1[0]*dir2[1]-dir1[1]*dir2[0];
120     if (!(OPERATEUR::egal(det,0.0,0.0001)))
121     {
122     n1=0;n2=1;
123     }
124     else
125     {
126     det=dir1[0]*dir2[2]-dir1[2]*dir2[0];
127     if (!(OPERATEUR::egal(det,0.0,0.0001)))
128     {
129     n1=0;n2=2;
130     }
131     else
132     {
133     n1=1;n2=2;
134     det=dir1[1]*dir2[2]-dir1[2]*dir2[1];
135     }
136     }
137     uv[0]=(coord[n1]*dir2[n2]-coord[n2]*dir2[n1])/det;
138     uv[1]=(dir1[n1]*coord[n2]-dir1[n2]*coord[n1])/det;
139    
140     }
141     int ST_PLANE::est_periodique_u(void)
142     {
143     return 0;
144     }
145     int ST_PLANE::est_periodique_v(void)
146     {
147     return 0;
148     }
149     double ST_PLANE::get_periode_u(void)
150     {
151     return 0.;
152     }
153     double ST_PLANE::get_periode_v(void)
154     {
155     return 0.;
156     }
157     double ST_PLANE::get_umin(void)
158     {
159     return -1e300;
160     }
161     double ST_PLANE::get_umax(void)
162     {
163     return 1e300;
164     }
165     double ST_PLANE::get_vmin(void)
166     {
167     return -1e300;
168     }
169     double ST_PLANE::get_vmax(void)
170     {
171     return 1e300;
172     }
173     void ST_PLANE::initialiser(ST_GESTIONNAIRE *gest)
174     {
175     ST_AXIS2_PLACEMENT_3D* axe=gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d);
176     ST_DIRECTION* dirz=gest->lst_direction.getid(axe->get_id_direction1());
177     ST_POINT* point=gest->lst_point.getid(axe->get_id_point());
178     double xyz[3];
179     point->evaluer(xyz);
180     double *direct=dirz->get_direction();
181     initialiser(xyz,direct);
182     }
183    
184     void ST_PLANE::initialiser(double *point, double *dirnorm)
185     {
186     origine.change_x(point[0]);
187     origine.change_y(point[1]);
188     origine.change_z(point[2]);
189     normal[0]=dirnorm[0];
190     normal[1]=dirnorm[1];
191     normal[2]=dirnorm[2];
192     calcul_parametre();
193     }
194    
195    
196    
197     int ST_PLANE::get_type_geometrique(TPL_LISTE_ENTITE<double> &param)
198     {
199     param.ajouter(origine.get_x());
200     param.ajouter(origine.get_y());
201     param.ajouter(origine.get_z());
202     param.ajouter(normal[0]);
203     param.ajouter(normal[1]);
204     param.ajouter(normal[2]);
205     return MGCo_PLAN;
206     }
207    
208    
209     void ST_PLANE::est_util(ST_GESTIONNAIRE* gest)
210     {
211     util=true;
212     gest->lst_axis2_placement_3d.getid(id_axis2_placement_3d)->est_util(gest);
213     }
214    
215    
216 francois 19 void ST_PLANE::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> &param)
217 5 {
218    
219     // For a plan the net controls point is
220     double uv[2];
221     double xyz[3];
222    
223     // The first parameter indicate the code access
224     param.ajouter(2);
225     // The follewing two parameters of the list indicate the orders of the net points
226    
227     param.ajouter(2);
228     param.ajouter(2);
229    
230     // The follewing two parameters indicate the number of rows and colons of the control points
231     // respectively to the two parameters directions
232    
233     param.ajouter(2);
234     param.ajouter(2);
235    
236     // this present the knot vector in the u-direction
237    
238     param.ajouter(0);
239     param.ajouter(0);
240     param.ajouter(1);
241     param.ajouter(1);
242    
243     // this present the knot vector in the v-direction
244    
245     param.ajouter(0);
246     param.ajouter(0);
247     param.ajouter(1);
248     param.ajouter(1);
249    
250     // note that the cordinate of the control points are given in the homogeneous cordinates
251    
252    
253     double inf_val=10e6;
254    
255     // this is the firt control point with cordinate (+inf,+inf)
256    
257     xyz[0]=origine.get_x()+inf_val*dir1[0]+inf_val*dir2[0];
258     xyz[1]=origine.get_y()+inf_val*dir1[1]+inf_val*dir2[1];
259     xyz[2]=origine.get_z()+inf_val*dir1[2]+inf_val*dir2[2];
260    
261     param.ajouter(xyz[0]);
262     param.ajouter(xyz[1]);
263     param.ajouter(xyz[2]);
264 francois 222 param.ajouter(1);
265 5
266    
267     // this is the second control point with cordinate (-inf,+inf)
268    
269     xyz[0]=origine.get_x()-inf_val*dir1[0]+inf_val*dir2[0];
270     xyz[1]=origine.get_y()-inf_val*dir1[1]+inf_val*dir2[1];
271     xyz[2]=origine.get_z()-inf_val*dir1[2]+inf_val*dir2[2];
272    
273     param.ajouter(xyz[0]);
274     param.ajouter(xyz[1]);
275     param.ajouter(xyz[2]);
276 francois 222 param.ajouter(1);
277 5
278     // this is the third control point with cordinate (-inf,-inf)
279    
280 francois 19 xyz[0]=origine.get_x()+inf_val*dir1[0]-inf_val*dir2[0];
281     xyz[1]=origine.get_y()+inf_val*dir1[1]-inf_val*dir2[1];
282     xyz[2]=origine.get_z()+inf_val*dir1[2]-inf_val*dir2[2];
283 5
284     param.ajouter(xyz[0]);
285     param.ajouter(xyz[1]);
286     param.ajouter(xyz[2]);
287 francois 222 param.ajouter(1);
288 5
289     // this is the second control point with cordinate (inf,-inf)
290    
291    
292 francois 19 xyz[0]=origine.get_x()-inf_val*dir1[0]-inf_val*dir2[0];
293     xyz[1]=origine.get_y()-inf_val*dir1[1]-inf_val*dir2[1];
294     xyz[2]=origine.get_z()-inf_val*dir1[2]-inf_val*dir2[2];
295    
296 5 param.ajouter(xyz[0]);
297     param.ajouter(xyz[1]);
298     param.ajouter(xyz[2]);
299 francois 222 param.ajouter(1);
300 5
301    
302 francois 19 indx_premier_ptctr=13;
303 5
304     }