#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#include <cadex/DFMMachining_DeepBoredHoleIssue.hxx>
#include <cadex/DFMMachining_DeepHoleIssue.hxx>
#include <cadex/DFMMachining_DeepPocketIssue.hxx>
#include <cadex/DFMMachining_FlatBottomHoleIssue.hxx>
#include <cadex/DFMMachining_HighBossIssue.hxx>
#include <cadex/DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue.hxx>
#include <cadex/DFMMachining_IntersectingCavityHoleIssue.hxx>
#include <cadex/DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue.hxx>
#include <cadex/DFMMachining_LargeMilledPartIssue.hxx>
#include <cadex/DFMMachining_LargeTurnedPartIssue.hxx>
#include <cadex/DFMMachining_LongSlenderTurnedPartIssue.hxx>
#include <cadex/DFMMachining_MilledPartExternalEdgeFilletIssue.hxx>
#include <cadex/DFMMachining_MilledPartSize.hxx>
#include <cadex/DFMMachining_NonPerpendicularHoleIssue.hxx>
#include <cadex/DFMMachining_NonPerpendicularMilledPartShapeIssue.hxx>
#include <cadex/DFMMachining_NonStandardDiameterHoleIssue.hxx>
#include <cadex/DFMMachining_NonStandardDrillPointAngleBlindHoleIssue.hxx>
#include <cadex/DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue.hxx>
#include <cadex/DFMMachining_NonSymmetricalAxialSlotIssue.hxx>
#include <cadex/DFMMachining_PartialHoleIssue.hxx>
#include <cadex/DFMMachining_SmallDepthBlindBoredHoleReliefIssue.hxx>
#include <cadex/DFMSheetMetal_SmallDepthLouverIssue.hxx>
#include <cadex/DFMMachining_SmallDiameterHoleIssue.hxx>
#include <cadex/DFMMachining_SmallRadiusMilledPartInternalCornerIssue.hxx>
#include <cadex/DFMMachining_SmallRadiusTurnedPartInternalCornerIssue.hxx>
#include <cadex/DFMMachining_SmallWallThicknessIssue.hxx>
#include <cadex/DFMMachining_SquareEndKeywayIssue.hxx>
#include <cadex/DFMMachining_TurnedPartSize.hxx>
#include <cadex/DFMMachining_LargeDifferenceRegionsSizeInPocketIssue.hxx>
#include <cadex/DFMMachining_NarrowRegionInPocketIssue.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_NonChamferedScrewBossIssue.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_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/DFMMolding_SmallWallThicknessIssue.hxx>
#include <cadex/Geom/Axis1d.hxx>
#include <cadex/Geom/Axis3d.hxx>
#include <cadex/Geom/Direction.hxx>
#include <cadex/Machining_Bore.hxx>
#include <cadex/Machining_Face.hxx>
#include <cadex/Machining_Hole.hxx>
#include <cadex/Machining_Countersink.hxx>
#include <cadex/Machining_Pocket.hxx>
#include <cadex/Machining_SteppedHole.hxx>
#include <cadex/Machining_ThreadedHole.hxx>
#include <cadex/Machining_TurningFace.hxx>
#include <cadex/Machining_TurningGroove.hxx>
#include <cadex/ModelData/Body.hxx>
#include <cadex/ModelData/Edge.hxx>
#include <cadex/ModelData/Face.hxx>
#include <cadex/ModelData/Part.hxx>
#include <cadex/ModelData/Shape.hxx>
#include <cadex/ModelData/Shell.hxx>
#include <cadex/Molding_Rib.hxx>
#include <cadex/Molding_ScrewBoss.hxx>
#include <cadex/MTKBase_Boss.hxx>
#include <cadex/SheetMetal_Bead.hxx>
#include <cadex/SheetMetal_Bend.hxx>
#include <cadex/SheetMetal_BendRelief.hxx>
#include <cadex/SheetMetal_Bridge.hxx>
#include <cadex/SheetMetal_ComplexHole.hxx>
#include <cadex/SheetMetal_CompoundBend.hxx>
#include <cadex/SheetMetal_CurvedBend.hxx>
#include <cadex/SheetMetal_Cutout.hxx>
#include <cadex/SheetMetal_HemBend.hxx>
#include <cadex/SheetMetal_HemBendType.hxx>
#include <cadex/SheetMetal_Hole.hxx>
#include <cadex/SheetMetal_Louver.hxx>
#include <cadex/SheetMetal_StraightNotch.hxx>
#include <cadex/SheetMetal_Tab.hxx>
#include <cadex/SheetMetal_VNotch.hxx>
#include <cadex/MTKBase_FeatureComparator.hxx>
#include <MTKConverter_Report.hxx>
#include <MTKConverter_MachiningProcessor.hxx>
#include <MTKConverter_MoldingProcessor.hxx>
#include <MTKConverter_SheetMetalProcessor.hxx>
#include <MTKConverter_WallThicknessProcessor.hxx>
#include <algorithm>
#include <array>
#include <cmath>
#include <fstream>
#include <functional>
#include <iomanip>
#include <map>
#include <sstream>
#include <vector>
namespace {
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 Geom::Direction& theDir)
{
return theStream << "(" << theDir.X() << ", " << theDir.Y() << ", " << theDir.Z() << ")";
}
inline std::ostream& operator<< (std::ostream& theStream, const Geom::Point& thePoint)
{
return theStream << "(" << thePoint.X() << ", " << thePoint.Y() << ", " << thePoint.Z() << ")";
}
inline std::ostream& operator<< (std::ostream& theStream, const ArrayType& theArray)
{
return theStream << theArray[0] << " x " << theArray[1] << " x " << theArray[2];
}
class JSONWriter
{
public:
JSONWriter (std::ostream& theStream, int theStartNestingLevel = 0) : myStream (theStream),
myNestingLevel (theStartNestingLevel),
myPrevNestingLevel (theStartNestingLevel - 1)
{}
void OpenSection()
{
DoOpenSection (nullptr, '{');
}
void OpenSection (const char* theName)
{
DoOpenSection (theName, '{');
}
void OpenArraySection (const char* theName)
{
DoOpenSection (theName, '[');
}
void CloseSection()
{
DoCloseSection ('}');
}
void CloseArraySection()
{
DoCloseSection (']');
}
template<typename T>
void WriteData (const char* theParamName, const T& theValue)
{
Stream() << "\"" << theParamName << "\": \"" << theValue << "\"";
}
void WriteRawData (const std::string& theRawData)
{
PrepareStream();
myStream << theRawData;
}
void WriteEmptyArray (const char* theParamName)
{
Stream() << "\"" << theParamName << "\": []";
}
int NestingLevel() const { return myNestingLevel; }
private:
void DoOpenSection (const char* theName, char theOpenBracketSymbol)
{
auto& aStream = Stream();
if (theName) {
aStream << "\"" << theName << "\": ";
}
aStream << theOpenBracketSymbol;
++myNestingLevel;
}
void DoCloseSection (char theCloseBracketSymbol)
{
--myNestingLevel;
Stream() << theCloseBracketSymbol;
}
void PrepareStream()
{
if (myNestingLevel == myPrevNestingLevel) {
myStream << ",";
}
myPrevNestingLevel = myNestingLevel;
if (myIsInit) {
myStream << std::endl;
}
myIsInit = true;
}
std::ostream& Stream()
{
PrepareStream();
for (int i = 0; i < myNestingLevel; ++i) {
myStream << " ";
}
return myStream;
}
std::ostream& myStream;
bool myIsInit = false;
int myNestingLevel;
int myPrevNestingLevel;
};
typedef std::vector<size_t> ShapeIDVectorType;
typedef std::vector<ShapeIDVectorType> ShapeIDVectorVectorType;
typedef std::shared_ptr<MTKConverter_ProcessData> DataType;
typedef std::map<MTKBase_Feature,
std::pair<size_t, ShapeIDVectorVectorType>,
MTKBase_FeatureComparator> FeatureMapType;
typedef std::vector<FeatureMapType::value_type> TypedFeatureVecType;
template <typename T>
void WriteParameter (JSONWriter& theWriter, const char* theParamName, const char* theParamUnits, const T& theParamValue)
{
theWriter.OpenSection();
theWriter.WriteData ("name", theParamName);
theWriter.WriteData ("units", theParamUnits);
theWriter.WriteData ("value", theParamValue);
theWriter.CloseSection();
}
void WriteShapeIDs (JSONWriter& theWriter, const ShapeIDVectorVectorType& theVector, bool theWriteFeatureSection)
{
if (theVector.empty()) {
return;
}
if (theWriteFeatureSection) {
theWriter.OpenArraySection ("features");
}
for (const auto& aShapeIDVector : theVector) {
theWriter.OpenSection();
theWriter.WriteData ("shapeIDCount", aShapeIDVector.size());
if (aShapeIDVector.empty()) {
theWriter.WriteEmptyArray ("shapeIDs");
} else {
theWriter.OpenArraySection ("shapeIDs");
for (auto aShapeID : aShapeIDVector) {
theWriter.OpenSection();
theWriter.WriteData ("id", aShapeID);
theWriter.CloseSection();
}
theWriter.CloseArraySection();
}
theWriter.CloseSection();
}
if (theWriteFeatureSection) {
theWriter.CloseArraySection();
}
}
template <typename F>
std::string DoWriteFeatureDataToString (const F& theFunc,
int theParamCount,
const ShapeIDVectorVectorType& theVector)
{
std::stringstream aStream;
aStream << std::fixed << std::setprecision (2);
JSONWriter aWriter (aStream, 7);
aWriter.OpenSection();
aWriter.WriteData ("parametersCount", theParamCount);
aWriter.OpenArraySection ("parameters");
theFunc (aWriter);
aWriter.CloseArraySection();
WriteShapeIDs (aWriter, theVector, true);
aWriter.CloseSection();
return aStream.str();
}
std::string WriteFeatureDataToString (const ShapeIDVectorVectorType& theVector)
{
std::stringstream aStream;
JSONWriter aWriter (aStream, 6);
WriteShapeIDs (aWriter, theVector, false);
return aStream.str();
}
template <typename T>
std::string WriteFeatureDataToString (const char* theParamName,
const char* theParamUnits,
const T& theParamValue,
const ShapeIDVectorVectorType& theVector)
{
auto WriteParams = [&] (JSONWriter& theWriter) {
WriteParameter (theWriter, theParamName, theParamUnits, theParamValue);
};
return DoWriteFeatureDataToString (WriteParams, 1, theVector);
}
template <typename T1, typename T2>
std::string WriteFeatureDataToString (const char* theParamName1,
const char* theParamUnits1,
const T1& theParamValue1,
const char* theParamName2,
const char* theParamUnits2,
const T2& theParamValue2,
const ShapeIDVectorVectorType& theVector)
{
auto WriteParams = [&] (JSONWriter& theWriter) {
WriteParameter (theWriter, theParamName1, theParamUnits1, theParamValue1);
WriteParameter (theWriter, theParamName2, theParamUnits2, theParamValue2);
};
return DoWriteFeatureDataToString (WriteParams, 2, theVector);
}
template <typename T1, typename T2, typename T3>
std::string WriteFeatureDataToString (const char* theParamName1,
const char* theParamUnits1,
const T1& theParamValue1,
const char* theParamName2,
const char* theParamUnits2,
const T2& theParamValue2,
const char* theParamName3,
const char* theParamUnits3,
const T3& theParamValue3,
const ShapeIDVectorVectorType& theVector)
{
auto WriteParams = [&] (JSONWriter& theWriter) {
WriteParameter (theWriter, theParamName1, theParamUnits1, theParamValue1);
WriteParameter (theWriter, theParamName2, theParamUnits2, theParamValue2);
WriteParameter (theWriter, theParamName3, theParamUnits3, theParamValue3);
};
return DoWriteFeatureDataToString (WriteParams, 3, theVector);
}
template <typename T1, typename T2, typename T3, typename T4>
std::string WriteFeatureDataToString (const char* theParamName1,
const char* theParamUnits1,
const T1& theParamValue1,
const char* theParamName2,
const char* theParamUnits2,
const T2& theParamValue2,
const char* theParamName3,
const char* theParamUnits3,
const T3& theParamValue3,
const char* theParamName4,
const char* theParamUnits4,
const T4& theParamValue4,
const ShapeIDVectorVectorType& theVector)
{
auto WriteParams = [&] (JSONWriter& theWriter) {
WriteParameter (theWriter, theParamName1, theParamUnits1, theParamValue1);
WriteParameter (theWriter, theParamName2, theParamUnits2, theParamValue2);
WriteParameter (theWriter, theParamName3, theParamUnits3, theParamValue3);
WriteParameter (theWriter, theParamName4, theParamUnits4, theParamValue4);
};
return DoWriteFeatureDataToString (WriteParams, 4, theVector);
}
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
std::string WriteFeatureDataToString (const char* theParamName1,
const char* theParamUnits1,
const T1& theParamValue1,
const char* theParamName2,
const char* theParamUnits2,
const T2& theParamValue2,
const char* theParamName3,
const char* theParamUnits3,
const T3& theParamValue3,
const char* theParamName4,
const char* theParamUnits4,
const T4& theParamValue4,
const char* theParamName5,
const char* theParamUnits5,
const T5& theParamValue5,
const char* theParamName6,
const char* theParamUnits6,
const T6& theParamValue6,
const ShapeIDVectorVectorType& theVector)
{
auto WriteParams = [&] (JSONWriter& theWriter) {
WriteParameter (theWriter, theParamName1, theParamUnits1, theParamValue1);
WriteParameter (theWriter, theParamName2, theParamUnits2, theParamValue2);
WriteParameter (theWriter, theParamName3, theParamUnits3, theParamValue3);
WriteParameter (theWriter, theParamName4, theParamUnits4, theParamValue4);
WriteParameter (theWriter, theParamName5, theParamUnits5, theParamValue5);
WriteParameter (theWriter, theParamName6, theParamUnits6, theParamValue6);
};
return DoWriteFeatureDataToString (WriteParams, 6, theVector);
}
class FeatureGroupManager
{
public:
void AddGroupData (const char* theGroupName,
const char* theGroupColor,
const std::string& theFeatureData,
size_t theFeatureNb)
{
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, theGroupColor));
}
auto& aGroup = *aRes;
aGroup.myFeatureData.push_back (theFeatureData);
aGroup.myFeatureCount += theFeatureNb;
}
size_t TotalFeatureCount() const
{
size_t aTotalFeatureCount = 0;
for (const auto& aGroup : myGroups) {
aTotalFeatureCount += aGroup.myFeatureCount;
}
return aTotalFeatureCount;
}
void Write (JSONWriter& theWriter) const
{
for (const auto& aGroup : myGroups) {
theWriter.OpenSection();
theWriter.WriteData ("name", aGroup.myName);
theWriter.WriteData ("color", aGroup.myColor);
theWriter.WriteData ("totalGroupFeatureCount", aGroup.myFeatureCount);
const auto& aFeatureData = aGroup.myFeatureData;
if (!aFeatureData.empty()) {
bool aHasParams = aFeatureData.front().find ("parameters") != std::string::npos;
if (aHasParams) {
theWriter.WriteData ("subGroupCount", aFeatureData.size());
theWriter.OpenArraySection ("subGroups");
for (const auto& j : aFeatureData) {
theWriter.WriteRawData (j);
}
theWriter.CloseArraySection();
} else {
theWriter.OpenArraySection ("features");
for (const auto& j : aFeatureData) {
theWriter.WriteRawData (j);
}
theWriter.CloseArraySection();
}
}
theWriter.CloseSection();
}
}
private:
class FeatureGroup
{
public:
FeatureGroup (const char* theName, const char* theColor) : myName (theName), myColor (theColor)
{}
std::string myName;
std::string myColor;
std::vector<std::string> myFeatureData;
size_t myFeatureCount = 0;
};
std::vector<FeatureGroup> myGroups;
};
const char* MachiningFaceTypeToString (Machining_FaceType theType)
{
switch (theType) {
case Machining_FT_FlatFaceMilled: return "Flat Face Milled Face(s)";
case Machining_FT_FlatSideMilled: return "Flat Side Milled Face(s)";
case Machining_FT_CurvedMilled: return "Curved Milled Face(s)";
case Machining_FT_CircularMilled: return "Circular Milled Face(s)";
case Machining_FT_Deburr: return "Deburr Face(s)";
case Machining_FT_ConvexProfileEdgeMilling: return "Convex Profile Edge Milling Face(s)";
case Machining_FT_ConcaveFilletEdgeMilling: return "Concave Fillet Edge Milling Face(s)";
case Machining_FT_FlatMilled: return "Flat Milled Face(s)";
case Machining_FT_TurnDiameter: return "Turn Diameter Face(s)";
case Machining_FT_TurnForm: return "Turn Form Face(s)";
case Machining_FT_TurnFace: return "Turn Face Face(s)";
default:
break;
}
return "Face(s)";
}
const char* MachiningFaceColor (Machining_FaceType theType)
{
switch (theType) {
case Machining_FT_FlatFaceMilled: return "(115, 251, 253)";
case Machining_FT_FlatSideMilled: return "(0, 35, 245)";
case Machining_FT_CurvedMilled: return "(22, 65, 124)";
case Machining_FT_CircularMilled: return "(255, 254, 145)";
case Machining_FT_Deburr: return "(0, 0, 0)";
case Machining_FT_ConvexProfileEdgeMilling: return "(240, 155, 89)";
case Machining_FT_ConcaveFilletEdgeMilling: return "(129, 127, 38)";
case Machining_FT_FlatMilled: return "(115, 43, 245)";
case Machining_FT_TurnDiameter: return "(88, 19, 94)";
case Machining_FT_TurnForm: return "(161, 251, 142)";
case Machining_FT_TurnFace: return "(239, 136, 190)";
default:
break;
}
return "(0, 0, 0)";
}
const char* MachiningHoleTypeToString (Machining_HoleType theType)
{
switch (theType) {
case Machining_HT_Through: return "Through Hole(s)";
case Machining_HT_FlatBottom: return "Flat Bottom Hole(s)";
case Machining_HT_Blind: return "Blind Hole(s)";
case Machining_HT_Partial: return "Partial Hole(s)";
default:
break;
}
return "Hole(s)";
}
const char* MachiningHoleColor (Machining_HoleType theType)
{
switch (theType) {
case Machining_HT_Through: return "(240, 135, 132)";
case Machining_HT_FlatBottom: return "(235, 51, 36)";
case Machining_HT_Blind: return "(142, 64, 58)";
case Machining_HT_Partial: return "(58, 6, 3)";
default:
break;
}
return "(0, 0, 0)";
}
const char* MachiningThreadedHoleColor (Machining_HoleType theType)
{
switch (theType) {
case Machining_HT_Through: return "(35, 160, 207)";
case Machining_HT_FlatBottom: return "(35, 76, 111)";
case Machining_HT_Blind: return "(192, 89, 133)";
case Machining_HT_Partial: return "(108, 31, 78)";
default:
break;
}
return "(0, 0, 0)";
}
const char* MachiningPocketTypeToString (Machining_PocketType theType)
{
switch (theType) {
case Machining_PT_Closed: return "Closed Pocket(s)";
case Machining_PT_Open: return "Open Pocket(s)";
case Machining_PT_Through: return "Through Pocket(s)";
default:
break;
}
return "Pocket(s)";
}
const char* MachiningPocketColor (Machining_PocketType theType)
{
switch (theType) {
case Machining_PT_Closed: return "(81, 20, 0)";
case Machining_PT_Open: return "(189, 103, 37)";
case Machining_PT_Through: return "(255, 217, 188)";
default:
break;
}
return "(0, 0, 0)";
}
const char* MachiningTurningGrooveColor (Machining_TurningGrooveType theType)
{
switch (theType) {
case Machining_TGT_OuterDiameter: return "(175, 49, 37)";
case Machining_TGT_InnerDiameter: return "(234, 255, 53)";
case Machining_TGT_EndFace: return "(144, 66, 159)";
default:
break;
}
return "(0, 0, 0)";
}
const char* HemTypeToString (SheetMetal_HemBendType theType)
{
switch (theType) {
case SheetMetal_HBT_Flattened: return "Flattened Hem Bend(s)";
case SheetMetal_HBT_Open: return "Open Hem Bend(s)";
case SheetMetal_HBT_Teardrop: return "Teardrop Hem Bend(s)";
case SheetMetal_HBT_Rope: return "Rope Hem Bend(s)";
case SheetMetal_HBT_Rolled: return "Rolled Hem Bend(s)";
default:
break;
}
return "Hem Bend(s)";
}
const char* MachiningTurningGrooveTypeToString (Machining_TurningGrooveType theType)
{
switch (theType) {
case Machining_TGT_OuterDiameter: return "Outer Diameter Groove(s)";
case Machining_TGT_InnerDiameter: return "Inner Diameter Groove(s)";
case Machining_TGT_EndFace: return "End Face Groove(s)";
default:
break;
}
return "Turning Groove(s)";
}
const char* BendName (const SheetMetal_Bend& theBend)
{
if (theBend.IsOfType<SheetMetal_HemBend>()) {
const auto& aHemBend = static_cast <const SheetMetal_HemBend&> (theBend);
return HemTypeToString (aHemBend.Type());
} else if (theBend.IsOfType<SheetMetal_CurvedBend>()) {
return "Curved Bend(s)";
}
return "Bend(s)";
}
const char* BendColor (const SheetMetal_Bend& theBend)
{
if (theBend.IsOfType<SheetMetal_HemBend>()) {
const auto& aType = static_cast <const SheetMetal_HemBend&> (theBend).Type();
switch (aType) {
case SheetMetal_HBT_Flattened: return "(22, 65, 124)";
case SheetMetal_HBT_Open: return "(42, 85, 144)";
case SheetMetal_HBT_Teardrop: return "(62, 105, 164)";
case SheetMetal_HBT_Rope: return "(82, 125, 184)";
case SheetMetal_HBT_Rolled: return "(102, 145, 204)";
default:
break;
}
return "(0, 0, 0)";
} else if (theBend.IsOfType<SheetMetal_CurvedBend>()) {
return "(255, 254, 145)";
}
return "(0, 35, 245)";
}
const char* SheetMetalHoleName (const SheetMetal_Hole& theHole)
{
if (theHole.IsOfType<SheetMetal_ComplexHole>()) {
return "Complex Hole(s)";
}
return "Hole(s)";
}
const char* SheetMetalHoleColor (const SheetMetal_Hole& theHole)
{
if (theHole.IsOfType<SheetMetal_ComplexHole>()) {
return "(115, 43, 245)";
}
return "(129, 127, 38)";
}
const char* SmallDistanceIssueName (const DFMSheetMetal_SmallDistanceBetweenFeaturesIssue& theIssue)
{
if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue>()) {
return "Small Distance Between Bend And Louver Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue>()) {
return "Small Distance Between Extruded Hole And Bend Issue(s)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndEdgeIssue>()) {
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)";
}
const char* SmallDistanceIssueColor (const DFMSheetMetal_SmallDistanceBetweenFeaturesIssue& theIssue)
{
if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue>()) {
return "(195, 56, 19)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue>()) {
return "(212, 75, 90)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndEdgeIssue>()) {
return "(198, 75, 105)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue>()) {
return "(170, 65, 120)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue>()) {
return "(239, 136, 190)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue>()) {
return "(127, 130, 187)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue>()) {
return "(240, 135, 132)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue>()) {
return "(15, 5, 129)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue>()) {
return "(235, 51, 36)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenHolesIssue>()) {
return "(142, 64, 58)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue>()) {
return "(58, 6, 3)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenNotchesIssue>()) {
return "(0, 215, 3)";
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenTabsIssue>()) {
return "(157, 160, 207)";
}
return "(0, 0, 0)";
}
void AddShapeFeature (FeatureGroupManager& theManager,
const MTKBase_Feature& theFeature,
size_t theCount,
const ShapeIDVectorVectorType& theShapeIdVector)
{
const auto& aFeature = theFeature;
std::function<void (MTKBase_FeatureList)> GroupByParameters = [&] (const MTKBase_FeatureList& theFeatures) -> void {
for (size_t i = 0; i < theFeatures.Size(); ++i) {
const auto& aGroupFeature = theFeatures[i];
if (aGroupFeature.IsOfType<Machining_Countersink>()) {
const auto& aCountersink = static_cast<const Machining_Countersink&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Radius", "mm", aCountersink.Radius(),
"Depth", "mm", aCountersink.Depth(),
"Axis", "", aCountersink.Axis().Axis(),
theShapeIdVector);
theManager.AddGroupData ("Countersink(s)", "(55, 125, 34)", aFeatureData, theCount);
} else if (aGroupFeature.IsOfType<Machining_Hole>()) {
const auto& aHole = static_cast<const Machining_Hole&> (aFeature);
auto aType = aHole.Type();
auto aFeatureData = WriteFeatureDataToString (
"Radius", "mm", aHole.Radius(),
"Depth", "mm", aHole.Depth(),
"Axis", "", aHole.Axis().Axis(),
theShapeIdVector);
theManager.AddGroupData (MachiningHoleTypeToString (aType), MachiningHoleColor (aType), aFeatureData, theCount);
} else if (aFeature.IsOfType<SheetMetal_Bend>()) {
const auto& aBend = static_cast<const SheetMetal_Bend&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Radius", "mm", aBend.Radius(),
"Angle", "deg", aBend.Angle() * 180 / M_PI,
"Length", "mm", aBend.Length(),
"Width", "mm", aBend.Width(),
theShapeIdVector);
theManager.AddGroupData (BendName (aBend), BendColor (aBend), aFeatureData, theCount);
}
}
};
if (aFeature.IsOfType<Machining_TurningFace>()) {
const auto& aTurningFace = static_cast<const Machining_TurningFace&> (aFeature);
auto aType = aTurningFace.Type();
auto aFeatureData = WriteFeatureDataToString ("Radius", "mm", aTurningFace.Radius(), theShapeIdVector);
theManager.AddGroupData (MachiningFaceTypeToString (aType), MachiningFaceColor (aType), aFeatureData, theCount);
} else if (aFeature.IsOfType<Machining_Face>()) {
auto& aFace = static_cast<const Machining_Face&> (aFeature);
auto aType = aFace.Type();
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData (MachiningFaceTypeToString (aType), MachiningFaceColor (aType), aFeatureData, theCount);
} else if (aFeature.IsOfType<Machining_Countersink>()) {
const auto& aCountersink = static_cast<const Machining_Countersink&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Radius", "mm", aCountersink.Radius(),
"Depth", "mm", aCountersink.Depth(),
"Axis", "", aCountersink.Axis().Axis(),
theShapeIdVector);
theManager.AddGroupData ("Countersink(s)", "(55, 125, 34)", aFeatureData, theCount);
} else if (aFeature.IsOfType<Machining_ThreadedHole>()) {
const auto& aThreadedHole = static_cast<const Machining_ThreadedHole&> (aFeature);
auto aType = aThreadedHole.Type();
auto aFeatureData = WriteFeatureDataToString (
"Minor radius", "mm", aThreadedHole.MinorRadius(),
"Major radius", "mm", aThreadedHole.MajorRadius(),
"Thread length", "mm", aThreadedHole.ThreadLength(),
"Pitch", "mm", aThreadedHole.Pitch(),
"Depth", "mm", aThreadedHole.Depth(),
"Axis", "", aThreadedHole.Axis().Axis(),
theShapeIdVector);
std::string aGroupName = std::string ("Threaded ") + MachiningHoleTypeToString (aThreadedHole.Type());
theManager.AddGroupData (aGroupName.c_str(), MachiningThreadedHoleColor (aType), aFeatureData, theCount);
} else if (aFeature.IsOfType<Machining_Hole>()) {
const auto& aHole = static_cast<const Machining_Hole&> (aFeature);
auto aType = aHole.Type();
auto aFeatureData = WriteFeatureDataToString (
"Radius", "mm", aHole.Radius(),
"Depth", "mm", aHole.Depth(),
"Axis", "", aHole.Axis().Axis(),
theShapeIdVector);
theManager.AddGroupData (MachiningHoleTypeToString (aType), MachiningHoleColor (aType), aFeatureData, theCount);
} else if (aFeature.IsOfType<Machining_SteppedHole>()) {
const auto& aSteppedHole = static_cast<const Machining_SteppedHole&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Depth", "mm", aSteppedHole.Depth(),
theShapeIdVector);
theManager.AddGroupData ("Stepped Hole(s)", "(204, 0, 125)", aFeatureData, theCount);
} else if (aFeature.IsOfType<Machining_Pocket>()) {
const auto& aPocket = static_cast<const Machining_Pocket&> (aFeature);
auto aType = aPocket.Type();
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aPocket.Length(),
"Width", "mm", aPocket.Width(),
"Depth", "mm", aPocket.Depth(),
"Axis", "", aPocket.Axis().Direction(),
theShapeIdVector);
theManager.AddGroupData (MachiningPocketTypeToString (aType), MachiningPocketColor (aType), aFeatureData, theCount);
} else if (aFeature.IsOfType<Machining_TurningGroove>()) {
const auto& aTurnGroove = static_cast<const Machining_TurningGroove&> (aFeature);
auto aType = aTurnGroove.Type();
auto aFeatureData = WriteFeatureDataToString (
"Radius", "mm", aTurnGroove.Radius(),
"Depth", "mm", aTurnGroove.Depth(),
"Width", "mm", aTurnGroove.Width(),
theShapeIdVector);
theManager.AddGroupData (MachiningTurningGrooveTypeToString (aType),
MachiningTurningGrooveColor (aType), aFeatureData, theCount);
} else if (aFeature.IsOfType<Machining_Bore>()) {
const auto& aBore = static_cast<const Machining_Bore&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Radius", "mm", aBore.Radius(),
"Depth", "mm", aBore.Depth(),
theShapeIdVector);
theManager.AddGroupData ("Bore(s)", "(127, 130, 187)", aFeatureData, theCount);
}
else if (aFeature.IsOfType<Molding_ScrewBoss>()) {
const auto& aScrewBoss = static_cast<const Molding_ScrewBoss&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Outer Radius", "mm", aScrewBoss.OuterRadius(),
"Inner Radius", "mm", aScrewBoss.InnerRadius(),
"Draft Angle", "deg", aScrewBoss.DraftAngle() * 180 / M_PI,
theShapeIdVector);
theManager.AddGroupData ("Screw Boss(es)", "(12, 32, 63)", aFeatureData, theCount);
} else if (aFeature.IsOfType<MTKBase_Boss>()) {
const auto& aBoss = static_cast<const MTKBase_Boss&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aBoss.Length(),
"Width", "mm", aBoss.Width(),
"Height", "mm", aBoss.Height(),
theShapeIdVector);
theManager.AddGroupData ("Boss(es)", "(56, 72, 13)", aFeatureData, theCount);
} else if (aFeature.IsOfType<Molding_Rib>()) {
const auto& aRib = static_cast<const Molding_Rib&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aRib.Length(),
"Height", "mm", aRib.Height(),
"Thickness", "mm", aRib.Thickness(),
"Draft Angle", "deg", aRib.DraftAngle() * 180 / M_PI,
theShapeIdVector);
theManager.AddGroupData ("Rib(s)", "(34, 51, 127)", aFeatureData, theCount);
}
else if (aFeature.IsOfType<SheetMetal_Bead>()) {
const auto& aBead = static_cast<const SheetMetal_Bead&> (aFeature);
auto aFeatureData = WriteFeatureDataToString ("Depth", "mm", aBead.Depth(), theShapeIdVector);
theManager.AddGroupData ("Bead(s)", "(115, 251, 253)", aFeatureData, theCount);
} else if (aFeature.IsOfType<SheetMetal_Bend>()) {
const auto& aBend = static_cast<const SheetMetal_Bend&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Radius", "mm", aBend.Radius(),
"Angle", "deg", aBend.Angle() * 180 / M_PI,
"Length", "mm", aBend.Length(),
"Width", "mm", aBend.Width(),
theShapeIdVector);
theManager.AddGroupData (BendName (aBend), BendColor (aBend), aFeatureData, theCount);
} else if (aFeature.IsOfType<SheetMetal_CompoundBend>()) {
const auto& aCompoundBend = static_cast<const SheetMetal_CompoundBend&> (aFeature);
GroupByParameters (aCompoundBend.FeatureList());
} else if (aFeature.IsOfType<SheetMetal_Bridge>()) {
const auto& aBridge = static_cast<const SheetMetal_Bridge&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aBridge.Length(),
"Depth", "mm", aBridge.Depth(),
theShapeIdVector);
theManager.AddGroupData ("Bridge(s)", "(240, 155, 89)", aFeatureData, theCount);
} else if (aFeature.IsOfType<SheetMetal_Hole>()) {
const auto& aHole = static_cast<const SheetMetal_Hole&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Radius", "mm", aHole.Radius(),
"Depth", "mm", aHole.Depth(),
"Axis", "", aHole.Axis().Axis(),
theShapeIdVector);
theManager.AddGroupData (SheetMetalHoleName (aHole), SheetMetalHoleColor (aHole), aFeatureData, theCount);
} else if (aFeature.IsOfType<SheetMetal_Cutout>()) {
const auto& aCutout = static_cast<const SheetMetal_Cutout&> (aFeature);
auto aFeatureData = WriteFeatureDataToString ("Perimeter", "mm", aCutout.Perimeter(), theShapeIdVector);
theManager.AddGroupData ("Cutout(s)", "(88, 19, 94)", aFeatureData, theCount);
} else if (aFeature.IsOfType<SheetMetal_Louver>()) {
const auto& aLouver = static_cast<const SheetMetal_Louver&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Depth", "mm", aLouver.Depth(),
theShapeIdVector);
theManager.AddGroupData ("Louver(s)", "(161, 251, 142)", aFeatureData, theCount);
} else if (aFeature.IsOfType<SheetMetal_Notch>()) {
const auto& aNotch = static_cast<const SheetMetal_Notch&> (aFeature);
if (aNotch.IsOfType<SheetMetal_StraightNotch>()) {
const auto& aStraightNotch = static_cast<const SheetMetal_StraightNotch&> (aNotch);
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aNotch.Length(),
"Width", "mm", aNotch.Width(),
"Corner Fillet Radius", "mm", aStraightNotch.CornerFilletRadius(),
theShapeIdVector);
theManager.AddGroupData ("Straight Notch(es)", "(240, 135, 132)", aFeatureData, theCount);
} else if (aNotch.IsOfType<SheetMetal_VNotch>()) {
const auto& aVNotch = static_cast<const SheetMetal_VNotch&> (aNotch);
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aNotch.Length(),
"Width", "mm", aNotch.Width(),
"Angle", "deg", aVNotch.Angle() * 180 / M_PI,
theShapeIdVector);
theManager.AddGroupData ("V Notch(es)", "(235, 51, 36)", aFeatureData, theCount);
} else {
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aNotch.Length(),
"Width", "mm", aNotch.Width(),
theShapeIdVector);
theManager.AddGroupData ("Notch(es)", "(239, 136, 190)", aFeatureData, theCount);
}
} else if (aFeature.IsOfType<SheetMetal_Tab>()) {
const auto& aTab = static_cast<const SheetMetal_Tab&> (aFeature);
auto aFeatureData = WriteFeatureDataToString (
"Length", "mm", aTab.Length(),
"Width", "mm", aTab.Width(),
theShapeIdVector);
theManager.AddGroupData ("Tab(s)", "(127, 130, 187)", aFeatureData, theCount);
}
}
void AddDrillingIssue (FeatureGroupManager& theManager,
const DFMMachining_DrillingIssue& theIssue,
size_t theCount,
const ShapeIDVectorVectorType& theShapeIdVector)
{
if (theIssue.IsOfType<DFMMachining_SmallDiameterHoleIssue>()) {
const auto& aSmallHoleIssue = static_cast<const DFMMachining_SmallDiameterHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Diameter", "mm", aSmallHoleIssue.ExpectedMinDiameter(),
"Actual Diameter", "mm", aSmallHoleIssue.ActualDiameter(),
theShapeIdVector);
theManager.AddGroupData ("Small Diameter Hole(s)", "(115, 251, 253)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_DeepHoleIssue>()) {
const auto& aDeepHoleIssue = static_cast<const DFMMachining_DeepHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Depth", "mm", aDeepHoleIssue.ExpectedMaxDepth(),
"Actual Depth", "mm", aDeepHoleIssue.ActualDepth(),
theShapeIdVector);
theManager.AddGroupData ("Deep Hole(s)", "(0, 35, 245)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_NonStandardDiameterHoleIssue>()) {
const auto& aNSDiameterHoleIssue = static_cast<const DFMMachining_NonStandardDiameterHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Nearest Standard Diameter", "mm", aNSDiameterHoleIssue.NearestStandardDiameter(),
"Actual Diameter", "mm", aNSDiameterHoleIssue.ActualDiameter(),
theShapeIdVector);
theManager.AddGroupData ("Non Standard Diameter Hole(s)", "(22, 65, 124)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_NonStandardDrillPointAngleBlindHoleIssue>()) {
const auto& aNSDrillPointAngleBlindHoleIssue = static_cast<const DFMMachining_NonStandardDrillPointAngleBlindHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Nearest Standard Angle", "deg", aNSDrillPointAngleBlindHoleIssue.NearestStandardAngle() * 180 / M_PI,
"Actual Angle", "deg", aNSDrillPointAngleBlindHoleIssue.ActualAngle() * 180 / M_PI,
theShapeIdVector);
theManager.AddGroupData ("Non Standard Drill Point Angle Blind Hole(s)", "(88, 13, 78)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_PartialHoleIssue>()) {
const auto& aPartialHoleIssue = static_cast<const DFMMachining_PartialHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Material Percent", "%", aPartialHoleIssue.ExpectedMinMaterialPercent() * 100,
"Actual Material Percent", "%", aPartialHoleIssue.ActualMaterialPercent() * 100,
theShapeIdVector);
theManager.AddGroupData ("Partial Hole(s)", "(255, 254, 145)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_FlatBottomHoleIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Flat Bottom Hole(s)", "(240, 155, 89)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_NonPerpendicularHoleIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Non Perpendicular Hole(s)", "(129, 127, 38)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_IntersectingCavityHoleIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Intersecting Cavity Hole(s)", "(115, 43, 245)", aFeatureData, theCount);
}
}
void AddMillingIssue (FeatureGroupManager& theManager,
const DFMMachining_MillingIssue& theIssue,
size_t theCount,
const ShapeIDVectorVectorType& theShapeIdVector)
{
if (theIssue.IsOfType<DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue>()) {
const auto& aFloorRadiusIssue = static_cast<const DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Nearest Standard Radius", "mm", aFloorRadiusIssue.NearestStandardRadius(),
"Actual Radius", "mm", aFloorRadiusIssue.ActualRadius(),
theShapeIdVector);
theManager.AddGroupData ("Non Standard Radius Milled Part Floor Fillet Issue(s)", "(0, 215, 3)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_DeepPocketIssue>()) {
const auto& aDeepPocketIssue = static_cast<const DFMMachining_DeepPocketIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Depth", "mm", aDeepPocketIssue.ExpectedMaxDepth(),
"Actual Depth", "mm", aDeepPocketIssue.ActualDepth(),
theShapeIdVector);
theManager.AddGroupData ("Deep Pocket Issue(s)", "(190, 10, 100)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_HighBossIssue>()) {
const auto& aHighBossIssue = static_cast<const DFMMachining_HighBossIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Height", "mm", aHighBossIssue.ExpectedMaxHeight(),
"Actual Height", "mm", aHighBossIssue.ActualHeight(),
theShapeIdVector);
theManager.AddGroupData ("High Boss Issue(s)", "(180, 100, 50)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_LargeMilledPartIssue>()) {
const auto& aLMPIssue = static_cast<const DFMMachining_LargeMilledPartIssue&> (theIssue);
const auto& anExpectedSize = aLMPIssue.ExpectedMaxMilledPartSize();
const auto& anActualSize = aLMPIssue.ActualMilledPartSize();
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Size (LxWxH)", "mm",
ArrayType ({ anExpectedSize.Length(), anExpectedSize.Width(), anExpectedSize.Height() }),
"Actual Size (LxWxH)", "mm",
ArrayType ({ anActualSize.Length(), anActualSize.Width(), anActualSize.Height() }),
theShapeIdVector);
theManager.AddGroupData ("Large Milled Part(s)", "(17, 37, 205)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_SmallRadiusMilledPartInternalCornerIssue>()) {
const auto& aMSICRIssue = static_cast<const DFMMachining_SmallRadiusMilledPartInternalCornerIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Radius", "mm", aMSICRIssue.ExpectedMinRadius(),
"Actual Radius", "mm", aMSICRIssue.ActualRadius(),
theShapeIdVector);
theManager.AddGroupData (
"Small Radius Milled Part Internal Corner(s)", "(10, 10, 200)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_NonPerpendicularMilledPartShapeIssue>()) {
const auto& aNPMPSIssue = static_cast<const DFMMachining_NonPerpendicularMilledPartShapeIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Actual Angle", "deg", aNPMPSIssue.ActualAngle() * 180 / M_PI,
theShapeIdVector);
theManager.AddGroupData ("Non Perpendicular Milled Part Shape(s)", "(129, 227, 138)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_MilledPartExternalEdgeFilletIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Milled Part External Edge Fillet(s)", "(201, 227, 13)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue>()) {
const auto& anInconsistentRadiusIssue =
static_cast<const DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Radius", "mm", anInconsistentRadiusIssue.ExpectedRadius(),
"Actual Radius", "mm", anInconsistentRadiusIssue.ActualRadius(),
theShapeIdVector);
theManager.AddGroupData ("Inconsistent Radius Milled Part Floor Fillet Issue(s)", "(180, 15, 190)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_NarrowRegionInPocketIssue>()) {
const auto& aNarrowRegionIssue =
static_cast<const DFMMachining_NarrowRegionInPocketIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Region Size", "mm", aNarrowRegionIssue.ExpectedMinRegionSize(),
"Actual Region Size", "mm", aNarrowRegionIssue.ActualRegionSize(),
theShapeIdVector);
theManager.AddGroupData ("Narrow Region In Pocket Issue(s)", "(70, 150, 150)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_LargeDifferenceRegionsSizeInPocketIssue>()) {
const auto& aLargeRatioIssue =
static_cast<const DFMMachining_LargeDifferenceRegionsSizeInPocketIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Regions Maximum To Minimum Size Ratio", "", aLargeRatioIssue.ExpectedMaxRegionsMaxToMinSizeRatio(),
"Actual Regions Maximum To Minimum Size Ratio", "", aLargeRatioIssue.ActualMaxRegionsMaxToMinSizeRatio(),
theShapeIdVector);
theManager.AddGroupData ("Large Difference Regions Size In Pocket Issue(s)", "(100, 150, 150)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_SmallWallThicknessIssue>()) {
const auto& aSWTIssue = static_cast<const DFMMachining_SmallWallThicknessIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Thickness", "mm", aSWTIssue.ExpectedMinThickness(),
"Actual Thickness", "mm", aSWTIssue.ActualThickness(), theShapeIdVector);
theManager.AddGroupData ("Small Wall Thickness Issue(s)", "(64, 224, 208)", aFeatureData, theCount);
}
}
void AddTurningIssue (FeatureGroupManager& theManager,
const DFMBase_Issue& theIssue,
size_t theCount,
const ShapeIDVectorVectorType& theShapeIdVector)
{
if (theIssue.IsOfType<DFMMachining_LargeTurnedPartIssue>()) {
const auto& aLTSIssue = static_cast<const DFMMachining_LargeTurnedPartIssue&> (theIssue);
const auto& anExpectedSize = aLTSIssue.ExpectedMaxTurnedPartSize();
const auto& anActualSize = aLTSIssue.ActualTurnedPartSize();
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Size (LxR)", "mm", std::make_pair (anExpectedSize.Length(), anExpectedSize.Radius()),
"Actual Size (LxR)", "mm", std::make_pair (anActualSize.Length(), anActualSize.Radius()),
theShapeIdVector);
theManager.AddGroupData ("Large Turned Part(s)", "(195, 195, 195)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_LongSlenderTurnedPartIssue>()) {
const auto& aLSTIssue = static_cast<const DFMMachining_LongSlenderTurnedPartIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Length", "mm", aLSTIssue.ExpectedMaxLength(),
"Actual Length", "mm", aLSTIssue.ActualLength(),
"Actual Minimum Diameter", "mm", aLSTIssue.ActualMinDiameter(),
theShapeIdVector);
theManager.AddGroupData ("Long-Slender Turned Part(s)", "(195, 195, 195)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_SmallDepthBlindBoredHoleReliefIssue>()) {
const auto& aBBHRIssue = static_cast<const DFMMachining_SmallDepthBlindBoredHoleReliefIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Relief Depth", "mm", aBBHRIssue.ExpectedMinReliefDepth(),
"Actual Relief Depth", "mm", aBBHRIssue.ActualReliefDepth(),
"Actual Diameter", "mm", aBBHRIssue.ActualDiameter(),
theShapeIdVector);
theManager.AddGroupData ("Small Depth Blind Bored Hole Relief(s)", "(88, 19, 94)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_DeepBoredHoleIssue>()) {
const auto& aISBHIssue = static_cast<const DFMMachining_DeepBoredHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Depth", "mm", aISBHIssue.ExpectedMaxDepth(),
"Actual Depth", "mm", aISBHIssue.ActualDepth(),
"Actual Diameter", "mm", aISBHIssue.ActualDiameter(),
theShapeIdVector);
theManager.AddGroupData ("Deep Bored Hole(s)", "(161, 251, 142)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue>()) {
const auto& aODPRIssue = static_cast<const DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Face Incline Angle", "deg", aODPRIssue.ExpectedMaxFaceInclineAngle() * 180 / M_PI,
"Actual Face Incline Angle", "deg", aODPRIssue.ActualFaceInclineAngle() * 180 / M_PI,
theShapeIdVector);
theManager.AddGroupData ("Irregular Turned Part Outer Diameter Profile Relief(s)", "(239, 136, 190)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_SmallRadiusTurnedPartInternalCornerIssue>()) {
const auto& aTSICRIssue = static_cast<const DFMMachining_SmallRadiusTurnedPartInternalCornerIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Radius", "mm", aTSICRIssue.ExpectedMinRadius(),
"Actual Radius", "mm", aTSICRIssue.ActualRadius(),
theShapeIdVector);
theManager.AddGroupData ("Small Radius Turned Part Internal Corner(s)", "(127, 130, 187)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_SquareEndKeywayIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Square End Keyway(s)", "(157, 160, 207)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMachining_NonSymmetricalAxialSlotIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Non Symmetrical Axial Slot(s)", "(130, 170, 200)", aFeatureData, theCount);
}
}
void AddMoldingIssue (FeatureGroupManager& theManager,
const DFMBase_Issue& theIssue,
size_t theCount,
const ShapeIDVectorVectorType& theShapeIdVector)
{
if (theIssue.IsOfType<DFMMolding_HighRibIssue>()) {
const auto& aHRIssue = static_cast<const DFMMolding_HighRibIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Height", "mm", aHRIssue.ExpectedMaxHeight(),
"Actual Height", "mm", aHRIssue.ActualHeight(),
theShapeIdVector);
theManager.AddGroupData ("High Rib(s)", "(284, 36, 12)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_HighScrewBossIssue>()) {
const auto& aHSBIssue = static_cast<const DFMMolding_HighScrewBossIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Height", "mm", aHSBIssue.ExpectedMaxHeight(),
"Actual Height", "mm", aHSBIssue.ActualHeight(),
theShapeIdVector);
theManager.AddGroupData ("High Screw Boss(es)", "(16, 75, 95)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_IrregularCoreDepthScrewBossIssue>()) {
const auto& aICDSBIssue = static_cast<const DFMMolding_IrregularCoreDepthScrewBossIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Actual Height", "mm", aICDSBIssue.ActualHeight(),
"Actual Core Depth", "mm", aICDSBIssue.ActualCoreDepth(),
theShapeIdVector);
theManager.AddGroupData ("Irregular Core Depth Screw Boss(es)", "(56, 176, 95)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_IrregularCoreDiameterScrewBossIssue>()) {
const auto& aICDSBIssue = static_cast<const DFMMolding_IrregularCoreDiameterScrewBossIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Outer Diameter", "mm", aICDSBIssue.ExpectedMinCoreDiameter(),
"Expected Maximum Outer Diameter", "mm", aICDSBIssue.ExpectedMaxCoreDiameter(),
"actual core diameter", "mm", aICDSBIssue.ActualCoreDiameter(),
theShapeIdVector);
theManager.AddGroupData ("Irregular Core Diameter Screw Boss(es)", "(195, 195, 195)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_IrregularThicknessRibIssue>()) {
const auto& aITRIssue = static_cast<const DFMMolding_IrregularThicknessRibIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Thickness", "mm", aITRIssue.ExpectedMinThickness(),
"Expected Maximum Thickness", "mm", aITRIssue.ExpectedMaxThickness(),
"Actual Thickness", "mm", aITRIssue.ActualThickness(),
theShapeIdVector);
theManager.AddGroupData ("Irregular Thickness Rib(s)", "(68, 114, 250)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_IrregularWallThicknessIssue>()) {
const auto& aIWTIssue = static_cast<const DFMMolding_IrregularWallThicknessIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Wall Thickness", "mm", aIWTIssue.ExpectedMaxThickness(),
"Expected Minimum Wall Thickness", "mm", aIWTIssue.ExpectedMinThickness(),
"Actual Wall Thickness", "mm", aIWTIssue.ActualThickness(),
theShapeIdVector);
theManager.AddGroupData ("Irregular Wall(s)", "(23, 11, 19)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_IrregularWallThicknessScrewBossIssue>()) {
const auto& aIWTSBIssue = static_cast<const DFMMolding_IrregularWallThicknessScrewBossIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Thickness", "mm", aIWTSBIssue.ExpectedMaxThickness(),
"Expected Minimum Thickness", "mm", aIWTSBIssue.ExpectedMinThickness(),
"Actual Thickness", "mm", aIWTSBIssue.ActualThickness(),
theShapeIdVector);
theManager.AddGroupData ("Irregular Wall Thickness Screw Boss(es)", "(13, 12, 245)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_LargeWallThicknessIssue>()) {
const auto& aLWTIssue = static_cast<const DFMMolding_LargeWallThicknessIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Wall Thickness", "mm", aLWTIssue.ExpectedMaxThickness(),
"Actual Wall Thickness", "mm", aLWTIssue.ActualThickness(),
theShapeIdVector);
theManager.AddGroupData ("Large Wall(s)", "(101, 22, 129)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_SmallBaseRadiusRibIssue>()) {
const auto& aSBRRIssue = static_cast<const DFMMolding_SmallBaseRadiusRibIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Base Radius", "mm", aSBRRIssue.ExpectedMinBaseRadius() ,
"Actual Base Radius", "mm", aSBRRIssue.ActualBaseRadius(),
theShapeIdVector);
theManager.AddGroupData ("Small Base Radius Rib(s)", "(13, 12, 90)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_SmallBaseRadiusScrewBossIssue>()) {
const auto& aSBRSBIssue = static_cast<const DFMMolding_SmallBaseRadiusScrewBossIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Base Radius", "mm", aSBRSBIssue.ExpectedMinBaseRadius() ,
"Actual Base Radius", "mm", aSBRSBIssue.ActualBaseRadius(),
theShapeIdVector);
theManager.AddGroupData ("Small Base Radius Screw Boss(es)", "(56, 18, 23)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_SmallDraftAngleRibIssue>()) {
const auto& aSDARIssue = static_cast<const DFMMolding_SmallDraftAngleRibIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Draft Angle", "deg", aSDARIssue.ExpectedMinDraftAngle() * 180. / M_PI,
"Actual Draft Angle", "deg", aSDARIssue.ActualDraftAngle() * 180. / M_PI,
theShapeIdVector);
theManager.AddGroupData ("Small Draft Angle Rib(s)", "(189, 200, 13)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_SmallDraftAngleScrewBossIssue>()) {
const auto& aSDASBIssue = static_cast<const DFMMolding_SmallDraftAngleScrewBossIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Draft Angle", "deg", aSDASBIssue.ExpectedMinDraftAngle() * 180. / M_PI,
"Actual Draft Angle", "deg", aSDASBIssue.ActualDraftAngle() * 180. / M_PI,
theShapeIdVector);
theManager.AddGroupData ("Small Draft Angle Screw Boss(es)", "(27, 101, 27)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_SmallHoleBaseRadiusScrewBossIssue>()) {
const auto& aSHBRSBIssue = static_cast<const DFMMolding_SmallHoleBaseRadiusScrewBossIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Hole Base Radius", "mm", aSHBRSBIssue.ExpectedMinHoleBaseRadius(),
"Actual Hole Base Radius", "mm", aSHBRSBIssue.ActualHoleBaseRadius(),
theShapeIdVector);
theManager.AddGroupData ("Small Hole Base Radius Screw Boss(es)", "(98, 8, 2)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_SmallDraftAngleWallIssue>()) {
const auto& aSDAWIssue = static_cast<const DFMMolding_SmallDraftAngleWallIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Draft Angle", "deg", aSDAWIssue.ExpectedMinDraftAngle() * 180. / M_PI,
"Actual Draft Angle", "deg", aSDAWIssue.ActualDraftAngle() * 180. / M_PI,
theShapeIdVector);
theManager.AddGroupData ("Small Draft Angle Wall(s)", "(101, 67, 33)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_NonChamferedScrewBossIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Non Chamfered Screw Boss(es)", "(38, 38, 10)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_SmallDistanceBetweenRibsIssue>()) {
const auto& aSDBRIssue = static_cast<const DFMMolding_SmallDistanceBetweenRibsIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Distance", "mm", aSDBRIssue.ExpectedMinDistanceBetweenRibs(),
"Actual Distance", "mm", aSDBRIssue.ActualDistanceBetweenRibs(),
theShapeIdVector);
theManager.AddGroupData ("Small Distance Between Ribs Issue(s)", "(11, 90, 111)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_SmallWallThicknessIssue>()) {
const auto& aSWTIssue = static_cast<const DFMMolding_SmallWallThicknessIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Wall Thickness", "mm", aSWTIssue.ExpectedMinThickness(),
"Actual Wall Thickness", "mm", aSWTIssue.ActualThickness(),
theShapeIdVector);
theManager.AddGroupData ("Small Wall(s)", "(14, 209, 199)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMMolding_SmallDistanceBetweenBossesIssue>()) {
const auto& aSDBBIssue = static_cast<const DFMMolding_SmallDistanceBetweenBossesIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Distance Between Bosses", "mm", aSDBBIssue.ExpectedMinDistanceBetweenBosses(),
"Actual Distance Between Bosses", "mm", aSDBBIssue.ActualDistanceBetweenBosses(),
theShapeIdVector);
theManager.AddGroupData ("Small Distance Between Bosses Issue(s)", "(255, 102, 0)", aFeatureData, theCount);
}
}
void AddSheetMetalIssue (FeatureGroupManager& theManager,
const DFMBase_Issue& theIssue,
size_t theCount,
const ShapeIDVectorVectorType& theShapeIdVector)
{
if (theIssue.IsOfType<DFMSheetMetal_FlatPatternInterferenceIssue>()) {
auto aFeatureData = WriteFeatureDataToString (theShapeIdVector);
theManager.AddGroupData ("Flat Pattern Interference(s)", "(115, 251, 253)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue>()) {
const auto& aICFRNIssue = static_cast<const DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Corner Fillet Radius", "mm", aICFRNIssue.ExpectedCornerFilletRadius(),
"Actual Corner Fillet Radius", "mm", aICFRNIssue.ActualCornerFilletRadius(),
theShapeIdVector);
theManager.AddGroupData ("Irregular Corner Fillet Radius Notch(es)", "(239, 136, 190)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularDepthExtrudedHoleIssue>()) {
const auto& aIDEHIssue = static_cast<const DFMSheetMetal_IrregularDepthExtrudedHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Extruded Height", "mm", aIDEHIssue.ExpectedMaxExtrudedHeight(),
"Expected Minimum Extruded Height", "mm", aIDEHIssue.ExpectedMinExtrudedHeight(),
"Actual Extruded Height", "mm", aIDEHIssue.ActualExtrudedHeight(),
theShapeIdVector);
theManager.AddGroupData ("Irregular depth extruded Hole(s)", "(50, 120, 210)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularRadiusOpenHemBendIssue>()) {
const auto& aIROHBIssue = static_cast<const DFMSheetMetal_IrregularRadiusOpenHemBendIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Radius", "mm", aIROHBIssue.ExpectedRadius(),
"Actual Radius", "mm", aIROHBIssue.ActualRadius(),
theShapeIdVector);
theManager.AddGroupData ("Irregular Radius Open Hem Bend(s)", "(188, 121, 11)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_InconsistentRadiusBendIssue>()) {
const auto& aIRBIssue = static_cast<const DFMSheetMetal_InconsistentRadiusBendIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Radius", "mm", aIRBIssue.ExpectedRadius(),
"Actual Radius", "mm", aIRBIssue.ActualRadius(),
theShapeIdVector);
theManager.AddGroupData ("Inconsistent Radius Bend(s)", "(0, 35, 245)", aFeatureData, theCount);
} 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();
std::string aFeatureData;
if (aFirstActualRelief && aSecondActualRelief) {
aFeatureData = WriteFeatureDataToString (
"Expected Minimum Relief Size (LxW)", "mm", std::make_pair (anExpectedRelief.Length(), anExpectedRelief.Width()),
"First Actual Relief Size (LxW)", "mm", std::make_pair (aFirstActualRelief.Length(), aFirstActualRelief.Width()),
"Second Actual Relief Size (LxW)", "mm", std::make_pair (aSecondActualRelief.Length(), aSecondActualRelief.Width()),
theShapeIdVector);
} else if (!aFirstActualRelief) {
aFeatureData = WriteFeatureDataToString (
"Expected Minimum Relief Size (LxW)", "mm", std::make_pair (anExpectedRelief.Length(), anExpectedRelief.Width()),
"Actual Relief Size (LxW)", "mm", std::make_pair (aSecondActualRelief.Length(), aSecondActualRelief.Width()),
theShapeIdVector);
} else {
aFeatureData = WriteFeatureDataToString (
"Expected Minimum Relief Size (LxW)", "mm", std::make_pair (anExpectedRelief.Length(), anExpectedRelief.Width()),
"Actual Relief Size (LxW)", "mm", std::make_pair (aFirstActualRelief.Length(), aFirstActualRelief.Width()),
theShapeIdVector);
}
theManager.AddGroupData ("Irregular Size Bend Relief(s)", "(22, 65, 124)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularSizeNotchIssue>()) {
const auto& aISNIssue = static_cast<const DFMSheetMetal_IrregularSizeNotchIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Size (LxW)", "mm", std::make_pair (aISNIssue.ExpectedLength(), aISNIssue.ExpectedWidth()),
"Actual Size (LxW)", "mm", std::make_pair (aISNIssue.ActualLength(), aISNIssue.ActualWidth()),
theShapeIdVector);
theManager.AddGroupData ("Irregular Size Notch(s)", "(255, 254, 145)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_IrregularSizeTabIssue>()) {
const auto& aISTIssue = static_cast<const DFMSheetMetal_IrregularSizeTabIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Size (LxW)", "mm", std::make_pair (aISTIssue.ExpectedLength(), aISTIssue.ExpectedWidth()),
"Actual Size (LxW)", "mm", std::make_pair (aISTIssue.ActualLength(), aISTIssue.ActualWidth()),
theShapeIdVector);
theManager.AddGroupData ("Irregular Size Tab(s)", "(240, 155, 89)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_LargeDepthBeadIssue>()) {
const auto& aLDBIssue = static_cast<const DFMSheetMetal_LargeDepthBeadIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Maximum Depth", "mm", aLDBIssue.ExpectedMaxDepth(),
"Actual Depth", "mm", aLDBIssue.ActualDepth(),
theShapeIdVector);
theManager.AddGroupData ("Large Depth Bead(s)", "(129, 127, 38)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDepthLouverIssue>()) {
const auto& aSDLIssue = static_cast<const DFMSheetMetal_SmallDepthLouverIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Depth", "mm", aSDLIssue.ExpectedMinDepth(),
"Actual Depth", "mm", aSDLIssue.ActualDepth(),
theShapeIdVector);
theManager.AddGroupData ("Small Depth Louver(s)", "(190, 127, 58)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_NonStandardSheetSizeIssue>()) {
const auto& aNSSSIssue = static_cast<const DFMSheetMetal_NonStandardSheetSizeIssue&> (theIssue);
const auto& aNesrestStandardSize = aNSSSIssue.NearestStandardSheetSize();
const auto& anActualSize = aNSSSIssue.ActualSheetSize();
auto aFeatureData = WriteFeatureDataToString (
"Nearest Standard Size (LxW)", "mm", std::make_pair (aNesrestStandardSize.Length(), aNesrestStandardSize.Width()),
"Actual Size (LxW)", "mm", std::make_pair (anActualSize.Length(), anActualSize.Width()),
theShapeIdVector);
theManager.AddGroupData ("Non Standard Sheet Size(s)", "(0, 0, 0)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_NonStandardSheetThicknessIssue>()) {
const auto& aNSSTIssue = static_cast<const DFMSheetMetal_NonStandardSheetThicknessIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Nearest Standard Thickness", "mm", aNSSTIssue.NearestStandardSheetThickness(),
"Actual Thickness", "mm", aNSSTIssue.ActualSheetThickness(),
theShapeIdVector);
theManager.AddGroupData ("Non Standard Sheet Thickness(s)", "(0, 0, 0)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDiameterHoleIssue>()) {
const auto& aSDHIssue = static_cast<const DFMSheetMetal_SmallDiameterHoleIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Diameter", "mm", aSDHIssue.ExpectedMinDiameter(),
"Actual Diameter", "mm", aSDHIssue.ActualDiameter(),
theShapeIdVector);
theManager.AddGroupData ("Small Diameter Hole(s)", "(115, 43, 245)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_SmallLengthFlangeIssue>()) {
const auto& aSLFIssue = static_cast<const DFMSheetMetal_SmallLengthFlangeIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Length", "mm", aSLFIssue.ExpectedMinLength(),
"Actual Length", "mm", aSLFIssue.ActualLength(),
theShapeIdVector);
theManager.AddGroupData ("Small Length Flange(s)", "(88, 19, 94)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_SmallLengthHemBendFlangeIssue>()) {
const auto& aSLFIssue = static_cast<const DFMSheetMetal_SmallLengthHemBendFlangeIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Length", "mm", aSLFIssue.ExpectedMinLength(),
"Actual Length", "mm", aSLFIssue.ActualLength(),
theShapeIdVector);
theManager.AddGroupData ("Small Length Hem Bend Flange(s)", "(70, 139, 51)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_SmallRadiusBendIssue>()) {
const auto& aSRBIssue = static_cast<const DFMSheetMetal_SmallRadiusBendIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Radius", "mm", aSRBIssue.ExpectedMinRadius(),
"Actual Radius", "mm", aSRBIssue.ActualRadius(),
theShapeIdVector);
theManager.AddGroupData ("Small Radius Bend(s)", "(161, 251, 142)", aFeatureData, theCount);
} else if (theIssue.IsOfType<DFMSheetMetal_SmallDistanceBetweenFeaturesIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenFeaturesIssue&> (theIssue);
auto aFeatureData = WriteFeatureDataToString (
"Expected Minimum Distance", "mm", aSDIssue.ExpectedMinDistanceBetweenFeatures(),
"Actual Distance", "mm", aSDIssue.ActualDistanceBetweenFeatures(),
theShapeIdVector);
theManager.AddGroupData (SmallDistanceIssueName (aSDIssue), SmallDistanceIssueColor (aSDIssue), aFeatureData, theCount);
}
}
ShapeIDVectorType GetShapesId (const ModelData::Shape& theShape,
ModelData::ShapeType theType)
{
ShapeIDVectorType aShapeIdVector;
ModelData::ShapeIterator aShapeIt (theShape, theType);
for (; aShapeIt.HasNext();) {
const auto& aShape = aShapeIt.Next();
aShapeIdVector.push_back (aShape.Id());
}
return aShapeIdVector;
}
void AddShapesId (const ModelData::Shape& theShape,
ModelData::ShapeType theType,
ShapeIDVectorType& theShapesIdVec)
{
ModelData::ShapeIterator aShapeIt (theShape, theType);
for (; aShapeIt.HasNext();) {
const auto& aShape = aShapeIt.Next();
theShapesIdVec.push_back (aShape.Id());
}
}
void SortFeatures (const MTKBase_FeatureList& theFeatures,
FeatureMapType& theMap)
{
for (size_t i = 0; i < theFeatures.Size(); i++) {
const auto& aFeature = theFeatures[i];
auto& anElement = theMap[aFeature];
++anElement.first;
if (aFeature.IsOfType<MTKBase_ShapeFeature>()) {
const auto& aShapeFeature = static_cast<const MTKBase_ShapeFeature&> (aFeature);
ModelData::ShapeType aShapeType = ModelData::ShapeType::Face;
if (aFeature.IsOfType<SheetMetal_Cutout>()
|| (aFeature.IsOfType<SheetMetal_Hole>() && !aFeature.IsOfType<SheetMetal_ComplexHole>())
|| aFeature.IsOfType<SheetMetal_Notch>() || aFeature.IsOfType<SheetMetal_Tab>()) {
aShapeType = ModelData::ShapeType::Edge;
}
auto aShapeIdVector = GetShapesId (aShapeFeature.Shape(), aShapeType);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<Machining_SteppedHole>()) {
ShapeIDVectorType aCompositeIdVector;
const auto& aHoles = static_cast<const Machining_SteppedHole&> (aFeature).FeatureList();
for (size_t j = 0; j < aHoles.Size(); ++j) {
const auto& aHole = static_cast<const Machining_Hole&> (aHoles[j]);
auto aShapeIdVector = GetShapesId (aHole.Shape(), ModelData::ShapeType::Face);
std::move (aShapeIdVector.begin(), aShapeIdVector.end(), std::back_inserter (aCompositeIdVector));
}
anElement.second.push_back (aCompositeIdVector);
} else if (aFeature.IsOfType<MTKBase_CompositeFeature>()) {
theMap.erase (aFeature);
const auto& aCompositeFeature = static_cast<const MTKBase_CompositeFeature&> (aFeature);
SortFeatures (aCompositeFeature.FeatureList(), theMap);
continue;
}
else if (aFeature.IsOfType<DFMMachining_DrillingIssue>()){
const auto& anIssue = static_cast<const DFMMachining_DrillingIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (anIssue.Hole().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
}
else if (aFeature.IsOfType<DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue>()) {
const auto& aNSRMPFFIssue = static_cast<const DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aNSRMPFFIssue.FloorFillet(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_DeepPocketIssue>()) {
const auto& aDCIssue = static_cast<const DFMMachining_DeepPocketIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aDCIssue.Pocket().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_HighBossIssue>()) {
const auto& aHBIssue = static_cast<const DFMMachining_HighBossIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aHBIssue.Boss().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_LargeMilledPartIssue>()) {
anElement.second.push_back (ShapeIDVectorType());
} else if (aFeature.IsOfType<DFMMachining_SmallRadiusMilledPartInternalCornerIssue>()) {
const auto& aMSICRIssue = static_cast<const DFMMachining_SmallRadiusMilledPartInternalCornerIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aMSICRIssue.Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_NonPerpendicularMilledPartShapeIssue>()) {
const auto& aNPMPSIssue = static_cast<const DFMMachining_NonPerpendicularMilledPartShapeIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aNPMPSIssue.Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_MilledPartExternalEdgeFilletIssue>()) {
const auto& aMPEEFIssue = static_cast<const DFMMachining_MilledPartExternalEdgeFilletIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aMPEEFIssue.Fillet(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue>()) {
const auto& aIRMPFFIssue = static_cast<const DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aIRMPFFIssue.FloorFillet(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_NarrowRegionInPocketIssue>()) {
const auto& aNRIPIssue = static_cast<const DFMMachining_NarrowRegionInPocketIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aNRIPIssue.InnerFeature(), ModelData::ShapeType::Face, aShapeIdVector);
AddShapesId (aNRIPIssue.NarrowRegionSidewall(), ModelData::ShapeType::Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_LargeDifferenceRegionsSizeInPocketIssue>()) {
const auto& aLDRSIPIssue = static_cast<const DFMMachining_LargeDifferenceRegionsSizeInPocketIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aLDRSIPIssue.InnerFeature(), ModelData::ShapeType::Face, aShapeIdVector);
AddShapesId (aLDRSIPIssue.MinRegionPocketSidewall(), ModelData::ShapeType::Face, aShapeIdVector);
AddShapesId (aLDRSIPIssue.MaxRegionPocketSidewall(), ModelData::ShapeType::Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_SmallWallThicknessIssue>()) {
const auto& aSWTIssue = static_cast<const DFMMachining_SmallWallThicknessIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSWTIssue.Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
}
else if (aFeature.IsOfType<DFMMachining_SmallDepthBlindBoredHoleReliefIssue>()) {
const auto& aBBHRIssue = static_cast<const DFMMachining_SmallDepthBlindBoredHoleReliefIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aBBHRIssue.BlindBoredHole(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_DeepBoredHoleIssue>()) {
const auto& aISBHIssue = static_cast<const DFMMachining_DeepBoredHoleIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aISBHIssue.Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue>()) {
const auto& aODPRIssue = static_cast<const DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aODPRIssue.Face(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_SmallRadiusTurnedPartInternalCornerIssue>()) {
const auto& aTSICRIssue = static_cast<const DFMMachining_SmallRadiusTurnedPartInternalCornerIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aTSICRIssue.Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_SquareEndKeywayIssue>()) {
const auto& aSEKIssue = static_cast<const DFMMachining_SquareEndKeywayIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSEKIssue.Keyway().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_NonSymmetricalAxialSlotIssue>()) {
const auto& aNSASIssue = static_cast<const DFMMachining_NonSymmetricalAxialSlotIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aNSASIssue.AxialSlot().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMachining_LargeTurnedPartIssue>()) {
anElement.second.push_back (ShapeIDVectorType());
} else if (aFeature.IsOfType<DFMMachining_LongSlenderTurnedPartIssue>()) {
anElement.second.push_back (ShapeIDVectorType());
}
else if (aFeature.IsOfType<DFMMolding_HighRibIssue>()) {
const auto& aHRIssue = static_cast<const DFMMolding_HighRibIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aHRIssue.Rib().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_HighScrewBossIssue>()) {
const auto& aHSBIssue = static_cast<const DFMMolding_HighScrewBossIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aHSBIssue.ScrewBoss().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_IrregularCoreDepthScrewBossIssue>()) {
const auto& aICDSBIssue = static_cast<const DFMMolding_IrregularCoreDepthScrewBossIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aICDSBIssue.ScrewBoss().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_IrregularCoreDiameterScrewBossIssue>()) {
const auto& aICDSBIssue = static_cast<const DFMMolding_IrregularCoreDiameterScrewBossIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aICDSBIssue.ScrewBoss().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_IrregularThicknessRibIssue>()) {
const auto& aITRIssue = static_cast<const DFMMolding_IrregularThicknessRibIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aITRIssue.Rib().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_IrregularWallThicknessScrewBossIssue>()) {
const auto& aIWTSBIssue = static_cast<const DFMMolding_IrregularWallThicknessScrewBossIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aIWTSBIssue.ScrewBoss().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back(aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_SmallDraftAngleWallIssue>()) {
const auto& aSDAWIssue = static_cast<const DFMMolding_SmallDraftAngleWallIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSDAWIssue.Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_SmallDistanceBetweenRibsIssue>()) {
const auto& aSDBRIssue = static_cast<const DFMMolding_SmallDistanceBetweenRibsIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDBRIssue.FirstRib().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
AddShapesId (aSDBRIssue.SecondRib().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_SmallBaseRadiusRibIssue>()) {
const auto& aSBRRIssue = static_cast<const DFMMolding_SmallBaseRadiusRibIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSBRRIssue.Rib().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_SmallBaseRadiusScrewBossIssue>()) {
const auto& aSBRSBIssue = static_cast<const DFMMolding_SmallBaseRadiusScrewBossIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSBRSBIssue.ScrewBoss().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_SmallDraftAngleRibIssue>()) {
const auto& aSMARIssue = static_cast<const DFMMolding_SmallDraftAngleRibIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSMARIssue.Rib().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_SmallDraftAngleScrewBossIssue>()) {
const auto& aSDASBIssue = static_cast<const DFMMolding_SmallDraftAngleScrewBossIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSDASBIssue.ScrewBoss().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_SmallHoleBaseRadiusScrewBossIssue>()) {
const auto& aSHBRSBIssue = static_cast<const DFMMolding_SmallHoleBaseRadiusScrewBossIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSHBRSBIssue.ScrewBoss().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_NonChamferedScrewBossIssue>()) {
const auto& aWTCSBIssue = static_cast<const DFMMolding_NonChamferedScrewBossIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aWTCSBIssue.ScrewBoss().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_IrregularWallThicknessIssue>()) {
const auto& aIWTIssue = static_cast<const DFMMolding_IrregularWallThicknessIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aIWTIssue.Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_LargeWallThicknessIssue>()) {
const auto& aLWTIssue = static_cast<const DFMMolding_LargeWallThicknessIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aLWTIssue.Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_SmallWallThicknessIssue>()) {
const auto& aSWTIssue = static_cast<const DFMMolding_SmallWallThicknessIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSWTIssue.Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMMolding_SmallDistanceBetweenBossesIssue>()) {
const auto& aSDBBIssue = static_cast<const DFMMolding_SmallDistanceBetweenBossesIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDBBIssue.FirstBoss().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
AddShapesId (aSDBBIssue.SecondBoss().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
}
else if (aFeature.IsOfType<DFMSheetMetal_FlatPatternInterferenceIssue>()) {
const auto& aFPIIssue = static_cast<const DFMSheetMetal_FlatPatternInterferenceIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector ({ aFPIIssue.FirstFace().Id(),
aFPIIssue.SecondFace().Id() });
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue>()) {
const auto& aICFRNIssue = static_cast<const DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aICFRNIssue.Notch().Shape(), ModelData::ShapeType::Edge);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_IrregularDepthExtrudedHoleIssue>()) {
const auto& aIDEHIssue = static_cast<const DFMSheetMetal_IrregularDepthExtrudedHoleIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aIDEHIssue.Hole().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_IrregularRadiusOpenHemBendIssue>()) {
const auto& aIROHBIssue = static_cast<const DFMSheetMetal_IrregularRadiusOpenHemBendIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aIROHBIssue.Bend().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_InconsistentRadiusBendIssue>()) {
const auto& aIRBIssue = static_cast<const DFMSheetMetal_InconsistentRadiusBendIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aIRBIssue.Bend().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_IrregularSizeBendReliefIssue>()) {
const auto& aISBRIssue = static_cast<const DFMSheetMetal_IrregularSizeBendReliefIssue&> (aFeature);
const auto& aFirstActualRelief = aISBRIssue.FirstActualRelief();
const auto& aSecondActualRelief = aISBRIssue.SecondActualRelief();
ShapeIDVectorType aShapeIdVector;
AddShapesId (aISBRIssue.Bend().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
if (aFirstActualRelief) {
AddShapesId (aFirstActualRelief.Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
}
if (aSecondActualRelief) {
AddShapesId (aSecondActualRelief.Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
}
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_IrregularSizeNotchIssue>()) {
const auto& aISNIssue = static_cast<const DFMSheetMetal_IrregularSizeNotchIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aISNIssue.Notch().Shape(), ModelData::ShapeType::Edge);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_IrregularSizeTabIssue>()) {
const auto& aISTIssue = static_cast<const DFMSheetMetal_IrregularSizeTabIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aISTIssue.Tab().Shape(), ModelData::ShapeType::Edge);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_LargeDepthBeadIssue>()) {
const auto& aLDBIssue = static_cast<const DFMSheetMetal_LargeDepthBeadIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aLDBIssue.Bead().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDepthLouverIssue>()) {
const auto& aSDLIssue = static_cast<const DFMSheetMetal_SmallDepthLouverIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSDLIssue.Louver().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_NonStandardSheetSizeIssue>()) {
anElement.second.push_back (ShapeIDVectorType());
} else if (aFeature.IsOfType<DFMSheetMetal_NonStandardSheetThicknessIssue>()) {
anElement.second.push_back (ShapeIDVectorType());
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDiameterHoleIssue>()) {
const auto& aSDHIssue = static_cast<const DFMSheetMetal_SmallDiameterHoleIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSDHIssue.Hole().Shape(), ModelData::ShapeType::Edge);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallLengthFlangeIssue>()) {
const auto& aSLFIssue = static_cast<const DFMSheetMetal_SmallLengthFlangeIssue&> (aFeature);
const auto& aFlange = aSLFIssue.Flange().FeatureList();
ShapeIDVectorType aShapeIdVector;
for (size_t j = 0; j < aFlange.Size(); j++) {
const auto& aFlangeFace = aFlange[j];
if (aFlangeFace.IsOfType<MTKBase_ShapeFeature>()) {
const auto& aShapeFeature = static_cast<const MTKBase_ShapeFeature&> (aFlangeFace);
AddShapesId (aShapeFeature.Shape(), ModelData::ShapeType::Face, aShapeIdVector);
}
}
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallLengthHemBendFlangeIssue>()) {
const auto& aSLFIssue = static_cast<const DFMSheetMetal_SmallLengthHemBendFlangeIssue&> (aFeature);
const auto& aFlange = aSLFIssue.Flange().FeatureList();
ShapeIDVectorType aShapeIdVector;
for (size_t j = 0; j < aFlange.Size(); j++) {
const auto& aFlangeFace = aFlange[j];
if (aFlangeFace.IsOfType<MTKBase_ShapeFeature>()) {
const auto& aShapeFeature = static_cast<const MTKBase_ShapeFeature&> (aFlangeFace);
AddShapesId (aShapeFeature.Shape(), ModelData::ShapeType::Face, aShapeIdVector);
}
}
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallRadiusBendIssue>()) {
const auto& aSRBIssue = static_cast<const DFMSheetMetal_SmallRadiusBendIssue&> (aFeature);
auto aShapeIdVector = GetShapesId (aSRBIssue.Bend().Shape(), ModelData::ShapeType::Face);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Bend().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
AddShapesId (aSDIssue.Louver().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Hole().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
AddShapesId (aSDIssue.Bend().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndEdgeIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndEdgeIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Hole().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
aShapeIdVector.push_back (aSDIssue.Edge().Id());
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.FirstHole().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
AddShapesId (aSDIssue.SecondHole().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Hole().Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
AddShapesId (aSDIssue.Bend().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Hole().Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
AddShapesId (aSDIssue.Cutout().Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Hole().Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
aShapeIdVector.push_back (aSDIssue.Edge().Id());
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Hole().Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
AddShapesId (aSDIssue.Louver().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Hole().Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
AddShapesId (aSDIssue.Notch().Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenHolesIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenHolesIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.FirstHole().Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
AddShapesId (aSDIssue.SecondHole().Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.Notch().Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
AddShapesId (aSDIssue.Bend().Shape(), ModelData::ShapeType::Face, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenNotchesIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenNotchesIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.FirstNotch().Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
AddShapesId (aSDIssue.SecondNotch().Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
} else if (aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenTabsIssue>()) {
const auto& aSDIssue = static_cast<const DFMSheetMetal_SmallDistanceBetweenTabsIssue&> (aFeature);
ShapeIDVectorType aShapeIdVector;
AddShapesId (aSDIssue.FirstTab().Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
AddShapesId (aSDIssue.SecondTab().Shape(), ModelData::ShapeType::Edge, aShapeIdVector);
anElement.second.push_back (aShapeIdVector);
}
}
}
bool WriteFeatures (JSONWriter& theWriter,
const char* theGroupName,
const char* theSubgroupName,
const MTKBase_FeatureList& theFeatures,
const char* theMessageForEmptyList)
{
theWriter.OpenSection (theSubgroupName);
theWriter.WriteData ("name", theGroupName);
if (theFeatures.IsEmpty()) {
theWriter.WriteData ("message", theMessageForEmptyList);
} else {
FeatureMapType aSortedFeatures;
SortFeatures (theFeatures, aSortedFeatures);
FeatureGroupManager aFGManager;
for (const auto& i : aSortedFeatures) {
const auto& aFeature = i.first;
size_t aCount = i.second.first;
const auto& aShapeIDVec = i.second.second;
if (aFeature.IsOfType<MTKBase_ShapeFeature>() || aFeature.IsOfType<Machining_SteppedHole>()) {
AddShapeFeature (aFGManager, static_cast<const MTKBase_ShapeFeature&> (aFeature), aCount, aShapeIDVec);
} else if (aFeature.IsOfType<DFMMachining_DrillingIssue>()) {
AddDrillingIssue (aFGManager, static_cast<const DFMMachining_DrillingIssue&> (aFeature), aCount, aShapeIDVec);
} else if (aFeature.IsOfType<DFMMachining_MillingIssue>()) {
AddMillingIssue (aFGManager, static_cast<const DFMMachining_MillingIssue&> (aFeature), aCount, aShapeIDVec);
} else if (aFeature.IsOfType<DFMSheetMetal_BendIssue>()
|| aFeature.IsOfType<DFMSheetMetal_FlatPatternInterferenceIssue>()
|| aFeature.IsOfType<DFMSheetMetal_HoleIssue>()
|| aFeature.IsOfType<DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue>()
|| aFeature.IsOfType<DFMSheetMetal_IrregularDepthExtrudedHoleIssue>()
|| aFeature.IsOfType<DFMSheetMetal_IrregularSizeNotchIssue>()
|| aFeature.IsOfType<DFMSheetMetal_IrregularSizeTabIssue>()
|| aFeature.IsOfType<DFMSheetMetal_LargeDepthBeadIssue>()
|| aFeature.IsOfType<DFMSheetMetal_SmallDepthLouverIssue>()
|| aFeature.IsOfType<DFMSheetMetal_NonStandardSheetSizeIssue>()
|| aFeature.IsOfType<DFMSheetMetal_NonStandardSheetThicknessIssue>()
|| aFeature.IsOfType<DFMSheetMetal_SmallDistanceBetweenFeaturesIssue>()) {
AddSheetMetalIssue (aFGManager, static_cast<const DFMBase_Issue&> (aFeature), aCount, aShapeIDVec);
} else if (aFeature.IsOfType<DFMMolding_HighRibIssue>()
|| aFeature.IsOfType<DFMMolding_HighScrewBossIssue>()
|| aFeature.IsOfType<DFMMolding_IrregularCoreDepthScrewBossIssue>()
|| aFeature.IsOfType<DFMMolding_IrregularCoreDiameterScrewBossIssue>()
|| aFeature.IsOfType<DFMMolding_IrregularThicknessRibIssue>()
|| aFeature.IsOfType<DFMMolding_IrregularWallThicknessScrewBossIssue>()
|| aFeature.IsOfType<DFMMolding_SmallBaseRadiusRibIssue>()
|| aFeature.IsOfType<DFMMolding_SmallBaseRadiusScrewBossIssue>()
|| aFeature.IsOfType<DFMMolding_SmallDraftAngleRibIssue>()
|| aFeature.IsOfType<DFMMolding_SmallDraftAngleScrewBossIssue>()
|| aFeature.IsOfType<DFMMolding_SmallHoleBaseRadiusScrewBossIssue>()
|| aFeature.IsOfType<DFMMolding_SmallDraftAngleWallIssue>()
|| aFeature.IsOfType<DFMMolding_NonChamferedScrewBossIssue>()
|| aFeature.IsOfType<DFMMolding_SmallDistanceBetweenRibsIssue>()
|| aFeature.IsOfType<DFMMolding_IrregularWallThicknessIssue>()
|| aFeature.IsOfType<DFMMolding_LargeWallThicknessIssue>()
|| aFeature.IsOfType<DFMMolding_SmallWallThicknessIssue>()
|| aFeature.IsOfType<DFMMolding_SmallDistanceBetweenBossesIssue>()) {
AddMoldingIssue (aFGManager, static_cast<const DFMBase_Issue&> (aFeature), aCount, aShapeIDVec);
} else if (aFeature.IsOfType<DFMBase_Issue>()) {
AddTurningIssue (aFGManager, static_cast<const DFMBase_Issue&> (aFeature), aCount, aShapeIDVec);
}
}
theWriter.WriteData ("totalFeatureCount", aFGManager.TotalFeatureCount());
theWriter.OpenArraySection ("featureGroups");
aFGManager.Write (theWriter);
theWriter.CloseArraySection();
}
theWriter.CloseSection();
return true;
}
const char* MachiningProcessName (Machining_OperationType theOperation)
{
switch (theOperation) {
case Machining_OT_Milling: return "CNC Machining Milling";
case Machining_OT_LatheMilling: return "CNC Machining Lathe+Milling";
default:
break;
}
return "CNC Machining";
}
bool HasShapes (const std::vector<ModelData::Body>& theBodies, ModelData::ShapeType theType)
{
for (const auto& aBody : theBodies) {
ModelData::ShapeIterator aShapeIt (aBody, theType);
if (aShapeIt.HasNext()) {
return true;
}
}
return false;
}
void WriteThicknessNode (JSONWriter& theWriter,
const char* theParamName,
double theParamValue,
const PointPairType& thePoints,
const char* theNodeName)
{
std::stringstream aStream;
aStream << std::fixed << std::setprecision (2);
JSONWriter aWriter (aStream, 3);
aWriter.OpenSection (theNodeName);
aWriter.WriteData ("name", theParamName);
aWriter.WriteData ("units", "mm");
aWriter.WriteData ("value", theParamValue);
aWriter.WriteData ("firstPoint", thePoints.first);
aWriter.WriteData ("secondPoint", thePoints.second);
aWriter.CloseSection();
theWriter.WriteRawData (aStream.str());
}
void WriteUnfoldedPartFeatures (JSONWriter& theWriter,
const MTKConverter_UnfoldedPartData& theData)
{
theWriter.OpenSection ("featureRecognitionUnfolded");
theWriter.WriteData ("name", "Feature Recognition");
if (theData.IsInit()) {
std::stringstream aStream;
aStream << std::fixed << std::setprecision (2);
JSONWriter aWriter (aStream, 4);
aWriter.WriteData ("parametersCount", 3);
aWriter.OpenArraySection ("parameters");
const auto& aFlatPattern = theData.myFlatPattern;
WriteParameter (aWriter, "Length", "mm", aFlatPattern.Length());
WriteParameter (aWriter, "Width", "mm", aFlatPattern.Width());
WriteParameter (aWriter, "Thickness", "mm", aFlatPattern.Thickness());
WriteParameter (aWriter, "Perimeter", "mm", aFlatPattern.Perimeter());
aWriter.CloseArraySection();
theWriter.WriteRawData (aStream.str());
} else {
theWriter.WriteData ("message", "Unfolded part wasn't generated.");
}
theWriter.CloseSection();
}
void WritePartProcessData (JSONWriter& theWriter, const DataType& theProcessData)
{
bool aRes = false;
theWriter.WriteData ("partId", theProcessData->myPart.Uuid());
std::string anErrorMsg = "An error occurred while processing the part.";
if (theProcessData) {
if (auto aMD = std::dynamic_pointer_cast<MTKConverter_MachiningData> (theProcessData)) {
theWriter.WriteData ("process", MachiningProcessName (aMD->myOperation));
const auto& aBodies = aMD->myPart.Bodies();
if (!aMD->myFeatureList.IsEmpty()) {
WriteFeatures (theWriter, "Feature Recognition", "featureRecognition", aMD->myFeatureList, "");
WriteFeatures (theWriter, "Design for Manufacturing", "dfm", aMD->myIssueList,
"Part contains no DFM improvement suggestions.");
aRes = true;
} else if (aBodies.empty() || !HasShapes (aBodies, ModelData::ShapeType::Solid)) {
anErrorMsg = "The part can't be analyzed due to lack of: "
"BRep representation or solids in BRep representation.";
}
} else if (auto aWTD = std::dynamic_pointer_cast<MTKConverter_WallThicknessData> (theProcessData)) {
theWriter.WriteData ("process", "Wall Thickness Analysis");
const auto& aBodies = aWTD->myPart.Bodies();
if (aWTD->myIsInit) {
WriteThicknessNode (theWriter, "Minimum Thickness", aWTD->myMinThickness, aWTD->myMinThicknessPoints, "minThickness");
WriteThicknessNode (theWriter, "Maximum Thickness", aWTD->myMaxThickness, aWTD->myMaxThicknessPoints, "maxThickness");
aRes = true;
} else if ((aBodies.empty() || !HasShapes (aBodies, ModelData::ShapeType::Solid))) {
anErrorMsg = "The part can't be analyzed due to lack of: "
"BRep representation, solids in BRep representation.";
}
} else if (auto aMoldingData = std::dynamic_pointer_cast<MTKConverter_MoldingData> (theProcessData)) {
const auto& aBodies = aMoldingData->myPart.Bodies();
if (!aMoldingData->myFeatureList.IsEmpty()) {
theWriter.WriteData ("process", "Molding Analysis");
WriteFeatures (theWriter, "Feature Recognition", "featureRecognition", aMoldingData->myFeatureList, "");
WriteFeatures (theWriter, "Design for Manufacturing", "dfm", aMoldingData->myIssueList,
"Part contains no DFM improvement suggestions.");
aRes = true;
} else if (aBodies.empty() || !HasShapes (aBodies, ModelData::ShapeType::Solid)) {
anErrorMsg = "The part can't be analyzed due to lack of: "
"BRep representation or solids in BRep representation.";
}
} else if (auto aSMD = std::dynamic_pointer_cast<MTKConverter_SheetMetalData> (theProcessData)) {
theWriter.WriteData ("process", "Sheet Metal");
const auto& aBodies = aSMD->myPart.Bodies();
if (aSMD->myIsSheetMetalPart) {
WriteFeatures (theWriter, "Feature Recognition", "featureRecognition", aSMD->myFeatureList,
"Part contains no features.");
WriteFeatures (theWriter, "Design for Manufacturing", "dfm", aSMD->myIssueList,
"Part contains no DFM improvement suggestions.");
const auto& anUnfoldedPartData = aSMD->myUnfoldedPartData;
WriteUnfoldedPartFeatures (theWriter, anUnfoldedPartData);
if (anUnfoldedPartData.IsInit()) {
WriteFeatures (theWriter, "Design for Manufacturing", "dfmUnfolded", anUnfoldedPartData.myIssueList,
"Unfolded part contains no DFM improvement suggestions.");
}
aRes = true;
} else if (aBodies.empty() || (!HasShapes (aBodies, ModelData::ShapeType::Solid) && !HasShapes (aBodies, ModelData::ShapeType::Shell))) {
anErrorMsg = "The part can't be analyzed due to lack of: "
"BRep representation, solids and shells in BRep representation.";
} else {
anErrorMsg = "The part wasn't recognized as a sheet metal part.";
}
} else {
anErrorMsg = "Unrecognized process";
}
}
if (!aRes) {
theWriter.WriteData ("error", anErrorMsg);
}
}
}
bool MTKConverter_Report::WriteToJSON (const UTF16String& thePath) const
{
std::ofstream aFile (thePath.ToString());
if (!aFile) {
return false;
}
JSONWriter aWriter (aFile);
aWriter.OpenSection();
aWriter.WriteData ("version", "1");
if (myData.empty()) {
aWriter.WriteData ("error", "The model doesn't contain any parts.");
} else {
aWriter.OpenArraySection ("parts");
for (const auto& aProcessData : myData) {
aWriter.OpenSection();
WritePartProcessData (aWriter, aProcessData);
aWriter.CloseSection();
}
aWriter.CloseArraySection();
}
aWriter.CloseSection();
return true;
}