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

Refer to the Sheet Metal 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/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 cadex;
using namespace std;
const char* SmallDistanceIssueName (const DFMSheetMetal_SmallDistanceBetweenFeaturesIssue& theIssue)
{
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)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue>()) {
return "Small Distance Between Extruded Holes Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue>()) {
return "Small Distance Between Hole And Bend Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue>()) {
return "Small Distance Between Hole And Cutout Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue>()) {
return "Small Distance Between Hole And Edge Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue>()) {
return "Small Distance Between Hole And Louver Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue>()) {
return "Small Distance Between Hole And Notch Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHolesIssue>()) {
return "Small Distance Between Holes Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue>()) {
return "Small Distance Between Notch And Bend Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenNotchesIssue>()) {
return "Small Distance Between Notches Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenTabsIssue>()) {
return "Small Distance Between Tabs Issue(s)";
}
return "Small Distance Between Feature(s)";
}
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];
if (anIssue.IsOfType<DFMSheetMetal_SmallRadiusBendIssue>()) {
aManager.AddFeature ("Small Radius Bend Issue(s)", "Bend(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_SmallDiameterHoleIssue>()) {
aManager.AddFeature ("Small Diameter Hole Issue(s)", "Hole(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_FlatPatternInterferenceIssue>()) {
aManager.AddFeature ("Flat Pattern Interference Issue(s)", "", false, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue>()) {
aManager.AddFeature ("Irregular Corner Fillet Radius Notch Issue(s)", "Notch(es)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_IrregularDepthExtrudedHoleIssue>()) {
aManager.AddFeature ("Irregular Depth Extruded Hole Issue(s)", "Hole(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_IrregularRadiusOpenHemBendIssue>()) {
aManager.AddFeature ("Irregular Radius Open Hem Bend Issue(s)", "Hem Bend(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_IrregularSizeBendReliefIssue>()) {
aManager.AddFeature ("Irregular Size Bend Relief Issue(s)", "Bend(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_LargeDepthBeadIssue>()) {
aManager.AddFeature ("Large Depth Bead Issue(s)", "Bead(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_InconsistentRadiusBendIssue>()) {
aManager.AddFeature ("Inconsistent Radius Bend Issue(s)", "Bend(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_SmallLengthFlangeIssue>()) {
aManager.AddFeature ("Small Length Flange Issue(s)", "Flange(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_SmallLengthHemBendFlangeIssue>()) {
aManager.AddFeature ("Small Length Hem Bend Flange Issue(s)", "Flange(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_IrregularSizeNotchIssue>()) {
aManager.AddFeature ("Irregular Size Notch Issue(s)", "Notch(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_IrregularSizeTabIssue>()) {
aManager.AddFeature ("Irregular Size Tab Issue(s)", "Tab(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_SmallDepthLouverIssue>()) {
aManager.AddFeature ("Small Depth Louver Issue(s)", "Louver(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenFeaturesIssue>()) {
const auto& aSDBFIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenFeaturesIssue&> (anIssue);
aManager.AddFeature (SmallDistanceIssueName (aSDBFIssue), "Distance(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_NonStandardSheetThicknessIssue>()) {
aManager.AddFeature ("Non Standard Sheet Thickness Issue(s)", "Sheet Thickness(s)", true, anIssue);
} else if (anIssue.IsOfType<DFMSheetMetal_NonStandardSheetSizeIssue>()) {
aManager.AddFeature ("Non Standard Sheet Size Issue(s)", "Sheet Size(s)", true, anIssue);
}
}
//print
auto PrintFeatureParameters = [] (const MTKBase_Feature& theIssue)
{
if (theIssue.IsOfType<DFMSheetMetal_SmallRadiusBendIssue>()) {
const auto& aSRBIssue = static_cast<const DFMSheetMetal_SmallRadiusBendIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min radius", aSRBIssue.ExpectedMinRadius(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual radius", aSRBIssue.ActualRadius(), "mm");
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDiameterHoleIssue>()) {
const auto& aSDHIssue = static_cast<const DFMSheetMetal_SmallDiameterHoleIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min diameter", aSDHIssue.ExpectedMinDiameter(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual diameter", aSDHIssue.ActualDiameter(), "mm");
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenFeaturesIssue>()) {
const auto& aSDBFIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenFeaturesIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter (
"expected min distance", aSDBFIssue.ExpectedMinDistanceBetweenFeatures(), "mm");
FeatureGroupManager::PrintFeatureParameter (
"actual distance", aSDBFIssue.ActualDistanceBetweenFeatures(), "mm");
} else if (theIssue.IsOfType<DFMSheetMetal_FlatPatternInterferenceIssue>()) {
//no parameters
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue>()) {
const auto& aICFRNIssue = static_cast<const DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected corner fillet radius", aICFRNIssue.ExpectedCornerFilletRadius(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual corner fillet radius", aICFRNIssue.ActualCornerFilletRadius(), "mm");
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularDepthExtrudedHoleIssue>()) {
const auto& aIDEHIssue = static_cast<const DFMSheetMetal_IrregularDepthExtrudedHoleIssue&> (theIssue);
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");
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularRadiusOpenHemBendIssue>()) {
const auto& aIROHBIssue = static_cast<const DFMSheetMetal_IrregularRadiusOpenHemBendIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected radius", aIROHBIssue.ExpectedRadius(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual radius", aIROHBIssue.ActualRadius(), "mm");
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularSizeBendReliefIssue>()) {
const auto& aISBRIssue = static_cast<const DFMSheetMetal_IrregularSizeBendReliefIssue&> (theIssue);
const auto& anExpectedRelief = aISBRIssue.ExpectedMinBendRelief();
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");
}
} else if (theIssue.IsOfType<DFMSheetMetal_LargeDepthBeadIssue>()) {
const auto& aLDBIssue = static_cast<const DFMSheetMetal_LargeDepthBeadIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected max depth", aLDBIssue.ExpectedMaxDepth(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual depth", aLDBIssue.ActualDepth(), "mm");
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDepthLouverIssue>()) {
const auto& aLDBIssue = static_cast<const DFMSheetMetal_SmallDepthLouverIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min depth", aLDBIssue.ExpectedMinDepth(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual depth", aLDBIssue.ActualDepth(), "mm");
} else if (theIssue.IsOfType<DFMSheetMetal_InconsistentRadiusBendIssue>()) {
const auto& aIRBIssue = static_cast<const DFMSheetMetal_InconsistentRadiusBendIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected max radius", aIRBIssue.ExpectedRadius(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual radius", aIRBIssue.ActualRadius(), "mm");
} else if (theIssue.IsOfType<DFMSheetMetal_SmallLengthFlangeIssue>()) {
const auto& aSLFIssue = static_cast<const DFMSheetMetal_SmallLengthFlangeIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min length", aSLFIssue.ExpectedMinLength(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual length", aSLFIssue.ActualLength(), "mm");
} else if (theIssue.IsOfType<DFMSheetMetal_SmallLengthHemBendFlangeIssue>()) {
const auto& aSLHBFIssue = static_cast<const DFMSheetMetal_SmallLengthHemBendFlangeIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter ("expected min length", aSLHBFIssue.ExpectedMinLength(), "mm");
FeatureGroupManager::PrintFeatureParameter ("actual length", aSLHBFIssue.ActualLength(), "mm");
} else if (theIssue.IsOfType <DFMSheetMetal_IrregularSizeNotchIssue>()) {
const auto& aISNIssue = static_cast<const DFMSheetMetal_IrregularSizeNotchIssue&> (theIssue);
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");
} else if (theIssue.IsOfType <DFMSheetMetal_IrregularSizeTabIssue>()) {
const auto& aISTIssue = static_cast<const DFMSheetMetal_IrregularSizeTabIssue&> (theIssue);
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");
} else if (theIssue.IsOfType<DFMSheetMetal_NonStandardSheetThicknessIssue>()) {
const auto& aNSSTIssue = static_cast<const DFMSheetMetal_NonStandardSheetThicknessIssue&> (theIssue);
FeatureGroupManager::PrintFeatureParameter (
"nearest standard sheet thickness", aNSSTIssue.NearestStandardSheetThickness(), "mm");
FeatureGroupManager::PrintFeatureParameter (
"actual sheet thickness", aNSSTIssue.ActualSheetThickness(), "mm");
} else if (theIssue.IsOfType<DFMSheetMetal_NonStandardSheetSizeIssue>()) {
const auto& aNSSSIssue = static_cast<const DFMSheetMetal_NonStandardSheetSizeIssue&> (theIssue);
const auto& aNearestStandardSize = aNSSSIssue.NearestStandardSheetSize();
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:
void ProcessSolid (const ModelData::Solid& theSolid) override
{
auto anIssueList = myAnalyzer.Perform (theSolid);
PrintIssues (anIssueList);
}
void ProcessShell (const ModelData::Shell& theShell) override
{
auto anIssueList = myAnalyzer.Perform (theShell);
PrintIssues (anIssueList);
}
private:
};
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 Sheet Metal analysis.
Definition DFMSheetMetal_Analyzer.hxx:44
Describes interference issue for flat pattern found during sheet metal design analysis.
Definition DFMSheetMetal_FlatPatternInterferenceIssue.hxx:32
Describes inconsistent radius bend issues found during sheet metal design analysis.
Definition DFMSheetMetal_InconsistentRadiusBendIssue.hxx:28
Describes irregular notch corner fillet radius issue found during sheet metal design analysis.
Definition DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue.hxx:31
Describes irregular depth extruded hole issue found during sheet metal design analysis.
Definition DFMSheetMetal_IrregularDepthExtrudedHoleIssue.hxx:30
Describes irregular open hem bend radius issue found during sheet metal design analysis.
Definition DFMSheetMetal_IrregularRadiusOpenHemBendIssue.hxx:30
Describes irregular size bend relief issues found during sheet metal design analysis.
Definition DFMSheetMetal_IrregularSizeBendReliefIssue.hxx:30
SheetMetal_BendRelief ExpectedMinBendRelief() const
Definition DFMSheetMetal_IrregularSizeBendReliefIssue.cxx:123
Describes irregular size notch issues found during sheet metal design analysis.
Definition DFMSheetMetal_IrregularSizeNotchIssue.hxx:31
Describes irregular size tab issues found during sheet metal design analysis.
Definition DFMSheetMetal_IrregularSizeTabIssue.hxx:31
Describes large depth bead issue found during sheet metal design analysis.
Definition DFMSheetMetal_LargeDepthBeadIssue.hxx:30
Describes non standard sheet size issue found during sheet metal design analysis.
Definition DFMSheetMetal_NonStandardSheetSizeIssue.hxx:30
const DFMSheetMetal_SheetSize & NearestStandardSheetSize() const
Definition DFMSheetMetal_NonStandardSheetSizeIssue.cxx:68
Describes non standard sheet thickness issue found during sheet metal design analysis.
Definition DFMSheetMetal_NonStandardSheetThicknessIssue.hxx:28
Describes small depth louver issue found during sheet metal design analysis.
Definition DFMSheetMetal_SmallDepthLouverIssue.hxx:30
Describes small diameter hole issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallDiameterHoleIssue.hxx:28
Describes small distance between bend and louver issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue.hxx:31
Describes small distance between complex hole and bend issues found during sheet metal design analysi...
Definition DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue.hxx:31
Describes small distance detween extruded hole and edge issues found during sheet metal design analys...
Definition DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndEdgeIssue.hxx:34
Describes small distance between extruded holes issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue.hxx:30
Describes a base class for small distance issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallDistanceBetweenFeaturesIssue.hxx:34
Describes small distance between hole and bend issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue.hxx:31
Describes small distance between hole and cutout issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue.hxx:31
Describes small distance detween hole and edge issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue.hxx:34
Describes small distance between hole and louver issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue.hxx:31
Describes small distance detween hole and notch issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue.hxx:31
Describes small distance detween holes issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallDistanceBetweenHolesIssue.hxx:30
Describes small distance detween notch and bend issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue.hxx:31
Describes small distance between notches issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallDistanceBetweenNotchesIssue.hxx:30
Describes small distance between tabs issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallDistanceBetweenTabsIssue.hxx:30
Describes small length flange issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallLengthFlangeIssue.hxx:31
Describes small length hem bend flange issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallLengthHemBendFlangeIssue.hxx:30
Describes small radius bend issues found during sheet metal design analysis.
Definition DFMSheetMetal_SmallRadiusBendIssue.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:231