Skip to content

Changed: Moves TopologyEdit to triangulation::flips#192

Merged
acgetchell merged 3 commits intomainfrom
refactor/preludes
Feb 8, 2026
Merged

Changed: Moves TopologyEdit to triangulation::flips#192
acgetchell merged 3 commits intomainfrom
refactor/preludes

Conversation

@acgetchell
Copy link
Owner

Moves the TopologyEdit trait to triangulation::flips and renames it to BistellarFlips.

This change involves updating imports and references throughout the codebase and documentation to reflect the new location and name of the trait.

Moves the `TopologyEdit` trait to `triangulation::flips` and renames it to `BistellarFlips`.

This change involves updating imports and references throughout the codebase and documentation to reflect the new location and name of the trait.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 8, 2026

Walkthrough

The PR renames and relocates the public editing trait from TopologyEdit to BistellarFlips under a new triangulation::flips public module, updates implementations to match (including a dimension guard and safe arithmetic), reworks crate-level prelude/exports to add triangulation submodules, and updates many docs, examples, and tests to use narrower prelude imports. It also adds a doc guidance in AGENTS.md to avoid mod.rs.

Changes

Cohort / File(s) Summary
Public API & Prelude
src/lib.rs, src/triangulation/lib.rs
Add triangulation crate-root module and prelude::triangulation submodule; re-export triangulation types; remove prelude::topology::edit from public surface and add prelude::topology::validation.
Trait & Implementations
src/triangulation/flips.rs
Rename TopologyEditBistellarFlips; update impls for Triangulation and DelaunayTriangulation; add runtime guard for unsupported dimensions and use checked arithmetic; delegate flip operations through triangulation instance methods.
Module layout guidance
AGENTS.md
Documentation-only change: new Rust guidance to avoid mod.rs and declare modules in src/lib.rs/src/main.rs, support inline nested modules.
Examples
examples/pachner_roundtrip_4d.rs, examples/topology_editing_2d_3d.rs
Replace broad prelude/edit imports with targeted prelude::triangulation::*, triangulation::flips::*, and explicit type imports; no logic changes.
Docs & Guides
docs/api_design.md, docs/code_organization.md, docs/*
Update docs to reflect trait rename/location and new prelude layout; adjust import examples to delaunay::prelude::triangulation::* (and other specific prelude submodules).
Doc examples across core/geometry/topology
src/core/*, src/geometry/*, src/topology/* (many files)
Widespread doc-comment/example edits replacing use delaunay::prelude::* with more specific imports (triangulation::*, query::*, geometry::*, etc.). No runtime changes.
Tests
tests/*, src/core/delaunay_triangulation.rs
Adjust test imports to use prelude::triangulation/other specific prelude modules and replace TopologyEdit references with BistellarFlips in tests; some tests add explicit imports.
Core algorithm docs
src/core/algorithms/*, src/core/util/*
Primarily documentation/example import refinements to specific prelude submodules; negligible code changes.
Small manifests / minor files
Cargo.toml, a few small sources
Minor manifest or single-line documentation tweaks accompanying re-exports and examples.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client as Client Code
  participant Trait as BistellarFlips (trait)
  participant DT as DelaunayTriangulation
  participant TDS as Triangulation (TDS)
  participant Core as CoreAlgorithms

  Client->>Trait: request_bistellar_flip(k, args)
  Trait->>DT: (impl on DelaunayTriangulation) check & delegate
  DT->>TDS: delegate flip call (self.tri.flip_*)
  alt Triangulation impl
    Trait->>TDS: call flip method (flip_k1_insert / flip_k2 / apply_bistellar_flip_dynamic)
  end
  TDS->>Core: perform low-level flip logic / validations
  Core-->>TDS: flip result or FlipError
  TDS-->>Trait: return outcome (or FlipError::UnsupportedDimension)
  Trait-->>Client: propagate result
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

api, topology

Poem

🐰 I hopped through modules, gave names a twist,
Topology became Bistellar, a brand-new list.
Docs trimmed their imports, tests found their way,
Triangulation now leads the flip ballet.
— a rabbit’s tiny code-step, then I’m off to play 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: moving TopologyEdit trait to triangulation::flips module and renaming it to BistellarFlips, which is the core objective reflected throughout the changeset.
Description check ✅ Passed The description is directly relevant to the changeset, explaining that TopologyEdit is moved to triangulation::flips, renamed to BistellarFlips, and that imports/references are updated throughout the codebase and documentation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/preludes

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
src/lib.rs (2)

1034-1063: Consider reducing duplication between prelude layers.

Lines 1036–1046 duplicate lines 990–1000 verbatim, and flips (lines 1053–1054) re-exports DelaunayTriangulation/Triangulation a third time. This is understandable for self-contained use …::* imports, but maintaining three identical export lists is a maintenance risk — additions to one must be mirrored to the others.

One option: have prelude::triangulation re-export from prelude (or a shared internal list) rather than duplicating the item-level use declarations. For example:

♻️ Sketch: reduce duplication via a shared base
     pub mod triangulation {
-        pub use crate::core::{
-            adjacency::*,
-            cell::*,
-            delaunay_triangulation::*,
-            edge::*,
-            facet::*,
-            traits::{boundary_analysis::*, data_type::*},
-            triangulation::*,
-            triangulation_data_structure::*,
-            vertex::*,
-        };
+        // Delegate to the parent prelude so only one list needs updating.
+        pub use super::*;

This is not urgent — just flagging the drift risk for long-term maintainability.


926-927: Nit: topology doc example could use the new prelude path.

Line 927 uses the direct path delaunay::topology::characteristics::validation, but there's now a prelude::topology::validation submodule (line 1141) that re-exports the same items. For consistency with the other doc examples that all use prelude paths, consider:

-/// use delaunay::prelude::triangulation::*;
-/// use delaunay::topology::characteristics::validation;
+/// use delaunay::prelude::triangulation::*;
+/// use delaunay::prelude::topology::validation;

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot added breaking change documentation Improvements or additions to documentation geometry Geometry-related issues rust Pull requests that update rust code labels Feb 8, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/triangulation/flips.rs (1)

258-264: ⚠️ Potential issue | 🟡 Minor

D - 1 in flip_k3_inverse_from_triangle will panic at compile-time or underflow if D == 0.

Both impls pass D - 1 to apply_bistellar_flip_dynamic. If D is 0, this would underflow. This is likely impossible given the domain (triangulations are always ≥ 1D), but a compile-time assert or doc comment noting the minimum D requirement would make the contract explicit.

Also applies to: 301-307

🧹 Nitpick comments (3)
docs/code_organization.md (1)

174-176: Directory ordering: triangulation/ appears before topology/ in the tree.

Alphabetically, topology/ sorts before triangulation/ (o < r). If you regenerate the tree with the command shown at line 30, the output should have topology/ first. Consider swapping these to keep the tree consistent with the auto-generation tip.

Proposed fix
-│   ├── triangulation/
-│   │   └── flips.rs
 │   ├── topology/
 │   │   ├── characteristics/
 │   │   │   ├── euler.rs
 │   │   │   └── validation.rs
 │   │   ├── spaces/
 │   │   │   ├── euclidean.rs
 │   │   │   ├── spherical.rs
 │   │   │   └── toroidal.rs
 │   │   ├── traits/
 │   │   │   └── topological_space.rs
 │   │   └── manifold.rs
+│   ├── triangulation/
+│   │   └── flips.rs
src/triangulation/flips.rs (1)

224-265: The two BistellarFlips implementations are nearly identical — consider a macro or helper to reduce duplication.

The Triangulation and DelaunayTriangulation impls differ only in how they access tds/kernel (self.tds vs self.tri.tds). This is a common delegation pattern, but with 6 methods the duplication is noticeable. A declarative macro could generate both impls from a single definition. That said, this is a stylistic preference and the current code is perfectly clear.

Also applies to: 267-308

src/lib.rs (1)

892-911: New triangulation module is well-structured.

The module cleanly wraps the flips submodule and provides convenient re-exports of DelaunayTriangulation and Triangulation for discoverability.

One observation: the nested triangulation::prelude::flips (lines 901-906) seems redundant given that users will typically import via delaunay::prelude::triangulation::flips::* or directly via delaunay::triangulation::flips::*. If no external consumer needs the intermediate prelude, it could be removed to simplify the module tree. Not a blocker.

@codacy-production
Copy link

codacy-production bot commented Feb 8, 2026

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.03% (target: -1.00%) 9.09%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (5ab686c) 10125 6381 63.02%
Head commit (5903e4b) 10126 (+1) 6385 (+4) 63.06% (+0.03%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#192) 11 1 9.09%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@codecov
Copy link

codecov bot commented Feb 8, 2026

Codecov Report

❌ Patch coverage is 9.09091% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.08%. Comparing base (5ab686c) to head (5903e4b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/triangulation/flips.rs 9.09% 10 Missing ⚠️

❌ Your patch status has failed because the patch coverage (9.09%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #192      +/-   ##
==========================================
+ Coverage   63.05%   63.08%   +0.03%     
==========================================
  Files          46       46              
  Lines       10118    10119       +1     
==========================================
+ Hits         6380     6384       +4     
+ Misses       3738     3735       -3     
Flag Coverage Δ
unittests 63.08% <9.09%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Streamlines the prelude modules to provide clearer and more
focused exports for common triangulation tasks. This change
affects import statements in documentation and examples,
requiring more specific paths for certain types.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@tests/delaunay_incremental_insertion.rs`:
- Line 565: Remove the unused import of the Coordinate trait: delete the `use
delaunay::geometry::Coordinate;` line, since the test only constructs points via
`Point::new()` and calls inherent methods like `.coords()` which don't require
the `Coordinate` trait to be in scope; ensure no other code in this file relies
on `Coordinate` before committing.
🧹 Nitpick comments (2)
src/lib.rs (2)

1155-1161: prelude::topology::validation delegates to topology::prelude::validation.

This adds an extra indirection layer (prelude::topology::validationtopology::prelude::validation → actual items). It works, but the nesting is a bit deep. Consider whether flattening to a direct re-export from crate::topology::* would simplify the path.


985-997: topology::prelude::validation module is only consumed by prelude::topology::validation.

This intermediate topology::prelude module exists solely so that prelude::topology::validation can re-export it. If no external consumer directly uses delaunay::topology::prelude::validation, you could simplify by having prelude::topology::validation re-export directly from crate::topology::*.

Removes the redundant topology validation prelude module.

Moves its contents into the main topology prelude, simplifying
module structure and reducing code duplication. This change
internally refactors the prelude modules for better organization.
@acgetchell acgetchell merged commit c491bb9 into main Feb 8, 2026
10 of 12 checks passed
@acgetchell acgetchell deleted the refactor/preludes branch February 8, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api breaking change documentation Improvements or additions to documentation geometry Geometry-related issues rust Pull requests that update rust code topology

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant