#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;
}
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 Drawing/Geometry.hxx:43
void AddCurve(const Geom::Curve2d &theCurve)
Adds a curve to the element.
Definition Drawing/Geometry.cxx:71
Represents a view on a drawing sheet.
Definition View.hxx:38
Defines a 2D Direction.
Definition Direction2d.hxx:32
Defines 2D line.
Definition Line2d.hxx:32
Defines a 3D point.
Definition Point2d.hxx:34
The nesting analyzing tool.
Definition Nesting_Computer.hxx:41
void AddMaterial(double theLength, double theWidth, size_t theQuantity)
Definition Nesting_Computer.cxx:86
Nesting_Data Perform(const cadex::ProgressStatus &theProgressStatus=cadex::ProgressStatus())
Definition Nesting_Computer.cxx:126
void AddPattern(const Drawing::View &theDrawing, size_t theQuantity)
Definition Nesting_Computer.cxx:76
Defines parameters used in nesting process.
Definition Nesting_ComputerParameters.hxx:34
void SetPartToPartDistance(double thePartToPartDistance)
Definition Nesting_ComputerParameters.cxx:54
void SetIterationCount(size_t theIterationCount)
Definition Nesting_ComputerParameters.cxx:76
void SetCurveTolerance(double theCurveTolerance)
Definition Nesting_ComputerParameters.cxx:142
void SetPartToSheetBoundaryDistance(double thePartToSheetBoundaryDistance)
Definition Nesting_ComputerParameters.cxx:164
void SetMutationRate(double theMutationRate)
Definition Nesting_ComputerParameters.cxx:120
void SetRotationCount(size_t theRotationCount)
Definition Nesting_ComputerParameters.cxx:227
void SetMirrorControl(bool theIsMirrorControl)
Definition Nesting_ComputerParameters.cxx:206
void SetGenerationSize(size_t theGenerationSize)
Definition Nesting_ComputerParameters.cxx:98
Contains information about nesting sheets.
Definition Nesting_Data.hxx:39
const std::vector< Nesting_Sheet > & Sheets() const
Definition Nesting_Data.cxx:70
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition UTF16String.hxx:30
Defines classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30