pythonocc-core icon indicating copy to clipboard operation
pythonocc-core copied to clipboard

Is there a way to approximate Spline surfaces with basic OCC objects?

Open tnakaicode opened this issue 4 years ago • 7 comments

I'm trying to figure out if there is a way to approximate the part of a shape that is loaded in a STEP file where Spline is used. Is there any way to approximate the surface generated by Spline using gp_Circe, gp_Cone, gp_Torus, gp_Plane, etc.?

As for the conversions, they are equivalent to the inverse conversion of Class in the following URL. https://dev.opencascade.org/doc/occt-7.5.0/refman/html/class_convert___circle_to_b_spline_curve.html

I would like to hear your opinions.

tnakaicode avatar Oct 18 '21 11:10 tnakaicode

You want to fit a primitive surface like a cone to a BSplineSurface?

cafhach avatar Oct 20 '21 18:10 cafhach

Yes, correct. I want to fit primitive surface (gp_Plane, gp_Sphere, gp_Torus, gp_Cone, etc) to BSplineSurface.

tnakaicode avatar Oct 26 '21 02:10 tnakaicode

Yes, but not directly. A cone for example consists of two surface (bottom and mantle). You have to extract the surface you are interested in with BrepTool_surface and then convert the surface into a Geom_BSplineSurface with GeomConvert_SurfaceToBSplineSurface.

rainman110 avatar Oct 26 '21 07:10 rainman110

As far as I understand you want to approximate a BSpline surface using primitive surfaces like cones, planes, spheres, etc. Usually we work the other way (using for example the GeomConvert_SurfaceToBSplineSurface class). What kind of industrial workflow requires a spline surf to be approximated using these basic surfaces ??? maybe I misunderstand?

tpaviot avatar Dec 01 '21 08:12 tpaviot

You could try to employ a general optimization algorithm (e.g. from SciPy) to find the parameters of your primitive surface. All you'd require would hopefully be a distance quantity. Perhaps pythonocc could help here by measuring the distance between the surfaces on a grid of points on the BSplineSurface. This quantity would have to be minimized by the optimizer then.

cafhach avatar Dec 06 '21 10:12 cafhach

"to approximate a BSpline surface using primitive surfaces like cones, planes, spheres, etc" is correct. This is exactly what I want to do. And it is certainly out of the normal workflow.

Specifically, I use it to read geometry data in an analysis code called MCNP. The MCNP Manual https://mcnp.lanl.gov/pdf_files/la-ur-17-29981.pdf p.59 Table3-4 lists the configurations that MCNP can read geometry data. Many models created by CAD software or OpenCASCADE contain splines, but there are several other analysis codes such as MCNP that do not contain splines in their readable geometry. I am wondering if there is a way to pass the data to such analysis codes that have difficulties in reading.

tnakaicode avatar Dec 07 '21 09:12 tnakaicode

And what about using a 2d tri or planar quad mesh?

tpaviot avatar Dec 07 '21 13:12 tpaviot