#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#include <cadex/LicenseManager_Activate.h>
#include <cadex/ModelData_Body.hxx>
#include <cadex/ModelData_BodyList.hxx>
#include <cadex/ModelAlgo_BRepMesher.hxx>
#include <cadex/ModelAlgo_BRepMesherParameters.hxx>
#include <cadex/ModelData_BRepRepresentation.hxx>
#include <cadex/ModelData_BRepToPolyAssociations.hxx>
#include <cadex/ModelData_Face.hxx>
#include <cadex/ModelData_IndexArray.hxx>
#include <cadex/ModelData_IndexedTriangleSet.hxx>
#include <cadex/ModelData_MeshPatch.hxx>
#include <cadex/ModelData_ModelReader.hxx>
#include <cadex/ModelData_ModelWriter.hxx>
#include <cadex/ModelData_Part.hxx>
#include <cmath>
#include <iostream>
#include "../../cadex_license.cxx"
using namespace std;
{
public:
{
if (myFace.IsNull()) {
}
}
{
return myFace;
};
private:
{
const auto& aBodyList = theBRep.
Get();
const auto& aFirstBody = aBodyList.
First();
const auto& aFirstShape = aFaceIt.
Next();
const auto& aFirstFace = ModelData_Face::Cast (aFirstShape);
myFace = aFirstFace;
};
};
{
cout <<
"Face triangulation contains " << aTriangleIndices.
Size() <<
" triangles." << endl;
const size_t aNumberOfTrianglesToPrint = std::min (
size_t (4), aTriangleIndices.
Size());
for (size_t i = 0; i < aNumberOfTrianglesToPrint; ++i) {
auto aTriangleIndex = aTriangleIndices[i];
cout << "Triangle index " << aTriangleIndex << " with vertices: " << endl;
cout << " Vertex index " << aVertexIndex << " with coords (";
cout << "X: " << aPoint.X() << ", ";
cout << "Y: " << aPoint.Y() << ", ";
cout << "Z: " << aPoint.Z() << ")" << endl;
}
}
}
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];
if (!aReader.
Read (aSource, aModel)) {
cerr << "Failed to read the file " << aSource << endl;
return 1;
}
aMesher.Compute (aModel, true );
FirstFaceGetter aVisitor;
auto aBRepToPolyAssociations = aMesher.BRepToPolyAssociations();
PrintFaceToPolyAssociation (aFace, aBRepToPolyAssociations);
if (!aWriter.
Write (aModel,
"VisMesher.cdx")) {
cout << "Unable to save the model!" << endl;
return 1;
}
return 0;
}
Computes a polygonal representation from a B-Rep one.
Definition: ModelAlgo_BRepMesher.hxx:48
Defines parameters used by the B-Rep mesher.
Definition: ModelAlgo_BRepMesherParameters.hxx:33
void SetAngularDeflection(double theValue)
Sets angular deflection.
Definition: ModelAlgo_BRepMesherParameters.cxx:285
void SetSaveBRepToPolyAssociations(bool theValue)
Sets whether associations between ModelData_Shapes and meshes should be generated.
Definition: ModelAlgo_BRepMesherParameters.cxx:480
void SetChordalDeflection(double theValue)
Sets chordal deflection.
Definition: ModelAlgo_BRepMesherParameters.cxx:191
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
Contains connecting information between B-Rep and Poly representation.
Definition: ModelData_BRepToPolyAssociations.hxx:42
ModelData_MeshPatch Get(const ModelData_Vertex &theVertex) const
Returns the result of meshing the given vertex.
Definition: ModelData_BRepToPolyAssociations.cxx:209
Defines a topological face.
Definition: ModelData_Face.hxx:32
Defines an array of indices.
Definition: ModelData_IndexArray.hxx:15
size_t Size() const
Returns the size of array.
Definition: ModelData_IndexArray.cxx:41
Defines a polygonal shape consisting of triangles.
Definition: ModelData_IndexedTriangleSet.hxx:35
const CoordType & Coordinate(IndexType theFace, IndexType theVertexSlot) const
Returns a vertex coordinate.
Definition: ModelData_IndexedTriangleSet.cxx:210
IndexType CoordinateIndex(IndexType theFace, IndexType theVertexSlot) const
Returns a coordinate index for a vertex in a face.
Definition: ModelData_IndexedTriangleSet.cxx:218
Represents piece of ModelData_PolyVertexSet using set of indices.
Definition: ModelData_MeshPatch.hxx:36
const ModelData_IndexArray & Indices() const
Returns IndexArray representing this patch.
Definition: ModelData_MeshPatch.cxx:70
const ModelData_PolyVertexSet & PVS() const
Returns full mesh (ModelData_PolyVertexSet).
Definition: ModelData_MeshPatch.cxx:65
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
bool Read(const Base_UTF16String &theFilePath, ModelData_Model &theModel)
Reads the file at the specified path into the specified model.
Definition: ModelData_ModelReader.cxx:171
Writes any format that CAD Exchanger can export.
Definition: ModelData_ModelWriter.hxx:33
bool Write(const ModelData_Model &theModel, const Base_UTF16String &theFilePath)
Writes the specified model to the file at the specified path.
Definition: ModelData_ModelWriter.cxx:134
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:35
ModelData_BRepRepresentation BRepRepresentation() const
Definition: ModelData_Part.cxx:360
int IndexType
Type of indices.
Definition: ModelData_PolyVertexSet.hxx:35
Iterates over subshapes in a shape.
Definition: ModelData_Shape.hxx:41
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22