Loading...

Searching...

No Matches

Part representations

Representations are associated with a part and define its shape.

The following representations are supported:

- BRep or Boundary Representation (ModelData_BRepRepresentation) - exact geometrical representation.
- Polygonal or facetted, or tessellated (ModelData_PolyRepresentation) - approximated representation with the help of a mesh.

Each part may have zero or one B-Rep representation and zero, one or several polygonal representations. Representations must be consistent with each other.

The following picture demonstrates the nut part from the assembly as1, with one BRep (as solid body) and one polygonal representation:

B-Rep representation (ModelData_BRepRepresentation) includes a topological model that describes hierarchy and connectivity information between elements in the 3D model (from vertices to solid), as well as reference to underlying geometries (points, curves and surfaces):

Topological entities subsclass the base class ModelData_Shape, curves subclass ModelData_Curve and surfaces inherit the base class ModelData_Surface.

CAD Exchanger supports all types of bodies: solid, sheet, wireframe, and acorn (single vertex) bodies. Body (ModelData_Body) belongs to B-Rep representation itself.

Supported geometries include:

- Analytical representations (lines, circles, ellipses, planar, spherical, cylindrical and other elementary surfaces);
- Extrusion and rotation surfaces;
- Offset curves and surfaces;
- Bezier and NURBS curves and surfaces.

Each topological entity can be explored for its children. Vertices, edges, faces can be interrogated for associated geometries.

ModelData_Wire aWire = ...;

ModelData_Shape::Iterator anIt (aWire);

while (anIt.HasNext()) {

const ModelData_Edge& anEdge = ModelData_Edge::Cast (anIt.Next());

double aFirst, aLast; //edge's curve range

ModelData_Curve aCurve = anEdge.Curve (aFirst, aLast);

}

static const ModelData_Edge & Cast(const ModelData_Shape &theShape)

Casts a base class object to ModelData_Edge.

Curves and surfaces can be interrogated for their defining parameters (e.g. axis placement for a circle, or control points for a NURBS curve):

ModelData_Circle aCircle = ...;

const ModelData_AxisPlacement& anAxis = aCircle.Position();

ModelData_Point aPoint = aCircle.Value (M_PI_2);

B-Rep bodies can be created using solid and sheet modeling API, such as solid primitives and sweep operations, or direct step-by-step bottom-up process:

static ModelData_Solid CreateCylinder(double theRadius, double theHeight, double theAngle=2 *M_PI)

Creates a cylinder.

Polygonal representation (ModelData_PolyRepresentation) defines a tessellated (mesh) representation of a part. The part may have zero or more polygonal representations.

CAD Exchanger supports triangular meshes, polylines and point clouds. All of them subclass the base class ModelData_PolyVertexSet.

Polygonal representations are either imported from the source file or can be created bottom-up (by populating lists of mesh nodes, normals) or generated from B-Rep representations with the help of meshers.

A part may have multiple polygonal representations. In this case a part is considered having levels of details (LOD's), i.e. granularity or accuracy of approximation of a part.

By convention, LODs must be sorted from the most accurate (fine) to the least accurate (coarse) representations.

The following two examples demonstrate a part with one BRep representation (as a sheet body or solid body respectively) and three polygonal representations:

Polygonal representations can be either explicitly created bottom-up or generated from B-Rep with the help of meshers (see Mesh Generation).

CAD Exchanger SDK contains two classes of meshers serving two different purposes and making different trade-off's in implementation:

- Visualization mesher, which is focused on achieving higher performance and producing fewer triangles so that the mesh can be used in visualization and other algorithms where good approximation is enough (e.g. bounding box computation).
- Computational mesher, which produces more regular triangulation (ideally equal sided) suitable for finite element analysis.

Each mesher supports various parameters (chordal and angular deflection, min/max size, etc) in order to control the resulting mesh.

The following code snippet demonstrates creation of a part with BRep and two polygonal representations:

ModelData_Solid aSolid = ...; //exact solid shape

ModelData_BRepRepresentation aBRep (aSolid);

//automatically generates polygonal representations from BRep

ModelData_PolyRepresentation aFinePoly (aBRep, ModelAlgo_BRepMesherParameters::Fine);

ModelData_PolyRepresentation aMediumPoly (aBRep, ModelAlgo_BRepMesherParameters::Medium);

ModelData_Part aPart (aBRep, aFinePoly, aMediumPoly, "my_part");

Semantics of LOD is application-specific. The data model only provides a mechanism to define multiple polygonal representations.

B-Rep representation contains ModelData_BodyList, which is a list of bodies (ModelData_Body), which define exact part geometry. Each ModelData_Body can be solid, sheet, wireframe or acorn (see ModelData_BodyType enumeration).

Each polygonal representation contains ModelData_PolyShapeList, which is a list of vertex sets. Each vertex set (subclass of ModelData_PolyVertexSet) defines either a set of triangles (ModelData_IndexedTriangleSet), polylines (ModelData_PolyLineSet) or just a point cloud ( ModelData_PolyPointSet).

The part representations can be traversed as follows:

- with the help of direct search;
- with the help of iterator;
- with the help of visitors.

The following examples demonstrate using each approach:

ModelData_Part aPart = ...;

//find B-Rep representation

ModelData_BRepRepresentation aBRep = aPart.BRepRepresentation();

if (aBRep) {

const ModelData_BodyList& aList = aBRep.Get(); //retrieve root bodies

for (ModelData_BodyList::SizeType i = 0; i < aList.Size(); ++i) {

const ModelData_Body& aBody = aList[i];

//...

}

}

//find first polygonal representation

ModelData_PolyRepresentation aPoly = aPart.PolyRepresentation (ModelData_RM_FineLOD);

if (aPoly) {

const ModelData_PolyShapeList& aList = aPoly.Get(); //retrive root vertex sets

for (ModelData_PolyShapeList::SizeType i = 0; i < aList.Size(); ++i) {

const ModelData_PolyVertexSet& aPVSet = aList[i];

//...

}

}

class MyRepresentationVisitor : public ModelData_Part::RepresentationVisitor

{

public:

virtual void operator() (const ModelData_BRepRepresentation& theRep) override

{

//...

}

virtual void operator() (const ModelData_PolyRepresentation& theRep) override

{

//...

}

};

MyRepresentationVisitor aVisitor;

aPart.Accept (aVisitor);

In the above example a respective operator() of MyRepresentationVisitor will be invoked for each representation encountered in the part.

ModelData_Part::RepresentationIterator anIt (aPart);

while (anIt.HasNext()) {

const ModelData_Representation& aRep = anIt.Next();

if (aRep.TypeId() == ModelData_PolyRepresentation::GetTypeId()) {

const ModelData_PolyRepresentation& aPoly = static_cast<const ModelData_PolyRepresentation&> (aRep);

} else if (aRep.TypeId() == ModelData_BRepRepresentation::GetTypeId()) {

const ModelData_BRepRepresentation& aBRep = static_cast<const ModelData_BRepRepresentation&> (aRep);

}

}