dc38349cbf
* Kernel: the B-rep record and the native body file come from solidcore-record SolidCraft's portable B-rep record (`solidcraft_geom::brep`: brep.rs, topology, history, envelope, part, curve2) and the native body file (`solidcraft_kernel::native`: the tagged binary codec and the container) move to solidcore's `solidcore-record` crate: geometry as data, with structural validation and no maths (solidcore's docs/layers.md, stage 1). Every caller uses `solidcore_record::brep` and `solidcore_record::native`; the old copies are deleted. What computes from coordinates stays with the kernel, in geom's `brep`: - `brep::check`: the record's geometric checks (orthonormal frames, non-degenerate planes, unit revolution axes, non-singular placements). `check::validate` and `check::validate_built` are the record's validation and these together, and every caller of `Brep::validate` uses them, so what is accepted is unchanged; - `brep::label`: a surface's natural ranges (a cone's apex), `curve_interval`, `edge_curve_interval` and `form_turns`; - `brep::pcurve::eval`: a pcurve's point; - `geometry::check`, `placement::moved` and `split_edges` become functions on the record. The kernel's native module keeps the conversion between a body and its saved record (metadata.rs) and checks the decoded record's geometry. `native/analytic.rs`, which no module declared, is deleted. solidcore-record is pinned to its rev on solidcore's `layer-record` branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NvoxKMbMFSQU8tzRtoJhtT * Geometry: Vec2, Vec3, Plane and the profile types come from solidcore-record The plain data of vectors and points, sketch planes and planar profiles (`Seg2`, `Loop2`, `Region2`) moves to `solidcore-record`, with its constants and component-wise operators only (owner decision, solidcore layer split). Their geometry stays in geom as traits: `Vec2Geom`, `Vec3Geom`, `PlaneGeom`, `Seg2Geom`, `Loop2Geom`, `Region2Geom`, `Seg2ArcFit`, `Loop2ArcFit` and `Region2ArcFit`, in scope with `use solidcraft_geom::prelude::*`. Every caller names the types from `solidcore_record`; geom no longer defines or re-exports them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NvoxKMbMFSQU8tzRtoJhtT * Kernel: pin solidcore-record to solidcore main f5e8e9a29 solidcore-record is merged on solidcore main (tangency-labs/solidcore#2519); its crate there is identical to the rev pinned before but for its clippy configuration. The lock is regenerated against the merged rev. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NvoxKMbMFSQU8tzRtoJhtT --------- Co-authored-by: jyviko <2501648+jyviko@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
2.4 KiB
Rust
49 lines
2.4 KiB
Rust
//! #1038: a small hole on a large curved face cuts cleanly, its rim on the face an intersection
|
||
//! edge.
|
||
|
||
use solidcore_record::brep::Curve;
|
||
use solidcore_record::{Loop2, Plane, Region2, Seg2, Vec2, Vec3};
|
||
use solidcraft_geom::prelude::*;
|
||
|
||
use crate::{Body, BoolOp, build::extrude, cylinder, ops::boolean};
|
||
|
||
/// A 200 × 200 block whose top is one cubic wave across x (a single B-spline face), with a
|
||
/// Ø1 mm hole through it at the middle.
|
||
fn holed() -> (Body, Body) {
|
||
let plane = Plane::new(Vec3::new(0.0, 200.0, 0.0), Vec3::X, Vec3::Z).unwrap();
|
||
let (a, b, c, d) = (Vec2::new(0.0, 0.0), Vec2::new(200.0, 0.0), Vec2::new(200.0, 40.0), Vec2::new(0.0, 40.0));
|
||
let top = Seg2::Cubic { p0: c, p1: Vec2::new(133.0, 70.0), p2: Vec2::new(67.0, 10.0), p3: d };
|
||
let outer = Loop2 { segs: vec![Seg2::Line { a, b }, Seg2::Line { a: b, b: c }, top, Seg2::Line { a: d, b: a }] };
|
||
let block = extrude(&plane, &[Region2 { outer, holes: vec![] }], 0.0, 200.0).unwrap().pop().unwrap();
|
||
let tool = cylinder(Vec3::new(100.0, 100.0, -10.0), Vec3::Z, 0.5, 100.0).unwrap();
|
||
let cut = boolean(&block, &tool, BoolOp::Cut).unwrap().unwrap();
|
||
(block, cut)
|
||
}
|
||
|
||
/// The edges that are intersection curves: neither lines nor conics (a hole's rim on a spline
|
||
/// face is a spline).
|
||
fn intersection_curves(body: &Body) -> Vec<Curve> {
|
||
body.record()
|
||
.edges
|
||
.iter()
|
||
.map(|e| e.curve.clone())
|
||
.filter(|c| matches!(c, Curve::Spline { .. } | Curve::RationalSpline { .. } | Curve::SurfaceIntersection { .. }))
|
||
.collect()
|
||
}
|
||
|
||
#[test]
|
||
fn a_small_hole_in_a_large_spline_face_cuts_cleanly() {
|
||
let (block, cut) = holed();
|
||
assert!(cut.validity().is_empty(), "{:?}", cut.validity());
|
||
// The hole adds its wall (one cylinder, closed along its seam) and splits nothing: the
|
||
// bottom and the wave each gain a loop.
|
||
assert_eq!(cut.face_count(), block.face_count() + 1);
|
||
let curves = intersection_curves(&cut);
|
||
assert!(!curves.is_empty(), "the hole's rim on the wave is an intersection edge");
|
||
// The wave is within a few tenths of a millimetre of flat across a Ø1 hole, so the hole
|
||
// removes a cylinder as tall as the wave at its axis (the cubic's middle: z = 40).
|
||
let (v0, v1) = (block.volume_at(0.001).unwrap(), cut.volume_at(0.001).unwrap());
|
||
let removed = std::f64::consts::PI * 0.25 * 40.0;
|
||
assert!((v0 - v1 - removed).abs() < 0.05 * removed, "removed {} of {removed}", v0 - v1);
|
||
}
|