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;
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");
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 : ShapeProcessor
{
public PartProcessor()
{
}
public override void ProcessSolid(
Solid theSolid)
{
var anIssueList = myAnalyzer.Perform(theSolid);
PrintIssues(anIssueList);
}
public override void ProcessShell(
Shell theShell)
{
var anIssueList = myAnalyzer.Perform(theShell);
PrintIssues(anIssueList);
}
}
{
FeatureGroupManager aManager = new FeatureGroupManager();
for (uint i = 0; i < theIssueList.
Size(); ++i)
{
{
aManager.AddFeature("Small Radius Bend Issue(s)", "Bend(s)", true, anIssue);
}
{
aManager.AddFeature("Small Diameter Hole Issue(s)", "Hole(s)", true, anIssue);
}
{
aManager.AddFeature("Flat Pattern Interference Issue(s)", "", false, anIssue);
}
{
aManager.AddFeature("Irregular Corner Fillet Radius Notch Issue(s)", "Notch(es)", true, anIssue);
}
{
aManager.AddFeature("Irregular Depth Extruded Hole Issue(s)", "Hole(s)", true, anIssue);
}
{
aManager.AddFeature("Irregular Radius Open Hem Bend Issue(s)", "Bend(s)", true, anIssue);
}
{
aManager.AddFeature("Irregular Size Bend Relief Issue(s)", "Bend(s)", true, anIssue);
}
{
aManager.AddFeature("Large Depth Bead Issue(s)", "Bead(s)", true, anIssue);
}
{
aManager.AddFeature("Small Depth Louver Issue(s)", "Louver(s)", true, anIssue);
}
{
aManager.AddFeature("Inconsistent Radius Bend Issue(s)", "Bend(s)", true, anIssue);
}
{
aManager.AddFeature("Small Length Flange Issue(s)", "Flange(s)", true, anIssue);
}
{
aManager.AddFeature("Small Length Hem Bend Flange Issue(s)", "Flange(s)", true, anIssue);
}
{
aManager.AddFeature("Irregular Size Notch Issue(s)", "Notch(s)", true, anIssue);
}
{
aManager.AddFeature("Irregular Size Tab Issue(s)", "Tab(s)", true, anIssue);
}
{
aManager.AddFeature(SmallDistanceIssueName(aSDBFIssue), "Distance(s)", true, anIssue);
}
{
aManager.AddFeature("Non Standard Sheet Thickness Issue(s)", "Sheet Thickness(s)", true, anIssue);
}
{
aManager.AddFeature("Non Standard Sheet Size Issue(s)", "Sheet Size(s)", true, anIssue);
}
}
Action<MTKBase_Feature> PrintFeatureParameters = theIssue =>
{
{
FeatureGroupManager.PrintFeatureParameter(
"expected min radius", aSRBIssue.
ExpectedMinRadius(),
"mm");
FeatureGroupManager.PrintFeatureParameter(
"actual radius", aSRBIssue.
ActualRadius(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter(
"expected min diameter", aSDHIssue.
ExpectedMinDiameter(),
"mm");
FeatureGroupManager.PrintFeatureParameter(
"actual diameter", aSDHIssue.
ActualDiameter(),
"mm");
}
{
}
{
}
{
}
{
FeatureGroupManager.PrintFeatureParameter(
"actual extruded height", aIDEHIssue.
ActualExtrudedHeight(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter(
"expected radius", aIROHBIssue.
ExpectedRadius(),
"mm");
FeatureGroupManager.PrintFeatureParameter(
"actual radius", aIROHBIssue.
ActualRadius(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter(
"expected min relief size (LxW)",
new Pair(anExpectedRelief.
Length(), anExpectedRelief.
Width()),
"mm");
if (!aFirstActualRelief.
IsNull() && !aSecondActualRelief.
IsNull())
{
FeatureGroupManager.PrintFeatureParameter(
"first actual relief size (LxW)",
new Pair(aFirstActualRelief.
Length(), aFirstActualRelief.
Width()),
"mm");
FeatureGroupManager.PrintFeatureParameter(
"second actual relief size (LxW)",
new Pair(aSecondActualRelief.
Length(), aSecondActualRelief.
Width()),
"mm");
}
else if (aFirstActualRelief.
IsNull())
{
FeatureGroupManager.PrintFeatureParameter(
"actual relief size (LxW)",
new Pair(aSecondActualRelief.
Length(), aSecondActualRelief.
Width()),
"mm");
}
else
{
FeatureGroupManager.PrintFeatureParameter(
"actual relief size (LxW)",
new Pair(aFirstActualRelief.
Length(), aFirstActualRelief.
Width()),
"mm");
}
}
{
FeatureGroupManager.PrintFeatureParameter(
"expected max depth", aLDBIssue.
ExpectedMaxDepth(),
"mm");
FeatureGroupManager.PrintFeatureParameter(
"actual depth", aLDBIssue.
ActualDepth(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter(
"expected min depth", aSDLIssue.
ExpectedMinDepth(),
"mm");
FeatureGroupManager.PrintFeatureParameter(
"actual depth", aSDLIssue.
ActualDepth(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter(
"expected max radius", aIRBIssue.
ExpectedRadius(),
"mm");
FeatureGroupManager.PrintFeatureParameter(
"actual radius", aIRBIssue.
ActualRadius(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter(
"expected min length", aSLFIssue.
ExpectedMinLength(),
"mm");
FeatureGroupManager.PrintFeatureParameter(
"actual length", aSLFIssue.
ActualLength(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter(
"expected min length", aSLHBFIssue.
ExpectedMinLength(),
"mm");
FeatureGroupManager.PrintFeatureParameter(
"actual length", aSLHBFIssue.
ActualLength(),
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter(
"expected size (LxW)",
"mm");
FeatureGroupManager.PrintFeatureParameter(
"actual size (LxW)",
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter(
"expected size (LxW)",
"mm");
FeatureGroupManager.PrintFeatureParameter(
"actual size (LxW)",
"mm");
}
{
FeatureGroupManager.PrintFeatureParameter(
FeatureGroupManager.PrintFeatureParameter(
}
{
FeatureGroupManager.PrintFeatureParameter(
"nearest standard sheet size (LxW)",
new Pair(aNearestStandardSize.
Length(), aNearestStandardSize.
Width()),
"mm");
FeatureGroupManager.PrintFeatureParameter(
"actual sheet size (LxW)",
"mm");
}
};
aManager.Print("issues", PrintFeatureParameters);
}
{
{
return "Small Distance Between Bend And Louver Issue(s)";
}
{
return "Small Distance Between Extruded Hole And Bend Issue(s)";
}
{
return "Small Distance Between Extruded Hole And Edge Issue(s)";
}
{
return "Small Distance Between Extruded Holes Issue(s)";
}
{
return "Small Distance Between Hole And Bend Issue(s)";
}
{
return "Small Distance Between Hole And Cutout Issue(s)";
}
{
return "Small Distance Between Hole And Edge Issue(s)";
}
{
return "Small Distance Between Hole And Louver Issue(s)";
}
{
return "Small Distance Between Hole And Notch Issue(s)";
}
{
return "Small Distance Between Holes Issue(s)";
}
{
return "Small Distance Between Notch And Bend Issue(s)";
}
{
return "Small Distance Between Notches Issue(s)";
}
{
return "Small Distance Between Tabs Issue(s)";
}
return "Small Distance Between Feature(s)";
}
static double ToDegrees(double theAngleRad)
{
return theAngleRad * 180 / Math.PI;
}
}
}
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
const MTKBase_Feature & Feature(size_t theIndex) const
Access specified element.
Definition MTKBase_FeatureList.cxx:69
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