#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"
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:
{
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;
}
{
case ModelData_BT_Solid: return "Solid";
case ModelData_BT_Sheet: return "Sheet";
case ModelData_BT_Wireframe: return "Wireframe";
case ModelData_BT_Acorn: return "Acorn";
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;
}
Defines precise Boundary Representation of part.
Definition: ModelData_BRepRepresentation.hxx:39
const ModelData_BodyList & Get() const
Returns an associated topological object.
Definition: ModelData_BRepRepresentation.cxx:626
Defines a root topological shape that can be owned by B-Rep representation.
Definition: ModelData_Body.hxx:28
ModelData_BodyType BodyType() const
Returns a body type.
Definition: ModelData_Body.cxx:139
Defines a list of bodies.
Definition: ModelData_BodyList.hxx:31
Base class for 3D curves.
Definition: ModelData_Curve.hxx:44
ModelData_CurveType Type() const
Returns a curve type.
Definition: ModelData_Curve.cxx:205
Defines an edge.
Definition: ModelData_Edge.hxx:36
bool IsDegenerated() const
Returns true if the edge is degenerated.
Definition: ModelData_Edge.cxx:671
double Tolerance() const
Returns edge tolerance.
Definition: ModelData_Edge.cxx:664
ModelData_Curve Curve(double &theFirstParameter, double &theLastParameter) const
Returns edge 3D curve and its limits.
Definition: ModelData_Edge.cxx:632
Defines a topological face.
Definition: ModelData_Face.hxx:32
ModelData_Surface Surface() const
Returns underlying surface.
Definition: ModelData_Face.cxx:253
Element visitor with empty implementation.
Definition: ModelData_Model.hxx:113
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:43
void Accept(ElementVisitor &theVisitor) const
Accepts a visitor.
Definition: ModelData_Model.cxx:833
Reads any format that CAD Exchanger can import.
Definition: ModelData_ModelReader.hxx:33
Compares shapes using 'IsEqual' relationship.
Definition: ModelData_Shape.hxx:128
Hasher for ModelData_Shape using 'IsEqual' relationship.
Definition: ModelData_Shape.hxx:116
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:35
ModelData_BRepRepresentation BRepRepresentation() const
Definition: ModelData_Part.cxx:360
Iterates over subshapes in a shape.
Definition: ModelData_Shape.hxx:41
Base class of topological shapes.
Definition: ModelData_Shape.hxx:37
ModelData_ShapeType Type() const
Returns a shape type.
Definition: ModelData_Shape.cxx:358
ModelData_ShapeOrientation Orientation() const
Returns orientation flag.
Definition: ModelData_Shape.cxx:392
Base class for geometrical surfaces.
Definition: ModelData_Surface.hxx:44
ModelData_SurfaceType Type() const
Returns a surface type.
Definition: ModelData_Surface.cxx:195
Compares shapes using 'IsSame' relationship.
Definition: ModelData_Shape.hxx:122
Hasher for ModelData_Shape using 'IsSame' relationship.
Definition: ModelData_Shape.hxx:110
Defines topological vertex.
Definition: ModelData_Vertex.hxx:31
double Tolerance() const
Returns vertex tolerance.
Definition: ModelData_Vertex.cxx:89
Defines a connected set of edges.
Definition: ModelData_Wire.hxx:31
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22
ModelData_ShapeOrientation
Defines shape orientation.
Definition: ModelData_ShapeOrientation.hxx:25