#include <cadex/LicenseManager_Activate.h>
#include <cadex/ModelAlgo_ValidationProperty.hxx>
#include <cadex/ModelData_Body.hxx>
#include <cadex/ModelData_BodyList.hxx>
#include <cadex/ModelData_BRepRepresentation.hxx>
#include <cadex/ModelData_Drawing.hxx>
#include <cadex/ModelData_ModelReader.hxx>
#include <cadex/ModelData_ModelWriter.hxx>
#include <cadex/ModelData_SceneGraphElementUniqueVisitor.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 "../../../cadex_license.cxx"
#include "../../../mtk_license.cxx"
using namespace std;
{
if (!aDrawing) {
return false;
}
bool aRes = aWriter.
Write (aDrawingModel, theFilePath);
return aRes;
}
{
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;
}
{
if (!theFlatPattern) {
cerr << " Failed to create flat pattern.";
return;
}
PrintFlatPattern (theFlatPattern);
if (WriteToDrawing (theFlatPattern, theDrawingFileName)) {
cout << " A drawing of the flat pattern has been saved to " << theDrawingFileName << endl;
} else {
cerr << " Failed to save drawing of the flat pattern to " << theDrawingFileName << endl;
}
}
{
double aVolume = ModelAlgo_ValidationProperty::ComputeVolume (theShape);
double aSurfaceArea = ModelAlgo_ValidationProperty::ComputeSurfaceArea (theShape);
double aThickness = aVolume / (aSurfaceArea / 2.);
return aThickness;
}
{
public:
myDrawingFolderPath (theDrawingFolderPath)
{}
{
if (aBRep) {
const auto& aBodyList = aBRep.
Get();
for (size_t i = 0, n = aBodyList.Size(); i < n; ++i) {
const auto& aBody = aBodyList[i];
while (aShapeIt.HasNext()) {
const auto& aShape = aShapeIt.Next();
if (aShape.Type() == ModelData_ST_Solid) {
cout << "Part #" << myPartIndex << " [\"" << aPartName << "\"] - solid #" << std::to_string (i) << " has:" << endl;
ProcessSolid (ModelData_Solid::Cast (aShape), aPartName, i);
} else if (aShape.Type() == ModelData_ST_Shell) {
cout << "Part #" << myPartIndex << " [\"" << aPartName << "\"] - shell #" << std::to_string (i) << " has:" << endl;
ProcessShell (ModelData_Shell::Cast (aShape), aPartName, i);
}
}
}
}
++myPartIndex;
}
{
double aThickness = CalculateInitialThicknessValue (theSolid);
auto aFlatPattern = myUnfolder.Perform (theSolid, aThickness);
Base_UTF16String aFileName = DrawingFileName (thePartName, theShapeIndex,
"solid");
PrintFlatPatternAndWriteToDrawing (aFlatPattern, aFileName);
}
{
auto aFlatPattern = myUnfolder.Perform (theShell);
Base_UTF16String aFileName = DrawingFileName (thePartName, theShapeIndex,
"shell");
PrintFlatPatternAndWriteToDrawing (aFlatPattern, aFileName);
}
private:
{
Base_UTF16String aShapeName = theShapeName +
" " + std::to_string (theShapeIndex).c_str();
Base_UTF16String aFileName = myDrawingFolderPath +
"/" + aPartName +
" - " + aShapeName +
" - drawing.dxf";
return aFileName;
}
size_t myPartIndex = 0;
};
int main (int argc, char* argv[])
{
auto aKey = LicenseKey::Value();
auto anMTKKey = MTKLicenseKey::Value();
if (!CADExLicense_Activate (aKey)) {
cerr << "Failed to activate CAD Exchanger license." << endl;
return 1;
}
if (!CADExLicense_Activate (anMTKKey)) {
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;
}
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition: Base_UTF16String.hxx:34
bool IsEmpty() const
Returns true if the string is empty.
Definition: Base_UTF16String.cxx:233
const ModelData_BodyList & Get() const
Returns an associated topological object.
Definition: ModelData_BRepRepresentation.cxx:626
Base_UTF16String Name() const
Definition: ModelData_BaseObject.cxx:218
Represents a single 2D drawing of a model.
Definition: ModelData_Drawing.hxx:37
Element visitor with empty implementation.
Definition: ModelData_Model.hxx:113
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:43
void SetDrawing(const ModelData_Drawing &theDrawing)
Sets the drawing of the model.
Definition: ModelData_Model.cxx:864
const Base_UTF16String & Name() const
Returns a model name.
Definition: ModelData_Model.cxx:358
void Accept(ElementVisitor &theVisitor) const
Accepts a visitor.
Definition: ModelData_Model.cxx:882
Reads any format that CAD Exchanger can import.
Definition: ModelData_ModelReader.hxx:33
bool Read(const Base_UTF16String &theFilePath, ModelData_Model &theModel)
Reads the file at the specified path into the specified model.
Definition: ModelData_ModelReader.cxx:182
Writes any format that CAD Exchanger can export.
Definition: ModelData_ModelWriter.hxx:33
bool Write(const ModelData_Model &theModel, const Base_UTF16String &theFilePath)
Writes the specified model to the file at the specified path.
Definition: ModelData_ModelWriter.cxx:143
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:35
ModelData_BRepRepresentation BRepRepresentation() const
Definition: ModelData_Part.cxx:360
Defines a visitor that visits each unique element only once.
Definition: ModelData_SceneGraphElementUniqueVisitor.hxx:33
Iterates over subshapes in a shape.
Definition: ModelData_Shape.hxx:41
Base class of topological shapes.
Definition: ModelData_Shape.hxx:37
Defines a connected set of faces.
Definition: ModelData_Shell.hxx:31
Defines a topological solid.
Definition: ModelData_Solid.hxx:31
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22