Feature fields: a type for each role (Expr, BodyName, FacePick…) (#1273)

Thanks @jijinbei.
This commit is contained in:
JIJINBEI authored and GitHub committed 2026-10-16 00:28:12 -04:00
1 parent 3333f8a62b
commit 44968dbfe6
59 files changed
+1505 -1043

No files matched your search

+6 -5
View File
@@ -1,4 +1,5 @@
//! Independent copies of a component definition graph, assembled and evaluated atomically.
use solidcraft_doc::BodyName;
use std::collections::{BTreeMap, BTreeSet};
use crate::params::bad;
@@ -327,7 +328,7 @@ pub(super) fn paste(
let entry = feats.iter().find(|f| {
!f.suppressed
&& matches!(&f.kind, FeatureKind::BodyTransfer { bodies, from, to, .. }
if !selected.contains(from) && bodies.contains(&body.name)
if !selected.contains(from) && bodies.iter().any(|b| *b == body.name)
&& s.model.result(f.id).is_some_and(|result| !result.skipped && result.error.is_none()
&& result.state.body(&body.name).is_some_and(|entered| source.model_body_component(entered) == *to)))
});
@@ -426,7 +427,7 @@ pub(super) fn paste(
if let FeatureKind::Emboss { face: Some(face), .. } = &mut f.kind
&& !face.path.is_empty()
&& let FeatureKind::Emboss { face: Some(old_face), .. } = &old.kind
&& bodies.contains_key(&old_face.body)
&& bodies.contains_key(old_face.body.as_ref())
{
face.path = cloned_path(&source, &old_face.path, component, &clone_path, &occurrences)?;
}
@@ -483,7 +484,7 @@ pub(super) fn paste(
.collect();
if !moved_out.is_empty() {
let name = unique("Assigned-out bodies", &mut used);
let id = scratch.doc_mut().add_feature(FeatureKind::Remove { bodies: moved_out }, Some(&name))?;
let id = scratch.doc_mut().add_feature(FeatureKind::Remove { bodies: moved_out.into_iter().map(BodyName).collect() }, Some(&name))?;
if let Some(f) = scratch.doc_mut().feature_mut(id) {
f.component = root;
}
@@ -526,7 +527,7 @@ pub(super) fn paste(
for feature in &feats {
if let FeatureKind::Emboss { face: Some(face), .. } = &feature.kind
&& !face.path.is_empty()
&& !bodies.contains_key(&face.body)
&& !bodies.contains_key(face.body.as_ref())
{
notices.push(format!("{} retains external selected occurrence path {:?}", feature.name, face.path));
}
@@ -588,7 +589,7 @@ pub(super) fn paste(
}
if let FeatureKind::Pattern { features: references, .. } | FeatureKind::Mirror { features: references, .. } = &feature.kind {
for name in references {
if !names.contains_key(name) {
if !names.contains_key(name.as_ref()) {
notices.push(format!("{} retains external feature reference {name}", feature.name));
}
}