Hide menu
Loading...
Searching...
No Matches
MTKConverter/MTKConverter.java

Refer to the MTK Converter Example.

MTKConverter_PartProcessor.java

// ****************************************************************************
// $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.
//
// ****************************************************************************
import cadex.*;
import cadex.ModelData.*;
import java.util.ArrayList;
class MTKConverter_ProcessData
{
protected MTKConverter_ProcessData(Part thePart)
{
myPart = thePart;
}
public Part myPart;
}
abstract class MTKConverter_PartProcessor extends ModelElementVoidVisitor
{
protected MTKConverter_PartProcessor()
{
myData = new ArrayList<MTKConverter_ProcessData>();
}
public void Apply(Part thePart)
{
UTF16String aPartName = thePart.Name().IsEmpty() ? new UTF16String("noname") : thePart.Name();
cadex.Collections.BodyList aBodyList = thePart.Bodies();
for (int i = 0; i < aBodyList.size(); ++i)
{
Body aBody = aBodyList.get(i);
ShapeIterator aShapeIt = new ShapeIterator(aBody);
while (aShapeIt.HasNext())
{
Shape aShape = aShapeIt.Next();
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);
public ArrayList<MTKConverter_ProcessData> myData;
}
class MTKConverter_VoidPartProcessor extends MTKConverter_PartProcessor
{
public MTKConverter_VoidPartProcessor() { super(); }
public void ProcessSolid(Part thePart, Solid theSolid) { }
public void ProcessShell(Part thePart, Shell theShell) { }
public void PostPartProcess(Part thePart) { }
}
Defines classes, types, enums, and functions related to topological entities and scene graph elements...
ShapeType
Defines shape type.
Definition ShapeType.hxx:27
Defines classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30

MTKConverter_MachiningProcessor.java

// ****************************************************************************
// $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.
//
// ****************************************************************************
import cadex.*;
import cadex.ModelData.*;
class MTKConverter_MachiningData extends MTKConverter_ProcessData
{
public MTKConverter_MachiningData(Part thePart)
{
super (thePart);
myFeatureList = new MTKBase_FeatureList();
myIssueList = new MTKBase_FeatureList();
}
public MTKBase_FeatureList myFeatureList;
public MTKBase_FeatureList myIssueList;
public Machining_OperationType myOperation;
}
class MTKConverter_MachiningProcessor extends MTKConverter_VoidPartProcessor
{
public MTKConverter_MachiningProcessor(Machining_OperationType theOperation)
{
super();
myOperation = theOperation;
}
public 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 (long 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 (long i = 0; i < aTurningIssueList.Size(); ++i)
{
MTKBase_Feature anIssue = aTurningIssueList.Feature(i);
aMachiningData.myIssueList.Append(anIssue);
}
}
}
private Machining_OperationType myOperation;
}
Machining_OperationType
Defines an operation type in machining.
Definition Machining_OperationType.hxx:28

MTKConverter_SheetMetalProcessor.java

// ****************************************************************************
// $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.
//
// ****************************************************************************
import cadex.*;
import cadex.ModelData.*;
import java.util.ArrayList;
import java.util.Collections;
class MTKConverter_UnfoldedPartData
{
public MTKConverter_UnfoldedPartData()
{
myIssueList = new MTKBase_FeatureList();
}
public boolean IsInit() { return myFlatPattern != null; }
public SheetMetal_FlatPattern myFlatPattern;
public MTKBase_FeatureList myIssueList;
}
class MTKConverter_SheetMetalData extends MTKConverter_ProcessData
{
public MTKConverter_SheetMetalData(Part thePart)
{
super(thePart);
myFeatureList = new MTKBase_FeatureList();
myIssueList = new MTKBase_FeatureList();
myUnfoldedPartData = new MTKConverter_UnfoldedPartData();
}
public boolean myIsSheetMetalPart = true;
public MTKBase_FeatureList myFeatureList;
public MTKBase_FeatureList myIssueList;
public MTKConverter_UnfoldedPartData myUnfoldedPartData;
}
class MTKConverter_SheetMetalProcessor extends MTKConverter_VoidPartProcessor
{
public MTKConverter_SheetMetalProcessor(Model theUnfoldedModel)
{
super();
myAnalyzer = new SheetMetal_Analyzer();
myAnalyzer.AddTool(new SheetMetal_FeatureRecognizer());
myAnalyzer.AddTool(new SheetMetal_Unfolder());
myUnfoldedModel = theUnfoldedModel;
myCurrentUnfoldedBody = new SheetBody();
}
public void ProcessSolid(Part thePart, Solid theSolid)
{
SheetMetal_Data anSMData = myAnalyzer.Perform(theSolid);
UpdateProcessData(anSMData, thePart);
}
public void ProcessShell(Part thePart, Shell theShell)
{
SheetMetal_Data anSMData = myAnalyzer.Perform(theShell);
UpdateProcessData(anSMData, thePart);
}
public void PostPartProcess(Part thePart)
{
if (myCurrentUnfoldedBody.Shapes().isEmpty())
{
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 (long 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);
}
}
}
private SheetMetal_Analyzer myAnalyzer;
private Model myUnfoldedModel;
private SheetBody myCurrentUnfoldedBody;
}

MTKConverter_Report.java

// ****************************************************************************
// $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.
//
// ****************************************************************************
import cadex.*;
import cadex.ModelData.*;
import cadex.Geom.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.Consumer;
class MTKConverter_Pair
{
public MTKConverter_Pair(double theFirst, double theSecond)
{
this.First = theFirst;
this.Second = theSecond;
}
public String toString()
{
return FormattedString(First) + " x " + FormattedString(Second);
}
private String FormattedString(double theValue)
{
DecimalFormatSymbols aDFS = new DecimalFormatSymbols();
aDFS.setDecimalSeparator('.');
DecimalFormat aDF = new DecimalFormat("0.00", aDFS);
return aDF.format(theValue);
}
public double First;
public double Second;
}
class MTKConverter_Dimension
{
public MTKConverter_Dimension(double theL, double theW, double theD)
{
this.L = theL;
this.W = theW;
this.D = theD;
}
public String toString()
{
return FormattedString(L) + " x " + FormattedString(W) + " x " + FormattedString(D);
}
private String FormattedString(double theValue)
{
DecimalFormatSymbols aDFS = new DecimalFormatSymbols();
aDFS.setDecimalSeparator('.');
DecimalFormat aDF = new DecimalFormat("0.00", aDFS);
return aDF.format(theValue);
}
public double L;
public double W;
public double D;
}
class MTKConverter_Direction
{
public MTKConverter_Direction(double theX, double theY, double theZ)
{
this.X = theX;
this.Y = theY;
this.Z = theZ;
}
public String toString()
{
return "(" + FormattedString(X) + ", " + FormattedString(Y) + ", " + FormattedString(Z) + ")";
}
private String FormattedString(double theValue)
{
DecimalFormatSymbols aDFS = new DecimalFormatSymbols();
aDFS.setDecimalSeparator('.');
DecimalFormat aDF = new DecimalFormat("0.00", aDFS);
return aDF.format(theValue);
}
public double X;
public double Y;
public double Z;
}
class MTKConverter_Point
{
public MTKConverter_Point(double theX, double theY, double theZ)
{
this.X = theX;
this.Y = theY;
this.Z = theZ;
}
public String toString()
{
return "(" + FormattedString(X) + ", " + FormattedString(Y) + ", " + FormattedString(Z) + ")";
}
private String FormattedString(double theValue)
{
DecimalFormatSymbols aDFS = new DecimalFormatSymbols();
aDFS.setDecimalSeparator('.');
DecimalFormat aDF = new DecimalFormat("0.00", aDFS);
return aDF.format(theValue);
}
public double X;
public double Y;
public double Z;
}
class MTKConverter_FeatureComparator implements Comparator<MTKBase_Feature>
{
@Override
public int compare(MTKBase_Feature theA, MTKBase_Feature theB)
{
MTKBase_FeatureComparator aComparator = new MTKBase_FeatureComparator();
boolean anALessThanB = aComparator.Apply(theA, theB);
if (anALessThanB)
{
return -1;
}
boolean aBLessThanA = aComparator.Apply(theB, theA);
if (aBLessThanA)
{
return 1;
}
return 0;
}
}
class ShapeIDVector extends ArrayList<java.math.BigInteger>
{
public ShapeIDVector()
{
super ();
}
}
class ShapeIDVectorVector extends ArrayList<ShapeIDVector>
{
public ShapeIDVectorVector()
{
super ();
}
}
class CountShapeIDVectorVectorPair
{
public CountShapeIDVectorVectorPair(long theCount, ShapeIDVectorVector theVector)
{
this.Count = theCount;
this.Vector = theVector;
}
public long Count;
public ShapeIDVectorVector Vector;
}
class MTKConverter_FeatureMap extends TreeMap<MTKBase_Feature, CountShapeIDVectorVectorPair>
{
public MTKConverter_FeatureMap()
{
super (new MTKConverter_FeatureComparator());
}
}
class JSONWriter
{
public JSONWriter(PrintWriter theStream, int theStartNestingLevel)
{
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 <T> void WriteData(String theParamName, T theValue)
{
DecimalFormatSymbols aDFS = new DecimalFormatSymbols();
aDFS.setDecimalSeparator('.');
DecimalFormat aDF = new DecimalFormat("0.00", aDFS);
String aValueString = theValue instanceof Double ? aDF.format(theValue) : theValue.toString();
Stream().print("\"" + theParamName + "\": \"" + aValueString + "\"");
}
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)
{
PrintWriter aStream = Stream();
if (!theName.isEmpty())
{
aStream.print("\"" + theName + "\": ");
}
aStream.write(theOpenBracketSymbol);
++myNestingLevel;
}
private void DoCloseSection(char theCloseBracketSymbol)
{
--myNestingLevel;
Stream().print(theCloseBracketSymbol);
}
private void PrepareStream()
{
if (myNestingLevel == myPrevNestingLevel)
{
myStream.print(",");
}
myPrevNestingLevel = myNestingLevel;
if (myIsInit)
{
myStream.println();
}
myIsInit = true;
}
private PrintWriter Stream()
{
PrepareStream();
for (int i = 0; i < myNestingLevel; ++i)
{
myStream.print(" ");
}
return myStream;
}
private PrintWriter myStream;
private boolean myIsInit = false;
private int myNestingLevel;
private int myPrevNestingLevel;
}
class MTKConverter_FeatureGroupManager
{
public MTKConverter_FeatureGroupManager()
{
myGroups = new ArrayList<FeatureGroup>();
}
public void AddGroupData(String theGroupName, String theGroupColor, String theFeatureData, long theFeatureNb)
{
//find or create
int aRes = -1;
for (int i = 0; i < myGroups.size(); ++i)
{
FeatureGroup aGroup = myGroups.get(i);
if (aGroup.myName == theGroupName)
{
aRes = i;
break;
}
}
if (aRes == -1)
{
myGroups.add(new FeatureGroup(theGroupName, theGroupColor));
aRes = myGroups.size() - 1;
}
//update
FeatureGroup aGroup = myGroups.get(aRes);
aGroup.myFeatureData.add(theFeatureData);
aGroup.myFeatureCount += theFeatureNb;
}
public long TotalFeatureCount()
{
long aTotalFeatureCount = 0;
for (FeatureGroup aGroup : myGroups)
{
aTotalFeatureCount += aGroup.myFeatureCount;
}
return aTotalFeatureCount;
}
public void Write(JSONWriter theWriter)
{
for (FeatureGroup aGroup : myGroups)
{
theWriter.OpenSection();
theWriter.WriteData("name", aGroup.myName);
theWriter.WriteData("color", aGroup.myColor);
theWriter.WriteData("totalGroupFeatureCount", aGroup.myFeatureCount);
ArrayList<String> aFeatureData = aGroup.myFeatureData;
if (!aFeatureData.isEmpty())
{
boolean aHasParams = aFeatureData.get(0).indexOf("parameters") != -1;
if (aHasParams)
{
theWriter.WriteData("subGroupCount", aFeatureData.size());
theWriter.OpenArraySection("subGroups");
for (String j : aFeatureData)
{
theWriter.WriteRawData(j);
}
theWriter.CloseArraySection();
}
else
{
theWriter.OpenArraySection("features");
for (String j : aFeatureData)
{
theWriter.WriteRawData(j);
}
theWriter.CloseArraySection();
}
}
theWriter.CloseSection();
}
}
private class FeatureGroup
{
public FeatureGroup(String theName, String theColor)
{
myName = theName;
myColor = theColor;
myFeatureData = new ArrayList<String>();
}
public String myName;
public String myColor;
public ArrayList<String> myFeatureData;
public long myFeatureCount = 0;
}
private ArrayList<FeatureGroup> myGroups;
}
class MTKConverter_Report
{
public MTKConverter_Report()
{
myData = new ArrayList<MTKConverter_ProcessData>();
}
public void AddData(MTKConverter_ProcessData theData)
{
myData.add(theData);
}
public boolean WriteToJSON(UTF16String thePath)
{
String aPath = thePath.toString();
File aFile = new File(aPath);
if (aFile.exists())
{
aFile.delete();
}
try
{
PrintWriter aStream = new PrintWriter (new BufferedWriter(new FileWriter(aPath)));
JSONWriter aWriter = new JSONWriter(aStream, 0);
aWriter.OpenSection();
aWriter.WriteData("version", "1");
if (myData.isEmpty())
{
aWriter.WriteData("error", "The model doesn't contain any parts.");
}
else
{
aWriter.OpenArraySection("parts");
for (MTKConverter_ProcessData aProcessData : myData)
{
aWriter.OpenSection();
WritePartProcessData(aWriter, aProcessData);
aWriter.CloseSection();
}
aWriter.CloseArraySection();
}
aWriter.CloseSection();
aStream.close();
}
catch (Exception anE)
{
return false;
}
return true;
}
private <T> void WriteParameter(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, ShapeIDVectorVector theVector, boolean theWriteFeatureSection)
{
if (theVector.isEmpty())
{
return;
}
if (theWriteFeatureSection) {
theWriter.OpenArraySection("features");
}
for (ShapeIDVector aShapeIDVector : theVector)
{
theWriter.OpenSection();
theWriter.WriteData("shapeIDCount", aShapeIDVector.size());
if (aShapeIDVector.isEmpty())
{
theWriter.WriteEmptyArray("shapeIDs");
}
else
{
theWriter.OpenArraySection("shapeIDs");
for (java.math.BigInteger aShapeID : aShapeIDVector)
{
theWriter.OpenSection();
theWriter.WriteData("id", aShapeID);
theWriter.CloseSection();
}
theWriter.CloseArraySection();
}
theWriter.CloseSection();
}
if (theWriteFeatureSection) {
theWriter.CloseArraySection();
}
}
private String DoWriteFeatureDataToString(Consumer<JSONWriter> theFunc, int theParamCount, ShapeIDVectorVector theVector)
{
StringWriter aStrWriter = new StringWriter();
PrintWriter aStream = new PrintWriter(aStrWriter);
JSONWriter aWriter = new JSONWriter(aStream, 7);
aWriter.OpenSection();
aWriter.WriteData("parametersCount", theParamCount);
aWriter.OpenArraySection("parameters");
theFunc.accept(aWriter);
aWriter.CloseArraySection();
WriteShapeIDs(aWriter, theVector, true);
aWriter.CloseSection();
return aStrWriter.toString();
}
private String WriteFeatureDataToString(ShapeIDVectorVector theVector)
{
StringWriter aStrWriter = new StringWriter();
PrintWriter aStream = new PrintWriter(aStrWriter);
JSONWriter aWriter = new JSONWriter(aStream, 6);
WriteShapeIDs(aWriter, theVector, false);
return aStrWriter.toString();
}
private <T> String WriteFeatureDataToString(String theParamName, String theParamUnits,
T theParamValue, ShapeIDVectorVector theVector)
{
Consumer<JSONWriter> WriteParams = (theWriter) ->
{
WriteParameter(theWriter, theParamName, theParamUnits, theParamValue);
};
return DoWriteFeatureDataToString(WriteParams, 1, theVector);
}
private <T1, T2> String WriteFeatureDataToString(String theParamName1, String theParamUnits1, T1 theParamValue1,
String theParamName2, String theParamUnits2, T2 theParamValue2,
ShapeIDVectorVector theVector)
{
Consumer<JSONWriter> WriteParams = (theWriter) ->
{
WriteParameter(theWriter, theParamName1, theParamUnits1, theParamValue1);
WriteParameter(theWriter, theParamName2, theParamUnits2, theParamValue2);
};
return DoWriteFeatureDataToString(WriteParams, 2, theVector);
}
private <T1, T2, T3> String WriteFeatureDataToString(String theParamName1, String theParamUnits1, T1 theParamValue1,
String theParamName2, String theParamUnits2, T2 theParamValue2,
String theParamName3, String theParamUnits3, T3 theParamValue3,
ShapeIDVectorVector theVector)
{
Consumer<JSONWriter> WriteParams = (theWriter) ->
{
WriteParameter(theWriter, theParamName1, theParamUnits1, theParamValue1);
WriteParameter(theWriter, theParamName2, theParamUnits2, theParamValue2);
WriteParameter(theWriter, theParamName3, theParamUnits3, theParamValue3);
};
return DoWriteFeatureDataToString(WriteParams, 3, theVector);
}
private <T1, T2, T3, T4> String WriteFeatureDataToString(String theParamName1, String theParamUnits1, T1 theParamValue1,
String theParamName2, String theParamUnits2, T2 theParamValue2,
String theParamName3, String theParamUnits3, T3 theParamValue3,
String theParamName4, String theParamUnits4, T4 theParamValue4,
ShapeIDVectorVector theVector)
{
Consumer<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 <T1, T2, T3, T4, T5, T6> String WriteFeatureDataToString(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,
ShapeIDVectorVector theVector)
{
Consumer<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_FT_FlatFaceMilled: return "Flat Face Milled Face(s)";
case Machining_FT_FlatSideMilled: return "Flat Side Milled Face(s)";
case Machining_FT_CurvedMilled: return "Curved Milled Face(s)";
case Machining_FT_CircularMilled: return "Circular Milled Face(s)";
case Machining_FT_Deburr: return "Deburr Face(s)";
case Machining_FT_ConvexProfileEdgeMilling: return "Convex Profile Edge Milling Face(s)";
case Machining_FT_ConcaveFilletEdgeMilling: return "Concave Fillet Edge Milling Face(s)";
case Machining_FT_FlatMilled: return "Flat Milled Face(s)";
case Machining_FT_TurnDiameter: return "Turn Diameter Face(s)";
case Machining_FT_TurnForm: return "Turn Form Face(s)";
case Machining_FT_TurnFace: return "Turn Face Face(s)";
default:
break;
}
return "Face(s)";
}
private String MachiningFaceColor(Machining_FaceType theType)
{
switch (theType)
{
case Machining_FT_FlatFaceMilled: return "(115, 251, 253)";
case Machining_FT_FlatSideMilled: return "(0, 35, 245)";
case Machining_FT_CurvedMilled: return "(22, 65, 124)";
case Machining_FT_CircularMilled: return "(255, 254, 145)";
case Machining_FT_Deburr: return "(0, 0, 0)";
case Machining_FT_ConvexProfileEdgeMilling: return "(240, 155, 89)";
case Machining_FT_ConcaveFilletEdgeMilling: return "(129, 127, 38)";
case Machining_FT_FlatMilled: return "(115, 43, 245)";
case Machining_FT_TurnDiameter: return "(88, 19, 94)";
case Machining_FT_TurnForm: return "(161, 251, 142)";
case Machining_FT_TurnFace: return "(239, 136, 190)";
default:
break;
}
return "(0, 0, 0)";
}
private String MachiningHoleTypeToString(Machining_HoleType theType)
{
switch (theType)
{
case Machining_HT_Through: return "Through Hole(s)";
case Machining_HT_FlatBottom: return "Flat Bottom Hole(s)";
case Machining_HT_Blind: return "Blind Hole(s)";
case Machining_HT_Partial: return "Partial Hole(s)";
default:
break;
}
return "Hole(s)";
}
private String MachiningHoleColor(Machining_HoleType theType)
{
switch (theType)
{
case Machining_HT_Through: return "(240, 135, 132)";
case Machining_HT_FlatBottom: return "(235, 51, 36)";
case Machining_HT_Blind: return "(142, 64, 58)";
case Machining_HT_Partial: return "(58, 6, 3)";
default:
break;
}
return "(0, 0, 0)";
}
private String MachiningThreadedHoleColor (Machining_HoleType theType)
{
switch (theType)
{
case Machining_HT_Through: return "(35, 160, 207)";
case Machining_HT_FlatBottom: return "(35, 76, 111)";
case Machining_HT_Blind: return "(192, 89, 133)";
case Machining_HT_Partial: return "(108, 31, 78)";
default:
break;
}
return "(0, 0, 0)";
}
private String MachiningPocketTypeToString(Machining_PocketType theType)
{
switch (theType)
{
case Machining_PT_Closed: return "Closed Pocket(s)";
case Machining_PT_Open: return "Open Pocket(s)";
case Machining_PT_Through: return "Through Pocket(s)";
default:
break;
}
return "Pocket(s)";
}
private String MachiningPocketColor(Machining_PocketType theType)
{
switch (theType)
{
case Machining_PT_Closed: return "(81, 20, 0)";
case Machining_PT_Open: return "(189, 103, 37)";
case Machining_PT_Through: return "(255, 217, 188)";
default:
break;
}
return "(0, 0, 0)";
}
private String HemTypeToString (SheetMetal_HemBendType theType)
{
switch (theType) {
case SheetMetal_HBT_Flattened: return "Flattened Hem Bend(s)";
case SheetMetal_HBT_Open: return "Open Hem Bend(s)";
case SheetMetal_HBT_Teardrop: return "Teardrop Hem Bend(s)";
case SheetMetal_HBT_Rope: return "Rope Hem Bend(s)";
case SheetMetal_HBT_Rolled: return "Rolled Hem Bend(s)";
default:
break;
}
return "Hem Bend(s)";
}
private String MachiningTurningGrooveTypeToString(Machining_TurningGrooveType theType)
{
switch (theType)
{
case Machining_TGT_OuterDiameter: return "Outer Diameter Groove(s)";
case Machining_TGT_InnerDiameter: return "Inner Diameter Groove(s)";
case Machining_TGT_EndFace: return "End Face Groove(s)";
default:
break;
}
return "Turning Groove(s)";
}
private String MachiningTurningGrooveColor(Machining_TurningGrooveType theType)
{
switch (theType)
{
case Machining_TGT_OuterDiameter: return "(175, 49, 37)";
case Machining_TGT_InnerDiameter: return "(234, 255, 53)";
case Machining_TGT_EndFace: return "(144, 66, 159)";
default:
break;
}
return "(0, 0, 0)";
}
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_HBT_Flattened: return "(22, 65, 124)";
case SheetMetal_HBT_Open: return "(42, 85, 144)";
case SheetMetal_HBT_Teardrop: return "(62, 105, 164)";
case SheetMetal_HBT_Rope: return "(82, 125, 184)";
case SheetMetal_HBT_Rolled: return "(102, 145, 204)";
default:
break;
}
return "(0, 0, 0)";
}
else if (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(MTKConverter_FeatureGroupManager theManager, MTKBase_ShapeFeature theFeature,
long theCount, ShapeIDVectorVector 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 MTKConverter_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 MTKConverter_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 MTKConverter_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 MTKConverter_Direction(aDir.X(), aDir.Y(), aDir.Z()),
theShapeIdVector);
theManager.AddGroupData(MachiningPocketTypeToString(aType), MachiningPocketColor(aType), aFeatureData, theCount);
}
else if (Machining_TurningGroove.CompareType(aFeature))
{
Machining_TurningGroove aTurningGroove = Machining_TurningGroove.Cast(theFeature);
Machining_TurningGrooveType aType = aTurningGroove.Type();
String aFeatureData = WriteFeatureDataToString(
"Radius", "mm", aTurningGroove.Radius(),
"Depth", "mm", aTurningGroove.Depth(),
"Width", "mm", aTurningGroove.Width(),
theShapeIdVector);
theManager.AddGroupData(MachiningTurningGrooveTypeToString(aType),
MachiningTurningGrooveColor(aType),
aFeatureData,
theCount);
}
else if (Machining_Bore.CompareType(aFeature))
{
Machining_Bore aBore = Machining_Bore.Cast(theFeature);
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 MTKConverter_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(MTKConverter_FeatureGroupManager theManager, DFMMachining_DrillingIssue theIssue,
long theCount, ShapeIDVectorVector 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(MTKConverter_FeatureGroupManager theManager, DFMMachining_MillingIssue theIssue,
long theCount, ShapeIDVectorVector 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 MTKConverter_Dimension(anExpectedSize.Length(), anExpectedSize.Width(), anExpectedSize.Height()),
"Actual Size (LxWxH)", "mm",
new MTKConverter_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", "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(MTKConverter_FeatureGroupManager theManager, DFMBase_Issue theIssue,
long theCount, ShapeIDVectorVector 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 MTKConverter_Pair(anExpectedSize.Length(), anExpectedSize.Radius()),
"Actual Size (LxR)", "mm", new MTKConverter_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 (MTKConverter_FeatureGroupManager theManager, DFMBase_Issue theIssue,
long theCount, ShapeIDVectorVector 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_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_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_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(MTKConverter_FeatureGroupManager theManager, DFMBase_Issue theIssue,
long theCount, ShapeIDVectorVector 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 Minimum Extruded Height", "mm", aIDEHIssue.ExpectedMinExtrudedHeight(),
"Expected Maximum 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 MTKConverter_Pair(anExpectedRelief.Length(), anExpectedRelief.Width()),
"First Actual Relief Size (LxW)", "mm", new MTKConverter_Pair(aFirstActualRelief.Length(), aFirstActualRelief.Width()),
"Second Actual Relief Size (LxW)", "mm", new MTKConverter_Pair(aSecondActualRelief.Length(), aSecondActualRelief.Width()),
theShapeIdVector);
}
else if (aFirstActualRelief.IsNull())
{
aFeatureData = WriteFeatureDataToString(
"Expected Minimum Relief Size (LxW)", "mm", new MTKConverter_Pair(anExpectedRelief.Length(), anExpectedRelief.Width()),
"Actual Relief Size (LxW)", "mm", new MTKConverter_Pair(aSecondActualRelief.Length(), aSecondActualRelief.Width()),
theShapeIdVector);
}
else
{
aFeatureData = WriteFeatureDataToString(
"Expected Minimum Relief Size (LxW)", "mm", new MTKConverter_Pair(anExpectedRelief.Length(), anExpectedRelief.Width()),
"Actual Relief Size (LxW)", "mm", new MTKConverter_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 MTKConverter_Pair(aISNIssue.ExpectedLength(), aISNIssue.ExpectedWidth()),
"Actual Size (LxW)", "mm", new MTKConverter_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 MTKConverter_Pair(aISTIssue.ExpectedLength(), aISTIssue.ExpectedWidth()),
"Actual Size (LxW)", "mm", new MTKConverter_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 MTKConverter_Pair(aNesrestStandardSize.Length(), aNesrestStandardSize.Width()),
"Actual Size (LxW)", "mm", new MTKConverter_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 aSLHBFIssue = DFMSheetMetal_SmallLengthHemBendFlangeIssue.Cast(theIssue);
String aFeatureData = WriteFeatureDataToString(
"Expected Minimum Length", "mm", aSLHBFIssue.ExpectedMinLength(),
"Actual Length", "mm", aSLHBFIssue.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 ShapeIDVector GetShapesId(Shape theShape, ShapeType theType)
{
ShapeIDVector aShapeIdVector = new ShapeIDVector();
ShapeIterator aShapeIt = new ShapeIterator(theShape, theType);
while (aShapeIt.HasNext())
{
Shape aShape = aShapeIt.Next();
aShapeIdVector.add(aShape.Id());
}
return aShapeIdVector;
}
private void AddShapesId(Shape theShape, ShapeType theType, ShapeIDVector theShapesIdVec)
{
ShapeIterator aShapeIt = new ShapeIterator(theShape, theType);
while (aShapeIt.HasNext())
{
Shape aShape = aShapeIt.Next();
theShapesIdVec.add(aShape.Id());
}
}
private void SortFeatures(MTKBase_FeatureList theFeatures, MTKConverter_FeatureMap theMap)
{
for (long i = 0; i < theFeatures.Size(); i++)
{
MTKBase_Feature aFeature = theFeatures.Feature(i);
CountShapeIDVectorVectorPair anElement;
if (theMap.containsKey(aFeature))
{
anElement = theMap.get(aFeature);
}
else
{
anElement = new CountShapeIDVectorVectorPair(0, new ShapeIDVectorVector());
}
ShapeIDVectorVector aValue = anElement.Vector;
//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;
}
ShapeIDVector aShapeIdVector = GetShapesId(aShapeFeature.Shape(), aShapeType);
aValue.add(aShapeIdVector);
}
else if (Machining_SteppedHole.CompareType(aFeature)) {
ShapeIDVector aCompositeIdVector = new ShapeIDVector();
Machining_SteppedHole aSteppedHole = Machining_SteppedHole.Cast(aFeature);
MTKBase_FeatureList aHoles = aSteppedHole.FeatureList();
for (long j = 0; j < aHoles.Size(); j++)
{
Machining_Hole aHole = Machining_Hole.Cast(aHoles.Feature(j));
ShapeIDVector aShapeIdVector = GetShapesId(aHole.Shape(), ShapeType.Face);
aCompositeIdVector.addAll(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);
ShapeIDVector 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);
ShapeIDVector aShapeIdVector = GetShapesId(aNSRMPFFIssue.FloorFillet(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMachining_DeepPocketIssue.CompareType(aFeature))
{
DFMMachining_DeepPocketIssue aDCIssue = DFMMachining_DeepPocketIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aDCIssue.Pocket().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMachining_HighBossIssue.CompareType(aFeature))
{
DFMMachining_HighBossIssue aHBIssue = DFMMachining_HighBossIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aHBIssue.Boss().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMachining_LargeMilledPartIssue.CompareType(aFeature))
{
aValue.add(new ShapeIDVector());
}
else if (DFMMachining_SmallRadiusMilledPartInternalCornerIssue.CompareType(aFeature))
{
DFMMachining_SmallRadiusMilledPartInternalCornerIssue aMSICRIssue =
DFMMachining_SmallRadiusMilledPartInternalCornerIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aMSICRIssue.Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMachining_NonPerpendicularMilledPartShapeIssue.CompareType(aFeature))
{
DFMMachining_NonPerpendicularMilledPartShapeIssue aNPMPSIssue =
DFMMachining_NonPerpendicularMilledPartShapeIssue.Cast (aFeature);
ShapeIDVector aShapeIdVector = GetShapesId (aNPMPSIssue.Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMachining_MilledPartExternalEdgeFilletIssue.CompareType(aFeature))
{
DFMMachining_MilledPartExternalEdgeFilletIssue aMPEEFSIssue = DFMMachining_MilledPartExternalEdgeFilletIssue.Cast (aFeature);
ShapeIDVector aShapeIdVector = GetShapesId (aMPEEFSIssue.Fillet(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue.CompareType(aFeature))
{
DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue aIRMPFFIssue =
DFMMachining_InconsistentRadiusMilledPartFloorFilletIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aIRMPFFIssue.FloorFillet(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMachining_NarrowRegionInPocketIssue.CompareType(aFeature)) {
DFMMachining_NarrowRegionInPocketIssue aNRIPIssue =
DFMMachining_NarrowRegionInPocketIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector 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);
ShapeIDVector aShapeIdVector = GetShapesId(aBBHRIssue.BlindBoredHole(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMachining_DeepBoredHoleIssue.CompareType(aFeature))
{
DFMMachining_DeepBoredHoleIssue aISBHIssue = DFMMachining_DeepBoredHoleIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aISBHIssue.Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue.CompareType(aFeature))
{
DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue aODPRIssue =
DFMMachining_IrregularTurnedPartOuterDiameterProfileReliefIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aODPRIssue.Face(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMachining_SmallRadiusTurnedPartInternalCornerIssue.CompareType(aFeature))
{
DFMMachining_SmallRadiusTurnedPartInternalCornerIssue aTSICRIssue =
DFMMachining_SmallRadiusTurnedPartInternalCornerIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aTSICRIssue.Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMachining_SquareEndKeywayIssue.CompareType(aFeature))
{
DFMMachining_SquareEndKeywayIssue aSEKIssue = DFMMachining_SquareEndKeywayIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aSEKIssue.Keyway().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMachining_NonSymmetricalAxialSlotIssue.CompareType(aFeature))
{
DFMMachining_NonSymmetricalAxialSlotIssue aNSASIssue =
DFMMachining_NonSymmetricalAxialSlotIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aNSASIssue.AxialSlot().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMachining_LargeTurnedPartIssue.CompareType(aFeature))
{
aValue.add(new ShapeIDVector());
}
else if (DFMMachining_LongSlenderTurnedPartIssue.CompareType(aFeature))
{
aValue.add(new ShapeIDVector());
}
//dfm molding
else if (DFMMolding_HighRibIssue.CompareType(aFeature))
{
DFMMolding_HighRibIssue aHRIssue = DFMMolding_HighRibIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aHRIssue.Rib().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_HighScrewBossIssue.CompareType(aFeature))
{
DFMMolding_HighScrewBossIssue aHSBIssue = DFMMolding_HighScrewBossIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aHSBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_IrregularCoreDepthScrewBossIssue.CompareType(aFeature))
{
DFMMolding_IrregularCoreDepthScrewBossIssue aICDSBIssue = DFMMolding_IrregularCoreDepthScrewBossIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aICDSBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_IrregularCoreDiameterScrewBossIssue.CompareType(aFeature))
{
DFMMolding_IrregularCoreDiameterScrewBossIssue aICDSBIssue = DFMMolding_IrregularCoreDiameterScrewBossIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aICDSBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_IrregularThicknessRibIssue.CompareType(aFeature))
{
DFMMolding_IrregularThicknessRibIssue aITRIssue = DFMMolding_IrregularThicknessRibIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aITRIssue.Rib().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_IrregularWallThicknessScrewBossIssue.CompareType(aFeature))
{
DFMMolding_IrregularWallThicknessScrewBossIssue aIWTSBIssue = DFMMolding_IrregularWallThicknessScrewBossIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aIWTSBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_SmallBaseRadiusRibIssue.CompareType(aFeature))
{
DFMMolding_SmallBaseRadiusRibIssue aSBRRIssue = DFMMolding_SmallBaseRadiusRibIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aSBRRIssue.Rib().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_SmallBaseRadiusScrewBossIssue.CompareType(aFeature))
{
DFMMolding_SmallBaseRadiusScrewBossIssue aSBRSBIssue = DFMMolding_SmallBaseRadiusScrewBossIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aSBRSBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_SmallDraftAngleRibIssue.CompareType(aFeature))
{
DFMMolding_SmallDraftAngleRibIssue aSMDARIssue = DFMMolding_SmallDraftAngleRibIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aSMDARIssue.Rib().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_SmallDraftAngleScrewBossIssue.CompareType(aFeature))
{
DFMMolding_SmallDraftAngleScrewBossIssue aSDASBIssue = DFMMolding_SmallDraftAngleScrewBossIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aSDASBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_SmallDistanceBetweenRibsIssue.CompareType(aFeature))
{
DFMMolding_SmallDistanceBetweenRibsIssue aSDBRIssue = DFMMolding_SmallDistanceBetweenRibsIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = GetShapesId(aSHBRSBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_SmallDraftAngleWallIssue.CompareType(aFeature))
{
DFMMolding_SmallDraftAngleWallIssue aSDAWIssue = DFMMolding_SmallDraftAngleWallIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aSDAWIssue.Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_NonChamferedScrewBossIssue.CompareType(aFeature))
{
DFMMolding_NonChamferedScrewBossIssue aWTCSBIssue = DFMMolding_NonChamferedScrewBossIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aWTCSBIssue.ScrewBoss().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_IrregularWallThicknessIssue.CompareType(aFeature))
{
DFMMolding_IrregularWallThicknessIssue aIWTIssue = DFMMolding_IrregularWallThicknessIssue.Cast (aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aIWTIssue.Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_LargeWallThicknessIssue.CompareType(aFeature))
{
DFMMolding_LargeWallThicknessIssue aLWTIssue = DFMMolding_LargeWallThicknessIssue.Cast (aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aLWTIssue.Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_SmallWallThicknessIssue.CompareType(aFeature))
{
DFMMolding_SmallWallThicknessIssue aSWTIssue = DFMMolding_SmallWallThicknessIssue.Cast (aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aSWTIssue.Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMMolding_SmallDistanceBetweenBossesIssue.CompareType(aFeature))
{
DFMMolding_SmallDistanceBetweenBossesIssue aSDBBIssue = DFMMolding_SmallDistanceBetweenBossesIssue.Cast (aFeature);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
aShapeIdVector.add(aFPIIssue.FirstFace().Id());
aShapeIdVector.add(aFPIIssue.SecondFace().Id());
aValue.add(aShapeIdVector);
}
else if (DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue.CompareType(aFeature))
{
DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue aICFRNIssue = DFMSheetMetal_IrregularCornerFilletRadiusNotchIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aICFRNIssue.Notch().Shape(), ShapeType.Edge);
aValue.add(aShapeIdVector);
}
else if (DFMSheetMetal_IrregularDepthExtrudedHoleIssue.CompareType(aFeature))
{
DFMSheetMetal_IrregularDepthExtrudedHoleIssue aIDEHIssue = DFMSheetMetal_IrregularDepthExtrudedHoleIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aIDEHIssue.Hole().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMSheetMetal_IrregularRadiusOpenHemBendIssue.CompareType(aFeature))
{
DFMSheetMetal_IrregularRadiusOpenHemBendIssue aICFRNIssue = DFMSheetMetal_IrregularRadiusOpenHemBendIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aICFRNIssue.Bend().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMSheetMetal_InconsistentRadiusBendIssue.CompareType(aFeature))
{
DFMSheetMetal_InconsistentRadiusBendIssue aIRBIssue = DFMSheetMetal_InconsistentRadiusBendIssue.Cast(aFeature);
ShapeIDVector 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();
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = GetShapesId(aISNIssue.Notch().Shape(), ShapeType.Edge);
aValue.add(aShapeIdVector);
}
else if (DFMSheetMetal_IrregularSizeTabIssue.CompareType(aFeature))
{
DFMSheetMetal_IrregularSizeTabIssue aISTIssue = DFMSheetMetal_IrregularSizeTabIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aISTIssue.Tab().Shape(), ShapeType.Edge);
aValue.add(aShapeIdVector);
}
else if (DFMSheetMetal_LargeDepthBeadIssue.CompareType(aFeature))
{
DFMSheetMetal_LargeDepthBeadIssue aLDBIssue = DFMSheetMetal_LargeDepthBeadIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aLDBIssue.Bead().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDepthLouverIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDepthLouverIssue aSDLIssue = DFMSheetMetal_SmallDepthLouverIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = GetShapesId(aSDLIssue.Louver().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMSheetMetal_NonStandardSheetSizeIssue.CompareType(aFeature))
{
aValue.add(new ShapeIDVector());
}
else if (DFMSheetMetal_NonStandardSheetThicknessIssue.CompareType(aFeature))
{
aValue.add(new ShapeIDVector());
}
else if (DFMSheetMetal_SmallDiameterHoleIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDiameterHoleIssue aSDHIssue = DFMSheetMetal_SmallDiameterHoleIssue.Cast(aFeature);
ShapeIDVector 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();
ShapeIDVector aShapeIdVector = new ShapeIDVector();
for (long 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();
ShapeIDVector aShapeIdVector = new ShapeIDVector();
for (long 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);
ShapeIDVector aShapeIdVector = GetShapesId(aSRBIssue.Bend().Shape(), ShapeType.Face);
aValue.add(aShapeIdVector);
}
else if (DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue.CompareType(aFeature))
{
DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue aSDIssue = DFMSheetMetal_SmallDistanceBetweenBendAndLouverIssue.Cast(aFeature);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
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);
ShapeIDVector aShapeIdVector = new ShapeIDVector();
AddShapesId(aSDIssue.FirstTab().Shape(), ShapeType.Edge, aShapeIdVector);
AddShapesId(aSDIssue.SecondTab().Shape(), ShapeType.Edge, aShapeIdVector);
aValue.add(aShapeIdVector);
}
anElement = new CountShapeIDVectorVectorPair(anElement.Count + 1, aValue);
theMap.put(aFeature, anElement);
}
}
private boolean 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
{
MTKConverter_FeatureMap aSortedFeatures = new MTKConverter_FeatureMap();
SortFeatures(theFeatures, aSortedFeatures);
MTKConverter_FeatureGroupManager aFGManager = new MTKConverter_FeatureGroupManager();
for (Map.Entry<MTKBase_Feature, CountShapeIDVectorVectorPair> i : aSortedFeatures.entrySet())
{
MTKBase_Feature aFeature = i.getKey();
long aCount = i.getValue().Count;
ShapeIDVectorVector aShapeIDVec = i.getValue().Vector;
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_SmallDistanceBetweenRibsIssue.CompareType(aFeature)
|| DFMMolding_SmallHoleBaseRadiusScrewBossIssue.CompareType(aFeature)
|| DFMMolding_SmallDraftAngleWallIssue.CompareType(aFeature)
|| DFMMolding_NonChamferedScrewBossIssue.CompareType(aFeature)
|| DFMMolding_SmallWallThicknessIssue.CompareType(aFeature)
|| DFMMolding_SmallDistanceBetweenBossesIssue.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_OT_Milling: return "CNC Machining Milling";
case Machining_OT_LatheMilling: return "CNC Machining Lathe+Milling";
default:
break;
}
return "CNC Machining";
}
private boolean HasShapes(cadex.Collections.BodyList theBodies, ShapeType theType)
{
for (Body aBody : theBodies) {
ShapeIterator aShapeIt = new ShapeIterator(aBody, theType);
if (aShapeIt.HasNext()) {
return true;
}
}
return false;
}
private void WriteThicknessNode(JSONWriter theWriter, String theParamName, double theParamValue,
PointPair thePoints, String theNodeName)
{
Point aFirstPoint = thePoints.First;
Point aSecondPoint = thePoints.Second;
theWriter.OpenSection(theNodeName);
theWriter.WriteData("name", theParamName);
theWriter.WriteData("units", "mm");
theWriter.WriteData("value", theParamValue);
theWriter.WriteData("firstPoint", new MTKConverter_Point(aFirstPoint.X(), aFirstPoint.Y(), aFirstPoint.Z()));
theWriter.WriteData("secondPoint", new MTKConverter_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 aStrWriter = new StringWriter();
PrintWriter aStream = new PrintWriter(aStrWriter);
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(aStrWriter.toString());
}
else
{
theWriter.WriteData("message", "Unfolded part wasn't generated.");
}
theWriter.CloseSection();
}
private void WritePartProcessData(JSONWriter theWriter, MTKConverter_ProcessData theProcessData)
{
boolean aRes = false;
theWriter.WriteData("partId", theProcessData.myPart.Uuid());
String anErrorMsg = "An error occurred while processing the part.";
if (theProcessData instanceof MTKConverter_MachiningData)
{
MTKConverter_MachiningData aMD = (MTKConverter_MachiningData)theProcessData;
theWriter.WriteData("process", MachiningProcessName(aMD.myOperation));
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(aMD.myPart.Bodies(), ShapeType.Solid))
{
anErrorMsg = "The part can't be analyzed due to lack of: BRep representation or solids in BRep representation.";
}
}
else if (theProcessData instanceof MTKConverter_MoldingData)
{
MTKConverter_MoldingData aMoldingData = (MTKConverter_MoldingData)theProcessData;
theWriter.WriteData("process", "Molding Analysis");
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(aMoldingData.myPart.Bodies(), 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 instanceof MTKConverter_SheetMetalData)
{
MTKConverter_SheetMetalData aSMD = (MTKConverter_SheetMetalData)theProcessData;
theWriter.WriteData("process", "Sheet Metal");
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(aSMD.myPart.Bodies(), ShapeType.Solid)
&& !HasShapes(aSMD.myPart.Bodies(), 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 instanceof MTKConverter_WallThicknessData)
{
MTKConverter_WallThicknessData aWTD = (MTKConverter_WallThicknessData)theProcessData;
theWriter.WriteData("process", "Wall Thickness Analysis");
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(aWTD.myPart.Bodies(), 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);
}
}
private ArrayList<MTKConverter_ProcessData> myData;
}
Defines a 3D Direction.
Definition Direction.hxx:34
Direction()
Constructor.
Definition Direction.cxx:38
Defines classes, types, enums, and functions related to geometric entities.
@ Machining_OT_Milling
Milling operation type.
Definition Machining_OperationType.hxx:29
@ Machining_OT_LatheMilling
Lathe + Milling operation type.
Definition Machining_OperationType.hxx:30
Machining_HoleType
Defines a hole type in machining.
Definition Machining_HoleType.hxx:28
@ Machining_HT_Partial
Partial hole type.
Definition Machining_HoleType.hxx:32
@ Machining_HT_Through
Through hole type.
Definition Machining_HoleType.hxx:29
@ Machining_HT_FlatBottom
Flat Bottom hole type.
Definition Machining_HoleType.hxx:30
@ Machining_HT_Blind
Blind hole type.
Definition Machining_HoleType.hxx:31
Machining_FaceType
Describes a face produced by a specified machining operation.
Definition Machining_FaceType.hxx:28
@ Machining_FT_Deburr
Deburr face type.
Definition Machining_FaceType.hxx:35
@ Machining_FT_FlatFaceMilled
Flat Face Milled face type.
Definition Machining_FaceType.hxx:36
@ Machining_FT_TurnDiameter
Turn Diameter face type.
Definition Machining_FaceType.hxx:39
@ Machining_FT_TurnForm
Turn Form face type.
Definition Machining_FaceType.hxx:41
@ Machining_FT_ConvexProfileEdgeMilling
Convex Profile Edge Milling face type.
Definition Machining_FaceType.hxx:33
@ Machining_FT_FlatMilled
Flat Milled face type.
Definition Machining_FaceType.hxx:37
@ Machining_FT_FlatSideMilled
Flat Side Milled face type.
Definition Machining_FaceType.hxx:38
@ Machining_FT_ConcaveFilletEdgeMilling
Concave Fillet Edge Milling face type.
Definition Machining_FaceType.hxx:32
@ Machining_FT_TurnFace
Turn Face face type.
Definition Machining_FaceType.hxx:40
@ Machining_FT_CurvedMilled
Curved Milled face type.
Definition Machining_FaceType.hxx:34
@ Machining_FT_CircularMilled
Circular Milled face type.
Definition Machining_FaceType.hxx:31
SheetMetal_HemBendType
Defines a hem bend type in sheet metal.
Definition SheetMetal_HemBendType.hxx:28
@ SheetMetal_HBT_Rope
Rope hem bend type.
Definition SheetMetal_HemBendType.hxx:32
@ SheetMetal_HBT_Flattened
Flattened hem bend type.
Definition SheetMetal_HemBendType.hxx:29
@ SheetMetal_HBT_Rolled
Rolled hem bend type.
Definition SheetMetal_HemBendType.hxx:33
@ SheetMetal_HBT_Open
Open hem bend type.
Definition SheetMetal_HemBendType.hxx:30
@ SheetMetal_HBT_Teardrop
Teardrop hem bend type.
Definition SheetMetal_HemBendType.hxx:31
Machining_TurningGrooveType
Defines a groove type in turning (lathe) machining.
Definition Machining_TurningGrooveType.hxx:26
@ Machining_TGT_EndFace
End Face turning groove type.
Definition Machining_TurningGrooveType.hxx:29
@ Machining_TGT_InnerDiameter
Inner Diameter turning groove type.
Definition Machining_TurningGrooveType.hxx:28
@ Machining_TGT_OuterDiameter
Outer Diameter turning groove type.
Definition Machining_TurningGrooveType.hxx:27
Machining_PocketType
Defines pocket type.
Definition Machining_PocketType.hxx:26

MTKConverter_Application.java

// ****************************************************************************
// $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.
//
// ****************************************************************************
import cadex.*;
import cadex.ModelData.*;
import java.io.File;
import java.util.HashMap;
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);
private MTKConverter_ReturnCode(int theValue)
{
this.myValue = theValue;
}
public int GetValue()
{
return myValue;
}
private final int myValue;
}
enum MTKConverter_ProcessType
{
MTKConverter_PT_Undefined,
MTKConverter_PT_WallThickness,
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 == 1 ||
(args[0].equals("-?")) || (args[0].equals("/?")) ||
(args[0].equals("-h")) || (args[0].equals("--help")))
{
PrintUsage();
return MTKConverter_ReturnCode.MTKConverter_RC_OK;
}
if (args.length < 6)
{
System.out.println("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;
for (int i = 0; (i < args.length) && (aRes == MTKConverter_ReturnCode.MTKConverter_RC_OK); ++i) {
String anArgument = args[i];
if (anArgument.equals("-i")) {
aMode = Mode.ImportMode;
} else if (anArgument.equals("-p")) {
aMode = Mode.ProcessMode;
} else if (anArgument.equals("-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, aReport, aProcessModel);
}
else
{
System.out.println("ERROR!: Invalid argument " + anArgument + ". Exiting");
System.out.println("Type \"-h\" for help.");
return MTKConverter_ReturnCode.MTKConverter_RC_InvalidArgument;
}
System.out.println("Done.");
}
catch(Exception anE)
{
System.out.println("Failed.\nERROR: Unhandled exception caught.");
return MTKConverter_ReturnCode.MTKConverter_RC_GeneralException;
}
}
}
return aRes;
}
public void PrintUsage()
{
System.out.println("Usage:");
System.out.println("MTKConverter -i <import_file> -p <process> -e <export_folder>\n");
System.out.println("Arguments:");
System.out.println(" <import_file> - import file name");
System.out.println(" <process> - manufacturing process or algorithm name");
System.out.println(" <export_folder> - export folder name");
System.out.println("Example:" );
System.out.println("MTKConverter -i C:\\models\\test.step -p machining_milling -e C:\\models\\test");
System.out.println("\nRecognized processes:");
System.out.println(" machining_milling:\t CNC Machining Milling feature recognition and dfm analysis");
System.out.println(" machining_turning:\t CNC Machining Lathe+Milling feature recognition and dfm analysis");
System.out.println(" molding :\t Molding feature recognition and dfm analysis");
System.out.println(" sheet_metal :\t Sheet Metal feature recognition, unfolding and dfm analysis");
}
private static MTKConverter_ProcessType ProcessType(String theOperationStr)
{
HashMap<String, MTKConverter_ProcessType> aProcessMap = new HashMap<>();
aProcessMap.put("wall_thickness", MTKConverter_ProcessType.MTKConverter_PT_WallThickness);
aProcessMap.put("machining_milling", MTKConverter_ProcessType.MTKConverter_PT_MachiningMilling);
aProcessMap.put("machining_turning", MTKConverter_ProcessType.MTKConverter_PT_MachiningTurning);
aProcessMap.put("molding", MTKConverter_ProcessType.MTKConverter_PT_Molding);
aProcessMap.put("sheet_metal", MTKConverter_ProcessType.MTKConverter_PT_SheetMetal);
MTKConverter_ProcessType aProcess = aProcessMap.getOrDefault(theOperationStr, MTKConverter_ProcessType.MTKConverter_PT_Undefined);
return aProcess;
}
private MTKConverter_ReturnCode Import(String theFilePath, Model theModel)
{
UTF16String aFilePath = new UTF16String(theFilePath);
System.out.print("Importing " + theFilePath + "...");
ModelReader aReader = new ModelReader();
if (!aReader.Read (aFilePath, theModel)) {
System.out.println("\nERROR: Failed to import " + theFilePath + ". Exiting");
return MTKConverter_ReturnCode.MTKConverter_RC_ImportError;
}
return MTKConverter_ReturnCode.MTKConverter_RC_OK;
}
private void ApplyProcessorToModel(Model theModel, MTKConverter_Report theReport, MTKConverter_PartProcessor theProcessor)
{
ModelElementUniqueVisitor aVisitor = new ModelElementUniqueVisitor(theProcessor);
theModel.Accept(aVisitor);
for (MTKConverter_ProcessData i : theProcessor.myData)
{
theReport.AddData(i);
}
}
private MTKConverter_ReturnCode Process(String theProcess, Model theModel,
MTKConverter_Report theReport, Model theProcessModel)
{
System.out.print("Processing " + theProcess + "...");
theModel.AssignUuids();
MTKConverter_ProcessType aProcessType = ProcessType(theProcess);
switch (aProcessType)
{
case MTKConverter_PT_WallThickness:
{
MTKConverter_WallThicknessProcessor aProcessor = new MTKConverter_WallThicknessProcessor(800);
ApplyProcessorToModel(theModel, theReport, aProcessor);
break;
}
case MTKConverter_PT_MachiningMilling:
{
MTKConverter_MachiningProcessor aProcessor = new MTKConverter_MachiningProcessor(Machining_OperationType.Machining_OT_Milling);
ApplyProcessorToModel(theModel, theReport, aProcessor);
break;
}
case MTKConverter_PT_MachiningTurning:
{
MTKConverter_MachiningProcessor aProcessor = new MTKConverter_MachiningProcessor(Machining_OperationType.Machining_OT_LatheMilling);
ApplyProcessorToModel(theModel, theReport, aProcessor);
break;
}
case 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_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_PT_Undefined:
default: return MTKConverter_ReturnCode.MTKConverter_RC_InvalidArgument;
}
return MTKConverter_ReturnCode.MTKConverter_RC_OK;
}
private MTKConverter_ReturnCode Export(String theFolderPath, Model theModel,
MTKConverter_Report theReport, Model theProcessModel)
{
System.out.print("Exporting " + theFolderPath + "...");
File directory = new File (theFolderPath);
directory.mkdirs();
UTF16String aModelPath = new UTF16String(theFolderPath + "/" + theModel.Name() + ".mtkweb" + "/scenegraph.mtkweb");
if (!theModel.Save(aModelPath, Model.FileFormatType.MTKWEB))
{
System.out.println("\nERROR: Failed to export " + aModelPath + ". 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))
{
System.out.println("\nERROR: Failed to export " + aProcessModelPath + ". Exiting");
return MTKConverter_ReturnCode.MTKConverter_RC_ExportError;
}
}
UTF16String aJsonPath = new UTF16String(theFolderPath + "/process_data.json");
if (!theReport.WriteToJSON(aJsonPath))
{
System.out.println("\nERROR: Failed to create JSON file " + aJsonPath + ". Exiting");
return MTKConverter_ReturnCode.MTKConverter_RC_ExportError;
}
return MTKConverter_ReturnCode.MTKConverter_RC_OK;
}
}

MTKConverter.java

// ****************************************************************************
// $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.
//
// ****************************************************************************
import cadex.*;
public class MTKConverter {
static {
try {
System.loadLibrary("CadExMTK");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String[] args) {
String aKey = MTKLicenseKey.Value();
// Activate the license (the key must be defined in MTKLicenseKey.java)
if (!LicenseManager.Activate(aKey)) {
System.out.println("Failed to activate Manufacturing Toolkit license.");
System.exit(1);
}
MTKConverter_Application anApp = new MTKConverter_Application();
System.exit(anApp.Run(args).GetValue());
}
}