Hide menu
Loading...
Searching...
No Matches
molding/dfm_analyzer/main.cxx

Refer to the Molding DFM Analyzer Example

feature_group.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#ifndef _FeatureGroup_HeaderFile
#define _FeatureGroup_HeaderFile
#include <cadex/Geom/Direction.hxx>
#include <cadex/MTKBase_Feature.hxx>
#include <cadex/MTKBase_FeatureComparator.hxx>
#include <algorithm>
#include <array>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <sstream>
#include <vector>
using namespace cadex;
using namespace std;
typedef std::pair<double, double> PairType;
typedef std::array<double, 3> ArrayType;
inline std::ostream& operator<< (std::ostream& theStream, const PairType& thePair)
{
return theStream << thePair.first << " x " << thePair.second;
}
inline std::ostream& operator<< (std::ostream& theStream, const ArrayType& theArray)
{
return theStream << theArray[0] << " x " << theArray[1] << " x " << theArray[2];
}
inline std::ostream& operator<< (std::ostream& theStream, const Geom::Direction& theDir)
{
stringstream aStream;
aStream << setprecision(2) << fixed << "(" << theDir.X() << ", " << theDir.Y() << ", " << theDir.Z() << ")";
return theStream << aStream.str();
}
class FeatureGroupManager
{
public:
void AddFeature (const char* theGroupName,
const char* theSubgroupName,
bool theHasParameters,
const MTKBase_Feature& theFeature)
{
//find or create
auto aRes = std::find_if (myGroups.begin(), myGroups.end(),
[&] (const FeatureGroup& theGroup) { return theGroup.myName == theGroupName; });
if (aRes == myGroups.end()) {
aRes = myGroups.insert (aRes, FeatureGroup (theGroupName, theSubgroupName, theHasParameters));
}
//update
auto& aGroup = *aRes;
++aGroup.myFeatureSubgroups[theFeature];
}
void Print (const char* theFeatureType, function<void (MTKBase_Feature)> thePrintFeatureParameters)
{
sort (myGroups.begin(), myGroups.end(), FeatureGroupComparator());
cout << setprecision(6);
size_t aTotalCount = 0;
for (const auto& aFeatureGroup : myGroups) {
size_t aFeatureCount = aFeatureGroup.FeatureCount();
aTotalCount += aFeatureCount;
cout << " " << aFeatureGroup.myName << ": " << aFeatureCount << endl;
if (!aFeatureGroup.myHasParameters) {
continue;
}
const char* aSubgroupName = aFeatureGroup.mySubgroupName.c_str();
for (const auto& aFeatureSubgroup : aFeatureGroup.myFeatureSubgroups) {
cout << " " << aFeatureSubgroup.second << " " << aSubgroupName << " with" << endl;
thePrintFeatureParameters (aFeatureSubgroup.first);
}
}
cout << "\n Total " << theFeatureType << ": " << aTotalCount << "\n" << endl;
}
template <typename T>
static void PrintFeatureParameter (const char* theName, const T& theValue, const char* theUnits)
{
cout << " " << theName << ": " << theValue << " " << theUnits << endl;
}
private:
class FeatureGroup
{
public:
FeatureGroup (const std::string& theName, const std::string& theSubgroupName, bool theHasParameters) :
myName (theName), mySubgroupName (theSubgroupName), myHasParameters (theHasParameters)
{}
size_t FeatureCount() const
{
size_t aCount = 0;
for (const auto& aFeatureSubgroup : myFeatureSubgroups) {
aCount += aFeatureSubgroup.second;
}
return aCount;
}
string myName;
string mySubgroupName;
bool myHasParameters;
map<MTKBase_Feature, size_t, MTKBase_FeatureComparator> myFeatureSubgroups;
};
class FeatureGroupComparator
{
public:
bool operator() (const FeatureGroup& theA, const FeatureGroup& theB) const
{
const auto& anAName = theA.myName;
const auto& aBName = theB.myName;
if (anAName == aBName) {
return false;
}
const auto& anAFeatureSubgroups = theA.myFeatureSubgroups;
const auto& aBFeatureSubgroups = theB.myFeatureSubgroups;
if (anAFeatureSubgroups.empty() || aBFeatureSubgroups.empty()) {
return anAName < aBName;
}
return MTKBase_FeatureComparator() (anAFeatureSubgroups.begin()->first,
aBFeatureSubgroups.begin()->first);
}
};
vector<FeatureGroup> myGroups;
};
#endif
Defines a 3D Direction.
Definition Direction.hxx:34
Provides possibility to compare MTK based features depending on their type and parameters.
Definition MTKBase_FeatureComparator.hxx:29
Describes a base class of MTK based features.
Definition MTKBase_Feature.hxx:33
Defines classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30

shape_processor.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#ifndef _ShapeProcessor_HeaderFile
#define _ShapeProcessor_HeaderFile
#include <cadex/Base/UTF16String.hxx>
#include <cadex/ModelData/Body.hxx>
#include <cadex/ModelData/Model.hxx>
#include <cadex/ModelData/Part.hxx>
#include <cadex/ModelData/Shell.hxx>
#include <cadex/ModelData/Solid.hxx>
#include <cadex/WallThickness_Data.hxx>
#include <iostream>
using namespace cadex;
using namespace std;
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;
};
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;
};
class SolidAndMeshProcessor : 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), aPartName, aBodyNumber);
}
}
}
++myPartIndex;
}
virtual void ProcessSolid (const ModelData::Solid& theSolid,
const UTF16String& thePartName, size_t theShapeIndex) = 0;
protected:
size_t myPartIndex = 0;
};
#endif
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
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition UTF16String.hxx:30
bool IsEmpty() const
Returns true if the string is empty.
Definition UTF16String.cxx:337

main.cxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#include <cadex/DFMMolding_Analyzer.hxx>
#include <cadex/DFMMolding_AnalyzerParameters.hxx>
#include <cadex/DFMMolding_HighRibIssue.hxx>
#include <cadex/DFMMolding_HighScrewBossIssue.hxx>
#include <cadex/DFMMolding_IrregularCoreDepthScrewBossIssue.hxx>
#include <cadex/DFMMolding_IrregularCoreDiameterScrewBossIssue.hxx>
#include <cadex/DFMMolding_IrregularThicknessRibIssue.hxx>
#include <cadex/DFMMolding_IrregularWallThicknessIssue.hxx>
#include <cadex/DFMMolding_IrregularWallThicknessScrewBossIssue.hxx>
#include <cadex/DFMMolding_LargeWallThicknessIssue.hxx>
#include <cadex/DFMMolding_RibIssue.hxx>
#include <cadex/DFMMolding_ScrewBossIssue.hxx>
#include <cadex/DFMMolding_SmallBaseRadiusRibIssue.hxx>
#include <cadex/DFMMolding_SmallBaseRadiusScrewBossIssue.hxx>
#include <cadex/DFMMolding_SmallDistanceBetweenBossesIssue.hxx>
#include <cadex/DFMMolding_SmallDraftAngleRibIssue.hxx>
#include <cadex/DFMMolding_SmallDraftAngleScrewBossIssue.hxx>
#include <cadex/DFMMolding_SmallDraftAngleWallIssue.hxx>
#include <cadex/DFMMolding_SmallDistanceBetweenRibsIssue.hxx>
#include <cadex/DFMMolding_SmallHoleBaseRadiusScrewBossIssue.hxx>
#include <cadex/DFMMolding_SmallWallThicknessIssue.hxx>
#include <cadex/DFMMolding_NonChamferedScrewBossIssue.hxx>
#include <cadex/LicenseManager_Activate.h>
#include <cadex/Molding_Analyzer.hxx>
#include <cadex/Molding_Data.hxx>
#include <cadex/Molding_FeatureRecognizer.hxx>
#include <cadex/Molding_FeatureRecognizerParameters.hxx>
#include <cadex/Molding_Rib.hxx>
#include <cadex/Molding_ScrewBoss.hxx>
#include <cadex/ModelData/Model.hxx>
#include <cadex/ModelData/ModelReader.hxx>
#include <cadex/MTKBase_Feature.hxx>
#include <cadex/MTKBase_FeatureList.hxx>
#define _USE_MATH_DEFINES
#include <math.h>
#include <unordered_map>
#include "../../helpers/feature_group.hxx"
#include "../../helpers/shape_processor.hxx"
#include "../../mtk_license.cxx"
using namespace cadex;
using namespace std;
double ToDegrees (double theAngleRad)
{
return theAngleRad * 180. / M_PI;
}
void PrintIssues (const MTKBase_FeatureList& theIssueList)
{
FeatureGroupManager aManager;
//group by parameters to provide more compact information about issues
for (size_t i = 0; i < theIssueList.Size(); ++i) {
const auto& anIssue = theIssueList[i];
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_IrregularWallThicknessScrewBossIssue>()) {
aManager.AddFeature ("Irregular Wall Thickness 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_SmallBaseRadiusScrewBossIssue>()) {
aManager.AddFeature ("Small Base Radius 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_SmallHoleBaseRadiusScrewBossIssue>()) {
aManager.AddFeature ("Small Hole Base Radius 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_IrregularThicknessRibIssue>()) {
aManager.AddFeature ("Irregular Thickness Rib Issue(s)", "Rib(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMMolding_SmallBaseRadiusRibIssue>()) {
aManager.AddFeature ("Small Base Radius 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);
} else if (anIssue.IsOfType<DFMMolding_SmallDistanceBetweenRibsIssue>()) {
aManager.AddFeature ("Small Distance Between Ribs Issue(s)", "Rib(s)", true, anIssue);
}
else if (anIssue.IsOfType<DFMMolding_IrregularWallThicknessIssue>()) {
aManager.AddFeature ("Irregular Wall Thickness Issue(s)", "Wall(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMMolding_LargeWallThicknessIssue>()) {
aManager.AddFeature ("Large Wall Thickness Issue(s)", "Wall(s)", true, anIssue);
} else if(anIssue.IsOfType<DFMMolding_SmallWallThicknessIssue>()) {
aManager.AddFeature ("Small Wall Thickness Issue(s)", "Wall(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMMolding_SmallDraftAngleWallIssue>()) {
aManager.AddFeature ("Small Draft Angle Wall Issue(s)", "Wall(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMMolding_SmallDistanceBetweenBossesIssue>()) {
aManager.AddFeature ("Small Distance Between Bosses Issue(s)", "Boss(es)", true, anIssue);
}
}
//print
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_IrregularWallThicknessScrewBossIssue>()) {
const auto& aIWTSBIssue = static_cast<const DFMMolding_IrregularWallThicknessScrewBossIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected max thickness", aIWTSBIssue.ExpectedMaxThickness(), "mm");
FeatureGroupManager::PrintFeatureParameter ("expected min thickness", aIWTSBIssue.ExpectedMinThickness(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual thickness", aIWTSBIssue.ActualThickness(), "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_SmallBaseRadiusScrewBossIssue>()) {
const auto& aSBRSBIssue = static_cast<const DFMMolding_SmallBaseRadiusScrewBossIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min base radius", aSBRSBIssue.ExpectedMinBaseRadius(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual base radius", aSBRSBIssue.ActualBaseRadius(), "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_SmallHoleBaseRadiusScrewBossIssue>()) {
const auto& aSHBRSBIssue = static_cast<const DFMMolding_SmallHoleBaseRadiusScrewBossIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min hole base radius",
aSHBRSBIssue.ExpectedMinHoleBaseRadius(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual hole base radius",
aSHBRSBIssue.ActualHoleBaseRadius(), "mm");
} else if (theIssue.IsOfType<DFMMolding_NonChamferedScrewBossIssue>()) {
//no parameters
} 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_IrregularThicknessRibIssue>()) {
const auto& aITRIssue = static_cast<const DFMMolding_IrregularThicknessRibIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min thickness", aITRIssue.ExpectedMinThickness(), "mm");
FeatureGroupManager::PrintFeatureParameter ("expected max thickness", aITRIssue.ExpectedMaxThickness(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual thickness", aITRIssue.ActualThickness(), "mm");
} else if (theIssue.IsOfType<DFMMolding_SmallBaseRadiusRibIssue>()) {
const auto& aSBRRIssue = static_cast<const DFMMolding_SmallBaseRadiusRibIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min base radius", aSBRRIssue.ExpectedMinBaseRadius(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual base radius", aSBRRIssue.ActualBaseRadius(), "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");
} else if (theIssue.IsOfType<DFMMolding_SmallDistanceBetweenRibsIssue>()) {
const auto& aSDBRIssue = static_cast<const DFMMolding_SmallDistanceBetweenRibsIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min distance", aSDBRIssue.ExpectedMinDistanceBetweenRibs(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual distance", aSDBRIssue.ActualDistanceBetweenRibs(), "mm");
} else if (theIssue.IsOfType<DFMMolding_IrregularWallThicknessIssue>()) {
const auto& aIWTIIssue = static_cast<const DFMMolding_IrregularWallThicknessIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected max thickness", aIWTIIssue.ExpectedMaxThickness(), "mm");
FeatureGroupManager::PrintFeatureParameter ("expected min thickness", aIWTIIssue.ExpectedMinThickness(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual thickness", aIWTIIssue.ActualThickness(), "mm");
} else if (theIssue.IsOfType<DFMMolding_LargeWallThicknessIssue>()) {
const auto& aHWTIIssue = static_cast<const DFMMolding_LargeWallThicknessIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected max thickness", aHWTIIssue.ExpectedMaxThickness(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual thickness", aHWTIIssue.ActualThickness(), "mm");
} else if (theIssue.IsOfType<DFMMolding_SmallWallThicknessIssue>()) {
const auto& aSWTIIssue = static_cast<const DFMMolding_SmallWallThicknessIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min thickness", aSWTIIssue.ExpectedMinThickness(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual thickness", aSWTIIssue.ActualThickness(), "mm");
} else if (theIssue.IsOfType<DFMMolding_SmallDraftAngleWallIssue>()) {
const auto& aSDAWIssue = static_cast<const DFMMolding_SmallDraftAngleWallIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min draft angle", ToDegrees (aSDAWIssue.ExpectedMinDraftAngle()), "deg");
FeatureGroupManager::PrintFeatureParameter ("actual draft angle", ToDegrees (aSDAWIssue.ActualDraftAngle()), "deg");
} else if (theIssue.IsOfType<DFMMolding_SmallDistanceBetweenBossesIssue>()) {
const auto& aSDBBIssue = static_cast<const DFMMolding_SmallDistanceBetweenBossesIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min distance", aSDBBIssue.ExpectedMinDistanceBetweenBosses(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual distance", aSDBBIssue.ActualDistanceBetweenBosses(), "mm");
}
};
aManager.Print ("issues", PrintFeatureParameters);
}
class PartProcessor : public SolidProcessor
{
public:
PartProcessor ()
{}
void ProcessSolid (const ModelData::Solid& theSolid) override
{
// Set up recognizer
Molding_FeatureRecognizerParameters aRecognizerParameters;
aRecognizerParameters.SetMaxRibThickness (30.0);
aRecognizerParameters.SetMaxRibDraftAngle (0.2);
aRecognizerParameters.SetMaxRibTaperAngle (0.1);
Molding_FeatureRecognizer aRecognizer(aRecognizerParameters);
//Set up analyzer
Molding_Analyzer anAnalyzer;
anAnalyzer.AddTool (aRecognizer);
// Fill molding data
Molding_Data aData = anAnalyzer.Perform (theSolid);
// Run dfm analyzer for found features
DFMMolding_Analyzer aDFMAnalyzer (aParameters);
auto anIssueList = aDFMAnalyzer.Perform (aData);
PrintIssues (anIssueList);
}
};
int main (int argc, char* argv[])
{
auto aKey = MTKLicenseKey::Value();
// Activate the license (aKey must be defined in mtk_license.cxx)
if (!CADExLicense_Activate (aKey)) {
cerr << "Failed to activate Manufacturing Toolkit license." << endl;
return 1;
}
if (argc != 2) {
cerr << "Usage: " << argv[0] << " <input_file>, where:" << endl;
cerr << " <input_file> is a name of the file to be read" << endl;
return 1;
}
const char* aSource = argv[1];
// Reading the file
if (!aReader.Read (aSource, aModel)) {
cerr << "Failed to read the file " << aSource << endl;
return 1;
}
cout << "Model: " << aModel.Name() << "\n" << endl;
//processing
PartProcessor aPartProcessor;
ModelData::ModelElementUniqueVisitor aVisitor (aPartProcessor);
aModel.Accept (aVisitor);
return 0;
}
Provides an interface to run DFM Molding analysis.
Definition DFMMolding_Analyzer.hxx:40
Defines parameters used in injection molding design analysis.
Definition DFMMolding_AnalyzerParameters.hxx:32
Describes large height rib issues found during injection molding design analysis.
Definition DFMMolding_HighRibIssue.hxx:28
Describes high screw boss issues found during injection molding design analysis.
Definition DFMMolding_HighScrewBossIssue.hxx:34
Describes irregular core depth screw boss issues found during injection molding design analysis.
Definition DFMMolding_IrregularCoreDepthScrewBossIssue.hxx:34
Describes irregular screw boss core diameter issues found during injection molding design analysis.
Definition DFMMolding_IrregularCoreDiameterScrewBossIssue.hxx:34
Describes irregular thickness rib issues found during injection molding design analysis.
Definition DFMMolding_IrregularThicknessRibIssue.hxx:28
Describes wall with irregular thickness issues found during molding design analysis.
Definition DFMMolding_IrregularWallThicknessIssue.hxx:29
Describes irregular wall thickness screw boss issues found during injection molding design analysis.
Definition DFMMolding_IrregularWallThicknessScrewBossIssue.hxx:34
Describes wall with large thickness issues found during molding design analysis.
Definition DFMMolding_LargeWallThicknessIssue.hxx:28
Describes screw boss without top chamfer issues found during injection molding design analysis.
Definition DFMMolding_NonChamferedScrewBossIssue.hxx:28
Describes small rib base radius issues found during injection molding design analysis.
Definition DFMMolding_SmallBaseRadiusRibIssue.hxx:28
Describes small screw boss base radius issues found during injection molding design analysis.
Definition DFMMolding_SmallBaseRadiusScrewBossIssue.hxx:28
Describes a base class for small distance between bosses issues found during molding design analysis.
Definition DFMMolding_SmallDistanceBetweenBossesIssue.hxx:34
Describes a class for small distance between ribs issues found during molding design analysis.
Definition DFMMolding_SmallDistanceBetweenRibsIssue.hxx:30
Describes small draft angle rib issues found during injection molding design analysis.
Definition DFMMolding_SmallDraftAngleRibIssue.hxx:28
Describes small screw boss draft angle issues found during injection molding design analysis.
Definition DFMMolding_SmallDraftAngleScrewBossIssue.hxx:28
Describes small wall draft angle issues found during injection molding design analysis.
Definition DFMMolding_SmallDraftAngleWallIssue.hxx:30
Describes small screw boss hole base radius issues found during injection molding design analysis.
Definition DFMMolding_SmallHoleBaseRadiusScrewBossIssue.hxx:28
Describes wall with small thickness issues found during molding design analysis.
Definition DFMMolding_SmallWallThicknessIssue.hxx:28
Defines a list of features.
Definition MTKBase_FeatureList.hxx:36
size_t Size() const
Returns the number of elements in the list.
Definition MTKBase_FeatureList.cxx:88
Defines a visitor that visits each unique element only once.
Definition ModelElementVisitor.hxx:87
Provides MTK data model.
Definition Model.hxx:40
UTF16String Name() const
Returns a model name.
Definition Model.cxx:250
void Accept(ModelElementVisitor &theVisitor) const
Accepts a visitor.
Definition Model.cxx:270
Reads STEP and native format.
Definition ModelReader.hxx:29
bool Read(const UTF16String &theFilePath, ModelData::Model &theModel)
Reads the file at the specified path into the specified model.
Definition ModelReader.cxx:227
Provides an interface to run several analyzer tools for different types of Molding processing.
Definition Molding_Analyzer.hxx:41
Molding_Data Perform(const ModelData::Solid &theSolid, const ProgressStatus &theProgressStatus=ProgressStatus())
Runs the analyzing process.
Definition Molding_Analyzer.cxx:80
void AddTool(const Molding_AnalyzerTool &theTool)
Adds additional tool to run during analyzing process.
Definition Molding_Analyzer.cxx:101
Defines data used in Molding analysis.
Definition Molding_Data.hxx:35
Provides an interface to recognizing molding features.
Definition Molding_FeatureRecognizer.hxx:37