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 |
|
|
// sat_plane.cpp
|
16 |
|
|
//
|
17 |
|
|
//------------------------------------------------------------
|
18 |
|
|
//------------------------------------------------------------
|
19 |
|
|
// COPYRIGHT 2000
|
20 |
|
|
// Version du 02/03/2006 à 11H24
|
21 |
|
|
//------------------------------------------------------------
|
22 |
|
|
//------------------------------------------------------------
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "gestionversion.h"
|
26 |
|
|
#include "sat_plane.h"
|
27 |
|
|
#include "constantegeo.h"
|
28 |
|
|
#include "ot_mathematique.h"
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
SAT_PLANE::SAT_PLANE(unsigned long num):SAT_SURFACE(num)
|
32 |
|
|
{
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
SAT_PLANE::SAT_PLANE():SAT_SURFACE()
|
36 |
|
|
{
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
SAT_PLANE::~SAT_PLANE()
|
40 |
|
|
{
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
void SAT_PLANE::calcule_parametre(void)
|
46 |
|
|
{
|
47 |
|
|
OT_VECTEUR_3D vec_normal(normal);
|
48 |
|
|
vec_normal.norme();
|
49 |
|
|
if (!(OPERATEUR::egal(vec_normal.get_x(),0.,0.0001)))
|
50 |
|
|
{
|
51 |
|
|
dir1[0]=vec_normal.get_y();
|
52 |
|
|
dir1[1]=(-vec_normal.get_x());
|
53 |
|
|
dir1[2]=0.;
|
54 |
|
|
}
|
55 |
|
|
else if (!(OPERATEUR::egal(vec_normal.get_y(),0.,0.0001)))
|
56 |
|
|
{
|
57 |
|
|
dir1[0]=0.;
|
58 |
|
|
dir1[1]=(-vec_normal.get_z());
|
59 |
|
|
dir1[2]=vec_normal.get_y();
|
60 |
|
|
}
|
61 |
|
|
else
|
62 |
|
|
{
|
63 |
|
|
dir1[0]=vec_normal.get_z();
|
64 |
|
|
dir1[1]=0.;
|
65 |
|
|
dir1[2]=0.;
|
66 |
|
|
}
|
67 |
|
|
OT_VECTEUR_3D vec_dir1(dir1);
|
68 |
|
|
vec_dir1.norme();
|
69 |
|
|
OT_VECTEUR_3D vec_dir2=vec_normal&vec_dir1;
|
70 |
|
|
dir2[0]=vec_dir2.get_x();
|
71 |
|
|
dir2[1]=vec_dir2.get_y();
|
72 |
|
|
dir2[2]=vec_dir2.get_z();
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
void SAT_PLANE::evaluer(double *uv,double *xyz)
|
77 |
|
|
{
|
78 |
|
|
xyz[0]=root[0]+uv[0]*dir1[0]+uv[1]*dir2[0];
|
79 |
|
|
xyz[1]=root[1]+uv[0]*dir1[1]+uv[1]*dir2[1];
|
80 |
|
|
xyz[2]=root[2]+uv[0]*dir1[2]+uv[1]*dir2[2];
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
void SAT_PLANE::deriver(double *uv,double *xyzdu, double *xyzdv)
|
84 |
|
|
{
|
85 |
|
|
xyzdu[0]=dir1[0];
|
86 |
|
|
xyzdu[1]=dir1[1];
|
87 |
|
|
xyzdu[2]=dir1[2];
|
88 |
|
|
xyzdv[0]=dir2[0];
|
89 |
|
|
xyzdv[1]=dir2[1];
|
90 |
|
|
xyzdv[2]=dir2[2];
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
void SAT_PLANE::deriver_seconde(double *uv,double* xyzduu,double* xyzduv,double* xyzdvv,double *xyz, double *xyzdu , double *xyzdv )
|
94 |
|
|
{
|
95 |
|
|
xyzduu[0]=0.;
|
96 |
|
|
xyzduu[1]=0.;
|
97 |
|
|
xyzduu[2]=0.;
|
98 |
|
|
xyzduv[0]=0.;
|
99 |
|
|
xyzduv[1]=0.;
|
100 |
|
|
xyzduv[2]=0.;
|
101 |
|
|
xyzdvv[0]=0.;
|
102 |
|
|
xyzdvv[1]=0.;
|
103 |
|
|
xyzdvv[2]=0.;
|
104 |
|
|
evaluer(uv,xyz);
|
105 |
|
|
deriver(uv,xyzdu,xyzdv);
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
void SAT_PLANE::inverser(double *uv,double *xyz,double precision)
|
109 |
|
|
{
|
110 |
|
|
double coord[3];
|
111 |
|
|
int n1,n2;
|
112 |
|
|
coord[0]=xyz[0]-root[0];
|
113 |
|
|
coord[1]=xyz[1]-root[1];
|
114 |
|
|
coord[2]=xyz[2]-root[2];;
|
115 |
|
|
double det=dir1[0]*dir2[1]-dir1[1]*dir2[0];
|
116 |
|
|
if (!(OPERATEUR::egal(det,0.0,0.0001)))
|
117 |
|
|
{
|
118 |
|
|
n1=0;n2=1;
|
119 |
|
|
}
|
120 |
|
|
else
|
121 |
|
|
{
|
122 |
|
|
det=dir1[0]*dir2[2]-dir1[2]*dir2[0];
|
123 |
|
|
if (!(OPERATEUR::egal(det,0.0,0.0001)))
|
124 |
|
|
{
|
125 |
|
|
n1=0;n2=2;
|
126 |
|
|
}
|
127 |
|
|
else
|
128 |
|
|
{
|
129 |
|
|
n1=1;n2=2;
|
130 |
|
|
det=dir1[1]*dir2[2]-dir1[2]*dir2[1];
|
131 |
|
|
}
|
132 |
|
|
}
|
133 |
|
|
uv[0]=(coord[n1]*dir2[n2]-coord[n2]*dir2[n1])/det;
|
134 |
|
|
uv[1]=(dir1[n1]*coord[n2]-dir1[n2]*coord[n1])/det;
|
135 |
|
|
|
136 |
|
|
}
|
137 |
|
|
|
138 |
|
|
int SAT_PLANE::est_periodique_u(void)
|
139 |
|
|
{
|
140 |
|
|
return 0;
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
int SAT_PLANE::est_periodique_v(void)
|
144 |
|
|
{
|
145 |
|
|
return 0;
|
146 |
|
|
}
|
147 |
|
|
|
148 |
|
|
double SAT_PLANE::get_periode_u(void)
|
149 |
|
|
{
|
150 |
|
|
return 0.;
|
151 |
|
|
}
|
152 |
|
|
|
153 |
|
|
double SAT_PLANE::get_periode_v(void)
|
154 |
|
|
{
|
155 |
|
|
return 0.;
|
156 |
|
|
}
|
157 |
|
|
|
158 |
|
|
double SAT_PLANE::get_umin(void)
|
159 |
|
|
{
|
160 |
|
|
return -1e300;
|
161 |
|
|
}
|
162 |
|
|
|
163 |
|
|
double SAT_PLANE::get_umax(void)
|
164 |
|
|
{
|
165 |
|
|
return 1e300;
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
double SAT_PLANE::get_vmin(void)
|
169 |
|
|
{
|
170 |
|
|
return -1e300;
|
171 |
|
|
}
|
172 |
|
|
|
173 |
|
|
double SAT_PLANE::get_vmax(void)
|
174 |
|
|
{
|
175 |
|
|
return 1e300;
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
int SAT_PLANE::get_type_geometrique(TPL_LISTE_ENTITE<double> ¶m)
|
180 |
|
|
{
|
181 |
|
|
param.ajouter(root[0]);
|
182 |
|
|
param.ajouter(root[1]);
|
183 |
|
|
param.ajouter(root[2]);
|
184 |
|
|
param.ajouter(normal[0]);
|
185 |
|
|
param.ajouter(normal[1]);
|
186 |
|
|
param.ajouter(normal[2]);
|
187 |
|
|
return MGCo_PLAN;
|
188 |
|
|
}
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
francois |
19 |
void SAT_PLANE::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> ¶m)
|
193 |
|
5 |
{
|
194 |
|
|
|
195 |
|
|
// For a plan the net controls point is
|
196 |
|
|
double uv[2];
|
197 |
|
|
double xyz[3];
|
198 |
|
|
|
199 |
|
|
// The first parameter indicate the code access
|
200 |
|
|
param.ajouter(2);
|
201 |
|
|
// The follewing two parameters of the list indicate the orders of the net points
|
202 |
|
|
|
203 |
|
|
param.ajouter(2);
|
204 |
|
|
param.ajouter(2);
|
205 |
|
|
|
206 |
|
|
// The follewing two parameters indicate the number of rows and colons of the control points
|
207 |
|
|
// respectively to the two parameters directions
|
208 |
|
|
|
209 |
|
|
param.ajouter(2);
|
210 |
|
|
param.ajouter(2);
|
211 |
|
|
|
212 |
|
|
// this present the knot vector in the u-direction
|
213 |
|
|
|
214 |
|
|
param.ajouter(0);
|
215 |
|
|
param.ajouter(0);
|
216 |
|
|
param.ajouter(1);
|
217 |
|
|
param.ajouter(1);
|
218 |
|
|
|
219 |
|
|
// this present the knot vector in the v-direction
|
220 |
|
|
|
221 |
|
|
param.ajouter(0);
|
222 |
|
|
param.ajouter(0);
|
223 |
|
|
param.ajouter(1);
|
224 |
|
|
param.ajouter(1);
|
225 |
|
|
|
226 |
|
|
// note that the cordinate of the control points are given in the homogeneous cordinates
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
double inf_val=10e6;
|
230 |
|
|
|
231 |
|
|
// this is the firt control point with cordinate (+inf,+inf)
|
232 |
|
|
|
233 |
|
|
xyz[0]=root[0]+inf_val*dir1[0]+inf_val*dir2[0];
|
234 |
|
|
xyz[1]=root[1]+inf_val*dir1[1]+inf_val*dir2[1];
|
235 |
|
|
xyz[2]=root[2]+inf_val*dir1[2]+inf_val*dir2[2];
|
236 |
|
|
|
237 |
|
|
param.ajouter(xyz[0]);
|
238 |
|
|
param.ajouter(xyz[1]);
|
239 |
|
|
param.ajouter(xyz[2]);
|
240 |
|
|
param.ajouter(0);
|
241 |
|
|
|
242 |
|
|
|
243 |
|
|
// this is the second control point with cordinate (-inf,+inf)
|
244 |
|
|
|
245 |
|
|
xyz[0]=root[0]-inf_val*dir1[0]+inf_val*dir2[0];
|
246 |
|
|
xyz[1]=root[1]-inf_val*dir1[1]+inf_val*dir2[1];
|
247 |
|
|
xyz[2]=root[2]-inf_val*dir1[2]+inf_val*dir2[2];
|
248 |
|
|
|
249 |
|
|
param.ajouter(xyz[0]);
|
250 |
|
|
param.ajouter(xyz[1]);
|
251 |
|
|
param.ajouter(xyz[2]);
|
252 |
|
|
param.ajouter(0);
|
253 |
|
|
|
254 |
|
|
|
255 |
|
|
// this is the third control point with cordinate (-inf,-inf)
|
256 |
|
|
|
257 |
francois |
19 |
xyz[0]=root[0]+inf_val*dir1[0]-inf_val*dir2[0];
|
258 |
|
|
xyz[1]=root[1]+inf_val*dir1[1]-inf_val*dir2[1];
|
259 |
|
|
xyz[2]=root[2]+inf_val*dir1[2]-inf_val*dir2[2];
|
260 |
|
5 |
|
261 |
|
|
param.ajouter(xyz[0]);
|
262 |
|
|
param.ajouter(xyz[1]);
|
263 |
|
|
param.ajouter(xyz[2]);
|
264 |
|
|
param.ajouter(0);
|
265 |
|
|
|
266 |
|
|
// this is the second control point with cordinate (inf,-inf)
|
267 |
|
|
|
268 |
francois |
19 |
xyz[0]=root[0]-inf_val*dir1[0]-inf_val*dir2[0];
|
269 |
|
|
xyz[1]=root[1]-inf_val*dir1[1]-inf_val*dir2[1];
|
270 |
|
|
xyz[2]=root[2]-inf_val*dir1[2]-inf_val*dir2[2];
|
271 |
|
5 |
|
272 |
|
|
param.ajouter(xyz[0]);
|
273 |
|
|
param.ajouter(xyz[1]);
|
274 |
|
|
param.ajouter(xyz[2]);
|
275 |
|
|
param.ajouter(0);
|
276 |
|
|
|
277 |
francois |
19 |
indx_premier_ptctr=13;
|
278 |
|
5 |
|
279 |
|
|
}
|