Skip to content

(HalfEdgeMesh) Improve interface for iteration #4

@csparker247

Description

@csparker247

Summary

Two related problems with the current iteration interface:

1. All iteration methods return std::vector by value (P1)
vertices(), edges(), faces(), vertices_interior(), vertices_boundary(), wheel(), boundaries(), outgoing_edges(), and connected_components() all allocate and return a new std::vector on every call. The ABF/ABFPlusPlus solvers call these in tight per-iteration loops, causing O(n) heap allocations per solver step.

2. FacePtr iteration requires *face dereference (A2)
Range-based iteration over a face pointer requires for (const auto& e : *face) rather than for (const auto& e : face->edges()).

Proposed Fix

Replace vector-returning methods with lazy range views:

  • std::span (or similar) for contiguous storage (vertices, edges, faces)
  • Custom iterator/sentinel for linked-list traversals (wheel, outgoing_edges, boundaries, face edges)

Add face->edges() as a named iterable accessor.

Acceptance Criteria

  • Hot-path iteration does not heap-allocate on every call
  • face->edges() works in range-based for loops
  • for (const auto& e : *face) continues to work (no breaking change)
  • All existing tests pass

Conductor Tracks

  • P1 — iteration redesign
  • A2face->edges() accessor (subsumed by P1)

Migrated from GitLab issue #3

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions