Convert CAD faces to splines with OpenCascade

Sometimes we want to do things that are completely opposite to canonical recognition, i.e., to convert nice analytical shapes to splines. There are several circumstances when you might need such a trick. What I could recall from practice is the following:

  1. Data exchange. After spending several weeks (if not months) modelling turbine blades with their hubs and shrouds, I realized that some surfaces (especially offset surface) were completely broken (Fig. 1). The “fix” was to represent the faulty geometries with splines.
  2. Lack of robustness in modelling algorithms for the special analytic cases. As you might know, a typical CAD engine tries to process analytic geometries in a specific way, and fall back to the generic methods for freeform geometries or tricky cases only. E.g., why would you run a walking procedure for surface-surface intersection [Barnhill, R. E., Farin, G., Jordan, M., & Piper, B. R. (1987). Surface / surface intersection. Computer Aided Geometric Design, 4, 3–16] if you are intersecting just a couple of planes? But if things are broken, you might want to force the engine to give a generic numerical method a try.
Figure 1. Bad luck on importing a solid model to Rhinoceros.

Converting a surface to a spline is as easy as calling GeomConvert::SurfaceToBSplineSurface() function:

Figure 2. Converting a single surface to spline in Analysis Situs.

As you can see from Fig. 2, the converted surface remains untrimmed as the conversion is done not taking into account the trimming contour of the original face. There is a package ShapeCustom that does the job at topological level, i.e., it allows converting not surfaces but the entire shape. Still, it works the same way underneath and the resulting spline surfaces are not minimal.

Open-source CAD platform: