fix: a dimension from linked geometry keeps its side when the source moves past it (#614)
A point dimensioned from linked geometry (projected, included or intersected) keeps its side when a parameter moves the link's source past it: the solve reads sides and turns from the stored state instead of from beside the moved line, both on recompute and when editing the sketch. Co-authored-by: NOWN-DEV <257771410+NOWN-DEV@users.noreply.github.com>
This commit is contained in:
1 parent
bf962a9989
commit
24974e6f37
13 files changed
+392
-27
No files matched your search
@@ -852,6 +852,21 @@ impl Sketch {
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
/// Where this sketch's points were in `stored`, the same sketch before its links were
|
||||
/// moved to where their sources are now ([`Sketch::update_link`]): point by point, as
|
||||
/// [`crate::solve_after_edit`] takes them. Points are matched by id (a rebuilt link has
|
||||
/// new ones); a point `stored` does not have is where it is now. `None` when none moved.
|
||||
pub fn positions_in(&self, stored: &Sketch) -> Option<Vec<Vec2>> {
|
||||
let aligned = self.points.len() == stored.points.len() && self.points.iter().zip(&stored.points).all(|(p, q)| p.id == q.id);
|
||||
let was: Vec<Vec2> = if aligned {
|
||||
stored.points.iter().map(|p| p.pos).collect()
|
||||
} else {
|
||||
let by_id: std::collections::BTreeMap<&str, Vec2> = stored.points.iter().map(|p| (p.id.as_str(), p.pos)).collect();
|
||||
self.points.iter().map(|p| by_id.get(p.id.as_str()).copied().unwrap_or(p.pos)).collect()
|
||||
};
|
||||
self.points.iter().zip(&was).any(|(p, w)| p.pos != *w).then_some(was)
|
||||
}
|
||||
|
||||
fn drop_link_entities(&mut self, id: &str) {
|
||||
let curves = self.link_curves(id);
|
||||
let keep = self.links.clone();
|
||||
@@ -921,3 +936,7 @@ impl Sketch {
|
||||
#[cfg(test)]
|
||||
#[path = "link_identity_tests.rs"]
|
||||
mod identity_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "link_side_tests.rs"]
|
||||
mod side_tests;
|
||||
Reference in new issue
Block a user