[K2] Raeume nach Rust: room_area (Flaechen, SIA-416-Zuordnung nur im Kern), room_boundary (ueber kernel2d), polygon_holes; TS-Fassaden, TS-Rechenlogik geloescht
This commit is contained in:
15 files changed
+950
-680
No files matched your search
@@ -12,6 +12,9 @@ mod auto_dimensions;
|
||||
mod kennzahlen;
|
||||
mod bulge;
|
||||
mod stair;
|
||||
mod room_area;
|
||||
mod room_boundary;
|
||||
mod polygon_holes;
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//! Bindung des Brücken-Tricks (`crate::polygon_holes`).
|
||||
|
||||
use crate::flat_read::{pairs, Reader};
|
||||
use crate::polygon_holes::merge_holes;
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Aussenring `[x0, y0, …]`, Löcher `[n, (nPkt, x, y, …)…]`, Brückenabstand →
|
||||
/// `[nBrücken, kantenIndex…, nPkt, x, y, …]`; leer bei kaputter Eingabe.
|
||||
#[wasm_bindgen]
|
||||
pub fn polygon_merge_holes(outline: &[f64], holes: &[f64], gap: f64) -> Vec<f64> {
|
||||
let mut r = Reader::new(holes);
|
||||
let Some(n) = r.count() else { return vec![] };
|
||||
let mut hs = Vec::with_capacity(n.min(1 << 16));
|
||||
for _ in 0..n {
|
||||
let Some(h) = r.ring() else { return vec![] };
|
||||
hs.push(h);
|
||||
}
|
||||
let m = merge_holes(&pairs(outline), &hs, gap);
|
||||
let mut out = Vec::with_capacity(2 + m.bridge_edges.len() + 2 * m.ring.len());
|
||||
out.push(m.bridge_edges.len() as f64);
|
||||
out.extend(m.bridge_edges.iter().map(|&k| k as f64));
|
||||
out.push(m.ring.len() as f64);
|
||||
for p in &m.ring {
|
||||
out.extend(*p);
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//! Bindungen der Raum-Flächen und der SIA-416-Bilanz (`crate::room_area`).
|
||||
//! Rechnungen ohne Prüfung der Zahlen: NaN/∞ ergeben NaN, nie einen Panic.
|
||||
|
||||
use crate::flat_read::pairs;
|
||||
use crate::room_area as ra;
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Ring `[x0, y0, …]`, Abzug (m²) → `[brutto, netto, umfang, schwerpunktX, schwerpunktY]`.
|
||||
#[wasm_bindgen]
|
||||
pub fn room_evaluate(pts: &[f64], deduction: f64) -> Vec<f64> {
|
||||
let e = ra::evaluate(&pairs(pts), deduction);
|
||||
vec![e.gross, e.net, e.perimeter, e.centroid[0], e.centroid[1]]
|
||||
}
|
||||
|
||||
/// Ring `[x0, y0, …]` → absolute Fläche.
|
||||
#[wasm_bindgen]
|
||||
pub fn room_polygon_area(pts: &[f64]) -> f64 {
|
||||
ra::evaluate(&pairs(pts), 0.0).gross
|
||||
}
|
||||
|
||||
/// Ring `[x0, y0, …]` → `[x, y]`.
|
||||
#[wasm_bindgen]
|
||||
pub fn room_centroid(pts: &[f64]) -> Vec<f64> {
|
||||
let c = ra::evaluate(&pairs(pts), 0.0).centroid;
|
||||
vec![c[0], c[1]]
|
||||
}
|
||||
|
||||
/// Kategorie-Indizes und Flächen je Raum (gleich lang) →
|
||||
/// `[6 Flächen je Blatt-Kategorie, 6 Raumzahlen, 3 Flächen NF/NGF/GF, 3 Raumzahlen]`.
|
||||
/// Ungültige Indizes (NaN, ausserhalb) werden übergangen.
|
||||
#[wasm_bindgen]
|
||||
pub fn room_balance(categories: &[f64], areas: &[f64]) -> Vec<f64> {
|
||||
let rooms: Vec<(usize, f64)> = categories
|
||||
.iter()
|
||||
.zip(areas)
|
||||
.filter(|(c, _)| c.is_finite() && **c >= 0.0 && c.fract() == 0.0 && **c < ra::CATEGORIES.len() as f64)
|
||||
.map(|(c, a)| (*c as usize, *a))
|
||||
.collect();
|
||||
let b = ra::balance(&rooms);
|
||||
let mut out = Vec::with_capacity(18);
|
||||
out.extend(b.leaf_area);
|
||||
out.extend(b.leaf_count.iter().map(|&n| n as f64));
|
||||
out.extend(b.agg_area);
|
||||
out.extend(b.agg_count.iter().map(|&n| n as f64));
|
||||
out
|
||||
}
|
||||
|
||||
/// Blatt-Kategorien in Index-Reihenfolge (TS prüft damit seine Namensliste).
|
||||
#[wasm_bindgen]
|
||||
pub fn room_sia_categories() -> Vec<String> {
|
||||
ra::CATEGORIES.iter().map(|s| s.to_string()).collect()
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
//! Bindungen der Raum-Erkennung (`crate::room_boundary`). Kodierung dort.
|
||||
|
||||
use crate::room_boundary as rb;
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Wände → Räume `[n, (nPkt, x, y, …)…]`; Lücken ≤ `gap_tol` werden geschlossen.
|
||||
#[wasm_bindgen]
|
||||
pub fn rooms_detect(walls: &[f64], gap_tol: f64, min_area: f64, offset_to_inner: bool) -> Vec<f64> {
|
||||
rb::detect(walls, gap_tol, min_area, offset_to_inner)
|
||||
}
|
||||
|
||||
/// Umriss der Zelle um den Punkt `[nPkt, x, y, …]`, leer = keine.
|
||||
#[wasm_bindgen]
|
||||
pub fn room_from_point(px: f64, py: f64, walls: &[f64], gap_tol: f64, offset_to_inner: bool) -> Vec<f64> {
|
||||
rb::from_point(px, py, walls, gap_tol, offset_to_inner)
|
||||
}
|
||||
|
||||
/// Wie `room_from_point`, aber auf fertigen Wand-Innenflächen (ohne Offset).
|
||||
#[wasm_bindgen]
|
||||
pub fn room_from_point_faces(px: f64, py: f64, faces: &[f64], gap_tol: f64) -> Vec<f64> {
|
||||
rb::from_point_faces(px, py, faces, gap_tol)
|
||||
}
|
||||
Reference in new issue
Block a user