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.edgeMateIndexarray on the input.- This array essentially completes the topology of the
IndexedPolyfaceby storing facet adjacency.
- This array essentially completes the topology of the
- After this setup, caller code can create
IndexedPolyfaceWalkerobjects 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 === Bwalker.previousAroundFacet().edgeIndex === Cwalker.edgeMate().edgeIndex === Fwalker.nextAroundVertex().edgeIndex === Ewalker.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
pointIndexarray 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 step is counterclockwise around the facet.
- The previousAroundFacet step is clockwise around the facet.
- The nextAroundVertex step is counterclockwise around the vertex.
- The previousAroundVertex step is clockwise around the vertex.
- The
nextAroundFacetsteps for a walker and its edgeMate are in opposite directions along their shared edge, when that edge is interior. Thus theedgeMatestep can be seen to iterate an "edge loop" of two locations for an interior edge. - 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
edgeMatestep returns an invalid walker. In the diagram above, theedgeMateof boundary edge B is undefined. - Invalid walkers can occur while traversing boundary vertices as well. If an edge lacks an
edgeMate, then thepreviousAroundVertexstep yields an invalid walker, becausepreviousAroundVertexis implemented asedgeMatefollowed bynextAroundFacet. In the diagram above, thepreviousAroundVertexstep at boundary edge B yields undefined walker. Similarly, thenextAroundVertexstep 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.
- Note that a null edge, for which the start and end vertex is the same, does not yield an invalid walker.
- See buildEdgeMateIndices for further description of the topological relations.
Methods
| Name | Description | |
|---|---|---|
| clone(result?: IndexedPolyfaceWalker): 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: number = 0): IndexedPolyfaceWalker Static | Create a walker for a given polyface at a specified facet. | |
| createAtVisitor(visitor: IndexedPolyfaceVisitor, offsetWithinFacet: number = 0): 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. | |
| isNull Accessor ReadOnly | boolean | Whether the walker is at a null edge, i.e. | |
| 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 | IndexedPolyface | Return the polyface of this walker. |
Defined in
Last Updated: 24 October, 2025
Found something wrong, missing, or unclear on this page? Raise an issue in our repo.