## On recognizing canonical surfaces: checking

The processing of sheet metal CAD parts cannot neglect the design issues, such as uneven thickness, missing bends, or dirty geometry. One of the often occurring problems is a non-canonical representation of the B-rep edges and faces constituting a CAD model. This issue is not specific to sheet metals and may block other geometry processing workflows, such as direct editing, for example. The analytical (or canonical) representation of shape has many vital advantages over the NURBS representation, even though the latter one gives a genuinely universal way to represent a shape. Although NURBS can define the canonical shapes precisely, it remains a kind of lossy way of communicating the design intent. For instance, a NURBSy cylinder cannot be asked for such fundamental properties as the radius or axis. At the same time, the modeling algorithms, such as sheet metal unfolding, often rely on such properties. That is not to mention other advantages of the analytical representation, such as compactness and efficiency of computation (just think of the complexity of projecting a point to a NURBS surface and to a plane).

The preconditioning of CAD models for further processing is a challenging business. We are attempting to approach this problem by developing an open-source SDK and this way to give CAD practitioners a bunch of handy tools. That's a long-shot goal, but let's eat this elephant one bite at a time. So, how do we know that our CAD part suffers from a non-canonical geometry issue?

Answering this question requires iterating over all B-rep edges and faces of a model, attempting to deduce their canonical shape from the existing free-form representations (Bezier or NURBS). In fact, besides freeform definitions, some kinematic surface types, such as extrusion and revolution, have to be considered. Indeed, imagine that a planar profile curve is being rotated around its perpendicular axis. Such a sweeping operation will end up with a planar surface of somehow wild parameterization. But, whenever speaking about canonical recognition, we are not interested in the parameterization, i.e., in the mathematics of form. It is a pure synthetic look on a shape. If something looks like a plane, we declare it a plane. If something looks like a cylinder, that's probably a sheet metal bend, whatever tricky spline it is defined with.

To understand whether your shape is of analytical or freeform type, you could take advantage of the basic inspection tools in Analysis Situs. We have enriched it with the possibility to inspect curves in the face's parametric domain as the following animation shows:

Checking pcurve type in Analysis Situs. |

One thing to keep in mind is that the actual conversion is not really necessary in the feature recognition scenarios. As long as you're not editing your shape, it is perfectly enough to convert freeform entities to their analytical counterparts on-fly. Therefore, we can save some efforts by avoiding recomposing the B-rep structures. Moreover, since freeform geometries may imprecisely approximate the analytical shape, any conversion will inevitably lose accuracy, and that's not what we want.

There are quite some tools for you to check out in OpenCascade for the sake of analytical recognition, e.g., GeomLib_IsPlanarSurface. Be aware, though, that there's no open-source implementation for a comprehensive analytical recognition toolbox.

*Want to discuss this? Jump in to our forum.*