Hide menu
Loading...
Searching...
No Matches
MTKConverter/Program.cs

Refer to the MTK Converter Example

MTKConverter_PartProcessor.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex;
using System.Collections.Generic;
namespace mtkconverter
{
class MTKConverter_ProcessData
{
protected MTKConverter_ProcessData(Part thePart)
{
myPart = thePart;
}
public Part myPart;
}
abstract class MTKConverter_PartProcessor : ModelElementVoidVisitor
{
protected MTKConverter_PartProcessor()
{
myData = new List<MTKConverter_ProcessData>();
}
public List<MTKConverter_ProcessData> myData;
public override void Apply(Part thePart)
{
cadex.Collections.BodyList aBodyList = thePart.Bodies();
for (int i = 0; i < aBodyList.Count; ++i)
{
Body aBody = aBodyList[i];
var aShapeIt = new ShapeIterator(aBody);
foreach (var aShape in aShapeIt)
{
if (aShape.Type() == ShapeType.Solid)
{
ProcessSolid(thePart, Solid.Cast(aShape));
}
else if (aShape.Type() == ShapeType.Shell)
{
ProcessShell(thePart, Shell.Cast(aShape));
}
}
}
PostPartProcess(thePart);
}
public abstract void ProcessSolid(Part thePart, Solid theSolid);
public abstract void ProcessShell(Part thePart, Shell theShell);
public abstract void PostPartProcess(Part thePart);
}
class MTKConverter_VoidPartProcessor : MTKConverter_PartProcessor
{
public MTKConverter_VoidPartProcessor() : base() { }
public override void ProcessSolid(Part thePart, Solid theSolid) { }
public override void ProcessShell(Part thePart, Shell theShell) { }
public override void PostPartProcess(Part thePart) { }
}
}
Defines classes, types, enums, and functions related to topological entities and scene graph elements...
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.

MTKConverter_MachiningProcessor.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex;
namespace mtkconverter
{
class MTKConverter_MachiningData : MTKConverter_ProcessData
{
public MTKConverter_MachiningData(Part thePart) : base(thePart)
{
myFeatureList = new MTKBase_FeatureList();
myIssueList = new MTKBase_FeatureList();
}
public MTKBase_FeatureList myFeatureList;
public MTKBase_FeatureList myIssueList;
public Machining_OperationType myOperation;
}
class MTKConverter_MachiningProcessor : MTKConverter_VoidPartProcessor
{
public MTKConverter_MachiningProcessor(Machining_OperationType theOperation) : base()
{
myOperation = theOperation;
}
private Machining_OperationType myOperation;
public override void ProcessSolid(Part thePart, Solid theSolid)
{
MTKConverter_MachiningData aMachiningData = new MTKConverter_MachiningData(thePart);
myData.Add(aMachiningData);
aMachiningData.myOperation = myOperation;
Machining_FeatureRecognizer aFeatureRecognizer = new Machining_FeatureRecognizer();
aFeatureRecognizer.Parameters().SetOperation(myOperation);
Machining_Analyzer anAnalyzer = new Machining_Analyzer();
anAnalyzer.AddTool(aFeatureRecognizer);
Machining_Data aData = anAnalyzer.Perform(theSolid);
if (aData.IsEmpty())
{
return;
}
//features
aMachiningData.myFeatureList = aData.FeatureList();
//issues
DFMMachining_DrillingAnalyzerParameters aDrillingParameters = new DFMMachining_DrillingAnalyzerParameters();
DFMMachining_Analyzer aDrillingAnalyzer = new DFMMachining_Analyzer(aDrillingParameters);
aMachiningData.myIssueList = aDrillingAnalyzer.Perform(theSolid, aData);
DFMMachining_MillingAnalyzerParameters aMillingParameters = new DFMMachining_MillingAnalyzerParameters();
DFMMachining_Analyzer aMillingAnalyzer = new DFMMachining_Analyzer(aMillingParameters);
MTKBase_FeatureList aMillingIssueList = aMillingAnalyzer.Perform(theSolid, aData);
for (uint i = 0; i < aMillingIssueList.Size(); ++i)
{
MTKBase_Feature anIssue = aMillingIssueList.Feature(i);
if (myOperation == Machining_OperationType.Machining_OT_LatheMilling
&& !DFMMachining_DeepPocketIssue.CompareType(anIssue))
{
continue;
}
aMachiningData.myIssueList.Append(anIssue);
}
if (myOperation == Machining_OperationType.Machining_OT_LatheMilling)
{
DFMMachining_TurningAnalyzerParameters aTurninigParameters = new DFMMachining_TurningAnalyzerParameters();
DFMMachining_Analyzer aTurningAnalyzer = new DFMMachining_Analyzer(aTurninigParameters);
MTKBase_FeatureList aTurningIssueList = aTurningAnalyzer.Perform(theSolid, aData);
for (uint i = 0; i < aTurningIssueList.Size(); ++i)
{
MTKBase_Feature anIssue = aTurningIssueList.Feature(i);
aMachiningData.myIssueList.Append(anIssue);
}
}
}
}
}

MTKConverter_SheetMetalProcessor.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex;
using System;
using System.Collections.Generic;
namespace mtkconverter
{
class MTKConverter_UnfoldedPartData
{
public MTKConverter_UnfoldedPartData()
{
myIssueList = new MTKBase_FeatureList();
}
public bool IsInit() { return myFlatPattern != null; }
public SheetMetal_FlatPattern myFlatPattern;
public MTKBase_FeatureList myIssueList;
}
class MTKConverter_SheetMetalData : MTKConverter_ProcessData
{
public MTKConverter_SheetMetalData(Part thePart) : base(thePart)
{
myFeatureList = new MTKBase_FeatureList();
myIssueList = new MTKBase_FeatureList();
myUnfoldedPartData = new MTKConverter_UnfoldedPartData();
}
public bool myIsSheetMetalPart = true;
public MTKBase_FeatureList myFeatureList;
public MTKBase_FeatureList myIssueList;
public MTKConverter_UnfoldedPartData myUnfoldedPartData;
}
class MTKConverter_SheetMetalProcessor : MTKConverter_VoidPartProcessor
{
public MTKConverter_SheetMetalProcessor(Model theUnfoldedModel) : base()
{
myAnalyzer = new SheetMetal_Analyzer();
myAnalyzer.AddTool(new SheetMetal_FeatureRecognizer());
myAnalyzer.AddTool(new SheetMetal_Unfolder());
myUnfoldedModel = theUnfoldedModel;
myCurrentUnfoldedBody = new SheetBody();
}
private SheetMetal_Analyzer myAnalyzer;
private Model myUnfoldedModel;
private SheetBody myCurrentUnfoldedBody;
public override void ProcessSolid(Part thePart, Solid theSolid)
{
SheetMetal_Data anSMData = myAnalyzer.Perform(theSolid);
UpdateProcessData(anSMData, thePart);
}
public override void ProcessShell(Part thePart, Shell theShell)
{
SheetMetal_Data anSMData = myAnalyzer.Perform(theShell);
UpdateProcessData(anSMData, thePart);
}
public override void PostPartProcess(Part thePart)
{
if (myCurrentUnfoldedBody.Shapes().Count == 0)
{
return;
}
Part anUnfoldedPart = new Part(thePart.Name());
anUnfoldedPart.SetUuid(thePart.Uuid());
anUnfoldedPart.AddBody(myCurrentUnfoldedBody);
myUnfoldedModel.AddRoot(anUnfoldedPart);
myCurrentUnfoldedBody = new SheetBody();
}
public void UpdateProcessData(SheetMetal_Data theData, Part thePart)
{
MTKConverter_SheetMetalData anSMData = new MTKConverter_SheetMetalData(thePart);
myData.Add(anSMData);
if (theData.IsEmpty())
{
anSMData.myIsSheetMetalPart = false;
return;
}
anSMData.myFeatureList = theData.FeatureList();
SheetMetal_FlatPattern aFlatPattern = theData.FlatPattern();
Shell anUnfoldedShell = !aFlatPattern.IsNull() ? aFlatPattern.UnfoldedShell() : null;
MTKConverter_UnfoldedPartData anUnfoldedData = anSMData.myUnfoldedPartData;
if (anUnfoldedShell != null)
{
myCurrentUnfoldedBody.Append(anUnfoldedShell);
anUnfoldedData.myFlatPattern = aFlatPattern;
}
DFMSheetMetal_Analyzer aDFMAnalyzer = new DFMSheetMetal_Analyzer();
MTKBase_FeatureList anIssueList = aDFMAnalyzer.Perform(theData);
for (uint i = 0; i < anIssueList.Size(); ++i)
{
MTKBase_Feature anIssue = anIssueList.Feature(i);
if (anUnfoldedData.IsInit()
&& (DFMSheetMetal_FlatPatternInterferenceIssue.CompareType(anIssue)
|| DFMSheetMetal_NonStandardSheetSizeIssue.CompareType(anIssue)
|| DFMSheetMetal_NonStandardSheetThicknessIssue.CompareType(anIssue)))
{
anUnfoldedData.myIssueList.Append(anIssue);
}
else
{
anSMData.myIssueList.Append(anIssue);
}
}
}
}
}

MTKConverter_Report.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex;
using System;
using System.Collections.Generic;
using System.IO;
using ShapeIDVectorType = System.Collections.Generic.List<ulong>;
using ShapeIDVectorVectorType = System.Collections.Generic.List<System.Collections.Generic.List<ulong>>;
using FeatureMapType = System.Collections.Generic.SortedDictionary<cadex.MTKBase_Feature,
System.Collections.Generic.KeyValuePair<uint, System.Collections.Generic.List<System.Collections.Generic.List<ulong>>>>;
using PointPairType = System.Collections.Generic.KeyValuePair<cadex.Geom.Point, cadex.Geom.Point>;
namespace mtkconverter
{
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() => $"{FormattedString(First)} x {FormattedString(Second)}";
private string FormattedString(double theValue)
{
System.Globalization.CultureInfo aCI = new System.Globalization.CultureInfo("en-US");
return string.Format(aCI, "{0:0.00}", theValue);
}
}
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() => $"{FormattedString(L)} x {FormattedString(W)} x {FormattedString(D)}";
private string FormattedString(double theValue)
{
System.Globalization.CultureInfo aCI = new System.Globalization.CultureInfo("en-US");
return string.Format(aCI, "{0:0.00}", theValue);
}
}
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);
}
}
public struct Point
{
public Point(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 FeatureComparer : IComparer<MTKBase_Feature>
{
public int Compare(MTKBase_Feature theA, MTKBase_Feature theB)
{
MTKBase_FeatureComparator aComparator = new MTKBase_FeatureComparator();
bool anALessThanB = aComparator.Apply(theA, theB);
if (anALessThanB)
{
return -1;
}
bool aBLessThanA = aComparator.Apply(theB, theA);
if (aBLessThanA)
{
return 1;
}
return 0;
}
}
class JSONWriter
{
public JSONWriter(TextWriter theStream, int theStartNestingLevel = 0)
{
myStream = theStream;
myNestingLevel = theStartNestingLevel;
myPrevNestingLevel = theStartNestingLevel - 1;
}
public void OpenSection()
{
DoOpenSection("", '{');
}
public void OpenSection(string theName)
{
DoOpenSection(theName, '{');
}
public void OpenArraySection(string theName)
{
DoOpenSection(theName, '[');
}
public void CloseSection()
{
DoCloseSection('}');
}
public void CloseArraySection()
{
DoCloseSection(']');
}
public void WriteData<T>(string theParamName, T theValue)
{
System.Globalization.CultureInfo aCI = new System.Globalization.CultureInfo ("en-US");
string aValueString = theValue is double ? string.Format(aCI, "{0:0.00}", theValue) : theValue.ToString();
Stream().Write("\"" + theParamName + "\": \"" + aValueString + "\"");
}
public void WriteRawData(string theRawData)
{
PrepareStream();
myStream.Write(theRawData);
}
public void WriteEmptyArray(string theParamName)
{
Stream().Write("\"" + theParamName + "\": []");
}
public int NestingLevel()
{
return myNestingLevel;
}
private void DoOpenSection(string theName, char theOpenBracketSymbol)
{
TextWriter aStream = Stream();
if (theName.Length > 0)
{
aStream.Write("\"" + theName + "\": ");
}
aStream.Write(theOpenBracketSymbol);
++myNestingLevel;
}
private void DoCloseSection(char theCloseBracketSymbol)
{
--myNestingLevel;
Stream().Write(theCloseBracketSymbol);
}
private void PrepareStream()
{
if (myNestingLevel == myPrevNestingLevel)
{
myStream.Write(",");
}
myPrevNestingLevel = myNestingLevel;
if (myIsInit)
{
myStream.WriteLine();
}
myIsInit = true;
}
private TextWriter Stream()
{
PrepareStream();
for (int i = 0; i < myNestingLevel; ++i)
{
myStream.Write(" ");
}
return myStream;
}
private TextWriter myStream;
private bool myIsInit = false;
private int myNestingLevel;
private int myPrevNestingLevel;
}
class FeatureGroupManager
{
public FeatureGroupManager()
{
myGroups = new List<FeatureGroup>();
}
private class FeatureGroup
{
public FeatureGroup(string theName, string theColor)
{
myName = theName;
myColor = theColor;
myFeatureData = new List<string>();
}
public string myName;
public string myColor;
public List<string> myFeatureData;
public uint myFeatureCount = 0;
}
private List<FeatureGroup> myGroups;
public void AddGroupData(string theGroupName, string theGroupColor, string theFeatureData, uint theFeatureNb)
{
//find or create
int aRes = myGroups.FindIndex(theGroup => theGroup.myName == theGroupName);
if (aRes == -1)
{
myGroups.Add(new FeatureGroup(theGroupName, theGroupColor));
aRes = myGroups.Count - 1;
}
//update
FeatureGroup aGroup = myGroups[aRes];
aGroup.myFeatureData.Add(theFeatureData);
aGroup.myFeatureCount += theFeatureNb;
}
public uint TotalFeatureCount()
{
uint aTotalFeatureCount = 0;
foreach (FeatureGroup aGroup in myGroups)
{
aTotalFeatureCount += aGroup.myFeatureCount;
}
return aTotalFeatureCount;
}
public void Write(JSONWriter theWriter)
{
foreach(FeatureGroup aGroup in myGroups)
{
theWriter.OpenSection();
theWriter.WriteData("name", aGroup.myName);
theWriter.WriteData("color", aGroup.myColor);
theWriter.WriteData("totalGroupFeatureCount", aGroup.myFeatureCount);
List<string> aFeatureData = aGroup.myFeatureData;
if (aFeatureData.Count !=0 )
{
bool aHasParams = aFeatureData[0].IndexOf("parameters") != -1;
if (aHasParams)
{
theWriter.WriteData("subGroupCount", aFeatureData.Count);
theWriter.OpenArraySection("subGroups");
foreach (string j in aFeatureData)
{
theWriter.WriteRawData(j);
}
theWriter.CloseArraySection();
}
else
{
theWriter.OpenArraySection("features");
foreach (string j in aFeatureData)
{
theWriter.WriteRawData(j);
}
theWriter.CloseArraySection();
}
}
theWriter.CloseSection();
}
}
}
class MTKConverter_Report
{
public MTKConverter_Report()
{
myData = new List<MTKConverter_ProcessData>();
}
private List<MTKConverter_ProcessData> myData;
public void AddData(MTKConverter_ProcessData theData)
{
myData.Add(theData);
}
public bool WriteToJSON(UTF16String thePath)
{
string aPath = thePath.ToString();
if (File.Exists(aPath))
{
File.Delete(aPath);
}
try
{
using (StreamWriter aStream = File.CreateText(aPath))
{
JSONWriter aWriter = new JSONWriter(aStream);
aWriter.OpenSection();
aWriter.WriteData("version", "1");
if (myData.Count == 0)
{
aWriter.WriteData("error", "The model doesn't contain any parts.");
}
else
{
aWriter.OpenArraySection("parts");
foreach (MTKConverter_ProcessData aProcessData in myData)
{
aWriter.OpenSection();
WritePartProcessData(aWriter, aProcessData);
aWriter.CloseSection();
}
aWriter.CloseArraySection();
}
aWriter.CloseSection();
}
}
catch
{
return false;
}
return true;
}
private void WriteParameter<T>(JSONWriter theWriter, string theParamName, string theParamUnits, T theParamValue)
{
theWriter.OpenSection();
theWriter.WriteData("name", theParamName);
theWriter.WriteData("units", theParamUnits);
theWriter.WriteData("value", theParamValue);
theWriter.CloseSection();
}
private void WriteShapeIDs(JSONWriter theWriter, ShapeIDVectorVectorType theVector, bool theWriteFeatureSection)
{
if (theVector.Count == 0)
{
return;
}
if (theWriteFeatureSection)
{
theWriter.OpenArraySection("features");
}
foreach (ShapeIDVectorType aShapeIDVector in theVector) {
theWriter.OpenSection();
theWriter.WriteData("shapeIDCount", aShapeIDVector.Count);
if (aShapeIDVector.Count == 0)
{
theWriter.WriteEmptyArray("shapeIDs");
}
else
{
theWriter.OpenArraySection("shapeIDs");
foreach (ulong aShapeID in aShapeIDVector)
{
theWriter.OpenSection();
theWriter.WriteData("id", aShapeID);
theWriter.CloseSection();
}
theWriter.CloseArraySection();
}
theWriter.CloseSection();
}
if (theWriteFeatureSection)
{
theWriter.CloseArraySection();
}
}
private string DoWriteFeatureDataToString(Action<JSONWriter> theFunc, int theParamCount, ShapeIDVectorVectorType theVector)
{
StringWriter aStream = new StringWriter();
JSONWriter aWriter = new JSONWriter(aStream, 7);
aWriter.OpenSection();
aWriter.WriteData("parametersCount", theParamCount);
aWriter.OpenArraySection("parameters");
theFunc(aWriter);
aWriter.CloseArraySection();
WriteShapeIDs(aWriter, theVector, true);
aWriter.CloseSection();
return aStream.ToString();
}
private string WriteFeatureDataToString(ShapeIDVectorVectorType theVector)
{
StringWriter aStream = new StringWriter();
JSONWriter aWriter = new JSONWriter(aStream, 6);
WriteShapeIDs(aWriter, theVector, false);
return aStream.ToString();
}
private string WriteFeatureDataToString<T>(string theParamName, string theParamUnits,
T theParamValue, ShapeIDVectorVectorType theVector)
{
Action<JSONWriter> WriteParams = theWriter => WriteParameter(theWriter, theParamName, theParamUnits, theParamValue);
return DoWriteFeatureDataToString(WriteParams, 1, theVector);
}
private string WriteFeatureDataToString<T1, T2>(string theParamName1, string theParamUnits1, T1 theParamValue1,
string theParamName2, string theParamUnits2, T2 theParamValue2, ShapeIDVectorVectorType theVector)
{
Action<JSONWriter> WriteParams = theWriter =>
{
WriteParameter(theWriter, theParamName1, theParamUnits1, theParamValue1);
WriteParameter(theWriter, theParamName2, theParamUnits2, theParamValue2);
};
return DoWriteFeatureDataToString(WriteParams, 2, theVector);
}
private string WriteFeatureDataToString<T1, T2, T3>(string theParamName1, string theParamUnits1, T1 theParamValue1,
string theParamName2, string theParamUnits2, T2 theParamValue2,
string theParamName3, string theParamUnits3, T3 theParamValue3, ShapeIDVectorVectorType theVector)
{
Action<JSONWriter> WriteParams = theWriter =>
{
WriteParameter(theWriter, theParamName1, theParamUnits1, theParamValue1);
WriteParameter(theWriter, theParamName2, theParamUnits2, theParamValue2);
WriteParameter(theWriter, theParamName3, theParamUnits3, theParamValue3);
};
return DoWriteFeatureDataToString(WriteParams, 3, theVector);
}
private string WriteFeatureDataToString<T1, T2, T3, T4>(string theParamName1, string theParamUnits1, T1 theParamValue1,
string theParamName2, string theParamUnits2, T2 theParamValue2,
string theParamName3, string theParamUnits3, T3 theParamValue3,
string theParamName4, string theParamUnits4, T4 theParamValue4, ShapeIDVectorVectorType theVector)
{
Action<JSONWriter> WriteParams = 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);
}
private string WriteFeatureDataToString<T1, T2, T3, T4, T5, T6>(
string theParamName1, string theParamUnits1, T1 theParamValue1,
string theParamName2, string theParamUnits2, T2 theParamValue2,
string theParamName3, string theParamUnits3, T3 theParamValue3,
string theParamName4, string theParamUnits4, T4 theParamValue4,
string theParamName5, string theParamUnits5, T5 theParamValue5,
string theParamName6, string theParamUnits6, T6 theParamValue6,
ShapeIDVectorVectorType theVector)
{
Action<JSONWriter> WriteParams = 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);
}
private string MachiningFaceTypeToString(Machining_FaceType theType)
{
switch (theType)
{
case Machining_FaceType.Machining_FT_FlatFaceMilled: return "Flat Face Milled Face(s)";
case Machining_FaceType.Machining_FT_FlatSideMilled: return "Flat Side Milled Face(s)";
case Machining_FaceType.Machining_FT_CurvedMilled: return "Curved Milled Face(s)";
case Machining_FaceType.Machining_FT_CircularMilled: return "Circular Milled Face(s)";
case Machining_FaceType.Machining_FT_Deburr: return "Deburr Face(s)";
case Machining_FaceType.Machining_FT_ConvexProfileEdgeMilling: return "Convex Profile Edge Milling Face(s)";
case Machining_FaceType.Machining_FT_ConcaveFilletEdgeMilling: return "Concave Fillet Edge Milling Face(s)";
case Machining_FaceType.Machining_FT_FlatMilled: return "Flat Milled Face(s)";
case Machining_FaceType.Machining_FT_TurnDiameter: return "Turn Diameter Face(s)";
case Machining_FaceType.Machining_FT_TurnForm: return "Turn Form Face(s)";
case Machining_FaceType.Machining_FT_TurnFace: return "Turn Face Face(s)";
default:
break;
}
return "Face(s)";
}
private string MachiningFaceColor(Machining_FaceType theType)
{
switch (theType)
{
case Machining_FaceType.Machining_FT_FlatFaceMilled: return "(115, 251, 253)";
case Machining_FaceType.Machining_FT_FlatSideMilled: return "(0, 35, 245)";
case Machining_FaceType.Machining_FT_CurvedMilled: return "(22, 65, 124)";
case Machining_FaceType.Machining_FT_CircularMilled: return "(255, 254, 145)";
case Machining_FaceType.Machining_FT_Deburr: return "(0, 0, 0)";
case Machining_FaceType.Machining_FT_ConvexProfileEdgeMilling: return "(240, 155, 89)";
case Machining_FaceType.Machining_FT_ConcaveFilletEdgeMilling: return "(129, 127, 38)";
case Machining_FaceType.Machining_FT_FlatMilled: return "(115, 43, 245)";
case Machining_FaceType.Machining_FT_TurnDiameter: return "(88, 19, 94)";
case Machining_FaceType.Machining_FT_TurnForm: return "(161, 251, 142)";
case Machining_FaceType.Machining_FT_TurnFace: return "(239, 136, 190)";
default:
break;
}
return "(0, 0, 0)";
}
private string MachiningHoleTypeToString(Machining_HoleType theType)
{
switch (theType)
{
case Machining_HoleType.Machining_HT_Through: return "Through Hole(s)";
case Machining_HoleType.Machining_HT_FlatBottom: return "Flat Bottom Hole(s)";
case Machining_HoleType.Machining_HT_Blind: return "Blind Hole(s)";
case Machining_HoleType.Machining_HT_Partial: return "Partial Hole(s)";
default:
break;
}
return "Hole(s)";
}
private string MachiningHoleColor(Machining_HoleType theType)
{
switch (theType)
{
case Machining_HoleType.Machining_HT_Through: return "(240, 135, 132)";
case Machining_HoleType.Machining_HT_FlatBottom: return "(235, 51, 36)";
case Machining_HoleType.Machining_HT_Blind: return "(142, 64, 58)";
case Machining_HoleType.Machining_HT_Partial: return "(58, 6, 3)";
default:
break;
}
return "(0, 0, 0)";
}
private string MachiningThreadedHoleColor (Machining_HoleType theType)
{
switch (theType)
{
case Machining_HoleType.Machining_HT_Through: return "(35, 160, 207)";
case Machining_HoleType.Machining_HT_FlatBottom: return "(35, 76, 111)";
case Machining_HoleType.Machining_HT_Blind: return "(192, 89, 133)";
case Machining_HoleType.Machining_HT_Partial: return "(108, 31, 78)";
default:
break;
}
return "(0, 0, 0)";
}
private string MachiningPocketTypeToString(Machining_PocketType theType)
{
switch (theType)
{
case Machining_PocketType.Machining_PT_Closed: return "Closed Pocket(s)";
case Machining_PocketType.Machining_PT_Open: return "Open Pocket(s)";
case Machining_PocketType.Machining_PT_Through: return "Through Pocket(s)";
default:
break;
}
return "Pocket(s)";
}
private string MachiningPocketColor(Machining_PocketType theType)
{
switch (theType)
{
case Machining_PocketType.Machining_PT_Closed: return "(81, 20, 0)";
case Machining_PocketType.Machining_PT_Open: return "(189, 103, 37)";
case Machining_PocketType.Machining_PT_Through: return "(255, 217, 188)";
default:
break;
}
return "(0, 0, 0)";
}
private string HemTypeToString(SheetMetal_HemBendType theType)
{
switch (theType) {
case SheetMetal_HemBendType.SheetMetal_HBT_Flattened: return "Flattened Hem Bend(s)";
case SheetMetal_HemBendType.SheetMetal_HBT_Open: return "Open Hem Bend(s)";
case SheetMetal_HemBendType.SheetMetal_HBT_Teardrop: return "Teardrop Hem Bend(s)";
case SheetMetal_HemBendType.SheetMetal_HBT_Rope: return "Rope Hem Bend(s)";
case SheetMetal_HemBendType.SheetMetal_HBT_Rolled: return "Rolled Hem Bend(s)";
default:
break;
}
return "Hem Bend(s)";
}
private static string MachiningTurningGrooveTypeToString(Machining_TurningGrooveType theType)
{
switch (theType)
{
case Machining_TurningGrooveType.Machining_TGT_OuterDiameter: return "Outer Diameter Groove(s)";
case Machining_TurningGrooveType.Machining_TGT_InnerDiameter: return "Inner Diameter Groove(s)";
case Machining_TurningGrooveType.Machining_TGT_EndFace: return "End Face Groove(s)";
default:
break;
}
return "Turning Groove(s)";
}
private string MachiningTurningGrooveColor(Machining_TurningGrooveType theType)
{
switch (theType)
{
case Machining_TurningGrooveType.Machining_TGT_OuterDiameter: return "(175, 49, 37)";
case Machining_TurningGrooveType.Machining_TGT_InnerDiameter: return "(234, 255, 53)";
case Machining_TurningGrooveType.Machining_TGT_EndFace: return "(144, 66, 159)";
default:
break;
}
return "(0, 0, 0)";
}
private string BendName(SheetMetal_Bend theBend)
{
if (SheetMetal_HemBend.CompareType(theBend))
{
SheetMetal_HemBend aHemBend = SheetMetal_HemBend.Cast(theBend);
return HemTypeToString(aHemBend.Type());
}
else if (SheetMetal_CurvedBend.CompareType(theBend))
{
return "Curved Bend(s)";
}
return "Bend(s)";
}
private string BendColor(SheetMetal_Bend theBend)
{
if (SheetMetal_HemBend.CompareType(theBend))
{
SheetMetal_HemBendType aType = SheetMetal_HemBend.Cast(theBend).Type();
switch (aType) {
case SheetMetal_HemBendType.SheetMetal_HBT_Flattened: return "(22, 65, 124)";
case SheetMetal_HemBendType.SheetMetal_HBT_Open: return "(42, 85, 144)";
case SheetMetal_HemBendType.SheetMetal_HBT_Teardrop: return "(62, 105, 164)";
case SheetMetal_HemBendType.SheetMetal_HBT_Rope: return "(82, 125, 184)";
case SheetMetal_HemBendType.SheetMetal_HBT_Rolled: return "(102, 145, 204)";
default:
break;
}
return "(0, 0, 0)";
}
else if (SheetMetal_CurvedBend.CompareType(theBend))
{
return "(255, 254, 145)";
}
return "(0, 35, 245)";
}
private string SheetMetalHoleName(SheetMetal_Hole theHole)
{
if (SheetMetal_ComplexHole.CompareType(theHole))
{
return "Complex Hole(s)";
}
return "Hole(s)";
}
private string SheetMetalHoleColor(SheetMetal_Hole theHole)
{
if (SheetMetal_ComplexHole.CompareType(theHole))
{
return "(115, 43, 245)";
}
return "(129, 127, 38)";
}
private string SmallDistanceIssueName(DFMSheetMetal_SmallDistanceBetweenFeaturesIssue theIssue)
{
if (DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue.CompareType(theIssue))
{
return "Small Distance Between Bend And Louver Issue(s)";
}
else if (DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue.CompareType(theIssue))
{
return "Small Distance Between Extruded Hole And Bend Issue(s)";
}
else if (DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndEdgeIssue.CompareType(theIssue))
{
return "Small Distance Between Extruded Hole And Edge Issue(s)";
}
else if (DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue.CompareType(theIssue))
{
return "Small Distance Between Extruded Holes Issue(s)";
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue.CompareType(theIssue))
{
return "Small Distance Between Hole And Bend Issue(s)";
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue.CompareType(theIssue))
{
return "Small Distance Between Hole And Cutout Issue(s)";
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue.CompareType(theIssue))
{
return "Small Distance Between Hole And Edge Issue(s)";
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue.CompareType(theIssue))
{
return "Small Distance Between Hole And Louver Issue(s)";
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue.CompareType(theIssue))
{
return "Small Distance Between Hole And Notch Issue(s)";
}
else if (DFMSheetMetal_SmallDistanceBetweenHolesIssue.CompareType(theIssue))
{
return "Small Distance Between Holes Issue(s)";
}
else if (DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue.CompareType(theIssue))
{
return "Small Distance Between Notch And Bend Issue(s)";
}
else if (DFMSheetMetal_SmallDistanceBetweenNotchesIssue.CompareType(theIssue))
{
return "Small Distance Between Notches Issue(s)";
}
else if (DFMSheetMetal_SmallDistanceBetweenTabsIssue.CompareType(theIssue))
{
return "Small Distance Between Tabs Issue(s)";
}
return "Small Distance Between Feature(s)";
}
private string SmallDistanceIssueColor(DFMSheetMetal_SmallDistanceBetweenFeaturesIssue theIssue)
{
if (DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue.CompareType(theIssue))
{
return "(195, 56, 19)";
}
else if (DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue.CompareType(theIssue))
{
return "(212, 75, 90)";
}
else if (DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndEdgeIssue.CompareType(theIssue))
{
return "(198, 75, 105)";
}
else if (DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue.CompareType(theIssue))
{
return "(170, 65, 120)";
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue.CompareType(theIssue))
{
return "(239, 136, 190)";
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue.CompareType(theIssue))
{
return "(127, 130, 187)";
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue.CompareType(theIssue))
{
return "(240, 135, 132)";
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue.CompareType(theIssue))
{
return "(15, 5, 129)";
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue.CompareType(theIssue))
{
return "(235, 51, 36)";
}
else if (DFMSheetMetal_SmallDistanceBetweenHolesIssue.CompareType(theIssue))
{
return "(142, 64, 58)";
}
else if (DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue.CompareType(theIssue))
{
return "(58, 6, 3)";
}
else if (DFMSheetMetal_SmallDistanceBetweenNotchesIssue.CompareType(theIssue))
{
return "(0, 215, 3)";
}
else if (DFMSheetMetal_SmallDistanceBetweenTabsIssue.CompareType(theIssue))
{
return "(157, 160, 207)";
}
return "(0, 0, 0)";
}
private void AddShapeFeature(FeatureGroupManager theManager, MTKBase_ShapeFeature theFeature,
uint theCount, ShapeIDVectorVectorType theShapeIdVector)
{
MTKBase_ShapeFeature aFeature = theFeature;
//machining
if (Machining_TurningFace.CompareType(aFeature))
{
Machining_TurningFace aTurningFace = Machining_TurningFace.Cast(aFeature);
Machining_FaceType aType = aTurningFace.Type();
string aFeatureData = WriteFeatureDataToString("Radius", "mm", aTurningFace.Radius(), theShapeIdVector);
theManager.AddGroupData(MachiningFaceTypeToString(aType), MachiningFaceColor(aType), aFeatureData, theCount);
}
else if (Machining_Face.CompareType(aFeature))
{
Machining_Face aFace = Machining_Face.Cast(aFeature);
Machining_FaceType aType = aFace.Type();
string aFeatureData = WriteFeatureDataToString(theShapeIdVector);
theManager.AddGroupData(MachiningFaceTypeToString(aType), MachiningFaceColor(aType), aFeatureData, theCount);
}
else if (Machining_Countersink.CompareType(aFeature))
{
Machining_Countersink aCountersink = Machining_Countersink.Cast(aFeature);
cadex.Geom.Direction aDir = aCountersink.Axis().Axis();
string aFeatureData = WriteFeatureDataToString(
"Radius", "mm", aCountersink.Radius(),
"Depth", "mm", aCountersink.Depth(),
"Axis", "", new Direction (aDir.X(), aDir.Y(), aDir.Z()),
theShapeIdVector);
theManager.AddGroupData("Countersink(s)", "(55, 125, 34)", aFeatureData, theCount);
}
else if (Machining_ThreadedHole.CompareType(aFeature))
{
Machining_ThreadedHole aThreadedHole = Machining_ThreadedHole.Cast(aFeature);
cadex.Geom.Direction aDir = aThreadedHole.Axis().Axis();
Machining_HoleType aType = aThreadedHole.Type();
string 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", "", new Direction(aDir.X(), aDir.Y(), aDir.Z()),
theShapeIdVector);
string aGroupName = "Threaded " + MachiningHoleTypeToString(aThreadedHole.Type());
theManager.AddGroupData(aGroupName, MachiningThreadedHoleColor(aType), aFeatureData, theCount);
}
else if (Machining_Hole.CompareType(aFeature))
{
Machining_Hole aHole = Machining_Hole.Cast(aFeature);
cadex.Geom.Direction aDir = aHole.Axis().Axis();
Machining_HoleType aType = aHole.Type();
string aFeatureData = WriteFeatureDataToString(
"Radius", "mm", aHole.Radius(),
"Depth", "mm", aHole.Depth(),
"Axis", "", new Direction(aDir.X(), aDir.Y(), aDir.Z()),
theShapeIdVector);
theManager.AddGroupData(MachiningHoleTypeToString(aType), MachiningHoleColor(aType), aFeatureData, theCount);
}
else if (Machining_SteppedHole.CompareType(aFeature))
{
Machining_SteppedHole aHole = Machining_SteppedHole.Cast(aFeature);
string aFeatureData = WriteFeatureDataToString(
"Depth", "mm", aHole.Depth(),
theShapeIdVector);
theManager.AddGroupData("Stepped Hole(s)", "(204, 0, 125)", aFeatureData, theCount);
}
else if (Machining_Pocket.CompareType(aFeature))
{
Machining_Pocket aPocket = Machining_Pocket.Cast(aFeature);
cadex.Geom.Direction aDir = aPocket.Axis().Direction();
Machining_PocketType aType = aPocket.Type();
string aFeatureData = WriteFeatureDataToString(
"Length", "mm", aPocket.Length(),
"Width", "mm", aPocket.Width(),
"Depth", "mm", aPocket.Depth(),
"Axis", "", new Direction(aDir.X(), aDir.Y(), aDir.Z()),
theShapeIdVector);
theManager.AddGroupData(MachiningPocketTypeToString(aType), MachiningPocketColor(aType), aFeatureData, theCount);
}
else if (Machining_TurningGroove.CompareType(aFeature))
{
Machining_TurningGroove aTurnGroove = Machining_TurningGroove.Cast(aFeature);
Machining_TurningGrooveType aType = aTurnGroove.Type();
string 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 (Machining_Bore.CompareType(aFeature))
{
Machining_Bore aBore = Machining_Bore.Cast(aFeature);
string aFeatureData = WriteFeatureDataToString(
"Radius", "mm", aBore.Radius(),
"Depth", "mm", aBore.Depth(),
theShapeIdVector);
theManager.AddGroupData("Bore(s)", "(127, 130, 187)", aFeatureData, theCount);
}
//molding
else if (Molding_ScrewBoss.CompareType (aFeature))
{
Molding_ScrewBoss aScrewBoss = Molding_ScrewBoss.Cast (aFeature);
string aFeatureData = WriteFeatureDataToString(
"Outer Radius", "mm", aScrewBoss.OuterRadius(),
"Inner Radius", "mm", aScrewBoss.InnerRadius(),
"Draft Angle", "deg", aScrewBoss.DraftAngle() * 180 / Math.PI,
theShapeIdVector);
theManager.AddGroupData("Screw Boss(es)", "(12, 32, 63)", aFeatureData, theCount);
}
else if (MTKBase_Boss.CompareType(aFeature))
{
MTKBase_Boss aBoss = MTKBase_Boss.Cast(aFeature);
string 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 (Molding_Rib.CompareType(aFeature))
{
Molding_Rib aRib = Molding_Rib.Cast(aFeature);
string aFeatureData = WriteFeatureDataToString(
"Length", "mm", aRib.Length(),
"Height", "mm", aRib.Height(),
"Thickness", "mm", aRib.Thickness(),
"Draft Angle", "deg", aRib.DraftAngle() * 180 / Math.PI,
theShapeIdVector);
theManager.AddGroupData("Rib(s)", "(34, 51, 127)", aFeatureData, theCount);
}
//sheet metal
else if (SheetMetal_Bead.CompareType(aFeature))
{
SheetMetal_Bead aBead = SheetMetal_Bead.Cast(aFeature);
string aFeatureData = WriteFeatureDataToString("Depth", "mm", aBead.Depth(), theShapeIdVector);
theManager.AddGroupData("Bead(s)", "(115, 251, 253)", aFeatureData, theCount);
}
else if (SheetMetal_Bend.CompareType(aFeature))
{
SheetMetal_Bend aBend = SheetMetal_Bend.Cast(aFeature);
string aFeatureData = WriteFeatureDataToString(
"Radius", "mm", aBend.Radius(),
"Angle", "deg", aBend.Angle() * 180 / Math.PI,
"Length", "mm", aBend.Length(),
"Width", "mm", aBend.Width(),
theShapeIdVector);
theManager.AddGroupData(BendName(aBend), BendColor(aBend), aFeatureData, theCount);
}
else if (SheetMetal_Bridge.CompareType(aFeature))
{
SheetMetal_Bridge aBridge = SheetMetal_Bridge.Cast(aFeature);
string aFeatureData = WriteFeatureDataToString(
"Length", "mm", aBridge.Length(),
"Depth", "mm", aBridge.Depth(),
theShapeIdVector);
theManager.AddGroupData("Bridge(s)", "(240, 155, 89)", aFeatureData, theCount);
}
else if (SheetMetal_Hole.CompareType(aFeature))
{
SheetMetal_Hole aHole = SheetMetal_Hole.Cast(aFeature);
cadex.Geom.Direction aDir = aHole.Axis().Axis();
string aFeatureData = WriteFeatureDataToString(
"Radius", "mm", aHole.Radius(),
"Depth", "mm", aHole.Depth(),
"Axis", "", new Direction(aDir.X(), aDir.Y(), aDir.Z()),
theShapeIdVector);
theManager.AddGroupData(SheetMetalHoleName(aHole), SheetMetalHoleColor(aHole), aFeatureData, theCount);
}
else if (SheetMetal_Cutout.CompareType(aFeature))
{
SheetMetal_Cutout aCutout = SheetMetal_Cutout.Cast(aFeature);
string aFeatureData = WriteFeatureDataToString("Perimeter", "mm", aCutout.Perimeter(), theShapeIdVector);
theManager.AddGroupData("Cutout(s)", "(88, 19, 94)", aFeatureData, theCount);
}
else if (SheetMetal_Louver.CompareType(aFeature))
{
SheetMetal_Louver aLouver = SheetMetal_Louver.Cast(aFeature);
string aFeatureData = WriteFeatureDataToString(
"Depth", "mm", aLouver.Depth(),
theShapeIdVector);
theManager.AddGroupData("Louver(s)", "(161, 251, 142)", aFeatureData, theCount);
}
else if (SheetMetal_Notch.CompareType(aFeature))
{
SheetMetal_Notch aNotch = SheetMetal_Notch.Cast(aFeature);
if (SheetMetal_StraightNotch.CompareType(aNotch))
{
SheetMetal_StraightNotch aStraightNotch = SheetMetal_StraightNotch.Cast(aNotch);
string 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 (SheetMetal_VNotch.CompareType(aNotch))
{
SheetMetal_VNotch aVNotch = SheetMetal_VNotch.Cast(aNotch);
string aFeatureData = WriteFeatureDataToString (
"Length", "mm", aNotch.Length(),
"Width", "mm", aNotch.Width(),
"Angle", "deg", aVNotch.Angle() * 180 / Math.PI,
theShapeIdVector);
theManager.AddGroupData ("V Notch(es)", "(235, 51, 36)", aFeatureData, theCount);
}
else
{
string aFeatureData = WriteFeatureDataToString(
"Length", "mm", aNotch.Length(),
"Width", "mm", aNotch.Width(),
theShapeIdVector);
theManager.AddGroupData("Notch(es)", "(239, 136, 190)", aFeatureData, theCount);
}
}
else if (SheetMetal_Tab.CompareType(aFeature))
{
SheetMetal_Tab aTab = SheetMetal_Tab.Cast(aFeature);
string aFeatureData = WriteFeatureDataToString(
"Length", "mm", aTab.Length(),
"Width", "mm", aTab.Width(),
theShapeIdVector);
theManager.AddGroupData("Tab(s)", "(127, 130, 187)", aFeatureData, theCount);
}
}
private void AddDrillingIssue(FeatureGroupManager theManager, DFMMachining_DrillingIssue theIssue,
uint theCount, ShapeIDVectorVectorType theShapeIdVector)
{
if (DFMMachining_SmallDiameterHoleIssue.CompareType(theIssue))
{
DFMMachining_SmallDiameterHoleIssue aSmallHoleIssue = DFMMachining_SmallDiameterHoleIssue.Cast(theIssue);
string 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 (DFMMachining_DeepHoleIssue.CompareType(theIssue))
{
DFMMachining_DeepHoleIssue aDeepHoleIssue = DFMMachining_DeepHoleIssue.Cast(theIssue);
string 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 (DFMMachining_NonStandardDiameterHoleIssue.CompareType(theIssue))
{
DFMMachining_NonStandardDiameterHoleIssue aNSDiameterHoleIssue = DFMMachining_NonStandardDiameterHoleIssue.Cast(theIssue);
string 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 (DFMMachining_NonStandardDrillPointAngleBlindHoleIssue.CompareType(theIssue))
{
DFMMachining_NonStandardDrillPointAngleBlindHoleIssue aNSDrillPointAngleBlindHoleIssue = DFMMachining_NonStandardDrillPointAngleBlindHoleIssue.Cast(theIssue);
string aFeatureData = WriteFeatureDataToString(
"Nearest Standard Angle", "deg", aNSDrillPointAngleBlindHoleIssue.NearestStandardAngle() * 180 / Math.PI,
"Actual Angle", "deg", aNSDrillPointAngleBlindHoleIssue.ActualAngle() * 180 / Math.PI,
theShapeIdVector);
theManager.AddGroupData("Non Standard Drill Point Angle Blind Hole(s)", "(88, 13, 78)", aFeatureData, theCount);
}
else if (DFMMachining_PartialHoleIssue.CompareType(theIssue))
{
DFMMachining_PartialHoleIssue aPartialHoleIssue = DFMMachining_PartialHoleIssue.Cast(theIssue);
string 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 (DFMMachining_FlatBottomHoleIssue.CompareType(theIssue))
{
string aFeatureData = WriteFeatureDataToString(theShapeIdVector);
theManager.AddGroupData("Flat Bottom Hole(s)", "(240, 155, 89)", aFeatureData, theCount);
}
else if (DFMMachining_NonPerpendicularHoleIssue.CompareType(theIssue))
{
string aFeatureData = WriteFeatureDataToString(theShapeIdVector);
theManager.AddGroupData("Non Perpendicular Hole(s)", "(129, 127, 38)", aFeatureData, theCount);
}
else if (DFMMachining_IntersectingCavityHoleIssue.CompareType(theIssue))
{
string aFeatureData = WriteFeatureDataToString(theShapeIdVector);
theManager.AddGroupData("Intersecting Cavity Hole(s)", "(115, 43, 245)", aFeatureData, theCount);
}
}
private void AddMillingIssue(FeatureGroupManager theManager, DFMMachining_MillingIssue theIssue,
uint theCount, ShapeIDVectorVectorType theShapeIdVector)
{
if (DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue.CompareType(theIssue))
{
DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue aFloorRadiusIssue =
DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue.Cast(theIssue);
string 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 (DFMMachining_DeepPocketIssue.CompareType(theIssue))
{
DFMMachining_DeepPocketIssue aDeepPocketIssue = DFMMachining_DeepPocketIssue.Cast(theIssue);
string 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 (DFMMachining_HighBossIssue.CompareType(theIssue))
{
DFMMachining_HighBossIssue aHighBossIssue = DFMMachining_HighBossIssue.Cast(theIssue);
string 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 (DFMMachining_LargeMilledPartIssue.CompareType(theIssue))
{
DFMMachining_LargeMilledPartIssue aLMPIssue = DFMMachining_LargeMilledPartIssue.Cast(theIssue);
DFMMachining_MilledPartSize anExpectedSize = aLMPIssue.ExpectedMaxMilledPartSize();
DFMMachining_MilledPartSize anActualSize = aLMPIssue.ActualMilledPartSize();
string aFeatureData = WriteFeatureDataToString(
"Expected Maximum Size (LxWxH)", "mm",
new Dimension(anExpectedSize.Length(), anExpectedSize.Width(), anExpectedSize.Height()),
"Actual Size (LxWxH)", "mm",
new Dimension(anActualSize.Length(), anActualSize.Width(), anActualSize.Height()),
theShapeIdVector);
theManager.AddGroupData("Large Milled Part(s)", "(17, 37, 205)", aFeatureData, theCount);
}
else if (DFMMachining_SmallRadiusMilledPartInternalCornerIssue.CompareType(theIssue))
{
DFMMachining_SmallRadiusMilledPartInternalCornerIssue aMSICRIssue =
DFMMachining_SmallRadiusMilledPartInternalCornerIssue.Cast(theIssue);
string 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 (DFMMachining_NonPerpendicularMilledPartShapeIssue.CompareType(theIssue))
{
DFMMachining_NonPerpendicularMilledPartShapeIssue aNPMPSIssue =
DFMMachining_NonPerpendicularMilledPartShapeIssue.Cast(theIssue);
string aFeatureData = WriteFeatureDataToString(
"Actual Angle", "deg", aNPMPSIssue.ActualAngle() * 180 / Math.PI,
theShapeIdVector);
theManager.AddGroupData("Non Perpendicular Milled Part Shape(s)", "(129, 227, 138)", aFeatureData, theCount);
}
else if (DFMMachining_MilledPartExternalEdgeFilletIssue.CompareType(theIssue))
{
string aFeatureData = WriteFeatureDataToString(theShapeIdVector);
theManager.AddGroupData("Milled Part External Edge Fillet(s)", "(201, 227, 13)", aFeatureData, theCount);
}
else if (DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue.CompareType(theIssue))
{
DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue anInconsistentRadiusIssue =
DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue.Cast(theIssue);
string 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 (DFMMachining_NarrowRegionInPocketIssue.CompareType(theIssue))
{
DFMMachining_NarrowRegionInPocketIssue aNarrowRegionIssue =
DFMMachining_NarrowRegionInPocketIssue.Cast(theIssue);
string 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 (DFMMachining_LargeDifferenceRegionsSizeInPocketIssue.CompareType(theIssue))
{
DFMMachining_LargeDifferenceRegionsSizeInPocketIssue aLargeRatioIssue =
DFMMachining_LargeDifferenceRegionsSizeInPocketIssue.Cast(theIssue);
string 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 (DFMMachining_SmallWallThicknessIssue.CompareType(theIssue))
{
DFMMachining_SmallWallThicknessIssue aSWTIssue = DFMMachining_SmallWallThicknessIssue.Cast(theIssue);
string 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);
}
}
private void AddTurningIssue(FeatureGroupManager theManager, DFMBase_Issue theIssue,
uint theCount, ShapeIDVectorVectorType theShapeIdVector)
{
if (DFMMachining_LargeTurnedPartIssue.CompareType(theIssue))
{
DFMMachining_LargeTurnedPartIssue aLTSIssue = DFMMachining_LargeTurnedPartIssue.Cast(theIssue);
DFMMachining_TurnedPartSize anExpectedSize = aLTSIssue.ExpectedMaxTurnedPartSize();
DFMMachining_TurnedPartSize anActualSize = aLTSIssue.ActualTurnedPartSize();
string aFeatureData = WriteFeatureDataToString(
"Expected Maximum Size (LxR)", "mm", new Pair(anExpectedSize.Length(), anExpectedSize.Radius()),
"Actual Size (LxR)", "mm", new Pair(anActualSize.Length(), anActualSize.Radius()),
theShapeIdVector);
theManager.AddGroupData("Large Turned Part(s)", "(195, 195, 195)", aFeatureData, theCount);
}
else if (DFMMachining_LongSlenderTurnedPartIssue.CompareType(theIssue))
{
DFMMachining_LongSlenderTurnedPartIssue aLSTIssue = DFMMachining_LongSlenderTurnedPartIssue.Cast(theIssue);
string 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 (DFMMachining_SmallDepthBlindBoredHoleReliefIssue.CompareType(theIssue))
{
DFMMachining_SmallDepthBlindBoredHoleReliefIssue aBBHRIssue = DFMMachining_SmallDepthBlindBoredHoleReliefIssue.Cast(theIssue);
string 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 (DFMMachining_DeepBoredHoleIssue.CompareType(theIssue))
{
DFMMachining_DeepBoredHoleIssue aISBHIssue = DFMMachining_DeepBoredHoleIssue.Cast(theIssue);
string 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 (DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue.CompareType(theIssue))
{
DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue aODPRIssue =
DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue.Cast(theIssue);
string aFeatureData = WriteFeatureDataToString(
"Expected Maximum Face Incline Angle", "deg", aODPRIssue.ExpectedMaxFaceInclineAngle() * 180 / Math.PI,
"Actual Face Incline Angle", "deg", aODPRIssue.ActualFaceInclineAngle() * 180 / Math.PI,
theShapeIdVector);
theManager.AddGroupData("Irregular Turned Part Outer Diameter Profile Relief(s)", "(239, 136, 190)", aFeatureData, theCount);
}
else if (DFMMachining_SmallRadiusTurnedPartInternalCornerIssue.CompareType(theIssue))
{
DFMMachining_SmallRadiusTurnedPartInternalCornerIssue aTSICRIssue =
DFMMachining_SmallRadiusTurnedPartInternalCornerIssue.Cast(theIssue);
string 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 (DFMMachining_SquareEndKeywayIssue.CompareType(theIssue))
{
string aFeatureData = WriteFeatureDataToString(theShapeIdVector);
theManager.AddGroupData("Square End Keyway(s)", "(157, 160, 207)", aFeatureData, theCount);
}
else if (DFMMachining_NonSymmetricalAxialSlotIssue.CompareType(theIssue))
{
string aFeatureData = WriteFeatureDataToString(theShapeIdVector);
theManager.AddGroupData("Non Symmetrical Axial Slot(s)", "(130, 170, 200)", aFeatureData, theCount);
}
}
private void AddMoldingIssue (FeatureGroupManager theManager, DFMBase_Issue theIssue,
uint theCount, ShapeIDVectorVectorType theShapeIdVector)
{
if (DFMMolding_HighRibIssue.CompareType (theIssue))
{
DFMMolding_HighRibIssue aHRIssue = DFMMolding_HighRibIssue.Cast(theIssue);
string 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 (DFMMolding_HighScrewBossIssue.CompareType (theIssue))
{
DFMMolding_HighScrewBossIssue aHSBIssue = DFMMolding_HighScrewBossIssue.Cast(theIssue);
string 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 (DFMMolding_IrregularCoreDepthScrewBossIssue.CompareType (theIssue))
{
DFMMolding_IrregularCoreDepthScrewBossIssue aICDSBIssue = DFMMolding_IrregularCoreDepthScrewBossIssue.Cast(theIssue);
string 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 (DFMMolding_IrregularCoreDiameterScrewBossIssue.CompareType (theIssue))
{
DFMMolding_IrregularCoreDiameterScrewBossIssue aICDSBIssue = DFMMolding_IrregularCoreDiameterScrewBossIssue.Cast(theIssue);
string 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 (DFMMolding_IrregularThicknessRibIssue.CompareType (theIssue))
{
DFMMolding_IrregularThicknessRibIssue aITRIssue = DFMMolding_IrregularThicknessRibIssue.Cast(theIssue);
string 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 (DFMMolding_IrregularWallThicknessIssue.CompareType (theIssue))
{
DFMMolding_IrregularWallThicknessIssue aIWTIssue = DFMMolding_IrregularWallThicknessIssue.Cast(theIssue);
string 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 (DFMMolding_IrregularWallThicknessScrewBossIssue.CompareType (theIssue))
{
DFMMolding_IrregularWallThicknessScrewBossIssue aIWTSBIssue = DFMMolding_IrregularWallThicknessScrewBossIssue.Cast(theIssue);
string 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 (DFMMolding_LargeWallThicknessIssue.CompareType (theIssue))
{
DFMMolding_LargeWallThicknessIssue aLWTIssue = DFMMolding_LargeWallThicknessIssue.Cast(theIssue);
string 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 (DFMMolding_SmallBaseRadiusRibIssue.CompareType (theIssue))
{
DFMMolding_SmallBaseRadiusRibIssue aSBRRIssue = DFMMolding_SmallBaseRadiusRibIssue.Cast(theIssue);
string 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 (DFMMolding_SmallBaseRadiusScrewBossIssue.CompareType (theIssue))
{
DFMMolding_SmallBaseRadiusScrewBossIssue aSBRSBIssue = DFMMolding_SmallBaseRadiusScrewBossIssue.Cast(theIssue);
string 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 (DFMMolding_SmallDraftAngleRibIssue.CompareType (theIssue))
{
DFMMolding_SmallDraftAngleRibIssue aSDARIssue = DFMMolding_SmallDraftAngleRibIssue.Cast(theIssue);
string aFeatureData = WriteFeatureDataToString(
"Expected Minimum Draft Angle", "deg", aSDARIssue.ExpectedMinDraftAngle() * 180.0 / Math.PI,
"Actual Draft Angle", "deg", aSDARIssue.ActualDraftAngle() * 180.0 / Math.PI,
theShapeIdVector);
theManager.AddGroupData("Small Draft Angle Rib(s)", "(189, 200, 13)", aFeatureData, theCount);
}
else if (DFMMolding_SmallDraftAngleScrewBossIssue.CompareType (theIssue))
{
DFMMolding_SmallDraftAngleScrewBossIssue aSDASBIssue = DFMMolding_SmallDraftAngleScrewBossIssue.Cast(theIssue);
string aFeatureData = WriteFeatureDataToString(
"Expected Minimum Draft Angle", "deg", aSDASBIssue.ExpectedMinDraftAngle() * 180.0 / Math.PI,
"Actual Draft Angle", "deg", aSDASBIssue.ActualDraftAngle() * 180.0 / Math.PI,
theShapeIdVector);
theManager.AddGroupData("Small Draft Angle Screw Boss(es)", "(27, 101, 27)", aFeatureData, theCount);
}
else if (DFMMolding_SmallHoleBaseRadiusScrewBossIssue.CompareType (theIssue))
{
DFMMolding_SmallHoleBaseRadiusScrewBossIssue aSHBRSBIssue = DFMMolding_SmallHoleBaseRadiusScrewBossIssue.Cast(theIssue);
string 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 (DFMMolding_SmallDraftAngleWallIssue.CompareType (theIssue))
{
DFMMolding_SmallDraftAngleWallIssue aSDAWIssue = DFMMolding_SmallDraftAngleWallIssue.Cast(theIssue);
string aFeatureData = WriteFeatureDataToString(
"Expected Minimum Draft Angle", "deg", aSDAWIssue.ExpectedMinDraftAngle() * 180.0 / Math.PI,
"Actual Draft Angle", "deg", aSDAWIssue.ActualDraftAngle() * 180.0 / Math.PI,
theShapeIdVector);
theManager.AddGroupData("Small Draft Angle Wall(s)", "(101, 67, 33)", aFeatureData, theCount);
}
else if (DFMMolding_NonChamferedScrewBossIssue.CompareType (theIssue))
{
string aFeatureData = WriteFeatureDataToString(theShapeIdVector);
theManager.AddGroupData("Non Chamfered Screw Boss(es)", "(38, 38, 10)", aFeatureData, theCount);
}
else if (DFMMolding_SmallDistanceBetweenRibsIssue.CompareType (theIssue))
{
DFMMolding_SmallDistanceBetweenRibsIssue aSDBRIssue = DFMMolding_SmallDistanceBetweenRibsIssue.Cast(theIssue);
string 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 (DFMMolding_SmallWallThicknessIssue.CompareType (theIssue))
{
DFMMolding_SmallWallThicknessIssue aSWTIssue = DFMMolding_SmallWallThicknessIssue.Cast(theIssue);
string 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 (DFMMolding_SmallDistanceBetweenBossesIssue.CompareType (theIssue))
{
DFMMolding_SmallDistanceBetweenBossesIssue aSDBBIssue = DFMMolding_SmallDistanceBetweenBossesIssue.Cast(theIssue);
string 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);
}
}
private void AddSheetMetalIssue(FeatureGroupManager theManager, DFMBase_Issue theIssue,
uint theCount, ShapeIDVectorVectorType theShapeIdVector)
{
if (DFMSheetMetal_FlatPatternInterferenceIssue.CompareType(theIssue))
{
string aFeatureData = WriteFeatureDataToString(theShapeIdVector);
theManager.AddGroupData("Flat Pattern Interference(s)", "(115, 251, 253)", aFeatureData, theCount);
}
else if (DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue.CompareType(theIssue))
{
DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue aICFRNIssue = DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue.Cast(theIssue);
string 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 (DFMSheetMetal_IrregularDepthExtrudedHoleIssue.CompareType(theIssue))
{
DFMSheetMetal_IrregularDepthExtrudedHoleIssue aIDEHIssue = DFMSheetMetal_IrregularDepthExtrudedHoleIssue.Cast(theIssue);
string aFeatureData = WriteFeatureDataToString(
"Expected Min Extruded Height", "mm", aIDEHIssue.ExpectedMinExtrudedHeight(),
"Expected Man Extruded Height", "mm", aIDEHIssue.ExpectedMaxExtrudedHeight(),
"Actual Extruded Height", "mm", aIDEHIssue.ActualExtrudedHeight(),
theShapeIdVector);
theManager.AddGroupData("Irregular Depth Extruded Hole(s)", "(50, 120, 210)", aFeatureData, theCount);
}
else if (DFMSheetMetal_IrregularRadiusOpenHemBendIssue.CompareType(theIssue))
{
DFMSheetMetal_IrregularRadiusOpenHemBendIssue aIROHBIssue = DFMSheetMetal_IrregularRadiusOpenHemBendIssue.Cast(theIssue);
string 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 (DFMSheetMetal_InconsistentRadiusBendIssue.CompareType(theIssue))
{
DFMSheetMetal_InconsistentRadiusBendIssue aIRBIssue = DFMSheetMetal_InconsistentRadiusBendIssue.Cast(theIssue);
string 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 (DFMSheetMetal_IrregularSizeBendReliefIssue.CompareType(theIssue))
{
DFMSheetMetal_IrregularSizeBendReliefIssue aISBRIssue = DFMSheetMetal_IrregularSizeBendReliefIssue.Cast(theIssue);
SheetMetal_BendRelief anExpectedRelief = aISBRIssue.ExpectedMinBendRelief();
SheetMetal_BendRelief aFirstActualRelief = aISBRIssue.FirstActualRelief();
SheetMetal_BendRelief aSecondActualRelief = aISBRIssue.SecondActualRelief();
string aFeatureData;
if (!aFirstActualRelief.IsNull() && !aSecondActualRelief.IsNull())
{
aFeatureData = WriteFeatureDataToString(
"Expected Minimum Relief Size (LxW)", "mm", new Pair(anExpectedRelief.Length(), anExpectedRelief.Width()),
"First Actual Relief Size (LxW)", "mm", new Pair(aFirstActualRelief.Length(), aFirstActualRelief.Width()),
"Second Actual Relief Size (LxW)", "mm", new Pair(aSecondActualRelief.Length(), aSecondActualRelief.Width()),
theShapeIdVector);
}
else if (aFirstActualRelief.IsNull())
{
aFeatureData = WriteFeatureDataToString(
"Expected Minimum Relief Size (LxW)", "mm", new Pair(anExpectedRelief.Length(), anExpectedRelief.Width()),
"Actual Relief Size (LxW)", "mm", new Pair(aSecondActualRelief.Length(), aSecondActualRelief.Width()),
theShapeIdVector);
}
else
{
aFeatureData = WriteFeatureDataToString(
"Expected Minimum Relief Size (LxW)", "mm", new Pair(anExpectedRelief.Length(), anExpectedRelief.Width()),
"Actual Relief Size (LxW)", "mm", new Pair(aFirstActualRelief.Length(), aFirstActualRelief.Width()),
theShapeIdVector);
}
theManager.AddGroupData("Irregular Size Bend Relief(s)", "(22, 65, 124)", aFeatureData, theCount);
}
else if (DFMSheetMetal_IrregularSizeNotchIssue.CompareType(theIssue))
{
DFMSheetMetal_IrregularSizeNotchIssue aISNIssue = DFMSheetMetal_IrregularSizeNotchIssue.Cast(theIssue);
string aFeatureData = WriteFeatureDataToString(
"Expected Size (LxW)", "mm", new Pair(aISNIssue.ExpectedLength(), aISNIssue.ExpectedWidth()),
"Actual Size (LxW)", "mm", new Pair(aISNIssue.ActualLength(), aISNIssue.ActualWidth()),
theShapeIdVector);
theManager.AddGroupData("Irregular Size Notch(s)", "(255, 254, 145)", aFeatureData, theCount);
}
else if (DFMSheetMetal_IrregularSizeTabIssue.CompareType(theIssue))
{
DFMSheetMetal_IrregularSizeTabIssue aISTIssue = DFMSheetMetal_IrregularSizeTabIssue.Cast(theIssue);
string aFeatureData = WriteFeatureDataToString(
"Expected Size (LxW)", "mm", new Pair(aISTIssue.ExpectedLength(), aISTIssue.ExpectedWidth()),
"Actual Size (LxW)", "mm", new Pair(aISTIssue.ActualLength(), aISTIssue.ActualWidth()),
theShapeIdVector);
theManager.AddGroupData("Irregular Size Tab(s)", "(240, 155, 89)", aFeatureData, theCount);
}
else if (DFMSheetMetal_LargeDepthBeadIssue.CompareType(theIssue))
{
DFMSheetMetal_LargeDepthBeadIssue aLDBIssue = DFMSheetMetal_LargeDepthBeadIssue.Cast(theIssue);
string 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 (DFMSheetMetal_SmallDepthLouverIssue.CompareType(theIssue))
{
DFMSheetMetal_SmallDepthLouverIssue aSDLIssue = DFMSheetMetal_SmallDepthLouverIssue.Cast(theIssue);
string 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 (DFMSheetMetal_NonStandardSheetSizeIssue.CompareType(theIssue))
{
DFMSheetMetal_NonStandardSheetSizeIssue aNSSSIssue = DFMSheetMetal_NonStandardSheetSizeIssue.Cast(theIssue);
DFMSheetMetal_SheetSize aNesrestStandardSize = aNSSSIssue.NearestStandardSheetSize();
DFMSheetMetal_SheetSize anActualSize = aNSSSIssue.ActualSheetSize();
string aFeatureData = WriteFeatureDataToString(
"Nearest Standard Size (LxW)", "mm", new Pair(aNesrestStandardSize.Length(), aNesrestStandardSize.Width()),
"Actual Size (LxW)", "mm", new Pair(anActualSize.Length(), anActualSize.Width()),
theShapeIdVector);
theManager.AddGroupData("Non Standard Sheet Size(s)", "(0, 0, 0)", aFeatureData, theCount);
}
else if (DFMSheetMetal_NonStandardSheetThicknessIssue.CompareType(theIssue))
{
DFMSheetMetal_NonStandardSheetThicknessIssue aNSSTIssue = DFMSheetMetal_NonStandardSheetThicknessIssue.Cast(theIssue);
string 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 (DFMSheetMetal_SmallDiameterHoleIssue.CompareType(theIssue))
{
DFMSheetMetal_SmallDiameterHoleIssue aSDHIssue = DFMSheetMetal_SmallDiameterHoleIssue.Cast(theIssue);
string 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 (DFMSheetMetal_SmallLengthFlangeIssue.CompareType(theIssue))
{
DFMSheetMetal_SmallLengthFlangeIssue aSLFIssue = DFMSheetMetal_SmallLengthFlangeIssue.Cast(theIssue);
string 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 (DFMSheetMetal_SmallLengthHemBendFlangeIssue.CompareType(theIssue))
{
DFMSheetMetal_SmallLengthHemBendFlangeIssue aSLHMFIssue = DFMSheetMetal_SmallLengthHemBendFlangeIssue.Cast(theIssue);
string aFeatureData = WriteFeatureDataToString(
"Expected Minimum Length", "mm", aSLHMFIssue.ExpectedMinLength(),
"Actual Length", "mm", aSLHMFIssue.ActualLength(),
theShapeIdVector);
theManager.AddGroupData("Small Length Hem Bend Flange(s)", "(70, 139, 51)", aFeatureData, theCount);
}
else if (DFMSheetMetal_SmallRadiusBendIssue.CompareType(theIssue))
{
DFMSheetMetal_SmallRadiusBendIssue aSRBIssue = DFMSheetMetal_SmallRadiusBendIssue.Cast(theIssue);
string 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 (DFMSheetMetal_SmallDistanceBetweenFeaturesIssue.CompareType(theIssue))
{
DFMSheetMetal_SmallDistanceBetweenFeaturesIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenFeaturesIssue.Cast(theIssue);
string aFeatureData = WriteFeatureDataToString(
"Expected Minimum Distance", "mm", aSDIssue.ExpectedMinDistanceBetweenFeatures(),
"Actual Distance", "mm", aSDIssue.ActualDistanceBetweenFeatures(),
theShapeIdVector);
theManager.AddGroupData(SmallDistanceIssueName(aSDIssue), SmallDistanceIssueColor(aSDIssue), aFeatureData, theCount);
}
}
private ShapeIDVectorType GetShapesId(Shape theShape, ShapeType theType)
{
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
var aShapeIt = new ShapeIterator(theShape, theType);
foreach (var aShape in aShapeIt)
{
aShapeIdVector.Add(aShape.Id());
}
return aShapeIdVector;
}
private void AddShapesId(Shape theShape, ShapeType theType, ShapeIDVectorType theShapesIdVec)
{
var aShapeIt = new ShapeIterator(theShape, theType);
foreach (var aShape in aShapeIt)
{
theShapesIdVec.Add(aShape.Id());
}
}
private void SortFeatures(MTKBase_FeatureList theFeatures, FeatureMapType theMap)
{
for (uint i = 0; i < theFeatures.Size(); i++)
{
MTKBase_Feature aFeature = theFeatures.Feature(i);
KeyValuePair<uint, ShapeIDVectorVectorType> anElement;
if (theMap.ContainsKey(aFeature))
{
anElement = theMap[aFeature];
}
else
{
anElement = new KeyValuePair<uint, ShapeIDVectorVectorType>(0, new ShapeIDVectorVectorType());
}
var aValue = anElement.Value;
//features
if (MTKBase_ShapeFeature.CompareType(aFeature))
{
MTKBase_ShapeFeature aShapeFeature = MTKBase_ShapeFeature.Cast(aFeature);
ShapeType aShapeType = ShapeType.Face;
if (SheetMetal_Cutout.CompareType(aFeature)
|| (SheetMetal_Hole.CompareType(aFeature) && !SheetMetal_ComplexHole.CompareType(aFeature))
|| SheetMetal_Notch.CompareType(aFeature) || SheetMetal_Tab.CompareType(aFeature))
{
aShapeType = ShapeType.Edge;
}
ShapeIDVectorType aShapeIdVector = GetShapesId(aShapeFeature.Shape(), aShapeType);
aValue.Add(aShapeIdVector);
}
else if (Machining_SteppedHole.CompareType(aFeature))
{
var aCompositeIdVector = new ShapeIDVectorType();
Machining_SteppedHole aSteppedHole = Machining_SteppedHole.Cast(aFeature);
var aHoles = aSteppedHole.FeatureList();
for (uint j = 0; j < aHoles.Size(); j++)
{
var aHole = Machining_Hole.Cast(aHoles.Feature(j));
ShapeIDVectorType aShapeIdVector = GetShapesId(aHole.Shape(), ShapeType.Face);
aCompositeIdVector.AddRange(aShapeIdVector);
}
aValue.Add(aCompositeIdVector);
}
else if (MTKBase_CompositeFeature.CompareType(aFeature))
{
MTKBase_CompositeFeature aCompositeFeature = MTKBase_CompositeFeature.Cast(aFeature);
SortFeatures(aCompositeFeature.FeatureList(), theMap);
continue;
}
//dfm machining drilling
else if (DFMMachining_DrillingIssue.CompareType(aFeature))
{
DFMMachining_DrillingIssue anIssue = DFMMachining_DrillingIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(anIssue.Hole().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
//dfm machining milling
else if (DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue.CompareType(aFeature))
{
DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue aNSRMPFFIssue =
DFMMachining_NonStandardRadiusMilledPartFloorFilletIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aNSRMPFFIssue.FloorFillet(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_DeepPocketIssue.CompareType(aFeature))
{
DFMMachining_DeepPocketIssue aDCIssue = DFMMachining_DeepPocketIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aDCIssue.Pocket().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_HighBossIssue.CompareType(aFeature))
{
DFMMachining_HighBossIssue aHBIssue = DFMMachining_HighBossIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aHBIssue.Boss().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_LargeMilledPartIssue.CompareType(aFeature))
{
aValue.Add(new ShapeIDVectorType());
}
else if (DFMMachining_SmallRadiusMilledPartInternalCornerIssue.CompareType(aFeature))
{
DFMMachining_SmallRadiusMilledPartInternalCornerIssue aMSICRIssue =
DFMMachining_SmallRadiusMilledPartInternalCornerIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aMSICRIssue.Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_NonPerpendicularMilledPartShapeIssue.CompareType(aFeature))
{
DFMMachining_NonPerpendicularMilledPartShapeIssue aNPMPSIssue =
DFMMachining_NonPerpendicularMilledPartShapeIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aNPMPSIssue.Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_MilledPartExternalEdgeFilletIssue.CompareType(aFeature))
{
DFMMachining_MilledPartExternalEdgeFilletIssue aMPEEFIssue = DFMMachining_MilledPartExternalEdgeFilletIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aMPEEFIssue.Fillet(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue.CompareType(aFeature))
{
DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue aIRMPFFIssue =
DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aIRMPFFIssue.FloorFillet(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_NarrowRegionInPocketIssue.CompareType(aFeature))
{
DFMMachining_NarrowRegionInPocketIssue aNRIPIssue =
DFMMachining_NarrowRegionInPocketIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aNRIPIssue.InnerFeature(), ShapeType.Face, aShapeIdVector);
AddShapesId(aNRIPIssue.NarrowRegionSidewall(), ShapeType.Face, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_LargeDifferenceRegionsSizeInPocketIssue.CompareType(aFeature))
{
DFMMachining_LargeDifferenceRegionsSizeInPocketIssue aLDRSIPIssue =
DFMMachining_LargeDifferenceRegionsSizeInPocketIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aLDRSIPIssue.InnerFeature(), ShapeType.Face, aShapeIdVector);
AddShapesId(aLDRSIPIssue.MinRegionPocketSidewall(), ShapeType.Face, aShapeIdVector);
AddShapesId(aLDRSIPIssue.MaxRegionPocketSidewall(), ShapeType.Face, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_SmallWallThicknessIssue.CompareType(aFeature))
{
DFMMachining_SmallWallThicknessIssue aSWTIssue = DFMMachining_SmallWallThicknessIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aSWTIssue.Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
//dfm machining turning
else if (DFMMachining_SmallDepthBlindBoredHoleReliefIssue.CompareType(aFeature))
{
DFMMachining_SmallDepthBlindBoredHoleReliefIssue aBBHRIssue =
DFMMachining_SmallDepthBlindBoredHoleReliefIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aBBHRIssue.BlindBoredHole(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_DeepBoredHoleIssue.CompareType(aFeature))
{
DFMMachining_DeepBoredHoleIssue aISBHIssue = DFMMachining_DeepBoredHoleIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aISBHIssue.Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue.CompareType(aFeature))
{
DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue aODPRIssue =
DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aODPRIssue.Face(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_SmallRadiusTurnedPartInternalCornerIssue.CompareType(aFeature))
{
DFMMachining_SmallRadiusTurnedPartInternalCornerIssue aTSICRIssue =
DFMMachining_SmallRadiusTurnedPartInternalCornerIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aTSICRIssue.Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_SquareEndKeywayIssue.CompareType(aFeature))
{
DFMMachining_SquareEndKeywayIssue aSEKIssue = DFMMachining_SquareEndKeywayIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aSEKIssue.Keyway().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_NonSymmetricalAxialSlotIssue.CompareType(aFeature))
{
DFMMachining_NonSymmetricalAxialSlotIssue aNSASIssue =
DFMMachining_NonSymmetricalAxialSlotIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aNSASIssue.AxialSlot().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMachining_LargeTurnedPartIssue.CompareType(aFeature))
{
aValue.Add(new ShapeIDVectorType());
}
else if (DFMMachining_LongSlenderTurnedPartIssue.CompareType(aFeature))
{
aValue.Add(new ShapeIDVectorType());
}
//dfm molding
else if (DFMMolding_HighRibIssue.CompareType(aFeature))
{
DFMMolding_HighRibIssue aHRIssue = DFMMolding_HighRibIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aHRIssue.Rib().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_HighScrewBossIssue.CompareType(aFeature))
{
DFMMolding_HighScrewBossIssue aHSBIssue = DFMMolding_HighScrewBossIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aHSBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_IrregularCoreDepthScrewBossIssue.CompareType(aFeature))
{
DFMMolding_IrregularCoreDepthScrewBossIssue aICDSBIssue = DFMMolding_IrregularCoreDepthScrewBossIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aICDSBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_IrregularCoreDiameterScrewBossIssue.CompareType(aFeature))
{
DFMMolding_IrregularCoreDiameterScrewBossIssue aICDSBIssue = DFMMolding_IrregularCoreDiameterScrewBossIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aICDSBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_IrregularThicknessRibIssue.CompareType(aFeature))
{
DFMMolding_IrregularThicknessRibIssue aITRIssue = DFMMolding_IrregularThicknessRibIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aITRIssue.Rib().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_IrregularWallThicknessScrewBossIssue.CompareType(aFeature))
{
DFMMolding_IrregularWallThicknessScrewBossIssue aIWTSBIssue = DFMMolding_IrregularWallThicknessScrewBossIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aIWTSBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_SmallDraftAngleWallIssue.CompareType(aFeature))
{
var aSDAWIssue = DFMMolding_SmallDraftAngleWallIssue.Cast(aFeature);
var aShapeIdVector = GetShapesId(aSDAWIssue.Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_SmallDistanceBetweenRibsIssue.CompareType(aFeature))
{
var aSDBRIssue = DFMMolding_SmallDistanceBetweenRibsIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDBRIssue.FirstRib().Shape(), ShapeType.Face, aShapeIdVector);
AddShapesId(aSDBRIssue.SecondRib().Shape(), ShapeType.Face, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_SmallBaseRadiusRibIssue.CompareType(aFeature))
{
DFMMolding_SmallBaseRadiusRibIssue aSBRRIssue = DFMMolding_SmallBaseRadiusRibIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aSBRRIssue.Rib().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_SmallBaseRadiusScrewBossIssue.CompareType(aFeature))
{
DFMMolding_SmallBaseRadiusScrewBossIssue aSBRSBIssue = DFMMolding_SmallBaseRadiusScrewBossIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aSBRSBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_SmallDraftAngleRibIssue.CompareType(aFeature))
{
DFMMolding_SmallDraftAngleRibIssue aSMDARIssue = DFMMolding_SmallDraftAngleRibIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aSMDARIssue.Rib().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_SmallDraftAngleScrewBossIssue.CompareType(aFeature))
{
var aSDASBIssue = DFMMolding_SmallDraftAngleScrewBossIssue.Cast(aFeature);
var aShapeIdVector = GetShapesId(aSDASBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_SmallDistanceBetweenRibsIssue.CompareType(aFeature))
{
DFMMolding_SmallDistanceBetweenRibsIssue aSDBRIssue = DFMMolding_SmallDistanceBetweenRibsIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDBRIssue.FirstRib().Shape(), ShapeType.Face, aShapeIdVector);
AddShapesId(aSDBRIssue.SecondRib().Shape(), ShapeType.Face, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_SmallHoleBaseRadiusScrewBossIssue.CompareType(aFeature))
{
DFMMolding_SmallHoleBaseRadiusScrewBossIssue aSHBRSBIssue = DFMMolding_SmallHoleBaseRadiusScrewBossIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aSHBRSBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_NonChamferedScrewBossIssue.CompareType(aFeature))
{
DFMMolding_NonChamferedScrewBossIssue aWTCSBIssue = DFMMolding_NonChamferedScrewBossIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aWTCSBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_IrregularWallThicknessIssue.CompareType(aFeature))
{
DFMMolding_IrregularWallThicknessIssue aIWTIssue = DFMMolding_IrregularWallThicknessIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aIWTIssue.Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_LargeWallThicknessIssue.CompareType(aFeature))
{
DFMMolding_LargeWallThicknessIssue aLWTIssue = DFMMolding_LargeWallThicknessIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aLWTIssue.Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_SmallWallThicknessIssue.CompareType(aFeature))
{
DFMMolding_SmallWallThicknessIssue aSWTIssue = DFMMolding_SmallWallThicknessIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aSWTIssue.Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMMolding_SmallDistanceBetweenBossesIssue.CompareType(aFeature))
{
DFMMolding_SmallDistanceBetweenBossesIssue aSDBBIssue = DFMMolding_SmallDistanceBetweenBossesIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDBBIssue.FirstBoss().Shape(), ShapeType.Face, aShapeIdVector);
AddShapesId(aSDBBIssue.SecondBoss().Shape(), ShapeType.Face, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
//dfm sheet metal
else if (DFMSheetMetal_FlatPatternInterferenceIssue.CompareType(aFeature))
{
DFMSheetMetal_FlatPatternInterferenceIssue aFPIIssue = DFMSheetMetal_FlatPatternInterferenceIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType { aFPIIssue.FirstFace().Id(),
aFPIIssue.SecondFace().Id() };
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue.CompareType(aFeature))
{
DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue aICFRNIssue = DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aICFRNIssue.Notch().Shape(), ShapeType.Edge);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_IrregularRadiusOpenHemBendIssue.CompareType(aFeature))
{
DFMSheetMetal_IrregularRadiusOpenHemBendIssue aICFRNIssue = DFMSheetMetal_IrregularRadiusOpenHemBendIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aICFRNIssue.Bend().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_IrregularDepthExtrudedHoleIssue.CompareType(aFeature))
{
DFMSheetMetal_IrregularDepthExtrudedHoleIssue aIDEHIssue = DFMSheetMetal_IrregularDepthExtrudedHoleIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aIDEHIssue.Hole().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_InconsistentRadiusBendIssue.CompareType(aFeature))
{
DFMSheetMetal_InconsistentRadiusBendIssue aIRBIssue = DFMSheetMetal_InconsistentRadiusBendIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aIRBIssue.Bend().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_IrregularSizeBendReliefIssue.CompareType(aFeature))
{
DFMSheetMetal_IrregularSizeBendReliefIssue aISBRIssue = DFMSheetMetal_IrregularSizeBendReliefIssue.Cast(aFeature);
SheetMetal_BendRelief aFirstActualRelief = aISBRIssue.FirstActualRelief();
SheetMetal_BendRelief aSecondActualRelief = aISBRIssue.SecondActualRelief();
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aISBRIssue.Bend().Shape(), ShapeType.Face, aShapeIdVector);
if (!aFirstActualRelief.IsNull())
{
AddShapesId(aFirstActualRelief.Shape(), ShapeType.Edge, aShapeIdVector);
}
if (!aSecondActualRelief.IsNull())
{
AddShapesId(aSecondActualRelief.Shape(), ShapeType.Edge, aShapeIdVector);
}
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_IrregularSizeNotchIssue.CompareType(aFeature))
{
DFMSheetMetal_IrregularSizeNotchIssue aISNIssue = DFMSheetMetal_IrregularSizeNotchIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aISNIssue.Notch().Shape(), ShapeType.Edge);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_IrregularSizeTabIssue.CompareType(aFeature))
{
DFMSheetMetal_IrregularSizeTabIssue aISTIssue = DFMSheetMetal_IrregularSizeTabIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aISTIssue.Tab().Shape(), ShapeType.Edge);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_LargeDepthBeadIssue.CompareType(aFeature))
{
DFMSheetMetal_LargeDepthBeadIssue aLDBIssue = DFMSheetMetal_LargeDepthBeadIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aLDBIssue.Bead().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDepthLouverIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDepthLouverIssue aSDLIssue = DFMSheetMetal_SmallDepthLouverIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aSDLIssue.Louver().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_NonStandardSheetSizeIssue.CompareType(aFeature))
{
aValue.Add(new ShapeIDVectorType());
}
else if (DFMSheetMetal_NonStandardSheetThicknessIssue.CompareType(aFeature))
{
aValue.Add(new ShapeIDVectorType());
}
else if (DFMSheetMetal_SmallDiameterHoleIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDiameterHoleIssue aSDHIssue = DFMSheetMetal_SmallDiameterHoleIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aSDHIssue.Hole().Shape(), ShapeType.Edge);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallLengthFlangeIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallLengthFlangeIssue aSLFIssue = DFMSheetMetal_SmallLengthFlangeIssue.Cast(aFeature);
MTKBase_FeatureList aFlange = aSLFIssue.Flange().FeatureList();
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
for (uint j = 0; j < aFlange.Size(); j++)
{
MTKBase_Feature aFlangeFace = aFlange.Feature(j);
if (MTKBase_ShapeFeature.CompareType(aFlangeFace))
{
MTKBase_ShapeFeature aShapeFeature = MTKBase_ShapeFeature.Cast(aFlangeFace);
AddShapesId(aShapeFeature.Shape(), ShapeType.Face, aShapeIdVector);
}
}
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallLengthHemBendFlangeIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallLengthHemBendFlangeIssue aSLHBFIssue = DFMSheetMetal_SmallLengthHemBendFlangeIssue.Cast(aFeature);
MTKBase_FeatureList aFlange = aSLHBFIssue.Flange().FeatureList();
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
for (uint j = 0; j < aFlange.Size(); j++)
{
MTKBase_Feature aFlangeFace = aFlange.Feature(j);
if (MTKBase_ShapeFeature.CompareType(aFlangeFace))
{
MTKBase_ShapeFeature aShapeFeature = MTKBase_ShapeFeature.Cast(aFlangeFace);
AddShapesId(aShapeFeature.Shape(), ShapeType.Face, aShapeIdVector);
}
}
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallRadiusBendIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallRadiusBendIssue aSRBIssue = DFMSheetMetal_SmallRadiusBendIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = GetShapesId(aSRBIssue.Bend().Shape(), ShapeType.Face);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDIssue.Bend().Shape(), ShapeType.Face, aShapeIdVector);
AddShapesId(aSDIssue.Louver().Shape(), ShapeType.Face, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndBendIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDIssue.Hole().Shape(), ShapeType.Face, aShapeIdVector);
AddShapesId(aSDIssue.Bend().Shape(), ShapeType.Face, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndEdgeIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndEdgeIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenExtrudedHoleAndEdgeIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDIssue.Hole().Shape(), ShapeType.Face, aShapeIdVector);
aShapeIdVector.Add(aSDIssue.Edge().Id());
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenExtrudedHolesIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDIssue.FirstHole().Shape(), ShapeType.Face, aShapeIdVector);
AddShapesId(aSDIssue.SecondHole().Shape(), ShapeType.Face, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenHoleAndBendIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDIssue.Hole().Shape(), ShapeType.Edge, aShapeIdVector);
AddShapesId(aSDIssue.Bend().Shape(), ShapeType.Face, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenHoleAndCutoutIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDIssue.Hole().Shape(), ShapeType.Edge, aShapeIdVector);
AddShapesId(aSDIssue.Cutout().Shape(), ShapeType.Edge, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenHoleAndEdgeIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDIssue.Hole().Shape(), ShapeType.Edge, aShapeIdVector);
aShapeIdVector.Add(aSDIssue.Edge().Id());
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenHoleAndLouverIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDIssue.Hole().Shape(), ShapeType.Edge, aShapeIdVector);
AddShapesId(aSDIssue.Louver().Shape(), ShapeType.Face, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenHoleAndNotchIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDIssue.Hole().Shape(), ShapeType.Edge, aShapeIdVector);
AddShapesId(aSDIssue.Notch().Shape(), ShapeType.Edge, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDistanceBetweenHolesIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDistanceBetweenHolesIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenHolesIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDIssue.FirstHole().Shape(), ShapeType.Edge, aShapeIdVector);
AddShapesId(aSDIssue.SecondHole().Shape(), ShapeType.Edge, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenNotchAndBendIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDIssue.Notch().Shape(), ShapeType.Edge, aShapeIdVector);
AddShapesId(aSDIssue.Bend().Shape(), ShapeType.Face, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDistanceBetweenNotchesIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDistanceBetweenNotchesIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenNotchesIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDIssue.FirstNotch().Shape(), ShapeType.Edge, aShapeIdVector);
AddShapesId(aSDIssue.SecondNotch().Shape(), ShapeType.Edge, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDistanceBetweenTabsIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDistanceBetweenTabsIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenTabsIssue.Cast(aFeature);
ShapeIDVectorType aShapeIdVector = new ShapeIDVectorType();
AddShapesId(aSDIssue.FirstTab().Shape(), ShapeType.Edge, aShapeIdVector);
AddShapesId(aSDIssue.SecondTab().Shape(), ShapeType.Edge, aShapeIdVector);
aValue.Add(aShapeIdVector);
}
anElement = new KeyValuePair<uint, ShapeIDVectorVectorType>(anElement.Key + 1, aValue);
theMap[aFeature] = anElement;
}
}
private bool WriteFeatures(JSONWriter theWriter, string theGroupName, string theSubgroupName,
MTKBase_FeatureList theFeatures, string theMessageForEmptyList)
{
theWriter.OpenSection(theSubgroupName);
theWriter.WriteData("name", theGroupName);
if (theFeatures.IsEmpty())
{
theWriter.WriteData("message", theMessageForEmptyList);
}
else
{
FeatureMapType aSortedFeatures = new FeatureMapType(new FeatureComparer());
SortFeatures(theFeatures, aSortedFeatures);
FeatureGroupManager aFGManager = new FeatureGroupManager();
foreach (var i in aSortedFeatures) {
MTKBase_Feature aFeature = i.Key;
uint aCount = i.Value.Key;
ShapeIDVectorVectorType aShapeIDVec = i.Value.Value;
if (MTKBase_ShapeFeature.CompareType(aFeature) || Machining_SteppedHole.CompareType(aFeature))
{
AddShapeFeature(aFGManager, MTKBase_ShapeFeature.Cast(aFeature), aCount, aShapeIDVec);
}
else if (DFMMachining_DrillingIssue.CompareType(aFeature))
{
AddDrillingIssue(aFGManager, DFMMachining_DrillingIssue.Cast(aFeature), aCount, aShapeIDVec);
}
else if (DFMMachining_MillingIssue.CompareType(aFeature))
{
AddMillingIssue(aFGManager, DFMMachining_MillingIssue.Cast(aFeature), aCount, aShapeIDVec);
}
else if (DFMSheetMetal_BendIssue.CompareType(aFeature)
|| DFMSheetMetal_FlatPatternInterferenceIssue.CompareType(aFeature)
|| DFMSheetMetal_HoleIssue.CompareType(aFeature)
|| DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue.CompareType(aFeature)
|| DFMSheetMetal_IrregularDepthExtrudedHoleIssue.CompareType(aFeature)
|| DFMSheetMetal_IrregularSizeNotchIssue.CompareType(aFeature)
|| DFMSheetMetal_IrregularSizeTabIssue.CompareType(aFeature)
|| DFMSheetMetal_LargeDepthBeadIssue.CompareType(aFeature)
|| DFMSheetMetal_SmallDepthLouverIssue.CompareType(aFeature)
|| DFMSheetMetal_NonStandardSheetSizeIssue.CompareType(aFeature)
|| DFMSheetMetal_NonStandardSheetThicknessIssue.CompareType(aFeature)
|| DFMSheetMetal_SmallDistanceBetweenFeaturesIssue.CompareType(aFeature))
{
AddSheetMetalIssue(aFGManager, DFMBase_Issue.Cast(aFeature), aCount, aShapeIDVec);
}
else if (DFMMolding_HighRibIssue.CompareType(aFeature)
|| DFMMolding_HighScrewBossIssue.CompareType(aFeature)
|| DFMMolding_IrregularCoreDepthScrewBossIssue.CompareType(aFeature)
|| DFMMolding_IrregularCoreDiameterScrewBossIssue.CompareType(aFeature)
|| DFMMolding_IrregularThicknessRibIssue.CompareType(aFeature)
|| DFMMolding_IrregularWallThicknessScrewBossIssue.CompareType(aFeature)
|| DFMMolding_SmallBaseRadiusRibIssue.CompareType(aFeature)
|| DFMMolding_SmallBaseRadiusScrewBossIssue.CompareType(aFeature)
|| DFMMolding_IrregularWallThicknessIssue.CompareType(aFeature)
|| DFMMolding_LargeWallThicknessIssue.CompareType(aFeature)
|| DFMMolding_SmallDraftAngleRibIssue.CompareType(aFeature)
|| DFMMolding_SmallDraftAngleScrewBossIssue.CompareType(aFeature)
|| DFMMolding_SmallHoleBaseRadiusScrewBossIssue.CompareType(aFeature)
|| DFMMolding_SmallDraftAngleWallIssue.CompareType(aFeature)
|| DFMMolding_NonChamferedScrewBossIssue.CompareType(aFeature)
|| DFMMolding_SmallWallThicknessIssue.CompareType(aFeature)
|| DFMMolding_SmallDistanceBetweenBossesIssue.CompareType(aFeature)
|| DFMMolding_SmallDistanceBetweenRibsIssue.CompareType(aFeature))
{
AddMoldingIssue(aFGManager, DFMBase_Issue.Cast(aFeature), aCount, aShapeIDVec);
}
else if (DFMBase_Issue.CompareType(aFeature))
{
AddTurningIssue(aFGManager, DFMBase_Issue.Cast(aFeature), aCount, aShapeIDVec);
}
}
theWriter.WriteData("totalFeatureCount", aFGManager.TotalFeatureCount());
theWriter.OpenArraySection("featureGroups");
aFGManager.Write(theWriter);
theWriter.CloseArraySection();
}
theWriter.CloseSection();
return true;
}
private string MachiningProcessName(Machining_OperationType theOperation)
{
switch (theOperation)
{
case Machining_OperationType.Machining_OT_Milling: return "CNC Machining Milling";
case Machining_OperationType.Machining_OT_LatheMilling: return "CNC Machining Lathe+Milling";
default:
break;
}
return "CNC Machining";
}
private bool HasShapes(cadex.Collections.BodyList theBodies, ShapeType theType)
{
for (int i = 0, n = theBodies.Count; i < n; ++i)
{
Body aBody = theBodies[i];
var aShapeIt = new ShapeIterator(aBody, theType);
if (aShapeIt.HasNext())
{
return true;
}
}
return false;
}
private void WriteThicknessNode(JSONWriter theWriter, string theParamName, double theParamValue,
PointPairType thePoints, string theNodeName)
{
cadex.Geom.Point aFirstPoint = thePoints.Key;
cadex.Geom.Point aSecondPoint = thePoints.Value;
theWriter.OpenSection(theNodeName);
theWriter.WriteData("name", theParamName);
theWriter.WriteData("units", "mm");
theWriter.WriteData("value", theParamValue);
theWriter.WriteData("firstPoint", new Point (aFirstPoint.X(), aFirstPoint.Y(), aFirstPoint.Z()));
theWriter.WriteData("secondPoint", new Point(aSecondPoint.X(), aSecondPoint.Y(), aSecondPoint.Z()));
theWriter.CloseSection();
}
private void WriteUnfoldedPartFeatures(JSONWriter theWriter, MTKConverter_UnfoldedPartData theData)
{
theWriter.OpenSection("featureRecognitionUnfolded");
theWriter.WriteData("name", "Feature Recognition");
if (theData.IsInit())
{
StringWriter aStream = new StringWriter();
JSONWriter aWriter = new JSONWriter(aStream, 4);
aWriter.WriteData("parametersCount", 3);
aWriter.OpenArraySection("parameters");
SheetMetal_FlatPattern 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.ToString());
}
else
{
theWriter.WriteData("message", "Unfolded part wasn't generated.");
}
theWriter.CloseSection();
}
private void WritePartProcessData(JSONWriter theWriter, MTKConverter_ProcessData theProcessData)
{
bool aRes = false;
theWriter.WriteData("partId", theProcessData.myPart.Uuid());
string anErrorMsg = "An error occurred while processing the part.";
if (theProcessData is MTKConverter_MachiningData)
{
MTKConverter_MachiningData aMD = (MTKConverter_MachiningData)theProcessData;
theWriter.WriteData("process", MachiningProcessName(aMD.myOperation));
cadex.Collections.BodyList 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 (!HasShapes(aBodies, ShapeType.Solid))
{
anErrorMsg = "The part can't be analyzed due to lack of: BRep representation or solids in BRep representation.";
}
}
else if (theProcessData is MTKConverter_MoldingData)
{
MTKConverter_MoldingData aMoldingData = (MTKConverter_MoldingData)theProcessData;
theWriter.WriteData("process", "Molding Analysis");
cadex.Collections.BodyList aBodies = aMoldingData.myPart.Bodies();
if (!aMoldingData.myFeatureList.IsEmpty())
{
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 (!HasShapes(aBodies, ShapeType.Solid))
{
anErrorMsg = "The part can't be analyzed due to lack of: " +
"BRep representation, solids in BRep representation or Poly representations.";
}
}
else if (theProcessData is MTKConverter_SheetMetalData)
{
MTKConverter_SheetMetalData aSMD = (MTKConverter_SheetMetalData)theProcessData;
theWriter.WriteData("process", "Sheet Metal");
cadex.Collections.BodyList 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.");
MTKConverter_UnfoldedPartData 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 (!HasShapes(aBodies, ShapeType.Solid) && !HasShapes(aBodies, 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 if (theProcessData is MTKConverter_WallThicknessData)
{
MTKConverter_WallThicknessData aWTD = (MTKConverter_WallThicknessData)theProcessData;
theWriter.WriteData("process", "Wall Thickness Analysis");
cadex.Collections.BodyList 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 (!HasShapes(aBodies, ShapeType.Solid))
{
anErrorMsg = "The part can't be analyzed due to lack of: " +
"BRep representation, solids in BRep representation.";
}
}
else
{
anErrorMsg = "Unrecognized process";
}
if (!aRes)
{
theWriter.WriteData("error", anErrorMsg);
}
}
}
}
Contains classes, types, enums, and functions related to geometric entities.

MTKConverter_Application.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex;
using cadex.View;
using System;
using System.Collections.Generic;
using System.IO;
namespace mtkconverter
{
enum MTKConverter_ReturnCode
{
// General codes
MTKConverter_RC_OK = 0,
MTKConverter_RC_UnknownError = 1,
MTKConverter_RC_GeneralException = 2,
MTKConverter_RC_NoValidLicense = 3,
MTKConverter_RC_InvalidArgumentsNumber = 4,
MTKConverter_RC_InvalidArgument = 5,
// Import errors
MTKConverter_RC_UnsupportedVersion = 100,
MTKConverter_RC_UnexpectedFormat = 101,
MTKConverter_RC_UnsupportedFileVariant = 102,
MTKConverter_RC_ImportError = 103,
// Process errors
MTKConverter_RC_ProcessError = 200,
// Export errors
MTKConverter_RC_ExportError = 300,
}
enum MTKConverter_ProcessType
{
MTKConverter_PT_Undefined = -1,
MTKConverter_PT_WallThickness = 0,
MTKConverter_PT_MachiningMilling,
MTKConverter_PT_MachiningTurning,
MTKConverter_PT_Molding,
MTKConverter_PT_SheetMetal
}
//parse and execute command line
enum Mode { NeutralMode, ImportMode, ProcessMode, ExportMode }
class MTKConverter_Application
{
public MTKConverter_Application()
{
}
public MTKConverter_ReturnCode Run (string[] args)
{
if (args.Length == 0 ||
(args[0] == "-?") || (args[0] == "/?") ||
(args[0] == "-h") || (args[0] == "--help"))
{
PrintUsage();
return MTKConverter_ReturnCode.MTKConverter_RC_OK;
}
if (args.Length < 6)
{
Console.WriteLine("Invalid number of arguments. Please use \"-h\" or \"--help\" for usage information.");
return MTKConverter_ReturnCode.MTKConverter_RC_InvalidArgumentsNumber;
}
Model aModel = new Model();
Model aProcessModel = new Model();
Mode aMode = Mode.NeutralMode;
MTKConverter_Report aReport = new MTKConverter_Report();
MTKConverter_ReturnCode aRes = MTKConverter_ReturnCode.MTKConverter_RC_OK;
bool aToGenerateScreenshot = true;
for (int i = 0; (i < args.Length) && (aRes == MTKConverter_ReturnCode.MTKConverter_RC_OK); ++i) {
string anArgument = args[i];
if (anArgument == "--no-screenshot") {
aToGenerateScreenshot = false;
} else if (anArgument == "-i") {
aMode = Mode.ImportMode;
} else if (anArgument == "-p") {
aMode = Mode.ProcessMode;
} else if (anArgument == "-e") {
aMode = Mode.ExportMode;
} else {
try
{
if (aMode == Mode.ImportMode)
{
aRes = Import(anArgument, aModel);
}
else if (aMode == Mode.ProcessMode)
{
aRes = Process(anArgument, aModel, aReport, aProcessModel);
}
else if (aMode == Mode.ExportMode)
{
aRes = Export(anArgument, aModel, aToGenerateScreenshot, aReport, aProcessModel);
}
else
{
Console.WriteLine($"ERROR!: Invalid argument {anArgument}. Exiting");
Console.WriteLine($"Type {System.Reflection.Assembly.GetExecutingAssembly().Location} -h for help.");
return MTKConverter_ReturnCode.MTKConverter_RC_InvalidArgument;
}
Console.WriteLine("Done.");
}
catch(Exception anE)
{
Console.WriteLine($"Failed.\nERROR: {anE.Message}");
return MTKConverter_ReturnCode.MTKConverter_RC_GeneralException;
}
}
}
return aRes;
}
public void PrintUsage()
{
Console.WriteLine("Usage:");
Console.WriteLine("MTKConverter -i <import_file> -p <process> --no-screenshot -e <export_folder>\n");
Console.WriteLine("Arguments:");
Console.WriteLine(" <import_file> - import file name");
Console.WriteLine(" <process> - manufacturing process or algorithm name");
Console.WriteLine(" <export_folder> - export folder name");
Console.WriteLine(" --no-screenshot - disable screenshot generation (optional)");
Console.WriteLine("Example:" );
Console.WriteLine("MTKConverter -i C:\\models\\test.step -p machining_milling -e C:\\models\\test");
Console.WriteLine("\nRecognized processes:");
Console.WriteLine(" wall_thickness :\t Wall Thickness analysis");
Console.WriteLine(" machining_milling:\t CNC Machining Milling feature recognition and dfm analysis");
Console.WriteLine(" machining_turning:\t CNC Machining Lathe+Milling feature recognition and dfm analysis");
Console.WriteLine(" molding :\t Molding feature recognition and dfm analysis");
Console.WriteLine(" sheet_metal :\t Sheet Metal feature recognition, unfolding and dfm analysis");
}
private MTKConverter_ProcessType ProcessType(string theProcessName)
{
var aProcessDictionary = new Dictionary<string, MTKConverter_ProcessType>()
{
{ "wall_thickness", MTKConverter_ProcessType.MTKConverter_PT_WallThickness},
{ "machining_milling", MTKConverter_ProcessType.MTKConverter_PT_MachiningMilling},
{ "machining_turning", MTKConverter_ProcessType.MTKConverter_PT_MachiningTurning},
{ "molding", MTKConverter_ProcessType.MTKConverter_PT_Molding},
{ "sheet_metal", MTKConverter_ProcessType.MTKConverter_PT_SheetMetal}
};
MTKConverter_ProcessType aProcess = MTKConverter_ProcessType.MTKConverter_PT_Undefined;
bool aRes = aProcessDictionary.TryGetValue(theProcessName, out aProcess);
if (aRes)
{
return aProcess;
}
return MTKConverter_ProcessType.MTKConverter_PT_Undefined;
}
private MTKConverter_ReturnCode Import(string theFilePath, Model theModel)
{
UTF16String aFilePath = new UTF16String(theFilePath);
Console.Write($"Importing {theFilePath}...");
ModelReader aReader = new ModelReader();
if (!aReader.Read (aFilePath, theModel)) {
Console.WriteLine($"\nERROR: Failed to import {theFilePath}. Exiting");
return MTKConverter_ReturnCode.MTKConverter_RC_ImportError;
}
return MTKConverter_ReturnCode.MTKConverter_RC_OK;
}
private bool CreateOriginModelThumbnail(UTF16String theFilePath, Model theModel)
{
ImageWriter aWriter = new ImageWriter();
ImageWriterParameters aParameters = aWriter.Parameters();
aParameters.SetImageHeight (800);
aParameters.SetImageWidth (600);
aParameters.SetViewCameraProjection (CameraProjectionType.Perspective);
aParameters.SetViewCameraPosition (CameraPositionType.Default);
aParameters.SetViewIsFitAll (true);
aParameters.SetViewAntialiasing (AntialiasingMode.High);
aParameters.SetViewBackground (new ColorBackgroundStyle (new Color(255, 255, 255)));
aWriter.SetParameters (aParameters);
bool aRes = aWriter.WriteFile (theModel, theFilePath);
return aRes;
}
private void ApplyProcessorToModel(Model theModel, MTKConverter_Report theReport, MTKConverter_PartProcessor theProcessor)
{
ModelElementUniqueVisitor aVisitor = new ModelElementUniqueVisitor(theProcessor);
theModel.Accept(aVisitor);
foreach (MTKConverter_ProcessData i in theProcessor.myData)
{
theReport.AddData(i);
}
}
private MTKConverter_ReturnCode Process(string theProcess, Model theModel,
MTKConverter_Report theReport, Model theProcessModel)
{
Console.Write($"Processing {theProcess}...");
theModel.AssignUuids();
MTKConverter_ProcessType aProcessType = ProcessType(theProcess);
switch (aProcessType)
{
case MTKConverter_ProcessType.MTKConverter_PT_WallThickness:
{
MTKConverter_WallThicknessProcessor aProcessor = new MTKConverter_WallThicknessProcessor(800);
ApplyProcessorToModel(theModel, theReport, aProcessor);
break;
}
case MTKConverter_ProcessType.MTKConverter_PT_MachiningMilling:
{
MTKConverter_MachiningProcessor aProcessor = new MTKConverter_MachiningProcessor(Machining_OperationType.Machining_OT_Milling);
ApplyProcessorToModel(theModel, theReport, aProcessor);
break;
}
case MTKConverter_ProcessType.MTKConverter_PT_MachiningTurning:
{
MTKConverter_MachiningProcessor aProcessor = new MTKConverter_MachiningProcessor(Machining_OperationType.Machining_OT_LatheMilling);
ApplyProcessorToModel(theModel, theReport, aProcessor);
break;
}
case MTKConverter_ProcessType.MTKConverter_PT_Molding:
{
UTF16String aProcessModelName = new UTF16String(theModel.Name() + "_extra");
theProcessModel.SetName(aProcessModelName);
MTKConverter_MoldingProcessor aProcessor = new MTKConverter_MoldingProcessor (theProcessModel);
ApplyProcessorToModel(theModel, theReport, aProcessor);
break;
}
case MTKConverter_ProcessType.MTKConverter_PT_SheetMetal:
{
UTF16String aProcessModelName = new UTF16String(theModel.Name() + "_unfolded");
theProcessModel.SetName(aProcessModelName);
MTKConverter_SheetMetalProcessor aProcessor = new MTKConverter_SheetMetalProcessor(theProcessModel);
ApplyProcessorToModel(theModel, theReport, aProcessor);
break;
}
case MTKConverter_ProcessType.MTKConverter_PT_Undefined:
default: return MTKConverter_ReturnCode.MTKConverter_RC_InvalidArgument;
}
return MTKConverter_ReturnCode.MTKConverter_RC_OK;
}
private MTKConverter_ReturnCode Export(string theFolderPath, Model theModel,
bool theToGenerateScreenshot, MTKConverter_Report theReport, Model theProcessModel)
{
Console.Write($"Exporting {theFolderPath}...");
UTF16String aModelPath = new UTF16String(theFolderPath + "/" + theModel.Name() + ".mtkweb" + "/scenegraph.mtkweb");
if (!theModel.Save(aModelPath, Model.FileFormatType.MTKWEB))
{
Console.WriteLine($"\nERROR: Failed to export {aModelPath}. Exiting");
return MTKConverter_ReturnCode.MTKConverter_RC_ExportError;
}
UTF16String aThumbnailPath = new UTF16String(theFolderPath + "/thumbnail.png");
if (theToGenerateScreenshot && !CreateOriginModelThumbnail(aThumbnailPath, theModel))
{
Console.WriteLine($"\nERROR: Failed to create thumbnail {aThumbnailPath}. Exiting");
return MTKConverter_ReturnCode.MTKConverter_RC_ExportError;
}
if (!theProcessModel.IsEmpty())
{
UTF16String aProcessModelPath = new UTF16String(theFolderPath + "/" + theProcessModel.Name() + ".mtkweb" + "/scenegraph.mtkweb");
if (!theProcessModel.Save(aProcessModelPath, Model.FileFormatType.MTKWEB))
{
Console.WriteLine($"\nERROR: Failed to export {aProcessModelPath}. Exiting");
return MTKConverter_ReturnCode.MTKConverter_RC_ExportError;
}
}
Directory.CreateDirectory (theFolderPath);
UTF16String aJsonPath = new UTF16String(theFolderPath + "/process_data.json");
if (!theReport.WriteToJSON(aJsonPath))
{
Console.WriteLine($"\nERROR: Failed to create JSON file {aJsonPath}. Exiting");
return MTKConverter_ReturnCode.MTKConverter_RC_ExportError;
}
return MTKConverter_ReturnCode.MTKConverter_RC_OK;
}
}
}
Contains classes, types, enums, and functions related to image generation.

Program.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex;
using System;
namespace mtkconverter
{
class Program
{
static int Main(string[] args)
{
string aKey = MTKLicenseKey.Value();
// Activate the license (aKey should be defined in mtk_license.cs)
if (!LicenseManager.Activate(aKey))
{
Console.WriteLine("Failed to activate Manufacturing Toolkit license.");
return 1;
}
MTKConverter_Application anApp = new MTKConverter_Application();
return (int)anApp.Run(args);
}
}
}