Merge upstream profile picks and flush-pad fixes with adaptive identities

This commit is contained in:
bherbruck committed 2026-10-11 09:43:16 -04:00
commit 0167c358bb
15 files changed
+623 -44

No files matched your search

+4 -2
View File
@@ -88,8 +88,10 @@ pub enum ProfileSel {
All,
/// Profiles by index in the solved sketch's profile list.
Indices { indices: Vec<usize> },
/// Profiles whose outer loop is made of exactly these curves (order-insensitive); stable
/// across parameter changes.
/// Profiles whose outer loop is made of exactly these curves, or pieces of them where other
/// curves cut them (order and repeats don't matter; see `sketch::profile_by_curves`). Found
/// again on every evaluation, so stable across parameter changes; no match or several is
/// an error, never another profile.
Curves { loops: Vec<Vec<String>> },
/// Complete current boundaries of topology-aware analytic offset associations.
/// The local association identity survives retirement and resurrection of arc roles.
+13 -1
View File
@@ -795,7 +795,7 @@ pub fn select_profiles(ss: &SolvedSketch, sel: &ProfileSel) -> Result<Vec<Region
let mut v = Vec::new();
for p in points {
// Innermost profile containing the point.
let found = ps.iter().filter(|q| q.region.contains(*p)).min_by(|a, b| a.area.total_cmp(&b.area));
let found = solvecraft_sketch::profile_at_point(ps, *p).and_then(|i| ps.get(i));
v.push(found.ok_or_else(|| DocError::Unknown(format!("profile at {:?} in {}", [p.x, p.y], ss.name)))?.region.clone());
}
v
@@ -807,6 +807,18 @@ pub fn select_profiles(ss: &SolvedSketch, sel: &ProfileSel) -> Result<Vec<Region
Ok(out)
}
/// The error for a profile picked by curves that no longer names exactly one profile.
pub fn curve_pick_error(e: solvecraft_sketch::CurvePick, ids: &[String], sketch: &str) -> DocError {
match e {
solvecraft_sketch::CurvePick::Missing => DocError::Invalid(format!(
"no profile of {sketch} is bounded by exactly the curves {ids:?} (a curve was deleted, or another curve now cuts the region)"
)),
solvecraft_sketch::CurvePick::Ambiguous(n) => DocError::Invalid(format!(
"{n} profiles of {sketch} are bounded by exactly the curves {ids:?}; add a curve that tells them apart, or pick by index or point"
)),
}
}
fn new_name(state: &mut ModelState, f: &Feature, k: usize) -> String {
if let Some(n) = f.body_names.get(k)
&& !n.is_empty()
+3 -3
View File
@@ -38,9 +38,9 @@ pub mod sheet;
pub use assembly::{IDENTITY, Mat, Occurrence, apply_point, apply_vector, is_identity, map_point_expr, mat_inverse, mat_mul, rigid};
pub use document::*;
pub use eval::{
EdgeRef, FeatureResult, Model, ModelBody, ModelState, RevolveExtent, SolvedSketch, ThreadInfo, edge_names_for, edge_refs, object_height,
parse_metric_thread, pattern_matrices, revolve_extent, revolve_extent_with_convention, select_profiles, state_in_frame, state_in_frame_at,
through_all_distance, world_state,
EdgeRef, FeatureResult, Model, ModelBody, ModelState, RevolveExtent, SolvedSketch, ThreadInfo, curve_pick_error, edge_names_for, edge_refs,
object_height, parse_metric_thread, pattern_matrices, revolve_extent, revolve_extent_with_convention, select_profiles, state_in_frame,
state_in_frame_at, through_all_distance, world_state,
};
pub use params::{ParamRow, ParamUser, cycles};
pub use solvecraft_kernel as kernel;
+9 -5
View File
@@ -112,12 +112,16 @@ pub fn profile_selection_indices(ss: &SolvedSketch, selection: &ProfileSel) -> R
}
indices.push(unique_profile(ss, &ss.sketch.offset_boundary(id)?)?);
} else {
// Preserve the historical first exact ordinary-loop match.
// Repeated saved IDs identify exact graph spans. Their multiplicity
// must not silently turn into a whole-source certificate on resize.
if curves.iter().collect::<BTreeSet<_>>().len() != curves.len()
&& !ss.profiles.iter().any(|profile| same_ids(curves, &profile.outer_curves))
{
return Err(crate::curve_pick_error(solvecraft_sketch::CurvePick::Missing, curves, &ss.name));
}
indices.push(
ss.profiles
.iter()
.position(|profile| same_ids(curves, &profile.outer_curves))
.ok_or_else(|| DocError::Unknown(format!("profile bounded by {curves:?} in {}", ss.name)))?,
solvecraft_sketch::profile_by_curves(&ss.profiles, curves)
.map_err(|error| crate::curve_pick_error(error, curves, &ss.name))?,
);
}
}