Hide menu
Loading...
Searching...
No Matches
sheet_metal/feature_recognizer/Program.cs

Refer to the Sheet Metal Feature Recognizer Example

feature_group.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex;
using System;
using System.Collections.Generic;
using FeatureMapType = System.Collections.Generic.SortedDictionary<cadex.MTKBase_Feature, uint>;
namespace feature_group
{
class FeatureComparer : IComparer<MTKBase_Feature>
{
public int Compare(MTKBase_Feature theA, MTKBase_Feature theB)
{
bool anALessThanB = aComparator.Apply(theA, theB);
if (anALessThanB)
{
return -1;
}
bool aBLessThanA = aComparator.Apply(theB, theA);
if (aBLessThanA)
{
return 1;
}
return 0;
}
}
public struct Pair
{
public Pair(double theFirst, double theSecond)
{
First = theFirst;
Second = theSecond;
}
public double First { get; }
public double Second { get; }
public override string ToString() => $"{First} x {Second}";
}
public struct Dimension
{
public Dimension(double theL, double theW, double theD)
{
L = theL;
W = theW;
D = theD;
}
public double L { get; }
public double W { get; }
public double D { get; }
public override string ToString() => $"{L} x {W} x {D}";
}
public struct Direction
{
public Direction(double theX, double theY, double theZ)
{
X = theX;
Y = theY;
Z = theZ;
}
public double X { get; }
public double Y { get; }
public double Z { get; }
public override string ToString() => $"({FormattedString(X)}, {FormattedString(Y)}, {FormattedString(Z)})";
private string FormattedString(double theValue)
{
System.Globalization.CultureInfo aCI = new System.Globalization.CultureInfo("en-US");
return string.Format(aCI, "{0:0.00}", theValue);
}
}
class FeatureGroupManager
{
public FeatureGroupManager()
{
myGroups = new List<FeatureGroup>();
}
private class FeatureGroup
{
public FeatureGroup(string theName, string theSubgroupName, bool theHasParameters)
{
myName = theName;
mySubgroupName = theSubgroupName;
myHasParameters = theHasParameters;
myFeatureSubgroups = new FeatureMapType(new FeatureComparer());
}
public uint FeatureCount()
{
uint aCount = 0;
foreach (var i in myFeatureSubgroups)
{
aCount += i.Value;
}
return aCount;
}
public string myName;
public string mySubgroupName;
public bool myHasParameters;
public FeatureMapType myFeatureSubgroups;
}
private class FeatureGroupComparer : IComparer<FeatureGroup>
{
public int Compare(FeatureGroup theA, FeatureGroup theB)
{
string anAName = theA.myName;
string aBName = theB.myName;
if (anAName == aBName)
{
return 0;
}
FeatureMapType anAFeatureSubgroups = theA.myFeatureSubgroups;
FeatureMapType aBFeatureSubgroups = theB.myFeatureSubgroups;
if (anAFeatureSubgroups.Count == 0 || aBFeatureSubgroups.Count == 0)
{
return anAName.CompareTo(aBName);
}
MTKBase_Feature anAFeature = new MTKBase_Feature();
MTKBase_Feature aBFeature = new MTKBase_Feature();
foreach (var i in anAFeatureSubgroups)
{
anAFeature = i.Key;
break;
}
foreach (var i in aBFeatureSubgroups)
{
aBFeature = i.Key;
break;
}
FeatureComparer aFeatureComparator = new FeatureComparer();
return aFeatureComparator.Compare(anAFeature, aBFeature);
}
}
private List<FeatureGroup> myGroups;
public void AddFeature(string theGroupName, string theSubgroupName, bool theHasParameters, MTKBase_Feature theFeature)
{
//find or create
int aRes = myGroups.FindIndex(theGroup => theGroup.myName == theGroupName);
if (aRes == -1)
{
myGroups.Add(new FeatureGroup(theGroupName, theSubgroupName, theHasParameters));
aRes = myGroups.Count - 1;
}
//update
FeatureGroup aGroup = myGroups[aRes];
FeatureMapType aSubgroups = aGroup.myFeatureSubgroups;
if (aSubgroups.ContainsKey(theFeature))
{
++aSubgroups[theFeature];
}
else
{
aSubgroups[theFeature] = 1;
}
}
public void Print(string theFeatureType, Action<MTKBase_Feature> thePrintFeatureParameters)
{
myGroups.Sort(new FeatureGroupComparer());
uint aTotalCount = 0;
foreach (var i in myGroups)
{
uint aFeatureCount = i.FeatureCount();
aTotalCount += aFeatureCount;
Console.WriteLine($" {i.myName}: {aFeatureCount}");
if (!i.myHasParameters)
{
continue;
}
string aSubgroupName = i.mySubgroupName;
foreach (var j in i.myFeatureSubgroups)
{
Console.WriteLine($" {j.Value} {aSubgroupName} with");
thePrintFeatureParameters(j.Key);
}
}
Console.WriteLine($"\n Total {theFeatureType}: {aTotalCount}\n");
}
public static void PrintFeatureParameter<T>(string theName, T theValue, string theUnits)
{
Console.WriteLine($" {theName}: {theValue} {theUnits}");
}
}
}
Provides possibility to compare MTK based features depending on their type and parameters.
Definition: MTKBase_FeatureComparator.hxx:29
Describes a base class of MTK based features.
Definition: MTKBase_Feature.hxx:34
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22

shape_processor.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex;
using System;
namespace shape_processor
{
abstract class ShapeProcessor : ModelData_Model.VoidElementVisitor
{
public override void Apply(ModelData_Part thePart)
{
var aPartName = thePart.Name().IsEmpty() ? new Base_UTF16String("noname") : thePart.Name();
var aBRep = thePart.BRepRepresentation();
if (aBRep != null)
{
// Looking for a suitable body
ModelData_BodyList aBodyList = aBRep.Get();
for (uint i = 0; i < aBodyList.Size(); ++i)
{
ModelData_Body aBody = aBodyList.Element(i);
var aShapeIt = new ModelData_Shape.Iterator(aBody);
while (aShapeIt.HasNext())
{
var aShape = aShapeIt.Next();
if (aShape.Type() == ModelData_ShapeType.ModelData_ST_Solid)
{
Console.Write($"Part #{myPartIndex} [\"{aPartName}\"] - solid #{i} has:\n");
ProcessSolid(ModelData_Solid.Cast(aShape));
}
else if (aShape.Type() == ModelData_ShapeType.ModelData_ST_Shell)
{
Console.Write($"Part #{myPartIndex} [\"{aPartName}\"] - shell #{i} has:\n");
ProcessShell(ModelData_Shell.Cast(aShape));
}
}
++myPartIndex;
}
}
}
public abstract void ProcessSolid(ModelData_Solid theSolid);
public abstract void ProcessShell(ModelData_Shell theShell);
private uint myPartIndex = 0;
}
abstract class SolidProcessor : ModelData_Model.VoidElementVisitor
{
public override void Apply(ModelData_Part thePart)
{
var aPartName = thePart.Name().IsEmpty() ? new Base_UTF16String ("noname") : thePart.Name();
var aBRep = thePart.BRepRepresentation();
if (aBRep != null)
{
// Looking for a suitable body
ModelData_BodyList aBodyList = aBRep.Get();
for (uint i = 0; i < aBodyList.Size(); ++i)
{
ModelData_Body aBody = aBodyList.Element(i);
var aShapeIt = new ModelData_Shape.Iterator(aBody);
while (aShapeIt.HasNext())
{
var aShape = aShapeIt.Next();
if (aShape.Type() == ModelData_ShapeType.ModelData_ST_Solid)
{
Console.Write ($"Part #{myPartIndex} [\"{aPartName}\"] - solid #{i} has:\n");
ProcessSolid(ModelData_Solid.Cast(aShape));
}
}
++myPartIndex;
}
}
}
public abstract void ProcessSolid(ModelData_Solid theSolid);
private uint myPartIndex = 0;
}
abstract class SolidAndMeshProcessor : ModelData_Model.VoidElementVisitor
{
public override void Apply(ModelData_Part thePart)
{
string aPartName = thePart.Name().IsEmpty() ? "noname" : thePart.Name().Data();
var aBRep = thePart.BRepRepresentation();
var aPolyRep = thePart.PolyRepresentation(ModelData_RepresentationMask.ModelData_RM_Poly);
if (aBRep != null)
{
// Looking for a suitable body
ModelData_BodyList aBodyList = aBRep.Get();
for (uint i = 0; i < aBodyList.Size(); ++i)
{
ModelData_Body aBody = aBodyList.Element(i);
var aShapeIt = new ModelData_Shape.Iterator(aBody);
while (aShapeIt.HasNext())
{
var aShape = aShapeIt.Next();
if (aShape.Type() == ModelData_ShapeType.ModelData_ST_Solid)
{
Console.Write($"Part #{myPartIndex} [\"{aPartName}\"] - solid #{i} has:\n");
ProcessSolid(ModelData_Solid.Cast(aShape), aPartName, i);
}
}
}
}
else if (aPolyRep != null)
{
var aPolyList = aPolyRep.Get();
for (uint i = 0; i < aPolyList.Size(); ++i)
{
var aPVS = aPolyList.Element(i);
if (aPVS.TypeId() == ModelData_IndexedTriangleSet.GetTypeId())
{
Console.Write($"Part #{myPartIndex} [\"{aPartName}\"] - mesh #{i} has:\n");
ProcessMesh(ModelData_IndexedTriangleSet.Cast(aPVS), aPartName, i);
}
}
}
++myPartIndex;
}
public abstract void ProcessSolid(ModelData_Solid theSolid, string thePartName, uint theShapeIndex);
public abstract void ProcessMesh(ModelData_IndexedTriangleSet theMesh, string thePartName, uint theShapeIndex);
protected uint myPartIndex = 0;
}
}
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition: Base_UTF16String.hxx:34
const UTF16 * Data() const
Returns an internal string buffer.
Definition: Base_UTF16String.cxx:126
bool IsEmpty() const
Returns true if the string is empty.
Definition: Base_UTF16String.cxx:233
Base_UTF16String Name() const
Definition: ModelData_BaseObject.cxx:218
Defines a root topological shape that can be owned by B-Rep representation.
Definition: ModelData_Body.hxx:28
Defines a list of bodies.
Definition: ModelData_BodyList.hxx:31
const ModelData_Body & Element(SizeType theIndex) const
Definition: ModelData_BodyList.cxx:177
Defines a polygonal shape consisting of triangles.
Definition: ModelData_IndexedTriangleSet.hxx:35
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:43
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:35
ModelData_BRepRepresentation BRepRepresentation() const
Definition: ModelData_Part.cxx:360
ModelData_PolyRepresentation PolyRepresentation(ModelData_RepresentationMask theRepresentationMask) const
Definition: ModelData_Part.cxx:371
Iterates over subshapes in a shape.
Definition: ModelData_Shape.hxx:41
Base class of topological shapes.
Definition: ModelData_Shape.hxx:37
Defines a connected set of faces.
Definition: ModelData_Shell.hxx:31
Defines a topological solid.
Definition: ModelData_Solid.hxx:31
ModelData_RepresentationMask
Defines a mask to filter part representations.
Definition: ModelData_RepresentationMask.hxx:25
ModelData_ShapeType
Defines shape type.
Definition: ModelData_ShapeType.hxx:25

Program.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex;
using feature_group;
using shape_processor;
using System;
namespace feature_recognizer
{
class Program
{
static int Main(string[] args)
{
// Add runtime path to CAD Exchanger libraries
cadex.helpers.LoadLibrarySearchDirectory.SetupDllDirectory();
string aKey = LicenseKey.Value();
string anMTKKey = MTKLicenseKey.Value();
// Activate the license (aKey must be defined in cadex_license.cs
// and anMTKKey should be defined in mtk_license.cs)
if (!LicenseManager.Activate(aKey))
{
Console.WriteLine("Failed to activate CAD Exchanger license.");
return 1;
}
if (!LicenseManager.Activate(anMTKKey))
{
Console.WriteLine("Failed to activate Manufacturing Toolkit license.");
return 1;
}
if (args.Length != 1)
{
Console.WriteLine("Usage: " +
$"{System.Reflection.Assembly.GetExecutingAssembly().Location} <input_file>, where:");
Console.WriteLine($" <input_file> is a name of the file to be read");
return 1;
}
string aSource = args[0];
var aModel = new ModelData_Model();
var aReader = new ModelData_ModelReader();
// Reading the file
if (!aReader.Read(new Base_UTF16String(aSource), aModel))
{
Console.WriteLine($"Failed to read the file {aSource}");
return 1;
}
Console.WriteLine($"Model: {aModel.Name()}\n");
var aPartProcessor = new PartProcessor();
var aVisitor = new ModelData_SceneGraphElementUniqueVisitor(aPartProcessor);
aModel.Accept(aVisitor);
return 0;
}
class PartProcessor : ShapeProcessor
{
public PartProcessor()
{
myRecognizer = new SheetMetal_FeatureRecognizer();
}
public override void ProcessSolid(ModelData_Solid theSolid)
{
double aThickness = CalculateInitialThicknessValue(theSolid);
var aFeatureList = myRecognizer.Perform(theSolid, aThickness);
PrintFeatures(aFeatureList);
}
public override void ProcessShell(ModelData_Shell theShell)
{
var aFeatureList = myRecognizer.Perform(theShell);
PrintFeatures(aFeatureList);
}
private SheetMetal_FeatureRecognizer myRecognizer;
}
static void PrintFeatures(MTKBase_FeatureList theFeatureList)
{
FeatureGroupManager aManager = new FeatureGroupManager();
//group by parameters to provide more compact information about features
Action<MTKBase_FeatureList> GroupByParameters = null;
GroupByParameters = new Action<MTKBase_FeatureList>((theFeatures) =>
{
for (uint i = 0; i < theFeatures.Size(); ++i)
{
MTKBase_Feature aFeature = theFeatures.Feature(i);
{
aManager.AddFeature("Bead(s)", "Bead(s)", true, aFeature);
}
else if (SheetMetal_Cutout.CompareType(aFeature))
{
aManager.AddFeature("Cutout(s)", "Cutout(s)", true, aFeature);
}
else if (SheetMetal_Louver.CompareType(aFeature))
{
aManager.AddFeature("Louver(s)", "", false, aFeature);
}
else if (SheetMetal_Bridge.CompareType(aFeature))
{
aManager.AddFeature("Bridge(s)", "Bridge(s)", true, aFeature);
}
else if (SheetMetal_Hole.CompareType(aFeature))
{
SheetMetal_Hole aHole = SheetMetal_Hole.Cast(aFeature);
aManager.AddFeature(HoleName(aHole), "Hole(s)", true, aFeature);
}
else if (SheetMetal_Bend.CompareType(aFeature))
{
SheetMetal_Bend aBend = SheetMetal_Bend.Cast(aFeature);
aManager.AddFeature(BendName(aBend), "Bend(s)", true, aFeature);
}
else if (SheetMetal_Notch.CompareType(aFeature))
{
SheetMetal_Notch aNotch = SheetMetal_Notch.Cast(aFeature);
aManager.AddFeature(NotchName (aNotch), "Notch(es)", true, aFeature);
}
else if (SheetMetal_Tab.CompareType(aFeature))
{
aManager.AddFeature("Tab(s)", "Tab(s)", true, aFeature);
}
{
SheetMetal_CompoundBend aCompoundBend = SheetMetal_CompoundBend.Cast(aFeature);
GroupByParameters(aCompoundBend.FeatureList());
}
}
});
GroupByParameters(theFeatureList);
//print
Action<MTKBase_Feature> PrintFeatureParameters = theFeature =>
{
if (SheetMetal_Bead.CompareType(theFeature))
{
SheetMetal_Bead aBead = SheetMetal_Bead.Cast(theFeature);
FeatureGroupManager.PrintFeatureParameter("depth", aBead.Depth(), "mm");
}
else if (SheetMetal_Cutout.CompareType(theFeature))
{
SheetMetal_Cutout aCutout = SheetMetal_Cutout.Cast(theFeature);
FeatureGroupManager.PrintFeatureParameter("perimeter", aCutout.Perimeter(), "mm");
}
else if (SheetMetal_Louver.CompareType(theFeature))
{
SheetMetal_Louver aLouver = SheetMetal_Louver.Cast(theFeature);
FeatureGroupManager.PrintFeatureParameter("depth", aLouver.Depth(), "mm");
}
else if (SheetMetal_Bridge.CompareType(theFeature))
{
SheetMetal_Bridge aBridge = SheetMetal_Bridge.Cast(theFeature);
FeatureGroupManager.PrintFeatureParameter("length", aBridge.Length(), "mm");
FeatureGroupManager.PrintFeatureParameter("depth", aBridge.Depth(), "mm");
}
else if (SheetMetal_Hole.CompareType(theFeature))
{
SheetMetal_Hole aHole = SheetMetal_Hole.Cast(theFeature);
ModelData_Direction anAxis = aHole.Axis().Axis();
Direction aDir = new Direction(anAxis.X(), anAxis.Y(), anAxis.Z());
FeatureGroupManager.PrintFeatureParameter("radius", aHole.Radius(), "mm");
FeatureGroupManager.PrintFeatureParameter("depth", aHole.Depth(), "mm");
FeatureGroupManager.PrintFeatureParameter("axis", aDir, "");
}
else if (SheetMetal_Bend.CompareType(theFeature))
{
SheetMetal_Bend aBend = SheetMetal_Bend.Cast(theFeature);
FeatureGroupManager.PrintFeatureParameter("radius", aBend.Radius(), "mm");
FeatureGroupManager.PrintFeatureParameter("angle", ToDegrees(aBend.Angle()), "deg");
FeatureGroupManager.PrintFeatureParameter("length", aBend.Length(), "mm");
FeatureGroupManager.PrintFeatureParameter("width", aBend.Width(), "mm");
}
else if (SheetMetal_Notch.CompareType(theFeature))
{
SheetMetal_Notch aNotch = SheetMetal_Notch.Cast(theFeature);
FeatureGroupManager.PrintFeatureParameter("length", aNotch.Length(), "mm");
FeatureGroupManager.PrintFeatureParameter("width", aNotch.Width(), "mm");
{
SheetMetal_StraightNotch aStraightNotch = SheetMetal_StraightNotch.Cast(aNotch);
FeatureGroupManager.PrintFeatureParameter ("corner fillet radius", aStraightNotch.CornerFilletRadius(), "mm");
}
else if (SheetMetal_VNotch.CompareType(aNotch))
{
SheetMetal_VNotch aVNotch = SheetMetal_VNotch.Cast(aNotch);
FeatureGroupManager.PrintFeatureParameter ("angle", ToDegrees(aVNotch.Angle()), "deg");
}
}
else if (SheetMetal_Tab.CompareType(theFeature))
{
SheetMetal_Tab aTab = SheetMetal_Tab.Cast(theFeature);
FeatureGroupManager.PrintFeatureParameter("length", aTab.Length(), "mm");
FeatureGroupManager.PrintFeatureParameter("width", aTab.Width(), "mm");
}
};
aManager.Print("features", PrintFeatureParameters);
}
static string HemTypeToString (SheetMetal_HemBendType theType)
{
switch (theType) {
case SheetMetal_HemBendType.SheetMetal_HBT_Flattened: return "Flattened Hem Bend(s)";
case SheetMetal_HemBendType.SheetMetal_HBT_Open: return "Open Hem Bend(s)";
case SheetMetal_HemBendType.SheetMetal_HBT_Teardrop: return "Teardrop Hem Bend(s)";
case SheetMetal_HemBendType.SheetMetal_HBT_Rope: return "Rope Hem Bend(s)";
case SheetMetal_HemBendType.SheetMetal_HBT_Rolled: return "Rolled Hem Bend(s)";
default:
break;
}
return "Hem Bend(s)";
}
static string BendName(SheetMetal_Bend theBend)
{
{
SheetMetal_HemBend aHemBend = SheetMetal_HemBend.Cast(theBend);
return HemTypeToString(aHemBend.Type());
}
{
return "Curved Bend(s)";
}
return "Bend(s)";
}
static string HoleName(SheetMetal_Hole theHole)
{
{
return "Complex Hole(s)";
}
return "Hole(s)";
}
static string NotchName(SheetMetal_Notch theNotch)
{
{
return "Straight Notch(es)";
}
else if (SheetMetal_VNotch.CompareType(theNotch))
{
return "V Notch(es)";
}
return "Notch(es)";
}
static double ToDegrees(double theAngleRad)
{
return theAngleRad * 180 / Math.PI;
}
//Compute approximate thickness value, which can be used as the input thickness
//value for SheetMetal_FeatureRecognizer.
static double CalculateInitialThicknessValue(ModelData_Shape theShape)
{
double aVolume = ModelAlgo_ValidationProperty.ComputeVolume(theShape);
double aSurfaceArea = ModelAlgo_ValidationProperty.ComputeSurfaceArea(theShape);
double aThickness = aVolume / (aSurfaceArea / 2.0);
return aThickness;
}
}
}
Defines a list of features.
Definition: MTKBase_FeatureList.hxx:37
const ModelData_Axis3Placement & Axis() const
Definition: MTKBase_Hole.cxx:127
double Depth() const
Definition: MTKBase_Hole.cxx:98
double Radius() const
Definition: MTKBase_Hole.cxx:78
Computes validation properties of the objects.
Definition: ModelAlgo_ValidationProperty.hxx:35
static double ComputeSurfaceArea(const ModelData_Model &theModel, bool theUseProperty=false, bool theStoreProperty=false)
Returns a surface area of a scene graph.
Definition: ModelAlgo_ValidationProperty.cxx:362
static double ComputeVolume(const ModelData_Model &theModel, bool theUseProperty=false, bool theStoreProperty=false)
Returns a volume of a scene graph.
Definition: ModelAlgo_ValidationProperty.cxx:402
const ModelData_Direction & Axis() const
Returns a Z-direction of the axis placement.
Definition: ModelData_Axis3Placement.cxx:90
Defines a 3D direction.
Definition: ModelData_Direction.hxx:180
Reads any format that CAD Exchanger can import.
Definition: ModelData_ModelReader.hxx:33
Defines a visitor that visits each unique element only once.
Definition: ModelData_SceneGraphElementUniqueVisitor.hxx:33
Describes a sheet metal bead.
Definition: SheetMetal_Bead.hxx:31
double Depth() const
Definition: SheetMetal_Bead.cxx:68
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a bead.
Definition: SheetMetal_Bead.cxx:85
Describes a bend in sheet metal.
Definition: SheetMetal_Bend.hxx:35
double Angle() const
Definition: SheetMetal_Bend.cxx:99
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a bend.
Definition: SheetMetal_Bend.cxx:142
double Width() const
Definition: SheetMetal_Bend.cxx:119
double Radius() const
Definition: SheetMetal_Bend.cxx:79
double Length() const
Returns the length of resulting bend (not blank sheet metal model). Length value returns in mm .
Definition: SheetMetal_Bend.cxx:136
Describes a sheet metal bridge feature.
Definition: SheetMetal_Bridge.hxx:31
double Depth() const
Definition: SheetMetal_Bridge.cxx:72
double Length() const
Definition: SheetMetal_Bridge.cxx:92
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a bridge.
Definition: SheetMetal_Bridge.cxx:109
Describes a sheet metal complex hole feature.
Definition: SheetMetal_ComplexHole.hxx:31
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a sheet metal complex hole.
Definition: SheetMetal_ComplexHole.cxx:77
Describes a sheet metal compound bend feature.
Definition: SheetMetal_CompoundBend.hxx:31
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is an compound bend.
Definition: SheetMetal_CompoundBend.cxx:61
Describes a sheet metal curved bend feature.
Definition: SheetMetal_CurvedBend.hxx:31
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is an curved bend.
Definition: SheetMetal_CurvedBend.cxx:59
Describes a cutout in sheet metal.
Definition: SheetMetal_Cutout.hxx:31
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a cutout.
Definition: SheetMetal_Cutout.cxx:79
double Perimeter() const
Definition: SheetMetal_Cutout.cxx:62
Provides an interface to recognizing sheet metal features tool. Is used for recognition of features s...
Definition: SheetMetal_FeatureRecognizer.hxx:38
Describes a sheet metal Hem bend feature.
Definition: SheetMetal_HemBend.hxx:32
SheetMetal_HemBendType Type() const
Definition: SheetMetal_HemBend.cxx:133
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is an hem bend.
Definition: SheetMetal_HemBend.cxx:148
Describes a circle hole drilled or punched in sheet metal.
Definition: SheetMetal_Hole.hxx:35
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a sheet metal hole.
Definition: SheetMetal_Hole.cxx:74
Describes a sheet metal louver feature.
Definition: SheetMetal_Louver.hxx:31
double Depth() const
Definition: SheetMetal_Louver.cxx:69
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a louver.
Definition: SheetMetal_Louver.cxx:86
Describes a sheet metal notch.
Definition: SheetMetal_Notch.hxx:35
double Length() const
Definition: SheetMetal_Notch.cxx:92
double Width() const
Definition: SheetMetal_Notch.cxx:72
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a notch.
Definition: SheetMetal_Notch.cxx:129
Describes a sheet metal straight notch.
Definition: SheetMetal_StraightNotch.hxx:31
double CornerFilletRadius() const
Definition: SheetMetal_StraightNotch.cxx:67
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a straight notch.
Definition: SheetMetal_StraightNotch.cxx:86
Describes a sheet metal tab.
Definition: SheetMetal_Tab.hxx:31
double Width() const
Definition: SheetMetal_Tab.cxx:71
double Length() const
Definition: SheetMetal_Tab.cxx:91
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a tab.
Definition: SheetMetal_Tab.cxx:108
Describes a sheet metal V-notch.
Definition: SheetMetal_VNotch.hxx:31
static bool CompareType(const MTKBase_Feature &theFeature)
Returns true if theFeature is a V notch.
Definition: SheetMetal_VNotch.cxx:79
double Angle() const
Definition: SheetMetal_VNotch.cxx:60
SheetMetal_HemBendType
Defines a hem bend type in sheet metal.
Definition: SheetMetal_HemBendType.hxx:29