#include <cadex/LicenseManager_Activate.h>
#include <cadex/ModelData/Body.hxx>
#include <cadex/ModelData/Edge.hxx>
#include <cadex/ModelData/Face.hxx>
#include <cadex/ModelData/Model.hxx>
#include <cadex/ModelData/ModelElementVisitor.hxx>
#include <cadex/ModelData/ModelReader.hxx>
#include <cadex/ModelData/Part.hxx>
#include <cadex/ModelData/Shape.hxx>
#include <cadex/ModelData/SheetBody.hxx>
#include <cadex/ModelData/Shell.hxx>
#include <cadex/ModelData/SolidBody.hxx>
#include <cadex/ModelData/Vertex.hxx>
#include <cadex/ModelData/Wire.hxx>
#include <cadex/ModelData/WireframeBody.hxx>
#include <iostream>
#include <unordered_set>
#include "../../mtk_license.cxx"
using namespace std;
#define ShapesOrientationIsUsed 0
#if ShapesOrientationIsUsed
#else
#endif
typedef unordered_set<ModelData::Shape, HasherType, EqualerType> ShapeSetType;
{
public:
PartBRepVisitor() :
myNestingLevel (0)
{}
void PrintUniqueShapesCount()
{
cout << endl << "Total unique shapes count: " << myShapeSet.size() << endl;
}
protected:
{
cout <<
"Part = \"" << thePart.
Name() <<
"\"" << endl;
const auto& aBodies = thePart.
Bodies();
if (!aBodies.empty()) {
ExploreBRep (aBodies);
}
}
private:
void ExploreBRep (const std::vector<ModelData::Body>& theBodies)
{
myNestingLevel++;
for (size_t i = 0; i < theBodies.size(); ++i) {
const auto& aBody = theBodies[i];
PrintTabulation();
cout << "Body " << i << " " << PrintBodyType (aBody) << endl;
ExploreShape (aShape);
}
}
myNestingLevel--;
}
{
myShapeSet.insert (theShape);
++myNestingLevel;
while (aShapeIt.HasNext()) {
PrintShapeInfo (aShape);
ExploreShape (aShape);
}
--myNestingLevel;
}
{
return "Sheet";
return "Solid";
return "Wireframe";
}
return "Undefined";
}
{
PrintTabulation();
switch (theShape.
Type()) {
case ModelData::ShapeType::Solid: cout << "Solid"; break;
case ModelData::ShapeType::Shell: cout << "Shell"; break;
case ModelData::ShapeType::Wire:
cout << "Wire";
PrintWireInfo (ModelData::Wire::Cast (theShape));
break;
case ModelData::ShapeType::Face:
cout << "Face";
PrintFaceInfo (ModelData::Face::Cast (theShape));
break;
case ModelData::ShapeType::Edge:
cout << "Edge";
PrintEdgeInfo (ModelData::Edge::Cast (theShape));
break;
case ModelData::ShapeType::Vertex:
cout << "Vertex";
PrintVertexInfo (ModelData::Vertex::Cast (theShape));
break;
default: cout << "Undefined"; break;
}
cout << endl;
}
{
++myNestingLevel;
--myNestingLevel;
}
{
++myNestingLevel;
cout << endl;
PrintTabulation();
cout << "Surface: " << PrintSurfaceType (aSurface);
--myNestingLevel;
}
{
switch (theSurface.
Type()) {
case Geom::SurfaceType::Plane: return "Plane";
case Geom::SurfaceType::Cylinder: return "Cylinder";
case Geom::SurfaceType::Cone: return "Cone";
case Geom::SurfaceType::Sphere: return "Sphere";
case Geom::SurfaceType::Torus: return "Torus";
case Geom::SurfaceType::LinearExtrusion: return "LinearExtrusion";
case Geom::SurfaceType::Revolution: return "Revolution";
case Geom::SurfaceType::Bezier: return "Bezier";
case Geom::SurfaceType::BSpline: return "BSpline";
case Geom::SurfaceType::Offset: return "Offset";
default: break;
}
return "Undefined";
}
{
++myNestingLevel;
cout << "(Degenerated)";
}
cout <<
"Tolerance = " << theEdge.
Tolerance();
double aFirstParam, aLastParam;
cout << endl;
PrintTabulation();
cout << "Curve: " << PrintCurvetype (aCurve);
}
--myNestingLevel;
}
const char* PrintCurvetype (
const Geom::Curve& theCurve)
{
switch (theCurve.
Type()) {
case Geom::CurveType::Line: return "Line";
case Geom::CurveType::Circle: return "Circle";
case Geom::CurveType::Ellipse: return "Ellipse";
case Geom::CurveType::Hyperbola: return "Hyperbola";
case Geom::CurveType::Parabola: return "Parabola";
case Geom::CurveType::Bezier: return "Bezier";
case Geom::CurveType::BSpline: return "BSpline";
case Geom::CurveType::Offset: return "Offset";
default: break;
}
return "Undefined";
}
{
cout <<
"Tolerance = " << theVertex.
Tolerance();
}
{
cout << "Orientation = ";
switch (theOrientation) {
case ModelData::ShapeOrientation::Forward: cout << "Forward"; break;
case ModelData::ShapeOrientation::Reversed: cout << "Reversed"; break;
default: cout << "Undefined"; break;
}
cout << "; ";
}
void PrintTabulation()
{
for (size_t i = 0; i < myNestingLevel; ++i) {
cout << "- ";
}
}
size_t myNestingLevel;
ShapeSetType myShapeSet;
};
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];
cerr << "Failed to read the file " << aSource << endl;
return 1;
}
PartBRepVisitor aVisitor;
aVisitor.PrintUniqueShapesCount();
return 0;
}
Base class for 3D curves.
Definition Curve.hxx:37
CurveType Type() const
Returns a curve type.
Definition Curve.cxx:424
Base class for geometrical surfaces.
Definition Surface.hxx:38
SurfaceType Type() const
Returns a surface type.
Definition Surface.cxx:492
Provides a base body class.
Definition Body.hxx:28
Defines an edge.
Definition Edge.hxx:31
Geom::Curve Curve(double &theFirstParameter, double &theLastParameter) const
Returns edge 3D curve and its limits.
Definition Edge.cxx:404
double Tolerance() const
Returns edge tolerance.
Definition Edge.cxx:683
bool IsDegenerated() const
Returns true if the edge is degenerated.
Definition Edge.cxx:690
Defines a topological face.
Definition Face.hxx:31
Geom::Surface Surface() const
Returns underlying surface.
Definition Face.cxx:322
UTF16String Name() const
Returns a name.
Definition ModelElement.cxx:54
Element visitor with empty implementation.
Definition ModelElementVisitor.hxx:63
Provides MTK data model.
Definition Model.hxx:39
void Accept(ModelElementVisitor &theVisitor) const
Accepts a visitor.
Definition Model.cxx:276
Reads supported formats, see Import section.
Definition ModelReader.hxx:32
Compares shapes using 'IsEqual' relationship.
Definition Shape.hxx:94
Hasher for Shape using 'IsEqual' relationship.
Definition Shape.hxx:82
Defines a leaf node in the scene graph hierarchy.
Definition Part.hxx:32
Base class of topological shapes.
Definition Shape.hxx:37
ShapeOrientation Orientation() const
Returns orientation flag.
Definition Shape.cxx:272
ShapeType Type() const
Returns a shape type. For a null object returns Undefined.
Definition Shape.cxx:260
Iterates over subshapes in a shape.
Definition ShapeIterator.hxx:30
Provides a sheet body composed of faces and shells.
Definition SheetBody.hxx:32
Provides a solid body composed of solids.
Definition SolidBody.hxx:28
Compares shapes using 'IsSame' relationship.
Definition Shape.hxx:88
Hasher for Shape using 'IsSame' relationship.
Definition Shape.hxx:76
Defines topological vertex.
Definition Vertex.hxx:28
double Tolerance() const
Returns vertex tolerance.
Definition Vertex.cxx:118
Defines a connected set of edges.
Definition Wire.hxx:30
Provides a wireframe body composed of edges and wires.
Definition WireframeBody.hxx:32
ShapeOrientation
Defines shape orientation.
Definition ShapeOrientation.hxx:25
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:29