1 |
francois |
1158 |
//####//------------------------------------------------------------ |
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 |
|
|
//####// occ_surface.cpp |
15 |
|
|
//####// |
16 |
|
|
//####//------------------------------------------------------------ |
17 |
|
|
//####//------------------------------------------------------------ |
18 |
|
|
//####// COPYRIGHT 2000-2024 |
19 |
|
|
//####// jeu 13 jun 2024 11:58:54 EDT |
20 |
|
|
//####//------------------------------------------------------------ |
21 |
|
|
//####//------------------------------------------------------------ |
22 |
francois |
283 |
|
23 |
|
|
#pragma hdrstop |
24 |
|
|
#include "gestionversion.h" |
25 |
|
|
#ifdef BREP_OCC |
26 |
|
|
|
27 |
|
|
#include "occ_surface.h" |
28 |
|
|
#include <gp_Pnt.hxx> |
29 |
|
|
#include <gp_Vec.hxx> |
30 |
|
|
#include "GeomAPI_ProjectPointOnSurf.hxx" |
31 |
|
|
#include <ShapeAnalysis_Surface.hxx> |
32 |
|
|
#include <BRep_Tool.hxx> |
33 |
|
|
#include <BRepAdaptor_Surface.hxx> |
34 |
|
|
#include <BRep_Tool.hxx> |
35 |
|
|
#include <Poly_Triangulation.hxx> |
36 |
|
|
#include <Geom_Plane.hxx> |
37 |
|
|
#include <gp_Pln.hxx> |
38 |
|
|
#include <Geom_CylindricalSurface.hxx> |
39 |
|
|
#include <gp_Cylinder.hxx> |
40 |
|
|
#include <Geom_ConicalSurface.hxx> |
41 |
|
|
#include <gp_Cone.hxx> |
42 |
|
|
#include <Geom_SphericalSurface.hxx> |
43 |
couturad |
818 |
#include <IGESSolid_SphericalSurface.hxx> |
44 |
francois |
283 |
#include <gp_Sphere.hxx> |
45 |
|
|
#include "Geom_ToroidalSurface.hxx" |
46 |
|
|
#include <gp_Torus.hxx> |
47 |
|
|
#include <Geom_BSplineSurface.hxx> |
48 |
|
|
#include <Geom_BezierSurface.hxx> |
49 |
|
|
#include <GeomConvert.hxx> |
50 |
|
|
#include <BRepBuilderAPI_NurbsConvert.hxx> |
51 |
|
|
#include <BRepLib_FindSurface.hxx> |
52 |
|
|
#include "mg_gestionnaire.h" |
53 |
|
|
#include "constantegeo.h" |
54 |
francois |
295 |
#include "ot_mathematique.h" |
55 |
couturad |
818 |
#include <Geom_RectangularTrimmedSurface.hxx> |
56 |
|
|
#include <BRepClass_FaceClassifier.hxx> |
57 |
|
|
#include <gp_Pnt2d.hxx> |
58 |
couturad |
825 |
#include <Geom_SurfaceOfRevolution.hxx> |
59 |
francois |
283 |
|
60 |
|
|
#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 |
couturad |
906 |
OCC_SURFACE::OCC_SURFACE(unsigned long num, TopoDS_Face srf, OCC_FONCTION* fonc):MG_SURFACE(num),face(srf), fonction1(fonc) |
75 |
francois |
283 |
{ |
76 |
francois |
1037 |
surface=BRep_Tool::Surface(face); |
77 |
francois |
820 |
//Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
78 |
|
|
Handle(Standard_Type) type=surface->DynamicType(); |
79 |
|
|
if(type==STANDARD_TYPE(Geom_RectangularTrimmedSurface)) |
80 |
|
|
{ |
81 |
|
|
Handle(Geom_RectangularTrimmedSurface) RTSurface = Handle(Geom_RectangularTrimmedSurface)::DownCast(surface); |
82 |
|
|
surface = RTSurface->BasisSurface(); |
83 |
|
|
} |
84 |
francois |
283 |
double u1; |
85 |
|
|
double u2; |
86 |
|
|
double v1; |
87 |
|
|
double v2; |
88 |
|
|
surface->Bounds(u1,u2,v1, v2); |
89 |
|
|
u_min=u1; |
90 |
|
|
u_max=u2; |
91 |
|
|
v_min=v1; |
92 |
|
|
v_max=v2; |
93 |
francois |
1025 |
estperiodeu=surface->IsUClosed(); |
94 |
|
|
estperiodev=surface->IsVClosed(); |
95 |
|
|
if (surface->IsUPeriodic()) periode_u=surface->UPeriod(); |
96 |
|
|
else if (surface->IsUClosed()) periode_u= u_max-u_min; |
97 |
|
|
else periode_u=0; |
98 |
|
|
if (surface->IsVPeriodic()) periode_v=surface->VPeriod(); |
99 |
|
|
else if (surface->IsVClosed()) periode_v= v_max-v_min; |
100 |
|
|
else periode_v=0; |
101 |
|
|
if (type==STANDARD_TYPE(Geom_BSplineSurface)) |
102 |
|
|
analyse_bspline(); |
103 |
|
|
|
104 |
couturad |
906 |
//************************************************************** |
105 |
|
|
//************************************************************** |
106 |
francois |
283 |
|
107 |
|
|
} |
108 |
|
|
|
109 |
couturad |
906 |
OCC_SURFACE::OCC_SURFACE(TopoDS_Face srf, OCC_FONCTION* fonc):MG_SURFACE(),face(srf), fonction1(fonc) |
110 |
francois |
283 |
{ |
111 |
francois |
820 |
//Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
112 |
|
|
surface=BRep_Tool::Surface(face); |
113 |
|
|
Handle(Standard_Type) type=surface->DynamicType(); |
114 |
|
|
if(type==STANDARD_TYPE(Geom_RectangularTrimmedSurface)) |
115 |
|
|
{ |
116 |
|
|
Handle(Geom_RectangularTrimmedSurface) RTSurface = Handle(Geom_RectangularTrimmedSurface)::DownCast(surface); |
117 |
|
|
surface = RTSurface->BasisSurface(); |
118 |
|
|
} |
119 |
francois |
283 |
double u1; |
120 |
|
|
double u2; |
121 |
|
|
double v1; |
122 |
|
|
double v2; |
123 |
|
|
surface->Bounds(u1,u2,v1, v2); |
124 |
|
|
u_min=u1; |
125 |
|
|
u_max=u2; |
126 |
|
|
v_min=v1; |
127 |
|
|
v_max=v2; |
128 |
francois |
1025 |
estperiodeu=surface->IsUClosed(); |
129 |
|
|
estperiodev=surface->IsVClosed(); |
130 |
|
|
if (surface->IsUPeriodic()) periode_u=surface->UPeriod(); |
131 |
|
|
else if (surface->IsUClosed()) periode_u= u_max-u_min; |
132 |
|
|
else periode_u=0; |
133 |
|
|
if (surface->IsVPeriodic()) periode_v=surface->VPeriod(); |
134 |
|
|
else if (surface->IsVClosed()) periode_v= v_max-v_min; |
135 |
|
|
else periode_v=0; |
136 |
|
|
if (type==STANDARD_TYPE(Geom_BSplineSurface)) |
137 |
|
|
analyse_bspline(); |
138 |
couturad |
906 |
//************************************************************** |
139 |
|
|
//************************************************************** |
140 |
|
|
|
141 |
|
|
|
142 |
francois |
283 |
} |
143 |
|
|
|
144 |
|
|
OCC_SURFACE::OCC_SURFACE(OCC_SURFACE& mdd):MG_SURFACE(mdd),face(mdd.face), fonction1(mdd.fonction1) |
145 |
|
|
{ |
146 |
francois |
820 |
//Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
147 |
|
|
surface=BRep_Tool::Surface(face); |
148 |
|
|
Handle(Standard_Type) type=surface->DynamicType(); |
149 |
|
|
if(type==STANDARD_TYPE(Geom_RectangularTrimmedSurface)) |
150 |
|
|
{ |
151 |
|
|
Handle(Geom_RectangularTrimmedSurface) RTSurface = Handle(Geom_RectangularTrimmedSurface)::DownCast(surface); |
152 |
|
|
surface = RTSurface->BasisSurface(); |
153 |
|
|
} |
154 |
francois |
283 |
u_min=mdd.get_umin(); |
155 |
|
|
u_max=mdd.get_umax(); |
156 |
|
|
v_min=mdd.get_vmin(); |
157 |
|
|
v_max=mdd.get_vmax(); |
158 |
francois |
1025 |
estperiodeu=mdd.estperiodeu; |
159 |
|
|
estperiodev=mdd.estperiodev; |
160 |
|
|
periode_u=mdd.periode_u; |
161 |
|
|
periode_v=mdd.periode_v; |
162 |
francois |
283 |
} |
163 |
|
|
OCC_SURFACE::~OCC_SURFACE() |
164 |
|
|
{ |
165 |
|
|
} |
166 |
|
|
void OCC_SURFACE::evaluer(double *uv,double *xyz) |
167 |
|
|
{ |
168 |
|
|
|
169 |
francois |
820 |
//const Handle(Geom_Surface) &surface=BRep_Tool::Surface(face); |
170 |
francois |
283 |
gp_Pnt P; |
171 |
|
|
double u=uv[0]; |
172 |
|
|
double v=uv[1]; |
173 |
|
|
|
174 |
|
|
surface->D0(u,v,P); |
175 |
|
|
|
176 |
|
|
xyz[0]=P.X(); |
177 |
|
|
xyz[1]=P.Y(); |
178 |
|
|
xyz[2]=P.Z(); |
179 |
|
|
} |
180 |
|
|
void OCC_SURFACE::deriver(double *uv,double *xyzdu, double *xyzdv) |
181 |
|
|
{ |
182 |
francois |
820 |
//Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
183 |
francois |
283 |
double u=uv[0]; |
184 |
|
|
double v=uv[1]; |
185 |
|
|
gp_Vec D1U; |
186 |
|
|
gp_Vec D1V; |
187 |
|
|
gp_Pnt P; |
188 |
|
|
|
189 |
|
|
surface->D1(u,v,P,D1U,D1V); |
190 |
|
|
xyzdu[0]=D1U.X(); |
191 |
|
|
xyzdu[1]=D1U.Y(); |
192 |
|
|
xyzdu[2]=D1U.Z(); |
193 |
|
|
|
194 |
|
|
xyzdv[0]=D1V.X(); |
195 |
|
|
xyzdv[1]=D1V.Y(); |
196 |
|
|
xyzdv[2]=D1V.Z(); |
197 |
|
|
|
198 |
|
|
} |
199 |
|
|
void OCC_SURFACE::deriver_seconde(double *uv,double* xyzduu,double* xyzduv,double* xyzdvv,double *xyz, double *xyzdu, double *xyzdv) |
200 |
|
|
{ |
201 |
francois |
820 |
//Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
202 |
francois |
283 |
double u=uv[0]; |
203 |
|
|
double v=uv[1]; |
204 |
|
|
gp_Pnt P; |
205 |
|
|
gp_Vec D1U; |
206 |
|
|
gp_Vec D1V; |
207 |
|
|
gp_Vec D2U; |
208 |
|
|
gp_Vec D2V; |
209 |
|
|
gp_Vec D2UV; |
210 |
|
|
|
211 |
|
|
surface->D2(u,v,P,D1U,D1V,D2U,D2V,D2UV); |
212 |
|
|
|
213 |
|
|
xyz[0]=P.X(); |
214 |
|
|
xyz[1]=P.Y(); |
215 |
|
|
xyz[2]=P.Z(); |
216 |
|
|
|
217 |
|
|
xyzdu[0]=D1U.X(); |
218 |
|
|
xyzdu[1]=D1U.Y(); |
219 |
|
|
xyzdu[2]=D1U.Z(); |
220 |
|
|
|
221 |
|
|
xyzdv[0]=D1V.X(); |
222 |
|
|
xyzdv[1]=D1V.Y(); |
223 |
|
|
xyzdv[2]=D1V.Z(); |
224 |
|
|
|
225 |
|
|
xyzduu[0]=D2U.X(); |
226 |
|
|
xyzduu[1]=D2U.Y(); |
227 |
|
|
xyzduu[2]=D2U.Z(); |
228 |
|
|
|
229 |
|
|
xyzdvv[0]=D2V.X(); |
230 |
|
|
xyzdvv[1]=D2V.Y(); |
231 |
|
|
xyzdvv[2]=D2V.Z(); |
232 |
|
|
|
233 |
|
|
xyzduv[0]=D2UV.X(); |
234 |
|
|
xyzduv[1]=D2UV.Y(); |
235 |
|
|
xyzduv[2]=D2UV.Z(); |
236 |
|
|
|
237 |
|
|
} |
238 |
|
|
|
239 |
|
|
void OCC_SURFACE::inverser(double *uv,double *xyz,double precision) |
240 |
|
|
{ |
241 |
francois |
820 |
// Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
242 |
francois |
283 |
double u=xyz[0]; |
243 |
|
|
double v=xyz[1]; |
244 |
|
|
double w=xyz[2]; |
245 |
|
|
gp_Pnt P(u,v,w); |
246 |
|
|
|
247 |
|
|
//ShapeAnalysis_Surface SAS(surface); |
248 |
|
|
//gp_Pnt2d pnt2d=SAS.ValueOfUV(P, precision); |
249 |
|
|
GeomAPI_ProjectPointOnSurf PPS(P,surface, precision); |
250 |
francois |
1037 |
double dist=PPS.LowerDistance(); |
251 |
|
|
if (dist>precision) |
252 |
|
|
inverser2(uv,xyz,precision); |
253 |
|
|
else |
254 |
|
|
{ |
255 |
|
|
double UU, VV; |
256 |
|
|
PPS.LowerDistanceParameters(UU,VV); |
257 |
|
|
uv[0]=UU; |
258 |
|
|
uv[1]=VV; |
259 |
|
|
} |
260 |
francois |
283 |
} |
261 |
couturad |
906 |
|
262 |
|
|
bool OCC_SURFACE::est_sur_surface(double* xyz, double precision) |
263 |
|
|
{ |
264 |
couturad |
908 |
#ifdef ALL_OCC |
265 |
couturad |
906 |
GeomAPI_ProjectPointOnSurf projecteur; |
266 |
|
|
double u0, u1; |
267 |
|
|
double v0, v1; |
268 |
|
|
ShapeAnalysis::GetFaceUVBounds(face,u0,u1,v0,v1); |
269 |
|
|
gp_Pnt point(xyz[0],xyz[1],xyz[2]); |
270 |
|
|
projecteur.Init(point,surface,u0,u1,v0,v1); |
271 |
|
|
if(projecteur.NbPoints()==0) return false; |
272 |
|
|
if(projecteur.LowerDistance()<precision) return true; |
273 |
|
|
return false; |
274 |
couturad |
908 |
#else |
275 |
|
|
std::cerr << "OCC_SURFACE::est_sur_surface(double* xyz, double precision) --> Non disponible" << std::endl; |
276 |
|
|
#endif |
277 |
|
|
|
278 |
couturad |
906 |
} |
279 |
|
|
|
280 |
francois |
283 |
int OCC_SURFACE::est_periodique_u(void) |
281 |
|
|
{ |
282 |
francois |
820 |
//Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
283 |
francois |
1025 |
//return surface->IsUClosed(); |
284 |
|
|
return estperiodeu; |
285 |
francois |
283 |
} |
286 |
|
|
|
287 |
|
|
int OCC_SURFACE::est_periodique_v(void) |
288 |
|
|
{ |
289 |
francois |
820 |
//Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
290 |
francois |
1025 |
return estperiodev; |
291 |
francois |
283 |
} |
292 |
|
|
double OCC_SURFACE::get_periode_u(void) |
293 |
|
|
{ |
294 |
francois |
820 |
//Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
295 |
francois |
1025 |
//if (surface->IsUPeriodic()) return surface->UPeriod(); |
296 |
|
|
//if (surface->IsUClosed()) return u_max-u_min; |
297 |
|
|
//return 1; |
298 |
|
|
return periode_u; |
299 |
francois |
283 |
} |
300 |
|
|
|
301 |
|
|
double OCC_SURFACE::get_periode_v(void) |
302 |
|
|
{ |
303 |
francois |
820 |
//Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
304 |
francois |
1025 |
//if (surface->IsVPeriodic()) return surface->VPeriod(); |
305 |
|
|
//if (surface->IsVClosed()) return v_max-v_min; |
306 |
|
|
//return 0; |
307 |
|
|
return periode_v; |
308 |
francois |
731 |
|
309 |
francois |
283 |
} |
310 |
couturad |
814 |
|
311 |
francois |
763 |
void OCC_SURFACE::enregistrer(std::ostream& o,double version) |
312 |
francois |
283 |
{ |
313 |
couturad |
906 |
if(fonction1->get_version()=="OCCV2017") |
314 |
|
|
{ |
315 |
|
|
o <<"%"<<get_id()<< "=SURFACE_OCC("<< get_idoriginal() << ");" << std::endl; |
316 |
|
|
} |
317 |
|
|
else |
318 |
|
|
{ |
319 |
|
|
o <<"%"<<get_id()<< "=SURFACE_OCC("<< fonction1->GetID(face)<< ");" << std::endl; |
320 |
|
|
} |
321 |
francois |
283 |
} |
322 |
|
|
int OCC_SURFACE::get_type_geometrique(TPL_LISTE_ENTITE<double> ¶m) |
323 |
|
|
{ |
324 |
francois |
820 |
//Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
325 |
francois |
283 |
Handle(Standard_Type) type=surface->DynamicType(); |
326 |
|
|
if (type==STANDARD_TYPE(Geom_Plane)) |
327 |
|
|
{ |
328 |
|
|
Handle(Geom_Plane) Pln=Handle(Geom_Plane)::DownCast(surface); |
329 |
|
|
gp_Pln plan=Pln->Pln(); |
330 |
|
|
|
331 |
|
|
double origine[3]; |
332 |
|
|
gp_Pnt centre=plan.Location(); |
333 |
|
|
|
334 |
|
|
origine[0]=centre.X(); |
335 |
|
|
origine[1]=centre.Y(); |
336 |
|
|
origine[2]=centre.Z(); |
337 |
|
|
|
338 |
|
|
double normal[3]; |
339 |
|
|
gp_Ax1 axe=plan.Axis(); |
340 |
|
|
gp_Dir direction=axe.Direction(); |
341 |
|
|
|
342 |
|
|
normal[0]=direction.X(); |
343 |
|
|
normal[1]=direction.Y(); |
344 |
|
|
normal[2]=direction.Z(); |
345 |
|
|
|
346 |
|
|
param.ajouter(origine[0]); |
347 |
|
|
param.ajouter(origine[1]); |
348 |
|
|
param.ajouter(origine[2]); |
349 |
|
|
param.ajouter(normal[0]); |
350 |
|
|
param.ajouter(normal[1]); |
351 |
|
|
param.ajouter(normal[2]); |
352 |
|
|
|
353 |
francois |
1149 |
return GEOMETRIE::CONST::Co_PLAN; |
354 |
francois |
283 |
} |
355 |
|
|
if (type==STANDARD_TYPE(Geom_CylindricalSurface)) |
356 |
|
|
{ |
357 |
|
|
Handle(Geom_CylindricalSurface) cylinder=Handle(Geom_CylindricalSurface)::DownCast(surface); |
358 |
|
|
gp_Cylinder cylin=cylinder->Cylinder(); |
359 |
|
|
|
360 |
|
|
double origine[3]; |
361 |
|
|
gp_Pnt centre=cylin.Location(); |
362 |
|
|
origine[0]=centre.X(); |
363 |
|
|
origine[1]=centre.Y(); |
364 |
|
|
origine[2]=centre.Z(); |
365 |
francois |
886 |
double directionX[3]; |
366 |
francois |
283 |
double direction[3]; |
367 |
|
|
double rayon; |
368 |
|
|
rayon=cylin.Radius(); |
369 |
|
|
|
370 |
francois |
886 |
gp_Ax3 repere=cylin.Position(); |
371 |
|
|
gp_Dir dirX=repere.XDirection(); |
372 |
|
|
gp_Dir dirZ=repere.Direction(); |
373 |
|
|
directionX[0]=dirX.X(); |
374 |
|
|
directionX[1]=dirX.Y(); |
375 |
|
|
directionX[2]=dirX.Z(); |
376 |
|
|
direction[0]=dirZ.X(); |
377 |
|
|
direction[1]=dirZ.Y(); |
378 |
|
|
direction[2]=dirZ.Z(); |
379 |
|
|
|
380 |
|
|
|
381 |
|
|
|
382 |
francois |
283 |
param.ajouter(origine[0]); |
383 |
|
|
param.ajouter(origine[1]); |
384 |
|
|
param.ajouter(origine[2]); |
385 |
francois |
886 |
param.ajouter(directionX[0]); |
386 |
|
|
param.ajouter(directionX[1]); |
387 |
|
|
param.ajouter(directionX[2]); |
388 |
francois |
283 |
param.ajouter(direction[0]); |
389 |
|
|
param.ajouter(direction[1]); |
390 |
|
|
param.ajouter(direction[2]); |
391 |
|
|
param.ajouter(rayon); |
392 |
francois |
886 |
param.ajouter(rayon); |
393 |
francois |
283 |
|
394 |
francois |
1149 |
return GEOMETRIE::CONST::Co_CYLINDRE; |
395 |
francois |
283 |
} |
396 |
|
|
if (type==STANDARD_TYPE(Geom_ConicalSurface)) |
397 |
|
|
{ |
398 |
|
|
Handle(Geom_ConicalSurface) cone=Handle(Geom_ConicalSurface)::DownCast(surface); |
399 |
|
|
gp_Cone con=cone->Cone(); |
400 |
|
|
|
401 |
|
|
double origine[3]; |
402 |
|
|
gp_Pnt centre=con.Location(); |
403 |
|
|
origine[0]=centre.X(); |
404 |
|
|
origine[1]=centre.Y(); |
405 |
|
|
origine[2]=centre.Z(); |
406 |
|
|
double direction[3]; |
407 |
francois |
886 |
double directionX[3]; |
408 |
francois |
283 |
double rayon; |
409 |
|
|
rayon=con.RefRadius(); |
410 |
|
|
double angle; |
411 |
|
|
angle=con.SemiAngle(); |
412 |
francois |
886 |
|
413 |
|
|
gp_Ax3 repere=con.Position(); |
414 |
|
|
gp_Dir dirX=repere.XDirection(); |
415 |
|
|
gp_Dir dirZ=repere.Direction(); |
416 |
|
|
directionX[0]=dirX.X(); |
417 |
|
|
directionX[1]=dirX.Y(); |
418 |
|
|
directionX[2]=dirX.Z(); |
419 |
|
|
direction[0]=dirZ.X(); |
420 |
|
|
direction[1]=dirZ.Y(); |
421 |
|
|
direction[2]=dirZ.Z(); |
422 |
francois |
283 |
param.ajouter(origine[0]); |
423 |
|
|
param.ajouter(origine[1]); |
424 |
|
|
param.ajouter(origine[2]); |
425 |
francois |
886 |
param.ajouter(directionX[0]); |
426 |
|
|
param.ajouter(directionX[1]); |
427 |
|
|
param.ajouter(directionX[2]); |
428 |
|
|
param.ajouter(direction[0]); |
429 |
francois |
283 |
param.ajouter(direction[1]); |
430 |
|
|
param.ajouter(direction[2]); |
431 |
|
|
param.ajouter(rayon); |
432 |
francois |
886 |
param.ajouter(rayon); |
433 |
|
|
param.ajouter(cos(angle)); |
434 |
|
|
param.ajouter(sin(angle)); |
435 |
francois |
283 |
|
436 |
francois |
1149 |
return GEOMETRIE::CONST::Co_CONE; |
437 |
francois |
283 |
|
438 |
|
|
} |
439 |
|
|
if (type==STANDARD_TYPE(Geom_SphericalSurface)) |
440 |
|
|
{ |
441 |
|
|
Handle(Geom_SphericalSurface) sphere=Handle(Geom_SphericalSurface)::DownCast(surface); |
442 |
|
|
gp_Sphere sph=sphere->Sphere(); |
443 |
|
|
|
444 |
|
|
double origine[3]; |
445 |
|
|
gp_Pnt centre=sph.Location(); |
446 |
|
|
origine[0]=centre.X(); |
447 |
|
|
origine[1]=centre.Y(); |
448 |
|
|
origine[2]=centre.Z(); |
449 |
|
|
double rayon; |
450 |
|
|
rayon=sph.Radius(); |
451 |
|
|
param.ajouter(origine[0]); |
452 |
|
|
param.ajouter(origine[1]); |
453 |
|
|
param.ajouter(origine[2]); |
454 |
|
|
param.ajouter(rayon); |
455 |
|
|
|
456 |
francois |
1149 |
return GEOMETRIE::CONST::Co_SPHERE; |
457 |
francois |
283 |
|
458 |
|
|
} |
459 |
|
|
if (type==STANDARD_TYPE(Geom_ToroidalSurface)) |
460 |
|
|
{ |
461 |
|
|
Handle(Geom_ToroidalSurface) tore=Handle(Geom_ToroidalSurface)::DownCast(surface); |
462 |
|
|
gp_Torus tro=tore->Torus(); |
463 |
|
|
double origine[3]; |
464 |
|
|
gp_Pnt centre=tro.Location(); |
465 |
|
|
origine[0]=centre.X(); |
466 |
|
|
origine[1]=centre.Y(); |
467 |
|
|
origine[2]=centre.Z(); |
468 |
|
|
double direction[3]; |
469 |
francois |
886 |
double directionX[3]; |
470 |
francois |
283 |
double Grayon; |
471 |
|
|
Grayon=tro.MajorRadius(); |
472 |
|
|
double Prayon; |
473 |
|
|
Prayon=tro.MinorRadius(); |
474 |
francois |
886 |
gp_Ax3 repere=tro.Position(); |
475 |
|
|
gp_Dir dirX=repere.XDirection(); |
476 |
|
|
gp_Dir dirZ=repere.Direction(); |
477 |
|
|
directionX[0]=dirX.X(); |
478 |
|
|
directionX[1]=dirX.Y(); |
479 |
|
|
directionX[2]=dirX.Z(); |
480 |
|
|
direction[0]=dirZ.X(); |
481 |
|
|
direction[1]=dirZ.Y(); |
482 |
|
|
direction[2]=dirZ.Z(); |
483 |
francois |
283 |
param.ajouter(origine[0]); |
484 |
|
|
param.ajouter(origine[1]); |
485 |
|
|
param.ajouter(origine[2]); |
486 |
francois |
886 |
param.ajouter(directionX[0]); |
487 |
|
|
param.ajouter(directionX[1]); |
488 |
|
|
param.ajouter(directionX[2]); |
489 |
|
|
param.ajouter(direction[0]); |
490 |
francois |
283 |
param.ajouter(direction[1]); |
491 |
|
|
param.ajouter(direction[2]); |
492 |
|
|
param.ajouter(Grayon); |
493 |
|
|
param.ajouter(Prayon); |
494 |
|
|
|
495 |
francois |
1149 |
return GEOMETRIE::CONST::Co_TORE; |
496 |
francois |
283 |
|
497 |
|
|
} |
498 |
|
|
if (type==STANDARD_TYPE(Geom_BSplineSurface)) |
499 |
|
|
{ |
500 |
|
|
Handle(Geom_BSplineSurface) bspline=Handle(Geom_BSplineSurface)::DownCast(surface); |
501 |
|
|
|
502 |
|
|
int nb_Uknot=bspline->NbUKnots(); |
503 |
|
|
for (int i=1; i<=nb_Uknot; i++) |
504 |
|
|
{ |
505 |
|
|
double Uvaleur=bspline->UKnot(i); |
506 |
|
|
param.ajouter(Uvaleur); |
507 |
|
|
} |
508 |
|
|
int nb_Vknot=bspline->NbVKnots(); |
509 |
|
|
for (int j=1; j<=nb_Vknot; j++) |
510 |
|
|
{ |
511 |
|
|
double Vvaleur=bspline->VKnot(j); |
512 |
|
|
param.ajouter(Vvaleur); |
513 |
|
|
} |
514 |
|
|
gp_Pnt pctr; |
515 |
|
|
double poids; |
516 |
|
|
for (int u=1; u<=bspline->NbUPoles(); u++) |
517 |
|
|
for (int v=1; v<=bspline->NbVPoles(); v++) |
518 |
|
|
{ |
519 |
|
|
pctr=bspline->Pole(u, v); |
520 |
|
|
|
521 |
|
|
param.ajouter(pctr.X()); |
522 |
|
|
param.ajouter(pctr.Y()); |
523 |
|
|
param.ajouter(pctr.Z()); |
524 |
|
|
|
525 |
|
|
poids=bspline->Weight(u, v); |
526 |
|
|
param.ajouter(poids); |
527 |
|
|
} |
528 |
|
|
|
529 |
|
|
double uDegree=bspline->UDegree(); |
530 |
|
|
param.ajouter(uDegree); |
531 |
|
|
double vDegree=bspline->VDegree(); |
532 |
|
|
param.ajouter(vDegree); |
533 |
francois |
1149 |
return GEOMETRIE::CONST::Co_BSPLINES; |
534 |
francois |
283 |
} |
535 |
francois |
1075 |
return 0; |
536 |
francois |
283 |
} |
537 |
|
|
void OCC_SURFACE::get_param_NURBS(int& indx_premier_ptctr,TPL_LISTE_ENTITE<double> ¶m) |
538 |
|
|
{ |
539 |
|
|
//Conversion of the complete geometry of a shape into |
540 |
|
|
//NURBS geometry |
541 |
|
|
BRepBuilderAPI_NurbsConvert NURBS(face); |
542 |
|
|
Handle(Geom_Surface) surface=BRepLib_FindSurface(NURBS).Surface(); |
543 |
|
|
Handle(Geom_BSplineSurface) bspline=GeomConvert::SurfaceToBSplineSurface(surface) ; |
544 |
|
|
|
545 |
|
|
param.ajouter(2); |
546 |
|
|
param.ajouter( bspline->UDegree()+1); |
547 |
|
|
param.ajouter(bspline->VDegree()+1); |
548 |
|
|
|
549 |
|
|
param.ajouter(bspline->NbUPoles()); |
550 |
|
|
param.ajouter(bspline->NbVPoles()); |
551 |
|
|
|
552 |
|
|
for (unsigned int i=1;i<=bspline->NbUKnots();i++) |
553 |
|
|
{ |
554 |
|
|
param.ajouter(bspline->UKnot(i)); |
555 |
|
|
} |
556 |
|
|
//This present the knot vector in the v-direction |
557 |
|
|
for (unsigned int j=1;j<=bspline->NbVKnots();j++) |
558 |
|
|
{ |
559 |
|
|
param.ajouter(bspline->VKnot(j)); |
560 |
|
|
} |
561 |
francois |
363 |
for (int v=1;v<=bspline->NbVPoles();v++) |
562 |
francois |
283 |
{ |
563 |
francois |
363 |
for (int u=1;u<=bspline->NbUPoles();u++) |
564 |
francois |
283 |
{ |
565 |
|
|
double w=bspline->Weight(u,v); |
566 |
|
|
gp_Pnt point=bspline->Pole(u, v); |
567 |
|
|
double x=point.X(); |
568 |
|
|
double y=point.Y(); |
569 |
|
|
double z=point.Z(); |
570 |
|
|
param.ajouter(x); |
571 |
|
|
param.ajouter(y); |
572 |
|
|
param.ajouter(z); |
573 |
|
|
param.ajouter(w); |
574 |
|
|
} |
575 |
|
|
|
576 |
|
|
} |
577 |
|
|
indx_premier_ptctr=5+bspline->NbUKnots()+bspline->NbVKnots(); |
578 |
|
|
|
579 |
|
|
|
580 |
|
|
|
581 |
|
|
|
582 |
|
|
|
583 |
|
|
} |
584 |
|
|
|
585 |
francois |
1095 |
void OCC_SURFACE::get_echantillonnage(int numechantillon,std::vector<double> &tab,double eps,double angle_dev) |
586 |
|
|
{ |
587 |
|
|
BRepMesh_IncrementalMesh(face,eps,angle_dev); |
588 |
|
|
TopLoc_Location L; |
589 |
|
|
Handle (Poly_Triangulation) occtri=BRep_Tool::Triangulation(face,L); |
590 |
|
|
if (occtri.IsNull()) |
591 |
|
|
{ |
592 |
|
|
BRepMesh_IncrementalMesh(face,eps); |
593 |
|
|
occtri=BRep_Tool::Triangulation(face,L); |
594 |
|
|
} |
595 |
|
|
int nbmaille=occtri->NbTriangles(); |
596 |
|
|
const Poly_Array1OfTriangle& triangles = occtri->Triangles(); |
597 |
|
|
const TColgp_Array1OfPnt2d& uvNodes = occtri->UVNodes(); |
598 |
|
|
int numechantillonpartri=sqrt(numechantillon*1.0/nbmaille)+1; |
599 |
|
|
for ( Standard_Integer i = 0; i < nbmaille; i++ ) |
600 |
|
|
{ |
601 |
|
|
int n1,n2,n3; |
602 |
|
|
Poly_Triangle triangle = triangles( i + 1 ); |
603 |
|
|
bool face_reversed = (face.Orientation() == TopAbs_REVERSED); |
604 |
|
|
if ( face_reversed ) |
605 |
|
|
triangle.Get( n1, n3, n2 ); |
606 |
|
|
else |
607 |
|
|
triangle.Get( n1, n2, n3 ); |
608 |
|
|
gp_Pnt2d p1=uvNodes(n1); |
609 |
|
|
double u1=p1.X(); |
610 |
|
|
double v1=p1.Y(); |
611 |
|
|
gp_Pnt2d p2=uvNodes(n2); |
612 |
|
|
double u2=p2.X(); |
613 |
|
|
double v2=p2.Y(); |
614 |
|
|
gp_Pnt2d p3=uvNodes(n3); |
615 |
|
|
double u3=p3.X(); |
616 |
|
|
double v3=p3.Y(); |
617 |
|
|
for (int ii=0;ii<numechantillonpartri;ii++) |
618 |
|
|
for (int jj=0;jj<numechantillonpartri;jj++) |
619 |
|
|
{ |
620 |
|
|
double ksi=(ii*1.0+0.5)/(double)numechantillonpartri; |
621 |
|
|
double eta=(jj*1.0+0.5)/(double)numechantillonpartri; |
622 |
francois |
1098 |
if (ksi+eta>0.999999999999) jj=numechantillonpartri; |
623 |
francois |
1095 |
else |
624 |
|
|
{ |
625 |
|
|
double u=ksi*u1+eta*u2+(1.-ksi-eta)*u3; |
626 |
|
|
double v=ksi*v1+eta*v2+(1.-ksi-eta)*v3; |
627 |
|
|
gp_Pnt P; |
628 |
|
|
surface->D0(u,v,P); |
629 |
|
|
tab.push_back(P.X()); |
630 |
|
|
tab.push_back(P.Y()); |
631 |
|
|
tab.push_back(P.Z()); |
632 |
|
|
tab.push_back(u); |
633 |
|
|
tab.push_back(v); |
634 |
|
|
} |
635 |
|
|
} |
636 |
|
|
|
637 |
|
|
|
638 |
|
|
} |
639 |
|
|
|
640 |
|
|
} |
641 |
|
|
|
642 |
|
|
|
643 |
|
|
|
644 |
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) |
645 |
francois |
283 |
{ |
646 |
francois |
353 |
TPL_MAP_ENTITE<MG_SOMMET*> listsom; |
647 |
|
|
TPL_MAP_ENTITE<MG_ARETE*> listare; |
648 |
francois |
371 |
//std::map<unsigned long,bool> aretemaille; |
649 |
couturad |
951 |
std::map<unsigned long,std::map<double,NOEUDARETE,std::less<double> >,std::less<unsigned long> > areteamaille; |
650 |
francois |
353 |
int nbboucle=mgface->get_nb_mg_boucle(); |
651 |
|
|
for (int i=0;i<nbboucle;i++) |
652 |
|
|
{ |
653 |
|
|
MG_BOUCLE* bou=mgface->get_mg_boucle(i); |
654 |
|
|
int nbarete=bou->get_nb_mg_coarete(); |
655 |
|
|
for (int j=0;j<nbarete;j++) |
656 |
|
|
{ |
657 |
|
|
MG_ARETE* are=bou->get_mg_coarete(j)->get_arete(); |
658 |
|
|
listare.ajouter(are); |
659 |
francois |
371 |
//bool amailler=true; |
660 |
|
|
//if (are->get_lien_maillage()->get_nb()>0) amailler=false; |
661 |
|
|
//aretemaille[are->get_id()]=amailler; |
662 |
francois |
353 |
listsom.ajouter(bou->get_mg_coarete(j)->get_arete()->get_cosommet1()->get_sommet()); |
663 |
francois |
371 |
listsom.ajouter(bou->get_mg_coarete(j)->get_arete()->get_cosommet2()->get_sommet()); |
664 |
couturad |
951 |
std::map<double,NOEUDARETE,std::less<double> > tmp; |
665 |
|
|
std::pair<unsigned long,std::map<double,NOEUDARETE,std::less<double> > > maptmp(are->get_id(),tmp); |
666 |
francois |
371 |
areteamaille.insert(maptmp); |
667 |
francois |
353 |
} |
668 |
|
|
} |
669 |
foucault |
569 |
|
670 |
|
|
|
671 |
francois |
283 |
TopLoc_Location L; |
672 |
|
|
Handle (Poly_Triangulation) pt=BRep_Tool::Triangulation(face,L); |
673 |
|
|
int nbnoeud=pt->NbNodes(); |
674 |
|
|
int nbmaille=pt->NbTriangles(); |
675 |
|
|
const TColgp_Array1OfPnt& nodes = pt->Nodes(); |
676 |
|
|
const Poly_Array1OfTriangle& triangles = pt->Triangles(); |
677 |
|
|
const TColgp_Array1OfPnt2d& uvNodes = pt->UVNodes(); |
678 |
francois |
295 |
std::vector<MG_NOEUD*> tabnoeud; |
679 |
francois |
283 |
for ( Standard_Integer i = 0; i < nbnoeud; i++ ) |
680 |
|
|
{ |
681 |
foucault |
569 |
gp_Pnt p1=nodes(i+1); |
682 |
|
|
double xx=p1.X(); |
683 |
|
|
double yy=p1.Y(); |
684 |
|
|
double zz=p1.Z(); |
685 |
|
|
double key=fabs(xx)+fabs(yy)+fabs(zz); |
686 |
|
|
MG_NOEUD* nvnoeud=NULL; |
687 |
|
|
if (mode>1) |
688 |
|
|
{ |
689 |
|
|
std::multimap<double,MG_NOEUD*,std::less<double> >::iterator it,itbas,ithaut; |
690 |
|
|
itbas=tabnoeudfus.lower_bound(key*0.99); |
691 |
|
|
ithaut=tabnoeudfus.upper_bound(key*1.1010101); |
692 |
|
|
for ( it=itbas ; it != ithaut; it++ ) |
693 |
|
|
{ |
694 |
|
|
MG_NOEUD* ntmp=(*it).second; |
695 |
|
|
double xtmp=ntmp->get_x(); |
696 |
|
|
double ytmp=ntmp->get_y(); |
697 |
|
|
double ztmp=ntmp->get_z(); |
698 |
|
|
OT_VECTEUR_3D vec(xtmp-xx,ytmp-yy,ztmp-zz); |
699 |
|
|
if (vec.get_longueur()<1e-6*eps) { |
700 |
|
|
nvnoeud=ntmp; |
701 |
|
|
break; |
702 |
|
|
} |
703 |
|
|
} |
704 |
|
|
} |
705 |
|
|
if (nvnoeud==NULL) |
706 |
|
|
{ |
707 |
|
|
MG_ELEMENT_TOPOLOGIQUE *topo=mgface; |
708 |
|
|
TPL_MAP_ENTITE<MG_SOMMET*>::ITERATEUR it1; |
709 |
|
|
for (MG_SOMMET* som=listsom.get_premier(it1);som!=NULL;som=listsom.get_suivant(it1)) |
710 |
|
|
{ |
711 |
|
|
double xyz[3]; |
712 |
|
|
som->get_point()->evaluer(xyz); |
713 |
|
|
OT_VECTEUR_3D vec(xyz[0]-xx,xyz[1]-yy,xyz[2]-zz); |
714 |
|
|
if (vec.get_longueur()<1e-6*eps) |
715 |
|
|
{ |
716 |
|
|
topo=som; |
717 |
|
|
break; |
718 |
francois |
283 |
|
719 |
foucault |
569 |
} |
720 |
|
|
} |
721 |
|
|
double param_t; |
722 |
|
|
if (topo==mgface) |
723 |
|
|
{ |
724 |
|
|
TPL_MAP_ENTITE<MG_ARETE*>::ITERATEUR it2; |
725 |
|
|
for (MG_ARETE* are=listare.get_premier(it2);are!=NULL;are=listare.get_suivant(it2)) |
726 |
|
|
{ |
727 |
|
|
double t; |
728 |
|
|
double xyz[3]={xx,yy,zz}; |
729 |
|
|
are->inverser(t,xyz); |
730 |
|
|
if (are->get_courbe()->est_periodique()) |
731 |
|
|
if (t< are->get_tmin()) t=t+are->get_courbe()->get_periode(); |
732 |
|
|
double xyztmp[3]; |
733 |
|
|
are->evaluer(t,xyztmp ); |
734 |
|
|
OT_VECTEUR_3D vec(xyz,xyztmp); |
735 |
|
|
if (vec.get_longueur()<1e-6*eps) |
736 |
|
|
if ((t>are->get_tmin()) && (t<are->get_tmax())) |
737 |
|
|
{ |
738 |
|
|
topo=are; |
739 |
|
|
param_t=t; |
740 |
|
|
break; |
741 |
|
|
} |
742 |
|
|
} |
743 |
|
|
} |
744 |
francois |
791 |
nvnoeud=new MG_NOEUD(topo,xx,yy,zz,MAGIC::ORIGINE::TRIANGULATION); |
745 |
foucault |
569 |
mai->ajouter_mg_noeud(nvnoeud); |
746 |
|
|
std::pair<double,MG_NOEUD*> tmp(key,nvnoeud); |
747 |
|
|
tabnoeudfus.insert(tmp); |
748 |
|
|
if (topo->get_dimension()==1) |
749 |
|
|
{ |
750 |
|
|
NOEUDARETE na; |
751 |
|
|
na.no=nvnoeud; |
752 |
|
|
na.are=(MG_ARETE*)topo; |
753 |
|
|
na.t=param_t; |
754 |
|
|
std::pair<double,NOEUDARETE> tmp(na.t,na); |
755 |
|
|
areteamaille[topo->get_id()].insert(tmp); |
756 |
|
|
} |
757 |
|
|
} |
758 |
francois |
283 |
|
759 |
foucault |
569 |
|
760 |
francois |
283 |
tabnoeud.insert(tabnoeud.end(),nvnoeud); |
761 |
|
|
} |
762 |
|
|
for ( Standard_Integer i = 0; i < nbmaille; i++ ) |
763 |
|
|
{ |
764 |
|
|
int n1,n2,n3; |
765 |
|
|
Poly_Triangle triangle = triangles( i + 1 ); |
766 |
|
|
bool face_reversed = (face.Orientation() == TopAbs_REVERSED); |
767 |
|
|
if ( face_reversed ) |
768 |
|
|
triangle.Get( n1, n3, n2 ); |
769 |
|
|
else |
770 |
|
|
triangle.Get( n1, n2, n3 ); |
771 |
francois |
525 |
MG_NOEUD* noeud1=tabnoeud[n1-1]; |
772 |
francois |
283 |
MG_NOEUD* noeud2=tabnoeud[n2-1]; |
773 |
|
|
MG_NOEUD* noeud3=tabnoeud[n3-1]; |
774 |
francois |
525 |
if (noeud1==noeud2) continue; |
775 |
|
|
if (noeud1==noeud3) continue; |
776 |
|
|
if (noeud2==noeud3) continue; |
777 |
francois |
791 |
mai->ajouter_mg_triangle(mgface,noeud1,noeud2,noeud3,MAGIC::ORIGINE::TRIANGULATION); |
778 |
francois |
525 |
/*if (noeud1->get_lien_topologie()->get_dimension()==0) |
779 |
francois |
353 |
{ |
780 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud1->get_lien_topologie(); |
781 |
|
|
som->get_lien_maillage()->ajouter(noeud1); |
782 |
|
|
} |
783 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==0) |
784 |
|
|
{ |
785 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud2->get_lien_topologie(); |
786 |
|
|
som->get_lien_maillage()->ajouter(noeud2); |
787 |
|
|
} |
788 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==0) |
789 |
|
|
{ |
790 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud3->get_lien_topologie(); |
791 |
|
|
som->get_lien_maillage()->ajouter(noeud3); |
792 |
francois |
525 |
}*/ |
793 |
francois |
371 |
/*if (noeud1->get_lien_topologie()==noeud2->get_lien_topologie()) |
794 |
francois |
353 |
if (noeud1->get_lien_topologie()->get_dimension()==1) |
795 |
|
|
{ |
796 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie(); |
797 |
|
|
if (aretemaille[are->get_id()]==true) |
798 |
|
|
{ |
799 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud2,TRIANGULATION); |
800 |
|
|
are->get_lien_maillage()->ajouter(seg); |
801 |
|
|
} |
802 |
|
|
} |
803 |
|
|
if (noeud1->get_lien_topologie()==noeud3->get_lien_topologie()) |
804 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==1) |
805 |
|
|
{ |
806 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie(); |
807 |
|
|
if (aretemaille[are->get_id()]==true) |
808 |
|
|
{ |
809 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud3,TRIANGULATION); |
810 |
|
|
are->get_lien_maillage()->ajouter(seg); |
811 |
|
|
} |
812 |
francois |
371 |
}#include <../gmsh/tutorial/t8.geo> |
813 |
francois |
353 |
if (noeud3->get_lien_topologie()==noeud2->get_lien_topologie()) |
814 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==1) |
815 |
|
|
{ |
816 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud3->get_lien_topologie(); |
817 |
|
|
if (aretemaille[are->get_id()]==true) |
818 |
|
|
{ |
819 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud3,noeud2,TRIANGULATION); |
820 |
|
|
are->get_lien_maillage()->ajouter(seg); |
821 |
|
|
} |
822 |
|
|
} |
823 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==1) |
824 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==0) |
825 |
|
|
{ |
826 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie(); |
827 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud2->get_lien_topologie(); |
828 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
829 |
|
|
{ |
830 |
|
|
if (aretemaille[are->get_id()]==true) |
831 |
|
|
{ |
832 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud2,TRIANGULATION); |
833 |
|
|
are->get_lien_maillage()->ajouter(seg); |
834 |
|
|
} |
835 |
|
|
} |
836 |
|
|
} |
837 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==1) |
838 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==0) |
839 |
|
|
{ |
840 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud1->get_lien_topologie(); |
841 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud3->get_lien_topologie(); |
842 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
843 |
|
|
{ |
844 |
|
|
if (aretemaille[are->get_id()]==true) |
845 |
|
|
{ |
846 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud1,noeud3,TRIANGULATION); |
847 |
|
|
are->get_lien_maillage()->ajouter(seg); |
848 |
|
|
} |
849 |
|
|
} |
850 |
|
|
} |
851 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==1) |
852 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==0) |
853 |
|
|
{ |
854 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud2->get_lien_topologie(); |
855 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud1->get_lien_topologie(); |
856 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
857 |
|
|
{ |
858 |
|
|
if (aretemaille[are->get_id()]==true) |
859 |
|
|
{ |
860 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud2,noeud1,TRIANGULATION); |
861 |
|
|
are->get_lien_maillage()->ajouter(seg); |
862 |
|
|
} |
863 |
|
|
} |
864 |
|
|
} |
865 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==1) |
866 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==0) |
867 |
|
|
{ |
868 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud2->get_lien_topologie(); |
869 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud3->get_lien_topologie(); |
870 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
871 |
|
|
{ |
872 |
|
|
if (aretemaille[are->get_id()]==true) |
873 |
|
|
{ |
874 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud2,noeud3,TRIANGULATION); |
875 |
|
|
are->get_lien_maillage()->ajouter(seg); |
876 |
|
|
} |
877 |
|
|
} |
878 |
|
|
} |
879 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==1) |
880 |
|
|
if (noeud1->get_lien_topologie()->get_dimension()==0) |
881 |
|
|
{ |
882 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud3->get_lien_topologie(); |
883 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud1->get_lien_topologie(); |
884 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
885 |
|
|
{ |
886 |
|
|
if (aretemaille[are->get_id()]==true) |
887 |
|
|
{ |
888 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud3,noeud1,TRIANGULATION); |
889 |
|
|
are->get_lien_maillage()->ajouter(seg); |
890 |
|
|
} |
891 |
|
|
} |
892 |
|
|
} |
893 |
|
|
if (noeud3->get_lien_topologie()->get_dimension()==1) |
894 |
|
|
if (noeud2->get_lien_topologie()->get_dimension()==0) |
895 |
|
|
{ |
896 |
|
|
MG_ARETE* are=(MG_ARETE*)noeud3->get_lien_topologie(); |
897 |
|
|
MG_SOMMET* som=(MG_SOMMET*)noeud2->get_lien_topologie(); |
898 |
|
|
if ((are->get_cosommet1()->get_sommet()==som)||(are->get_cosommet2()->get_sommet()==som)) |
899 |
|
|
{ |
900 |
|
|
if (aretemaille[are->get_id()]==true) |
901 |
|
|
{ |
902 |
|
|
MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeud3,noeud2,TRIANGULATION); |
903 |
|
|
are->get_lien_maillage()->ajouter(seg); |
904 |
|
|
} |
905 |
|
|
} |
906 |
francois |
371 |
}*/ |
907 |
francois |
283 |
} |
908 |
francois |
525 |
if (mode>1) |
909 |
|
|
{ |
910 |
francois |
353 |
TPL_MAP_ENTITE<MG_ARETE*>::ITERATEUR it2; |
911 |
|
|
for (MG_ARETE* are=listare.get_premier(it2);are!=NULL;are=listare.get_suivant(it2)) |
912 |
|
|
{ |
913 |
|
|
if (are->get_lien_maillage()->get_nb()==0) |
914 |
|
|
{ |
915 |
francois |
371 |
unsigned long id=are->get_id(); |
916 |
|
|
MG_NOEUD* nodep=(MG_NOEUD*)are->get_cosommet1()->get_sommet()->get_lien_maillage()->get(0); |
917 |
|
|
MG_NOEUD* noarr=(MG_NOEUD*)are->get_cosommet2()->get_sommet()->get_lien_maillage()->get(0); |
918 |
couturad |
951 |
std::map<double,NOEUDARETE,std::less<double> >::iterator it=areteamaille[id].begin(); |
919 |
francois |
371 |
MG_NOEUD* noeudcourant=nodep; |
920 |
|
|
while (it!=areteamaille[id].end()) |
921 |
|
|
{ |
922 |
|
|
MG_NOEUD* noeud=(*it).second.no; |
923 |
francois |
525 |
//MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeudcourant,noeud,TRIANGULATION); |
924 |
|
|
MG_SEGMENT* seg=mai->get_mg_segment(noeudcourant->get_id(),noeud->get_id()); |
925 |
|
|
seg->change_lien_topologie(are); |
926 |
francois |
371 |
noeudcourant=noeud; |
927 |
|
|
it++; |
928 |
|
|
} |
929 |
francois |
525 |
//MG_SEGMENT* seg=mai->ajouter_mg_segment(are,noeudcourant,noarr,TRIANGULATION); |
930 |
|
|
MG_SEGMENT* seg=mai->get_mg_segment(noeudcourant->get_id(),noarr->get_id()); |
931 |
|
|
seg->change_lien_topologie(are); |
932 |
francois |
353 |
} |
933 |
|
|
} |
934 |
francois |
525 |
|
935 |
|
|
} |
936 |
francois |
283 |
} |
937 |
|
|
|
938 |
francois |
820 |
void OCC_SURFACE::get_liste_pole(std::vector< double> *liste_pole,double eps) |
939 |
couturad |
814 |
{ |
940 |
francois |
820 |
//Handle(Geom_Surface) surface=BRep_Tool::Surface(face); |
941 |
couturad |
818 |
Handle(Standard_Type) type=surface->DynamicType(); |
942 |
francois |
820 |
//std::cout << surface->DynamicType()->Name() <<std::endl; |
943 |
couturad |
818 |
if(type==STANDARD_TYPE(Geom_RectangularTrimmedSurface)) |
944 |
|
|
{ |
945 |
|
|
Handle(Geom_RectangularTrimmedSurface) RTSurface = Handle(Geom_RectangularTrimmedSurface)::DownCast(surface); |
946 |
|
|
Handle(Geom_Surface) basissurface = RTSurface->BasisSurface(); |
947 |
|
|
Handle(Standard_Type) type_basissurface=basissurface->DynamicType(); |
948 |
|
|
if(type_basissurface==STANDARD_TYPE(Geom_SphericalSurface)) |
949 |
|
|
{ |
950 |
|
|
type=STANDARD_TYPE(Geom_SphericalSurface); |
951 |
|
|
} |
952 |
|
|
} |
953 |
couturad |
814 |
if(type==STANDARD_TYPE(Geom_SphericalSurface)) |
954 |
couturad |
818 |
{ |
955 |
|
|
BRepClass_FaceClassifier faceclassifier; |
956 |
|
|
gp_Pnt2d pnt2d_pole_sud(0.0,-M_PI/2.); |
957 |
francois |
820 |
faceclassifier.Perform(face,pnt2d_pole_sud,eps); |
958 |
couturad |
818 |
if(faceclassifier.State()==TopAbs_IN || faceclassifier.State()==TopAbs_ON) |
959 |
|
|
{ |
960 |
francois |
820 |
liste_pole->push_back(0.0); |
961 |
|
|
liste_pole->push_back(-M_PI/2.); |
962 |
couturad |
818 |
} |
963 |
|
|
gp_Pnt2d pnt2d_pole_nord(0.0,M_PI/2.); |
964 |
francois |
820 |
faceclassifier.Perform(face,pnt2d_pole_nord,eps); |
965 |
couturad |
818 |
if(faceclassifier.State()==TopAbs_IN || faceclassifier.State()==TopAbs_ON) |
966 |
|
|
{ |
967 |
francois |
820 |
liste_pole->push_back(0.0); |
968 |
|
|
liste_pole->push_back(M_PI/2.); |
969 |
couturad |
818 |
} |
970 |
couturad |
825 |
} |
971 |
|
|
if(type==STANDARD_TYPE(Geom_SurfaceOfRevolution)) |
972 |
|
|
{ |
973 |
|
|
BRepClass_FaceClassifier faceclassifier; |
974 |
|
|
gp_Pnt2d pnt2d_pole_sud(0.0,v_min); |
975 |
|
|
faceclassifier.Perform(face,pnt2d_pole_sud,eps); |
976 |
|
|
if(faceclassifier.State()==TopAbs_IN || faceclassifier.State()==TopAbs_ON) |
977 |
|
|
{ |
978 |
|
|
liste_pole->push_back(0.0); |
979 |
|
|
liste_pole->push_back(v_min); |
980 |
|
|
} |
981 |
|
|
gp_Pnt2d pnt2d_pole_nord(0.0,v_max); |
982 |
|
|
faceclassifier.Perform(face,pnt2d_pole_nord,eps); |
983 |
|
|
if(faceclassifier.State()==TopAbs_IN || faceclassifier.State()==TopAbs_ON) |
984 |
|
|
{ |
985 |
|
|
liste_pole->push_back(0.0); |
986 |
|
|
liste_pole->push_back(v_max); |
987 |
|
|
} |
988 |
|
|
} |
989 |
couturad |
814 |
} |
990 |
|
|
|
991 |
|
|
|
992 |
francois |
1025 |
void OCC_SURFACE::analyse_bspline(void) |
993 |
|
|
{ |
994 |
|
|
Handle(Geom_BSplineSurface) bspline=Handle(Geom_BSplineSurface)::DownCast(surface); |
995 |
|
|
bool ferme=true; |
996 |
|
|
for (int v=1; v<=bspline->NbVPoles(); v++) |
997 |
|
|
{ |
998 |
|
|
gp_Pnt pctr1=bspline->Pole(1, v); |
999 |
|
|
gp_Pnt pctr2=bspline->Pole(bspline->NbUPoles(), v); |
1000 |
|
|
double poids1=bspline->Weight(1, v); |
1001 |
|
|
double poids2=bspline->Weight(bspline->NbUPoles(), v); |
1002 |
|
|
double xyz1[4]; |
1003 |
|
|
double xyz2[4]; |
1004 |
|
|
xyz1[0]=pctr1.X(); |
1005 |
|
|
xyz1[1]=pctr1.Y(); |
1006 |
|
|
xyz1[2]=pctr1.Z(); |
1007 |
|
|
xyz1[3]=poids1; |
1008 |
|
|
xyz2[0]=pctr2.X(); |
1009 |
|
|
xyz2[1]=pctr2.Y(); |
1010 |
|
|
xyz2[2]=pctr2.Z(); |
1011 |
|
|
xyz2[3]=poids2; |
1012 |
|
|
OT_VECTEUR_4D vec(xyz1,xyz2); |
1013 |
|
|
if (vec.get_longueur()>fonction1->get_precision()) |
1014 |
|
|
ferme=false; |
1015 |
|
|
|
1016 |
|
|
} |
1017 |
|
|
if (ferme) |
1018 |
|
|
{ |
1019 |
|
|
estperiodeu=1; |
1020 |
|
|
periode_u=u_max-u_min; |
1021 |
|
|
} |
1022 |
|
|
ferme=true; |
1023 |
|
|
for (int u=1; u<=bspline->NbUPoles(); u++) |
1024 |
|
|
{ |
1025 |
|
|
gp_Pnt pctr1=bspline->Pole(u,1); |
1026 |
|
|
gp_Pnt pctr2=bspline->Pole(u,bspline->NbVPoles()); |
1027 |
|
|
double poids1=bspline->Weight(u,1); |
1028 |
|
|
double poids2=bspline->Weight(u,bspline->NbVPoles()); |
1029 |
|
|
double xyz1[4]; |
1030 |
|
|
double xyz2[4]; |
1031 |
|
|
xyz1[0]=pctr1.X(); |
1032 |
|
|
xyz1[1]=pctr1.Y(); |
1033 |
|
|
xyz1[2]=pctr1.Z(); |
1034 |
|
|
xyz1[3]=poids1; |
1035 |
|
|
xyz2[0]=pctr2.X(); |
1036 |
|
|
xyz2[1]=pctr2.Y(); |
1037 |
|
|
xyz2[2]=pctr2.Z(); |
1038 |
|
|
xyz2[3]=poids2; |
1039 |
|
|
OT_VECTEUR_4D vec(xyz1,xyz2); |
1040 |
|
|
if (vec.get_longueur()>fonction1->get_precision()) |
1041 |
|
|
ferme=false; |
1042 |
|
|
|
1043 |
|
|
} |
1044 |
|
|
if (ferme) |
1045 |
|
|
{ |
1046 |
|
|
estperiodev=1; |
1047 |
|
|
periode_v=v_max-v_min; |
1048 |
|
|
} |
1049 |
|
|
} |
1050 |
couturad |
814 |
|
1051 |
francois |
1037 |
void OCC_SURFACE::inverser2(double *uv,double *xyz,double precision) |
1052 |
|
|
{ |
1053 |
|
|
int NUMDECOUP=20; |
1054 |
|
|
double u1; |
1055 |
|
|
double u2; |
1056 |
|
|
double v1; |
1057 |
|
|
double v2; |
1058 |
|
|
double u,v,distmin=1e300; |
1059 |
|
|
surface->Bounds(u1,u2,v1, v2); |
1060 |
|
|
for (int i=0;i<NUMDECOUP+1;i++) |
1061 |
|
|
for (int j=0;j<NUMDECOUP+1;j++) |
1062 |
|
|
{ |
1063 |
|
|
double ut=u1+i*1.0/NUMDECOUP*(u2-u1); |
1064 |
|
|
double vt=v1+j*1.0/NUMDECOUP*(v2-v1); |
1065 |
|
|
gp_Pnt P; |
1066 |
|
|
surface->D0(ut,vt,P); |
1067 |
|
|
double xyz2[3]={P.X(),P.Y(),P.Z()}; |
1068 |
|
|
OT_VECTEUR_3D vec(xyz,xyz2); |
1069 |
|
|
double dist=vec.get_longueur(); |
1070 |
|
|
if (dist<distmin) |
1071 |
|
|
{ |
1072 |
|
|
distmin=dist; |
1073 |
|
|
u=ut; |
1074 |
|
|
v=vt; |
1075 |
|
|
} |
1076 |
|
|
} |
1077 |
|
|
bool sortie=false; |
1078 |
francois |
1039 |
int nbiteration=0; |
1079 |
francois |
1037 |
while (sortie==false) |
1080 |
|
|
{ |
1081 |
|
|
double uv2[3]={u,v,0.}; |
1082 |
|
|
double xyzuv[3],xyzuvdu[3],xyzuvdv[3],xyzuvduu[3],xyzuvduv[3],xyzuvdvv[3]; |
1083 |
|
|
deriver_seconde(uv2,xyzuvduu,xyzuvduv,xyzuvdvv,xyzuv,xyzuvdu,xyzuvdv); |
1084 |
|
|
OT_VECTEUR_3D vxyz(xyz); |
1085 |
|
|
OT_VECTEUR_3D vxyzuv(xyzuv); |
1086 |
|
|
OT_VECTEUR_3D P=vxyzuv-vxyz; |
1087 |
|
|
OT_VECTEUR_3D vxyzuvdu(xyzuvdu); |
1088 |
|
|
OT_VECTEUR_3D vxyzuvdv(xyzuvdv); |
1089 |
|
|
OT_VECTEUR_3D vxyzuvduu(xyzuvduu); |
1090 |
|
|
OT_VECTEUR_3D vxyzuvdvv(xyzuvdvv); |
1091 |
|
|
OT_VECTEUR_3D vxyzuvduv(xyzuvduv); |
1092 |
|
|
double Fdu=P*vxyzuvduu+vxyzuvdu*vxyzuvdu; |
1093 |
|
|
double Fdv=P*vxyzuvduv+vxyzuvdv*vxyzuvdu; |
1094 |
|
|
double Gdu=P*vxyzuvduv+vxyzuvdu*vxyzuvdv; |
1095 |
|
|
double Gdv=P*vxyzuvdvv+vxyzuvdv*vxyzuvdv; |
1096 |
|
|
double F=P*xyzuvdu; |
1097 |
|
|
double G=P*xyzuvdv; |
1098 |
|
|
double det=Fdu*Gdv-Gdu*Fdv; |
1099 |
|
|
double deltau=(-F*Gdv+Gdu*G)/det; |
1100 |
|
|
double deltav=(-Fdu*G+F*Fdv)/det; |
1101 |
|
|
double new_u=u+deltau; |
1102 |
|
|
double new_v=v+deltav; |
1103 |
|
|
if (new_u<u1) new_u=u1; |
1104 |
|
|
if (new_u>u2) new_u=u2; |
1105 |
|
|
if (new_v<v1) new_v=v1; |
1106 |
|
|
if (new_v>v2) new_v=v2; |
1107 |
|
|
if (fabs(new_u-u)<precision) |
1108 |
|
|
if (fabs(new_v-v)<precision) |
1109 |
|
|
sortie=true; |
1110 |
|
|
u=new_u; |
1111 |
|
|
v=new_v; |
1112 |
francois |
1039 |
nbiteration++; |
1113 |
|
|
if (nbiteration>1000) sortie=true; |
1114 |
francois |
1037 |
} |
1115 |
|
|
uv[0]=u; |
1116 |
|
|
uv[1]=v; |
1117 |
|
|
} |
1118 |
couturad |
814 |
|
1119 |
francois |
283 |
#endif |