1 |
francois |
139 |
//---------------------------------------------------------------------------
|
2 |
|
|
//------------------------------------------------------------
|
3 |
|
|
//------------------------------------------------------------
|
4 |
|
|
// MAGiC
|
5 |
francois |
275 |
// Jean Christophe Cuilli�re et Vincent FRANCOIS
|
6 |
|
|
// D�partement de G�nie M�canique - UQTR
|
7 |
francois |
139 |
//------------------------------------------------------------
|
8 |
francois |
275 |
// Le projet MAGIC est un projet de recherche du d�partement
|
9 |
|
|
// de g�nie m�canique de l'Universit� du Qu�bec �
|
10 |
|
|
// Trois Rivi�res
|
11 |
|
|
// Les librairies ne peuvent �tre utilis�es sans l'accord
|
12 |
francois |
139 |
// des auteurs (contact : francois@uqtr.ca)
|
13 |
|
|
//------------------------------------------------------------
|
14 |
|
|
//------------------------------------------------------------
|
15 |
|
|
//
|
16 |
|
|
// OCC_Surface.cpp
|
17 |
|
|
//
|
18 |
|
|
//------------------------------------------------------------
|
19 |
|
|
//------------------------------------------------------------
|
20 |
|
|
// COPYRIGHT 2000
|
21 |
francois |
275 |
// Version du 02/03/2006 � 11H22
|
22 |
francois |
139 |
//------------------------------------------------------------
|
23 |
|
|
//------------------------------------------------------------
|
24 |
|
|
|
25 |
|
|
#pragma hdrstop
|
26 |
|
|
#include "gestionversion.h"
|
27 |
|
|
#ifdef BREP_OCC
|
28 |
|
|
|
29 |
|
|
#include "occ_surface.h"
|
30 |
|
|
#include <gp_Pnt.hxx>
|
31 |
|
|
#include <gp_Vec.hxx>
|
32 |
|
|
#include "GeomAPI_ProjectPointOnSurf.hxx"
|
33 |
|
|
#include <ShapeAnalysis_Surface.hxx>
|
34 |
|
|
#include <BRep_Tool.hxx>
|
35 |
|
|
#include <BRepAdaptor_Surface.hxx>
|
36 |
|
|
//***********************************
|
37 |
francois |
275 |
#include <BRep_Tool.hxx>
|
38 |
|
|
#include <Poly_Triangulation.hxx>
|
39 |
francois |
139 |
#include <Geom_Plane.hxx>
|
40 |
|
|
#include <gp_Pln.hxx>
|
41 |
|
|
#include <Geom_CylindricalSurface.hxx>
|
42 |
|
|
#include <gp_Cylinder.hxx>
|
43 |
|
|
#include <Geom_ConicalSurface.hxx>
|
44 |
|
|
#include <gp_Cone.hxx>
|
45 |
|
|
#include <Geom_SphericalSurface.hxx>
|
46 |
|
|
#include <gp_Sphere.hxx>
|
47 |
|
|
#include "Geom_ToroidalSurface.hxx"
|
48 |
|
|
#include <gp_Torus.hxx>
|
49 |
|
|
#include <Geom_BSplineSurface.hxx>
|
50 |
|
|
#include <Geom_BezierSurface.hxx>
|
51 |
|
|
#include <GeomConvert.hxx>
|
52 |
|
|
#include <BRepBuilderAPI_NurbsConvert.hxx>
|
53 |
|
|
#include <BRepLib_FindSurface.hxx>
|
54 |
francois |
275 |
#include "mg_gestionnaire.h"
|
55 |
francois |
139 |
#include "constantegeo.h"
|
56 |
|
|
|
57 |
|
|
#pragma package(smart_init)
|
58 |
|
|
OCC_SURFACE::OCC_SURFACE(unsigned long num, TopoDS_Face srf, OCC_FONCTION1& fonc):MG_SURFACE(num),face(srf), fonction1(fonc)
|
59 |
|
|
{
|
60 |
|
|
|
61 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face);
|
62 |
|
|
double u1; double u2; double v1; double v2;
|
63 |
|
|
surface->Bounds(u1,u2,v1, v2);
|
64 |
|
|
u_min=u1;
|
65 |
|
|
u_max=u2;
|
66 |
|
|
v_min=v1;
|
67 |
|
|
v_max=v2;
|
68 |
|
|
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
OCC_SURFACE::OCC_SURFACE(TopoDS_Face srf, OCC_FONCTION1& fonc):MG_SURFACE(),face(srf), fonction1(fonc)
|
72 |
|
|
{
|
73 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face);
|
74 |
|
|
double u1; double u2; double v1; double v2;
|
75 |
|
|
surface->Bounds(u1,u2,v1, v2);
|
76 |
|
|
u_min=u1;
|
77 |
|
|
u_max=u2;
|
78 |
|
|
v_min=v1;
|
79 |
|
|
v_max=v2;
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
OCC_SURFACE::OCC_SURFACE(OCC_SURFACE& mdd):MG_SURFACE(mdd),face(mdd.face), fonction1(mdd.fonction1)
|
83 |
|
|
{
|
84 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face);
|
85 |
|
|
u_min=mdd.get_umin();
|
86 |
|
|
u_max=mdd.get_umax();
|
87 |
|
|
v_min=mdd.get_vmin();
|
88 |
|
|
v_max=mdd.get_vmax();
|
89 |
|
|
|
90 |
|
|
}
|
91 |
|
|
OCC_SURFACE::~OCC_SURFACE()
|
92 |
|
|
{
|
93 |
|
|
}
|
94 |
|
|
void OCC_SURFACE::evaluer(double *uv,double *xyz)
|
95 |
|
|
{
|
96 |
|
|
|
97 |
|
|
const Handle(Geom_Surface) &surface=BRep_Tool::Surface(face);
|
98 |
|
|
gp_Pnt P;
|
99 |
|
|
double u=uv[0];
|
100 |
|
|
double v=uv[1];
|
101 |
|
|
|
102 |
|
|
surface->D0(u,v,P);
|
103 |
|
|
|
104 |
|
|
xyz[0]=P.X();
|
105 |
|
|
xyz[1]=P.Y();
|
106 |
|
|
xyz[2]=P.Z();
|
107 |
|
|
}
|
108 |
|
|
void OCC_SURFACE::deriver(double *uv,double *xyzdu, double *xyzdv)
|
109 |
|
|
{
|
110 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face);
|
111 |
|
|
double u=uv[0];
|
112 |
|
|
double v=uv[1];
|
113 |
|
|
gp_Vec D1U;
|
114 |
|
|
gp_Vec D1V;
|
115 |
|
|
gp_Pnt P;
|
116 |
|
|
|
117 |
|
|
surface->D1(u,v,P,D1U,D1V);
|
118 |
|
|
xyzdu[0]=D1U.X();
|
119 |
|
|
xyzdu[1]=D1U.Y();
|
120 |
|
|
xyzdu[2]=D1U.Z();
|
121 |
|
|
|
122 |
|
|
xyzdv[0]=D1V.X();
|
123 |
|
|
xyzdv[1]=D1V.Y();
|
124 |
|
|
xyzdv[2]=D1V.Z();
|
125 |
|
|
|
126 |
|
|
}
|
127 |
|
|
void OCC_SURFACE::deriver_seconde(double *uv,double* xyzduu,double* xyzduv,double* xyzdvv,double *xyz, double *xyzdu, double *xyzdv)
|
128 |
|
|
{
|
129 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face);
|
130 |
|
|
double u=uv[0];
|
131 |
|
|
double v=uv[1];
|
132 |
|
|
gp_Pnt P;
|
133 |
|
|
gp_Vec D1U;
|
134 |
|
|
gp_Vec D1V;
|
135 |
|
|
gp_Vec D2U;
|
136 |
|
|
gp_Vec D2V;
|
137 |
|
|
gp_Vec D2UV;
|
138 |
|
|
|
139 |
|
|
surface->D2(u,v,P,D1U,D1V,D2U,D2V,D2UV);
|
140 |
|
|
|
141 |
|
|
xyz[0]=P.X();
|
142 |
|
|
xyz[1]=P.Y();
|
143 |
|
|
xyz[2]=P.Z();
|
144 |
|
|
|
145 |
|
|
xyzdu[0]=D1U.X();
|
146 |
|
|
xyzdu[1]=D1U.Y();
|
147 |
|
|
xyzdu[2]=D1U.Z();
|
148 |
|
|
|
149 |
|
|
xyzdv[0]=D1V.X();
|
150 |
|
|
xyzdv[1]=D1V.Y();
|
151 |
|
|
xyzdv[2]=D1V.Z();
|
152 |
|
|
|
153 |
|
|
xyzduu[0]=D2U.X();
|
154 |
|
|
xyzduu[1]=D2U.Y();
|
155 |
|
|
xyzduu[2]=D2U.Z();
|
156 |
|
|
|
157 |
|
|
xyzdvv[0]=D2V.X();
|
158 |
|
|
xyzdvv[1]=D2V.Y();
|
159 |
|
|
xyzdvv[2]=D2V.Z();
|
160 |
|
|
|
161 |
|
|
xyzduv[0]=D2UV.X();
|
162 |
|
|
xyzduv[1]=D2UV.Y();
|
163 |
|
|
xyzduv[2]=D2UV.Z();
|
164 |
|
|
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
void OCC_SURFACE::inverser(double *uv,double *xyz,double precision)
|
168 |
|
|
{
|
169 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face);
|
170 |
|
|
double u=xyz[0];
|
171 |
|
|
double v=xyz[1];
|
172 |
|
|
double w=xyz[2];
|
173 |
|
|
gp_Pnt P(u,v,w);
|
174 |
|
|
|
175 |
|
|
//ShapeAnalysis_Surface SAS(surface);
|
176 |
|
|
//gp_Pnt2d pnt2d=SAS.ValueOfUV(P, precision);
|
177 |
|
|
|
178 |
|
|
GeomAPI_ProjectPointOnSurf PPS(P,surface, precision);
|
179 |
|
|
//PPS.Perform(P);
|
180 |
|
|
double UU, VV;
|
181 |
|
|
PPS.LowerDistanceParameters(UU,VV);
|
182 |
|
|
|
183 |
|
|
uv[0]=UU;
|
184 |
|
|
uv[1]=VV;
|
185 |
|
|
}
|
186 |
|
|
int OCC_SURFACE::est_periodique_u(void)
|
187 |
|
|
{
|
188 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face);
|
189 |
|
|
return surface->IsUClosed();
|
190 |
|
|
}
|
191 |
|
|
|
192 |
|
|
int OCC_SURFACE::est_periodique_v(void)
|
193 |
|
|
{
|
194 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face);
|
195 |
|
|
return surface->IsVPeriodic();
|
196 |
|
|
}
|
197 |
|
|
double OCC_SURFACE::get_periode_u(void)
|
198 |
|
|
{
|
199 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face);
|
200 |
|
|
if(surface->IsUPeriodic()==0) return 0.;
|
201 |
|
|
return surface->UPeriod();
|
202 |
|
|
}
|
203 |
|
|
|
204 |
|
|
double OCC_SURFACE::get_periode_v(void)
|
205 |
|
|
{
|
206 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face);
|
207 |
|
|
if(surface->IsVPeriodic()==0) return 0.;
|
208 |
|
|
return surface->VPeriod();
|
209 |
|
|
}
|
210 |
|
|
void OCC_SURFACE::enregistrer(std::ostream& o)
|
211 |
|
|
{
|
212 |
|
|
o <<"%"<<get_id()<< "=SURFACE_OCC("<< fonction1.GetID(face)<< ");" << std::endl;
|
213 |
|
|
}
|
214 |
|
|
int OCC_SURFACE::get_type_geometrique(TPL_LISTE_ENTITE<double> ¶m)
|
215 |
|
|
{
|
216 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face);
|
217 |
|
|
Handle(Standard_Type) type=surface->DynamicType();
|
218 |
|
|
//******plan
|
219 |
|
|
if(type==STANDARD_TYPE(Geom_Plane))
|
220 |
|
|
{
|
221 |
|
|
Handle(Geom_Plane) Pln=Handle(Geom_Plane)::DownCast(surface);
|
222 |
|
|
gp_Pln plan=Pln->Pln();
|
223 |
|
|
|
224 |
|
|
double origine[3];
|
225 |
|
|
gp_Pnt centre=plan.Location();
|
226 |
|
|
|
227 |
|
|
origine[0]=centre.X();
|
228 |
|
|
origine[1]=centre.Y();
|
229 |
|
|
origine[2]=centre.Z();
|
230 |
|
|
|
231 |
|
|
double normal[3];
|
232 |
|
|
gp_Ax1 axe=plan.Axis();
|
233 |
|
|
gp_Dir direction=axe.Direction();
|
234 |
|
|
|
235 |
|
|
normal[0]=direction.X();
|
236 |
|
|
normal[1]=direction.Y();
|
237 |
|
|
normal[2]=direction.Z();
|
238 |
|
|
|
239 |
|
|
param.ajouter(origine[0]);
|
240 |
|
|
param.ajouter(origine[1]);
|
241 |
|
|
param.ajouter(origine[2]);
|
242 |
|
|
param.ajouter(normal[0]);
|
243 |
|
|
param.ajouter(normal[1]);
|
244 |
|
|
param.ajouter(normal[2]);
|
245 |
|
|
|
246 |
|
|
return MGCo_PLAN;
|
247 |
|
|
}
|
248 |
|
|
//******cylindre
|
249 |
|
|
if(type==STANDARD_TYPE(Geom_CylindricalSurface))
|
250 |
|
|
{
|
251 |
|
|
Handle(Geom_CylindricalSurface) cylinder=Handle(Geom_CylindricalSurface)::DownCast(surface);
|
252 |
|
|
gp_Cylinder cylin=cylinder->Cylinder();
|
253 |
|
|
|
254 |
|
|
double origine[3];
|
255 |
|
|
gp_Pnt centre=cylin.Location();
|
256 |
|
|
origine[0]=centre.X();
|
257 |
|
|
origine[1]=centre.Y();
|
258 |
|
|
origine[2]=centre.Z();
|
259 |
|
|
double direction[3];
|
260 |
|
|
gp_Ax1 axe=cylin.Axis();
|
261 |
|
|
gp_Dir dir=axe.Direction();
|
262 |
|
|
direction[0]=dir.X();
|
263 |
|
|
direction[1]=dir.Y();
|
264 |
|
|
direction[2]=dir.Z();
|
265 |
|
|
double rayon;
|
266 |
|
|
rayon=cylin.Radius();
|
267 |
|
|
|
268 |
|
|
param.ajouter(origine[0]);
|
269 |
|
|
param.ajouter(origine[1]);
|
270 |
|
|
param.ajouter(origine[2]);
|
271 |
|
|
param.ajouter(direction[0]);
|
272 |
|
|
param.ajouter(direction[1]);
|
273 |
|
|
param.ajouter(direction[2]);
|
274 |
|
|
param.ajouter(rayon);
|
275 |
|
|
|
276 |
|
|
return MGCo_CYLINDRE;
|
277 |
|
|
}
|
278 |
|
|
//******Cone
|
279 |
|
|
if(type==STANDARD_TYPE(Geom_ConicalSurface))
|
280 |
|
|
{
|
281 |
|
|
Handle(Geom_ConicalSurface) cone=Handle(Geom_ConicalSurface)::DownCast(surface);
|
282 |
|
|
gp_Cone con=cone->Cone();
|
283 |
|
|
|
284 |
|
|
double origine[3];
|
285 |
|
|
gp_Pnt centre=con.Location();
|
286 |
|
|
origine[0]=centre.X();
|
287 |
|
|
origine[1]=centre.Y();
|
288 |
|
|
origine[2]=centre.Z();
|
289 |
|
|
double direction[3];
|
290 |
|
|
gp_Ax1 axe=con.Axis();
|
291 |
|
|
gp_Dir dir=axe.Direction();
|
292 |
|
|
direction[0]=dir.X();
|
293 |
|
|
direction[1]=dir.Y();
|
294 |
|
|
direction[2]=dir.Z();
|
295 |
|
|
double rayon;
|
296 |
|
|
rayon=con.RefRadius();
|
297 |
|
|
double angle;
|
298 |
|
|
angle=con.SemiAngle();
|
299 |
|
|
|
300 |
|
|
param.ajouter(origine[0]);
|
301 |
|
|
param.ajouter(origine[1]);
|
302 |
|
|
param.ajouter(origine[2]);
|
303 |
|
|
param.ajouter(direction[0]);
|
304 |
|
|
param.ajouter(direction[1]);
|
305 |
|
|
param.ajouter(direction[2]);
|
306 |
|
|
param.ajouter(rayon);
|
307 |
|
|
param.ajouter(angle);
|
308 |
|
|
|
309 |
|
|
return MGCo_CONE;
|
310 |
|
|
|
311 |
|
|
}
|
312 |
|
|
//*****Sphere
|
313 |
|
|
if(type==STANDARD_TYPE(Geom_SphericalSurface))
|
314 |
|
|
{
|
315 |
|
|
Handle(Geom_SphericalSurface) sphere=Handle(Geom_SphericalSurface)::DownCast(surface);
|
316 |
|
|
gp_Sphere sph=sphere->Sphere();
|
317 |
|
|
|
318 |
|
|
double origine[3];
|
319 |
|
|
gp_Pnt centre=sph.Location();
|
320 |
|
|
origine[0]=centre.X();
|
321 |
|
|
origine[1]=centre.Y();
|
322 |
|
|
origine[2]=centre.Z();
|
323 |
|
|
double rayon;
|
324 |
|
|
rayon=sph.Radius();
|
325 |
|
|
param.ajouter(origine[0]);
|
326 |
|
|
param.ajouter(origine[1]);
|
327 |
|
|
param.ajouter(origine[2]);
|
328 |
|
|
param.ajouter(rayon);
|
329 |
|
|
|
330 |
|
|
return MGCo_SPHERE;
|
331 |
|
|
|
332 |
|
|
}
|
333 |
|
|
//****** Tore
|
334 |
|
|
if(type==STANDARD_TYPE(Geom_ToroidalSurface))
|
335 |
|
|
{
|
336 |
|
|
Handle(Geom_ToroidalSurface) tore=Handle(Geom_ToroidalSurface)::DownCast(surface);
|
337 |
|
|
gp_Torus tro=tore->Torus();
|
338 |
|
|
double origine[3];
|
339 |
|
|
gp_Pnt centre=tro.Location();
|
340 |
|
|
origine[0]=centre.X();
|
341 |
|
|
origine[1]=centre.Y();
|
342 |
|
|
origine[2]=centre.Z();
|
343 |
|
|
double direction[3];
|
344 |
|
|
gp_Ax1 axe=tro.Axis();
|
345 |
|
|
gp_Dir dir=axe.Direction();
|
346 |
|
|
direction[0]=dir.X();
|
347 |
|
|
direction[1]=dir.Y();
|
348 |
|
|
direction[2]=dir.Z();
|
349 |
|
|
double Grayon;
|
350 |
|
|
Grayon=tro.MajorRadius();
|
351 |
|
|
double Prayon;
|
352 |
|
|
Prayon=tro.MinorRadius();
|
353 |
|
|
|
354 |
|
|
param.ajouter(origine[0]);
|
355 |
|
|
param.ajouter(origine[1]);
|
356 |
|
|
param.ajouter(origine[2]);
|
357 |
|
|
param.ajouter(direction[0]);
|
358 |
|
|
param.ajouter(direction[1]);
|
359 |
|
|
param.ajouter(direction[2]);
|
360 |
|
|
param.ajouter(Grayon);
|
361 |
|
|
param.ajouter(Prayon);
|
362 |
|
|
|
363 |
|
|
return MGCo_TORE;
|
364 |
|
|
|
365 |
|
|
}
|
366 |
|
|
//*******BSpline
|
367 |
|
|
if(type==STANDARD_TYPE(Geom_BSplineSurface))
|
368 |
|
|
{
|
369 |
|
|
Handle(Geom_BSplineSurface) bspline=Handle(Geom_BSplineSurface)::DownCast(surface);
|
370 |
|
|
|
371 |
|
|
//nombre des noeuds suivant Udirection
|
372 |
|
|
int nb_Uknot=bspline->NbUKnots();
|
373 |
|
|
//valeur de Unoeud
|
374 |
|
|
for(int i=1; i<=nb_Uknot; i++)
|
375 |
|
|
{
|
376 |
|
|
double Uvaleur=bspline->UKnot(i);
|
377 |
|
|
param.ajouter(Uvaleur);
|
378 |
|
|
}
|
379 |
|
|
//nombre des noeuds suivants Vdirection
|
380 |
|
|
int nb_Vknot=bspline->NbVKnots();
|
381 |
|
|
//valeur de Vnoeud
|
382 |
|
|
for(int j=1; j<=nb_Vknot; j++)
|
383 |
|
|
{
|
384 |
|
|
double Vvaleur=bspline->VKnot(j);
|
385 |
|
|
param.ajouter(Vvaleur);
|
386 |
|
|
}
|
387 |
|
|
//point de controle et poids
|
388 |
|
|
gp_Pnt pctr;
|
389 |
|
|
double poids;
|
390 |
|
|
for(int u=1; u<=bspline->NbUPoles(); u++)
|
391 |
|
|
for(int v=1; v<=bspline->NbVPoles(); v++)
|
392 |
|
|
{
|
393 |
|
|
pctr=bspline->Pole(u, v);
|
394 |
|
|
|
395 |
|
|
param.ajouter(pctr.X());
|
396 |
|
|
param.ajouter(pctr.Y());
|
397 |
|
|
param.ajouter(pctr.Z());
|
398 |
|
|
|
399 |
|
|
poids=bspline->Weight(u, v);
|
400 |
|
|
param.ajouter(poids);
|
401 |
|
|
}
|
402 |
|
|
|
403 |
|
|
double uDegree=bspline->UDegree();
|
404 |
|
|
param.ajouter(uDegree);
|
405 |
|
|
double vDegree=bspline->VDegree();
|
406 |
|
|
param.ajouter(vDegree);
|
407 |
|
|
return MGCo_BSPLINES;
|
408 |
|
|
}
|
409 |
|
|
|
410 |
|
|
}
|
411 |
|
|
void OCC_SURFACE::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> ¶m)
|
412 |
|
|
{
|
413 |
|
|
//Conversion of the complete geometry of a shape into
|
414 |
|
|
//NURBS geometry
|
415 |
|
|
BRepBuilderAPI_NurbsConvert NURBS(face);
|
416 |
|
|
Handle(Geom_Surface) surface=BRepLib_FindSurface(NURBS).Surface();
|
417 |
|
|
Handle(Geom_BSplineSurface) bspline=GeomConvert::SurfaceToBSplineSurface(surface) ;
|
418 |
|
|
|
419 |
|
|
// The first parameter indicate the code access
|
420 |
francois |
275 |
param.ajouter(2);
|
421 |
|
|
//The follewing two parameters of the list indicate the orders of the net points
|
422 |
|
|
param.ajouter( bspline->UDegree()+1);
|
423 |
|
|
param.ajouter(bspline->VDegree()+1);
|
424 |
francois |
139 |
|
425 |
francois |
275 |
//The follewing two parameters indicate the number of rows and colons of the control points
|
426 |
|
|
//respectively to the two parameters directions
|
427 |
|
|
param.ajouter(bspline->NbUPoles());
|
428 |
|
|
param.ajouter(bspline->NbVPoles());
|
429 |
francois |
139 |
|
430 |
francois |
275 |
// this present the knot vector in the u-direction
|
431 |
|
|
for(unsigned int i=1;i<=bspline->NbUKnots();i++)
|
432 |
|
|
{
|
433 |
|
|
param.ajouter(bspline->UKnot(i));
|
434 |
|
|
}
|
435 |
|
|
//This present the knot vector in the v-direction
|
436 |
|
|
for(unsigned int j=1;j<=bspline->NbVKnots();j++)
|
437 |
|
|
{
|
438 |
|
|
param.ajouter(bspline->VKnot(j));
|
439 |
|
|
}
|
440 |
|
|
|
441 |
|
|
for(int u=1;u<=bspline->NbUPoles();u++)
|
442 |
|
|
{
|
443 |
|
|
for(int v=1;v<=bspline->NbVPoles();v++)
|
444 |
|
|
{
|
445 |
|
|
double w=bspline->Weight(u,v);
|
446 |
|
|
gp_Pnt point=bspline->Pole(u, v);
|
447 |
|
|
double x=point.X();
|
448 |
|
|
double y=point.Y();
|
449 |
|
|
double z=point.Z();
|
450 |
|
|
param.ajouter(x);
|
451 |
|
|
param.ajouter(y);
|
452 |
|
|
param.ajouter(z);
|
453 |
|
|
param.ajouter(w);
|
454 |
|
|
}
|
455 |
|
|
|
456 |
|
|
}
|
457 |
|
|
indx_premier_ptctr=5+bspline->NbUKnots()+bspline->NbVKnots();
|
458 |
|
|
|
459 |
|
|
|
460 |
|
|
|
461 |
|
|
|
462 |
|
|
|
463 |
francois |
139 |
}
|
464 |
francois |
275 |
|
465 |
|
|
void OCC_SURFACE::get_triangulation(MG_MAILLAGE* mai,MG_FACE* mgface,multimap<double,MG_NOEUD*,less<double> >& tabnoeudfus,double eps,int mode)
|
466 |
|
|
{
|
467 |
|
|
TopLoc_Location L;
|
468 |
|
|
Handle (Poly_Triangulation) pt=BRep_Tool::Triangulation(face,L);
|
469 |
|
|
int nbnoeud=pt->NbNodes();
|
470 |
|
|
int nbmaille=pt->NbTriangles();
|
471 |
|
|
const TColgp_Array1OfPnt& nodes = pt->Nodes();
|
472 |
|
|
const Poly_Array1OfTriangle& triangles = pt->Triangles();
|
473 |
|
|
const TColgp_Array1OfPnt2d& uvNodes = pt->UVNodes();
|
474 |
|
|
vector<MG_NOEUD*> tabnoeud;
|
475 |
|
|
for ( Standard_Integer i = 0; i < nbnoeud; i++ )
|
476 |
|
|
{
|
477 |
|
|
gp_Pnt p1=nodes(i+1);
|
478 |
|
|
double xx=p1.X();
|
479 |
|
|
double yy=p1.Y();
|
480 |
|
|
double zz=p1.Z();
|
481 |
|
|
double key=fabs(xx)+fabs(yy)+fabs(zz);
|
482 |
|
|
MG_NOEUD* nvnoeud=NULL;
|
483 |
|
|
if (mode>1)
|
484 |
|
|
{
|
485 |
|
|
multimap<double,MG_NOEUD*,less<double> >::iterator it,itbas,ithaut;
|
486 |
|
|
itbas=tabnoeudfus.lower_bound(key*0.99);
|
487 |
|
|
ithaut=tabnoeudfus.upper_bound(key*1.1010101);
|
488 |
|
|
for ( it=itbas ; it != ithaut; it++ )
|
489 |
|
|
{
|
490 |
|
|
MG_NOEUD* ntmp=(*it).second;
|
491 |
|
|
double xtmp=ntmp->get_x();
|
492 |
|
|
double ytmp=ntmp->get_y();
|
493 |
|
|
double ztmp=ntmp->get_z();
|
494 |
|
|
OT_VECTEUR_3D vec(xtmp-xx,ytmp-yy,ztmp-zz);
|
495 |
|
|
if (vec.get_longueur()<1e-6*eps) {nvnoeud=ntmp;break;}
|
496 |
|
|
}
|
497 |
|
|
}
|
498 |
|
|
if (nvnoeud==NULL)
|
499 |
|
|
{
|
500 |
|
|
nvnoeud=new MG_NOEUD(mgface,xx,yy,zz,TRIANGULATION);
|
501 |
|
|
mai->ajouter_mg_noeud(nvnoeud);
|
502 |
|
|
std::pair<double,MG_NOEUD*> tmp(key,nvnoeud);
|
503 |
|
|
tabnoeudfus.insert(tmp);
|
504 |
|
|
}
|
505 |
|
|
|
506 |
|
|
|
507 |
|
|
tabnoeud.insert(tabnoeud.end(),nvnoeud);
|
508 |
|
|
}
|
509 |
|
|
for ( Standard_Integer i = 0; i < nbmaille; i++ )
|
510 |
|
|
{
|
511 |
|
|
int n1,n2,n3;
|
512 |
|
|
Poly_Triangle triangle = triangles( i + 1 );
|
513 |
|
|
bool face_reversed = (face.Orientation() == TopAbs_REVERSED);
|
514 |
|
|
if ( face_reversed )
|
515 |
|
|
triangle.Get( n1, n3, n2 );
|
516 |
|
|
else
|
517 |
|
|
triangle.Get( n1, n2, n3 );
|
518 |
|
|
MG_NOEUD* noeud1=tabnoeud[n1-1];
|
519 |
|
|
MG_NOEUD* noeud2=tabnoeud[n2-1];
|
520 |
|
|
MG_NOEUD* noeud3=tabnoeud[n3-1];
|
521 |
|
|
mai->ajouter_mg_triangle(mgface,noeud1,noeud2,noeud3,TRIANGULATION);
|
522 |
|
|
|
523 |
|
|
|
524 |
|
|
}
|
525 |
|
|
}
|
526 |
|
|
|
527 |
francois |
139 |
#endif
|