Merge claude/practical-noether-1hb2s1 in [216]
This commit is contained in:
231 files changed
+11368
-1152
No files matched your search
@@ -208,6 +208,12 @@ fn arc_cutters(arc: &crate::wall_arc::WallArc, f: &OuterFaces, cuts: &WallCuts,
|
||||
/// Abzugs-Streifen einer Wand für eine Decke (leer: Wand trägt die Decke nicht als Aussenwand).
|
||||
pub(crate) fn wall_cutters(p: &Project, w: &Wall, cuts: &WallCuts, c: &Ceiling) -> Vec<Vec<[f64; 2]>> {
|
||||
let Some(f) = outer_faces(p, w) else { return Vec::new() };
|
||||
wall_cutters_with(p, w, f, cuts, c)
|
||||
}
|
||||
|
||||
/// Wie [`wall_cutters`] mit schon bestimmten Aussenschichten (`outer_faces` liest die Schichtfunktionen, [214]: je
|
||||
/// Wand einmal statt je Decke).
|
||||
fn wall_cutters_with(p: &Project, w: &Wall, f: OuterFaces, cuts: &WallCuts, c: &Ceiling) -> Vec<Vec<[f64; 2]>> {
|
||||
if cuts.covered || c.edge_at_outline == Some(true) || c.outline.len() < 3 || !overlaps_z(p, w, c) {
|
||||
return Vec::new();
|
||||
}
|
||||
@@ -243,12 +249,17 @@ pub(crate) fn bearing_outlines(p: &Project, only: impl Fn(&Ceiling) -> bool, kno
|
||||
if todo.is_empty() {
|
||||
return out;
|
||||
}
|
||||
let walls: Vec<&Wall> = p.walls.iter().filter(|w| outer_faces(p, w).is_some() && todo.iter().any(|&i| overlaps_z(p, w, &ceilings[i]))).collect();
|
||||
let walls: Vec<(&Wall, OuterFaces)> = p
|
||||
.walls
|
||||
.iter()
|
||||
.filter(|w| todo.iter().any(|&i| overlaps_z(p, w, &ceilings[i])))
|
||||
.filter_map(|w| Some((w, outer_faces(p, w)?)))
|
||||
.collect();
|
||||
if walls.is_empty() {
|
||||
return out;
|
||||
}
|
||||
// Verschneidung nur der Geschosse mit solchen Wänden (wie `compute_joins_by_floor`).
|
||||
let floors: HashSet<&str> = walls.iter().map(|w| w.floor_id.as_str()).collect();
|
||||
let floors: HashSet<&str> = walls.iter().map(|(w, _)| w.floor_id.as_str()).collect();
|
||||
let mut joins: HashMap<&str, WallCuts> = HashMap::new();
|
||||
for (floor, idx) in floor_groups(p) {
|
||||
if !floors.contains(floor) || known.is_some() {
|
||||
@@ -268,7 +279,7 @@ pub(crate) fn bearing_outlines(p: &Project, only: impl Fn(&Ceiling) -> bool, kno
|
||||
let cb = bbox_of(ring.iter().copied());
|
||||
let cutters: Vec<crate::flat::Polygon> = walls
|
||||
.iter()
|
||||
.flat_map(|w| wall_cutters(p, w, known.and_then(|k| k.get(&w.id)).or_else(|| joins.get(w.id.as_str())).unwrap_or(&none), c))
|
||||
.flat_map(|&(w, f)| wall_cutters_with(p, w, f, known.and_then(|k| k.get(&w.id)).or_else(|| joins.get(w.id.as_str())).unwrap_or(&none), c))
|
||||
.filter(|s| {
|
||||
let b = bbox_of(s.iter().copied());
|
||||
b[0] < cb[2] && b[2] > cb[0] && b[1] < cb[3] && b[3] > cb[1]
|
||||
|
||||
@@ -25,12 +25,21 @@ pub(super) fn ceiling_layers<'a>(p: &'a Project, c: &Ceiling) -> Option<&'a [Lay
|
||||
|
||||
/// Deckenplatten (`emitSlabs`): eine Platte je Materiallage, oben→unten gestapelt.
|
||||
pub fn emit_slabs(p: &Project) -> Vec<RSlab> {
|
||||
emit_slabs_with(p, None)
|
||||
}
|
||||
|
||||
/// Wie [`emit_slabs`]; `joins`: schon gerechnete Schnittlinien je Wand-id (3D-Cache, [214]: sonst rechnet das
|
||||
/// Deckenauflager die Verschneidung aller Geschosse neu).
|
||||
pub fn emit_slabs_with(p: &Project, joins: Option<&HashMap<String, WallCuts>>) -> Vec<RSlab> {
|
||||
let mut ceilings: Vec<(usize, &Ceiling)> = Vec::new();
|
||||
let mut layers_of: Vec<Option<&[Layer]>> = Vec::new();
|
||||
let mut w = FlatWriter::new();
|
||||
let count = w.slot();
|
||||
// [178] Auflager an Aussenwänden: Platte bis Aussenkante Kern (abgeleiteter Umriss, Modell unverändert).
|
||||
let bearing = super::bearing::ceiling_bearing_outlines(p);
|
||||
let bearing = match joins {
|
||||
Some(j) => super::bearing::bearing_outlines(p, |_| true, Some(j)),
|
||||
None => super::bearing::ceiling_bearing_outlines(p),
|
||||
};
|
||||
let v2 = |r: &[[f64; 2]]| -> Vec<Vec2> { r.iter().map(|q| Vec2 { x: q[0], y: q[1] }).collect() };
|
||||
for (ci, c) in p.ceilings.as_deref().unwrap_or(&[]).iter().enumerate() {
|
||||
if c.outline.len() < 3 {
|
||||
|
||||
@@ -22,7 +22,7 @@ use crate::jsnum::round;
|
||||
|
||||
// Teile der 3D-Ableitung ([162] aus einer Datei aufgeteilt).
|
||||
mod ceilings;
|
||||
mod bearing;
|
||||
pub(crate) mod bearing;
|
||||
mod columns;
|
||||
mod walls;
|
||||
mod wall_body;
|
||||
@@ -128,7 +128,7 @@ pub const DEFAULT_CREASE_DEG: f64 = 30.0;
|
||||
|
||||
|
||||
/// Das 3D-Modell in Teilen.
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Parts {
|
||||
pub walls: Vec<RWall>,
|
||||
|
||||
@@ -719,3 +719,25 @@ fn giebelwand_mit_rundfenster_ohne_stossfuge() {
|
||||
}
|
||||
}
|
||||
|
||||
/// [217] Wandkörper mit negativer/NaN-Höhe und ebener Oberkante: `wall_top_at`/`wall_piece_mesh` dürfen nicht
|
||||
/// panikieren (`f64::clamp` mit min > max oder NaN-Grenzen legte das WASM-Modul lahm).
|
||||
#[test]
|
||||
fn wandkoerper_mit_kaputter_hoehe_ohne_panic() {
|
||||
use crate::plan::walls::tests::pocket_project;
|
||||
let ws = emit_walls(&pocket_project(DoorTypeKind::Schiebe, None, 1.0), false).unwrap();
|
||||
let mut w = ws[0].clone();
|
||||
w.top_plane = Some([3.0, 0.1, 0.0]);
|
||||
for h in [-3.0, f64::NAN, 0.0, f64::INFINITY, -1e300] {
|
||||
w.height = h;
|
||||
let _ = wall_top_at(&w, [0.0, 0.0]);
|
||||
let _ = wall_piece_mesh(&w);
|
||||
let _ = wall_piece_volume(&w);
|
||||
}
|
||||
for c in [[f64::NAN, 0.0, 0.0], [f64::INFINITY, 1.0, 1.0]] {
|
||||
w.height = 2.5;
|
||||
w.top_plane = Some(c);
|
||||
assert!(wall_top_at(&w, [1.0, 1.0]).is_finite());
|
||||
}
|
||||
w.base_elevation = f64::NAN;
|
||||
let _ = wall_piece_mesh(&w);
|
||||
}
|
||||
@@ -969,7 +969,11 @@ pub(crate) fn wall_footprint(w: &RWall) -> Option<[[f64; 2]; 4]> {
|
||||
pub(crate) fn wall_top_at(w: &RWall, q: [f64; 2]) -> f64 {
|
||||
let zt = w.base_elevation + w.height;
|
||||
match w.top_plane {
|
||||
Some(c) => (c[0] + c[1] * (q[0] - w.start[0]) + c[2] * (q[1] - w.start[1])).clamp(w.base_elevation, zt),
|
||||
// Negative Höhe oder NaN: Grenzen vertauscht bzw. ungültig -> ebene Oberkante, kein Panic.
|
||||
Some(c) => {
|
||||
let z = crate::jsnum::clamp_safe(c[0] + c[1] * (q[0] - w.start[0]) + c[2] * (q[1] - w.start[1]), w.base_elevation, zt);
|
||||
if z.is_finite() { z } else { zt }
|
||||
}
|
||||
None => zt,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user