#include <cadex/LicenseManager_Activate.h>
#include <cadex/Drawing/Drawing.hxx>
#include <cadex/Drawing/ElementVisitor.hxx>
#include <cadex/Drawing/Geometry.hxx>
#include <cadex/Drawing/Hatch.hxx>
#include <cadex/Drawing/Sheet.hxx>
#include <cadex/Drawing/Text.hxx>
#include <cadex/Drawing/View.hxx>
#include <cadex/Geom/Point2d.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;
{
public:
{
cout << "------- CurveSet <" << myCurveSetCounter << ">" << endl;
cout <<
"--------- number of curves: " << theElement.
NumberOfCurves() << endl;
myCurveSetCounter++;
}
{
cout << "------- Hatch <" << myHatchCounter << ">" << endl;
cout <<
"--------- number of contours: " << theElement.
NumberOfContours() << endl;
size_t aNumberOfCurves = 0;
}
cout << "--------- number of curves: " << aNumberOfCurves << endl;
cout <<
"--------- pattern: " << PatternToString (theElement.
Pattern()) << endl;
cout <<
"--------- angle: " << theElement.
Angle() << endl;
cout <<
"--------- scale: " << theElement.
Scale() << endl;
myHatchCounter++;
}
{
cout << "------- Text <" << myTextCounter << ">" << endl;
cout <<
"--------- text: \"" << theElement.
GetText() <<
"\"" << endl;
cout <<
"--------- origin: " << PointToString (theElement.
TextOrigin()) << endl;
cout <<
"--------- rotation: " << theElement.
TextProperties().
Rotation() << endl;
cout <<
"--------- font size: " << theElement.
FontSize() << endl;
myTextCounter++;
}
private:
{
return "(" + std::to_string (thePoint.
X()) +
"; " + std::to_string (thePoint.
Y()) +
")";
}
{
switch (thePattern) {
case Drawing::Hatch::PatternType::Solid: return "Solid";
case Drawing::Hatch::PatternType::ANSI_31: return "ANSI 31";
case Drawing::Hatch::PatternType::ANSI_32: return "ANSI 32";
case Drawing::Hatch::PatternType::ANSI_33: return "ANSI 33";
case Drawing::Hatch::PatternType::ANSI_34: return "ANSI 34";
case Drawing::Hatch::PatternType::ANSI_35: return "ANSI 35";
case Drawing::Hatch::PatternType::ANSI_36: return "ANSI 36";
case Drawing::Hatch::PatternType::ANSI_37: return "ANSI 37";
case Drawing::Hatch::PatternType::ANSI_38: return "ANSI 38";
case Drawing::Hatch::PatternType::ISO_02: return "ISO 02";
case Drawing::Hatch::PatternType::ISO_03: return "ISO 03";
case Drawing::Hatch::PatternType::ISO_04: return "ISO 04";
case Drawing::Hatch::PatternType::ISO_05: return "ISO 05";
case Drawing::Hatch::PatternType::ISO_06: return "ISO 06";
case Drawing::Hatch::PatternType::ISO_07: return "ISO 07";
case Drawing::Hatch::PatternType::ISO_08: return "ISO 08";
case Drawing::Hatch::PatternType::ISO_09: return "ISO 09";
case Drawing::Hatch::PatternType::ISO_10: return "ISO 10";
case Drawing::Hatch::PatternType::ISO_11: return "ISO 11";
case Drawing::Hatch::PatternType::ISO_12: return "ISO 12";
case Drawing::Hatch::PatternType::ISO_13: return "ISO 13";
case Drawing::Hatch::PatternType::ISO_14: return "ISO 14";
case Drawing::Hatch::PatternType::ISO_15: return "ISO 15";
default: return "Other";
}
}
size_t myCurveSetCounter = 0;
size_t myHatchCounter = 0;
size_t myTextCounter = 0;
};
{
size_t aViewCounter = 0;
while (aViewIt.HasNext()) {
const auto& aView = aViewIt.Next();
cout << "---- View <" << aViewCounter << ">" << endl;
DrawingElementVisitor aVisitor;
aView.Accept (aVisitor);
aViewCounter++;
}
}
{
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];
if (!aReader.
Read (aSource, aModel)) {
cerr << "Failed to read the file " << aSource << endl;
return 1;
}
cerr << "The model doesn't contain a drawing" << endl;
return 1;
}
cout <<
"Drawing \"" << aModel.
Name() <<
"\":" << endl;
ExploreDrawing (aDrawing);
return 0;
}
Describes drawing elements composed of 2D curves.
Definition Drawing/Geometry.hxx:43
size_t NumberOfCurves() const
Returns the number of curves currently composing the element.
Definition Drawing/Geometry.cxx:78
Iterator over sheets of a drawing.
Definition Drawing.hxx:45
Represents a single 2D drawing of a model.
Definition Drawing.hxx:32
Defines a visitor for drawing elements with empty implementation.
Definition ElementVisitor.hxx:58
Represents an area filled with a pattern.
Definition Hatch.hxx:32
const PiecewiseContour & Contour(size_t theIndex) const
Returns the contour.
Definition Hatch.cxx:109
PatternType
Definition Hatch.hxx:34
double Scale() const
Returns the scale of the hatch.
Definition Hatch.cxx:148
PatternType Pattern() const
Returns the pattern of the hatch.
Definition Hatch.cxx:135
size_t NumberOfContours() const
Returns the number of hatch contours.
Definition Hatch.cxx:100
double Angle() const
Returns the angle of the hatch.
Definition Hatch.cxx:161
size_t NumberOfCurves() const
Returns the number of curves currently composing the element.
Definition Drawing/Geometry.cxx:194
Iterates over views of a drawing sheet.
Definition Sheet.hxx:75
Represents a single sheet of a model drawing.
Definition Sheet.hxx:32
Defines a text for drawing.
Definition Text.hxx:36
const Geom::Point2d & TextOrigin() const
Returns a position of the text on the 2D plane.
Definition Text.cxx:156
const UTF16String & GetText() const
Returns a text.
Definition Text.cxx:143
float FontSize() const
Returns size of the font in points.
Definition Text.cxx:169
Properties TextProperties() const
Returns the properties of dimension text.
Definition Text.cxx:175
Defines a 3D point.
Definition Point2d.hxx:34
Provides MTK data model.
Definition Model.hxx:40
UTF16String Name() const
Returns a model name.
Definition Model.cxx:254
Reads supported formats, see Import section.
Definition ModelReader.hxx:33
void SetParameters(const ModelReaderParameters &theParameters)
Sets reader parameters.
Definition ModelReader.cxx:254
bool Read(const UTF16String &theFilePath, ModelData::Model &theModel)
Reads the file at the specified path into the specified model.
Definition ModelReader.cxx:280
Defines parameters of the ModelReader.
Definition ModelReaderParameters.hxx:29
void SetReadDrawing(bool theReadDrawing)
Sets whether a drawing should be read from the file.
Definition ModelReaderParameters.cxx:94
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30