[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
@@ -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