using System;
using System.Collections.Generic;
namespace feature_group
{
class FeatureComparer : IComparer<MTKBase_Feature>
{
{
bool anALessThanB = aComparator.Apply(theA, theB);
if (anALessThanB)
{
return -1;
}
bool aBLessThanA = aComparator.Apply(theB, theA);
if (aBLessThanA)
{
return 1;
}
return 0;
}
}
public struct Pair
{
public Pair(double theFirst, double theSecond)
{
First = theFirst;
Second = theSecond;
}
public double First { get; }
public double Second { get; }
public override string ToString() => $"{First} x {Second}";
}
public struct Dimension
{
public Dimension(double theL, double theW, double theD)
{
L = theL;
W = theW;
D = theD;
}
public double L { get; }
public double W { get; }
public double D { get; }
public override string ToString() => $"{L} x {W} x {D}";
}
public struct Direction
{
public Direction(double theX, double theY, double theZ)
{
X = theX;
Y = theY;
Z = theZ;
}
public double X { get; }
public double Y { get; }
public double Z { get; }
public override string ToString() => $"({FormattedString(X)}, {FormattedString(Y)}, {FormattedString(Z)})";
private string FormattedString(double theValue)
{
System.Globalization.CultureInfo aCI = new System.Globalization.CultureInfo("en-US");
return string.Format(aCI, "{0:0.00}", theValue);
}
}
class FeatureGroupManager
{
public FeatureGroupManager()
{
myGroups = new List<FeatureGroup>();
}
private class FeatureGroup
{
public FeatureGroup(string theName, string theSubgroupName, bool theHasParameters)
{
myName = theName;
mySubgroupName = theSubgroupName;
myHasParameters = theHasParameters;
myFeatureSubgroups = new FeatureMapType(new FeatureComparer());
}
public uint FeatureCount()
{
uint aCount = 0;
foreach (var i in myFeatureSubgroups)
{
aCount += i.Value;
}
return aCount;
}
public string myName;
public string mySubgroupName;
public bool myHasParameters;
public FeatureMapType myFeatureSubgroups;
}
private class FeatureGroupComparer : IComparer<FeatureGroup>
{
public int Compare(FeatureGroup theA, FeatureGroup theB)
{
string anAName = theA.myName;
string aBName = theB.myName;
if (anAName == aBName)
{
return 0;
}
FeatureMapType anAFeatureSubgroups = theA.myFeatureSubgroups;
FeatureMapType aBFeatureSubgroups = theB.myFeatureSubgroups;
if (anAFeatureSubgroups.Count == 0 || aBFeatureSubgroups.Count == 0)
{
return anAName.CompareTo(aBName);
}
foreach (var i in anAFeatureSubgroups)
{
anAFeature = i.Key;
break;
}
foreach (var i in aBFeatureSubgroups)
{
aBFeature = i.Key;
break;
}
FeatureComparer aFeatureComparator = new FeatureComparer();
return aFeatureComparator.Compare(anAFeature, aBFeature);
}
}
private List<FeatureGroup> myGroups;
public void AddFeature(
string theGroupName,
string theSubgroupName,
bool theHasParameters,
MTKBase_Feature theFeature)
{
int aRes = myGroups.FindIndex(theGroup => theGroup.myName == theGroupName);
if (aRes == -1)
{
myGroups.Add(new FeatureGroup(theGroupName, theSubgroupName, theHasParameters));
aRes = myGroups.Count - 1;
}
FeatureGroup aGroup = myGroups[aRes];
FeatureMapType aSubgroups = aGroup.myFeatureSubgroups;
if (aSubgroups.ContainsKey(theFeature))
{
++aSubgroups[theFeature];
}
else
{
aSubgroups[theFeature] = 1;
}
}
public void Print(string theFeatureType, Action<MTKBase_Feature> thePrintFeatureParameters)
{
myGroups.Sort(new FeatureGroupComparer());
uint aTotalCount = 0;
foreach (var i in myGroups)
{
uint aFeatureCount = i.FeatureCount();
aTotalCount += aFeatureCount;
Console.WriteLine($" {i.myName}: {aFeatureCount}");
if (!i.myHasParameters)
{
continue;
}
string aSubgroupName = i.mySubgroupName;
foreach (var j in i.myFeatureSubgroups)
{
Console.WriteLine($" {j.Value} {aSubgroupName} with");
thePrintFeatureParameters(j.Key);
}
}
Console.WriteLine($"\n Total {theFeatureType}: {aTotalCount}\n");
}
public static void PrintFeatureParameter<T>(string theName, T theValue, string theUnits)
{
Console.WriteLine($" {theName}: {theValue} {theUnits}");
}
}
}
Provides possibility to compare MTK based features depending on their type and parameters.
Definition MTKBase_FeatureComparator.hxx:29
Describes a base class of MTK based features.
Definition MTKBase_Feature.hxx:33
Defines classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30
using feature_group;
using shape_processor;
using System;
using System.Collections.Generic;
namespace dfm_analyzer
{
class Program
{
static int Main(string[] args)
{
string aKey = MTKLicenseKey.Value();
if (!LicenseManager.Activate(aKey))
{
Console.WriteLine("Failed to activate Manufacturing Toolkit license.");
return 1;
}
if (args.Length != 1)
{
Console.WriteLine("Usage: " +
$"{System.Reflection.Assembly.GetExecutingAssembly().Location} <input_file>, where:");
Console.WriteLine($" <input_file> is a name of the file to be read");
Console.WriteLine($"");
return 1;
}
string aSource = args[0];
var aModel =
new Model();
{
Console.WriteLine($"Failed to read the file {aSource}");
return 1;
}
Console.WriteLine($"Model: {aModel.Name()}\n");
var aPartProcessor = new PartProcessor();
aModel.Accept (aVisitor);
return 0;
}
class PartProcessor : SolidProcessor
{
public PartProcessor()
{}
public override void ProcessSolid(
Solid theSolid)
{
var aRecognizerParameters = new Molding_FeatureRecognizerParameters();
aRecognizerParameters.SetMaxRibThickness(30.0);
aRecognizerParameters.SetMaxRibDraftAngle(0.2);
aRecognizerParameters.SetMaxRibTaperAngle(0.1);
anAnalyzer.AddTool (aRecognizer);
var aData = anAnalyzer.Perform (theSolid);
var anIssueList = aDFMAnalyzer.Perform(aData);
PrintIssues(anIssueList);
}
}
{
FeatureGroupManager aManager = new FeatureGroupManager();
for (uint i = 0; i < theIssueList.
Size(); ++i)
{
{
aManager.AddFeature("Irregular Core Depth Screw Boss Issue(s)", "Screw Boss(es)", true, anIssue);
}
{
aManager.AddFeature("Irregular Core Diameter Screw Boss Issue(s)", "Screw Boss(es)", true, anIssue);
}
{
aManager.AddFeature("Irregular Wall Thickness Screw Boss Issue(s)", "Screw Boss(es)", true, anIssue);
}
{
aManager.AddFeature("High Screw Boss Issue(s)", "Screw Boss(es)", true, anIssue);
}
{
aManager.AddFeature("Small Base Radius Screw Boss Issue(s)", "Screw Boss(es)", true, anIssue);
}
{
aManager.AddFeature("Small Draft Angle Screw Boss Issue(s)", "Screw Boss(es)", true, anIssue);
}
{
aManager.AddFeature("High Rib Issue(s)", "Rib(s)", true, anIssue);
}
{
aManager.AddFeature("Irregular Thickness Rib Issue(s)", "Rib(s)", true, anIssue);
}
{
aManager.AddFeature("Small Base Radius Rib Issue(s)", "Rib(s)", true, anIssue);
}
{
aManager.AddFeature("Small Draft Angle Rib Issue(s)", "Rib(s)", true, anIssue);
}
{
aManager.AddFeature("Small Distance Between Ribs Issue(s)", "Rib(s)", true, anIssue);
}
{
aManager.AddFeature("Small Hole Base Radius Screw Boss Issue(s)", "Screw Boss(es)", true, anIssue);
}
{
aManager.AddFeature("Non Chamfered Screw Boss Issue(s)", "Screw Boss(es)", false, anIssue);
}
{
aManager.AddFeature("Irregular Wall Thickness Issue(s)", "Wall(s)", true, anIssue);
}
{
aManager.AddFeature("Large Wall Thickness Issue(s)", "Wall(s)", true, anIssue);
}
{
aManager.AddFeature("Small Wall Thickness Issue(s)", "Wall(s)", true, anIssue);
}
{
aManager.AddFeature("Small Draft Angle Wall Thickness Issue(s)", "Wall(s)", true, anIssue);
}
{
aManager.AddFeature("Small Distance Between Bosses Issue(s)", "Boss(es)", true, anIssue);
}
}
Action<MTKBase_Feature> PrintFeatureParameters = theIssue =>
{
{
FeatureGroupManager.PrintFeatureParameter (
"actual height", aICDSBIssue.
ActualCoreDepth(),
"mm");
FeatureGroupManager.PrintFeatureParameter (
"actual core depth", aICDSBIssue.
ActualHeight(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter (
"expected min core diameter", aICDSBIssue.
ExpectedMinCoreDiameter(),
"mm");
FeatureGroupManager.PrintFeatureParameter (
"expected max core diameter", aICDSBIssue.
ExpectedMaxCoreDiameter(),
"mm");
FeatureGroupManager.PrintFeatureParameter (
"actual core diameter", aICDSBIssue.
ActualCoreDiameter(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter (
"expected max thickness", aIWTSBIssue.
ExpectedMaxThickness(),
"mm");
FeatureGroupManager.PrintFeatureParameter (
"expected min thickness", aIWTSBIssue.
ExpectedMinThickness(),
"mm");
FeatureGroupManager.PrintFeatureParameter (
"actual thickness", aIWTSBIssue.
ActualThickness(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter (
"expected max height", aHSBIssue.
ExpectedMaxHeight(),
"mm");
FeatureGroupManager.PrintFeatureParameter (
"actual height", aHSBIssue.
ActualHeight(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter (
"expected min base radius", aSBRSBIssue.
ExpectedMinBaseRadius(),
"mm");
FeatureGroupManager.PrintFeatureParameter (
"actual base radius", aSBRSBIssue.
ActualBaseRadius(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter (
"expected min draft angle", ToDegrees(aSDASBIssue.
ExpectedMinDraftAngle()),
"deg");
FeatureGroupManager.PrintFeatureParameter (
"actual draft angle", ToDegrees(aSDASBIssue.
ActualDraftAngle()),
"deg");
}
{
FeatureGroupManager.PrintFeatureParameter (
"expected max height", aHRIssue.
ExpectedMaxHeight(),
"mm");
FeatureGroupManager.PrintFeatureParameter (
"actual height", aHRIssue.
ActualHeight(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter (
"expected min thickness", aITRIssue.
ExpectedMinThickness(),
"mm");
FeatureGroupManager.PrintFeatureParameter (
"expected max thickness", aITRIssue.
ExpectedMaxThickness(),
"mm");
FeatureGroupManager.PrintFeatureParameter (
"actual thickness", aITRIssue.
ActualThickness(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter (
"expected min base radius", aSBRRIssue.
ExpectedMinBaseRadius(),
"mm");
FeatureGroupManager.PrintFeatureParameter (
"actual base radius", aSBRRIssue.
ActualBaseRadius(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter (
"expected min draft angle", ToDegrees(aSDARIssue.
ExpectedMinDraftAngle()),
"deg");
FeatureGroupManager.PrintFeatureParameter (
"actual draft angle", ToDegrees(aSDARIssue.
ActualDraftAngle()),
"deg");
}
{
}
{
FeatureGroupManager.PrintFeatureParameter (
"actual hole base radius", aSHBRSBIssue.
ActualHoleBaseRadius(),
"mm");
}
{
}
{
FeatureGroupManager.PrintFeatureParameter (
"expected max thickness", aIWTIIssue.
ExpectedMaxThickness(),
"mm");
FeatureGroupManager.PrintFeatureParameter (
"expected min thickness", aIWTIIssue.
ExpectedMinThickness(),
"mm");
FeatureGroupManager.PrintFeatureParameter (
"actual thickness", aIWTIIssue.
ActualThickness(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter (
"expected max thickness", aLWTIIssue.
ExpectedMaxThickness(),
"mm");
FeatureGroupManager.PrintFeatureParameter ("actual thickness", aLWTIIssue.ActualThickness(), "mm");
}
{
FeatureGroupManager.PrintFeatureParameter (
"expected min thickness", aSWTIIssue.
ExpectedMinThickness(),
"mm");
FeatureGroupManager.PrintFeatureParameter ("actual thickness", aSWTIIssue.ActualThickness(), "mm");
}
{
FeatureGroupManager.PrintFeatureParameter (
"expected min draft angle", ToDegrees(aSDAWIssue.
ExpectedMinDraftAngle()),
"deg");
FeatureGroupManager.PrintFeatureParameter (
"actual draft angle", ToDegrees(aSDAWIssue.
ActualDraftAngle()),
"deg");
}
{
}
};
aManager.Print ("issues", PrintFeatureParameters);
}
static double ToDegrees(double theAngleRad)
{
return theAngleRad * 180 / Math.PI;
}
}
}
Provides an interface to run DFM Molding analysis.
Definition DFMMolding_Analyzer.hxx:40
Defines parameters used in injection molding design analysis.
Definition DFMMolding_AnalyzerParameters.hxx:32
Describes large height rib issues found during injection molding design analysis.
Definition DFMMolding_HighRibIssue.hxx:28
double ExpectedMaxHeight() const
Definition DFMMolding_HighRibIssue.cxx:97
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding high rib issue.
Definition DFMMolding_HighRibIssue.cxx:112
double ActualHeight() const
Definition DFMMolding_HighRibIssue.cxx:106
Describes high screw boss issues found during injection molding design analysis.
Definition DFMMolding_HighScrewBossIssue.hxx:34
double ActualHeight() const
Definition DFMMolding_HighScrewBossIssue.cxx:107
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding boss outer diameter issue.
Definition DFMMolding_HighScrewBossIssue.cxx:113
double ExpectedMaxHeight() const
Definition DFMMolding_HighScrewBossIssue.cxx:98
Describes irregular core depth screw boss issues found during injection molding design analysis.
Definition DFMMolding_IrregularCoreDepthScrewBossIssue.hxx:34
double ActualCoreDepth() const
Definition DFMMolding_IrregularCoreDepthScrewBossIssue.cxx:88
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding boss core depth issue.
Definition DFMMolding_IrregularCoreDepthScrewBossIssue.cxx:94
double ActualHeight() const
Definition DFMMolding_IrregularCoreDepthScrewBossIssue.cxx:79
Describes irregular screw boss core diameter issues found during injection molding design analysis.
Definition DFMMolding_IrregularCoreDiameterScrewBossIssue.hxx:34
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding irregular core diameter screw boss issue.
Definition DFMMolding_IrregularCoreDiameterScrewBossIssue.cxx:144
double ExpectedMinCoreDiameter() const
Definition DFMMolding_IrregularCoreDiameterScrewBossIssue.cxx:120
double ExpectedMaxCoreDiameter() const
Definition DFMMolding_IrregularCoreDiameterScrewBossIssue.cxx:129
double ActualCoreDiameter() const
Definition DFMMolding_IrregularCoreDiameterScrewBossIssue.cxx:138
Describes irregular thickness rib issues found during injection molding design analysis.
Definition DFMMolding_IrregularThicknessRibIssue.hxx:28
double ExpectedMaxThickness() const
Definition DFMMolding_IrregularThicknessRibIssue.cxx:141
double ExpectedMinThickness() const
Definition DFMMolding_IrregularThicknessRibIssue.cxx:121
double ActualThickness() const
Definition DFMMolding_IrregularThicknessRibIssue.cxx:161
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding irregular thickness rib issue.
Definition DFMMolding_IrregularThicknessRibIssue.cxx:167
Describes wall with irregular thickness issues found during molding design analysis.
Definition DFMMolding_IrregularWallThicknessIssue.hxx:29
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding irregular wall thickness issue.
Definition DFMMolding_IrregularWallThicknessIssue.cxx:147
double ExpectedMaxThickness() const
Definition DFMMolding_IrregularWallThicknessIssue.cxx:110
double ExpectedMinThickness() const
Definition DFMMolding_IrregularWallThicknessIssue.cxx:130
Describes irregular wall thickness screw boss issues found during injection molding design analysis.
Definition DFMMolding_IrregularWallThicknessScrewBossIssue.hxx:34
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding irregular wall thickness issue.
Definition DFMMolding_IrregularWallThicknessScrewBossIssue.cxx:168
double ExpectedMaxThickness() const
Definition DFMMolding_IrregularWallThicknessScrewBossIssue.cxx:122
double ExpectedMinThickness() const
Definition DFMMolding_IrregularWallThicknessScrewBossIssue.cxx:142
double ActualThickness() const
Definition DFMMolding_IrregularWallThicknessScrewBossIssue.cxx:162
Describes wall with large thickness issues found during molding design analysis.
Definition DFMMolding_LargeWallThicknessIssue.hxx:28
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding large wall thickness issue.
Definition DFMMolding_LargeWallThicknessIssue.cxx:96
double ExpectedMaxThickness() const
Definition DFMMolding_LargeWallThicknessIssue.cxx:79
Describes screw boss without top chamfer issues found during injection molding design analysis.
Definition DFMMolding_NonChamferedScrewBossIssue.hxx:28
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding non chamfered screw boss issue.
Definition DFMMolding_NonChamferedScrewBossIssue.cxx:63
Describes small rib base radius issues found during injection molding design analysis.
Definition DFMMolding_SmallBaseRadiusRibIssue.hxx:28
double ExpectedMinBaseRadius() const
Definition DFMMolding_SmallBaseRadiusRibIssue.cxx:99
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding small base radius rib issue.
Definition DFMMolding_SmallBaseRadiusRibIssue.cxx:136
double ActualBaseRadius() const
Definition DFMMolding_SmallBaseRadiusRibIssue.cxx:119
Describes small screw boss base radius issues found during injection molding design analysis.
Definition DFMMolding_SmallBaseRadiusScrewBossIssue.hxx:28
double ActualBaseRadius() const
Definition DFMMolding_SmallBaseRadiusScrewBossIssue.cxx:119
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding small base radius screw boss issue.
Definition DFMMolding_SmallBaseRadiusScrewBossIssue.cxx:136
double ExpectedMinBaseRadius() const
Definition DFMMolding_SmallBaseRadiusScrewBossIssue.cxx:99
Describes a base class for small distance between bosses issues found during molding design analysis.
Definition DFMMolding_SmallDistanceBetweenBossesIssue.hxx:34
static bool CompareType(const MTKBase_Feature &theFeature)
Returnstrue if theFeature is a dfm molding small distance between bosses issue.
Definition DFMMolding_SmallDistanceBetweenBossesIssue.cxx:174
double ExpectedMinDistanceBetweenBosses() const
Definition DFMMolding_SmallDistanceBetweenBossesIssue.cxx:100
double ActualDistanceBetweenBosses() const
Definition DFMMolding_SmallDistanceBetweenBossesIssue.cxx:121
Describes a class for small distance between ribs issues found during molding design analysis.
Definition DFMMolding_SmallDistanceBetweenRibsIssue.hxx:30
double ActualDistanceBetweenRibs() const
Definition DFMMolding_SmallDistanceBetweenRibsIssue.cxx:120
double ExpectedMinDistanceBetweenRibs() const
Definition DFMMolding_SmallDistanceBetweenRibsIssue.cxx:100
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding small distance between ribs issue.
Definition DFMMolding_SmallDistanceBetweenRibsIssue.cxx:167
Describes small draft angle rib issues found during injection molding design analysis.
Definition DFMMolding_SmallDraftAngleRibIssue.hxx:28
double ExpectedMinDraftAngle() const
Definition DFMMolding_SmallDraftAngleRibIssue.cxx:77
double ActualDraftAngle() const
Definition DFMMolding_SmallDraftAngleRibIssue.cxx:97
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding small draft angle rib issue.
Definition DFMMolding_SmallDraftAngleRibIssue.cxx:103
Describes small screw boss draft angle issues found during injection molding design analysis.
Definition DFMMolding_SmallDraftAngleScrewBossIssue.hxx:28
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding small draft angle screw boss issue.
Definition DFMMolding_SmallDraftAngleScrewBossIssue.cxx:102
double ExpectedMinDraftAngle() const
Definition DFMMolding_SmallDraftAngleScrewBossIssue.cxx:76
double ActualDraftAngle() const
Definition DFMMolding_SmallDraftAngleScrewBossIssue.cxx:96
Describes small wall draft angle issues found during injection molding design analysis.
Definition DFMMolding_SmallDraftAngleWallIssue.hxx:30
double ExpectedMinDraftAngle() const
Definition DFMMolding_SmallDraftAngleWallIssue.cxx:75
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding small draft angle wall issue.
Definition DFMMolding_SmallDraftAngleWallIssue.cxx:131
double ActualDraftAngle() const
Definition DFMMolding_SmallDraftAngleWallIssue.cxx:93
Describes small screw boss hole base radius issues found during injection molding design analysis.
Definition DFMMolding_SmallHoleBaseRadiusScrewBossIssue.hxx:28
double ActualHoleBaseRadius() const
Definition DFMMolding_SmallHoleBaseRadiusScrewBossIssue.cxx:118
double ExpectedMinHoleBaseRadius() const
Definition DFMMolding_SmallHoleBaseRadiusScrewBossIssue.cxx:98
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding small hole base radius screw boss issue.
Definition DFMMolding_SmallHoleBaseRadiusScrewBossIssue.cxx:135
Describes wall with small thickness issues found during molding design analysis.
Definition DFMMolding_SmallWallThicknessIssue.hxx:28
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a dfm molding small wall thickness issue.
Definition DFMMolding_SmallWallThicknessIssue.cxx:96
double ExpectedMinThickness() const
Definition DFMMolding_SmallWallThicknessIssue.cxx:79
Defines a list of features.
Definition MTKBase_FeatureList.hxx:36
size_t Size() const
Returns the number of elements in the list.
Definition MTKBase_FeatureList.cxx:88
Defines a visitor that visits each unique element only once.
Definition ModelElementVisitor.hxx:87
Provides MTK data model.
Definition Model.hxx:40
Reads STEP and native format.
Definition ModelReader.hxx:29
Provides an interface to run several analyzer tools for different types of Molding processing.
Definition Molding_Analyzer.hxx:41
Provides an interface to recognizing molding features.
Definition Molding_FeatureRecognizer.hxx:37