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>
45 lines
2.4 KiB
Rust
45 lines
2.4 KiB
Rust
//! A join whose tool ends at other levels than the part, both prisms along that direction: a
|
||
//! hinge barrel under a plate's back edge, its ends flush with the sides of the leaf it hangs
|
||
//! from, the plate running on past them (#827 without its fillets). The barrel's ends lie in the
|
||
//! leaf's sides, which the B-rep boolean can't intersect, and there is no room to push them
|
||
//! apart (the plate goes on beyond them). The prisms are joined in 2D, exactly: the barrel is no
|
||
//! longer nudged (moved and turned by a hair) for the boolean to go through.
|
||
|
||
use std::f64::consts::PI;
|
||
|
||
use solidcore_record::Vec3;
|
||
|
||
use crate::*;
|
||
|
||
/// A 40 × 20 × 6 plate (z 5 … 11) with a 14 × 10 × 6 leaf under its back edge, 1 mm into it:
|
||
/// 5500 mm³.
|
||
fn plate_with_leaf() -> Body {
|
||
let plate = box_solid(Vec3::new(0., 0., 5.), Vec3::new(40., 20., 11.)).unwrap();
|
||
let leaf = box_solid(Vec3::new(10., 10., 0.), Vec3::new(24., 20., 6.)).unwrap();
|
||
boolean(&plate, &leaf, BoolOp::Union).unwrap().unwrap()
|
||
}
|
||
|
||
/// Barrels along x with their axis on the leaf's back bottom edge (y 20, z 0): radius 5 (its top
|
||
/// meets the plate's back edge) and 4.9, ends flush with both of the leaf's sides, with one, and
|
||
/// running on past both under the plate. A quarter of the barrel lies in the leaf (where the
|
||
/// leaf is). Each join is exact: one solid, and every vertex on a level along x of the
|
||
/// plate, the leaf or the barrel.
|
||
#[test]
|
||
fn a_barrel_between_the_sides_of_a_leaf_joins_exactly() {
|
||
let part = plate_with_leaf();
|
||
for (r, x0, x1) in [(5., 10., 24.), (4.9, 10., 24.), (5., 10., 23.), (5., 8.5, 25.5)] {
|
||
let what = format!("radius {r}, x {x0} … {x1}");
|
||
let barrel = cylinder(Vec3::new(x0, 20., 0.), Vec3::X, r, x1 - x0).unwrap();
|
||
let joined = boolean(&part, &barrel, BoolOp::Union).unwrap().unwrap();
|
||
assert_eq!(joined.shell_count(), 1, "{what}");
|
||
assert!(joined.validity().is_empty(), "{what}: {:?}", joined.validity());
|
||
let inside = (x1.min(24.) - x0.max(10.)) / 4.;
|
||
let want = 5500. + PI * r * r * (x1 - x0 - inside);
|
||
let v = joined.mesh(&crate::MeshTolerance::chord(1e-4)).unwrap().measure().volume;
|
||
assert!((v - want).abs() < want * 1e-5, "{what}: volume {v} vs {want}");
|
||
for p in joined.record().vertices.iter().map(|v| Vec3::from(v.point)) {
|
||
assert!([0., 10., 24., 40., x0, x1].iter().any(|x| (p.x - x).abs() < 1e-9), "{what}: a vertex at {p:?}");
|
||
}
|
||
}
|
||
}
|