Hide menu
Loading...
Searching...
No Matches
cadex::ModelData_BRepRepresentation Class Reference

Defines precise Boundary Representation of part. More...

#include <cadex/ModelData_BRepRepresentation.hxx>

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

Classes

class  LayerIterator
 Iterator over subshape layers. More...
 
class  PMIDataIterator
 Iterator over added graphical elements. More...
 
class  SubshapeIterator
 Iterator over added subshapes. 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.
 
 ModelData_BRepRepresentation (initialized)
 Constructor.
 
 ModelData_BRepRepresentation (ImplType *theImpl)
 
 ModelData_BRepRepresentation (const ModelData_Shape &theShape)
 Constructor.
 
 ModelData_BRepRepresentation (const TopoDS_Shape &theShape)
 
ModelData_Shape Add (const ModelData_Shape &theShape)
 Adds a root body (or bodies).
 
ModelData_Shape Add (const TopoDS_Shape &theShape)
 
const ModelData_BodyListGet () const
 Returns an associated topological object.
 
void AddProvider (const std::shared_ptr< Provider > &theProvider)
 Adds a B-Rep model provider.
 
void Clear ()
 Discards associated data.
 
bool HasSubshapes () const
 Returns true if there is at least one explicitly registered sub-shape.
 
size_t NumberOfSubshapes () const
 Returns the number of registered sub-shapes.
 
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)
 
void AddPMIData (const ModelData_Shape &theSubshape, const ModelData_PMIData &thePMIData)
 Sets an association between theSubshape and thePMIData.
 
void AddPMIData (const TopoDS_Shape &theSubshape, const ModelData_PMIData &thePMIData)
 
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.
 
void 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.
 
bool RemoveFromLayer (const ModelData_Shape &theSubshape, const ModelData_Layer &theLayer)
 Removes subshape from layer.
 
bool 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.
 
bool FindInLayer (const ModelData_Shape &theSubshape, const ModelData_Layer &theLayer) const
 Finds subshape in layer.
 
bool 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.
 
void Accept (SubshapeVisitor &theVisitor) const
 Applies the visitor to visit the subshapes.
 
ModelData_Shape Shape (int theId) const
 Returns a B-Rep shape by its Id.
 
int ShapeId (const ModelData_Shape &theShape) const
 Returns an Id of B-Rep shape.
 
void Accept (ModelData_Part::RepresentationVisitor &theVisitor) const
 Accepts a representation visitor.
 
Base_UTF16String Name () const
 
void SetName (const Base_UTF16String &theName)
 Sets an object name.
 
- Public Member Functions inherited from cadex::ModelData_Representation
 ModelData_Representation ()
 Constructor.
 
void Accept (ModelData_Part::RepresentationVisitor &theVisitor) const
 Accepts a representation visitor.
 
- Public Member Functions inherited from cadex::ModelData_BaseObject
 ModelData_BaseObject ()
 Constructor.
 
IdType TypeId () const
 Returns an object type id.
 
template<typename T >
bool IsOfType () const
 Returns true if the object has a type T.
 
void SetName (const Base_UTF16String &theName)
 Sets an object name.
 
Base_UTF16String Name () const
 
void SetUuid (const Base_Uuid &theUuid)
 
Base_Uuid Uuid () const
 
void Nullify ()
 Resets reference to implementation object.
 
bool IsNull () const
 Returns true if the object is nullified.
 
 operator bool () const
 Casts the object to the bool type.
 
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:

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 = ...;
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];
//...
}
}
Defines precise Boundary Representation of part.
Definition: ModelData_BRepRepresentation.hxx:39
const ModelData_BodyList & Get() const
Returns an associated topological object.
Definition: ModelData_BRepRepresentation.cxx:626
Defines a root topological shape that can be owned by B-Rep representation.
Definition: ModelData_Body.hxx:28
Defines a list of bodies.
Definition: ModelData_BodyList.hxx:31
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:35
ModelData_BRepRepresentation BRepRepresentation() const
Definition: ModelData_Part.cxx:360
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
...
void SetAppearance(const ModelData_Shape &theSubshape, const ModelData_Appearance &theAppearance)
Definition: ModelData_BRepRepresentation.cxx:698
void SetName(const ModelData_Shape &theSubshape, const Base_UTF16String &theName)
Definition: ModelData_BRepRepresentation.cxx:684
Defines an RGBA color (with alpha channel).
Definition: ModelData_Color.hxx:34
Iterates over subshapes in a shape.
Definition: ModelData_Shape.hxx:41
Base class of topological shapes.
Definition: ModelData_Shape.hxx:37
Defines a topological solid.
Definition: ModelData_Solid.hxx:31

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

B-Rep with subshape attributes

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

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
}
}
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition: Base_UTF16String.hxx:34
bool IsEmpty() const
Returns true if the string is empty.
Definition: Base_UTF16String.cxx:233
Provides an interface to appearance which is a collection of visual styles.
Definition: ModelData_Appearance.hxx:39
Iterator over added subshapes.
Definition: ModelData_BRepRepresentation.hxx:149

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 = ...;
aBRep.SetName (aSolid, "solid"); // assign name to solid
Base_UTF16String aName = aBRep.Name (aBody); // get name of body
assert (aName == "solid");
static ModelData_Body Create(const ModelData_Shape &theShape)
Creates a body from an arbitrary shape.
Definition: ModelData_Body.cxx:223
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, B-Rep Representation Example.
Examples
MTKConverter/Program.cs, MTKConverter/main.cxx, advgeom/brepsimplify/Program.cs, exploring/appearance/Program.cs, exploring/appearance/main.cxx, exploring/brepgeometry/Program.cs, exploring/brepgeometry/main.cxx, exploring/breprepresentation/Program.cs, exploring/breprepresentation/main.cxx, exploring/layers/Program.cs, exploring/layers/main.cxx, exploring/propertytable/Program.cs, exploring/propertytable/main.cxx, exploring/validationproperties/Program.cs, exploring/validationproperties/main.cxx, meshing/lods/Program.cs, meshing/lods/main.cxx, meshing/visualizationmesher/Program.cs, meshing/visualizationmesher/main.cxx, modeling/assembly/Program.cs, modeling/assembly/main.cxx, modeling/brep/Program.cs, modeling/brep/main.cxx, modeling/brepfeatures/Program.cs, modeling/brepfeatures/main.cxx, modeling/brepprimitives/Program.cs, modeling/brepprimitives/main.cxx, modeling/metadata/Program.cs, modeling/metadata/main.cxx, modification/coloring/Program.cs, modification/coloring/main.cxx, modification/renaming/Program.cs, and modification/renaming/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.

Examples
MTKConverter/Program.cs.

◆ AddPMIData()

void cadex::ModelData_BRepRepresentation::AddPMIData ( const ModelData_Shape theSubshape,
const ModelData_PMIData thePMIData 
)

Sets an association between theSubshape and thePMIData.

The created association is a bilateral connection between theSubshape and thePMIData. The assigned ModelData_PMIGraphicalElement to the shape could be iterated via PMIGraphicalElementIterator.

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

◆ AddToLayer()

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.
Examples
exploring/layers/Program.cs, and exploring/layers/main.cxx.

◆ Clear()

void cadex::ModelData_BRepRepresentation::Clear ( )

Discards associated data.

Clears the root bodies.

◆ FindInLayer()

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.

◆ Get()

◆ 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().

◆ Name()

Base_UTF16String cadex::ModelData_BaseObject::Name ( ) const

Returns an object name. Returns empty string if the object has no name (by default).

See also
SetName().

◆ 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()

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.

◆ SetAppearance()

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

◆ SetName() [1/2]

void cadex::ModelData_BaseObject::SetName ( const Base_UTF16String theName)

Sets an object name.

Accepts a string as a unicode string. Must not be called on IsNull() object. Otherwise behavior is undefined.

See also
Name().

◆ SetName() [2/2]

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.

Examples
modification/renaming/Program.cs, and modification/renaming/main.cxx.

◆ Shape()

ModelData_Shape cadex::ModelData_BRepRepresentation::Shape ( int  theId) const

Returns a B-Rep shape by its Id.

If theId is negative or there is no corresponding shape in this representation, then returns empty ModelData_Shape. If this representation IsNull(), then behavior is undefined.

◆ ShapeId()

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

Returns an Id of B-Rep shape.

If the shape IsNull() or does not belong to B-Rep, then returns -1. May also return -1 if new shapes were added to existing shapes of B-Rep after first call of current method (except ModelData_Representation::Add()). If this representation IsNull(), then behavior is undefined.

Examples
MTKConverter/Program.cs, MTKConverter/main.cxx, modification/renaming/Program.cs, and modification/renaming/main.cxx.