#include <cadex/LicenseManager_Activate.h>
#include <cadex/ModelData_Appearance.hxx>
#include <cadex/ModelData_BRepRepresentation.hxx>
#include <cadex/ModelData_Model.hxx>
#include <cadex/ModelData_ModelReader.hxx>
#include <cadex/ModelData_Part.hxx>
#include <cadex/ModelData_PolyRepresentation.hxx>
#include <cadex/ModelData_PolyShape.hxx>
#include <cadex/ModelData_PolyShapeList.hxx>
#include <cadex/ModelData_PolyVertexSet.hxx>
#include <cadex/ModelData_SceneGraphElement.hxx>
#include <iostream>
#include <unordered_set>
#include "../../cadex_license.cxx"
using namespace std;
typedef unordered_set<ModelData_Appearance, ModelData_AppearanceHash> AppSetType;
class SubshapeAppearancesCollector : public ModelData_BRepRepresentation::SubshapeVisitor
{
public:
myBRep (theBRep), myAppSet (theAppSet) {}
protected:
{
ExploreShapeAppearances (theShape);
}
private:
{
if (anApp) {
myAppSet.insert (anApp);
}
}
AppSetType& myAppSet;
};
class RepVisitor : public ModelData_Part::RepresentationVisitor
{
public:
RepVisitor (AppSetType& theAppSet) : myAppSet (theAppSet) {}
protected:
{
SubshapeAppearancesCollector aCollector (theBRep, myAppSet);
}
{
ExplorePVSAppearances (thePolyRep);
}
private:
{
const ModelData_PolyShapeList& aList = thePolyRep.
Get();
for (ModelData_PolyShapeList::SizeType i = 0; i < aList.Size(); ++i) {
if (anApp) {
myAppSet.insert (anApp);
}
}
}
AppSetType& myAppSet;
};
{
public:
SGEAppearancesCollector (AppSetType& theAppset) : myAppSet (theAppset) {}
protected:
{
ExploreSGEAppearance (thePart);
RepVisitor aVisitor (myAppSet);
}
{
ExploreSGEAppearance (theElement);
return true;
}
private:
{
if (anApp) {
myAppSet.insert (anApp);
}
}
AppSetType& myAppSet;
};
class AppearancesCollector
{
public:
{
SGEAppearancesCollector aCollector (myAppSet);
myModel.Accept (aCollector);
}
void PrintAppearancesCount()
{
cout << "Total Model Unique Appearances Count: " << myAppSet.size() << endl;
}
private:
AppSetType myAppSet;
};
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;
}
AppearancesCollector aCollector (aModel);
aCollector.PrintAppearancesCount();
return 0;
}
Provides an interface to appearance which is a collection of visual styles.
Definition: ModelData_Appearance.hxx:39
Defines precise Boundary Representation of part.
Definition: ModelData_BRepRepresentation.hxx:39
void Accept(SubshapeVisitor &theVisitor) const
Applies the visitor to visit the subshapes.
Definition: ModelData_BRepRepresentation.cxx:993
Provides combined methods VisitEnter() and VisitLeave() to visit all elements.
Definition: ModelData_Model.hxx:123
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:43
Reads any format that CAD Exchanger can import.
Definition: ModelData_ModelReader.hxx:33
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:35
void Accept(RepresentationVisitor &theVisitor) const
Accepts a visitor of the associated representations.
Definition: ModelData_Part.cxx:384
Defines polygonal (faceted or tessellated) representation of part.
Definition: ModelData_PolyRepresentation.hxx:39
const ModelData_PolyShapeList & Get() const
Returns poly shapes comprising the representation.
Definition: ModelData_PolyRepresentation.cxx:408
Base class for particular vertex sets - triangle sets, polyline sets, point sets.
Definition: ModelData_PolyVertexSet.hxx:31
Base class for part, instance and assembly.
Definition: ModelData_SceneGraphElement.hxx:39
ModelData_Appearance Appearance() const
Returns the scene graph element's own appearance.
Definition: ModelData_SceneGraphElement.cxx:120
Base class of topological shapes.
Definition: ModelData_Shape.hxx:37
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22