CAD Exchanger SDK
cadex::ModelData_BRepRepresentation Class Reference

Defines precise Boundary Representation of part. More...

Inheritance diagram for cadex::ModelData_BRepRepresentation:
cadex::ModelData_Representation cadex::ModelData_BaseObject

Classes

class  LayerIterator
 Iterator over subshape layers. More...
 

Public Types

typedef cadex::internal::ModelData_BRepRepresentationImpl ImplType
 
- Public Types inherited from cadex::ModelData_Representation
typedef cadex::internal::ModelData_RepresentationImpl ImplType
 
- Public Types inherited from cadex::ModelData_BaseObject
typedef int IdType
 Defines a type identifier.
 

Public Member Functions

 ModelData_BRepRepresentation ()
 Constructor. More...
 
 ModelData_BRepRepresentation (initialized)
 Constructor. More...
 
 ModelData_BRepRepresentation (ImplType *theImpl)
 
 ModelData_BRepRepresentation (const ModelData_Shape &theShape)
 Constructor. More...
 
 ModelData_BRepRepresentation (const TopoDS_Shape &theShape)
 
ModelData_Shape Add (const ModelData_Shape &theShape)
 Adds a root body (or bodies). More...
 
ModelData_Shape Add (const TopoDS_Shape &theShape)
 
const ModelData_BodyListGet () const
 Returns an associated topological object. More...
 
void AddProvider (const std::shared_ptr< Provider > &theProvider)
 Adds a B-Rep model provider.
 
void Clear ()
 Discards associated data. More...
 
bool HasSubshapes () const
 Returns true if there is at least one explicitly registered sub-shape. More...
 
size_t NumberOfSubshapes () const
 Returns the number of registered sub-shapes. More...
 
void SetName (const ModelData_Shape &theSubshape, const Base_UTF16String &theName)
 
void SetName (const TopoDS_Shape &theSubshape, const Base_UTF16String &theName)
 
void SetAppearance (const ModelData_Shape &theSubshape, const ModelData_Appearance &theAppearance)
 
void SetAppearance (const TopoDS_Shape &theSubshape, const ModelData_Appearance &theAppearance)
 
void SetPropertyTable (const ModelData_Shape &theSubshape, const ModelData_PropertyTable &thePTable)
 
void SetPropertyTable (const TopoDS_Shape &theSubshape, const ModelData_PropertyTable &thePTable)
 
Base_UTF16String Name (const ModelData_Shape &theSubshape) const
 
Base_UTF16String Name (const TopoDS_Shape &theSubshape) const
 
ModelData_Appearance Appearance (const ModelData_Shape &theSubshape) const
 
ModelData_Appearance Appearance (const TopoDS_Shape &theSubshape) const
 
ModelData_PropertyTable PropertyTable (const ModelData_Shape &theSubshape) const
 
ModelData_PropertyTable PropertyTable (const TopoDS_Shape &theSubshape) const
 
void AddToLayer (const ModelData_Shape &theSubshape, const ModelData_Layer &theLayer)
 Adds subshape to layer. More...
 
void AddToLayer (const TopoDS_Shape &theSubshape, const ModelData_Layer &theLayer)
 
bool RemoveFromLayer (const ModelData_Shape &theSubshape, const ModelData_Layer &theLayer)
 Removes subshape from layer. More...
 
bool RemoveFromLayer (const TopoDS_Shape &theSubshape, const ModelData_Layer &theLayer)
 
bool FindInLayer (const ModelData_Shape &theSubshape, const ModelData_Layer &theLayer) const
 Finds subshape in layer. More...
 
bool FindInLayer (const TopoDS_Shape &theSubshape, const ModelData_Layer &theLayer) const
 
void Accept (SubshapeVisitor &theVisitor) const
 Applies the visitor to visit the subshapes.
 
- Public Member Functions inherited from cadex::ModelData_Representation
 ModelData_Representation ()
 Constructor. More...
 
void Accept (ModelData_Part::RepresentationVisitor &theVisitor) const
 Accepts a representation visitor.
 
- Public Member Functions inherited from cadex::ModelData_BaseObject
 ModelData_BaseObject ()
 Constructor. More...
 
IdType TypeId () const
 Returns an object type id. More...
 
template<typename T >
bool IsOfType () const
 Returns true if the object has a type T. More...
 
void SetName (const Base_UTF16String &theName)
 Sets an object name. More...
 
Base_UTF16String Name () const
 Returns an object name. More...
 
void Nullify ()
 Resets reference to implementation object. More...
 
bool IsNull () const
 Returns true if the object is nullified. More...
 
 operator bool () const
 Casts the object to the bool type. More...
 
internal::ModelData_BaseObjectImpl * Impl () const
 Return a handle to backend (reserved for internal use).
 

Static Public Member Functions

static IdType GetTypeId ()
 

Additional Inherited Members

- Protected Member Functions inherited from cadex::ModelData_Representation
 ModelData_Representation (internal::ModelData_BaseObjectImpl *theImpl)
 Constructor (reserved for internal use).
 
- Protected Member Functions inherited from cadex::ModelData_BaseObject
 ModelData_BaseObject (const internal::ModelData_BaseObjectImpl *theImpl)
 Constructor (reserved for internal use).
 
 ModelData_BaseObject (const internal::ModelData_BaseObjectImpl *theImpl, const Base_UTF16String &theName)
 Constructor (reserved for internal use).
 
template<typename T >
T * GetOrCreateImpl ()
 Reserved for internal use.
 

Detailed Description

Defines precise Boundary Representation of part.

B-Rep representation contains a precise geometrical description of a part (ModelData_Part). A part may have none or one B-Rep representation.

The following image depicts a precise B-Rep representation of a conrod:

bodysolid_256.png
B-Rep representation of a conrod

B-Rep uses geometrical and topological entities (curves, surfaces, edges, faces, etc) to define own contents.

Root Body List

B-Rep representation contains ModelData_BodyList, which is a list of bodies (ModelData_Body), returned by the Get() method. As a rule a B-Rep representation consists of a single body. Models with multiple bodies can be most often received when importing STEP files created by CATIA CAD system.

The following example demonstrates how to iterate over root bodies:

ModelData_Part aPart = ...;
ModelData_BRepRepresentation aBRep = aPart.BRepRepresentation();
if (aBRep) {
const ModelData_BodyList& aList = aBRep.Get(); //retrieve root bodies
for (ModelData_BodyList::SizeType i = 0; i < aList.Size(); ++i) {
const ModelData_Body& aBody = aList[i];
//...
}
}
Note
B-Rep representations of different parts shall not share bodies or their subshapes. Bodies in the B-Rep representation shall not share sub-shapes. That is, each body must be self-contained and shall not share subshapes with any other bodies. If this requirement is not met then behavior may be undefined (up to a crash or corrupting representation).
Although it is not illegal to mix different body types in one B-Rep representation, it is recommended to use consistent body types (or rather single body per part). This is to ensure greater compatibility with target formats which might not allow to mix different body types or multiple bodies per part.

Creation

B-Rep representation is initially created with a single body (from the shape provided in the constructor) or with an empty body list. Bodies can be added using the Add() method.

CAD Exchanger provides various techniques to create B-Rep bodies - from bottom-up creation up to using higher-level solid modeling algorithms. Refer to B-Rep Modeling for further details.

Shape Attributes

In addition to root bodies which only contain geometrical definitions, the B-Rep representation may also contain additional meta-data such as names, appearance attributes (colors or materials), user-defined properties, layers attached to sub-shapes (bodies or their sub-elements), such as faces or edges.

This association may only take place at the B-Rep representation itself, as topological shapes (subclasses of ModelData_Shape) do not allow to define meta-data.

The following example demonstrates how to assign attributes to sub-shapes:

ModelData_Solid aSolid = ...;
aBRep.SetName (aSolid, "solid");
//shell
ModelData_Shape::Iterator aShellIt (aSolid);
ModelData_Shape aShape = aShellIt.Next();
aBRep.SetName (aShape, "shell");
aBRep.SetAppearance (aShape, ModelData_Color (0.f, 0.f, 1.f)); //blue
//faces
ModelData_Shape::Iterator aFaceIt (aSolid, ModelData_ST_Face);
aShape = aFaceIt.Next();
aBRep.SetName (aShape, "face0");
aBRep.SetAppearance (aShape, ModelData_Color (1.f, 0.f, 0.f)); //red
...

The screenshot below demonstrates how this B-Rep representation would be displayed:

dm_brep_subshapes.png
B-Rep with subshape attributes

The following example demonstrates how to iterate over registered sub-shapes and to retrieve their attributes:

ModelData_BRepRepresentation::SubshapeIterator i (aBRep);
while (i.HasNext()) {
const ModelData_Shape& aShape = i.Next();
Base_UTF16String aName = aBRep.Name (aShape);
if (!aName.IsEmpty()) { //subshape has name
}
ModelData_Appearance anAppearance = aBRep.Appearance (aShape);
if (anAppearance) { //subshape has appearance
}
}

Attributes can also be assigned to root bodies. For single shape body (e.g., solid body) this is same as assigning attributes to it's underlying shape. I.e.

ModelData_Solid aSolid = ...;
ModelData_Body aBody = ModelData_Body::Create (aSolid);
aBRep.SetName (aSolid, "solid"); // assign name to solid
Base_UTF16String aName = aBRep.Name (aBody); // get name of body
assert (aName == "solid");
Warning
To avoid confusion it's recommended to assign attributes rather to body or it's shape. But don't mix up.

For body with multiply shapes (e.g., sheet body with several ModelData_Face) assigning attributes is not same as assigning to it's children. They all have separate attributes.

See also
ModelData_PolyRepresentation, Model Explorer.
Examples:
assemblycreator/main.cxx, brepmodeling/main.cxx, meshing/main.cxx, and modelexplorer/main.cxx.

Constructor & Destructor Documentation

◆ ModelData_BRepRepresentation() [1/3]

cadex::ModelData_BRepRepresentation::ModelData_BRepRepresentation ( )

Constructor.

Creates a null object (see IsNull()).

◆ ModelData_BRepRepresentation() [2/3]

cadex::ModelData_BRepRepresentation::ModelData_BRepRepresentation ( initialized  )

Constructor.

Creates an initialized object (IsNull() returns false) with an empty body list.

◆ ModelData_BRepRepresentation() [3/3]

cadex::ModelData_BRepRepresentation::ModelData_BRepRepresentation ( const ModelData_Shape theShape)

Constructor.

Creates an object with a single root body created from theShape invoking the Add() method.

Member Function Documentation

◆ Add()

ModelData_Shape cadex::ModelData_BRepRepresentation::Add ( const ModelData_Shape theShape)

Adds a root body (or bodies).

If theShape is not a body or a body list then creates a body that holds theShape, adds it to the list of root bodies and returns it.

If theShape is a body then appends it to the list of root bodies, if it is a body list then appends all its bodies to the root list; returns theShape in either above case.

◆ AddToLayer() [1/2]

void cadex::ModelData_BRepRepresentation::AddToLayer ( const ModelData_Shape theSubshape,
const ModelData_Layer theLayer 
)

Adds subshape to layer.

Note
Should be called in context of BRep representation theSubshape belongs to.

◆ AddToLayer() [2/2]

void cadex::ModelData_BRepRepresentation::AddToLayer ( const TopoDS_Shape &  theSubshape,
const ModelData_Layer theLayer 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Clear()

void cadex::ModelData_BRepRepresentation::Clear ( )

Discards associated data.

Clears the root bodies.

◆ FindInLayer() [1/2]

bool cadex::ModelData_BRepRepresentation::FindInLayer ( const ModelData_Shape theSubshape,
const ModelData_Layer theLayer 
) const

Finds subshape in layer.

Returns
true if theLayer contains theSubshape.
Note
Should be called in context of BRep representation theSubshape belongs to.

◆ FindInLayer() [2/2]

bool cadex::ModelData_BRepRepresentation::FindInLayer ( const TopoDS_Shape &  theSubshape,
const ModelData_Layer theLayer 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Get()

const ModelData_BodyList & cadex::ModelData_BRepRepresentation::Get ( ) const

Returns an associated topological object.

If the object IsNull() then behavior is undefined.

Examples:
meshing/main.cxx, and modelexplorer/main.cxx.

◆ HasSubshapes()

bool cadex::ModelData_BRepRepresentation::HasSubshapes ( ) const

Returns true if there is at least one explicitly registered sub-shape.

Subshapes are registered when calling SetName() or SetAppearance() methods.

See also
NumberOfSubshapes().

◆ NumberOfSubshapes()

size_t cadex::ModelData_BRepRepresentation::NumberOfSubshapes ( ) const

Returns the number of registered sub-shapes.

Subshapes are registered when calling SetName() or SetAppearance() methods.

See also
HasSubshapes().

◆ RemoveFromLayer() [1/2]

bool cadex::ModelData_BRepRepresentation::RemoveFromLayer ( const ModelData_Shape theSubshape,
const ModelData_Layer theLayer 
)

Removes subshape from layer.

Returns
true if removal was successful.
Note
Should be called in context of BRep representation theSubshape belongs to.

◆ RemoveFromLayer() [2/2]

bool cadex::ModelData_BRepRepresentation::RemoveFromLayer ( const TopoDS_Shape &  theSubshape,
const ModelData_Layer theLayer 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ SetAppearance()

void cadex::ModelData_BRepRepresentation::SetAppearance ( const ModelData_Shape theSubshape,
const ModelData_Appearance theAppearance 
)

theSubshape may only be a ModelData_Body or its subshape. ModelData_BodyList will be iterated into its bodies.

◆ SetName()

void cadex::ModelData_BRepRepresentation::SetName ( const ModelData_Shape theSubshape,
const Base_UTF16String theName 
)

theSubshape may only be a ModelData_Body or its subshape. ModelData_BodyList is ignored.