Hide menu
Loading...
Searching...
No Matches
Wall Thickness Analyzer Example

Demonstrates how to compute minimum and maximum wall thickness of a 3D model and print the result in a console.

Overview

In this example demonstrates how to compute minimum and maximum wall thickness of a 3D model using wall thickness analysis tool (WallThickness_Analyzer). For this purpose, used a console application that imports a model. Wall thickness analysis will be performed for each unique ModelData::Part , but only for the scope of accepted geometries.


Application needs 1 or 2 input arguments to run:

Usage: wall_thickness_analyzer <input_file> <input_resolution>, where:
<input_file> is a name of the file to be read
<input_resolution> is an optional argument that determine accuracy of wall thickness calculation. The larger the value, the higher the accuracy of the calculations, but greatly increase computation time and memory usage. Should be at least 20.


For more information about wall thickness visit Wall Thickness Calculation page.

Implementation

To explore the model and process ModelData::Part , 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, the SolidProcessor and PartProcessor classes were created. In operator() method a ModelData::Part is examined for the presence of ModelData::Solid shapes in it.

using namespace cadex;
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;
}
UTF16String Name() const
Returns a name.
Definition ModelElement.cxx:55
Defines a leaf node in the scene graph hiearchy.
Definition Part.hxx:34
Iterates over subshapes in a shape.
Definition ShapeIterator.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

ProcessSolid method is used to run wall thickness analysis for given entities.

using namespace cadex;
void ProcessSolid (const ModelData::Solid& theSolid) override
{
auto aWTData = myAnalyzer.Perform (theSolid, myResolution);
PrintWTData (aWTData);
}
Defines a topological solid.
Definition Solid.hxx:32

PrintWTData method is used to retrieve minimum and maximum thickness from computed WallThickness_Data and print these values to console.

using namespace cadex;
void PrintWTData (const WallThickness_Data& theData)
{
if (!theData.IsEmpty()) {
cout << " Min thickness = " << theData.MinThickness() << " mm" << endl;
cout << " Max thickness = " << theData.MaxThickness() << " mm\n" << endl;
} else {
cerr << " Failed to analyze the wall thickness of this entity.\n";
}
}
Contains information about minimum and maximum wall thicknesses.
Definition WallThickness_Data.hxx:41
double MaxThickness() const
Returns the maximum wall thickness in mm.
Definition WallThickness_Data.cxx:148
bool IsEmpty() const
Returns true if WallThickness_Data is empty.
Definition WallThickness_Data.cxx:207
double MinThickness() const
Returns the minimum wall thickness in mm.
Definition WallThickness_Data.cxx:142

To traverse only unique parts of the imported model, the ModelData::ModelElementUniqueVisitor class is used.

using namespace cadex;
PartProcessor aPartProcessor;
ModelData::ModelElementUniqueVisitor aVisitor (aPartProcessor);
aModel.Accept (aVisitor);
Defines a visitor that visits each unique element only once.
Definition ModelElementVisitor.hxx:87

Example output

Below is the example output for model from ./examples/models/barrel.stp and resolution set to 1000.

Model Example output
Model: barrel

Part #0 ["barrel"] - solid #0 has:
    Min thickness = 4.526479 mm
    Max thickness = 10.036917 mm

Files