Each wall of a surface built from sketch curves (Surface Extrude, Revolve, Sweep and Loft) is now named after the curve it comes from, exactly rather than from geometry, so references to those faces survive edits.
This commit is contained in:
1 parent
8746376ee9
commit
d2e409f40c
6 files changed
+216
-76
No files matched your search
@@ -249,6 +249,47 @@ impl<'a> ProfileRoles<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// How a surface built from chains of sketch segments (Surface Extrude, Revolve, Sweep) names
|
||||
/// its walls: each `side:<curve>` of the sketch curve its segment lies on exactly, segments
|
||||
/// numbered through the chains in order. It has no caps.
|
||||
pub(crate) struct ChainRoles<'a> {
|
||||
pub sketch: &'a SolvedSketch,
|
||||
pub chains: &'a [Vec<solidcraft_geom::Seg2>],
|
||||
}
|
||||
|
||||
impl ChainRoles<'_> {
|
||||
/// The surface `body`, its walls named by their roles where its history gives them.
|
||||
pub fn tool(&self, body: Body) -> Traced {
|
||||
let roles = body.history().filter(|h| h.operands == 0).map(|h| self.of(h));
|
||||
Traced::made(body, roles)
|
||||
}
|
||||
|
||||
fn of(&self, history: &History) -> Vec<Vec<String>> {
|
||||
let segments: Vec<&solidcraft_geom::Seg2> = self.chains.iter().flatten().collect();
|
||||
let curves = crate::config::ExactSketchCurves::new(self.sketch);
|
||||
history
|
||||
.faces
|
||||
.iter()
|
||||
.map(|face| {
|
||||
let mut roles: Vec<String> = Vec::new();
|
||||
for origin in &face.origins {
|
||||
let role = match *origin {
|
||||
FaceOrigin::Profile { segment } => segments.get(segment).and_then(|s| curves.find_along(s)).map(|id| format!("side:{id}")),
|
||||
_ => None,
|
||||
};
|
||||
match role {
|
||||
Some(role) if !roles.contains(&role) => roles.push(role),
|
||||
Some(_) => {}
|
||||
// One unknown origin leaves the face unknown: never a partial guess.
|
||||
None => return Vec::new(),
|
||||
}
|
||||
}
|
||||
roles
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
/// How a loft names its faces: each side by the sketch curves of the sections it runs between
|
||||
/// (`side:<curve>` for the first section's, `side:s<k>.<curve>` for section `k`'s), named after
|
||||
/// the section with the most segments (the one each side spans exactly one segment of) and
|
||||
|
||||
Reference in new issue
Block a user