1 |
francois |
283 |
//--------------------------------------------------------------------------- |
2 |
|
|
//------------------------------------------------------------ |
3 |
|
|
//------------------------------------------------------------ |
4 |
|
|
// MAGiC |
5 |
|
|
// Jean Christophe Cuilli�re et Vincent FRANCOIS |
6 |
|
|
// D�partement de G�nie M�canique - UQTR |
7 |
|
|
//------------------------------------------------------------ |
8 |
|
|
// 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 |
|
|
// des auteurs (contact : francois@uqtr.ca) |
13 |
|
|
//------------------------------------------------------------ |
14 |
|
|
//------------------------------------------------------------ |
15 |
|
|
// |
16 |
|
|
// OCC_Surface.cpp |
17 |
|
|
// |
18 |
|
|
//------------------------------------------------------------ |
19 |
|
|
//------------------------------------------------------------ |
20 |
|
|
// COPYRIGHT 2000 |
21 |
|
|
// Version du 02/03/2006 � 11H22 |
22 |
|
|
//------------------------------------------------------------ |
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 |
|
|
#include <BRep_Tool.hxx> |
38 |
|
|
#include <Poly_Triangulation.hxx> |
39 |
|
|
#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 |
|
|
#include "mg_gestionnaire.h" |
55 |
|
|
#include "constantegeo.h" |
56 |
francois |
295 |
#include "ot_mathematique.h" |
57 |
francois |
283 |
|
58 |
francois |
371 |
|
59 |
|
|
|
60 |
francois |
283 |
#pragma package(smart_init) |
61 |
francois |
371 |
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
class NOEUDARETE |
65 |
|
|
{ |
66 |
|
|
public: |
67 |
|
|
MG_NOEUD* no; |
68 |
|
|
MG_ARETE* are; |
69 |
|
|
double t; |
70 |
|
|
}; |
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
francois |
283 |
OCC_SURFACE::OCC_SURFACE(unsigned long num, TopoDS_Face srf, OCC_FONCTION1& fonc):MG_SURFACE(num),face(srf), fonction1(fonc) |
75 |
|
|
{ |
76 |
|
|
|
77 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
78 |
|
|
double u1; |
79 |
|
|
double u2; |
80 |
|
|
double v1; |
81 |
|
|
double v2; |
82 |
|
|
surface->Bounds(u1,u2,v1, v2); |
83 |
|
|
u_min=u1; |
84 |
|
|
u_max=u2; |
85 |
|
|
v_min=v1; |
86 |
|
|
v_max=v2; |
87 |
|
|
|
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
OCC_SURFACE::OCC_SURFACE(TopoDS_Face srf, OCC_FONCTION1& fonc):MG_SURFACE(),face(srf), fonction1(fonc) |
91 |
|
|
{ |
92 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
93 |
|
|
double u1; |
94 |
|
|
double u2; |
95 |
|
|
double v1; |
96 |
|
|
double v2; |
97 |
|
|
surface->Bounds(u1,u2,v1, v2); |
98 |
|
|
u_min=u1; |
99 |
|
|
u_max=u2; |
100 |
|
|
v_min=v1; |
101 |
|
|
v_max=v2; |
102 |
francois |
731 |
/*std::cout << " " <<std::endl; |
103 |
|
|
Handle(Standard_Type) type=surface->DynamicType(); |
104 |
|
|
if (type==STANDARD_TYPE(Geom_Plane)) std::cout << "plan" << std::endl; |
105 |
|
|
if (type==STANDARD_TYPE(Geom_CylindricalSurface)) std::cout << "Cylindre" << std::endl; |
106 |
|
|
if (type==STANDARD_TYPE(Geom_ConicalSurface)) std::cout << "Cone" << std::endl; |
107 |
|
|
if (type==STANDARD_TYPE(Geom_SphericalSurface)) std::cout << "Sphere" << std::endl; |
108 |
|
|
if (type==STANDARD_TYPE(Geom_ToroidalSurface)) std::cout << "Tore" << std::endl; |
109 |
|
|
if (type==STANDARD_TYPE(Geom_BSplineSurface)) std::cout << "Bspline surf" << std::endl; |
110 |
|
|
|
111 |
|
|
std::cout << surface->IsUClosed()<< " " <<surface->IsVClosed() <<std::endl;; |
112 |
|
|
std::cout << surface->IsUPeriodic() <<" " <<surface->IsVPeriodic() << std::endl;; |
113 |
|
|
if (surface->IsUPeriodic()) std::cout << "Pu=" << surface->UPeriod() << std::endl;; |
114 |
|
|
if (surface->IsVPeriodic()) std::cout << "Pv=" << surface->VPeriod() << std::endl;;*/ |
115 |
francois |
283 |
} |
116 |
|
|
|
117 |
|
|
OCC_SURFACE::OCC_SURFACE(OCC_SURFACE& mdd):MG_SURFACE(mdd),face(mdd.face), fonction1(mdd.fonction1) |
118 |
|
|
{ |
119 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
120 |
|
|
u_min=mdd.get_umin(); |
121 |
|
|
u_max=mdd.get_umax(); |
122 |
|
|
v_min=mdd.get_vmin(); |
123 |
|
|
v_max=mdd.get_vmax(); |
124 |
|
|
|
125 |
|
|
} |
126 |
|
|
OCC_SURFACE::~OCC_SURFACE() |
127 |
|
|
{ |
128 |
|
|
} |
129 |
|
|
void OCC_SURFACE::evaluer(double *uv,double *xyz) |
130 |
|
|
{ |
131 |
|
|
|
132 |
|
|
const Handle(Geom_Surface) &surface=BRep_Tool::Surface(face); |
133 |
|
|
gp_Pnt P; |
134 |
|
|
double u=uv[0]; |
135 |
|
|
double v=uv[1]; |
136 |
|
|
|
137 |
|
|
surface->D0(u,v,P); |
138 |
|
|
|
139 |
|
|
xyz[0]=P.X(); |
140 |
|
|
xyz[1]=P.Y(); |
141 |
|
|
xyz[2]=P.Z(); |
142 |
|
|
} |
143 |
|
|
void OCC_SURFACE::deriver(double *uv,double *xyzdu, double *xyzdv) |
144 |
|
|
{ |
145 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
146 |
|
|
double u=uv[0]; |
147 |
|
|
double v=uv[1]; |
148 |
|
|
gp_Vec D1U; |
149 |
|
|
gp_Vec D1V; |
150 |
|
|
gp_Pnt P; |
151 |
|
|
|
152 |
|
|
surface->D1(u,v,P,D1U,D1V); |
153 |
|
|
xyzdu[0]=D1U.X(); |
154 |
|
|
xyzdu[1]=D1U.Y(); |
155 |
|
|
xyzdu[2]=D1U.Z(); |
156 |
|
|
|
157 |
|
|
xyzdv[0]=D1V.X(); |
158 |
|
|
xyzdv[1]=D1V.Y(); |
159 |
|
|
xyzdv[2]=D1V.Z(); |
160 |
|
|
|
161 |
|
|
} |
162 |
|
|
void OCC_SURFACE::deriver_seconde(double *uv,double* xyzduu,double* xyzduv,double* xyzdvv,double *xyz, double *xyzdu, double *xyzdv) |
163 |
|
|
{ |
164 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
165 |
|
|
double u=uv[0]; |
166 |
|
|
double v=uv[1]; |
167 |
|
|
gp_Pnt P; |
168 |
|
|
gp_Vec D1U; |
169 |
|
|
gp_Vec D1V; |
170 |
|
|
gp_Vec D2U; |
171 |
|
|
gp_Vec D2V; |
172 |
|
|
gp_Vec D2UV; |
173 |
|
|
|
174 |
|
|
surface->D2(u,v,P,D1U,D1V,D2U,D2V,D2UV); |
175 |
|
|
|
176 |
|
|
xyz[0]=P.X(); |
177 |
|
|
xyz[1]=P.Y(); |
178 |
|
|
xyz[2]=P.Z(); |
179 |
|
|
|
180 |
|
|
xyzdu[0]=D1U.X(); |
181 |
|
|
xyzdu[1]=D1U.Y(); |
182 |
|
|
xyzdu[2]=D1U.Z(); |
183 |
|
|
|
184 |
|
|
xyzdv[0]=D1V.X(); |
185 |
|
|
xyzdv[1]=D1V.Y(); |
186 |
|
|
xyzdv[2]=D1V.Z(); |
187 |
|
|
|
188 |
|
|
xyzduu[0]=D2U.X(); |
189 |
|
|
xyzduu[1]=D2U.Y(); |
190 |
|
|
xyzduu[2]=D2U.Z(); |
191 |
|
|
|
192 |
|
|
xyzdvv[0]=D2V.X(); |
193 |
|
|
xyzdvv[1]=D2V.Y(); |
194 |
|
|
xyzdvv[2]=D2V.Z(); |
195 |
|
|
|
196 |
|
|
xyzduv[0]=D2UV.X(); |
197 |
|
|
xyzduv[1]=D2UV.Y(); |
198 |
|
|
xyzduv[2]=D2UV.Z(); |
199 |
|
|
|
200 |
|
|
} |
201 |
|
|
|
202 |
|
|
void OCC_SURFACE::inverser(double *uv,double *xyz,double precision) |
203 |
|
|
{ |
204 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
205 |
|
|
double u=xyz[0]; |
206 |
|
|
double v=xyz[1]; |
207 |
|
|
double w=xyz[2]; |
208 |
|
|
gp_Pnt P(u,v,w); |
209 |
|
|
|
210 |
|
|
//ShapeAnalysis_Surface SAS(surface); |
211 |
|
|
//gp_Pnt2d pnt2d=SAS.ValueOfUV(P, precision); |
212 |
|
|
GeomAPI_ProjectPointOnSurf PPS(P,surface, precision); |
213 |
francois |
339 |
if (PPS.NbPoints() < 1) |
214 |
|
|
{ |
215 |
|
|
uv[0]=1e308; |
216 |
|
|
uv[1]=1e308; |
217 |
|
|
return; |
218 |
|
|
} |
219 |
francois |
283 |
//PPS.Perform(P); |
220 |
|
|
double UU, VV; |
221 |
|
|
PPS.LowerDistanceParameters(UU,VV); |
222 |
|
|
uv[0]=UU; |
223 |
|
|
uv[1]=VV; |
224 |
|
|
} |
225 |
|
|
int OCC_SURFACE::est_periodique_u(void) |
226 |
|
|
{ |
227 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
228 |
|
|
return surface->IsUClosed(); |
229 |
|
|
} |
230 |
|
|
|
231 |
|
|
int OCC_SURFACE::est_periodique_v(void) |
232 |
|
|
{ |
233 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
234 |
francois |
731 |
// return surface->IsVPeriodic(); |
235 |
francois |
733 |
return surface->IsVClosed(); |
236 |
francois |
283 |
} |
237 |
|
|
double OCC_SURFACE::get_periode_u(void) |
238 |
|
|
{ |
239 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
240 |
francois |
731 |
if (surface->IsUPeriodic()) return surface->UPeriod(); |
241 |
|
|
if (surface->IsUClosed()) return u_max-u_min; |
242 |
|
|
return 0; |
243 |
francois |
283 |
} |
244 |
|
|
|
245 |
|
|
double OCC_SURFACE::get_periode_v(void) |
246 |
|
|
{ |
247 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
248 |
francois |
731 |
if (surface->IsVPeriodic()) surface->VPeriod(); |
249 |
|
|
if (surface->IsVClosed()) v_max-v_min; |
250 |
|
|
return 0; |
251 |
|
|
|
252 |
francois |
283 |
} |
253 |
|
|
void OCC_SURFACE::enregistrer(std::ostream& o) |
254 |
|
|
{ |
255 |
|
|
o <<"%"<<get_id()<< "=SURFACE_OCC("<< fonction1.GetID(face)<< ");" << std::endl; |
256 |
|
|
} |
257 |
|
|
int OCC_SURFACE::get_type_geometrique(TPL_LISTE_ENTITE<double> ¶m) |
258 |
|
|
{ |
259 |
|
|
Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
260 |
|
|
Handle(Standard_Type) type=surface->DynamicType(); |
261 |
|
|
//******plan |
262 |
|
|
if (type==STANDARD_TYPE(Geom_Plane)) |
263 |
|
|
{ |
264 |
|
|
Handle(Geom_Plane) Pln=Handle(Geom_Plane)::DownCast(surface); |
265 |
|
|
gp_Pln plan=Pln->Pln(); |
266 |
|
|
|
267 |
|
|
double origine[3]; |
268 |
|
|
gp_Pnt centre=plan.Location(); |
269 |
|
|
|
270 |
|
|
origine[0]=centre.X(); |
271 |
|
|
origine[1]=centre.Y(); |
272 |
|
|
origine[2]=centre.Z(); |
273 |
|
|
|
274 |
|
|
double normal[3]; |
275 |
|
|
gp_Ax1 axe=plan.Axis(); |
276 |
|
|
gp_Dir direction=axe.Direction(); |
277 |
|
|
|
278 |
|
|
normal[0]=direction.X(); |
279 |
|
|
normal[1]=direction.Y(); |
280 |
|
|
normal[2]=direction.Z(); |
281 |
|
|
|
282 |
|
|
param.ajouter(origine[0]); |
283 |
|
|
param.ajouter(origine[1]); |
284 |
|
|
param.ajouter(origine[2]); |
285 |
|
|
param.ajouter(normal[0]); |
286 |
|
|
param.ajouter(normal[1]); |
287 |
|
|
param.ajouter(normal[2]); |
288 |
|
|
|
289 |
|
|
return MGCo_PLAN; |
290 |
|
|
} |
291 |
|
|
//******cylindre |
292 |
|
|
if (type==STANDARD_TYPE(Geom_CylindricalSurface)) |
293 |
|
|
{ |
294 |
|
|
Handle(Geom_CylindricalSurface) cylinder=Handle(Geom_CylindricalSurface)::DownCast(surface); |
295 |
|
|
gp_Cylinder cylin=cylinder->Cylinder(); |
296 |
|
|
|
297 |
|
|
double origine[3]; |
298 |
|
|
gp_Pnt centre=cylin.Location(); |
299 |
|
|
origine[0]=centre.X(); |
300 |
|
|
origine[1]=centre.Y(); |
301 |
|
|
origine[2]=centre.Z(); |
302 |
|
|
double direction[3]; |
303 |
|
|
gp_Ax1 axe=cylin.Axis(); |
304 |
|
|
gp_Dir dir=axe.Direction(); |
305 |
|
|
direction[0]=dir.X(); |
306 |
|
|
direction[1]=dir.Y(); |
307 |
|
|
direction[2]=dir.Z(); |
308 |
|
|
double rayon; |
309 |
|
|
rayon=cylin.Radius(); |
310 |
|
|
|
311 |
|
|
param.ajouter(origine[0]); |
312 |
|
|
param.ajouter(origine[1]); |
313 |
|
|
param.ajouter(origine[2]); |
314 |
|
|
param.ajouter(direction[0]); |
315 |
|
|
param.ajouter(direction[1]); |
316 |
|
|
param.ajouter(direction[2]); |
317 |
|
|
param.ajouter(rayon); |
318 |
|
|
|
319 |
|
|
return MGCo_CYLINDRE; |
320 |
|
|
} |
321 |
|
|
//******Cone |
322 |
|
|
if (type==STANDARD_TYPE(Geom_ConicalSurface)) |
323 |
|
|
{ |
324 |
|
|
Handle(Geom_ConicalSurface) cone=Handle(Geom_ConicalSurface)::DownCast(surface); |
325 |
|
|
gp_Cone con=cone->Cone(); |
326 |
|
|
|
327 |
|
|
double origine[3]; |
328 |
|
|
gp_Pnt centre=con.Location(); |
329 |
|
|
origine[0]=centre.X(); |
330 |
|
|
origine[1]=centre.Y(); |
331 |
|
|
origine[2]=centre.Z(); |
332 |
|
|
double direction[3]; |
333 |
|
|
gp_Ax1 axe=con.Axis(); |
334 |
|
|
gp_Dir dir=axe.Direction(); |
335 |
|
|
direction[0]=dir.X(); |
336 |
|
|
direction[1]=dir.Y(); |
337 |
|
|
direction[2]=dir.Z(); |
338 |
|
|
double rayon; |
339 |
|
|
rayon=con.RefRadius(); |
340 |
|
|
double angle; |
341 |
|
|
angle=con.SemiAngle(); |
342 |
|
|
|
343 |
|
|
param.ajouter(origine[0]); |
344 |
|
|
param.ajouter(origine[1]); |
345 |
|
|
param.ajouter(origine[2]); |
346 |
|
|
param.ajouter(direction[0]); |
347 |
|
|
param.ajouter(direction[1]); |
348 |
|
|
param.ajouter(direction[2]); |
349 |
|
|
param.ajouter(rayon); |
350 |
|
|
param.ajouter(angle); |
351 |
|
|
|
352 |
|
|
return MGCo_CONE; |
353 |
|
|
|
354 |
|
|
} |
355 |
|
|
//*****Sphere |
356 |
|
|
if (type==STANDARD_TYPE(Geom_SphericalSurface)) |
357 |
|
|
{ |
358 |
|
|
Handle(Geom_SphericalSurface) sphere=Handle(Geom_SphericalSurface)::DownCast(surface); |
359 |
|
|
gp_Sphere sph=sphere->Sphere(); |
360 |
|
|
|
361 |
|
|
double origine[3]; |
362 |
|
|
gp_Pnt centre=sph.Location(); |
363 |
|
|
origine[0]=centre.X(); |
364 |
|
|
origine[1]=centre.Y(); |
365 |
|
|
origine[2]=centre.Z(); |
366 |
|
|
double rayon; |
367 |
|
|
rayon=sph.Radius(); |
368 |
|
|
param.ajouter(origine[0]); |
369 |
|
|
param.ajouter(origine[1]); |
370 |
|
|
param.ajouter(origine[2]); |
371 |
|
|
param.ajouter(rayon); |
372 |
|
|
|
373 |
|
|
return MGCo_SPHERE; |
374 |
|
|
|
375 |
|
|
} |
376 |
|
|
//****** Tore |
377 |
|
|
if (type==STANDARD_TYPE(Geom_ToroidalSurface)) |
378 |
|
|
{ |
379 |
|
|
Handle(Geom_ToroidalSurface) tore=Handle(Geom_ToroidalSurface)::DownCast(surface); |
380 |
|
|
gp_Torus tro=tore->Torus(); |
381 |
|
|
double origine[3]; |
382 |
|
|
gp_Pnt centre=tro.Location(); |
383 |
|
|
origine[0]=centre.X(); |
384 |
|
|
origine[1]=centre.Y(); |
385 |
|
|
origine[2]=centre.Z(); |
386 |
|
|
double direction[3]; |
387 |
|
|
gp_Ax1 axe=tro.Axis(); |
388 |
|
|
gp_Dir dir=axe.Direction(); |
389 |
|
|
direction[0]=dir.X(); |
390 |
|
|
direction[1]=dir.Y(); |
391 |
|
|
direction[2]=dir.Z(); |
392 |
|
|
double Grayon; |
393 |
|
|
Grayon=tro.MajorRadius(); |
394 |
|
|
double Prayon; |
395 |
|
|
Prayon=tro.MinorRadius(); |
396 |
|
|
|
397 |
|
|
param.ajouter(origine[0]); |
398 |
|
|
param.ajouter(origine[1]); |
399 |
|
|
param.ajouter(origine[2]); |
400 |
|
|
param.ajouter(direction[0]); |
401 |
|
|
param.ajouter(direction[1]); |
402 |
|
|
param.ajouter(direction[2]); |
403 |
|
|
param.ajouter(Grayon); |
404 |
|
|
param.ajouter(Prayon); |
405 |
|
|
|
406 |
|
|
return MGCo_TORE; |
407 |
|
|
|
408 |
|
|
} |
409 |
|
|
//*******BSpline |
410 |
|
|
if (type==STANDARD_TYPE(Geom_BSplineSurface)) |
411 |
|
|
{ |
412 |
|
|
Handle(Geom_BSplineSurface) bspline=Handle(Geom_BSplineSurface)::DownCast(surface); |
413 |
|
|
|
414 |
|
|
//nombre des noeuds suivant Udirection |
415 |
|
|
int nb_Uknot=bspline->NbUKnots(); |
416 |
|
|
//valeur de Unoeud |
417 |
|
|
for (int i=1; i<=nb_Uknot; i++) |
418 |
|
|
{ |
419 |
|
|
double Uvaleur=bspline->UKnot(i); |
420 |
|
|
param.ajouter(Uvaleur); |
421 |
|
|
} |
422 |
|
|
//nombre des noeuds suivants Vdirection |
423 |
|
|
int nb_Vknot=bspline->NbVKnots(); |
424 |
|
|
//valeur de Vnoeud |
425 |
|
|
for (int j=1; j<=nb_Vknot; j++) |
426 |
|
|
{ |
427 |
|
|
double Vvaleur=bspline->VKnot(j); |
428 |
|
|
param.ajouter(Vvaleur); |
429 |
|
|
} |
430 |
|
|
//point de controle et poids |
431 |
|
|
gp_Pnt pctr; |
432 |
|
|
double poids; |
433 |
|
|
for (int u=1; u<=bspline->NbUPoles(); u++) |
434 |
|
|
for (int v=1; v<=bspline->NbVPoles(); v++) |
435 |
|
|
{ |
436 |
|
|
pctr=bspline->Pole(u, v); |
437 |
|
|
|
438 |
|
|
param.ajouter(pctr.X()); |
439 |
|
|
param.ajouter(pctr.Y()); |
440 |
|
|
param.ajouter(pctr.Z()); |
441 |
|
|
|
442 |
|
|
poids=bspline->Weight(u, v); |
443 |
|
|
param.ajouter(poids); |
444 |
|
|
} |
445 |
|
|
|
446 |
|
|
double uDegree=bspline->UDegree(); |
447 |
|
|
param.ajouter(uDegree); |
448 |
|
|
double vDegree=bspline->VDegree(); |
449 |
|
|
param.ajouter(vDegree); |
450 |
|
|
return MGCo_BSPLINES; |
451 |
|
|
} |
452 |
|
|
|
453 |
|
|
} |
454 |
|
|
void OCC_SURFACE::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> ¶m) |
455 |
|
|
{ |
456 |
|
|
//Conversion of the complete geometry of a shape into |
457 |
|
|
//NURBS geometry |
458 |
|
|
BRepBuilderAPI_NurbsConvert NURBS(face); |
459 |
|
|
Handle(Geom_Surface) surface=BRepLib_FindSurface(NURBS).Surface(); |
460 |
|
|
Handle(Geom_BSplineSurface) bspline=GeomConvert::SurfaceToBSplineSurface(surface) ; |
461 |
|
|
|
462 |
|
|
// The first parameter indicate the code access |
463 |
|
|
param.ajouter(2); |
464 |
|
|
//The follewing two parameters of the list indicate the orders of the net points |
465 |
|
|
param.ajouter( bspline->UDegree()+1); |
466 |
|
|
param.ajouter(bspline->VDegree()+1); |
467 |
|
|
|
468 |
|
|
//The follewing two parameters indicate the number of rows and colons of the control points |
469 |
|
|
//respectively to the two parameters directions |
470 |
|
|
param.ajouter(bspline->NbUPoles()); |
471 |
|
|
param.ajouter(bspline->NbVPoles()); |
472 |
|
|
|
473 |
|
|
// this present the knot vector in the u-direction |
474 |
|
|
for (unsigned int i=1;i<=bspline->NbUKnots();i++) |
475 |
|
|
{ |
476 |
|
|
param.ajouter(bspline->UKnot(i)); |
477 |
|
|
} |
478 |
|
|
//This present the knot vector in the v-direction |
479 |
|
|
for (unsigned int j=1;j<=bspline->NbVKnots();j++) |
480 |
|
|
{ |
481 |
|
|
param.ajouter(bspline->VKnot(j)); |
482 |
|
|
} |
483 |
francois |
363 |
for (int v=1;v<=bspline->NbVPoles();v++) |
484 |
francois |
283 |
{ |
485 |
francois |
363 |
for (int u=1;u<=bspline->NbUPoles();u++) |
486 |
francois |
283 |
{ |
487 |
|
|
double w=bspline->Weight(u,v); |
488 |
|
|
gp_Pnt point=bspline->Pole(u, v); |
489 |
|
|
double x=point.X(); |
490 |
|
|
double y=point.Y(); |
491 |
|
|
double z=point.Z(); |
492 |
|
|
param.ajouter(x); |
493 |
|
|
param.ajouter(y); |
494 |
|
|
param.ajouter(z); |
495 |
|
|
param.ajouter(w); |
496 |
|
|
} |
497 |
|
|
|
498 |
|
|
} |
499 |
|
|
indx_premier_ptctr=5+bspline->NbUKnots()+bspline->NbVKnots(); |
500 |
|
|
|
501 |
|
|
|
502 |
|
|
|
503 |
|
|
|
504 |
|
|
|
505 |
|
|
} |
506 |
|
|
|
507 |
francois |
295 |
void OCC_SURFACE::get_triangulation(MG_MAILLAGE* mai,MG_FACE* mgface,std::multimap<double,MG_NOEUD*,std::less<double> >& tabnoeudfus,double eps,int mode) |
508 |
francois |
283 |
{ |
509 |
francois |
353 |
TPL_MAP_ENTITE<MG_SOMMET*> listsom; |
510 |
|
|
TPL_MAP_ENTITE<MG_ARETE*> listare; |
511 |
francois |
371 |
//std::map<unsigned long,bool> aretemaille; |
512 |
|
|
std::map<unsigned long,std::map<double,NOEUDARETE,less<double> >,less<unsigned long> > areteamaille; |
513 |
francois |
353 |
int nbboucle=mgface->get_nb_mg_boucle(); |
514 |
|
|
for (int i=0;i<nbboucle;i++) |
515 |
|
|
{ |
516 |
|
|
MG_BOUCLE* bou=mgface->get_mg_boucle(i); |
517 |
|
|
int nbarete=bou->get_nb_mg_coarete(); |
518 |
|
|
for (int j=0;j<nbarete;j++) |
519 |
|
|
{ |
520 |
|
|
MG_ARETE* are=bou->get_mg_coarete(j)->get_arete(); |
521 |
|
|
listare.ajouter(are); |
522 |
francois |
371 |
//bool amailler=true; |
523 |
|
|
//if (are->get_lien_maillage()->get_nb()>0) amailler=false; |
524 |
|
|
//aretemaille[are->get_id()]=amailler; |
525 |
francois |
353 |
listsom.ajouter(bou->get_mg_coarete(j)->get_arete()->get_cosommet1()->get_sommet()); |
526 |
francois |
371 |
listsom.ajouter(bou->get_mg_coarete(j)->get_arete()->get_cosommet2()->get_sommet()); |
527 |
|
|
std::map<double,NOEUDARETE,less<double> > tmp; |
528 |
|
|
std::pair<unsigned long,std::map<double,NOEUDARETE,less<double> > > maptmp(are->get_id(),tmp); |
529 |
|
|
areteamaille.insert(maptmp); |
530 |
francois |
353 |
} |
531 |
|
|
} |
532 |
foucault |
569 |
|
533 |
|
|
|
534 |
francois |
283 |
TopLoc_Location L; |
535 |
|
|
Handle (Poly_Triangulation) pt=BRep_Tool::Triangulation(face,L); |
536 |
|
|
int nbnoeud=pt->NbNodes(); |
537 |
|
|
int nbmaille=pt->NbTriangles(); |
538 |
|
|
const TColgp_Array1OfPnt& nodes = pt->Nodes(); |
539 |
|
|
const Poly_Array1OfTriangle& triangles = pt->Triangles(); |
540 |
|
|
const TColgp_Array1OfPnt2d& uvNodes = pt->UVNodes(); |
541 |
francois |
295 |
std::vector<MG_NOEUD*> tabnoeud; |
542 |
francois |
283 |
for ( Standard_Integer i = 0; i < nbnoeud; i++ ) |
543 |
|
|
{ |
544 |
foucault |
569 |
gp_Pnt p1=nodes(i+1); |
545 |
|
|
double xx=p1.X(); |
546 |
|
|
double yy=p1.Y(); |
547 |
|
|
double zz=p1.Z(); |
548 |
|
|
double key=fabs(xx)+fabs(yy)+fabs(zz); |
549 |
|
|
MG_NOEUD* nvnoeud=NULL; |
550 |
|
|
if (mode>1) |
551 |
|
|
{ |
552 |
|
|
std::multimap<double,MG_NOEUD*,std::less<double> >::iterator it,itbas,ithaut; |
553 |
|
|
itbas=tabnoeudfus.lower_bound(key*0.99); |
554 |
|
|
ithaut=tabnoeudfus.upper_bound(key*1.1010101); |
555 |
|
|
for ( it=itbas ; it != ithaut; it++ ) |
556 |
|
|
{ |
557 |
|
|
MG_NOEUD* ntmp=(*it).second; |
558 |
|
|
double xtmp=ntmp->get_x(); |
559 |
|
|
double ytmp=ntmp->get_y(); |
560 |
|
|
double ztmp=ntmp->get_z(); |
561 |
|
|
OT_VECTEUR_3D vec(xtmp-xx,ytmp-yy,ztmp-zz); |
562 |
|
|
if (vec.get_longueur()<1e-6*eps) { |
563 |
|
|
nvnoeud=ntmp; |
564 |
|
|
break; |
565 |
|
|
} |
566 |
|
|
} |
567 |
|
|
} |
568 |
|
|
if (nvnoeud==NULL) |
569 |
|
|
{ |
570 |
|
|
MG_ELEMENT_TOPOLOGIQUE *topo=mgface; |
571 |
|
|
TPL_MAP_ENTITE<MG_SOMMET*>::ITERATEUR it1; |
572 |
|
|
for (MG_SOMMET* som=listsom.get_premier(it1);som!=NULL;som=listsom.get_suivant(it1)) |
573 |
|
|
{ |
574 |
|
|
double xyz[3]; |
575 |
|
|
som->get_point()->evaluer(xyz); |
576 |
|
|
OT_VECTEUR_3D vec(xyz[0]-xx,xyz[1]-yy,xyz[2]-zz); |
577 |
|
|
if (vec.get_longueur()<1e-6*eps) |
578 |
|
|
{ |
579 |
|
|
topo=som; |
580 |
|
|
break; |
581 |
francois |
283 |
|
582 |
foucault |
569 |
} |
583 |
|
|
} |
584 |
|
|
double param_t; |
585 |
|
|
if (topo==mgface) |
586 |
|
|
{ |
587 |
|
|
TPL_MAP_ENTITE<MG_ARETE*>::ITERATEUR it2; |
588 |
|
|
for (MG_ARETE* are=listare.get_premier(it2);are!=NULL;are=listare.get_suivant(it2)) |
589 |
|
|
{ |
590 |
|
|
double t; |
591 |
|
|
double xyz[3]={xx,yy,zz}; |
592 |
|
|
are->inverser(t,xyz); |
593 |
|
|
if (are->get_courbe()->est_periodique()) |
594 |
|
|
if (t< are->get_tmin()) t=t+are->get_courbe()->get_periode(); |
595 |
|
|
double xyztmp[3]; |
596 |
|
|
are->evaluer(t,xyztmp ); |
597 |
|
|
OT_VECTEUR_3D vec(xyz,xyztmp); |
598 |
|
|
if (vec.get_longueur()<1e-6*eps) |
599 |
|
|
if ((t>are->get_tmin()) && (t<are->get_tmax())) |
600 |
|
|
{ |
601 |
|
|
topo=are; |
602 |
|
|
param_t=t; |
603 |
|
|
break; |
604 |
|
|
} |
605 |
|
|
} |
606 |
|
|
} |
607 |
|
|
nvnoeud=new MG_NOEUD(topo,xx,yy,zz,TRIANGULATION); |
608 |
|
|
mai->ajouter_mg_noeud(nvnoeud); |
609 |
|
|
std::pair<double,MG_NOEUD*> tmp(key,nvnoeud); |
610 |
|
|
tabnoeudfus.insert(tmp); |
611 |
|
|
if (topo->get_dimension()==1) |
612 |
|
|
{ |
613 |
|
|
NOEUDARETE na; |
614 |
|
|
na.no=nvnoeud; |
615 |
|
|
na.are=(MG_ARETE*)topo; |
616 |
|
|
na.t=param_t; |
617 |
|
|
std::pair<double,NOEUDARETE> tmp(na.t,na); |
618 |
|
|
areteamaille[topo->get_id()].insert(tmp); |
619 |
|
|
} |
620 |
|
|
} |
621 |
francois |
283 |
|
622 |
foucault |
569 |
|
623 |
francois |
283 |
tabnoeud.insert(tabnoeud.end(),nvnoeud); |
624 |
|
|
} |
625 |
|
|
for ( Standard_Integer i = 0; i < nbmaille; i++ ) |
626 |
|
|
{ |
627 |
|
|
int n1,n2,n3; |
628 |
|
|
Poly_Triangle triangle = triangles( i + 1 ); |
629 |
|
|
bool face_reversed = (face.Orientation() == TopAbs_REVERSED); |
630 |
|
|
if ( face_reversed ) |
631 |
|
|
triangle.Get( n1, n3, n2 ); |
632 |
|
|
else |
633 |
|
|
triangle.Get( n1, n2, n3 ); |
634 |
francois |
525 |
MG_NOEUD* noeud1=tabnoeud[n1-1]; |
635 |
francois |
283 |
MG_NOEUD* noeud2=tabnoeud[n2-1]; |
636 |
|
|
MG_NOEUD* noeud3=tabnoeud[n3-1]; |
637 |
francois |
525 |
if (noeud1==noeud2) continue; |
638 |
|
|
if (noeud1==noeud3) continue; |
639 |
|
|
if (noeud2==noeud3) continue; |
640 |
|
|
mai->ajouter_mg_triangle(mgface,noeud1,noeud2,noeud3,TRIANGULATION); |
641 |
|
|
/*if (noeud1->get_lien_topologie()->get_dimension()==0) |
642 |
francois |
353 |
{ |
643 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud1->get_lien_topologie(); |
644 |
|
|
som->get_lien_maillage()->ajouter(noeud1); |
645 |
|
|
} |
646 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==0) |
647 |
|
|
{ |
648 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud2->get_lien_topologie(); |
649 |
|
|
som->get_lien_maillage()->ajouter(noeud2); |
650 |
|
|
} |
651 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==0) |
652 |
|
|
{ |
653 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud3->get_lien_topologie(); |
654 |
|
|
som->get_lien_maillage()->ajouter(noeud3); |
655 |
francois |
525 |
}*/ |
656 |
francois |
371 |
/*if (noeud1->get_lien_topologie()==noeud2->get_lien_topologie()) |
657 |
francois |
353 |
if (noeud1->get_lien_topologie()->get_dimension()==1) |
658 |
|
|
{ |
659 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie(); |
660 |
|
|
if (aretemaille[are->get_id()]==true) |
661 |
|
|
{ |
662 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud2,TRIANGULATION); |
663 |
|
|
are->get_lien_maillage()->ajouter(seg); |
664 |
|
|
} |
665 |
|
|
} |
666 |
|
|
if (noeud1->get_lien_topologie()==noeud3->get_lien_topologie()) |
667 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==1) |
668 |
|
|
{ |
669 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie(); |
670 |
|
|
if (aretemaille[are->get_id()]==true) |
671 |
|
|
{ |
672 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud3,TRIANGULATION); |
673 |
|
|
are->get_lien_maillage()->ajouter(seg); |
674 |
|
|
} |
675 |
francois |
371 |
}#include <../gmsh/tutorial/t8.geo> |
676 |
francois |
353 |
if (noeud3->get_lien_topologie()==noeud2->get_lien_topologie()) |
677 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==1) |
678 |
|
|
{ |
679 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud3->get_lien_topologie(); |
680 |
|
|
if (aretemaille[are->get_id()]==true) |
681 |
|
|
{ |
682 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud3,noeud2,TRIANGULATION); |
683 |
|
|
are->get_lien_maillage()->ajouter(seg); |
684 |
|
|
} |
685 |
|
|
} |
686 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==1) |
687 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==0) |
688 |
|
|
{ |
689 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie(); |
690 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud2->get_lien_topologie(); |
691 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
692 |
|
|
{ |
693 |
|
|
if (aretemaille[are->get_id()]==true) |
694 |
|
|
{ |
695 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud2,TRIANGULATION); |
696 |
|
|
are->get_lien_maillage()->ajouter(seg); |
697 |
|
|
} |
698 |
|
|
} |
699 |
|
|
} |
700 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==1) |
701 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==0) |
702 |
|
|
{ |
703 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie(); |
704 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud3->get_lien_topologie(); |
705 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
706 |
|
|
{ |
707 |
|
|
if (aretemaille[are->get_id()]==true) |
708 |
|
|
{ |
709 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud3,TRIANGULATION); |
710 |
|
|
are->get_lien_maillage()->ajouter(seg); |
711 |
|
|
} |
712 |
|
|
} |
713 |
|
|
} |
714 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==1) |
715 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==0) |
716 |
|
|
{ |
717 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud2->get_lien_topologie(); |
718 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud1->get_lien_topologie(); |
719 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
720 |
|
|
{ |
721 |
|
|
if (aretemaille[are->get_id()]==true) |
722 |
|
|
{ |
723 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud2,noeud1,TRIANGULATION); |
724 |
|
|
are->get_lien_maillage()->ajouter(seg); |
725 |
|
|
} |
726 |
|
|
} |
727 |
|
|
} |
728 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==1) |
729 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==0) |
730 |
|
|
{ |
731 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud2->get_lien_topologie(); |
732 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud3->get_lien_topologie(); |
733 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
734 |
|
|
{ |
735 |
|
|
if (aretemaille[are->get_id()]==true) |
736 |
|
|
{ |
737 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud2,noeud3,TRIANGULATION); |
738 |
|
|
are->get_lien_maillage()->ajouter(seg); |
739 |
|
|
} |
740 |
|
|
} |
741 |
|
|
} |
742 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==1) |
743 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==0) |
744 |
|
|
{ |
745 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud3->get_lien_topologie(); |
746 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud1->get_lien_topologie(); |
747 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
748 |
|
|
{ |
749 |
|
|
if (aretemaille[are->get_id()]==true) |
750 |
|
|
{ |
751 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud3,noeud1,TRIANGULATION); |
752 |
|
|
are->get_lien_maillage()->ajouter(seg); |
753 |
|
|
} |
754 |
|
|
} |
755 |
|
|
} |
756 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==1) |
757 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==0) |
758 |
|
|
{ |
759 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud3->get_lien_topologie(); |
760 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud2->get_lien_topologie(); |
761 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
762 |
|
|
{ |
763 |
|
|
if (aretemaille[are->get_id()]==true) |
764 |
|
|
{ |
765 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud3,noeud2,TRIANGULATION); |
766 |
|
|
are->get_lien_maillage()->ajouter(seg); |
767 |
|
|
} |
768 |
|
|
} |
769 |
francois |
371 |
}*/ |
770 |
francois |
283 |
} |
771 |
francois |
525 |
if (mode>1) |
772 |
|
|
{ |
773 |
francois |
353 |
TPL_MAP_ENTITE<MG_ARETE*>::ITERATEUR it2; |
774 |
|
|
for (MG_ARETE* are=listare.get_premier(it2);are!=NULL;are=listare.get_suivant(it2)) |
775 |
|
|
{ |
776 |
|
|
if (are->get_lien_maillage()->get_nb()==0) |
777 |
|
|
{ |
778 |
francois |
371 |
unsigned long id=are->get_id(); |
779 |
|
|
MG_NOEUD* nodep=(MG_NOEUD*)are->get_cosommet1()->get_sommet()->get_lien_maillage()->get(0); |
780 |
|
|
MG_NOEUD* noarr=(MG_NOEUD*)are->get_cosommet2()->get_sommet()->get_lien_maillage()->get(0); |
781 |
|
|
std::map<double,NOEUDARETE,less<double> >::iterator it=areteamaille[id].begin(); |
782 |
|
|
MG_NOEUD* noeudcourant=nodep; |
783 |
|
|
while (it!=areteamaille[id].end()) |
784 |
|
|
{ |
785 |
|
|
MG_NOEUD* noeud=(*it).second.no; |
786 |
francois |
525 |
//MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeudcourant,noeud,TRIANGULATION); |
787 |
|
|
MG_SEGMENT* seg=mai->get_mg_segment(noeudcourant->get_id(),noeud->get_id()); |
788 |
|
|
seg->change_lien_topologie(are); |
789 |
francois |
371 |
noeudcourant=noeud; |
790 |
|
|
it++; |
791 |
|
|
} |
792 |
francois |
525 |
//MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeudcourant,noarr,TRIANGULATION); |
793 |
|
|
MG_SEGMENT* seg=mai->get_mg_segment(noeudcourant->get_id(),noarr->get_id()); |
794 |
|
|
seg->change_lien_topologie(are); |
795 |
francois |
353 |
} |
796 |
|
|
} |
797 |
francois |
525 |
|
798 |
|
|
} |
799 |
francois |
283 |
} |
800 |
|
|
|
801 |
|
|
#endif |