#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 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,
{
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));
}
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;
}
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
#include <cadex/DFMSheetMetal_Analyzer.hxx>
#include <cadex/DFMSheetMetal_AnalyzerParameters.hxx>
#include <cadex/DFMSheetMetal_FlatPatternInterferenceIssue.hxx>
#include <cadex/DFMSheetMetal_InconsistentRadiusBendIssue.hxx>
#include <cadex/DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue.hxx>
#include <cadex/DFMSheetMetal_IrregularDepthExtrudedHoleIssue.hxx>
#include <cadex/DFMSheetMetal_IrregularRadiusOpenHemBendIssue.hxx>
#include <cadex/DFMSheetMetal_IrregularSizeBendReliefIssue.hxx>
#include <cadex/DFMSheetMetal_IrregularSizeNotchIssue.hxx>
#include <cadex/DFMSheetMetal_IrregularSizeTabIssue.hxx>
#include <cadex/DFMSheetMetal_LargeDepthBeadIssue.hxx>
#include <cadex/DFMSheetMetal_NonStandardSheetSizeIssue.hxx>
#include <cadex/DFMSheetMetal_NonStandardSheetThicknessIssue.hxx>
#include <cadex/DFMSheetMetal_SheetSize.hxx>
#include <cadex/DFMSheetMetal_SmallDepthLouverIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDiameterHoleIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndEdgeIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenHolesIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenNotchesIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDistanceBetweenTabsIssue.hxx>
#include <cadex/DFMSheetMetal_SmallLengthFlangeIssue.hxx>
#include <cadex/DFMSheetMetal_SmallLengthHemBendFlangeIssue.hxx>
#include <cadex/DFMSheetMetal_SmallRadiusBendIssue.hxx>
#include <cadex/LicenseManager_Activate.h>
#include <cadex/Measurements/ValidationProperties.hxx>
#include <cadex/ModelData/Model.hxx>
#include <cadex/ModelData/ModelReader.hxx>
#include <cadex/MTKBase_FeatureList.hxx>
#include <cadex/SheetMetal_BendRelief.hxx>
#include "../../helpers/feature_group.hxx"
#include "../../helpers/shape_processor.hxx"
#include "../../mtk_license.cxx"
using namespace std;
{
return "Small Distance Between Bend And Louver Issue(s)";
return "Small Distance Between Extruded Hole And Bend Issue(s)";
return "Small Distance Between Extruded Hole And Edge Issue(s)";
return "Small Distance Between Extruded Holes Issue(s)";
return "Small Distance Between Hole And Bend Issue(s)";
return "Small Distance Between Hole And Cutout Issue(s)";
return "Small Distance Between Hole And Edge Issue(s)";
return "Small Distance Between Hole And Louver Issue(s)";
return "Small Distance Between Hole And Notch Issue(s)";
return "Small Distance Between Holes Issue(s)";
return "Small Distance Between Notch And Bend Issue(s)";
return "Small Distance Between Notches Issue(s)";
return "Small Distance Between Tabs Issue(s)";
}
return "Small Distance Between Feature(s)";
}
{
FeatureGroupManager aManager;
for (
size_t i = 0; i < theIssueList.
Size(); ++i) {
const auto& anIssue = theIssueList[i];
aManager.AddFeature ("Small Radius Bend Issue(s)", "Bend(s)", true, anIssue);
aManager.AddFeature ("Small Diameter Hole Issue(s)", "Hole(s)", true, anIssue);
aManager.AddFeature ("Flat Pattern Interference Issue(s)", "", false, anIssue);
aManager.AddFeature ("Irregular Corner Fillet Radius Notch Issue(s)", "Notch(es)", true, anIssue);
aManager.AddFeature ("Irregular Depth Extruded Hole Issue(s)", "Hole(s)", true, anIssue);
aManager.AddFeature ("Irregular Radius Open Hem Bend Issue(s)", "Hem Bend(s)", true, anIssue);
aManager.AddFeature ("Irregular Size Bend Relief Issue(s)", "Bend(s)", true, anIssue);
aManager.AddFeature ("Large Depth Bead Issue(s)", "Bead(s)", true, anIssue);
aManager.AddFeature ("Inconsistent Radius Bend Issue(s)", "Bend(s)", true, anIssue);
aManager.AddFeature ("Small Length Flange Issue(s)", "Flange(s)", true, anIssue);
aManager.AddFeature ("Small Length Hem Bend Flange Issue(s)", "Flange(s)", true, anIssue);
aManager.AddFeature ("Irregular Size Notch Issue(s)", "Notch(s)", true, anIssue);
aManager.AddFeature ("Irregular Size Tab Issue(s)", "Tab(s)", true, anIssue);
aManager.AddFeature ("Small Depth Louver Issue(s)", "Louver(s)", true, anIssue);
aManager.AddFeature (SmallDistanceIssueName (aSDBFIssue), "Distance(s)", true, anIssue);
aManager.AddFeature ("Non Standard Sheet Thickness Issue(s)", "Sheet Thickness(s)", true, anIssue);
aManager.AddFeature ("Non Standard Sheet Size Issue(s)", "Sheet Size(s)", true, anIssue);
}
}
{
FeatureGroupManager::PrintFeatureParameter ("expected min radius", aSRBIssue.ExpectedMinRadius(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual radius", aSRBIssue.ActualRadius(), "mm");
FeatureGroupManager::PrintFeatureParameter ("expected min diameter", aSDHIssue.ExpectedMinDiameter(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual diameter", aSDHIssue.ActualDiameter(), "mm");
FeatureGroupManager::PrintFeatureParameter (
"expected min distance", aSDBFIssue.ExpectedMinDistanceBetweenFeatures(), "mm");
FeatureGroupManager::PrintFeatureParameter (
"actual distance", aSDBFIssue.ActualDistanceBetweenFeatures(), "mm");
FeatureGroupManager::PrintFeatureParameter ("expected corner fillet radius", aICFRNIssue.ExpectedCornerFilletRadius(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual corner fillet radius", aICFRNIssue.ActualCornerFilletRadius(), "mm");
FeatureGroupManager::PrintFeatureParameter ("expected max extruded height", aIDEHIssue.ExpectedMaxExtrudedHeight(), "mm");
FeatureGroupManager::PrintFeatureParameter ("expected min extruded height", aIDEHIssue.ExpectedMinExtrudedHeight(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual extruded height", aIDEHIssue.ActualExtrudedHeight(), "mm");
FeatureGroupManager::PrintFeatureParameter ("expected radius", aIROHBIssue.ExpectedRadius(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual radius", aIROHBIssue.ActualRadius(), "mm");
const auto& aFirstActualRelief = aISBRIssue.FirstActualRelief();
const auto& aSecondActualRelief = aISBRIssue.SecondActualRelief();
FeatureGroupManager::PrintFeatureParameter (
"expected min relief size (LxW)",
std::make_pair (anExpectedRelief.Length(), anExpectedRelief.Width()),
"mm");
if (aFirstActualRelief && aSecondActualRelief) {
FeatureGroupManager::PrintFeatureParameter (
"first actual relief size (LxW)",
std::make_pair (aFirstActualRelief.Length(), aFirstActualRelief.Width()),
"mm");
FeatureGroupManager::PrintFeatureParameter (
"second actual relief size (LxW)",
std::make_pair (aSecondActualRelief.Length(), aSecondActualRelief.Width()),
"mm");
} else if (!aFirstActualRelief) {
FeatureGroupManager::PrintFeatureParameter (
"actual relief size (LxW)",
std::make_pair (aSecondActualRelief.Length(), aSecondActualRelief.Width()),
"mm");
} else {
FeatureGroupManager::PrintFeatureParameter (
"actual relief size (LxW)",
std::make_pair (aFirstActualRelief.Length(), aFirstActualRelief.Width()),
"mm");
}
FeatureGroupManager::PrintFeatureParameter ("expected max depth", aLDBIssue.ExpectedMaxDepth(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual depth", aLDBIssue.ActualDepth(), "mm");
FeatureGroupManager::PrintFeatureParameter ("expected min depth", aLDBIssue.ExpectedMinDepth(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual depth", aLDBIssue.ActualDepth(), "mm");
FeatureGroupManager::PrintFeatureParameter ("expected max radius", aIRBIssue.ExpectedRadius(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual radius", aIRBIssue.ActualRadius(), "mm");
FeatureGroupManager::PrintFeatureParameter ("expected min length", aSLFIssue.ExpectedMinLength(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual length", aSLFIssue.ActualLength(), "mm");
FeatureGroupManager::PrintFeatureParameter ("expected min length", aSLHBFIssue.ExpectedMinLength(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual length", aSLHBFIssue.ActualLength(), "mm");
FeatureGroupManager::PrintFeatureParameter (
"expected size (LxW)",
std::make_pair (aISNIssue.ExpectedLength(), aISNIssue.ExpectedWidth()),
"mm");
FeatureGroupManager::PrintFeatureParameter (
"actual size (LxW)",
std::make_pair (aISNIssue.ActualLength(), aISNIssue.ActualWidth()),
"mm");
FeatureGroupManager::PrintFeatureParameter (
"expected size (LxW)",
std::make_pair (aISTIssue.ExpectedLength(), aISTIssue.ExpectedWidth()),
"mm");
FeatureGroupManager::PrintFeatureParameter (
"actual size (LxW)",
std::make_pair (aISTIssue.ActualLength(), aISTIssue.ActualWidth()),
"mm");
FeatureGroupManager::PrintFeatureParameter (
"nearest standard sheet thickness", aNSSTIssue.NearestStandardSheetThickness(), "mm");
FeatureGroupManager::PrintFeatureParameter (
"actual sheet thickness", aNSSTIssue.ActualSheetThickness(), "mm");
const auto& anActualSize = aNSSSIssue.ActualSheetSize();
FeatureGroupManager::PrintFeatureParameter (
"nearest standard sheet size (LxW)",
std::make_pair (aNearestStandardSize.Length(), aNearestStandardSize.Width()),
"mm");
FeatureGroupManager::PrintFeatureParameter (
"actual sheet size (LxW)",
std::make_pair (anActualSize.Length(), anActualSize.Width()),
"mm");
}
};
aManager.Print ("issues", PrintFeatureParameters);
}
class PartProcessor : public ShapeProcessor
{
public:
{
auto anIssueList = myAnalyzer.Perform (theSolid);
PrintIssues (anIssueList);
}
{
auto anIssueList = myAnalyzer.Perform (theShell);
PrintIssues (anIssueList);
}
private:
};
int main (int argc, char* argv[])
{
auto aKey = MTKLicenseKey::Value();
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];
if (!aReader.
Read (aSource, aModel)) {
cerr << "Failed to read the file " << aSource << endl;
return 1;
}
cout <<
"Model: " << aModel.
Name() <<
"\n" << endl;
PartProcessor aPartProcessor;
return 0;
}
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:231