#include <cadex/Base/UTF16String.hxx>
#include <cadex/Drawing/Drawing.hxx>
#include <cadex/Drawing/Geometry.hxx>
#include <cadex/Drawing/View.hxx>
#include <cadex/Geom/Line2d.hxx>
#include <cadex/Geom/Point2d.hxx>
#include <cadex/LicenseManager_Activate.h>
#include <cadex/Nesting_Computer.hxx>
#include <cadex/Nesting_ComputerParameters.hxx>
#include <cadex/Nesting_Data.hxx>
#include <iostream>
#include <vector>
#include "../../mtk_license.cxx"
using namespace std;
class Pattern
{
public:
myName (theName),
myNumber (theNumber)
{
myDrawingView.Add (theShape);
}
size_t myNumber;
};
using PatternVector = vector<Pattern>;
{
aL1.SetTrim (0, theWidth);
aL2.SetTrim (0, theHeight);
aL3.SetTrim (0, theWidth);
aL4.SetTrim (0, theHeight);
return aRectangle;
}
void PrintPatternsInfo (const PatternVector& thePatterns)
{
cout << "------- Patterns Info -------" << endl;
for (const auto& aPattern : thePatterns) {
cout << aPattern.myName << ": " << aPattern.myNumber << endl;
}
}
{
cout << endl;
cout << "------- Nesting Info -------" << endl;
double aTotalEfficiency = 0.0;
double aTotalScrap = 0.0;
const auto& aSheets = theData.
Sheets();
for (size_t i = 0; i < aSheets.size(); ++i) {
cout << "#" << i << " Sheet" << endl;
cout << " Nested Parts: " << aSheets[i].NestedParts() << endl;
aTotalScrap += aSheets[i].Scrap();
cout << " Scrap: " << aSheets[i].Scrap() * 100 << "%" << endl;
aTotalEfficiency += aSheets[i].PlacementEfficiency();
cout << " Placement Efficiency: " << aSheets[i].PlacementEfficiency() * 100 << "%" << endl;
cout << endl;
}
cout << "Average Scrap: " << aTotalScrap / aSheets.size() * 100 << "%" << endl;
cout << "Average Placement Efficiency: " << aTotalEfficiency / aSheets.size() * 100 << "%" << endl;
}
int main()
{
auto aKey = MTKLicenseKey::Value();
if (!CADExLicense_Activate (aKey)) {
cerr << "Failed to activate Manufacturing Toolkit license." << endl;
return 1;
}
Nesting_ComputerParameters aParams;
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);
auto aPatterns = PatternVector { Pattern (CreateRectangle (50.0, 50.0), "Rectangle 50x50", 1),
Pattern (CreateRectangle (20.0, 10.0), "Rectangle 20x10", 10) };
PrintPatternsInfo (aPatterns);
for (const auto& aPattern : aPatterns) {
aComputer.
AddPattern (aPattern.myDrawingView, aPattern.myNumber);
}
PrintNestingInfo (aData);
return 0;
}
Describes drawing elements composed of 2D curves.
Definition CurveSet.cs:20
void AddCurve(cadex.Geom.Curve2d theCurve)
Adds a curve to the element.
Definition CurveSet.cs:62
Represents a view on a drawing sheet.
Definition View.cs:24
Defines a 2D Direction.
Definition Direction2d.cs:17
Defines 2D line.
Definition Line2d.cs:19
Defines a 3D point.
Definition Point2d.cs:17
The nesting analyzing tool.
Definition Nesting_Computer.cs:24
void AddMaterial(double theLength, double theWidth, uint theQuantity)
Configure material in which the patterns will be nested.
Definition Nesting_Computer.cs:95
cadex.Nesting_Data Perform(cadex.ProgressStatus theProgressStatus)
Runs analyzing process for loaded patterns and materials.
Definition Nesting_Computer.cs:132
void AddPattern(cadex.Drawing.View theDrawing, uint theQuantity)
Load pattern theDrawing and its quantity theQuantity that will be nested.
Definition Nesting_Computer.cs:85
Contains information about nesting sheets.
Definition Nesting_Data.cs:20
cadex.Collections.Nesting_SheetList Sheets()
Returns the result sheets.
Definition Nesting_Data.cs:79
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition UTF16String.cs:17
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition BaseObject.cs:12