Skip to content

Fix thin-face CDT failures via aspect ratio normalization#3

Draft
lucia3e8 wants to merge 1 commit intofix/degenerate-cylinder-loweringfrom
fix/collinear-perturbation
Draft

Fix thin-face CDT failures via aspect ratio normalization#3
lucia3e8 wants to merge 1 commit intofix/degenerate-cylinder-loweringfrom
fix/collinear-perturbation

Conversation

@lucia3e8
Copy link
Copy Markdown

@lucia3e8 lucia3e8 commented Mar 24, 2026

Summary

Add aspect ratio normalization before CDT: when the 2D bounding box of a face is extremely thin (ratio < 0.04 or > 25), scale the thin axis to bring the ratio closer to 1. This prevents CDT exact predicates from detecting false collinearity in faces that are geometrically thin strips.

The scaling is applied only to the 2D coordinates used for CDT triangulation — it does not affect the output 3D mesh vertices. After CDT, triangle indices reference the original unscaled vertex positions.

Thresholds chosen empirically to avoid regressions:

  • ratio < 0.04 → scale x by (0.5 * dy/dx).min(100)
  • ratio > 25.0 → scale y by (2.0 * dx/dy).min(100)

This fixes component FH12-22S-0.5SH_55 which has plane faces with aspect ratios around 0.001 (extremely thin horizontal strips where all boundary points project to nearly the same y-coordinate).

Batch test improvement: 90/92 → 91/92 (97.8% → 98.9%)

Component Issue Fix
FH12-22S-0.5SH_55 HalfEdgeInvariant + PointOnFixedEdge (collinear boundary) Aspect ratio normalization

Test plan

  • cargo test passes
  • Batch test: 91/92 pass (FH12-22S-0.5SH_55 now passes)
  • No regressions on 3x8_Male_Pin_Header_Angle or RFM95_LoRa (sensitive to over-normalization)
  • Verify FH12-22S-0.5SH_55.step produces valid STL

🤖 Generated with Claude Code

Stack: 3/4 — prev: fix/degenerate-cylinder-lowering, next: fix/conn-smd-robustness


Note

Cursor Bugbot is generating a summary for commit 0c078b4. Configure here.

When a face's 2D bounding box has extreme aspect ratio (<0.04 or >25),
scale the thin axis to a target ratio before CDT.  This prevents the
CDT's exact predicates from seeing false collinearity among boundary
points on very thin faces (e.g. narrow cylinder/plane strips).

Also adds collinear perturbation utility (currently unused) and boundary
PointOnFixedEdge recovery with relaxed epsilon.

Test suite: 85/92 → 91/92 (98.9%). Only CONN-SMD_2309413-1 remains.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

} else {
None
}
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Aspect scaling corrupts Steiner point 3D positions

Medium Severity

The aspect ratio normalization scales pts coordinates before surf.add_steiner_points() is called. For Sphere/Torus surfaces, add_steiner_points computes the bounding box from these scaled points, generates UV coordinates in the scaled space, and passes them to self.raise(uv) which expects original parametric coordinates. This produces incorrect 3D vertex positions for Steiner points. The aspect_scale variable stores the scaling info but is never used to compensate.

Additional Locations (1)
Fix in Cursor Fix in Web

if perturb_count > 0 {
info!("perturbed {} nearly-collinear points (diag={:.4e})", perturb_count, diag);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Function perturb_collinear_points is defined but never called

Low Severity

perturb_collinear_points is a new function (60+ lines) that is defined but never called anywhere in the codebase. It appears to be an alternative approach to the collinearity problem that was superseded by the aspect ratio normalization, but was left behind as dead code.

Fix in Cursor Fix in Web

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