using System;
using System.Collections.Generic;
namespace unfolder
{
class Program
{
static int Main(string[] args)
{
cadex.helpers.LoadLibrarySearchDirectory.SetupDllDirectory();
string aKey = LicenseKey.Value();
string anMTKKey = MTKLicenseKey.Value();
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 != 2)
{
Console.WriteLine("Usage: " +
$"{System.Reflection.Assembly.GetExecutingAssembly().Location} <input_file> <output_folder>, where:");
Console.WriteLine($" <input_file> is a name of the file to be read");
Console.WriteLine($" <output_folder> is a name of the folder where DXF files with drawing to be written");
return 1;
}
string aSource = args[0];
string aDrawingPath = args[1];
Console.WriteLine($"Failed to read the file {aSource}");
return 1;
}
Console.WriteLine($"Model: {aModel.Name()}\n");
var aPartProcessor = new PartProcessor(aDrawingPath);
return 0;
}
{
public PartProcessor(string theDrawingFolderPath)
{
myDrawingFolderPath = theDrawingFolderPath;
}
{
if (aBRep != null)
{
for (uint i = 0; i < aBodyList.
Size(); ++i)
{
while (aShapeIt.HasNext())
{
var aShape = aShapeIt.
Next();
{
Console.Write($"Part #{myPartIndex} [\"{aPartName}\"] - solid #{i} has:\n");
}
{
Console.Write($"Part #{myPartIndex} [\"{aPartName}\"] - shell #{i} has:\n");
}
}
}
}
++myPartIndex;
}
public void ProcessSolid(
ModelData_Solid theSolid,
string thePartName, uint theShapeIndex)
{
double aThickness = CalculateInitialThicknessValue(theSolid);
Base_UTF16String aFileName = DrawingFileName(thePartName, theShapeIndex,
"solid");
PrintFlatPatternAndWriteToDrawing(aFlatPattern, aFileName);
}
public void ProcessShell(
ModelData_Shell theShell,
string thePartName, uint theShapeIndex)
{
Base_UTF16String aFileName = DrawingFileName(thePartName, theShapeIndex,
"shell");
PrintFlatPatternAndWriteToDrawing(aFlatPattern, aFileName);
}
private Base_UTF16String DrawingFileName(
string thePartName, uint theShapeIndex,
string theShapeName)
{
string aPartName = "Part " + myPartIndex.ToString() + " [" + thePartName + "]";
string aShapeName = theShapeName + " " + theShapeIndex.ToString();
return aFileName;
}
string myDrawingFolderPath;
private uint myPartIndex = 0;
}
{
{
Console.WriteLine($" Failed to create flat pattern.");
return;
}
PrintFlatPattern(theFlatPattern);
if (WriteToDrawing(theFlatPattern, theDrawingFileName))
{
Console.WriteLine($" A drawing of the flat pattern has been saved to {theDrawingFileName.Data()}");
}
else
{
Console.WriteLine($" Failed to save drawing of the flat pattern to {theDrawingFileName.Data()}");
}
}
{
Console.WriteLine($" Flat Pattern with:");
Console.WriteLine($" length: {theFlatPattern.Length()} mm");
Console.WriteLine($" width: {theFlatPattern.Width()} mm");
Console.WriteLine($" thickness: {theFlatPattern.Thickness()} mm");
Console.WriteLine($" perimeter: {theFlatPattern.Perimeter()} mm");
}
{
if (aDrawing == null)
{
return false;
}
aDrawingModel.SetDrawing(aDrawing);
bool aRes = aWriter.Write(aDrawingModel, theFilePath);
return aRes;
}
{
double aThickness = aVolume / (aSurfaceArea / 2.0);
return aThickness;
}
}
}
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
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
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
Represents a single 2D drawing of a model.
Definition: ModelData_Drawing.hxx:37
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:43
void Accept(ElementVisitor &theVisitor) const
Accepts a visitor.
Definition: ModelData_Model.cxx:882
Reads any format that CAD Exchanger can import.
Definition: ModelData_ModelReader.hxx:33
Writes any format that CAD Exchanger can export.
Definition: ModelData_ModelWriter.hxx:33
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:35
ModelData_BRepRepresentation BRepRepresentation() const
Definition: ModelData_Part.cxx:360
Defines a visitor that visits each unique element only once.
Definition: ModelData_SceneGraphElementUniqueVisitor.hxx:33
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
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22
ModelData_ShapeType
Defines shape type.
Definition: ModelData_ShapeType.hxx:25