feat: pick sketch profiles by their bounding curve ids so features keep the same region when parameters move the geometry, matching curves cut into pieces, refusing ambiguous or missing picks instead of taking another region, and storing point picks by curves

This commit is contained in:
CypherNaugh_0x committed 2026-10-11 10:17:25 +02:00
1 parent 22672585c9
commit 848e7aec0e
11 files changed
+342 -60

No files matched your search

+28
View File
@@ -188,12 +188,36 @@ fn merge(dst: &mut Value, src: &Value, depth: usize) {
}
}
/// `profiles` (also a loft section's) given as the feature commands take it (`"all"`,
/// `[index]`, `[{curves}]`, `[{point}]`...) becomes the stored form; the stored form passes.
fn command_profiles(set: &Value, cmd: &str) -> Result<Value> {
let conv = |v: &mut Value| -> Result<()> {
if let Some(pv) = v.get("profiles").filter(|x| x.get("type").is_none()) {
let sel = super::features::profiles(&json!({"profiles": pv}), cmd)?;
let sv = serde_json::to_value(sel).map_err(|e| EngineError::Other(e.to_string()))?;
if let Some(o) = v.as_object_mut() {
o.insert("profiles".into(), sv);
}
}
Ok(())
};
let mut set = set.clone();
conv(&mut set)?;
if let Some(secs) = set.get_mut("sections").and_then(Value::as_array_mut) {
for sec in secs.iter_mut().take(10_000) {
conv(sec)?;
}
}
Ok(set)
}
fn edit_feature(s: &mut Session, p: &Value) -> Result<Value> {
let cmd = "timeline.edit";
let id = feature_id(s, p.get("feature"), cmd)?;
let set = p.get("set").filter(|v| v.is_object()).ok_or_else(|| bad(cmd, "`set` must be an object of fields"))?;
let f = s.doc.feature(id).cloned().ok_or_else(|| bad(cmd, "feature"))?;
let mut v = serde_json::to_value(&f).map_err(|e| EngineError::Other(e.to_string()))?;
let set = &command_profiles(set, cmd)?;
merge(&mut v, set, 0);
let mut nf: Feature = serde_json::from_value(v).map_err(|e| bad(cmd, format!("invalid feature: {e}")))?;
nf.id = f.id;
@@ -216,6 +240,10 @@ fn edit_feature(s: &mut Session, p: &Value) -> Result<Value> {
nf.edge_refs = solvecraft_doc::edge_refs(&before, body, a);
nf.edge_names = solvecraft_doc::edge_names_for(&before, body, a);
}
// Profiles picked by index or point are kept by their curves, as when the feature was made.
if nf.kind.clone().profile_sels_mut() != f.kind.clone().profile_sels_mut() {
super::features::stable_profiles(s, &mut nf.kind)?;
}
// New face points: their faces' names now.
if nf.kind.face_points() != f.kind.face_points() {
nf.face_names = solvecraft_doc::naming::face_names_at(&s.model.state_before(id), &nf.kind.face_points());