refactor(modify): take plane geometry from cadkernel

TRIM, FILLET and EXPLODE each carried their own copy of the same plane
maths. The copies had already drifted apart: `ll` differed only in
parameter names between trim.rs and fillet.rs, `arc_pts` only in which
angle helper it called, and `norm` meant angle normalisation in trim.rs
and explode.rs while meaning vector normalisation in two other files.

The implementations now live in cadkernel's geom2d. A new local `geom`
module adapts the call shapes — the kernel takes `[f64; 2]` points and
returns `[f64; 3]`, while these commands pass loose scalars and feed
`WireModel::points`, which is `[f32; 3]`. Narrowing stays on this side
because only the caller knows whether it is a preview wire, which leaves
`points_low` empty and accepts the loss, or resident geometry, which
splits the f64 into a high/low pair instead.

Call sites are untouched: the kernel functions are imported under the old
local names, so the signatures they were written against still hold.

This also fixes ELLIPSE trim and extend previews. `ellipse_pts` wrote its
components as [x, z, y] while `arc_pts` — reached from the same match in
`entity_pts`, feeding the same `[f32; 3]` — wrote [x, y, z], and
`WireModel::points` is documented as world-space positions. Ellipse
previews were collapsing onto y = 0 and displacing along Z. The kernel's
`ellipse_arc` orders them correctly, so delegating corrects it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 5 committed 2026-08-08 15:27:45 +03:00
1 parent 051272ad71
commit d0cc3284d2
6 files changed
+152 -272

No files matched your search

+1 -5
View File
@@ -14,7 +14,7 @@
//
// Unsupported entity types are skipped silently.
use std::f64::consts::TAU;
use super::geom::normalize_angle as norm_angle;
use acadrust::entities::EntityCommon;
use acadrust::entities::{
@@ -260,10 +260,6 @@ fn bulge_to_arc(
Some(EntityType::Arc(arc))
}
fn norm_angle(a: f64) -> f64 {
((a % TAU) + TAU) % TAU
}
fn explode_mline(ml: &MLine) -> Vec<EntityType> {
let n = ml.vertices.len();
if n < 2 {