ODA Facet Modeler Developer Guide > Work with B-rep Data > Iterate through Entities
Iterate through Entities

This chapter provides information on how to iterate through body faces, edges and vertices in Facet Modeler.

ODA Facet Modeler uses the boundary representation technique for solid modeling, and due to its data structure presented in the Overview topic, it provides a set of iterators defined in the <KERNEL_DIR>/FacetModeler/include/Modeler/FMMdlIterators.h header file. <KERNEL_DIR> is the directory where you unpacked the Kernel archive.

Facet Modeler makes it possible to iterate through a body's faces using FaceIterator:

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

By following the B-Rep hierarchy, it is possible to iterate through all edges of a given face. Note that edges may belong to different loops during an iteration. The first loop is the outer one, and the following loops are holes (see the Topological entities section for more details). The bNextLoop parameter becomes true when pEdge starts belonging to a different edge loop.
To iterate through all edges of a face, use EdgeFaceIterator:

EdgeFaceIterator iter(pFace);
while ( !iter.done() ) 
{
  Edge* pEdge = iter.get();
  
  //access the starting point of the current edge
  OdGePoint3d ptVtx = pEdge->vertex()->point(); 
  ... // work with edge here

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

Also, you can access all edges and vertices directly, without having to iterate through a body.
To iterate through edges, use EdgeBodyIterator. The following code snippet creates a cube and iterates through its edges while numerating them:

void iterTags(const DeviationParams& devDeviation)
{
  Body body = createCube(devDeviation);
  EdgeBodyIterator iter(&body);
  OdUInt64 tag = 0;
  while (!iter.done())
  {
    Edge* pEdge = iter.get();	
    pEdge->setTag(tag++);
    odPrintConsoleString(L"The edge's number is: %d\n", pEdge->tag());
    iter.next();
  }
}

To iterate through vertices, use VertexIterator:

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

  … // work with vertex here

  itV.next();
}

See Also

Work with B-Rep Data in Facet Modeler
Create Basic Objects
Create Basic 2D Objects
Create Objects via Revolution
Create Objects via Extrusion
Perform Boolean Operations
Perform Slicing Operations
Calculate Area and Volume
Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.