#include <cadex/LicenseManager_Activate.h>
#include <cadex/ModelData_Body.hxx>
#include <cadex/ModelData_BodyList.hxx>
#include <cadex/ModelData_BodyType.hxx>
#include <cadex/ModelData_BRepRepresentation.hxx>
#include <cadex/ModelData_Curve.hxx>
#include <cadex/ModelData_Curve2d.hxx>
#include <cadex/ModelData_Edge.hxx>
#include <cadex/ModelData_Face.hxx>
#include <cadex/ModelData_ModelReader.hxx>
#include <cadex/ModelData_Part.hxx>
#include <cadex/ModelData_Surface.hxx>
#include <cadex/ModelData_Vertex.hxx>
#include <cadex/ModelData_Wire.hxx>
#include <array>
#include <iostream>
#include <unordered_set>
#include "../../cadex_license.cxx"
#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:
{
if (aBRep) {
ExploreBRep (aBRep);
}
}
private:
{
for (ModelData_BodyList::SizeType i = 0; i < aBodyList.
Size(); ++i) {
cout << "Body " << i << " : -type " << PrintBodyType (aBody) << endl;
ExploreShape (aBody);
}
}
{
myShapeSet.insert (theShape);
++myNestingLevel;
while (aShapeIt.
HasNext()) {
PrintShapeInfo (aShape);
ExploreShape (aShape);
}
--myNestingLevel;
}
{
default:
break;
}
return "Undefined";
}
{
PrintTabulation();
switch (theShape.
Type()) {
case ModelData_ST_Body: cout << "Body"; break;
case ModelData_ST_Solid: cout << "Solid"; break;
case ModelData_ST_Shell: cout << "Shell"; break;
case ModelData_ST_Wire: cout << "Wire"; PrintWireInfo (ModelData_Wire::Cast (theShape)); break;
case ModelData_ST_Face: cout << "Face"; PrintFaceInfo (ModelData_Face::Cast (theShape)); break;
case ModelData_ST_Edge: cout << "Edge"; PrintEdgeInfo (ModelData_Edge::Cast (theShape)); break;
case ModelData_ST_Vertex: cout << "Vertex"; PrintVertexInfo (ModelData_Vertex::Cast (theShape)); break;
default:
cout << "Undefined"; break;
}
cout << endl;
}
{
++myNestingLevel;
cout <<
". Orientation: " << PrintOrientation (theWire.
Orientation());
--myNestingLevel;
}
{
++myNestingLevel;
cout <<
". Orientation: " << PrintOrientation (theFace.
Orientation()) << endl;
PrintTabulation();
cout << "Surface: " << PrintSurfaceType (aSurface);
--myNestingLevel;
}
{
switch (theSurface.
Type()) {
case ModelData_ST_Plane: return "Plane";
case ModelData_ST_Cylinder: return "Cylinder";
case ModelData_ST_Cone: return "Cone";
case ModelData_ST_Sphere: return "Sphere";
case ModelData_ST_Torus: return "Torus";
case ModelData_ST_LinearExtrusion: return "LinearExtrusion";
case ModelData_ST_Revolution: return "Revolution";
case ModelData_ST_Bezier: return "Bezier";
case ModelData_ST_BSpline: return "BSpline";
case ModelData_ST_Offset: return "Offset";
case ModelData_ST_Trimmed: return "Trimmed";;
default:
break;
}
return "Undefined";
}
{
++myNestingLevel;
cout << "(Degenerated)";
}
cout <<
". Orientation: " << PrintOrientation (theEdge.
Orientation()) <<
array<double, 2> aParameters;
enum {First, Last};
cout << endl;
PrintTabulation();
cout << "Curve: " << PrintCurvetype (aCurve);
}
--myNestingLevel;
}
{
switch (theCurve.
Type()) {
case ModelData_CT_Line: return "Line";
case ModelData_CT_Circle: return "Circle";
case ModelData_CT_Ellipse: return "Ellipse";
case ModelData_CT_Hyperbola: return "Hyperbola";
case ModelData_CT_Parabola: return "Parabola";
case ModelData_CT_Bezier: return "Bezier";
case ModelData_CT_BSpline: return "BSpline";
case ModelData_CT_Offset: return "Offset";
case ModelData_CT_Trimmed: return "Trimmed";
default:
break;
}
return "Undefined";
}
{
cout <<
". Orientation: " << PrintOrientation (theVertex.
Orientation()) <<
}
{
switch (theOrientation) {
case ModelData_SO_Forward: return "Forward";
case ModelData_SO_Reversed: return "Reversed";
default:
break;
}
return "Undefined";
}
void PrintTabulation()
{
for (size_t i = 0; i < myNestingLevel; ++i) {
cout << "- ";
}
}
size_t myNestingLevel;
ShapeSetType myShapeSet;
};
int main (int argc, char *argv[])
{
auto aKey = LicenseKey::Value();
if (!CADExLicense_Activate (aKey)) {
cerr << "Failed to activate CAD Exchanger license." << endl;
return 1;
}
if (argc != 2) {
cerr << "Usage: " << argv[0] << " <input_file>, where:" << endl;
cerr << " <input_file> is a name of the XML 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;
}