#include <cadex/LicenseManager_Activate.h>
#include <cadex/Measurements/ValidationProperties.hxx>
#include <cadex/ModelData/Body.hxx>
#include <cadex/ModelData/Model.hxx>
#include <cadex/ModelData/ModelReader.hxx>
#include <cadex/ModelData/Part.hxx>
#include <cadex/ModelData/Shell.hxx>
#include <cadex/ModelData/Solid.hxx>
#include <cadex/SheetMetal_FlatPattern.hxx>
#include <cadex/SheetMetal_Unfolder.hxx>
#include <iostream>
#include <vector>
#include "../../mtk_license.cxx"
using namespace std;
{
if (!theFlatPattern) {
cerr << " Failed to create flat pattern.";
return;
}
cout << " Flat Pattern with:" << endl;
cout <<
" length: " << theFlatPattern.
Length() <<
" mm" << endl;
cout <<
" width: " << theFlatPattern.
Width() <<
" mm" << endl;
cout <<
" thickness: " << theFlatPattern.
Thickness() <<
" mm" << endl;
cout <<
" perimeter: " << theFlatPattern.
Perimeter() <<
" mm" << endl;
}
{
public:
PartProcessor (
const UTF16String& theDrawingFolderPath) :
myDrawingFolderPath (theDrawingFolderPath)
{}
{
size_t aBodyNumber = 0;
auto aBodies = thePart.
Bodies();
for (const auto& aBody : aBodies) {
while (aShapeIt.HasNext()) {
const auto& aShape = aShapeIt.Next();
if (aShape.Type() == ModelData::ShapeType::Solid) {
cout << "Part #" << myPartIndex << " [\"" << aPartName << "\"] - solid #" << std::to_string (aBodyNumber) << " has:" << endl;
ProcessSolid (ModelData::Solid::Cast (aShape), aPartName, aBodyNumber);
} else if (aShape.Type() == ModelData::ShapeType::Shell) {
cout << "Part #" << myPartIndex << " [\"" << aPartName << "\"] - shell #" << std::to_string (aBodyNumber) << " has:" << endl;
ProcessShell (ModelData::Shell::Cast (aShape), aPartName, aBodyNumber);
}
}
++aBodyNumber;
}
++myPartIndex;
}
{
auto aFlatPattern = myUnfolder.Perform (theSolid);
PrintFlatPatternInfo (aFlatPattern);
}
{
auto aFlatPattern = myUnfolder.Perform (theShell);
PrintFlatPatternInfo (aFlatPattern);
}
private:
{
UTF16String aPartName =
UTF16String (
"Part ") + std::to_string (myPartIndex).c_str() +
" [" + thePartName +
"]";
UTF16String aShapeName = theShapeName +
" " + std::to_string (theShapeIndex).c_str();
UTF16String aFileName = myDrawingFolderPath +
"/" + aPartName +
" - " + aShapeName +
" - drawing.dxf";
return aFileName;
}
size_t myPartIndex = 0;
};
int main (int argc, char* argv[])
{
auto aKey = MTKLicenseKey::Value();
if (!CADExLicense_Activate (aKey)) {
cerr << "Failed to activate Manufacturing Toolkit license." << endl;
return 1;
}
if (argc != 3) {
cerr << "Usage: " << argv[0] << " <input_file> <output_folder>, where:" << endl;
cerr << " <input_file> is a name of the file to be read" << endl;
cerr << " <output_folder> is a name of the folder where DXF files with drawing to be written" << endl;
return 1;
}
const char* aSource = argv[1];
const char* aDrawingPath = argv[2];
if (!aReader.
Read (aSource, aModel)) {
cerr << "Failed to read the file " << aSource << endl;
return 1;
}
cout <<
"Model: " << aModel.
Name() <<
"\n" << endl;
PartProcessor aPartProcessor (aDrawingPath);
return 0;
}
UTF16String Name() const
Returns a name.
Definition ModelElement.cxx:55
Defines a visitor that visits each unique element only once.
Definition ModelElementVisitor.hxx:87
Element visitor with empty implementation.
Definition ModelElementVisitor.hxx:64
Provides MTK data model.
Definition Model.hxx:40
UTF16String Name() const
Returns a model name.
Definition Model.cxx:250
void Accept(ModelElementVisitor &theVisitor) const
Accepts a visitor.
Definition Model.cxx:270
Reads STEP and native format.
Definition ModelReader.hxx:29
bool Read(const UTF16String &theFilePath, ModelData::Model &theModel)
Reads the file at the specified path into the specified model.
Definition ModelReader.cxx:227
Defines a leaf node in the scene graph hiearchy.
Definition Part.hxx:34
Iterates over subshapes in a shape.
Definition ShapeIterator.hxx:32
Defines a connected set of faces.
Definition Shell.hxx:32
Defines a topological solid.
Definition Solid.hxx:32
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition UTF16String.hxx:30
bool IsEmpty() const
Returns true if the string is empty.
Definition UTF16String.cxx:337
Defines classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30