Hide menu
Loading...
Searching...
No Matches
Model Explore Helper Implementation

Implementation of classes that help to explore model BRep representation of a part in Manufacturing Toolkit examples.

Overview

This helper is used to explore the model, BRep representation of a ModelData::Part and process specific shapes using MTK tools.

Implementation

To explore the model and process ModelData::Part s, it's need to create an inheritor from the ModelData::ModelElementVoidVisitor and override the part processing method void operator() (const ModelData::Part& thePart). For this purpose, two classes were created: ShapeProcessor and SolidProcessor.
ShapeProcessor is used to explore BRep representation and process each unique ModelData::Solid or ModelData::Shell by passing it to virtual method void ProcessSolid (const ModelData::Solid& theSolid) or void ProcessShell (const ModelData::Shell& theShell). These methods should be overridden in child classes.

using namespace cadex;
class ShapeProcessor : public ModelData::ModelElementVoidVisitor
{
public:
void operator() (const ModelData::Part& thePart) override
{
auto aPartName = thePart.Name().IsEmpty() ? "noname" : thePart.Name();
size_t aBodyNumber = 0;
const auto& aBodies = thePart.Bodies();
for (const auto& aBody : aBodies) {
ModelData::ShapeIterator aShapeIt (aBody);
while (aShapeIt.HasNext()) {
const auto& aShape = aShapeIt.Next();
if (aShape.Type() == ModelData::ShapeType::Solid) {
cout << "Part #" << myPartIndex << " [\"" << aPartName << "\"] - solid #" << std::to_string (aBodyNumber) << " has:" << endl;
ProcessSolid (ModelData::Solid::Cast (aShape));
} else if (aShape.Type() == ModelData::ShapeType::Shell) {
cout << "Part #" << myPartIndex << " [\"" << aPartName << "\"] - shell #" << std::to_string (aBodyNumber) << " has:" << endl;
ProcessShell (ModelData::Shell::Cast (aShape));
}
}
++aBodyNumber;
}
++myPartIndex;
}
virtual void ProcessSolid (const ModelData::Solid& theSolid) = 0;
virtual void ProcessShell (const ModelData::Shell& theShell) = 0;
private:
size_t myPartIndex = 0;
};
UTF16String Name() const
Returns a name.
Definition ModelElement.cxx:55
Element visitor with empty implementation.
Definition ModelElementVisitor.hxx:64
Defines a leaf node in the scene graph hiearchy.
Definition Part.hxx:34
Iterates over subshapes in a shape.
Definition ShapeIterator.hxx:32
Defines a connected set of faces.
Definition Shell.hxx:32
Defines a topological solid.
Definition Solid.hxx:32
bool IsEmpty() const
Returns true if the string is empty.
Definition UTF16String.cxx:336
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30

SolidProcessor is used to explore BRep representation and process each unique ModelData::Solid by passing it to virtual method void ProcessSolid (const ModelData::Solid& theSolid). This method should be overridden in child classes.

using namespace cadex;
class SolidProcessor : public ModelData::ModelElementVoidVisitor
{
public:
void operator() (const ModelData::Part& thePart) override
{
auto aPartName = thePart.Name().IsEmpty() ? "noname" : thePart.Name();
size_t aBodyNumber = 0;
const auto& aBodies = thePart.Bodies();
for (const auto& aBody : aBodies) {
ModelData::ShapeIterator aShapeIt (aBody);
while (aShapeIt.HasNext()) {
const auto& aShape = aShapeIt.Next();
if (aShape.Type() == ModelData::ShapeType::Solid) {
cout << "Part #" << myPartIndex << " [\"" << aPartName << "\"] - solid #" << std::to_string (aBodyNumber++) << " has:" << endl;
ProcessSolid (ModelData::Solid::Cast (aShape));
}
}
}
++myPartIndex;
}
virtual void ProcessSolid (const ModelData::Solid& theSolid) = 0;
private:
size_t myPartIndex = 0;
};

Files