solidcore pin: 8ddce9016 → 9856ffee5, solidcore and solidcore-record at one rev
Both crates now come from the same solidcore commit. Builds on #11875 (jyviko), which moved the pin to 5d2635d36: its compile fixes (the per-kernel blend serial ranges go, solidcore#2480 keys the station memo by definition) and its fix choices carry over. Compile fixes for the newer API: - Offset refusals are typed (solidcore#2654): a fold is OffsetFailure::Folds, walls touching and a vanishing edge are read from the error's kind. - The fitted surface extension is gone (solidcore a5de86aaf, issue #2730): extend_sheet takes solidcore's exact extension (extended_by_distance) instead of solving for the distance to ask. Flags: the six solidcore retired into its defaults leave fixes() (fillet_blend_corner, fillet_round_on_round_as_definition, fillet_nx1_tangent_side_edge_same_convexity, gap_array_append_updates_longest, masked_array_uses_bit_shift, hash_table_grow_preserves_removed_records); the two new ones are on (brep_ray_classifies_current_trims, revolution_frame_from_profile_origin). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8312bf0cb8
commit
26e5560fb0
7 files changed
+69
-187
No files matched your search
Generated
+3
-2
@@ -4051,15 +4051,16 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "solidcore"
|
||||
version = "1.0.1"
|
||||
source = "git+https://github.com/tangency-labs/solidcore?rev=8ddce901671f1cebd9214a31d21895d725e886c8#8ddce901671f1cebd9214a31d21895d725e886c8"
|
||||
source = "git+https://github.com/tangency-labs/solidcore?rev=9856ffee5ab778c6b49f24716e82305683eda1fb#9856ffee5ab778c6b49f24716e82305683eda1fb"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "solidcore-record"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/tangency-labs/solidcore?rev=f5e8e9a29e0c9b7cf6c4040a5bc8878382b3c62f#f5e8e9a29e0c9b7cf6c4040a5bc8878382b3c62f"
|
||||
source = "git+https://github.com/tangency-labs/solidcore?rev=9856ffee5ab778c6b49f24716e82305683eda1fb#9856ffee5ab778c6b49f24716e82305683eda1fb"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
+2
-2
@@ -36,10 +36,10 @@ solidcraft-3dx-client = { path = "crates/threedx-client" }
|
||||
# move the rev on its own commit. For a
|
||||
# local checkout, add `[patch."https://github.com/tangency-labs/solidcore"] solidcore = { path =
|
||||
# "../solidcore/crates/solidcore" }` to a `.cargo/config.toml` outside the repository.
|
||||
solidcore = { git = "https://github.com/tangency-labs/solidcore", rev = "8ddce901671f1cebd9214a31d21895d725e886c8" }
|
||||
solidcore = { git = "https://github.com/tangency-labs/solidcore", rev = "9856ffee5ab778c6b49f24716e82305683eda1fb" }
|
||||
# Geometry as data (solidcore's layers §1, "Record"): the B-rep record, its structural validation
|
||||
# and the native body file. Pinned like solidcore; for a local checkout, patch it as above.
|
||||
solidcore-record = { git = "https://github.com/tangency-labs/solidcore", rev = "f5e8e9a29e0c9b7cf6c4040a5bc8878382b3c62f" }
|
||||
solidcore-record = { git = "https://github.com/tangency-labs/solidcore", rev = "9856ffee5ab778c6b49f24716e82305683eda1fb" }
|
||||
# test tooling: a dev-dependency only (xtask/src/layers.rs)
|
||||
solidcraft-testkit = { path = "crates/testkit" }
|
||||
|
||||
|
||||
+26
-18
@@ -6,7 +6,6 @@
|
||||
//! fork fixed in its own sources; each one turned on here says which fork commit it matches.
|
||||
|
||||
use std::panic::{AssertUnwindSafe, catch_unwind};
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::sync::{Mutex, PoisonError};
|
||||
|
||||
use solidcore::geom::attribute::{AttributeStore, ObjectKey};
|
||||
@@ -153,7 +152,6 @@ pub(crate) fn fixes() -> UpstreamFixes {
|
||||
f.fillet_point_step_per_point = true;
|
||||
f.analytic_copy_keeps_parameterization = true;
|
||||
f.fillet_point_bigger_step_retry = true;
|
||||
f.fillet_through_extended_rail_end = true;
|
||||
f.precise_properties_body_length_scale = true;
|
||||
f.offset_extension_from_base = true;
|
||||
f.corner_blend_stays_inside_neighbours = true;
|
||||
@@ -230,7 +228,6 @@ pub(crate) fn fixes() -> UpstreamFixes {
|
||||
f.fillet_cleanup_removes_input_slits = true;
|
||||
f.fillet_rail_end_on_continued_surface = true;
|
||||
f.glue_vertices_joins_every_region = true;
|
||||
f.fillet_nx1_tangent_side_edge_same_convexity = true;
|
||||
f.fillet_removal_takes_ring_fillets = true;
|
||||
// The fork's commits that reached `SMLIB_REV` at eaa998a (tangency-labs/smlib#68, #69, #70).
|
||||
f.fillet_trim_inside_by_best_dot = true;
|
||||
@@ -274,7 +271,6 @@ pub(crate) fn fixes() -> UpstreamFixes {
|
||||
f.offset_keep_cavity_regions = true;
|
||||
f.offset_four_face_vertex_split = true;
|
||||
f.gap_samples_non_bspline_v_stride = true;
|
||||
f.gap_array_append_updates_longest = true;
|
||||
f.imprint_skips_collapsed_definition = true;
|
||||
f.precise_properties_trim_base_v = true;
|
||||
f.fillet_blend_curve_revolved_on_arc = true;
|
||||
@@ -319,7 +315,6 @@ pub(crate) fn fixes() -> UpstreamFixes {
|
||||
f.circle_silhouette_perspective_center = true;
|
||||
f.ellipse_convert_to_2d_uses_both_axes = true;
|
||||
f.circle_offset_antiparallel_normal = true;
|
||||
f.masked_array_uses_bit_shift = true;
|
||||
f.global_solver_identical_prefers_larger_when_maximizing = true;
|
||||
f.surface_continuity_checks_last_v_knot = true;
|
||||
f.surface_point_solver_propagates_bbox_failure = true;
|
||||
@@ -346,7 +341,6 @@ pub(crate) fn fixes() -> UpstreamFixes {
|
||||
f.surface_parallel_to_vector_checks = true;
|
||||
f.fillet_round_ends_at_tangent_continuation = true;
|
||||
f.geometric_g2_continuity = true;
|
||||
f.hash_table_grow_preserves_removed_records = true;
|
||||
f.bend_volume_bbox_contains_wide_angle_and_inf_u = true;
|
||||
f.bend_volume_trim_param_box_across_period = true;
|
||||
f.point_set_tight_pbox_projects_points = true;
|
||||
@@ -377,7 +371,6 @@ pub(crate) fn fixes() -> UpstreamFixes {
|
||||
f.fillet_section_end_trim_at_creases = true;
|
||||
f.fillet_refuse_mixed_corner_crossing_rails = true;
|
||||
f.fillet_keep_features = true;
|
||||
f.fillet_blend_corner = true;
|
||||
f.fillet_exact_arc_sections = true;
|
||||
f.fillet_exact_arc_spans = true;
|
||||
// Held back: see `HELD_BACK`.
|
||||
@@ -385,11 +378,22 @@ pub(crate) fn fixes() -> UpstreamFixes {
|
||||
f.cone_unbounded_parameterized_as_nurb = true;
|
||||
f.ellipse_open_arc_keeps_end_angle = true;
|
||||
f.fillet_round_as_definition = true;
|
||||
f.fillet_round_on_round_as_definition = true;
|
||||
f.fillet_overflow_crease_along_edge = true;
|
||||
f.plane_first_torus_section_exact = true;
|
||||
f.keep_exact_pcurves = true;
|
||||
f.shell_one_construction = true;
|
||||
f.offset_extends_ball_patches_as_themselves = true;
|
||||
f.approximate_surface_checks_every_row = true;
|
||||
f.topological_vertex_has_only_edge_uses = true;
|
||||
f.planar_section_face_tolerance = true;
|
||||
f.face_swap_uv_transposes_trims = true;
|
||||
f.closed_smooth_pole_tangent_limit = true;
|
||||
// Held back: see `HELD_BACK`.
|
||||
f.fillet_round_ends_on_outline = false;
|
||||
f.fillet_setback_beside_curved_faces = true;
|
||||
f.fillet_chamfer_corner = true;
|
||||
f.brep_ray_classifies_current_trims = true;
|
||||
f.revolution_frame_from_profile_origin = true;
|
||||
f
|
||||
}
|
||||
|
||||
@@ -407,21 +411,25 @@ pub(crate) fn fixes() -> UpstreamFixes {
|
||||
/// 324-fillet-over-hole-cut-by-overlong-cylinder, 324-fillet-over-hole-overlap,
|
||||
/// 5158-fillet-adjacent-plate-edges-as-thick-as-plate and the sloped and equal-slope basin rims of
|
||||
/// #1080 and #5835. A fix under the same flag is in progress on solidcore.
|
||||
///
|
||||
/// `fillet_round_ends_on_outline` (WR-730, solidcore#2541): volumes wrong against their closed
|
||||
/// forms, and rounds too big for their faces built instead of refused. With it on, each of these
|
||||
/// passes with it off: `fillet_over_a_cliff` measures 721.832 against the closed form's 693.205;
|
||||
/// `a_round_wider_than_its_faces_overflows_onto_its_tangent_sides` 6125.719 against 6107.529;
|
||||
/// `taper_follows_the_room_along_the_edge` 4210.926 against 4195.579; the round larger than the
|
||||
/// cube in `hostile_inputs_are_errors` builds (4773.168 against the 1094.853 its refusal leaves),
|
||||
/// as do the fillets the CLI's `run_strict` and `json_out` tests need to fail; and
|
||||
/// `a_corner_round_wider_than_its_faces_overflows_and_takes_the_corners_other_edges`,
|
||||
/// `overflow_goes_first`, `corners_refuse_what_they_cannot_build` and
|
||||
/// `fillet_edge_removed_by_a_larger_overflowing_round_is_noted` are refused (too large, no room,
|
||||
/// status 1001), where with it off they build.
|
||||
#[cfg(test)]
|
||||
const HELD_BACK: &[&str] = &["fillet_refuse_rounds_breaking_through"];
|
||||
const HELD_BACK: &[&str] = &["fillet_refuse_rounds_breaking_through", "fillet_round_ends_on_outline"];
|
||||
|
||||
/// How far apart two kernels' procedural blend serials start. A body keeps the serials of the
|
||||
/// kernel that made it and may be used on any other, whose memo of solved stations is keyed by
|
||||
/// serial alone: the ranges keep one definition's stations from answering for another's. A serial
|
||||
/// only names a definition, so which range one comes from changes no answer.
|
||||
pub(crate) const BLEND_SERIALS_PER_KERNEL: u64 = 1 << 40;
|
||||
|
||||
/// A new kernel. Each takes the next range of blend serials, the first starting at 0.
|
||||
/// A new kernel, with this backend's fixes.
|
||||
fn fresh() -> Kernel {
|
||||
static MADE: AtomicU64 = AtomicU64::new(0);
|
||||
let mut k = Kernel::new(&KernelOptions::default());
|
||||
k.fixes = fixes();
|
||||
k.blend_last_serial.set(MADE.fetch_add(1, Ordering::Relaxed).wrapping_mul(BLEND_SERIALS_PER_KERNEL));
|
||||
k
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
use solidcore::EntityRef;
|
||||
use solidcore::SolidError;
|
||||
use solidcore::error::offset::OffsetFailure;
|
||||
use solidcore::error::{ErrorKind, Reason};
|
||||
use solidcore::geom::attribute::{Attribute, Behavior, ids};
|
||||
use solidcore::geom::axis2_placement::Axis2Placement;
|
||||
use solidcore::geom::object::Shape;
|
||||
@@ -29,7 +31,6 @@ use solidcore::nurbs::b_spline_curve::ControlPointForm;
|
||||
use solidcore::nurbs::b_spline_surface::p1::SurfParamType;
|
||||
use solidcore::nurbs::b_spline_surface_n_lib::p2::OrientType;
|
||||
use solidcore::nurbs::knots::Side;
|
||||
use solidcore::offset::construction::ShellRefusal;
|
||||
use solidcore::offset::offset_executive::p2::{OffsetOptions, ShellOptions, local_operation_simple, offset_brep_simple, shell_brep_simple};
|
||||
use solidcore::offset::offset_faces::{OffsetFacesExecutive, OffsetFacesRefusal};
|
||||
use solidcore::query::api_queries::{face_bounding_box, face_classify_uv, face_closest_point_in_shape, face_internal_point};
|
||||
@@ -50,21 +51,23 @@ type Out<T> = std::result::Result<T, Error>;
|
||||
/// `SM_ERR_INVALID_INPUT`.
|
||||
const INVALID_INPUT: i32 = 1007;
|
||||
|
||||
/// `SM_ERR_OFFSET_WALLS_TOUCH` (fork a759622), which `status` (smlib_shim.h) reports as
|
||||
/// `SMLIB_ERR_WALLS_TOUCH`.
|
||||
const OFFSET_WALLS_TOUCH: i32 = 1042;
|
||||
|
||||
/// `status` (smlib_shim.h): an offset whose walls touch is [`Error::WallsTouch`]; a vertex moved
|
||||
/// past an edge's other end (`SM_ERR_OFFSET_EDGE_VANISHES`, fork 34318f4) is
|
||||
/// `SMLIB_ERR_UNSUPPORTED`; a wall whose face's offset folds, which solidcore's one construction
|
||||
/// refuses (`fixes.shell_one_construction`, solidcore#2367), is [`Error::WallFolds`] with the
|
||||
/// largest wall it names; any other status as the blends pass it on.
|
||||
/// largest wall it names; any other status as the blends pass it on. solidcore names an offset's
|
||||
/// refusals by their kind and reason (its errors in its own terms, solidcore#2654), whichever
|
||||
/// status the pinned C++ gives them.
|
||||
fn status(e: SolidError) -> Error {
|
||||
match e {
|
||||
SolidError::Upstream { code: OFFSET_WALLS_TOUCH, .. } => Error::WallsTouch,
|
||||
SolidError::ShellRefused { refusal: ShellRefusal::Fold, size, .. } => Error::WallFolds { largest: size },
|
||||
e if e.is_offset_edge_vanishes() => Error::Unsupported,
|
||||
e => blend_status(e),
|
||||
if let SolidError::Failed(f) = &e
|
||||
&& let Reason::Offset(OffsetFailure::Folds { largest, .. }) = f.reason
|
||||
{
|
||||
return Error::WallFolds { largest: Some(largest) };
|
||||
}
|
||||
match e.kind() {
|
||||
ErrorKind::OffsetWallsTouch => Error::WallsTouch,
|
||||
ErrorKind::OffsetEdgeVanishes => Error::Unsupported,
|
||||
_ => blend_status(e),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-140
@@ -24,21 +24,20 @@
|
||||
|
||||
use std::sync::PoisonError;
|
||||
|
||||
use solidcore::EntityRef;
|
||||
use solidcore::curve::curve::Curve;
|
||||
use solidcore::geom::extent2d::Extent2d;
|
||||
use solidcore::geom::geom_utility::p2::ContinuityType;
|
||||
use solidcore::geom::object::Shape;
|
||||
use solidcore::geom::tol::USE_DEFAULT;
|
||||
use solidcore::geom::vector2d::Point2;
|
||||
use solidcore::geom::vector3d::{Point3, Vec3};
|
||||
use solidcore::kernel::Kernel;
|
||||
use solidcore::nurbs::b_spline_surface::p1::SurfParamType;
|
||||
use solidcore::nurbs::b_spline_surface_n_lib::p2::EvaluateFlags;
|
||||
use solidcore::nurbs::b_spline_surface_n_lib::p2::OrientType;
|
||||
use solidcore::query::api_queries::{edge_closest_point, face_closest_point_in_shape, face_internal_point};
|
||||
use solidcore::query::brep::{BrepQuery, LiveBrepObjects};
|
||||
use solidcore::surface::cone::p1::Cone;
|
||||
use solidcore::surface::extend::Continuity;
|
||||
use solidcore::surface::side::BoxSide;
|
||||
use solidcore::surface::surface::Surface;
|
||||
use solidcore::surface::surface::SurfaceKind;
|
||||
use solidcore::topology::brep::p1 as brep_p1;
|
||||
@@ -54,6 +53,7 @@ use solidcore::topology::face::{p1 as face_p1, p2 as face_p2, p4 as face_p4};
|
||||
use solidcore::topology::loopuse::{loop_edges, loop_loopuses, notify_ref};
|
||||
use solidcore::topology::topology_traverser::Marks;
|
||||
use solidcore::topology::{Brep, BrepId, EdgeId, FaceId, LoopId, edge};
|
||||
use solidcore::{EntityRef, SolidError};
|
||||
|
||||
use super::blend::{p3, status};
|
||||
use super::sweep::build_faces;
|
||||
@@ -454,17 +454,17 @@ pub(crate) fn untrim_face(body: &Body, point: [f64; 3], tol: f64, holes: Option<
|
||||
/// grows in u), and whether it is at the box's max.
|
||||
#[derive(Clone, Copy)]
|
||||
struct Side {
|
||||
which: SurfParamType,
|
||||
which: BoxSide,
|
||||
u: bool,
|
||||
high: bool,
|
||||
}
|
||||
|
||||
/// `SIDES`.
|
||||
const SIDES: [Side; 4] = [
|
||||
Side { which: SurfParamType::UMin, u: true, high: false },
|
||||
Side { which: SurfParamType::UMax, u: true, high: true },
|
||||
Side { which: SurfParamType::VMin, u: false, high: false },
|
||||
Side { which: SurfParamType::VMax, u: false, high: true },
|
||||
Side { which: BoxSide::UMin, u: true, high: false },
|
||||
Side { which: BoxSide::UMax, u: true, high: true },
|
||||
Side { which: BoxSide::VMin, u: false, high: false },
|
||||
Side { which: BoxSide::VMax, u: false, high: true },
|
||||
];
|
||||
|
||||
/// `SAMPLES`.
|
||||
@@ -546,55 +546,6 @@ fn side_edge(k: &Kernel, b: &Brep, surf: &Surface, dom: &Extent2d, s: Side, edge
|
||||
e.filter(|_| d <= on)
|
||||
}
|
||||
|
||||
/// `across`: how far `ext` (the face's surface extended past side `s` of its box `dom`, on the
|
||||
/// same parameters) runs past that side, measured across it through the side's middle, by
|
||||
/// 16-point Gauss-Legendre quadrature on 64 pieces. Negative when it can't be evaluated.
|
||||
fn across(k: &Kernel, ext: &Surface, dom: &Extent2d, s: Side) -> f64 {
|
||||
const X: [f64; 8] = [
|
||||
0.0950125098376374,
|
||||
0.2816035507792589,
|
||||
0.4580167776572274,
|
||||
0.6178762444026438,
|
||||
0.755404408355003,
|
||||
0.8656312023878318,
|
||||
0.9445750230732326,
|
||||
0.9894009349916499,
|
||||
];
|
||||
const W: [f64; 8] = [
|
||||
0.1894506104550685,
|
||||
0.1826034150449236,
|
||||
0.1691565193950025,
|
||||
0.1495959888165767,
|
||||
0.1246289712555339,
|
||||
0.0951585116824928,
|
||||
0.0622535239386479,
|
||||
0.0271524594117541,
|
||||
];
|
||||
const PIECES: usize = 64;
|
||||
let Ok(bx) = ext.natural_uv_domain_with_nurb(k) else { return -1.0 };
|
||||
let mid = on_side(dom, s, 0.5);
|
||||
let from = if s.u { mid.x } else { mid.y };
|
||||
let to = match (s.u, s.high) {
|
||||
(true, true) => bx.max().x,
|
||||
(true, false) => bx.min().x,
|
||||
(false, true) => bx.max().y,
|
||||
(false, false) => bx.min().y,
|
||||
};
|
||||
let h = (to - from) / PIECES as f64;
|
||||
let mut length = 0.0;
|
||||
for piece in 0..PIECES {
|
||||
let c = from + (piece as f64 + 0.5) * h;
|
||||
for i in 0..16 {
|
||||
let (x, w) = if i < 8 { (-X[i], W[i]) } else { (X[i - 8], W[i - 8]) };
|
||||
let t = c + 0.5 * h * x;
|
||||
let uv = if s.u { Point2::new(t, mid.y) } else { Point2::new(mid.x, t) };
|
||||
let Some((_, du, dv)) = eval(k, ext, uv) else { return -1.0 };
|
||||
length += 0.5 * h.abs() * w * if s.u { du } else { dv }.length();
|
||||
}
|
||||
}
|
||||
length
|
||||
}
|
||||
|
||||
/// `cone_continued`: a cone's or cylinder's face continued naturally `distance` past side `s` of
|
||||
/// its box `dom`, as the analytic itself over a wider STEP domain (degrees round the axis,
|
||||
/// height along it). `None` where the cone can't be widened so (more than a turn, or past the
|
||||
@@ -656,82 +607,16 @@ fn same_patch(k: &Kernel, p: &Surface, q: &Surface, tol: f64) -> bool {
|
||||
}
|
||||
|
||||
/// `extended_by`: the surface `surf` (whose face is its whole box `dom`) extended past side `s` as
|
||||
/// `ct` says, so that it runs `distance` past that side measured across it ([`across`]), within
|
||||
/// 1e-9 of it. `CreateExtendedSurface` takes its distance as an estimate, and how far it then runs
|
||||
/// is increasing in what it is asked: a bracketed solve on that (each ask scaled by the distance
|
||||
/// over what it gave until two asks fall either side, then Illinois false position). An extension
|
||||
/// that moves the face's side off its parameters, or a target not met, is [`Error::NotExact`],
|
||||
/// never the surface as it came out.
|
||||
fn extended_by(k: &Kernel, surf: &Surface, dom: &Extent2d, s: Side, ct: ContinuityType, distance: f64, model_tol: f64) -> Result<Surface> {
|
||||
const BRACKET_TRIES: usize = 40;
|
||||
const SOLVE_TRIES: usize = 100;
|
||||
let tol = 1e-9 * distance;
|
||||
// How far asking `ask` runs, and the surface it makes.
|
||||
let try_ask = |ask: f64| -> Result<(Surface, f64)> {
|
||||
let tried = surf.create_extended_surface_dir(k, s.which, ask, ct).map_err(status)?;
|
||||
// The face's side stays where it was on the extended surface's parameters.
|
||||
let mid = on_side(dom, s, 0.5);
|
||||
let stays = matches!((point_at(k, surf, mid), point_at(k, &tried, mid)), (Some(was), Some(now)) if (was - now).length() <= model_tol);
|
||||
if !stays {
|
||||
return Err(Error::NotExact);
|
||||
}
|
||||
let got = across(k, &tried, dom, s);
|
||||
if got.is_finite() && got > 0.0 { Ok((tried, got)) } else { Err(Error::NotExact) }
|
||||
};
|
||||
// Asks that run short of and past `distance`, by f = got - distance.
|
||||
let (mut short, mut past) = (None, None);
|
||||
let mut ask = distance;
|
||||
for _ in 0..BRACKET_TRIES {
|
||||
let (made, got) = try_ask(ask)?;
|
||||
let f = got - distance;
|
||||
if f.abs() <= tol {
|
||||
return Ok(made);
|
||||
}
|
||||
if f < 0.0 {
|
||||
short = Some((ask, f));
|
||||
} else {
|
||||
past = Some((ask, f));
|
||||
}
|
||||
if short.is_some() && past.is_some() {
|
||||
break;
|
||||
}
|
||||
ask *= distance / got;
|
||||
/// `how` says, so that it runs `distance` past that side measured across it, exactly: solidcore's
|
||||
/// one extension ([`Surface::extended_by_distance`]), which keeps the source's own part bit for bit
|
||||
/// and meets the distance within 1e-9 of it. A distance it cannot meet exactly is
|
||||
/// [`Error::NotExact`], never a surface that falls short or runs past.
|
||||
fn extended_by(k: &Kernel, surf: &Surface, dom: &Extent2d, s: Side, how: Continuity, distance: f64) -> Result<Surface> {
|
||||
match surf.extended_by_distance(k, dom, s.which, how, distance) {
|
||||
Ok(e) => Ok(e.surface),
|
||||
Err(SolidError::ExtendRefused { .. } | SolidError::NotConverged { .. }) => Err(Error::NotExact),
|
||||
Err(e) => Err(status(e)),
|
||||
}
|
||||
let (Some((mut lo, mut flo)), Some((mut hi, mut fhi))) = (short, past) else { return Err(Error::NotExact) };
|
||||
// Illinois: false position, halving the value at the end that stays when the same end moves
|
||||
// twice running.
|
||||
#[derive(PartialEq)]
|
||||
enum Moved {
|
||||
Neither,
|
||||
Lo,
|
||||
Hi,
|
||||
}
|
||||
let mut moved = Moved::Neither;
|
||||
for _ in 0..SOLVE_TRIES {
|
||||
let x = hi - fhi * (hi - lo) / (fhi - flo);
|
||||
if !(x > lo.min(hi) && x < lo.max(hi)) {
|
||||
break;
|
||||
}
|
||||
let (made, got) = try_ask(x)?;
|
||||
let f = got - distance;
|
||||
if f.abs() <= tol {
|
||||
return Ok(made);
|
||||
}
|
||||
if f < 0.0 {
|
||||
(lo, flo) = (x, f);
|
||||
if moved == Moved::Lo {
|
||||
fhi *= 0.5;
|
||||
}
|
||||
moved = Moved::Lo;
|
||||
} else {
|
||||
(hi, fhi) = (x, f);
|
||||
if moved == Moved::Hi {
|
||||
flo *= 0.5;
|
||||
}
|
||||
moved = Moved::Hi;
|
||||
}
|
||||
}
|
||||
Err(Error::NotExact)
|
||||
}
|
||||
|
||||
/// `smlib_extend_sheet`: the one-face sheet `sheet`, whose face is its surface's whole parameter
|
||||
@@ -787,15 +672,13 @@ pub(crate) fn extend_sheet(sheet: &Body, point: [f64; 3], tol: f64, distance: f6
|
||||
if (nl.x - dl.x).abs() > ptol || (nl.y - dl.y).abs() > ptol || (nh.x - dh.x).abs() > ptol || (nh.y - dh.y).abs() > ptol {
|
||||
return Ok(Err(Error::Unsupported));
|
||||
}
|
||||
let ct = match how {
|
||||
Continuation::Tangent => ContinuityType::G1,
|
||||
Continuation::Curvature => ContinuityType::G1G2,
|
||||
Continuation::Natural => ContinuityType::CInfinity,
|
||||
let continuity = match how {
|
||||
Continuation::Tangent => Continuity::Tangent,
|
||||
Continuation::Curvature => Continuity::Curvature,
|
||||
Continuation::Natural => Continuity::Natural,
|
||||
};
|
||||
// CreateExtendedSurface takes its distance as an estimate (a natural parabola falls 2.5%
|
||||
// short, a G2 run-off of a circle runs more than twice as far): the distance asked of it
|
||||
// is solved for until the extension measures `distance` across the side's middle.
|
||||
let extended = match extended_by(k, &surf, &dom, grow, ct, distance, model_tol) {
|
||||
// The extension runs `distance` across the side, exactly (solidcore's one extension).
|
||||
let extended = match extended_by(k, &surf, &dom, grow, continuity, distance) {
|
||||
Ok(e) => e,
|
||||
Err(e) => return Ok(Err(e)),
|
||||
};
|
||||
|
||||
@@ -55,7 +55,7 @@ pub enum Error {
|
||||
/// middle of the edge it was found for, and why there is no room, when the refusal names them.
|
||||
TooLarge { size: f64, kind: FitKind, at: Option<[f64; 3]>, why: Option<RoomReason> },
|
||||
/// A shell, offset or thicken whose wall is thicker than a face curves: the face's offset
|
||||
/// folds (solidcore's `ShellRefused`, `ShellRefusal::Fold`). The largest wall that works,
|
||||
/// folds (solidcore's `OffsetFailure::Folds`). The largest wall that works,
|
||||
/// when solidcore names one.
|
||||
WallFolds { largest: Option<f64> },
|
||||
/// SMLib cannot build this exactly yet (a variable radius whose law has a corner).
|
||||
|
||||
@@ -486,19 +486,6 @@ fn bodies_move_between_kernels_and_calls_run_side_by_side() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Each kernel has its own range of blend serials: a body keeps the serials of the kernel that
|
||||
/// made it, and another kernel's memo of solved stations must not take them for its own.
|
||||
#[test]
|
||||
fn kernels_never_issue_the_same_blend_serial() {
|
||||
let range = core::BLEND_SERIALS_PER_KERNEL as usize;
|
||||
let ranges = core::run("outer", |outer| {
|
||||
let inner = core::run("inner", |inner| Ok(inner.blend_last_serial.get() as usize)).unwrap_or_default();
|
||||
Ok([outer.blend_last_serial.get() as usize / range, inner / range])
|
||||
});
|
||||
let [outer, inner] = ranges.unwrap();
|
||||
assert_ne!(outer, inner);
|
||||
}
|
||||
|
||||
/// A panic in a call running beside another costs neither: the panicking call's kernel is thrown
|
||||
/// away and the other call and later ones go on.
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user