Skip to content

Stop surface extension searches at a certified length bracket - #3404

Open
ecke101 wants to merge 2 commits into
tangency-labs:mainfrom
ecke101:perf/surface-extension-bracket
Open

ecke101 wants to merge 2 commits into
tangency-labs:mainfrom
ecke101:perf/surface-extension-bracket

Conversation

@ecke101

@ecke101 ecke101 commented Nov 26, 2026 •

Copy link
Copy Markdown

When a requested surface extension cannot be built, the solver now stops bisecting as soon as a candidate meets the target length or provides an upper bound. It reuses midpoints already proved short by their control polygons. Accepted extensions still pass the full length check at the existing tolerances.

On two existing geometry tests, the solver made fewer attempts to construct a candidate surface. Both tests passed the same length and geometry checks on both revisions.

Test Base This PR Fewer attempts
G² fillet section 189 24 87%
Rational quarter-circle extension 369 224 39%

Run cargo test -p solidcore --lib surface::extend:: for the regressions. The new bracket test took 10 construction attempts and enforces a limit of 12.

Reproduce the counts in the table

On each revision (74a23617c and 2cb8c65c4), add this at the start of solve in crates/solidcore/src/surface/extend.rs to count calls to the candidate builder.

let original = made;
let made = &|e| { eprintln!("BUILD_CANDIDATE"); original(e) };
for case in a_gn_section_continues_past_a_foot a_far_mirror_is_met; do
  cargo test -p solidcore --lib "$case" -- --nocapture 2>&1 | grep -c BUILD_CANDIDATE
done

Summary by CodeRabbit

  • Bug Fixes
    • Improved distance measurements when extending surfaces, including cases where an extension is difficult to construct or the requested distance falls near a measurement boundary.
    • Surface side-length estimates now retain the existing relative-precision validation while supporting enclosure measurements without a requested precision.
    • Blend extensions now use the same side-based measurement approach, preserving existing behavior when a result is below measurement resolution.

ecke101 and others added 2 commits November 26, 2026 21:38
When an extension cannot be built, stop bisecting as soon as a buildable midpoint meets the requested distance or supplies a certified upper bound.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Use the unsplit control polygon to discard short candidates and retain their lower bracket for the length solve. Refine near the target and verify distances reported by a refusal.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The extension distance solver now uses shared side measurements, coarse midpoint enclosures, and bisection when candidate construction fails. Side-length enclosure calculation accepts optional relative precision. New tests cover midpoint selection and construction limits.

Changes: Surface extension distance solving

Layer / File(s) Summary
Side measurement and midpoint bounds
crates/solidcore/src/surface/side.rs, crates/solidcore/src/surface/extend.rs, crates/solidcore/src/surface/extend/tests.rs
The side-length enclosure helper accepts optional relative precision. SideMeasure uses coarse midpoint bounds and refines measurements when needed. Tests check midpoint classifications and returned measurements.
Extension callers use shared measurement
crates/solidcore/src/surface/extend.rs, crates/solidcore/src/surface/extend/blend.rs
Extension entry points and blend extensions pass SideMeasure to solve instead of local across-length callbacks. The Ruled product-form fallback remains conditional on NotExact.
Candidate bisection and bracket completion
crates/solidcore/src/surface/extend.rs, crates/solidcore/src/surface/extend/tests.rs
The solver bisects between buildable and failed asks. It uses short midpoint measurements to help complete the bracket and measures the initial lower ask when needed. A test checks that a synthetic solve meets its target within 12 constructions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant Extension as extended_by_distance_at
  participant Solver as solve
  participant Measure as SideMeasure
  participant Surface as Surface::enclose_length_across_side
  Extension->>Solver: solve requested extension distance
  Solver->>Measure: measure candidate at side and location
  Measure->>Surface: request coarse or refined enclosure
  Surface-->>Measure: return length enclosure
  Measure-->>Solver: return midpoint classification or measurement
Loading

Possibly related issues

  • tangency-labs/solidcore#3057: Both address how extension length is measured and certified at a requested side location.
  • tangency-labs/solidcore#3079: Both change the extension search behavior when candidate construction fails or produces a length below the requested margin.

Possibly related PRs

Suggested reviewers: jyviko, bherbruck

Merge Risk: Minimal · up to 2cb8c

The change makes surface-extension distance searches stop sooner when an extension cannot be built, while accepted extensions still go through the existing full length check. No actionable merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: surface extension searches now stop at a certified length bracket. The raw summary describes the distance solver stopping early via bisection and midpoint enclosures …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title states the main change: surface extension searches now stop at a certified length bracket. The raw summary describes the distance solver stopping early via bisection and midpoint enclosures that prove a midpoint is short, and the objectives say the same. The title is specific and matches the changeset, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 74a2361 and 2cb8c65.

Files selected for processing: 4

  • crates/solidcore/src/surface/extend.rs
  • crates/solidcore/src/surface/extend/blend.rs
  • crates/solidcore/src/surface/extend/tests.rs
  • crates/solidcore/src/surface/side.rs

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@ecke101
ecke101 marked this pull request as ready for review November 26, 2026 20:41

This branch has not been deployed

No deployments
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