PlanarTriangulation: reusable ISweepLineCache for the sweep-line triangulation - #6750
Draft
Grantim wants to merge 1 commit into
Draft
PlanarTriangulation: reusable ISweepLineCache for the sweep-line triangulation#6750Grantim wants to merge 1 commit into
Grantim wants to merge 1 commit into
Conversation
…ngulation SweepLineQueue now keeps all its buffers in a Cache that a caller can carry between runs via the optional cache argument of triangulateDisjointContours and fillContours2DPlan, so batch hole planning does not reallocate them per hole; HoleFillPlanner holds one cache per worker. The plan path triangulates into the cache without materializing a Mesh (triangulateDisjointContoursTopology). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-derivation of #6542 on top of current master: the interim mesh-space plan path (#6555, #6739), the region-copy sweep init (#6584) and the HolesVertIds removal (#6745) rebuilt this area, so the cache was re-implemented from scratch against today's code rather than rebased.
What it does
SweepLineQueuekeeps every buffer it grows during a run (patch topology, projected points, winding info, sweep/event/monotonation scratch, theinitMeshByLoops_maps that carried a// TODO: can be cached) in aSweepLineQueue::Cache, referenced by the queue instead of owned. A caller triangulating many contour sets one by one can carry one cache across calls:PlanarTriangulation::ISweepLineCache(abstract) +makeSweepLineCache();cacheargument ontriangulateDisjointContours(2d/2f and mesh-space) andfillContours2DPlan;triangulateDisjointContoursTopology( mesh, loops, normal, outPatchMap, cache )(MR_BIND_IGNORE): the plan path needs only connectivity, so it triangulates into the cache without materializing aMesh— the result lives in the cache until its next run;HoleFillPlannerholds one cache per worker, sogetPlanarHoleFillPlansreuses buffers across all holes a worker processes, and releases the grown per-worker planners in a parallel pass instead of the serial ETS destructor;MeshTopology::clear()— capacity-keeping reset used by the cache between runs.Behavior is unchanged: with no cache argument every entry point works on a local cache exactly as before. Plans are bit-identical to master (FNV fingerprint of
getPlanarHoleFillPlans+getPlanarHoleFillPlanover 3000 mixed 4-16-vert holes:5aef970cd4fa279eon both builds), and the boolean/hole-fill/planar-triangulation gtest subset passes identically on both.Measurements
Release x64, same exe per side, interleaved runs, medians:
getPlanarHoleFillPlans, 2000 × 16-vert holesgetPlanarHoleFillPlan× 2000, 16-vert holesOn workloads whose holes stay below
cMinSweptHoleSizethe cache is never engaged and timings are unchanged.Replaces #6542.
🤖 Generated with Claude Code