using System;
using System.Collections.Generic;
namespace nesting_computer
{
class Pattern
{
public Pattern(
CurveSet theShape,
string theName, uint theNumber)
{
myDrawingView.Add(theShape);
myName = theName;
myNumber = theNumber;
}
public string myName;
public uint myNumber;
}
class Program
{
static int Main()
{
string aKey = MTKLicenseKey.Value();
if (!LicenseHelper.SetupRuntimeKey())
{
return 1;
}
try
{
}
{
Console.WriteLine(
"Failed to activate Manufacturing Toolkit license: " + theException.
what());
return 1;
}
aParams.SetIterationCount(10);
aParams.SetGenerationSize(10);
aParams.SetMutationRate(0.5);
aParams.SetPartToPartDistance(1.0);
aParams.SetPartToSheetBoundaryDistance(1.0);
aParams.SetMirrorControl(false);
aParams.SetRotationCount(4);
aParams.SetCurveTolerance(10);
aComputer.SetParameters(aParams);
aComputer.AddMaterial(100.0, 100.0, 1);
var aPatterns = new List<Pattern>
{
new Pattern(CreateRectangle(50.0, 50.0), "Rectangle 50x50", 1),
new Pattern(CreateRectangle(20.0, 10.0), "Rectangle 20x10", 10)
};
PrintPatternsInfo(aPatterns);
foreach (var aPattern in aPatterns)
{
aComputer.AddPattern(aPattern.myDrawingView, aPattern.myNumber);
}
PrintNestingInfo(aData);
return 0;
}
static CurveSet CreateRectangle(
double theWidth,
double theHeight)
{
aL1.SetTrim(0, theWidth);
aL2.SetTrim(0, theHeight);
aL3.SetTrim(0, theWidth);
aL4.SetTrim(0, theHeight);
aRectangle.AddCurve(aL1);
aRectangle.AddCurve(aL2);
aRectangle.AddCurve(aL3);
aRectangle.AddCurve(aL4);
return aRectangle;
}
static void PrintPatternsInfo(List<Pattern> thePatterns)
{
Console.WriteLine("------- Patterns Info -------");
foreach (var aPattern in thePatterns)
{
Console.WriteLine($"{aPattern.myName}: {aPattern.myNumber}");
}
}
{
Console.WriteLine();
Console.WriteLine("------- Nesting Info -------");
double aTotalEfficiency = 0.0;
double aTotalScrap = 0.0;
var aSheets = theData.
Sheets();
for (int i = 0; i < aSheets.Count; ++i)
{
Console.WriteLine($"# Sheet {i}");
Console.WriteLine($" Nested Parts: {aSheets[i].NestedParts()}");
aTotalScrap += aSheets[i].Scrap();
Console.WriteLine($" Scrap: {aSheets[i].Scrap() * 100}%");
aTotalEfficiency += aSheets[i].PlacementEfficiency();
Console.WriteLine($" Placement Efficiency: {aSheets[i].PlacementEfficiency() * 100}%");
Console.WriteLine();
}
Console.WriteLine($"Average Scrap: {aTotalScrap / aSheets.Count * 100}%");
Console.WriteLine($"Average Placement Efficiency: {aTotalEfficiency / aSheets.Count * 100}%");
}
}
}
Base class for all public classes.
Definition BaseObject.hxx:33
Describes drawing elements composed of 2D curves.
Definition Drawing/Geometry.hxx:43
Represents a view on a drawing sheet.
Definition View.hxx:37
Defines a 2D Direction.
Definition Direction2d.hxx:30
Defines 2D line.
Definition Line2d.hxx:30
Defines a 3D point.
Definition Point2d.hxx:32
The nesting analyzing tool.
Definition Nesting_Computer.hxx:40
Defines parameters used in nesting process.
Definition Nesting_ComputerParameters.hxx:33
Contains information about nesting sheets.
Definition Nesting_Data.hxx:38
const std::vector< Nesting_Sheet > & Sheets() const
Returns the result sheets.
Definition Nesting_Data.cxx:75
Defines an exception thrown by a license manager when a valid license could not be acquired.
Definition LicenseError.hxx:37
const char * what() const noexcept override
Returns an error string.
Definition LicenseError.cxx:50
Provides MTK licensing activation and deactivation API.
Definition LicenseManager.hxx:33
static bool Deactivate()
Closes the active licensing session.
Definition LicenseManager.cxx:640
static bool Activate(const std::string &theDeveloperKey)
Activates MTK licensing using the development license key.
Definition LicenseManager.cxx:191
Contains classes, types and enums related to drawings.
Contains classes, types, enums, and functions related to geometric entities.
The mtk namespace is intended to become the primary namespace for MTK and replace direct use of the c...
Definition LicenseError.hxx:27
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseError.hxx:27
Definition BaseObject.hxx:38