Manifold Geometry // Многообразная Геометрия

More on B-Rep instancing

/ Просмотров: 1850

In this post, we continue talking about B-Rep instancing and how to deal with it in the modeling operators. You're encouraged to read the first part before you proceed. In the outline, our main discoveries were as follows:

  1. There is a distinction between sharing and instancing. While all serious modelers support sharing (because this is the essential ingredient of a topology data structure), the modelers are not obligated to support instancing.
  2. The instancing mechanism available in the OpenCascade kernel allows expressing tricky things. However, the instancing of low-level boundary elements goes away on STEP export/import.
  3. Although instancing is supported in B-Rep, it's real application is the assembly design.

Like it or not, the modeling operators should take care of instancing to survive on real engineering data. We will not consider anymore the instancing of the low-level boundary elements such as faces because of the reasons outlined previously. In our opinion, such data structures should be first recognized as abnormal and then normalized before further processing. Our discussion is therefore limited with the CAD models whose topology can be expressed by the graphs of the following kind:

A good topology graph without low-level instancing.

The peculiarity of this sort of topology is that the instancing relationship does not go deeper than a certain level. The level of the graph where the instancing interrupts corresponds to the level of a real part definition. A part per se can be a solid, a shell or whatever entity not excluding another compound without a location. This sort of representation is not very clear in fact. Essentially, two concepts are mixed here: part and assembly. While it is better to avoid any instancing in a topology graph, the instancing relations like shown above often emerge in practice, e.g., when you read a STEP file containing an assembly into a single shape. When dealing with the mixed structures which contain several real parts instantiated within compound entities, you may want to isolate those parts for subsequent manipulations.

Isolated "real" parts.

The following code can be used to explore and take out all real parts from the compound model:

void IsolateRealParts(const TopoDS_Shape&   S,
                      TopTools_ListOfShape& parts)
  for ( TopoDS_Iterator it(S, false, false); it.More(); it.Next() )
    const TopoDS_Shape& subShape = it.Value();
    if ( subShape.Location().IsIdentity() )
      parts.Append( S.Located( TopLoc_Location() ) ); // Stop recursion and add the parent as a real part.
      IsolateRealParts(subShape, parts); // Go deeper.

The corresponding command in Analysis Situs is "isolate-real-parts". It works pretty much like "explode" but implements another traversal rule which is location-driven.