From 47f3e2e8ef0ed308a3ffed0fb163eec399e294d0 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Wed, 30 Sep 2026 15:55:27 +0300 Subject: [PATCH] fix(solids): a 3D drawing with bad pcurves opens instead of hanging Two causes behind the load stalling at the scene-cache step: - Solids were fitted to the ACIS header's first tolerance-line value, which is the millimetres-per-unit scale (25.4 in this inch drawing, 1 in most), not a tolerance. It is now resabs, the second value. - The kernel (37b6902) drops pcurves that miss their edge and caps the pcurve walk, so a solid carrying a bad pcurve no longer refines an edge hundreds of thousands of times. Graph b741bd6. The attached drawing now meshes all 76 solids in 3.4 s (release) and opens in 19 s in a debug build. Fixes #1538 Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 6 +++--- Cargo.toml | 6 +++--- src/scene/convert/acis_kernel.rs | 12 ++++++++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2628a1dc3..8e192cbbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4228,7 +4228,7 @@ dependencies = [ [[package]] name = "opencadgraph" version = "0.1.0" -source = "git+https://github.com/HakanSeven12/opencadgraph.git?rev=455c878#455c8789052a227a7a7f9249ece9c1ec7163d166" +source = "git+https://github.com/HakanSeven12/opencadgraph.git?rev=b741bd6#b741bd6aeb3b19222f8fa489b7a556552359df8f" dependencies = [ "opencadkernel", "serde_json", @@ -4237,7 +4237,7 @@ dependencies = [ [[package]] name = "opencadkernel" version = "0.1.0" -source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=019d3b1#019d3b17ad1842a1aebfffeb50bbc0bdac64899c" +source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=37b6902#37b690219af25ae21a9952bc36c6d82cc9dc40eb" dependencies = [ "cavalier_contours", "opencadcodec", @@ -4248,7 +4248,7 @@ dependencies = [ [[package]] name = "opencadkernel-constraints" version = "0.1.0" -source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=019d3b1#019d3b17ad1842a1aebfffeb50bbc0bdac64899c" +source = "git+https://github.com/HakanSeven12/opencadkernel.git?rev=37b6902#37b690219af25ae21a9952bc36c6d82cc9dc40eb" dependencies = [ "nalgebra", ] diff --git a/Cargo.toml b/Cargo.toml index b75183f4d..d465e2aa8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,9 +34,9 @@ clap = { version = "4", features = ["derive", "string"] } env_logger = "0.11" log = "0.4" codec = { package = "opencadcodec", git = "https://github.com/HakanSeven12/opencadcodec.git", rev = "54e6fa1", features = ["serde"] } -kernel = { package = "opencadkernel", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "019d3b1", features = ["acis", "offset"] } -kernel-constraints = { package = "opencadkernel-constraints", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "019d3b1" } -graph = { package = "opencadgraph", git = "https://github.com/HakanSeven12/opencadgraph.git", rev = "455c878" } +kernel = { package = "opencadkernel", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "37b6902", features = ["acis", "offset"] } +kernel-constraints = { package = "opencadkernel-constraints", git = "https://github.com/HakanSeven12/opencadkernel.git", rev = "37b6902" } +graph = { package = "opencadgraph", git = "https://github.com/HakanSeven12/opencadgraph.git", rev = "b741bd6" } dwg-thumbnailer = { path = "crates/dwg-thumbnailer" } flate2 = "1" image = { version = "0.25", default-features = false, features = ["png", "jpeg", "bmp", "tiff"] } diff --git a/src/scene/convert/acis_kernel.rs b/src/scene/convert/acis_kernel.rs index 3a713d541..d4ede7699 100644 --- a/src/scene/convert/acis_kernel.rs +++ b/src/scene/convert/acis_kernel.rs @@ -103,10 +103,14 @@ pub fn tessellate_sat( // parameters leaves a hole, the same as one that never lifted — so both // are counted before calling the mesh whole. let mut undrawn = 0usize; - let source_fit = if document.header.spatial_resolution.is_finite() - && document.header.spatial_resolution > 0.0 - { - document.header.spatial_resolution + // The header's tolerance line is ` `: the + // codec's `spatial_resolution` is the unit scale (1, or 25.4 for inches) + // and its `normal_tolerance` is resabs, the file's absolute tolerance. + // Fitting to the unit scale let every edge wander a whole unit, and on a + // bad pcurve that meant minutes of refinement (#1538). + let resabs = document.header.normal_tolerance; + let source_fit = if resabs.is_finite() && resabs > 0.0 && resabs < 1e-2 { + resabs } else { DEFAULT_FIT_TOLERANCE };