Introduction to CAD feature recognition
Form features or simply features are groups of CAD faces or volume elements that are meaningful for a specific engineering activity or application. In most cases, design and manufacturing features are not the same things because a CAD part is not modelled (digitally) the same way it is manufactured. Regardless of its type, a feature is a carrier of domain knowledge associated with the geometry of a part. A cornerstone problem for bridging CAD and CAM software is how to match form features with the corresponding machining programs. We recommend our readers to familiarize themselves with the paper by [Wu et al, 1996] that gives a clear introduction to the feature recognition area of research.
Although it might be possible to design a CAD part in terms of its ultimate manufacturing features, such an approach is not widely used and is generally considered a bad idea [Vandenbrande and Requicha, 1993]. Therefore, even when the design features are known from the originating CAD system, they have to be converted to the manufacturing features to generate NC code. Then, more often than not, the design features are not even available because of lossy data exchange between the employed CAD and CAM packages. As a result, feature recognition had become a fundamental problem in the computer-aided design field.
There is a bunch of engineering workflows where feature recognition is highly demanded. Some of them are listed below:
- Manufacturability analysis. Before passing a CAD part to a machining shop, one has to be sure that this part can be fabricated in the first place. The manufacturability analysis can be conducted to assess all holes, pockets, slots, fillets and chamfers on a CAD part for accessibility and fitting the manufacturing constraints.
- Direct editing. Direct editing is opposed to history-based editing in the sense that direct editing operations (push/pull, face tweaking, etc.) do not rely on the availability of design features somewhere in a feature tree. Instead, direct editing operators perform local feature recognition in the affected area. Knowing local features allows for changing the part's geometry without corrupting its original design intent.
- CAD part simplification (defeaturing). Strictly speaking, simplification (or "defeaturing") is yet another type of direct editing. Simplification is often used to prepare design models for numerical simulation or consumption by downstream systems that do not speak the "CAD language" natively (e.g., for gaming engines). To simplify a feature (e.g., to removal a drilled hole), one needs to recognize that feature in the CAD part in the first place.
- Manufacturing cost estimation. Digital manufacturing (or "Manufacturing as a Service") is a growing industry. It is often necessary to assess the expected production costs for a CAD part before placing the order. Those costs would naturally include the milling, turning or 3D printing time that highly correlates with the part's features. Therefore, feature recognition is required for accurate machining time estimation.
- Manufacturing planning. Even if the design features are known from the originating CAD system (and that is often not the case), automated CNC manufacturing would require specific manufacturing features instead of "form" as-designed features.
To our knowledge, Analysis Situs is the first, and the only open-sourced CAD software aimed to provide general feature recognition functionality.
Why naive approach is not the best?
By "naive" approach we mean the technique of iterating CAD model's faces and grouping them together to compose the features. Such scanning approach is not completely desperate, and, if implemented wisely, it can end up with a workable solution.
At the same time, such a naive approach is fundamentally "blind" as here we do not employ any formalism to ground our recognition algorithm upon. What we do here is just visiting all the CAD faces and analyzing their analytical properties to deduce if they "look like a feature" or not. The following subsections uncover the principal complexities of the recognition process.
It is relatively easy to extract all plain cylindrical holes out of a CAD model if you are well equipped and know how to program (Python can be just fine, although we prefer C++ here). The things get more laborious if you need to distinguish between plain, countersunk, counterbored and counterdrilled holes.
Looking at the image above, you can imagine a few more combinations of countersinks and counterbores, including variations of blind and through holes. The number of possible feature patterns is quite big even for such a simple thing as a drilled hole. Now imagine that these holes perforate each other:
Even without interactions, some holes could not be easily classified as they correspond to a sequence of milling operations, such as boring stacked up steps:
In the presence of interacting and complex features, simple scanning technique becomes error-prone unless it is equipped with a rich set of topologic and geometric checks all applied following some specific recognition strategy. Elaborating such a strategy is not a trivial exercise, although the heuristics employed down the road might not be that complicated.
The principal data structure guiding feature recognition is, of course, the boundary representation of a CAD part itself. Since Analysis Situs is based on OpenCascade, we employ its minimalistic B-rep structure that does not support neither user-defined attributes nor convenient methods of iteration (such as back-references and circulators). Therefore, a computationally efficient feature recognition algorithm should employ some extra data structures, such as:
- Attributes holder. This data structure is aimed at storing all the geometric cues and "knowledge" about the CAD features as they are being extracted by the recognition algorithms progressively.
- Adjacency graphs. These graph data structures allow us to focus on the topological relationships between the boundary elements (and possibly features) and formalize the connectivity of shapes without much care of their geometry.
- Iterators. It is critical to have efficient iterators over the B-rep elements to be able to query, for example, all parent faces for the given edge.
Having a rich B-rep modeller under the hood of a feature recognizer is essential not only because we need to represent a part's shape with all its boundaries. Besides that, we also need to ask various "geometric questions" in the course of recognition. Therefore, we have to leverage the modelling kernel's API to solve the recognition problem.
A sound idea is the key ingerient to any geometric algorithm. If a good idea is missing (and that is often the case with naive scan approaches), the algorithm has good chances to become a "big ball of mud" [Foote and Yoder, 1997], i.e. a piece of puzzled non-maintainable code.
Many scientific papers and technical reports have been published with the aim to document a well-proven feature recognition method. One of such methods consists in injecting the formalism of graph theory aimed at building up the graph-based abstraction of the recognition problem. The driving idea here consists of converting the geometric representation of a CAD part to a pure topological representation which facilitates computation.