Accessing B-Rep Data of Bodies in the Facet Modeler

Vladimir Savelyev
June 15, 2017

Tags: b-rep facet modeler

ODA’s Facet Modeler uses boundary representation for solid modeling, also called the B-Rep technique.

A brief overview of bodies:

  • Body — Consists of planar faces and forms a “water-proof” shell separating the interior body space from the exterior.
  • Face — Each face is represented as a plane and a list of edge loops, bounding some portion of the plane.
  • Edge loop — A closed list of non-intersecting edges.
  • Edge — Has a pointer to its vertex and pointers to previous and next edges in the loop.
  • Vertex — A 3D point.

The Facet Modeler provides a set of iterators for the Body class. They are defined in the “…\FacetModeler\include\Modeler\FMMdlIterators.h” header file.
Here is an example of iterating through all the faces of a body:

FaceIterator itF(pBody);
  while( !itF.done() )
  {
    Face* pFace = itF.get();
    … // working with pFace
    itF.next();
  }

Following the B-Rep hierarchy, you can iterate through all the edges of a given face. Please note that edges may belong to different loops during an iteration. The first loop is the outer one, and the following loops are holes. If you need to separate edges from different loops, use the bNextLoop parameter of the next() function.

EdgeFaceIterator iter(pFace);
    while ( !iter.done() ) 
    {
      Edge* pEdge = iter.get();

      OdGePoint3d ptVtx = pEdge->vertex()->point();
      ... // work with edge here

      bool bNextLoop;
      iter.next( &bNextLoop );
      if( bNextLoop ) 
      {
        ... // next loop begins from next iteration
      }
    }

There are also two more iterators that access all the edges or body vertexes directly, without iterating through bodies:

EdgeBodyIterator itE(pBody);
    while( !itE.done() )
    {
      Edge* pEdge = iter.get();

      ... // work with edge here

      itE.next();
    }

    VertexIterator itV(pBody);
    while( !itV.done() )
    {
      Vertex* pVertex = itV.get();

      … // work with vertex here

      itV.next();
    }
All posts