IndexedPolyfaceWalker Class

The IndexedPolyfaceWalker class supports navigation around facets, across edges, and around vertices in an IndexedPolyface.

  • Compare to the IndexedPolyfaceVisitor class, which supports the iteration of facets in an IndexedPolyface.
  • A one-time call to buildEdgeMateIndices creates and populates the data.edgeMateIndex array on the input.
    • This array essentially completes the topology of the IndexedPolyface by storing facet adjacency.
  • After this setup, caller code can create IndexedPolyfaceWalker objects via:
    • walker = IndexedPolyfaceWalker.createAtFacetIndex(polyface, facetIndex, offsetWithinFacet)
    • walker = IndexedPolyfaceWalker.createAtEdgeIndex(polyface, edgeIndex)
    • walker = IndexedPolyfaceWalker.createAtVisitor(visitor, offsetWithinFacet)
  • Once you have a walker object, you can traverse the facet, edge, and vertex loops it references. For example, if walker.edgeIndex === A, referring to the right edge of the upper left facet pictured below, then the following are true:
    • walker.nextAroundFacet().edgeIndex === B
    • walker.previousAroundFacet().edgeIndex === C
    • walker.edgeMate().edgeIndex === F
    • walker.nextAroundVertex().edgeIndex === E
    • walker.previousAroundVertex().edgeIndex === D
       # --------- # --------- #
       |   < < < B | F         |
       |         ^ | v         |
       |         ^ | v         |
       |         ^ | v         |
       | C > > > A | D > > >   |
       # --------- # --------- #
       |   < < < E |           |
       |           |           |
       |           |           |
       |           |           |
       # --------- # --------- #
      
  • When facets are viewed so that the face loops stored in the PolyfaceData pointIndex array have counterclockwise ordering, an edge "from A to B" has facet area to the left and the edge to the right. Likewise, the edges "out of" locations B, C, E, F, D are directed as depicted above.
  • With this conventional counterclockwise ordering of face loops, "next" is counterclockwise, and "previous" is clockwise:
  • The nextAroundFacet steps for a walker and its edgeMate are in opposite directions along their shared edge, when that edge is interior. Thus the edgeMate step can be seen to iterate an "edge loop" of two locations for an interior edges.
  • Invalid Walkers:
    • An invalid walker has undefined edgeIndex. For these walkers, isUndefined returns true, and isValid returns false. Traversal operations on an invalid walker return an invalid walker.
    • Invalid walkers are expected during traversals of a mesh with boundary edges, so calling code must be prepared. Boundary edges have exactly one adjacent facet, so for these edges the edgeMate step returns an invalid walker. In the diagram above, the edgeMate of boundary edge B is undefined.
    • Invalid walkers can occur while traversing boundary vertices as well. If an edge lacks an edgeMate, then the previousAroundVertex step yields an invalid walker, because previousAroundVertex is implemented as edgeMate followed by nextAroundFacet. In the diagram above, the previousAroundVertex step at boundary edge B yields undefined walker. Similarly, the nextAroundVertex step at edge F yields undefined walker.
    • Invalid walkers can also occur while traversing a non-manifold mesh. Such meshes feature edge(s) with more than two adjacent facets, or with two adjacent facets that have opposite orientations. These meshes are uncommon, and usually indicate a construction problem.
  • See buildEdgeMateIndices for further description of the topological relations.

Methods

Name Description
clone(edgeIndex?: number): undefined | IndexedPolyfaceWalker Create a new IndexedPolyfaceWalker from the instance.  
edgeMate(result?: IndexedPolyfaceWalker): IndexedPolyfaceWalker Return a walker (new or reused) at the edge mate of this walker's edge.  
isDifferentEdgeInSamePolyface(other: IndexedPolyfaceWalker): boolean Test if two walkers are at different edges in the same polyface.  
isSameEdge(other: IndexedPolyfaceWalker): boolean Test if two walkers are in the same polyface at the same edge.  
loadVisitor(visitor: IndexedPolyfaceVisitor): boolean Load the walker's facet into the given visitor.  
nextAroundFacet(result?: IndexedPolyfaceWalker): IndexedPolyfaceWalker Return a walker (new or reused) at the next edge around the facet.  
nextAroundVertex(result?: IndexedPolyfaceWalker): IndexedPolyfaceWalker Return a walker (new or reused) at the next outbound edge around the vertex at the base of this walker's edge.  
previousAroundFacet(result?: IndexedPolyfaceWalker): IndexedPolyfaceWalker Return a walker (new or reused) at the previous edge around the facet.  
previousAroundVertex(result?: IndexedPolyfaceWalker): IndexedPolyfaceWalker Return a walker (new or reused) at the previous outbound edge around the vertex at the base of this walker's edge.  
buildEdgeMateIndices(polyface: IndexedPolyface): void Static Build the edgeMate index array into the polyface's PolyfaceData.  
createAtEdgeIndex(polyface: IndexedPolyface, edgeIndex?: number): IndexedPolyfaceWalker Static Create a walker for a given polyface at an optional edge.  
createAtFacetIndex(polyface: IndexedPolyface, facetIndex: number, offsetWithinFacet: number0): IndexedPolyfaceWalker Static Create a walker for a given polyface at a specified facet.  
createAtVisitor(visitor: IndexedPolyfaceVisitor, offsetWithinFacet: number0): IndexedPolyfaceWalker Static Create a walker at the facet specified by a visitor.  

Properties

Name Type Description
edgeIndex Accessor ReadOnly undefined | number Return the edge index of this walker.  
isUndefined Accessor ReadOnly boolean Return true if the walker's edgeIndex is undefined.  
isValid Accessor ReadOnly boolean Return true if the walker's edgeIndex is defined.  
polyface Accessor ReadOnly undefined | IndexedPolyface Return the polyface of this walker.  

Defined in

Last Updated: 21 February, 2025