[258] Kern-Panic: partial_cmp().unwrap() auf NaN beim Sortieren
Ein Deckenpunkt bei 1e300 läuft in render3d (f32) zu inf/NaN über; die Sortierung der Schnittkreuzungen rief partial_cmp().unwrap() und panikte. Alle gleichartigen Sortierungen von Gleitkommazahlen (render3d section/mesh/openings, hatchgen, Kern wall_poche/area_report) nutzen total_cmp (NaN sortiert ans Ende). Regression: tests/robustness.rs regression_decke_nan_im_schnitt.
This commit is contained in:
6 files changed
+8
-8
No files matched your search
@@ -536,7 +536,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
for (_, mut v) in rows {
|
||||
v.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap());
|
||||
v.sort_by(|a, b| a.0.total_cmp(&b.0));
|
||||
for w in v.windows(2) {
|
||||
assert!(w[0].1 <= w[1].0, "Überlappung {:?}", w);
|
||||
}
|
||||
|
||||
@@ -1112,7 +1112,7 @@ mod tests {
|
||||
});
|
||||
let c = core.unwrap();
|
||||
let mut ends = [c[0].x, c[3].x];
|
||||
ends.sort_by(|a, b| a.partial_cmp(b).unwrap());
|
||||
ends.sort_by(|a, b| a.total_cmp(b));
|
||||
assert!((c[0].y - merge).abs() < 1e-9 && (c[3].y - merge).abs() < 1e-9, "{deg}°");
|
||||
assert!((ends[0] - xb0).abs() < 1e-9 && (ends[1] - xb1).abs() < 1e-9, "{deg}° {ends:?} {xb0} {xb1}");
|
||||
// Fugen beidseits des Kerns laufen bis zur Rückgrat-Fläche (Kern gegen Nah-Putz), die
|
||||
|
||||
@@ -1359,7 +1359,7 @@ mod tests {
|
||||
((a.y - y) * (b.y - y) <= 0.0 && (b.y - a.y).abs() > 1e-12).then(|| a.x + (y - a.y) / (b.y - a.y) * (b.x - a.x))
|
||||
})
|
||||
.collect();
|
||||
xs.sort_by(|a, b| a.partial_cmp(b).unwrap());
|
||||
xs.sort_by(|a, b| a.total_cmp(b));
|
||||
xs
|
||||
}
|
||||
|
||||
|
||||
@@ -397,7 +397,7 @@ fn solid_subrects(
|
||||
holes: &[(f32, f32, f32, f32)],
|
||||
) -> Vec<(f32, f32, f32, f32)> {
|
||||
let sort_dedup = |mut v: Vec<f32>| -> Vec<f32> {
|
||||
v.sort_by(|a, b| a.partial_cmp(b).unwrap());
|
||||
v.sort_by(|a, b| a.total_cmp(b));
|
||||
v.dedup_by(|a, b| (*a - *b).abs() <= MIN_SPAN);
|
||||
v
|
||||
};
|
||||
@@ -444,7 +444,7 @@ fn subtract_intervals(lo: f32, hi: f32, gaps: &[(f32, f32)]) -> Vec<(f32, f32)>
|
||||
.map(|(a, b)| (a.max(lo), b.min(hi)))
|
||||
.filter(|(a, b)| b - a > MIN_SPAN)
|
||||
.collect();
|
||||
gs.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap());
|
||||
gs.sort_by(|a, b| a.0.total_cmp(&b.0));
|
||||
let mut out = Vec::new();
|
||||
let mut cursor = lo;
|
||||
for (a, b) in gs {
|
||||
|
||||
@@ -44,7 +44,7 @@ pub(crate) fn split_range_by_voids(
|
||||
if voids.is_empty() {
|
||||
return vec![(lo, hi, z0, z1)];
|
||||
}
|
||||
voids.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap());
|
||||
voids.sort_by(|a, b| a.0.total_cmp(&b.0));
|
||||
|
||||
let mut rects = Vec::new();
|
||||
let mut cursor = lo;
|
||||
|
||||
@@ -516,7 +516,7 @@ fn footprint_u_intervals(plane: &SectionPlane, footprint: &[Point2]) -> Vec<(f32
|
||||
crossings.push(u_of([px, py]));
|
||||
}
|
||||
}
|
||||
crossings.sort_by(|x, y| x.partial_cmp(y).unwrap());
|
||||
crossings.sort_by(|x, y| x.total_cmp(y));
|
||||
crossings.dedup_by(|x, y| (*x - *y).abs() < eps);
|
||||
|
||||
let mut out = Vec::new();
|
||||
@@ -755,7 +755,7 @@ fn intersect_ranges(a: Option<(f32, f32)>, b: Option<(f32, f32)>) -> Option<(f32
|
||||
/// disjunkten Liste.
|
||||
fn merge_intervals(mut ivs: Vec<(f32, f32)>) -> Vec<(f32, f32)> {
|
||||
ivs.retain(|(s, e)| *e - *s > MIN_SPAN);
|
||||
ivs.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap());
|
||||
ivs.sort_by(|a, b| a.0.total_cmp(&b.0));
|
||||
let mut out: Vec<(f32, f32)> = Vec::new();
|
||||
for (s, e) in ivs {
|
||||
if let Some(last) = out.last_mut() {
|
||||
|
||||
Reference in new issue
Block a user