CAD Exchanger SDK
Layers

Table of Contents

Scene graph elements, bodies and subshapes in B-Rep representation can be organized into logical groups with the help of layers. Semantics of these groups is application-specific.

A layer may have a visibility flag which can be used by user application to show on/off objects belonging to the layer.

The following example demonstrates creation and association of a layer with graph elements:

ModelData_Layer aLayer ("invisible");
aLayer.IsVisible() = false;
...
ModelData_Assembly anAsm = ...;
aLayer.Add (anAsm);

B-Rep representation subshapes can also be added to layers:

ModelData_BRepRepresentation aBRep = aPart.BRepRepresentation();
const ModelData_Face& aFace = ...; // face from aBRep
ModelData_Layer aLayer ("faces");
aBRep.AddToLayer (aFace, aLayer);

Traversal over layers

All items in layer can be traversed using ItemVisitor:

class MyLayerVisitor : public ModelData_Layer::ItemVisitor
{
public:
void operator() (const ModelData_SceneGraphElement& theSGE) override {...};
void operator() (const ModelData_Shape& theShape, const ModelData_BRepRepresentation& theRep) override {...};
};
ModelData_Layer aLayer = ...;
MyLayerVisitor aVisitor;
aLayer.Accept (aVisitor);

Alternatively, all layers for one particular scene graph element or subshape can be accessed using iterators:

// Iterate layers of scene graph element
ModelData_Part aPart = ...;
ModelData_SceneGraphElement::LayerIterator aSGELayerIt (aPart);
while (aSGELayerIt.HasNext()) {
ModelData_Layer aLayer = aSGELayerIt.Next();
...
}
// Iterate layers of subshape
ModelData_BRepRepresentation aBRep = aPart.BRepRepresentation();
const ModelData_Face& aFace = ...; // face from aBRep
ModelData_BRepRepresentation::LayerIterator aSubshapeLayerIt (aFace, aBRep);
while (aSubshapeLayerIt.HasNext()) {
ModelData_Layer aLayer = aSubshapeLayerIt.Next();
...
}