Skip to content

Add PolygonSplitter for symmetric edge clipping and polygon-level classification#247

Open
TheBeachLab wants to merge 3 commits into
gkjohnson:mainfrom
TheBeachLab:feature/polygon-splitter
Open

Add PolygonSplitter for symmetric edge clipping and polygon-level classification#247
TheBeachLab wants to merge 3 commits into
gkjohnson:mainfrom
TheBeachLab:feature/polygon-splitter

Conversation

@TheBeachLab
Copy link
Copy Markdown

Summary

Addresses #51 — enables symmetrical clipping along connected edges by replacing CDTTriangleSplitter with a new PolygonSplitter that:

  • Groups CDT sub-triangles into polygon regions via flood-fill over non-constraint adjacency
  • Classifies each polygon region with a single raycast instead of one per sub-triangle
  • Shares canonical intersection edge instances between both geometry sides to ensure symmetric vertex positions

Changes

  • New PolygonSplitter class (src/core/PolygonSplitter.js) — extends CDT triangulation with getPolygonRegions() flood-fill grouping
  • Updated performSplitTriangleOperations (src/core/operations/operations.js) — iterates polygon regions for bulk classification, removes dead connectivity traversal code
  • Canonical edge sharing (src/core/operations/operationsUtils.js) — both intersection maps reference the same Line3 instance per intersection edge
  • Removed CDTTriangleSplitterPolygonSplitter replaces it as the useCDTClipping = true backend

Test Plan

  • All 36 existing + new unit tests pass (npm test)
  • Volume correctness verified for SUBTRACTION, INTERSECTION, ADDITION with useCDTClipping = true
  • Visual verification via simple example — no missing triangles or holes
  • Performance improvement observed (~3x on simple SUBTRACTION case)
  • Lint passes with 0 errors
  • Build succeeds

Replaces CDTTriangleSplitter with a polygon-aware approach that groups
split sub-triangles into regions for bulk classification, reducing
raycasts and enabling symmetric edge matching across CSG boundaries.
5-task TDD plan: create PolygonSplitter with flood-fill polygon
grouping, wire into Evaluator, update split triangle operations for
bulk classification, add canonical edge sharing, verify with benchmarks.
Replace CDTTriangleSplitter with PolygonSplitter that groups CDT
sub-triangles into polygon regions via flood-fill, classifies each
region with a single raycast, and shares canonical edge instances
between intersection maps for symmetric vertex positions.
@TheBeachLab TheBeachLab force-pushed the feature/polygon-splitter branch from 703d628 to 900a45d Compare March 28, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant