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>
67 lines
3.5 KiB
Rust
67 lines
3.5 KiB
Rust
//! Partial planar contact must sew a solid without displacing or inventing material.
|
|
use crate::*;
|
|
use solidcore_record::Vec3;
|
|
use solidcraft_geom::prelude::*;
|
|
use std::f64::consts::PI;
|
|
|
|
#[test]
|
|
fn split_contact_arc_crossing_one_edge_twice_preserves_the_body() {
|
|
let a = box_solid(Vec3::ZERO, Vec3::new(25.0, 47.5, 37.5)).unwrap();
|
|
let b = cylinder(Vec3::new(0.0, 7.5, 0.0), -Vec3::X, 5.0, 2.5).unwrap();
|
|
let face = a.faces(0.01).unwrap().iter().position(|f| f.plane_normal.is_some_and(|n| n.dot(-Vec3::X) > 0.99)).unwrap();
|
|
let side = b
|
|
.record()
|
|
.faces
|
|
.iter()
|
|
.position(|f| !matches!(f.surface, solidcore_record::brep::Surface::Plane { .. } | solidcore_record::brep::Surface::PlaneThrough { .. }))
|
|
.unwrap();
|
|
let r = split_faces(&a, &[face], &SplitTool::Face { body: &b, face: side }).unwrap();
|
|
assert_eq!(r.face_count(), a.face_count() + 1);
|
|
assert!(r.validity().is_empty(), "{:?}", r.validity());
|
|
assert!(r.history().is_some());
|
|
let (before, after) = (measure(&a).unwrap(), measure(&r).unwrap());
|
|
assert!((before.volume - after.volume).abs() < 1e-7);
|
|
assert!((before.area - after.area).abs() < 1e-7);
|
|
}
|
|
|
|
#[test]
|
|
fn partial_contact_retains_an_authored_split_away_from_the_contact() {
|
|
let a = box_solid(Vec3::ZERO, Vec3::new(25.0, 47.5, 37.5)).unwrap();
|
|
let face = a.faces(0.01).unwrap().iter().position(|f| f.plane_normal.is_some_and(|n| n.dot(Vec3::X) > 0.99)).unwrap();
|
|
let a = split_faces(&a, &[face], &SplitTool::Plane(solidcore_record::Plane { origin: Vec3::new(0.0, 0.0, 15.0), ..solidcore_record::Plane::XY }))
|
|
.unwrap();
|
|
let b = cylinder(Vec3::new(0.0, 7.5, 0.0), -Vec3::X, 5.0, 2.5).unwrap();
|
|
let r = boolean(&a, &b, BoolOp::Union).unwrap().unwrap();
|
|
assert_eq!(r.split_lines(), a.split_lines());
|
|
assert!(r.regularization_protected);
|
|
assert!(r.validity().is_empty());
|
|
let remote_faces =
|
|
r.faces(0.01).unwrap().iter().filter(|f| f.plane_normal.is_some_and(|n| n.dot(Vec3::X) > 0.99) && (f.centroid.x - 25.0).abs() < 1e-7).count();
|
|
assert_eq!(remote_faces, 2);
|
|
}
|
|
|
|
#[test]
|
|
fn partial_circular_contact_preserves_material_and_history() {
|
|
for z in [-3.0_f64, 0.0, 3.0] {
|
|
for angle in [0.0, 0.37] {
|
|
let a = box_solid(Vec3::ZERO, Vec3::new(25.0, 47.5, 37.5)).unwrap();
|
|
let b = cylinder(Vec3::new(0.0, 7.5, z), -Vec3::X, 5.0, 2.5).unwrap();
|
|
let place = |body: &Body| transform(body, Vec3::new(4.0, -8.0, 2.0), Vec3::ZERO, Vec3::new(1.0, 2.0, 3.0), angle).unwrap();
|
|
let (a, b) = (place(&a), place(&b));
|
|
for reversed in [false, true] {
|
|
let (a, b) = if reversed { (&b, &a) } else { (&a, &b) };
|
|
let r = boolean(a, b, BoolOp::Union).unwrap().unwrap();
|
|
assert!(r.validity().is_empty(), "z={z} angle={angle}: {:?}", r.validity());
|
|
assert_eq!(r.shell_count(), 1);
|
|
assert!(r.history().is_some(), "missing history z={z} angle={angle}");
|
|
let m = measure(&r).unwrap();
|
|
let volume = 25.0 * 47.5 * 37.5 + PI * 25.0 * 2.5;
|
|
let contact = 25.0 * (-z / 5.0).acos() + z * (25.0 - z * z).sqrt();
|
|
let area = 2.0 * (25.0 * 47.5 + 25.0 * 37.5 + 47.5 * 37.5) + 2.0 * PI * 5.0 * (5.0 + 2.5) - 2.0 * contact;
|
|
assert!((m.volume - volume).abs() < 0.1, "z={z} angle={angle}: volume {} expected {volume}", m.volume);
|
|
assert!((m.area - area).abs() < 0.2, "z={z} angle={angle}: area {} expected {area}", m.area);
|
|
}
|
|
}
|
|
}
|
|
}
|