4 Traversing Mesh Components, Vertices, Faces, and Edges

QuickDraw3D provides a large number of functions that you can use to iterate through the components, vertices, faces, or edges of a mesh. For example, you can call the Q3Mesh_FirstMeshComponent function to get the first component in a mesh; then you can call the Q3Mesh_NextMeshComponent function to get any subsequent mesh components.

For even simpler mesh traversal, QuickDraw3D defines a large number of macros modeled on the standard C language for statement. For example, the Q3ForEachMeshComponent macro uses the Q3Mesh_FirstMeshComponent function and the Q3Mesh_NextMeshComponent function to iterate through all the components of a mesh.

Adding or deleting vertices or faces within the scope of these iterators might produce unpredictable results.<8bat>s

#define Q3ForEachMeshComponent(m,c,i)                   \
 for ( (c) = Q3Mesh_FirstMeshComponent((m),(i));                  \
  (c);                 \
  (c) = Q3Mesh_NextMeshComponent((i)) )
#define Q3ForEachComponentVertex(c,v,i)                   \
 for ( (v) = Q3Mesh_FirstComponentVertex((c),(i));                  \
  (v);                 \
  (v) = Q3Mesh_NextComponentVertex((i)) )
#define Q3ForEachComponentEdge(c,e,i)                   \
 for ( (e) = Q3Mesh_FirstComponentEdge((c),(i));                  \
  (e);                 \
  (e) = Q3Mesh_NextComponentEdge((i)) )
#define Q3ForEachMeshVertex(m,v,i)                   \
 for ( (v) = Q3Mesh_FirstMeshVertex((m),(i));                  \
  (v);                 \
  (v) = Q3Mesh_NextMeshVertex((i)) )
#define Q3ForEachMeshFace(m,f,i)                   \
 for ( (f) = Q3Mesh_FirstMeshFace((m),(i));                  \
  (f);                 \
  (f) = Q3Mesh_NextMeshFace((i)) )
#define Q3ForEachMeshEdge(m,e,i)                   \
 for ( (e) = Q3Mesh_FirstMeshEdge((m),(i));                  \
  (e);                 \
  (e) = Q3Mesh_NextMeshEdge((i)) )
#define Q3ForEachVertexEdge(v,e,i)                   \
 for ( (e) = Q3Mesh_FirstVertexEdge((v),(i));                  \
  (e);                 \
  (e) = Q3Mesh_NextVertexEdge((i)) )
#define Q3ForEachVertexVertex(v,n,i)                   \
 for ( (n) = Q3Mesh_FirstVertexVertex((v),(i));                  \
  (n);                 \
  (n) = Q3Mesh_NextVertexVertex((i)) )
#define Q3ForEachVertexFace(v,f,i)                   \
 for ( (f) = Q3Mesh_FirstVertexFace((v),(i));                  \
  (f);                 \
  (f) = Q3Mesh_NextVertexFace((i)) )
#define Q3ForEachFaceEdge(f,e,i)                   \
 for ( (e) = Q3Mesh_FirstFaceEdge((f),(i));                  \
  (e);                 \
  (e) = Q3Mesh_NextFaceEdge((i)) )
#define Q3ForEachFaceVertex(f,v,i)                   \
 for ( (v) = Q3Mesh_FirstFaceVertex((f),(i));                  \
  (v);                 \
  (v) = Q3Mesh_NextFaceVertex((i)) )
#define Q3ForEachFaceFace(f,n,i)                   \
 for ( (n) = Q3Mesh_FirstFaceFace((f),(i));                   \
  (n);                 \
  (n) = Q3Mesh_NextFaceFace((i)) )
#define Q3ForEachFaceContour(f,h,i)                   \
 for ( (h) = Q3Mesh_FirstFaceContour((f),(i));                  \
  (h);                 \
  (h) = Q3Mesh_NextFaceContour((i)) )
#define Q3ForEachContourEdge(h,e,i)                   \
 for ( (e) = Q3Mesh_FirstContourEdge((h),(i));                  \
  (e);                 \
  (e) = Q3Mesh_NextContourEdge((i)) )
#define Q3ForEachContourVertex(h,v,i)                   \
 for ( (v) = Q3Mesh_FirstContourVertex((h),(i));                  \
  (v);                 \
  (v) = Q3Mesh_NextContourVertex((i)) )
#define Q3ForEachContourFace(h,f,i)                   \
 for ( (f) = Q3Mesh_FirstContourFace((h),(i));                  \
  (f);                 \
  (f) = Q3Mesh_NextContourFace((i)) )

3D Graphics Programming with QuickDraw 3D - 21 OCT 1995

© Apple Computer, Inc.

Let us know what you think of these prototype pages.

Generated with Harlequin WebMaker