Hide menu
Loading...
Searching...
No Matches
Sheet Metal Feature Recognizer Example

Demonstrates how to perform recognition of sheet metal features on a 3D model and print information about found features and their parameters in a console.

Overview

In this example demonstrates how to perform recognition of sheet metal features on a 3D model using sheet metal feature recognition tool (SheetMetal_FeatureRecognizer). For this purpose, used a console application that imports a model, traverses through unique ModelData::Part , creates and runs SheetMetal_FeatureRecognizer, groups and prints information about found features and their parameters into console. Sheet metal feature recognition will be performed for each unique ModelData::Part , but only for the scope of accepted geometries.


Application needs 1 input argument to run:

Usage: sheet_metal_feature_recognizer <input_file>, where:
<input_file> is a name of the file to be read


For more information about feature recognition visit Sheet Metal page.

Implementation

PartProcessor class is inherited from ShapeProcessor and overrides ProcessSolid and ProcessShell methods that are used to run SheetMetal_FeatureRecognizer on given shapes. Then PrintFeatures method is used to print information about found features and their parameters in a console.
Visit Model Explore Helper Implementation page for more information about base ShapeProcessor class implementation.

using namespace cadex;
class PartProcessor : public ShapeProcessor
{
public:
void ProcessSolid (const ModelData::Solid& theSolid) override
{
auto aFeatureList = myRecognizer.Perform (theSolid);
PrintFeatures (aFeatureList);
}
void ProcessShell (const ModelData::Shell& theShell) override
{
auto aFeatureList = myRecognizer.Perform (theShell);
PrintFeatures (aFeatureList);
}
private:
};
Defines a connected set of faces.
Definition Shell.hxx:32
Defines a topological solid.
Definition Solid.hxx:32
Provides an interface to recognizing sheet metal features tool. Is used for recognition of features s...
Definition SheetMetal_FeatureRecognizer.hxx:38
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30

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

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

After performing feature recognition, the object of FeatureGroupManager class is used to group and sort found sheet metal features. For this purpose, there is a traverse through all found features and add each of them to FeatureGroupManager with a specified name.

using namespace cadex;
std::function<void(MTKBase_FeatureList)> GroupByParameters = [&] (const MTKBase_FeatureList& theFeatures) -> void {
for (size_t i = 0; i < theFeatures.Size(); ++i) {
const auto& aFeature = theFeatures[i];
if (aFeature.IsOfType<SheetMetal_Bead>()) {
aManager.AddFeature ("Bead(s)", "Bead(s)", true, aFeature);
} else if (aFeature.IsOfType<SheetMetal_Cutout>()) {
aManager.AddFeature ("Cutout(s)", "Cutout(s)", true, aFeature);
} else if ...
}
};
GroupByParameters (theFeatureList);
Defines a list of features.
Definition MTKBase_FeatureList.hxx:36
Describes a sheet metal bead.
Definition SheetMetal_Bead.hxx:28
Describes a cutout in sheet metal.
Definition SheetMetal_Cutout.hxx:28

After adding all found features to FeatureGroupManager, a Print method of the manager is used to print information about found features and their parameters in a console. PrintFeatureParameters is created to explore and print MTK feature parameters. It uses as an input parameter of Print method.

using namespace cadex;
auto PrintFeatureParameters = [] (const MTKBase_Feature& theFeature)
{
if (theFeature.IsOfType<SheetMetal_Bead>()) {
const auto& aBead = static_cast<const SheetMetal_Bead&> (theFeature);
FeatureGroupManager::PrintFeatureParameter ("depth", aBead.Depth(), "mm");
} else if (theFeature.IsOfType<SheetMetal_Cutout>()) {
const auto& aCutout = static_cast<const SheetMetal_Cutout&> (theFeature);
FeatureGroupManager::PrintFeatureParameter ("perimeter", aCutout.Perimeter(), "mm");
} else if ...
};
aManager.Print ("features", PrintFeatureParameters);
Describes a base class of MTK based features.
Definition MTKBase_Feature.hxx:33

Visit Feature Group Helper Implementation page for more information about FeatureGroupManager class implementation.

Example output

Below is the example output for model from ./examples/models/Power_box_Chasis.stp.

Model Example output
Model: Power_box_Chasis

Part #0 ["power box sheetmetal"] - solid #0 has:
    Bend(s): 8
        2 Bend(s) with
          radius: 0.7366 mm
          angle: 90 deg
          length: 1.15705 mm
          width: 60 mm
        2 Bend(s) with
          radius: 0.7366 mm
          angle: 90 deg
          length: 1.15705 mm
          width: 137.327 mm
        4 Bend(s) with
          radius: 0.7366 mm
          angle: 90 deg
          length: 1.15705 mm
          width: 148 mm
    ...

    Total features: 76

Files