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>
81 lines
3.6 KiB
Rust
81 lines
3.6 KiB
Rust
//! A face whose edge is an intersection curve that does not evaluate (#1252): meshing it neither
|
|
//! panics nor gives non-finite points.
|
|
|
|
use solidcore_record::brep::{self as b, Curve, Curve2, Surface};
|
|
|
|
/// A plane at height `z` with its parameters along x and y.
|
|
fn plane(z: f64) -> Surface {
|
|
Surface::Plane { origin: [0.0, 0.0, z], u_axis: [1.0, 0.0, 0.0], v_axis: [0.0, 1.0, 0.0] }
|
|
}
|
|
|
|
/// A triangular sheet at z = 0.5 whose first edge is the intersection of two planes: the parallel
|
|
/// planes `z = 0` and `z = 1` when `support_gap` is `1.0` (the projection onto both never
|
|
/// converges), the same plane twice when it is `0.0` (the leader lies on both and always
|
|
/// evaluates).
|
|
fn triangle_with_intersection_edge(support_gap: f64) -> b::Brep {
|
|
let corners = [[0.0, 0.0, 0.5], [1.0, 0.0, 0.5], [0.5, 1.0, 0.5]];
|
|
let uv = [[0.0, 0.0], [1.0, 0.0], [0.5, 1.0]];
|
|
let traced = Curve::SurfaceIntersection {
|
|
surfaces: [Box::new(plane(0.5 - support_gap / 2.0)), Box::new(plane(0.5 + support_gap / 2.0))],
|
|
leader: Box::new(Curve::Polyline { points: vec![corners[0], corners[1]] }),
|
|
tolerance: 0.01,
|
|
};
|
|
let curve = |k: usize| if k == 0 { traced.clone() } else { Curve::Line { start: corners[k], end: corners[(k + 1) % 3] } };
|
|
let edges = (0..3)
|
|
.map(|k| b::Edge {
|
|
nurbs: None,
|
|
curve: curve(k),
|
|
interval: [0.0, 1.0],
|
|
vertices: [k as u32, ((k + 1) % 3) as u32],
|
|
tolerance: 1e-6,
|
|
uses: Vec::new(),
|
|
})
|
|
.collect();
|
|
let uses = (0..3)
|
|
.map(|k| b::OrientedEdge {
|
|
edge: k as u32,
|
|
forward: true,
|
|
pcurve: Curve2::Spline { knots: vec![0.0, 0.0, 1.0, 1.0], points: vec![uv[k], uv[(k + 1) % 3]] },
|
|
})
|
|
.collect();
|
|
let face = b::Face { nurbs: None, surface: plane(0.5), domain: [[0.0, 1.0], [0.0, 1.0]], loops: vec![b::Loop::Edges { edges: uses }] };
|
|
let loose = b::Brep {
|
|
version: b::VERSION,
|
|
tolerance: 1e-6,
|
|
regions: vec![b::Region { shells: vec![0], void: false }],
|
|
shells: vec![b::Shell::Faces { faces: vec![b::OrientedFace { face: 0, forward: true }], wires: Vec::new() }],
|
|
faces: vec![face],
|
|
edges,
|
|
vertices: corners.iter().map(|p| b::Vertex { point: *p, tolerance: 1e-6 }).collect(),
|
|
};
|
|
loose.canonical().unwrap().brep
|
|
}
|
|
|
|
/// Meshing an edge whose intersection curve does not evaluate (#1252): the two supports here are
|
|
/// parallel planes, so the projection never converges. Nothing may panic (wasm aborts on one, and
|
|
/// the native guard prints the message first), and a mesh that comes back is finite.
|
|
#[test]
|
|
fn meshing_an_edge_that_does_not_evaluate_neither_panics_nor_goes_non_finite() {
|
|
use std::sync::Arc;
|
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
|
for gap in [1.0, 0.0] {
|
|
let me = std::thread::current().id();
|
|
let count = Arc::new(AtomicUsize::new(0));
|
|
let c2 = count.clone();
|
|
let prev = std::panic::take_hook();
|
|
std::panic::set_hook(Box::new(move |_| {
|
|
if std::thread::current().id() == me {
|
|
c2.fetch_add(1, Ordering::SeqCst);
|
|
}
|
|
}));
|
|
let meshed = std::panic::catch_unwind(|| {
|
|
crate::Body::from_record(triangle_with_intersection_edge(gap)).and_then(|body| body.mesh(&crate::MeshTolerance::chord(0.01)))
|
|
});
|
|
std::panic::set_hook(prev);
|
|
assert_eq!(count.load(Ordering::SeqCst), 0, "gap {gap}: panics while meshing");
|
|
if let Ok(Ok(mesh)) = meshed {
|
|
assert!(mesh.positions.iter().all(|p| p.is_finite()), "gap {gap}");
|
|
}
|
|
}
|
|
}
|