Demonstrates how to perform molding design analysis on a 3D model and print information about found issues and their parameters in a console.
Overview
In this example demonstrates how to perform molding design analysis on a 3D model using molding dfm analyzer tool (DFMMolding_Analyzer). For this purpose, used a console application that imports a model, traverses through unique ModelData::Part , creates and runs DFMMolding_Analyzer, groups and prints information about found issues and their parameters into console. Molding design analysis will be performed for each unique ModelData::Part , but only for the scope of accepted geometries.
Application needs 1 input argument to run:
Usage: molding_dfm_analyzer <input_file>, where:
<input_file> is a name of the file to be read
For more information about molding design analysis visit Design for Manufacturing (DFM) page.
Implementation
PartProcessor
class is inherited from SolidProcessor
and overrides ProcessSolid
method that are used to run design analysis on given shape.
Visit Model Explore Helper Implementation page for more information about base SolidProcessor
class implementation.
class PartProcessor : public SolidProcessor
{
public:
void ProcessSolid (const ModelData::Solid& theSolid) override
{
Molding_FeatureRecognizerParameters aRecognizerParameters;
aRecognizerParameters.SetMaxRibThickness (30.0);
aRecognizerParameters.SetMaxRibDraftAngle (0.2);
aRecognizerParameters.SetMaxRibTaperAngle (0.1);
Molding_FeatureRecognizer aRecognizer(aRecognizerParameters);
Molding_Analyzer anAnalyzer;
anAnalyzer.AddTool (aRecognizer);
Molding_Data aData = anAnalyzer.Perform (theSolid);
DFMMolding_AnalyzerParameters aParameters;
DFMMolding_Analyzer aDFMAnalyzer (aParameters);
auto anIssueList = aDFMAnalyzer.Perform (aData);
PrintIssues (anIssueList);
}
};
To traverse only unique parts of the imported model, the ModelData::ModelElementUniqueVisitor class is used.
PartProcessor aPartProcessor;
ModelData::ModelElementUniqueVisitor aVisitor (aPartProcessor);
aModel.Accept (aVisitor);
After performing design analysis, the object of FeatureGroupManager
class is used to group and sort found issues. For this purpose, there is a traverse through all found issues and add each of them to FeatureGroupManager
with a specified name.
for (size_t i = 0; i < theIssueList.Size(); ++i) {
const auto& anIssue = theIssueList[i];
if (anIssue.IsOfType<DFMMolding_IrregularCoreDepthScrewBossIssue>()) {
aManager.AddFeature ("Irregular Core Depth Screw Boss Issue(s)", "Screw Boss(es)", true, anIssue);
} else if (anIssue.IsOfType<DFMMolding_IrregularCoreDiameterScrewBossIssue>()) {
aManager.AddFeature ("Irregular Core Diameter Screw Boss Issue(s)", "Screw Boss(es)", true, anIssue);
} else if (anIssue.IsOfType<DFMMolding_HighScrewBossIssue>()) {
aManager.AddFeature ("High Screw Boss Issue(s)", "Screw Boss(es)", true, anIssue);
} else if (anIssue.IsOfType<DFMMolding_SmallDraftAngleScrewBossIssue>()) {
aManager.AddFeature ("Small Draft Angle Screw Boss Issue(s)", "Screw Boss(es)", true, anIssue);
} else if (anIssue.IsOfType<DFMMolding_NonChamferedScrewBossIssue>()) {
aManager.AddFeature ("Non Chamfered Screw Boss Issue(s)", "Screw Boss(es)", false, anIssue);
} else if (anIssue.IsOfType<DFMMolding_HighRibIssue>()) {
aManager.AddFeature ("High Rib Issue(s)", "Rib(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMMolding_SmallDraftAngleRibIssue>()) {
aManager.AddFeature ("Small Draft Angle Rib Issue(s)", "Rib(s)", true, anIssue);
}
}
After adding all found issues to FeatureGroupManager
, a Print
method of the manager is used to print information about found issues and their parameters in a console. PrintFeatureParameters
is created to explore and print issue parameters. It uses as an input parameter of Print
method.
auto PrintFeatureParameters = [] (const MTKBase_Feature& theIssue)
{
if (theIssue.IsOfType<DFMMolding_IrregularCoreDepthScrewBossIssue>()) {
const auto& aICDSBIssue = static_cast<const DFMMolding_IrregularCoreDepthScrewBossIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("actual height", aICDSBIssue.ActualHeight(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual core depth", aICDSBIssue.ActualCoreDepth(), "mm");
} else if (theIssue.IsOfType<DFMMolding_IrregularCoreDiameterScrewBossIssue>()) {
const auto& aICDSBIssue = static_cast<const DFMMolding_IrregularCoreDiameterScrewBossIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min core diameter", aICDSBIssue.ExpectedMinCoreDiameter(), "mm");
FeatureGroupManager::PrintFeatureParameter ("expected max core diameter", aICDSBIssue.ExpectedMaxCoreDiameter(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual core diameter", aICDSBIssue.ActualCoreDiameter(), "mm");
} else if (theIssue.IsOfType<DFMMolding_HighScrewBossIssue>()) {
const auto& aHSBIssue = static_cast<const DFMMolding_HighScrewBossIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected max height", aHSBIssue.ExpectedMaxHeight(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual height", aHSBIssue.ActualHeight(), "mm");
} else if (theIssue.IsOfType<DFMMolding_SmallDraftAngleScrewBossIssue>()) {
const auto& aSDASBIssue = static_cast<const DFMMolding_SmallDraftAngleScrewBossIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min draft angle",
ToDegrees (aSDASBIssue.ExpectedMinDraftAngle()), "deg");
FeatureGroupManager::PrintFeatureParameter ("actual draft angle",
ToDegrees (aSDASBIssue.ActualDraftAngle()), "deg");
} else if (theIssue.IsOfType<DFMMolding_NonChamferedScrewBossIssue>()) {
} else if (theIssue.IsOfType<DFMMolding_HighRibIssue>()) {
const auto& aHRIssue = static_cast<const DFMMolding_HighRibIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected max height", aHRIssue.ExpectedMaxHeight(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual height", aHRIssue.ActualHeight(), "mm");
} else if (theIssue.IsOfType<DFMMolding_SmallDraftAngleRibIssue>()) {
const auto& aSDARIssue = static_cast<const DFMMolding_SmallDraftAngleRibIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min draft angle", ToDegrees (aSDARIssue.ExpectedMinDraftAngle()), "deg");
FeatureGroupManager::PrintFeatureParameter ("actual draft angle", ToDegrees (aSDARIssue.ActualDraftAngle()), "deg");
}
};
aManager.Print ("issues", PrintFeatureParameters);
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/Part3.stp
.
The model | Example output |
| Part #0 ["Part3"] - solid #0 has:
High Rib Issue(s): 3
3 Rib(s) with
expected max height: 11.7371 mm
actual height: 29 mm
High Screw Boss Issue(s): 3
1 Screw Boss(es) with
expected max height: 3.50883 mm
actual height: 50 mm
1 Screw Boss(es) with
expected max height: 5.775 mm
actual height: 30 mm
1 Screw Boss(es) with
expected max height: 18 mm
actual height: 30 mm
Irregular Core Diameter Screw Boss Issue(s): 2
1 Screw Boss(es) with
expected min core diameter: 15.7209 mm
expected max core diameter: 18.85 mm
actual core diameter: 30 mm
1 Screw Boss(es) with
expected min core diameter: 18.6309 mm
expected max core diameter: 22.3392 mm
actual core diameter: 40 mm
Irregular Thickness Rib Issue(s): 3
3 Rib(s) with
expected min thickness: 12 mm
expected max thickness: 18 mm
actual thickness: 3.91237 mm
Irregular Wall Thickness Screw Boss Issue(s): 2
1 Screw Boss(es) with
expected max thickness: 18 mm
expected min thickness: 12 mm
actual thickness: 2.33922 mm
1 Screw Boss(es) with
expected max thickness: 18 mm
expected min thickness: 12 mm
actual thickness: 3.85 mm
Small Base Radius Boss Issue(s): 3
3 Screw Boss(es) with
expected min base radius: 7.5 mm
actual base radius: 1 mm
Small Base Radius Rib Issue(s): 3
3 Rib(s) with
expected min base radius: 3.75 mm
actual base radius: 1 mm
Small Draft Angle Rib Issue(s): 5
5 Rib(s) with
expected min draft angle: 0.498473 deg
actual draft angle: 0 deg
Small Draft Angle Screw Boss Issue(s): 2
2 Screw Boss(es) with
expected min draft angle: 0.498473 deg
actual draft angle: 0 deg
Small Distance Between Ribs Issue(s): 3
2 Rib(s) with
expected min distance: 60 mm
actual distance: 8 mm
1 Rib(s) with
expected min distance: 60 mm
actual distance: 21.9124 mm
Small Hole Base Radius Screw Boss Issue(s): 3
3 Screw Boss(es) with
expected min hole base radius: 7.5 mm
actual hole base radius: 0 mm
Non Chamfered Screw Boss Issue(s): 3
Total issues: 35
|
Files