Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9dfc1a8
STEP and cadmpeg import: a spline patch whose face's trims run a litt…
oursland Nov 18, 2026
e8e1474
STEP and cadmpeg import: a plane face with an edge whose pcurve has n…
oursland Nov 18, 2026
c0a6ac9
solidcore: a face whose trims lie a period round a closed spline is m…
oursland Nov 18, 2026
73cc424
solidcore: a face loop whose lowest point lies a writer's rounding be…
oursland Nov 18, 2026
4db8ace
STEP and cadmpeg import: a face across a closed spline patch's seam i…
oursland Nov 18, 2026
a8f9501
STEP and cadmpeg import: an edge wholly past the quarter line its rou…
oursland Nov 18, 2026
0f8a3f2
STEP and cadmpeg import: a pcurve end a few µm past the height a cyli…
oursland Nov 18, 2026
6c26bb8
cadmpeg import: a solid refused for several faces comes in as an open…
oursland Nov 19, 2026
003c536
STEP and cadmpeg import: a body refused for faces narrower than the t…
oursland Nov 19, 2026
b9e5b5c
solidcore: a vertex a little past one knot range of a rational patch …
oursland Nov 20, 2026
dd33275
STEP and cadmpeg import: a line where four faces meet, written as two…
oursland Nov 20, 2026
231dc71
Import through cadmpeg: a solid a file also shows as a mesh comes in …
oursland Nov 20, 2026
94b2d06
Merge origin/main into cadir-14-patch-extension
oursland Nov 21, 2026
2d9afe0
STEP import: decide patch continuation, reseams, sliver collapses and…
oursland Nov 21, 2026
47fa690
Merge remote-tracking branch 'origin/main' into cadir-14-patch-extension
oursland Nov 21, 2026
bfb16bb
STEP import: prove a sliver face away on the kernel's enclosures, not…
oursland Nov 21, 2026
8aef20a
Merge remote-tracking branch 'origin/main' into cadir-14-patch-extension
oursland Nov 21, 2026
bdaeba4
Merge remote-tracking branch 'origin/main' into cadir-14-patch-extension
oursland Nov 21, 2026
fdbd4a9
STEP and cadmpeg import: the sliver screen settles its length limit w…
oursland Nov 22, 2026
6de730f
Merge origin/main into cadir-14-patch-extension
oursland Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions crates/io/src/native_cad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,20 @@ fn traced_records(
let mut unplaced = Vec::with_capacity(read.read.len());
let looks = colours.then(|| Looks::of(ir));
let layers = HiddenLayers::of(ir);
// With `shown`, a B-rep that cannot be read comes in as the mesh the file shows it with (an
// OpenUSD `BrepArray`'s fallback mesh, a tessellation of its body), rather than not at all,
// and rather than as an open surface of the faces that read: the mesh is all of the body.
let has_triangles =
|id: &str| ir.model.tessellations.iter().any(|t| t.body.as_ref().is_some_and(|b| b.as_str() == id) && !t.triangles().is_empty());
let mut opened: Vec<(String, String)> = Vec::new();
for r in read.read {
if shown
&& has_triangles(&r.body)
&& let Some(why) = r.opened
{
opened.push((r.body, why));
continue;
}
let body = by_id.get(r.body.as_str());
let (color, paint) = looks.as_ref().map_or((None, None), |l| l.paint_of(ir, &r.body, &r.solid.face_origin));
warnings.extend(r.solid.notes.iter().map(|n| format!("{}: {n}", label(&r.body))));
Expand All @@ -138,12 +151,12 @@ fn traced_records(
};
unplaced.push(assembly::Unplaced { body: r.body, record });
}
// With `shown`, a B-rep that cannot be read comes in as the mesh the file shows it with (an
// OpenUSD `BrepArray`'s fallback mesh, a tessellation of its body), rather than not at all.
let has_triangles =
|id: &str| ir.model.tessellations.iter().any(|t| t.body.as_ref().is_some_and(|b| b.as_str() == id) && !t.triangles().is_empty());
let fallen: std::collections::HashSet<&str> =
let mut fallen: std::collections::HashSet<&str> =
if shown { read.failures.iter().map(|f| f.body.as_str()).filter(|id| has_triangles(id)).collect() } else { Default::default() };
fallen.extend(opened.iter().map(|(id, _)| id.as_str()));
warnings.extend(
opened.iter().map(|(id, why)| format!("{}: its B-rep was not imported ({why}): it came in as the mesh the file shows it with", label(id))),
);
warnings.extend(read.failures.iter().map(|f| {
if fallen.contains(f.body.as_str()) {
format!("{}: its B-rep was not imported ({}): it came in as the mesh the file shows it with", label(&f.body), f.message)
Expand Down
6 changes: 4 additions & 2 deletions crates/kernel/tests/step_export_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ const NO_READ_BACK: &[&str] = &["tests/step-regressions/thread_crest_band.step"]
/// is written as that circle (#17929). Kernel-case 3208 differs only in its uncertainty (line #8,
/// the largest edge tolerance): 1e-6 where main wrote 1.3356874714460462e-6, as the lazy UV trim
/// no longer raises its edge past the trim's proved distance, which 1e-6 covers (#18166).
/// The thread crest band's pcurve ends a rounding past its cylinder form's end height
/// (v 3.0000000000000004) are written on it (v 3.0).
/// Kernel-case 3098 writes its spline knots scaled exactly by a power of two, as the reader now
/// rescales a curve too fast to resolve its edges (#16441); the curves are the same point for point
/// (see `the_tiny_knot_span_block_exports_its_knots_scaled_exactly_and_reads_back_as_the_block`).
Expand All @@ -90,7 +92,7 @@ const DIGESTS_MACOS: &[(&str, &str)] = &[
("tests/step-conformance/grooved_shaft.step", "e08ae1efaaae2696"),
("tests/step-regressions/hole_round_revolved.step", "1749e03c3c2f194a"),
("tests/step-regressions/rod_doubled_edge.step", "ef5f1b70be16e528"),
("tests/step-regressions/thread_crest_band.step", "2053d57556b7dafa"),
("tests/step-regressions/thread_crest_band.step", "2ed5caa31e66e216"),
("(assembly)", "4256f9f7676566de"),
];

Expand Down Expand Up @@ -153,7 +155,7 @@ const DIGESTS: &[(&str, &str)] = &[
("tests/step-regressions/hole_round_revolved.step", "260e07ac4dec005d"),
("tests/step-regressions/net_steps_back_within_tolerance.step", "687c36e89ffe679a"),
("tests/step-regressions/rod_doubled_edge.step", "7e5ec3041433853c"),
("tests/step-regressions/thread_crest_band.step", "30923bc03bcfd757"),
("tests/step-regressions/thread_crest_band.step", "2dfb86551d60a9f3"),
("tests/step-regressions/tiny_rounds_coarse_tolerance.step", "0909a2e6b030bd2c"),
("tests/step-regressions/torus_patch_and_rest.step", "a82c8cbad7038460"),
("tests/step-regressions/torus_patch_and_rest_revolved.step", "6b2f15c1dc602029"),
Expand Down
67 changes: 47 additions & 20 deletions solidcore/crates/solidcore-cadir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ pub struct Read {
/// Where the body's placement puts the record (column-major 4 × 4, millimetres), when it
/// moves it. Only a rigid placement is taken: a body placed otherwise is refused.
pub placement: Option<[[f64; 4]; 4]>,
/// Why the region was refused whole, where it came in as an open surface of the faces that
/// read, without the faces the refusal names; `None` where it read as given. A reader with
/// another form of the body (a file's own mesh of it) may take that instead.
pub opened: Option<String>,
}

/// A body region that could not be read, and why.
Expand Down Expand Up @@ -161,24 +165,28 @@ pub fn read_bodies(ir: &CadIr, trims: Option<&dyn Trims>) -> Bodies {
&none,
&mut budget,
)
.map(|solid| (solid, None))
.or_else(|message| {
model.without_named_faces(
region.as_str(),
kind,
name,
model.region_tolerance(region.as_str(), tolerance(ir)),
trims,
message,
&mut budget,
)
model
.without_named_faces(
region.as_str(),
kind,
name,
model.region_tolerance(region.as_str(), tolerance(ir)),
trims,
message.clone(),
&mut budget,
)
.map(|solid| (solid, Some(message)))
});
match read {
Ok(solid) => {
Ok((solid, opened)) => {
out.read.push(Read {
body: id.clone(),
region: k,
solid,
placement,
opened,
});
}
Err(message) => out.failures.push(Failure {
Expand Down Expand Up @@ -282,11 +290,12 @@ impl<'a> Model<'a> {
matches!((at(a), at(b)), (Some(p), Some(q)) if (p - q).length() <= tol)
}

/// A region refused with `refusal`, read again without the face the refusal names, as an
/// open surface of the faces that remain (the faces that do read, sharing the edges they do):
/// what the STEP reader makes of a solid it cannot close. A refusal of that naming another face
/// of the region leaves it out too, up to [`MAX_LEFT_OUT_ROUNDS`] reads; a face is only ever
/// left out where a refusal names it. The record's notes say why it is open and each face left
/// A region refused with `refusal`, read again without the faces the refusal names (every
/// face whose pcurves failed, as the assembly names them), as an open surface of the faces
/// that remain (the faces that do read, sharing the edges they do): what the STEP reader makes
/// of a solid it cannot close. A refusal of that naming other faces of the region leaves them
/// out too, up to [`MAX_LEFT_OUT_ROUNDS`] reads; a face is only ever left out where a refusal
/// names it. The record's notes say why it is open and each face left
/// out. The refusal stands where it names no face of the region, or no read succeeds.
#[allow(clippy::too_many_arguments)]
fn without_named_faces(
Expand Down Expand Up @@ -325,13 +334,17 @@ impl<'a> Model<'a> {
// Each read is charged to the file's face budget, as the first one was: a region read
// again costs what it reads again, so refused regions cannot read past the budget.
for _ in 0..MAX_LEFT_OUT_ROUNDS {
let Some(face) = self
.named(&why)
// Every face of the region still in that the refusal names (the assembly names each
// face whose pcurves failed), left out together.
let named: Vec<u64> = self
.all_named(&why)
.into_iter()
.filter(|f| of_region.contains(f) && !skip.contains(f))
else {
.collect();
if named.is_empty() {
break;
};
skip.insert(face);
}
skip.extend(named);
left_out.push(why.clone());
if skip.len() >= of_region.len() {
break;
Expand All @@ -353,6 +366,20 @@ impl<'a> Model<'a> {
Err(refusal)
}

/// Every face a refusal names by its model index (`face #12`), in order; else the one it
/// names by its id ([`Self::named`]).
fn all_named(&self, message: &str) -> Vec<u64> {
let indices: Vec<u64> = message
.match_indices("face #")
.filter_map(|(at, _)| named_face(message.get(at..)?))
.collect();
if indices.is_empty() {
self.named(message).into_iter().collect()
} else {
indices
}
}

/// Whether every shell of region `id` is closed, as the model writes it: each edge of its
/// faces' loops used at least twice among them, but for an edge that collapses to a point
/// (no curve, or a degenerate one: [`Builder::join_collapsed`]), which no loop keeps. A face
Expand Down
52 changes: 52 additions & 0 deletions solidcore/crates/solidcore-cadir/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,58 @@ fn a_solid_refused_for_one_face_comes_in_as_an_open_surface_of_the_others() {
);
}

/// A solid refused for two faces (both planes moved 5 mm off their edges) leaves both out in one
/// read again: the refusal names every face whose pcurves failed, not only the first, so a solid
/// with more such faces than reads still comes in.
#[test]
fn a_solid_refused_for_several_faces_leaves_them_all_out_in_one_read() {
let mut ir = cube();
for k in 0..2 {
let face = ir.model.faces[k].clone();
let surface = ir
.model
.surfaces
.iter_mut()
.find(|s| s.id == face.surface)
.unwrap();
let SurfaceGeometry::Solved(SolvedSurfaceGeometry::Plane(plane)) = &surface.geometry else {
panic!("{:?}", surface.geometry)
};
let o = plane.origin().get();
let (n, u) = (
plane.frame().axis().as_raw(),
plane.frame().reference().as_raw(),
);
let moved = cadmpeg_ir::geometry::analytic::PlaneSurface::try_new(
Point3::new(o.x + 5.0 * n.x, o.y + 5.0 * n.y, o.z + 5.0 * n.z),
Vector3::new(n.x, n.y, n.z),
Vector3::new(u.x, u.y, u.z),
)
.unwrap();
surface.geometry = SurfaceGeometry::Solved(SolvedSurfaceGeometry::Plane(moved));
}
let bodies = read_bodies(&ir, None);
assert!(bodies.failures.is_empty(), "{:?}", bodies.failures);
let s = &bodies.read[0].solid;
assert!(s.sheet, "an open surface");
assert_eq!(s.brep.faces.len(), 4);
assert!(
!s.face_origin.contains(&0) && !s.face_origin.contains(&1),
"{:?}",
s.face_origin
);
let left: Vec<&String> = s
.notes
.iter()
.filter(|n| n.starts_with("left out: "))
.collect();
assert_eq!(left.len(), 1, "one read left both out: {:?}", s.notes);
assert!(
left[0].contains("face #0") && left[0].contains("face #1"),
"{left:?}"
);
}

/// A refusal that names its face by the face's id in the model (as this reader names a face it
/// cannot read: here its surface is missing) leaves that face out as one naming it by index does.
#[test]
Expand Down
Loading
Loading