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-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger 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/ModelData_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 ModelData_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
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:34
Defines a 3D direction.
Definition: ModelData_Direction.hxx:180
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22

shape_processor.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger 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_BodyList.hxx>
#include <cadex/ModelData_BRepRepresentation.hxx>
#include <cadex/ModelData_Model.hxx>
#include <cadex/ModelData_Part.hxx>
#include <cadex/ModelData_Shell.hxx>
#include <cadex/ModelData_Solid.hxx>
#include <iostream>
using namespace cadex;
using namespace std;
class ShapeProcessor : public ModelData_Model::VoidElementVisitor
{
public:
void operator() (const ModelData_Part& thePart) override
{
auto aPartName = thePart.Name().IsEmpty() ? "noname" : thePart.Name();
auto aBRep = thePart.BRepRepresentation();
if (aBRep) {
const auto& aBodyList = aBRep.Get();
for (size_t i = 0, n = aBodyList.Size(); i < n; ++i) {
const auto& aBody = aBodyList[i];
ModelData_Shape::Iterator aShapeIt (aBody);
while (aShapeIt.HasNext()) {
const auto& aShape = aShapeIt.Next();
if (aShape.Type() == ModelData_ST_Solid) {
cout << "Part #" << myPartIndex << " [\"" << aPartName << "\"] - solid #" << std::to_string (i) << " has:" << endl;
ProcessSolid (ModelData_Solid::Cast (aShape));
} else if (aShape.Type() == ModelData_ST_Shell) {
cout << "Part #" << myPartIndex << " [\"" << aPartName << "\"] - shell #" << std::to_string (i) << " has:" << endl;
ProcessShell (ModelData_Shell::Cast (aShape));
}
}
}
}
++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_Model::VoidElementVisitor
{
public:
void operator() (const ModelData_Part& thePart) override
{
auto aPartName = thePart.Name().IsEmpty() ? "noname" : thePart.Name();
auto aBRep = thePart.BRepRepresentation();
if (aBRep) {
const auto& aBodyList = aBRep.Get();
for (size_t i = 0, n = aBodyList.Size(); i < n; ++i) {
const auto& aBody = aBodyList[i];
ModelData_Shape::Iterator aShapeIt (aBody);
while (aShapeIt.HasNext()) {
const auto& aShape = aShapeIt.Next();
if (aShape.Type() == ModelData_ST_Solid) {
cout << "Part #" << myPartIndex << " [\"" << aPartName << "\"] - solid #" << std::to_string (i) << " has:" << endl;
ProcessSolid (ModelData_Solid::Cast (aShape));
}
}
}
}
++myPartIndex;
}
virtual void ProcessSolid (const ModelData_Solid& theSolid) = 0;
private:
size_t myPartIndex = 0;
};
#endif
bool IsEmpty() const
Returns true if the string is empty.
Definition: Base_UTF16String.cxx:233
const ModelData_BodyList & Get() const
Returns an associated topological object.
Definition: ModelData_BRepRepresentation.cxx:626
Base_UTF16String Name() const
Definition: ModelData_BaseObject.cxx:218
Element visitor with empty implementation.
Definition: ModelData_Model.hxx:113
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:35
ModelData_BRepRepresentation BRepRepresentation() const
Definition: ModelData_Part.cxx:360
Iterates over subshapes in a shape.
Definition: ModelData_Shape.hxx:41
Defines a connected set of faces.
Definition: ModelData_Shell.hxx:31
Defines a topological solid.
Definition: ModelData_Solid.hxx:31

main.cxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger 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/ModelAlgo_ValidationProperty.hxx>
#include <cadex/ModelData_ModelReader.hxx>
#include <cadex/ModelData_SceneGraphElementUniqueVisitor.hxx>
#include <cadex/MTKBase_FeatureList.hxx>
#include <cadex/SheetMetal_BendRelief.hxx>
#include "../../helpers/feature_group.hxx"
#include "../../helpers/shape_processor.hxx"
#include "../../../cadex_license.cxx"
#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);
}
//Compute approximate thickness value, which can be used as the input thickness value for DFMSheetMetal_Analyzer.
double CalculateInitialThicknessValue (const ModelData_Shape& theShape)
{
double aVolume = ModelAlgo_ValidationProperty::ComputeVolume (theShape);
double aSurfaceArea = ModelAlgo_ValidationProperty::ComputeSurfaceArea (theShape);
double aThickness = aVolume / (aSurfaceArea / 2.);
return aThickness;
}
class PartProcessor : public ShapeProcessor
{
public:
void ProcessSolid (const ModelData_Solid& theSolid) override
{
double aThickness = CalculateInitialThicknessValue (theSolid);
auto anIssueList = myAnalyzer.Perform (theSolid, aThickness);
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 = LicenseKey::Value();
auto anMTKKey = MTKLicenseKey::Value();
// Activate the license (aKey must be defined in cadex_license.cxx
// and anMTKKey must be defined in mtk_license.cxx)
if (!CADExLicense_Activate (aKey)) {
cerr << "Failed to activate CAD Exchanger license." << endl;
return 1;
}
if (!CADExLicense_Activate (anMTKKey)) {
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_SceneGraphElementUniqueVisitor aVisitor (aPartProcessor);
aModel.Accept (aVisitor);
return 0;
}
Provides an interface to run DFM Sheet Metal analysis.
Definition: DFMSheetMetal_Analyzer.hxx:45
Describes interference issue for flat pattern found during sheet metal design analysis.
Definition: DFMSheetMetal_FlatPatternInterferenceIssue.hxx:33
Describes inconsistent radius bend issues found during sheet metal design analysis.
Definition: DFMSheetMetal_InconsistentRadiusBendIssue.hxx:31
Describes irregular notch corner fillet radius issue found during sheet metal design analysis.
Definition: DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue.hxx:34
Describes irregular depth extruded hole issue found during sheet metal design analysis.
Definition: DFMSheetMetal_IrregularDepthExtrudedHoleIssue.hxx:33
Describes irregular open hem bend radius issue found during sheet metal design analysis.
Definition: DFMSheetMetal_IrregularRadiusOpenHemBendIssue.hxx:33
Describes irregular size bend relief issues found during sheet metal design analysis.
Definition: DFMSheetMetal_IrregularSizeBendReliefIssue.hxx:33
SheetMetal_BendRelief ExpectedMinBendRelief() const
Definition: DFMSheetMetal_IrregularSizeBendReliefIssue.cxx:124
Describes irregular size notch issues found during sheet metal design analysis.
Definition: DFMSheetMetal_IrregularSizeNotchIssue.hxx:34
Describes irregular size tab issues found during sheet metal design analysis.
Definition: DFMSheetMetal_IrregularSizeTabIssue.hxx:34
Describes large depth bead issue found during sheet metal design analysis.
Definition: DFMSheetMetal_LargeDepthBeadIssue.hxx:33
Describes non standard sheet size issue found during sheet metal design analysis.
Definition: DFMSheetMetal_NonStandardSheetSizeIssue.hxx:33
const DFMSheetMetal_SheetSize & NearestStandardSheetSize() const
Definition: DFMSheetMetal_NonStandardSheetSizeIssue.cxx:69
Describes non standard sheet thickness issue found during sheet metal design analysis.
Definition: DFMSheetMetal_NonStandardSheetThicknessIssue.hxx:31
Describes small depth louver issue found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDepthLouverIssue.hxx:33
Describes small diameter hole issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDiameterHoleIssue.hxx:31
Describes small distance between bend and louver issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue.hxx:34
Describes small distance between complex hole and bend issues found during sheet metal design analysi...
Definition: DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue.hxx:34
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:33
Describes a base class for small distance issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenFeaturesIssue.hxx:37
Describes small distance between hole and bend issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue.hxx:34
Describes small distance between hole and cutout issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue.hxx:34
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:34
Describes small distance detween hole and notch issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue.hxx:34
Describes small distance detween holes issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenHolesIssue.hxx:33
Describes small distance detween notch and bend issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue.hxx:34
Describes small distance between notches issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenNotchesIssue.hxx:33
Describes small distance between tabs issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallDistanceBetweenTabsIssue.hxx:33
Describes small length flange issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallLengthFlangeIssue.hxx:34
Describes small length hem bend flange issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallLengthHemBendFlangeIssue.hxx:33
Describes small radius bend issues found during sheet metal design analysis.
Definition: DFMSheetMetal_SmallRadiusBendIssue.hxx:31
Defines a list of features.
Definition: MTKBase_FeatureList.hxx:37
size_t Size() const
Returns the number of elements in the list.
Definition: MTKBase_FeatureList.cxx:87
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:43
const Base_UTF16String & Name() const
Returns a model name.
Definition: ModelData_Model.cxx:358
void Accept(ElementVisitor &theVisitor) const
Accepts a visitor.
Definition: ModelData_Model.cxx:882
Reads any format that CAD Exchanger can import.
Definition: ModelData_ModelReader.hxx:33
bool Read(const Base_UTF16String &theFilePath, ModelData_Model &theModel)
Reads the file at the specified path into the specified model.
Definition: ModelData_ModelReader.cxx:182
Defines a visitor that visits each unique element only once.
Definition: ModelData_SceneGraphElementUniqueVisitor.hxx:33
Base class of topological shapes.
Definition: ModelData_Shape.hxx:37