Merge branch 'worktree-agent-abca8f1c9f80d8eb4' into claude/practical-noether-1hb2s1
# Conflicts: # TODO.md # src-tauri/core/src/web/mod.rs
This commit is contained in:
15 files changed
+1207
-91
No files matched your search
@@ -314,7 +314,9 @@ impl State<'_> {
|
||||
|
||||
pub fn triangulate(coords: &[f64]) -> Vec<u32> {
|
||||
let n = coords.len() >> 1;
|
||||
if n < 3 || coords.len() != 2 * n || coords.iter().any(|v| !v.is_finite()) {
|
||||
// Obergrenze der Koordinaten ([258]): darüber laufen Abstandsquadrate/Umkreisprodukte über (∞/NaN), die Hülle
|
||||
// wird inkonsistent und die Suchschleifen drehen endlos. Kartenkoordinaten bleiben weit darunter.
|
||||
if n < 3 || coords.len() != 2 * n || coords.iter().any(|v| !(v.abs() <= 1e60)) {
|
||||
return Vec::new();
|
||||
}
|
||||
let max_triangles = if n * 2 >= 5 { 2 * n - 5 } else { 0 };
|
||||
@@ -522,6 +524,14 @@ mod tests {
|
||||
assert_eq!(t.len(), 6);
|
||||
}
|
||||
|
||||
/// [258] Riesige Koordinaten (Quadrate laufen über): leer statt Endlosschleife.
|
||||
#[test]
|
||||
fn regression_riesige_koordinaten() {
|
||||
assert!(triangulate(&[0.0, 0.0, 1e300, 0.0, 0.0, 1e300, 1e300, 1e300, 5e299, 5e299]).is_empty());
|
||||
assert!(triangulate(&[0.0, 0.0, f64::MAX, 0.0, 0.0, f64::MAX, 1.0, 1.0]).is_empty());
|
||||
assert_eq!(triangulate(&[0.0, 0.0, 1e6, 0.0, 0.0, 1e6]).len(), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kollinear_und_zu_wenig_sind_leer() {
|
||||
assert!(triangulate(&[0.0, 0.0, 1.0, 1.0, 2.0, 2.0]).is_empty());
|
||||
|
||||
@@ -478,7 +478,7 @@ pub fn decode_mesh(f: &[f64], strings: &[String]) -> Result<(Vec<MeshObject>, Va
|
||||
let color = (h[2] == 1.0).then(|| vec![h[3], h[4], h[5], h[6]]);
|
||||
let (np, ni) = (h[7], h[8]);
|
||||
at += 9;
|
||||
if !(np.fract() == 0.0 && ni.fract() == 0.0 && np >= 0.0 && ni >= 0.0) || at + np as usize + ni as usize > f.len() {
|
||||
if !(np.fract() == 0.0 && ni.fract() == 0.0 && np >= 0.0 && ni >= 0.0) || np + ni > (f.len() - at) as f64 {
|
||||
return Err("Mesh-Import: Puffer beschädigt".into());
|
||||
}
|
||||
let positions: Vec<f64> = f[at..at + np as usize].to_vec();
|
||||
@@ -617,7 +617,7 @@ pub fn decode_step(f: &[f64]) -> Result<Vec<(Vec<f32>, Vec<f64>)>, String> {
|
||||
let h = f.get(at..at + 2).ok_or_else(bad)?;
|
||||
let (np, ni) = (h[0], h[1]);
|
||||
at += 2;
|
||||
if !(np.fract() == 0.0 && ni.fract() == 0.0 && np >= 0.0 && ni >= 0.0) || at + np as usize + ni as usize > f.len() {
|
||||
if !(np.fract() == 0.0 && ni.fract() == 0.0 && np >= 0.0 && ni >= 0.0) || np + ni > (f.len() - at) as f64 {
|
||||
return Err(bad());
|
||||
}
|
||||
let positions = f[at..at + np as usize].iter().map(|&x| x as f32).collect();
|
||||
@@ -657,6 +657,16 @@ pub fn step_meshes(bodies: &[(Vec<f32>, Vec<f64>)], file_name: &str, now: f64) -
|
||||
mod step_tests {
|
||||
use super::*;
|
||||
|
||||
/// [258] Zähler 1e300 / 1e19 (saturieren zu usize::MAX, Summe lief über): Fehler statt Slice-Panic.
|
||||
#[test]
|
||||
fn regression_decode_step_riesige_zaehler() {
|
||||
for n in [1e300, 1e19, 9.3e18] {
|
||||
assert!(decode_step(&[1.0, 1.0, n, 0.0, 1.0]).is_err());
|
||||
assert!(decode_step(&[1.0, 1.0, 1.0, n, 1.0]).is_err());
|
||||
assert!(decode_step(&[1.0, 1.0, n, n, 1.0]).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
fn flat() -> Vec<f64> {
|
||||
// zwei Körper: Dreieck mit 0.1f32 (nicht exakt in f64), Dreieck mit ganzen Zahlen
|
||||
let mut f = vec![1.0, 2.0, 9.0, 3.0];
|
||||
|
||||
@@ -147,7 +147,8 @@ pub mod dim_assoc;
|
||||
pub mod opening_slide;
|
||||
|
||||
#[cfg(feature = "web")]
|
||||
mod web;
|
||||
#[doc(hidden)]
|
||||
pub mod web;
|
||||
pub mod presentation_sheet;
|
||||
pub mod drawing_recognize;
|
||||
pub mod kosten;
|
||||
|
||||
@@ -281,7 +281,7 @@ pub fn contour_marks(flat: &[f64]) -> Vec<f64> {
|
||||
let mut i = 5;
|
||||
while i + 3 <= flat.len() {
|
||||
let (z, closed, n) = (flat[i], flat[i + 1] != 0.0, flat[i + 2]);
|
||||
if !(n >= 0.0 && n.fract() == 0.0) || i + 3 + 2 * (n as usize) > flat.len() {
|
||||
if !(n >= 0.0 && n.fract() == 0.0) || n > ((flat.len() - i - 3) / 2) as f64 {
|
||||
return vec![];
|
||||
}
|
||||
let pts = flat[i + 3..i + 3 + 2 * (n as usize)].chunks_exact(2).map(|c| [c[0], c[1]]).collect();
|
||||
@@ -332,6 +332,14 @@ fn ridge_pitch(r: &Value, eave: f64, rise: f64) -> Option<f64> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// [258] Punktzahl 1e300 (saturiert zu usize::MAX, `2 * n` lief über → Slice-Panic): leer statt Panic.
|
||||
#[test]
|
||||
fn regression_contour_marks_riesige_punktzahl() {
|
||||
for n in [1e300, 1e19, 4e18, 1e9, f64::INFINITY, f64::NAN, -1.0, 0.5] {
|
||||
assert!(contour_marks(&[0.0, 0.0, 1.0, 0.0, f64::NAN, 10.0, 1.0, n, 0.0, 0.0]).is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
fn root() -> Map<String, Value> {
|
||||
json!({
|
||||
"drawingLevels": [
|
||||
|
||||
@@ -524,6 +524,10 @@ pub fn faces(rings: &[Vec<P2>], speeds: &[f64], budget: Option<usize>) -> Result
|
||||
}
|
||||
budget = budget.checked_sub(1).ok_or(SkeletonError::Budget)?;
|
||||
w.step(e);
|
||||
// Ecken wachsen höchstens linear mit n; darüber läuft die Front in einen Rundungs-Zyklus ([258]).
|
||||
if w.corners.len() > 32 * n + 256 {
|
||||
w.broken = true;
|
||||
}
|
||||
}
|
||||
let left: Vec<&Corner> = w.corners.iter().filter(|c| c.alive).collect();
|
||||
if !w.broken && !left.is_empty() && left.iter().all(|c| w.edges[c.left].speed <= 0.0 && w.edges[c.right].speed <= 0.0) {
|
||||
|
||||
@@ -1020,7 +1020,7 @@ pub fn datum(reference_masl: Option<f64>, z: &[f64]) -> f64 {
|
||||
/// Binomialfilters [1 2 1]/4 je Achse. Fehlende Nachbarn zählen nicht (Gewichte werden renormiert), fehlende
|
||||
/// Zellen bleiben fehlend. Falsche Grösse → Eingabe unverändert.
|
||||
pub fn smooth_grid(z: &[f64], nx: usize, ny: usize, passes: u32) -> Vec<f64> {
|
||||
if nx == 0 || ny == 0 || z.len() != nx * ny {
|
||||
if nx == 0 || ny == 0 || nx.checked_mul(ny) != Some(z.len()) {
|
||||
return z.to_vec();
|
||||
}
|
||||
let mut cur = z.to_vec();
|
||||
@@ -1100,6 +1100,15 @@ pub fn resmooth_grid_mesh(positions: &[f64], passes: u32) -> Option<Vec<f64>> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
/// [258] Rastergrösse nx · ny läuft über (usize-Wrap passte zur Länge → Index-Panic): Eingabe unverändert.
|
||||
#[test]
|
||||
fn regression_smooth_grid_ueberlauf() {
|
||||
let z = [1.0, 2.0];
|
||||
assert_eq!(smooth_grid(&z, (1usize << 63) + 1, 2, 1), z.to_vec());
|
||||
assert_eq!(smooth_grid(&z, usize::MAX, usize::MAX, 1), z.to_vec());
|
||||
assert_eq!(smooth_grid(&z, 3, 1, 1), z.to_vec());
|
||||
}
|
||||
|
||||
use super::*;
|
||||
|
||||
/// [137] Raster-Gelände neu glätten: Raster erkannt, nur z ändert sich, Spitze wird flacher; additiv
|
||||
|
||||
@@ -198,10 +198,11 @@ pub fn grip_coincident(corners: &[f64], groups: &[f64]) -> Vec<f64> {
|
||||
if !(n >= 0.0 && n.fract() == 0.0) {
|
||||
return vec![];
|
||||
}
|
||||
let end = i + 1 + 2 * n as usize;
|
||||
if end > groups.len() {
|
||||
// Als f64 prüfen: `n as usize` sättigt bei 1e300, `1 + 2 * n` liefe über ([258]).
|
||||
if n > ((groups.len() - i - 1) / 2) as f64 {
|
||||
return vec![];
|
||||
}
|
||||
let end = i + 1 + 2 * n as usize;
|
||||
gs.push(pts(&groups[i + 1..end]));
|
||||
i = end;
|
||||
}
|
||||
@@ -212,6 +213,15 @@ pub fn grip_coincident(corners: &[f64], groups: &[f64]) -> Vec<f64> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// [258] Gruppengrösse 1e300 / 1e19: leer statt Slice-Panic durch usize-Überlauf.
|
||||
#[test]
|
||||
fn regression_coincident_riesige_gruppe() {
|
||||
for n in [1e300, 1e19, 9.3e18, 4e18, f64::INFINITY] {
|
||||
assert!(grip_coincident(&[0.0, 0.0], &[n, 0.0, 0.0]).is_empty());
|
||||
assert!(grip_coincident(&[0.0, 0.0], &[1.0, 0.0, 0.0, n, 0.0, 0.0]).is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kaputte_puffer_leer() {
|
||||
assert!(grip_coincident(&[0.0, 0.0], &[3.0, 1.0]).is_empty());
|
||||
|
||||
@@ -3,54 +3,54 @@
|
||||
//! Kaputte Eingaben ergeben ein leeres Ergebnis statt eines Panics (ein Panic legt das ganze
|
||||
//! WASM-Modul lahm, [14]).
|
||||
|
||||
mod kernel2d;
|
||||
mod polygon;
|
||||
mod roof;
|
||||
mod sun;
|
||||
mod site_rules;
|
||||
mod kennzahlen;
|
||||
mod bulge;
|
||||
mod stair;
|
||||
mod room_area;
|
||||
mod room_boundary;
|
||||
mod polygon_holes;
|
||||
mod plan_buf;
|
||||
mod project_format;
|
||||
mod gpu_compile;
|
||||
mod delaunay;
|
||||
mod document;
|
||||
mod ops;
|
||||
mod voids;
|
||||
mod curves;
|
||||
mod hatch;
|
||||
mod skeleton;
|
||||
mod plan_scene;
|
||||
mod plan_pick;
|
||||
mod snap;
|
||||
mod plan_svg;
|
||||
mod plan_dxf;
|
||||
mod plan_print_svg;
|
||||
mod layers;
|
||||
mod pens;
|
||||
mod layout_model;
|
||||
mod clash_broad;
|
||||
mod parametric_walls;
|
||||
mod reorder;
|
||||
mod text_layout;
|
||||
mod grips;
|
||||
mod grip_drag;
|
||||
mod competition;
|
||||
mod project_refs;
|
||||
mod commands;
|
||||
mod import;
|
||||
mod cmd_create;
|
||||
mod area_report;
|
||||
mod rich_text;
|
||||
mod geo_mesh;
|
||||
mod opening_presets;
|
||||
mod furniture_lib;
|
||||
mod solid_bool;
|
||||
mod line_pattern;
|
||||
pub mod kernel2d;
|
||||
pub mod polygon;
|
||||
pub mod roof;
|
||||
pub mod sun;
|
||||
pub mod site_rules;
|
||||
pub mod kennzahlen;
|
||||
pub mod bulge;
|
||||
pub mod stair;
|
||||
pub mod room_area;
|
||||
pub mod room_boundary;
|
||||
pub mod polygon_holes;
|
||||
pub mod plan_buf;
|
||||
pub mod project_format;
|
||||
pub mod gpu_compile;
|
||||
pub mod delaunay;
|
||||
pub mod document;
|
||||
pub mod ops;
|
||||
pub mod voids;
|
||||
pub mod curves;
|
||||
pub mod hatch;
|
||||
pub mod skeleton;
|
||||
pub mod plan_scene;
|
||||
pub mod plan_pick;
|
||||
pub mod snap;
|
||||
pub mod plan_svg;
|
||||
pub mod plan_dxf;
|
||||
pub mod plan_print_svg;
|
||||
pub mod layers;
|
||||
pub mod pens;
|
||||
pub mod layout_model;
|
||||
pub mod clash_broad;
|
||||
pub mod parametric_walls;
|
||||
pub mod reorder;
|
||||
pub mod text_layout;
|
||||
pub mod grips;
|
||||
pub mod grip_drag;
|
||||
pub mod competition;
|
||||
pub mod project_refs;
|
||||
pub mod commands;
|
||||
pub mod import;
|
||||
pub mod cmd_create;
|
||||
pub mod area_report;
|
||||
pub mod rich_text;
|
||||
pub mod geo_mesh;
|
||||
pub mod opening_presets;
|
||||
pub mod furniture_lib;
|
||||
pub mod solid_bool;
|
||||
pub mod line_pattern;
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
|
||||
Reference in new issue
Block a user