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