Demonstrates how to optimize the arrangement of patterns on material sheets minimizing waste.
Overview
This example demonstrates how to optimize the layout of 2D patterns (drawings) on material sheets using the nesting tool (Nesting_Computer ). For this purpose, a console application is used, which defines nesting parameters, creates patterns, and executes the nesting process. The tool computes an optimal arrangement of parts to minimize material waste and maximize placement efficiency.
For more information about nesting, refer to the Nesting Process.
Implementation
The nesting process begins by creating an instance of the Nesting_Computer class, which serves as the primary tool for optimizing the arrangement of 2D patterns. This is followed by defining and configuring the nesting parameters using the Nesting_ComputerParameters class:
aComputer.SetParameters (aParams);
The nesting analyzing tool.
Definition Nesting_Computer.hxx:40
Defines parameters used in nesting process.
Definition Nesting_ComputerParameters.hxx:33
void SetPartToPartDistance(double thePartToPartDistance)
Sets part to part distance in mm.
Definition Nesting_ComputerParameters.cxx:53
void SetIterationCount(size_t theIterationCount)
Sets iteration count of genetic algorithm.
Definition Nesting_ComputerParameters.cxx:75
void SetCurveTolerance(double theCurveTolerance)
Sets curve tolerance used to build polygons for geentic algorithm.
Definition Nesting_ComputerParameters.cxx:141
void SetPartToSheetBoundaryDistance(double thePartToSheetBoundaryDistance)
Sets part to sheet boundary distance distance in mm.
Definition Nesting_ComputerParameters.cxx:163
void SetMutationRate(double theMutationRate)
Sets mutation rate in geentic algorithm.
Definition Nesting_ComputerParameters.cxx:119
void SetRotationCount(size_t theRotationCount)
Sets rotation count.
Definition Nesting_ComputerParameters.cxx:226
void SetMirrorControl(bool theIsMirrorControl)
Sets mirror transformation flag.
Definition Nesting_ComputerParameters.cxx:205
void SetGenerationSize(size_t theGenerationSize)
Sets generation size used in genetic algorithm.
Definition Nesting_ComputerParameters.cxx:97
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:29
The dimensions and number of sheets are defined using AddMaterial() method:
void AddMaterial(double theLength, double theWidth, size_t theQuantity)
Configure material in which the patterns will be nested.
Definition Nesting_Computer.cxx:86
A Pattern is essentially a Drawing::View combined with metadata, such as the pattern name and number:
class Pattern
{
public:
myName (theName),
myNumber (theNumber)
{
myDrawingView.Add (theShape);
}
size_t myNumber;
};
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 Unicode (UTF-16) string wrapping a standard string.
Definition UTF16String.hxx:29
Rectangular patterns are created using the CreateRectangle function and added to a PatternVector:
using PatternVector = vector<Pattern>;
{
aL1.SetTrim (0, theWidth);
aL2.SetTrim (0, theHeight);
aL3.SetTrim (0, theWidth);
aL4.SetTrim (0, theHeight);
return aRectangle;
}
auto aPatterns = PatternVector{Pattern (CreateRectangle (50.0, 50.0), "Rectangle 50x50", 1),
Pattern (CreateRectangle (20.0, 10.0), "Rectangle 20x10", 10)};
void AddCurve(const Geom::Curve2d &theCurve)
Adds a curve to the element.
Definition Drawing/Geometry.cxx:71
Defines a 2D Direction.
Definition Direction2d.hxx:30
Defines 2D line.
Definition Line2d.hxx:30
Defines a 3D point.
Definition Point2d.hxx:32
The patterns are loaded into the Nesting_Computer , which performs the nesting process and generates a Nesting_Data object containing the results.
for (const auto& aPattern : aPatterns) {
aComputer.
AddPattern (aPattern.myDrawingView, aPattern.myNumber);
}
Nesting_Data Perform(const cadex::ProgressStatus &theProgressStatus=cadex::ProgressStatus())
Runs analyzing process for loaded patterns and materials.
Definition Nesting_Computer.cxx:126
void AddPattern(const Drawing::View &theDrawing, size_t theQuantity)
Load pattern theDrawing and its quantity theQuantity that will be nested.
Definition Nesting_Computer.cxx:76
Contains information about nesting sheets.
Definition Nesting_Data.hxx:38
Example output
Below is the example output:
------- Patterns Info -------
Rectangle 50x50: 1
Rectangle 20x10: 10
------- Nesting Info -------
#0 Sheet
Nested Parts: 11
Scrap: 55%
Placement Efficiency: 90.58%
Average Scrap: 55%
Average Placement Efficiency: 90.58%
Files