No panics in the boolean's final assembly (the web build aborts on any panic: the Plastic Enclosure sample panicked 8 times and crashed the browser's start page); face pushes check their result and fall back to the general offset (a boss standing on a plate joins again with off-axis cylinder seams); offset errors name the face they can't move; docs/robustness.md with the before and after rates; caught panics counted per design in the robustness runs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AS5Tn3xieewUSg3uxrMVdL
This commit is contained in:
1 parent
ccde7a4837
commit
1bf377c14b
8 files changed
+182
-33
No files matched your search
@@ -26,10 +26,11 @@ impl<P, C, S> FacesClassification<P, C, S> {
|
||||
pub fn and_or_unknown(&self) -> [Shell<P, C, S>; 3] {
|
||||
let [mut and, mut or, mut unknown] = <[Shell<P, C, S>; 3]>::default();
|
||||
for face in &self.shell {
|
||||
match self.status.get(&face.id()).unwrap() {
|
||||
ShapesOpStatus::And => and.push(face.clone()),
|
||||
ShapesOpStatus::Or => or.push(face.clone()),
|
||||
ShapesOpStatus::Unknown => unknown.push(face.clone()),
|
||||
// SolveCraft: no panics (wasm can't catch them).
|
||||
match self.status.get(&face.id()) {
|
||||
Some(ShapesOpStatus::And) => and.push(face.clone()),
|
||||
Some(ShapesOpStatus::Or) => or.push(face.clone()),
|
||||
_ => unknown.push(face.clone()),
|
||||
}
|
||||
}
|
||||
[and, or, unknown]
|
||||
@@ -42,21 +43,19 @@ impl<P, C, S> FacesClassification<P, C, S> {
|
||||
let components = unknown.connected_components();
|
||||
for comp in components {
|
||||
let boundary = comp.extract_boundaries();
|
||||
if and_boundary
|
||||
.iter()
|
||||
.flatten()
|
||||
.any(|edge| edge.id() == boundary[0][0].id())
|
||||
{
|
||||
let Some(first) = boundary.first().and_then(|w| w.edge_iter().next()).map(|e| e.id()) else { continue };
|
||||
let set = if and_boundary.iter().flatten().any(|edge| edge.id() == first) {
|
||||
Some(ShapesOpStatus::And)
|
||||
} else if or_boundary.iter().flatten().any(|edge| edge.id() == first) {
|
||||
Some(ShapesOpStatus::Or)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
if let Some(st) = set {
|
||||
comp.iter().for_each(|face| {
|
||||
*self.status.get_mut(&face.id()).unwrap() = ShapesOpStatus::And;
|
||||
})
|
||||
} else if or_boundary
|
||||
.iter()
|
||||
.flatten()
|
||||
.any(|edge| edge.id() == boundary[0][0].id())
|
||||
{
|
||||
comp.iter().for_each(|face| {
|
||||
*self.status.get_mut(&face.id()).unwrap() = ShapesOpStatus::Or;
|
||||
if let Some(x) = self.status.get_mut(&face.id()) {
|
||||
*x = st;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+10
-8
@@ -68,7 +68,8 @@ fn process_one_pair_of_shells<C: ShapeOpsCurve<S>, S: ShapeOpsSurface>(
|
||||
cls1.integrate_by_component();
|
||||
let [mut and0, mut or0, unknown0] = cls0.and_or_unknown();
|
||||
unknown0.into_iter().try_for_each(|face| {
|
||||
let pt = face.boundaries()[0].vertex_iter().next().unwrap().point();
|
||||
// SolveCraft: no panics (wasm can't catch them).
|
||||
let pt = face.boundaries().first()?.vertex_iter().next()?.point();
|
||||
let dir = hash::take_one_unit(pt);
|
||||
let count = poly_shell1.iter().try_fold(0, |count, face| {
|
||||
let poly = face.surface()?;
|
||||
@@ -83,7 +84,8 @@ fn process_one_pair_of_shells<C: ShapeOpsCurve<S>, S: ShapeOpsSurface>(
|
||||
})?;
|
||||
let [mut and1, mut or1, unknown1] = cls1.and_or_unknown();
|
||||
unknown1.into_iter().try_for_each(|face| {
|
||||
let pt = face.boundaries()[0].vertex_iter().next().unwrap().point();
|
||||
// SolveCraft: no panics (wasm can't catch them).
|
||||
let pt = face.boundaries().first()?.vertex_iter().next()?.point();
|
||||
let dir = hash::take_one_unit(pt);
|
||||
let count = poly_shell0.iter().try_fold(0, |count, face| {
|
||||
let poly = face.surface()?;
|
||||
@@ -109,8 +111,8 @@ pub fn and<C: ShapeOpsCurve<S>, S: ShapeOpsSurface>(
|
||||
) -> Option<Solid<Point3, C, S>> {
|
||||
let mut iter0 = solid0.boundaries().iter();
|
||||
let mut iter1 = solid1.boundaries().iter();
|
||||
let shell0 = iter0.next().unwrap();
|
||||
let shell1 = iter1.next().unwrap();
|
||||
let shell0 = iter0.next()?;
|
||||
let shell1 = iter1.next()?;
|
||||
let [mut and_shell, _] = process_one_pair_of_shells(shell0, shell1, tol)?;
|
||||
for shell in iter0 {
|
||||
let [res, _] = process_one_pair_of_shells(&and_shell, shell, tol)?;
|
||||
@@ -121,7 +123,7 @@ pub fn and<C: ShapeOpsCurve<S>, S: ShapeOpsSurface>(
|
||||
and_shell = res;
|
||||
}
|
||||
let boundaries = components_in_order(&and_shell);
|
||||
Some(Solid::new(boundaries))
|
||||
Solid::try_new(boundaries).ok()
|
||||
}
|
||||
|
||||
/// OR operation between two solids.
|
||||
@@ -132,8 +134,8 @@ pub fn or<C: ShapeOpsCurve<S>, S: ShapeOpsSurface>(
|
||||
) -> Option<Solid<Point3, C, S>> {
|
||||
let mut iter0 = solid0.boundaries().iter();
|
||||
let mut iter1 = solid1.boundaries().iter();
|
||||
let shell0 = iter0.next().unwrap();
|
||||
let shell1 = iter1.next().unwrap();
|
||||
let shell0 = iter0.next()?;
|
||||
let shell1 = iter1.next()?;
|
||||
let [_, mut or_shell] = process_one_pair_of_shells(shell0, shell1, tol)?;
|
||||
for shell in iter0 {
|
||||
let [_, res] = process_one_pair_of_shells(&or_shell, shell, tol)?;
|
||||
@@ -144,7 +146,7 @@ pub fn or<C: ShapeOpsCurve<S>, S: ShapeOpsSurface>(
|
||||
or_shell = res;
|
||||
}
|
||||
let boundaries = components_in_order(&or_shell);
|
||||
Some(Solid::new(boundaries))
|
||||
Solid::try_new(boundaries).ok()
|
||||
}
|
||||
|
||||
// SolveCraft: truck's connected components come out in hash order of face addresses, so the
|
||||
|
||||
Reference in new issue
Block a user