#include <cadex/LicenseManager_Activate.h>
#include <cadex/Drawing/Drawing.hxx>
#include <cadex/Drawing/ElementVisitor.hxx>
#include <cadex/Drawing/Geometry.hxx>
#include <cadex/Drawing/Sheet.hxx>
#include <cadex/Drawing/View.hxx>
#include <cadex/ModelData/Model.hxx>
#include <cadex/ModelData/ModelReader.hxx>
#include <cadex/ModelData/ModelReaderParameters.hxx>
#include <iostream>
#include "../../mtk_license.cxx"
using namespace std;
class DrawingElementVisitor : public Drawing::ElementVoidVisitor
{
public:
void operator() (const Drawing::CurveSet& theElement) override
{
cout << "------- CurveSet <" << myCurveSetCounter << ">" << endl;
cout << "------- number of curves: " << theElement.NumberOfCurves() << endl;
myCurveSetCounter++;
}
private:
size_t myCurveSetCounter = 0;
};
void ExploreSheet (const Drawing::Sheet& theSheet)
{
Drawing::Sheet::ViewIterator aViewIt (theSheet);
size_t aViewCounter = 0;
while (aViewIt.HasNext()) {
const auto& aView = aViewIt.Next();
cout << "---- View <" << aViewCounter << ">" << endl;
DrawingElementVisitor aVisitor;
aView.Accept (aVisitor);
aViewCounter++;
}
}
void ExploreDrawing (const Drawing::Drawing& theDrawing)
{
Drawing::Drawing::SheetIterator aSheetIt (theDrawing);
size_t aSheetCounter = 0;
while (aSheetIt.HasNext()) {
const auto& aSheet = aSheetIt.Next();
cout << "-- Sheet <" << aSheetCounter << ">" << endl;
ExploreSheet (aSheet);
aSheetCounter++;
}
}
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 != 2) {
cerr << "Usage: " << argv[0] << " <input_file>, where:" << endl;
cerr << " <input_file> is a name of the file to be read" << endl;
return 1;
}
const char* aSource = argv[1];
ModelData::ModelReaderParameters aReaderParameters;
aReaderParameters.SetReadDrawing (true);
ModelData::ModelReader aReader;
aReader.SetParameters (aReaderParameters);
ModelData::Model aModel;
if (!aReader.Read (aSource, aModel)) {
cerr << "Failed to read the file " << aSource << endl;
return 1;
}
Drawing::Drawing aDrawing = aModel.Drawing();
if (aDrawing.IsNull()) {
cerr << "The model doesn't contain a drawing" << endl;
return 1;
}
cout << "Drawing \"" << aModel.Name() << "\":" << endl;
ExploreDrawing (aDrawing);
return 0;
}
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.