diff --git a/TODO.md b/TODO.md index f8572269..a68dafab 100644 --- a/TODO.md +++ b/TODO.md @@ -701,6 +701,25 @@ truck (`trucksolid`) bleibt eigenes WASM-Modul (Panic-Isolation), wird vom Kern ~1 ms → 0,2–0,5 ms, 5000 Punkte 18–22 → 9–16 ms; Auswahl (300 Wände) verschieben unverändert (5–11 ms). Bleibt: die Kopie der Liste in TS je Änderung (`slice` von 20 000 Elementen ≈ 0,14 ms) — Preis der unveränderlichen Leseansicht. Nicht in der Tauri-App geprüft. + **Aufräumen nach den parallelen Ports (29.10.):** Suche nach toten Exporten (Skript über alle `src/**/*.ts`: + Export ohne Nutzer ausser Tests/Fassade) und toten Bindungen (`#[wasm_bindgen]` ohne TS-Aufrufer), dazu + `cargo clippy` (dead_code, auch Web-Build). Gelöscht (TS): `wallVerticalExtent`/`ceilingVerticalExtent`/ + `columnVerticalExtent` (`model/wall.ts`, Aufrufer `toSection`/`voids`/`sectionOpenings`/`toElevation` gab es + nicht mehr; Tests über die Kern-Abfrage `verticalExtents` bzw. Rust-Tests), `openingVerticalExtent`/ + `wallAxisFrame`/`openingCenter` (`geometry/opening.ts`), `isValidOutline`/`outlineCentroid`, `getStairType`/ + `openingsOfWall`/`openingLabel`/`columnLabel`/`getComponent` (`types.ts`), `MONO_INK`/`WALL_FALLBACK_MM`, + `scatterStrokes`, `ShaderProgram`, `SLAB_RGB`/`DRAWING_LINE_FALLBACK_RGB`, `booleanMesh` samt Typen, + `meshBytesToImportedMeshes`, `IDEAL_RISER`, `bulgeBetweenAngles`, `pointSegDistPx`, `coreReady`. Bindungen: + `doc_query`, `core_version`, `drawing3d_line_verts`/`drawing3d_pick_segs` (`web/drawing2d_3d.rs`), + `bulge_between_angles`, `scatter_strokes_flat`. Rust zusammengelegt: Höhenregeln (UK/OK von Wand/Stütze/Decke, + Geschoss-Bindung) einmal in `model/helpers.rs::heights` für typisierte Sicht und rohe Wurzel (`selection_info.rs`); + JS-Wahrheitswert `truthy` (vorher je eine Kopie in `geo_translate`/`layers`/`pens`) aus `grips`; `finite` → + `jsnum::or_zero` (Kopien in `kennzahlen`/`flaechen`/`room_program`); JS-`String(v)` einmal in + `js_fmt::js_string` (vorher `project_format` und `selection_info`, letztere ohne Listen); `arr` aus `grips`. + Bleibt bewusst: `geometry/geomTransform.ts` (Werkzeuge, zieht mit [K4] S3 Werkzeuge in den Kern), TS-Fassaden, + die nur Tests nutzen (`solidVolume`, `withoutHoles`, `straightSkeleton`, `stairCut`, `triangulate`, + Schraffur-Clipping in `glPlanHatch.ts`, `subtractRings` — prüfen Kern-Bindungen von TS aus), mehrere + `signed_area`/`bbox`-Varianten in Rust (verschiedene Punkt-Typen, teils mit JS-Semantik `jsnum::min`). - ◐ **S4 Typen aus Rust**: `types.ts` wird aus den Rust-Strukturen erzeugt (ts-rs); Datei-I/O (`projectFormat`, Migration, IFC/DXF/ STEP-Ex- und -Import) im Kern. **Typen (28.10.):** Das Rust-Modell (`core/src/model/generated.rs`, `manual.rs`) ist die Quelle; ts-rs 12 (MIT, nur diff --git a/src-tauri/core/src/flaechen.rs b/src-tauri/core/src/flaechen.rs index f4467f62..05ea643c 100644 --- a/src-tauri/core/src/flaechen.rs +++ b/src-tauri/core/src/flaechen.rs @@ -81,13 +81,7 @@ fn area_kind(r: &Room) -> usize { kennzahlen::category_index(r.sia_category) } -fn finite(v: f64) -> f64 { - if v.is_finite() { - v - } else { - 0.0 - } -} +use crate::jsnum::or_zero as finite; /// Woher das Gebäudevolumen kommt. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)] diff --git a/src-tauri/core/src/geo_translate.rs b/src-tauri/core/src/geo_translate.rs index 3b4a6a5d..73bb5f3f 100644 --- a/src-tauri/core/src/geo_translate.rs +++ b/src-tauri/core/src/geo_translate.rs @@ -20,15 +20,7 @@ fn shift_all(v: Option<&Value>, dx: f64, dy: f64) -> Value { Value::Array(v.and_then(Value::as_array).map(|a| a.iter().map(|p| shift(p, dx, dy)).collect()).unwrap_or_default()) } -fn truthy(v: Option<&Value>) -> bool { - match v { - None | Some(Value::Null) => false, - Some(Value::Bool(b)) => *b, - Some(Value::Number(n)) => n.as_f64().is_some_and(|f| f != 0.0 && !f.is_nan()), - Some(Value::String(s)) => !s.is_empty(), - Some(_) => true, - } -} +use crate::grips::truthy; /// `{...m, key: v}` — ein vorhandener Schlüssel behält seine Stelle; `None` = `undefined` (Feld entfällt). fn set(m: &mut Map, key: &str, v: Option) { diff --git a/src-tauri/core/src/grips.rs b/src-tauri/core/src/grips.rs index 13bd9611..cf8b1ad8 100644 --- a/src-tauri/core/src/grips.rs +++ b/src-tauri/core/src/grips.rs @@ -161,7 +161,7 @@ fn calc(f: f64) -> Pass { Pass { f, v: Some(js_num(f)) } } -fn arr(v: Option<&Value>) -> &[Value] { +pub fn arr(v: Option<&Value>) -> &[Value] { v.and_then(Value::as_array).map(Vec::as_slice).unwrap_or(&[]) } diff --git a/src-tauri/core/src/js_fmt.rs b/src-tauri/core/src/js_fmt.rs index 4a5eae8d..c3616ded 100644 --- a/src-tauri/core/src/js_fmt.rs +++ b/src-tauri/core/src/js_fmt.rs @@ -109,6 +109,19 @@ pub fn js_number(x: f64) -> String { format!("{sign}{body}") } +/// JS-`String(v)` eines JSON-Werts (Meldungen, Anzeige-Texte). +pub fn js_string(v: &serde_json::Value) -> String { + use serde_json::Value; + match v { + Value::Null => "null".into(), + Value::Bool(b) => b.to_string(), + Value::Number(n) => n.as_f64().map_or(n.to_string(), js_number), + Value::String(s) => s.clone(), + Value::Array(a) => a.iter().map(|x| if x.is_null() { String::new() } else { js_string(x) }).collect::>().join(","), + Value::Object(_) => "[object Object]".into(), + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/src-tauri/core/src/jsnum.rs b/src-tauri/core/src/jsnum.rs index c4bb0fee..46bd826a 100644 --- a/src-tauri/core/src/jsnum.rs +++ b/src-tauri/core/src/jsnum.rs @@ -85,6 +85,16 @@ mod trig { pub use trig::{acos, atan2, cos, pow, sin, tan}; +/// Endliche Zahl oder 0 (NaN/±∞ → 0; Summen der Kennzahlen/Flächen). +#[inline] +pub fn or_zero(v: f64) -> f64 { + if v.is_finite() { + v + } else { + 0.0 + } +} + /// `Math.min(a, b)` (NaN gewinnt; −0 < +0). #[inline] pub fn min(a: f64, b: f64) -> f64 { diff --git a/src-tauri/core/src/kennzahlen.rs b/src-tauri/core/src/kennzahlen.rs index 50d5da1f..5d277106 100644 --- a/src-tauri/core/src/kennzahlen.rs +++ b/src-tauri/core/src/kennzahlen.rs @@ -11,13 +11,7 @@ use crate::flat_read::signed_area; /// Anzahl der SIA-416-Blattkategorien (Reihenfolge: `room_area::CATEGORIES`). pub const CATEGORIES: usize = crate::room_area::CATEGORIES.len(); -fn finite(v: f64) -> f64 { - if v.is_finite() { - v - } else { - 0.0 - } -} +use crate::jsnum::or_zero as finite; /// Volumen (m³): Grundfläche (Polygon `points` oder Kreis mit Radius `circle_r`, NaN = kein /// Kreis), Höhe, Verjüngung `taper` (0 = Prisma, 1 = Spitze; ausserhalb geklemmt, NaN = 0). diff --git a/src-tauri/core/src/layers.rs b/src-tauri/core/src/layers.rs index 60a847f8..d3c3d2a3 100644 --- a/src-tauri/core/src/layers.rs +++ b/src-tauri/core/src/layers.rs @@ -11,16 +11,7 @@ use std::collections::HashSet; type Tree = Vec; -/// JS-Wahrheitswert eines JSON-Werts (`if (c.visible)`). -fn truthy(v: Option<&Value>) -> bool { - match v { - None | Some(Value::Null) => false, - Some(Value::Bool(b)) => *b, - Some(Value::Number(n)) => n.as_f64().is_some_and(|f| f != 0.0 && !f.is_nan()), - Some(Value::String(s)) => !s.is_empty(), - Some(_) => true, - } -} +use crate::grips::truthy; fn code_of(c: &Value) -> Option<&str> { c.get("code").and_then(Value::as_str) diff --git a/src-tauri/core/src/model/helpers.rs b/src-tauri/core/src/model/helpers.rs index 6df7c114..78e2ffb3 100644 --- a/src-tauri/core/src/model/helpers.rs +++ b/src-tauri/core/src/model/helpers.rs @@ -118,7 +118,7 @@ impl Project { VerticalAnchor::Custom { z } => Some(*z), VerticalAnchor::Floor { floor_id, offset } => { let f = self.floor(floor_id)?; - Some(f.base_elevation.unwrap_or(0.0) + offset.unwrap_or(0.0)) + Some(heights::floor_anchor(f.base_elevation.unwrap_or(0.0), offset.unwrap_or(0.0))) } } } @@ -126,16 +126,12 @@ impl Project { /// (UK, OK) einer Wand in Metern (`wallVerticalExtent`). pub fn wall_vertical_extent(&self, w: &Wall) -> (f64, f64) { let floor_base = self.floor(&w.floor_id).map_or(0.0, |f| f.base_elevation.unwrap_or(0.0)); - let bottom = self.resolve_anchor(w.bottom.as_ref()).unwrap_or(floor_base); - let top = self.resolve_anchor(w.top.as_ref()).unwrap_or(bottom + w.height); - (bottom, top) + heights::element(floor_base, self.resolve_anchor(w.bottom.as_ref()), self.resolve_anchor(w.top.as_ref()), w.height) } pub fn ceiling_vertical_extent(&self, c: &Ceiling) -> (f64, f64) { let floor_top = self.floor(&c.floor_id).map_or(0.0, |f| f.base_elevation.unwrap_or(0.0) + f.floor_height.unwrap_or(0.0)); - let top = self.resolve_anchor(c.top.as_ref()).unwrap_or(floor_top); - let bottom = self.resolve_anchor(c.bottom.as_ref()).unwrap_or(top - self.ceiling_thickness(c)); - (bottom, top) + heights::ceiling(floor_top, self.resolve_anchor(c.bottom.as_ref()), self.resolve_anchor(c.top.as_ref()), || self.ceiling_thickness(c)) } pub fn stair_vertical_extent(&self, s: &Stair) -> (f64, f64) { @@ -150,9 +146,7 @@ impl Project { pub fn column_vertical_extent(&self, c: &Column) -> (f64, f64) { let floor_base = self.floor(&c.floor_id).map_or(0.0, |f| f.base_elevation.unwrap_or(0.0)); - let bottom = self.resolve_anchor(c.bottom.as_ref()).unwrap_or(floor_base); - let top = self.resolve_anchor(c.top.as_ref()).unwrap_or(bottom + c.height); - (bottom, top) + heights::element(floor_base, self.resolve_anchor(c.bottom.as_ref()), self.resolve_anchor(c.top.as_ref()), c.height) } /// Traufhöhe (absolutes Z): `baseElevation`, sonst Oberkante des Geschosses (`roofBaseElevation`). @@ -227,3 +221,43 @@ impl Stair { ] } } + +/// Höhenregeln (UK/OK) — eine Fassung für die typisierte Sicht (oben) und die rohe Projekt-Wurzel +/// (`selection_info.rs`: Objekt-Info, 3D-Griffe); die Aufrufer lösen nur ihre Eingaben auf. +pub mod heights { + /// Bindung „Geschoss“: Basis des Geschosses + Versatz. + pub fn floor_anchor(base: f64, offset: f64) -> f64 { + base + offset + } + + /// Wand/Stütze: UK aus der Bindung `bottom`, sonst Geschoss-Basis; OK aus `top`, sonst UK + Höhe. + pub fn element(floor_base: f64, bottom: Option, top: Option, height: f64) -> (f64, f64) { + let zb = bottom.unwrap_or(floor_base); + (zb, top.unwrap_or(zb + height)) + } + + /// Decke: OK aus `top`, sonst Geschoss-Oberkante; UK aus `bottom`, sonst OK − Dicke (die Decke wächst + /// nach unten; die Dicke wird nur dann bestimmt). + pub fn ceiling(floor_top: f64, bottom: Option, top: Option, thickness: impl FnOnce() -> f64) -> (f64, f64) { + let zt = top.unwrap_or(floor_top); + (bottom.unwrap_or_else(|| zt - thickness()), zt) + } + + #[cfg(test)] + mod tests { + use super::*; + + #[test] + fn wand_stuetze_und_decke() { + // Geschoss-Basis + Höhe; Bindungen übersteuern UK/OK unabhängig. + assert_eq!(element(0.0, None, None, 3.0), (0.0, 3.0)); + assert_eq!(element(0.0, Some(0.5), Some(floor_anchor(3.0, 0.0)), 3.0), (0.5, 3.0)); + assert_eq!(element(2.8, Some(1.0), None, 2.0), (1.0, 3.0)); + // Decke: OK = Geschoss-Oberkante, UK = OK − Dicke; die Dicke nur ohne UK-Bindung. + assert_eq!(ceiling(2.6, None, None, || 0.25), (2.35, 2.6)); + assert_eq!(ceiling(2.6, Some(2.2), None, || panic!("Dicke nicht gebraucht")), (2.2, 2.6)); + assert_eq!(ceiling(2.6, None, Some(3.0), || 0.2), (2.8, 3.0)); + assert_eq!(floor_anchor(2.8, 0.1), 2.8 + 0.1); + } + } +} diff --git a/src-tauri/core/src/pens.rs b/src-tauri/core/src/pens.rs index 97de0f42..160fb307 100644 --- a/src-tauri/core/src/pens.rs +++ b/src-tauri/core/src/pens.rs @@ -12,16 +12,7 @@ pub const PEN_FALLBACK_COLOR: &str = "#9aa0a6"; /// Strichstärke (mm) eines Stifts ohne Eintrag. pub const PEN_FALLBACK_WEIGHT: f64 = 0.18; -/// JS-Wahrheitswert (`if (x.colorPenId)`). -fn truthy(v: Option<&Value>) -> bool { - match v { - None | Some(Value::Null) => false, - Some(Value::Bool(b)) => *b, - Some(Value::Number(n)) => n.as_f64().is_some_and(|f| f != 0.0 && !f.is_nan()), - Some(Value::String(s)) => !s.is_empty(), - Some(_) => true, - } -} +use crate::grips::truthy; /// Schlüssel des Stifts als Objekt-Schlüssel (JS: `pens[penId]`, eine Zahl wird zu Text). fn key_of(v: &Value) -> Option { diff --git a/src-tauri/core/src/project_format.rs b/src-tauri/core/src/project_format.rs index dc781e91..1672c4f5 100644 --- a/src-tauri/core/src/project_format.rs +++ b/src-tauri/core/src/project_format.rs @@ -32,17 +32,7 @@ pub enum Parsed { Err(String), } -/// JS-`String(v)` für die Meldungen. -fn js_string(v: &Value) -> String { - match v { - Value::Null => "null".into(), - Value::Bool(b) => b.to_string(), - Value::Number(n) => n.as_f64().map_or(n.to_string(), crate::js_fmt::js_number), - Value::String(s) => s.clone(), - Value::Array(a) => a.iter().map(|x| if x.is_null() { String::new() } else { js_string(x) }).collect::>().join(","), - Value::Object(_) => "[object Object]".into(), - } -} +use crate::js_fmt::js_string; /// 1 → 2: Legacy-Türen (`doors`) werden zu Öffnungen (`openings`, kind `door`). fn migrate_doors(mut raw: Map) -> Map { diff --git a/src-tauri/core/src/room_program.rs b/src-tauri/core/src/room_program.rs index dbbb0d40..dc22f462 100644 --- a/src-tauri/core/src/room_program.rs +++ b/src-tauri/core/src/room_program.rs @@ -30,13 +30,7 @@ use crate::model::{Project, SiaCategory}; pub const DEFAULT_TOLERANCE: f64 = 0.05; -fn finite(v: f64) -> f64 { - if v.is_finite() { - v - } else { - 0.0 - } -} +use crate::jsnum::or_zero as finite; fn cat_name(c: SiaCategory) -> &'static str { match c { diff --git a/src-tauri/core/src/selection_info.rs b/src-tauri/core/src/selection_info.rs index bf1b283e..8f9fe45e 100644 --- a/src-tauri/core/src/selection_info.rs +++ b/src-tauri/core/src/selection_info.rs @@ -15,7 +15,8 @@ //! Der B-Rep-Körper einer Extrusion (`spec`) bleibt in TS (truck-Pipeline, `plan/extrudedSolidSpec.ts`). use crate::document::Lookup; -use crate::grips::{field, js_num, num_of, truthy, xy}; +use crate::model::helpers::heights; +use crate::grips::{arr, field, js_num, num_of, truthy, xy}; use crate::jsmath::hypot2; use crate::jsnum; use crate::ops::id_of; @@ -134,10 +135,6 @@ impl O { } } -fn arr(v: Option<&Value>) -> &[Value] { - v.and_then(Value::as_array).map(Vec::as_slice).unwrap_or(&[]) -} - /// Erstes Element, dessen Feld `key` gleich `val` ist (`===`; fehlend gleich fehlend). fn find_by<'a>(list: &'a [Value], key: &str, val: Option<&Value>) -> Option<&'a Value> { list.iter().find(|e| field(e, key) == val) @@ -152,17 +149,6 @@ fn str_of(v: Option<&Value>) -> Option<&str> { v.and_then(Value::as_str) } -/// `String(v)` für die Anzeige (Name eines Geschosses). -fn js_string(v: &Value) -> Value { - match v { - Value::String(_) => v.clone(), - Value::Number(n) => Value::from(crate::js_fmt::js_number(n.as_f64().unwrap_or(f64::NAN))), - Value::Null => Value::from("null"), - Value::Bool(b) => Value::from(if *b { "true" } else { "false" }), - _ => Value::from("[object Object]"), - } -} - /// Kategorie (Ebene) per Code: erster Treffer der Tiefensuche (`findCategory`). fn category<'a>(root: &'a Map, code: Option<&Value>) -> Option<&'a Value> { fn walk<'a>(list: &'a [Value], code: Option<&Value>) -> Option<&'a Value> { @@ -186,10 +172,7 @@ fn component<'a>(root: &'a Map, id: Option<&Value>) -> Result<&'a /// Wert in einer Template-Zeichenkette (`${v}`). fn js_text(v: &Value) -> String { - match js_string(v) { - Value::String(s) => s, - _ => String::new(), - } + crate::js_fmt::js_string(v) } /// `x.color ?? cat?.color ?? fallback`. @@ -305,7 +288,7 @@ fn anchor(root: &Map, a: Option<&Value>) -> Option { return nn(field(a, "z")).map(|z| num_of(Some(z))); } let f = level(root, field(a, "floorId"))?; - Some(num_or(field(f, "baseElevation"), 0.0) + num_or(field(a, "offset"), 0.0)) + Some(heights::floor_anchor(num_or(field(f, "baseElevation"), 0.0), num_or(field(a, "offset"), 0.0))) } fn num_or(v: Option<&Value>, d: f64) -> f64 { @@ -319,18 +302,14 @@ fn num_or(v: Option<&Value>, d: f64) -> f64 { /// (UK, OK) einer Wand oder Stütze: UK aus `bottom` sonst Geschoss-Basis, OK aus `top` sonst UK + Höhe. fn vertical_extent(root: &Map, el: &Value) -> (f64, f64) { let floor_base = level(root, field(el, "floorId")).map_or(0.0, |f| num_or(field(f, "baseElevation"), 0.0)); - let zb = anchor(root, field(el, "bottom")).unwrap_or(floor_base); - let zt = anchor(root, field(el, "top")).unwrap_or(zb + num_of(field(el, "height"))); - (zb, zt) + heights::element(floor_base, anchor(root, field(el, "bottom")), anchor(root, field(el, "top")), num_of(field(el, "height"))) } /// (UK, OK) einer Decke (`ceilingVerticalExtent`): OK aus `top` sonst Geschoss-Oberkante (Basis + Höhe), UK aus /// `bottom` sonst OK − `thickness` (die Decke wächst nach unten). fn ceiling_extent(root: &Map, c: &Value, thickness: f64) -> (f64, f64) { let floor_top = level(root, field(c, "floorId")).map_or(0.0, |f| num_or(field(f, "baseElevation"), 0.0) + num_or(field(f, "floorHeight"), 0.0)); - let zt = anchor(root, field(c, "top")).unwrap_or(floor_top); - let zb = anchor(root, field(c, "bottom")).unwrap_or(zt - thickness); - (zb, zt) + heights::ceiling(floor_top, anchor(root, field(c, "bottom")), anchor(root, field(c, "top")), || thickness) } /// Anfrage `verticalExtents`: Wände und Decken als ganze Elemente (die 3D-Griffe zeigen auch gerade gezogene, diff --git a/src-tauri/core/src/web/bulge.rs b/src-tauri/core/src/web/bulge.rs index d71fc906..fe652392 100644 --- a/src-tauri/core/src/web/bulge.rs +++ b/src-tauri/core/src/web/bulge.rs @@ -27,11 +27,6 @@ pub fn bulge_from_sagitta_point(ax: f64, ay: f64, bx: f64, by: f64, px: f64, py: b::from_sagitta_point(ax, ay, bx, by, px, py) } -#[wasm_bindgen] -pub fn bulge_between_angles(cx: f64, cy: f64, r: f64, a_from: f64, a_to: f64, sweep_sign: f64) -> f64 { - b::between_angles(cx, cy, r, a_from, a_to, sweep_sign) -} - /// `[x, y]` auf dem Bogen bei t∈[0,1]. #[wasm_bindgen] pub fn bulge_point_at(ax: f64, ay: f64, bx: f64, by: f64, bulge: f64, t: f64) -> Vec { diff --git a/src-tauri/core/src/web/document.rs b/src-tauri/core/src/web/document.rs index c40b0741..bec26de9 100644 --- a/src-tauri/core/src/web/document.rs +++ b/src-tauri/core/src/web/document.rs @@ -174,15 +174,9 @@ pub fn doc_json(h: u32) -> String { with_doc(h, |d| d.to_json()).unwrap_or_default() } -/// Abfrage auf dem typisierten Projekt; Ergebnis als JSON. Fehler (Dokument nicht offen, Modell -/// passt nicht, unbekannte Abfrage, Rechenfehler) kommen als Text mit vorangestelltem `\u{1}`. -/// Abfragen s. `crate::queries`. -#[wasm_bindgen] -pub fn doc_query(h: u32, name: &str) -> String { - doc_query_args(h, name, &[], "") -} - -/// Wie [`doc_query`] mit Zahlen- und Textargument. +/// Abfrage auf dem typisierten Projekt mit Zahlen- und Textargument; Ergebnis als JSON. Fehler (Dokument +/// nicht offen, Modell passt nicht, unbekannte Abfrage, Rechenfehler) kommen als Text mit vorangestelltem +/// `\u{1}`. Abfragen s. `crate::queries`. #[wasm_bindgen] pub fn doc_query_args(h: u32, name: &str, args: &[f64], text: &str) -> String { let result = with_doc(h, |d| { @@ -196,7 +190,7 @@ pub fn doc_query_args(h: u32, name: &str, args: &[f64], text: &str) -> String { } } -/// Abfrage auf der rohen Projekt-Wurzel (`crate::queries::run_root`); Fehler wie bei [`doc_query`]. +/// Abfrage auf der rohen Projekt-Wurzel (`crate::queries::run_root`); Fehler wie bei [`doc_query_args`]. #[wasm_bindgen] pub fn doc_query_root(h: u32, name: &str, text: &str) -> String { let result = with_doc(h, |d| crate::queries::run_root(&d.lookup(), name, text)).unwrap_or_else(|| Err("Dokument nicht offen".to_string())); diff --git a/src-tauri/core/src/web/drawing2d_3d.rs b/src-tauri/core/src/web/drawing2d_3d.rs deleted file mode 100644 index 87a90cb2..00000000 --- a/src-tauri/core/src/web/drawing2d_3d.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! Bindungen der 2D-Zeichnungen im 3D (`crate::drawing2d_3d`). Kodierung s. dort. - -use crate::drawing2d_3d as d; -use wasm_bindgen::prelude::wasm_bindgen; - -/// LineList-Vertices `[px, höhe, py, r, g, b]` (zwei je Segment) einer Charge. -#[wasm_bindgen] -pub fn drawing3d_line_verts(drawings: &[f64]) -> Vec { - d::line_verts(drawings) -} - -/// Pick-Strecken `[ax, ay, bx, by, baseElevation, zeichnung]` einer Charge. -#[wasm_bindgen] -pub fn drawing3d_pick_segs(drawings: &[f64], tolerance: f64) -> Vec { - d::pick_segs(drawings, tolerance) -} diff --git a/src-tauri/core/src/web/hatch.rs b/src-tauri/core/src/web/hatch.rs index 45e83c37..8e46cabc 100644 --- a/src-tauri/core/src/web/hatch.rs +++ b/src-tauri/core/src/web/hatch.rs @@ -75,16 +75,3 @@ pub fn hatch_line_family_flat(poly: &[f64], angle_rad: f64, spacing_m: f64, offs segs_out(&hatch::hatch_line_family(&pts(poly), angle_rad, spacing_m, offset_m, v2(ax, ay))) } -/// `len_min`/`len_max` NaN = nicht gesetzt. -#[wasm_bindgen] -pub fn scatter_strokes_flat( - poly: &[f64], - cell: f64, - base_angle_rad: f64, - seed: f64, - stroke_len: f64, - len_min: f64, - len_max: f64, -) -> Vec { - runs_out(&hatch::scatter_strokes(&pts(poly), cell, base_angle_rad, seed, stroke_len, opt(len_min), opt(len_max))) -} diff --git a/src-tauri/core/src/web/mod.rs b/src-tauri/core/src/web/mod.rs index 27a20595..ae142a07 100644 --- a/src-tauri/core/src/web/mod.rs +++ b/src-tauri/core/src/web/mod.rs @@ -15,7 +15,6 @@ mod stair; mod room_area; mod room_boundary; mod polygon_holes; -mod drawing2d_3d; mod plan_buf; mod project_format; mod gpu_compile; @@ -46,9 +45,3 @@ use wasm_bindgen::prelude::wasm_bindgen; pub fn start() { console_error_panic_hook::set_once(); } - -/// Version des Kern-Moduls (für Diagnose/Startprotokoll). -#[wasm_bindgen] -pub fn core_version() -> String { - env!("CARGO_PKG_VERSION").to_string() -} diff --git a/src/core/extra.ts b/src/core/extra.ts index 2ec22270..c35453c9 100644 --- a/src/core/extra.ts +++ b/src/core/extra.ts @@ -18,7 +18,7 @@ export { exportObj, exportStl, exportGlb, exportGltf } from "../export/exportMes export { exportProjectStep } from "../export/exportStep"; export { planToSvgString } from "../export/planToSvgString"; export { setWasmBytesProvider } from "../engine/wasmSource"; -export { initCore, coreReady } from "../engine/coreWasm"; +export { initCore } from "../engine/coreWasm"; export { applyOps, validateProject, validateOps } from "./ops"; export type { CoreOp } from "./ops"; export type { Project, DrawingLevel } from "../model/types"; diff --git a/src/core/index.ts b/src/core/index.ts index ba4b9bc9..0c0c2288 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -9,7 +9,6 @@ export { bulgeArc, bulgeArcPoints, bulgePolylinePoints, - bulgeBetweenAngles, bulgeFromSagittaPoint, bulgePointAt, bulgeThroughPoint, @@ -97,7 +96,6 @@ export { } from "../geometry/lineSegments"; export { - openingVerticalExtent, } from "../geometry/opening"; export { autoExteriorDimensions } from "../geometry/autoDimensions"; export * as polygonBool from "../geometry/polygonBool"; @@ -255,7 +253,6 @@ export { meetScale, mmToPx, pointInPolygon, - pointSegDistPx, printStrokeVb, scaleFromView, toScreen, diff --git a/src/engine/coreWasm.ts b/src/engine/coreWasm.ts index 99c1aa1c..3f565435 100644 --- a/src/engine/coreWasm.ts +++ b/src/engine/coreWasm.ts @@ -24,10 +24,6 @@ export function initCoreSync(bytes: BufferSource): void { ready = true; } -export function coreReady(): boolean { - return ready; -} - /** Der geladene Kern; wirft, wenn `initCore()` noch nicht gelaufen ist (Programmierfehler). */ export function core(): CoreModule { if (!ready) throw new Error("Rust-Kern nicht geladen: initCore() muss vor der ersten Kern-Funktion laufen."); diff --git a/src/engine/truckSolid.ts b/src/engine/truckSolid.ts index 0237b546..0617d6bd 100644 --- a/src/engine/truckSolid.ts +++ b/src/engine/truckSolid.ts @@ -70,37 +70,6 @@ export async function extrudeCircle( return JSON.parse(json) as ExtrudedMesh; } -export type BooleanOp = "union" | "difference" | "intersection"; - -export interface BooleanMeshResult { - positions: number[]; - indices: number[]; - empty: boolean; -} - -/** Boolesche Operation zweier Dreiecks-Meshes (Mesh-Ebenen-CSG via csgrs, - * truck-Integration Phase 4). Beide Meshes müssen konsistent nach außen - * gewundene Dreiecke haben (Rechte-Hand-Regel) — sonst liefert csgrs ein - * falsches Ergebnis, ohne das zu erkennen. */ -export async function booleanMesh( - a: ExtrudedMesh, - b: ExtrudedMesh, - op: BooleanOp, -): Promise { - const json = await guarded((m) => - m.boolean_mesh( - JSON.stringify({ - a_positions: a.positions, - a_indices: a.indices, - b_positions: b.positions, - b_indices: b.indices, - op, - }), - ), - ); - return JSON.parse(json) as BooleanMeshResult; -} - // ── B-Rep-Körper (truck 0.6): Spezifikation → Mesh / STEP ──────────────────── /** Ein Loft-Schnitt: Höhe + geschlossener Ring [x0,y0,x1,y1,…]. */ diff --git a/src/geometry/bulge.ts b/src/geometry/bulge.ts index 0d6aed73..83c04be6 100644 --- a/src/geometry/bulge.ts +++ b/src/geometry/bulge.ts @@ -120,21 +120,6 @@ export function arcThroughPoints(a: Vec2, through: Vec2, b: Vec2): ArcParams | n return toArcParams(core().arc_through_points(a.x, a.y, through.x, through.y, b.x, b.y)); } -/** - * Bulge-Wert für den Teilbogen desselben Kreises (center, r) von Winkel `aFrom` zu `aTo`, in der - * durch `sweepSign` vorgegebenen Schwenkrichtung (+1 = CCW, −1 = CW), z. B. beim Zuschneiden/ - * Offsetten eines Bogen-Segments. - */ -export function bulgeBetweenAngles( - center: Vec2, - r: number, - aFrom: number, - aTo: number, - sweepSign: 1 | -1, -): number { - return core().bulge_between_angles(center.x, center.y, r, aFrom, aTo, sweepSign); -} - /** * Kreisbogen durch zwei Endpunkte `a`→`b` mit vorgegebenem Radius `r` (Methode „Start-Ende- * Radius"). `near` (typischerweise der Cursor) wählt die Seite der Sehne; es entsteht immer der diff --git a/src/geometry/ceiling.ts b/src/geometry/ceiling.ts index bbdb4f63..ca674075 100644 --- a/src/geometry/ceiling.ts +++ b/src/geometry/ceiling.ts @@ -32,44 +32,11 @@ export function normalizeOutline(pts: Vec2[]): Vec2[] | null { return isCCW(clean) ? clean : clean.slice().reverse(); } -/** Ob ein Umriss ein gültiges (nicht entartetes) Deckenpolygon bildet. */ -export function isValidOutline(pts: Vec2[]): boolean { - const norm = normalizeOutline(pts); - return norm != null && ceilingArea(norm) >= MIN_CEILING_AREA; -} - /** Fläche eines Deckenumrisses in m² (immer positiv). */ export function ceilingArea(pts: Vec2[]): number { return Math.abs(signedArea(pts)); } -/** Schwerpunkt (Zentroid) des Umriss-Polygons (für HUD/Beschriftung). */ -export function outlineCentroid(pts: Vec2[]): Vec2 { - const a = signedArea(pts); - if (Math.abs(a) < 1e-12) { - // Entartet: einfacher Mittelwert der Punkte. - let sx = 0, - sy = 0; - for (const p of pts) { - sx += p.x; - sy += p.y; - } - const n = pts.length || 1; - return { x: sx / n, y: sy / n }; - } - let cx = 0, - cy = 0; - for (let i = 0; i < pts.length; i++) { - const p = pts[i]; - const q = pts[(i + 1) % pts.length]; - const cr = p.x * q.y - q.x * p.y; - cx += (p.x + q.x) * cr; - cy += (p.y + q.y) * cr; - } - const f = 1 / (6 * a); - return { x: cx * f, y: cy * f }; -} - /** * Punkt-in-Polygon-Test (Ray-Casting) für einen geschlossenen Umriss — dient dem * Body-Select einer Decke im Grundriss/3D. Randpunkte gelten als innen genug. diff --git a/src/geometry/grips.ts b/src/geometry/grips.ts index 62c942b6..8f57fae3 100644 --- a/src/geometry/grips.ts +++ b/src/geometry/grips.ts @@ -113,8 +113,8 @@ export interface VerticalExtent { } /** - * UK/OK von Wänden und Decken aus dem Kern (`selection_info.rs::vertical_extents`, Regeln wie - * `wallVerticalExtent`/`ceilingVerticalExtent`): Geschoss-Bindungen und Deckentypen aus `project`, die + * UK/OK von Wänden und Decken aus dem Kern (`selection_info.rs::vertical_extents`, Regeln + * `model/helpers.rs::heights`): Geschoss-Bindungen und Deckentypen aus `project`, die * Elemente selbst als ganze Fassung (auch gerade gezogene, noch nicht übernommene — 3D-Griffe). */ export function verticalExtents( diff --git a/src/geometry/opening.ts b/src/geometry/opening.ts index 60ca0c5d..bb87b6f8 100644 --- a/src/geometry/opening.ts +++ b/src/geometry/opening.ts @@ -1,7 +1,7 @@ // Geometrie-Helfer für Öffnungen (Fenster/Türen) — reine Funktionen, die eine // `Opening` relativ zu ihrer Wirts-Wand in konkrete Welt-Geometrie auflösen: -// • die Öffnungs-Lücke entlang der Wandachse (from/to in Metern), -// • die vertikale Lage (UK/OK der Öffnung, absolut in Metern). +// • die Öffnungs-Lücke entlang der Wandachse (from/to in Metern), die Pfosten. +// (Die vertikale Lage rechnet der Kern: `model3d.rs`/`plan/section.rs`, UK/OK der Wand: `model/helpers.rs::heights`.) // // Da JEDE Größe aus der aktuellen Wandachse (`wall.start`/`wall.end`) abgeleitet // wird, folgt eine Öffnung ihrer Wand automatisch, sobald die Wand bewegt wird — @@ -9,9 +9,8 @@ // // Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). -import type { Opening, Project, Vec2, Wall } from "../model/types"; -import { along, leftNormal, normalize, sub } from "../model/geometry"; -import { wallVerticalExtent } from "../model/wall"; +import type { Opening, Vec2, Wall } from "../model/types"; +import { along } from "../model/geometry"; /** Achslänge einer Wand (Meter). */ export function wallAxisLength(wall: Wall): number { @@ -34,29 +33,6 @@ export function openingInterval( return { from, to }; } -/** - * Vertikale Lage einer Öffnung (absolute Z-Werte in Metern) relativ zur Wand-UK. - * Türen sitzen am Boden (sillHeight 0); Fenster ab Brüstung. Die OK wird auf die - * Wand-OK geklemmt, damit die Öffnung nie über den Wandkopf hinausragt. - */ -export function openingVerticalExtent( - project: Project, - wall: Wall, - o: Opening, -): { zBottom: number; zTop: number } { - const { zBottom, zTop } = wallVerticalExtent(project, wall); - const sill = Math.max(0, o.sillHeight); - const oBottom = zBottom + sill; - const oTop = Math.min(zTop, oBottom + o.height); - return { zBottom: oBottom, zTop: oTop }; -} - -/** Einheits-Laufrichtung (u) und linke Normale (n) der Wandachse. */ -export function wallAxisFrame(wall: Wall): { u: Vec2; n: Vec2 } { - const u = normalize(sub(wall.end, wall.start)); - return { u, n: leftNormal(u) }; -} - /** Die beiden Pfosten-Punkte (auf der Achse) einer Öffnung im Grundriss. */ export function openingJambs( wall: Wall, @@ -70,9 +46,3 @@ export function openingJambs( }; } -/** Mittelpunkt einer Öffnung im Grundriss (Achse) — für HUD/Auswahl-Anker. */ -export function openingCenter(wall: Wall, o: Opening): Vec2 | null { - const iv = openingInterval(wall, o); - if (!iv) return null; - return along(wall.start, wall.end, (iv.from + iv.to) / 2); -} diff --git a/src/geometry/stair.ts b/src/geometry/stair.ts index eb911d04..af50a9f1 100644 --- a/src/geometry/stair.ts +++ b/src/geometry/stair.ts @@ -19,8 +19,6 @@ import type { Stair, Vec2 } from "../model/types"; import { core } from "../engine/coreWasm"; -/** SIA-nahe Schrittregel: gute Steigungshöhe ≈ 0.17 m, Auftritt ≈ 0.29 m. */ -export const IDEAL_RISER = 0.17; export const IDEAL_TREAD = 0.29; export const MIN_STEPS = 2; diff --git a/src/io/ifcImport.test.ts b/src/io/ifcImport.test.ts index d27d7b9d..16a8cab3 100644 --- a/src/io/ifcImport.test.ts +++ b/src/io/ifcImport.test.ts @@ -14,7 +14,7 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import { exportIfcSpf, ifcGuid } from "../export/exportIfc"; import { sampleProject } from "../model/sampleProject"; -import { ceilingVerticalExtent } from "../model/wall"; +import { verticalExtents } from "../geometry/grips"; import { polygonArea } from "../geometry/roomArea"; import { wallMeshVolumes } from "../export/meshScene.testutil"; import { formatIfcReport, handleIfcWorkerRequest, ifcToImportedMeshes, readIfc, type IfcProduct, type IfcWorkerRequest } from "./ifcImport"; @@ -100,7 +100,7 @@ describe("IFC-Import: Rundreise mit dem eigenen Export", () => { const slabsExpected = (sampleProject.ceilings ?? []) .filter((c) => c.outline.length >= 3) .map((c) => { - const { zBottom, zTop } = ceilingVerticalExtent(sampleProject, c); + const { zBottom, zTop } = verticalExtents(sampleProject, [], [c]).ceilings[0]; return Math.abs(polygonArea(c.outline)) * Math.max(zTop - zBottom, 0.001); }) .sort((a, b) => a - b); diff --git a/src/io/meshImport.ts b/src/io/meshImport.ts index 70b87d0c..f01f2ea6 100644 --- a/src/io/meshImport.ts +++ b/src/io/meshImport.ts @@ -346,17 +346,6 @@ export function meshObjectsToImportedMeshes(objects: readonly MeshObject[], file }); } -/** Datei-Bytes → Kontext-Meshes + Bericht. */ -export async function meshBytesToImportedMeshes( - bytes: Uint8Array, - fileName: string, - read?: MeshReadOptions, - place?: MeshToContextOptions, -): Promise<{ meshes: ImportedMesh[]; report: MeshImportReport }> { - const { objects, report } = await readMesh(bytes, fileName, read); - return { meshes: meshObjectsToImportedMeshes(objects, fileName, place), report }; -} - /** Bericht als kurzer Text; `tr` übersetzt (Kern kennt kein i18n, die Hülle reicht `t` herein). */ export function formatMeshReport( r: MeshImportReport, diff --git a/src/model/types.ts b/src/model/types.ts index c8013cc6..637bc915 100644 --- a/src/model/types.ts +++ b/src/model/types.ts @@ -18,7 +18,6 @@ import type { BuiltinPaletteBanks, Ceiling, CeilingType, - Column, Component, DoorType, DrawingLevel, @@ -30,8 +29,6 @@ import type { RichTextDoc, Roof, SashDef, - Stair, - StairType, Vec2, Wall, WallType, @@ -204,35 +201,6 @@ export const glazingPanesOf = (wt: WindowType): 1 | 2 | 3 => { return wt.glazing === "dreifach" ? 3 : wt.glazing === "zweifach" ? 2 : 1; }; -/** Löst den {@link StairType} einer Treppe auf, oder `undefined`. */ -export const getStairType = (project: Project, stair: Stair): StairType | undefined => - stair.typeId ? (project.stairTypes ?? []).find((t) => t.id === stair.typeId) : undefined; - -/** Alle Öffnungen einer Wand (leere Liste, wenn keine oder `openings` fehlt). */ -export const openingsOfWall = (project: Project, wallId: string): Opening[] => - (project.openings ?? []).filter((o) => o.hostWallId === wallId); - -/** Menschenlesbarer Standardname einer Öffnung (Fenster/Tür + Breite×Höhe). */ -export const openingLabel = (o: Opening): string => - `${o.kind === "door" ? "Tür" : "Fenster"} ${(o.width * 100).toFixed(0)}×${( - o.height * 100 - ).toFixed(0)}`; - -/** Menschenlesbarer Standardname einer Stütze (Profil + Masse in cm). */ -export const columnLabel = (c: Column): string => { - if (c.profile.kind === "round") { - return `Stütze Ø${(c.profile.radius * 200).toFixed(0)}`; - } - return `Stütze ${(c.profile.width * 100).toFixed(0)}×${(c.profile.depth * 100).toFixed(0)}`; -}; - -/** Liefert ein Bauteil-Material (Component) per ID oder wirft. */ -export const getComponent = (project: Project, id: string): Component => { - const c = project.components.find((co) => co.id === id); - if (!c) throw new Error(`Unbekanntes Bauteil-Material: ${id}`); - return c; -}; - /** Liefert eine Schraffur (HatchStyle) per ID oder wirft. */ export const getHatch = (project: Project, id: string): HatchStyle => { const h = project.hatches.find((ht) => ht.id === id); diff --git a/src/model/wall.test.ts b/src/model/wall.test.ts index b26c515f..f3247d67 100644 --- a/src/model/wall.test.ts +++ b/src/model/wall.test.ts @@ -1,8 +1,9 @@ -// Unit-Tests für die Wand-/Decken-Resolver (wallVerticalExtent / -// ceilingVerticalExtent): reine Datenschicht, kein React/Store. +// Unit-Tests für die Wand-/Decken-Resolver: Referenzlinie (`wallReferenceOffset`) und die UK/OK der +// Decken über den Kern (`verticalExtents`, Regeln `model/helpers.rs::heights`). import { describe, it, expect } from "vitest"; -import { ceilingVerticalExtent, wallReferenceOffset } from "./wall"; +import { wallReferenceOffset } from "./wall"; +import { verticalExtents } from "../geometry/grips"; import type { Ceiling, Project, Wall } from "./types"; /** Minimalprojekt mit einem Geschoss (baseElevation 0, floorHeight 2.6) und @@ -68,7 +69,10 @@ function makeCeiling(overrides?: Partial): Ceiling { }; } -describe("ceilingVerticalExtent", () => { +/** UK/OK einer Decke (Kern-Abfrage). */ +const ceilingVerticalExtent = (p: Project, c: Ceiling) => verticalExtents(p, [], [c]).ceilings[0]; + +describe("UK/OK einer Decke", () => { it("ohne top/bottom: OK = Geschoss-Oberkante, UK = OK − Dicke (heutiges Verhalten)", () => { const project = makeProject(); const ceiling = makeCeiling(); diff --git a/src/model/wall.ts b/src/model/wall.ts index 28b2298b..24a7273b 100644 --- a/src/model/wall.ts +++ b/src/model/wall.ts @@ -1,12 +1,9 @@ -// Wand-Resolver: leitet aus den (optionalen) Wand-Attributen die konkreten -// geometrischen Größen ab — Versatz der Achse über die Dicke (Referenzlinie) -// und die vertikale Ausdehnung (UK..OK). Alle Defaults entsprechen exakt dem -// bisherigen Verhalten, sodass bestehende Wände unverändert rendern. +// Wand-Resolver: Versatz der Achse über die Dicke (Referenzlinie). Die vertikale Ausdehnung (UK/OK) +// rechnet der Kern (`model/helpers.rs::heights`; TS: Abfrage `verticalExtents`, `geometry/grips.ts`). // // Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). -import type { Ceiling, Column, Project, VerticalAnchor, Wall } from "./types"; -import { ceilingThickness, getFloor } from "./types"; +import type { Wall } from "./types"; /** * Versatz der Schichtstapelung entlang der linken Normalen `+n` (leftNormal), @@ -38,89 +35,3 @@ export function wallReferenceOffset( if (ref === "right") return -half; return 0; } - -/** Löst einen VerticalAnchor zu einem absoluten Z (Meter) auf oder `null`. */ -function resolveAnchor( - project: Project, - anchor: VerticalAnchor | undefined, -): number | null { - if (!anchor) return null; - if (anchor.mode === "custom") return anchor.z; - // "floor": baseElevation des gebundenen Geschosses (+ optionalem Offset). - const floor = project.drawingLevels.find((z) => z.id === anchor.floorId); - if (!floor) return null; - return (floor.baseElevation ?? 0) + (anchor.offset ?? 0); -} - -/** - * Vertikale Ausdehnung der Wand (absolute Z-Werte in Metern). - * • zBottom: aus `wall.bottom`, sonst baseElevation des Wand-Geschosses - * (= heutiges Verhalten). - * • zTop: aus `wall.top`, sonst `zBottom + wall.height` (= heute). - * Sind beide UK/OK ungesetzt, liefert dies exakt `[baseElevation, base+height]`. - */ -export function wallVerticalExtent( - project: Project, - wall: Wall, -): { zBottom: number; zTop: number } { - // Geschoss-baseElevation als Default-UK (heutiges Verhalten). Fehlt das - // Geschoss, 0 als sicherer Rückfall. - let floorBase = 0; - try { - floorBase = getFloor(project, wall.floorId).baseElevation ?? 0; - } catch { - floorBase = 0; - } - const zBottom = resolveAnchor(project, wall.bottom) ?? floorBase; - const zTop = resolveAnchor(project, wall.top) ?? zBottom + wall.height; - return { zBottom, zTop }; -} - -/** - * Vertikale Ausdehnung einer Decke (absolute Z-Werte in Metern). - * • zTop: aus `ceiling.top`, sonst Oberkante des Geschosses - * (baseElevation + floorHeight) — also bündig mit dem Wandkopf. - * • zBottom: aus `ceiling.bottom`, sonst zTop − Deckendicke (die Decke - * wächst nach UNTEN — heutiges Verhalten). Die `thickness` bleibt bei - * gesetztem `bottom` rein informativ (dient nicht mehr der UK-Ableitung). - * Fehlt das Geschoss, dient 0 als sicherer Rückfall für die Oberkante. - */ -export function ceilingVerticalExtent( - project: Project, - ceiling: Ceiling, -): { zBottom: number; zTop: number } { - let floorTop = 0; - try { - const floor = getFloor(project, ceiling.floorId); - floorTop = (floor.baseElevation ?? 0) + (floor.floorHeight ?? 0); - } catch { - floorTop = 0; - } - const zTop = resolveAnchor(project, ceiling.top) ?? floorTop; - const zBottom = - resolveAnchor(project, ceiling.bottom) ?? - zTop - ceilingThickness(project, ceiling); - return { zBottom, zTop }; -} - -/** - * Vertikale Ausdehnung einer Stütze (absolute Z-Werte in Metern) — dieselbe - * Regel wie {@link wallVerticalExtent}: - * • zBottom: aus `column.bottom`, sonst baseElevation des Geschosses. - * • zTop: aus `column.top`, sonst `zBottom + column.height`. - * Fehlt das Geschoss, dient 0 als sicherer Rückfall für die Unterkante. - */ -export function columnVerticalExtent( - project: Project, - column: Column, -): { zBottom: number; zTop: number } { - let floorBase = 0; - try { - floorBase = getFloor(project, column.floorId).baseElevation ?? 0; - } catch { - floorBase = 0; - } - const zBottom = resolveAnchor(project, column.bottom) ?? floorBase; - const zTop = resolveAnchor(project, column.top) ?? zBottom + column.height; - return { zBottom, zTop }; -} diff --git a/src/plan/column.test.ts b/src/plan/column.test.ts index 769cd163..f0679981 100644 --- a/src/plan/column.test.ts +++ b/src/plan/column.test.ts @@ -5,13 +5,12 @@ * Querschnitt. * • 3D (projectToModel3d/emitColumns): eine Stütze wird zu einem Prisma-Mesh * (Rechteck-Box bzw. Kreis-Prisma) mit der erwarteten vertikalen Ausdehnung. - * • Vertikale Lage (columnVerticalExtent): Geschoss-Default sowie UK/OK-Anker. + * (Vertikale Lage: Rust-Tests `model/helpers.rs::heights`.) */ import { describe, it, expect } from "vitest"; import { generatePlan } from "./generatePlan"; import { projectToModel3d } from "./toWalls3d"; -import { columnVerticalExtent } from "../model/wall"; import { columnFootprint } from "../geometry/column"; import type { Column, Project } from "../model/types"; @@ -125,28 +124,6 @@ describe("Stütze — 3D (projectToModel3d / emitColumns)", () => { }); }); -describe("Stütze — vertikale Lage (columnVerticalExtent)", () => { - it("nutzt Geschoss-UK + Höhe als Default", () => { - const { zBottom, zTop } = columnVerticalExtent( - projectWithColumn(rectColumn), - rectColumn, - ); - expect(zBottom).toBeCloseTo(0, 6); - expect(zTop).toBeCloseTo(3, 6); - }); - - it("bindet UK/OK an Anker (custom + floor)", () => { - const anchored: Column = { - ...rectColumn, - bottom: { mode: "custom", z: 0.5 }, - top: { mode: "floor", floorId: "og" }, // baseElevation OG = 3 - }; - const { zBottom, zTop } = columnVerticalExtent(projectWithColumn(anchored), anchored); - expect(zBottom).toBeCloseTo(0.5, 6); - expect(zTop).toBeCloseTo(3, 6); - }); -}); - describe("Stütze — Footprint-Helfer (columnFootprint)", () => { it("tesselliert ein rundes Profil als 32-Eck um die Position", () => { const round: Column = { ...rectColumn, profile: { kind: "round", radius: 0.15 } }; diff --git a/src/plan/generatePlan/shared.ts b/src/plan/generatePlan/shared.ts index ff673da4..0e8cfa21 100644 --- a/src/plan/generatePlan/shared.ts +++ b/src/plan/generatePlan/shared.ts @@ -42,9 +42,6 @@ export type DetailLevel = "grob" | "mittel" | "fein"; /** Stroke-Farbe der Schicht-Polygone (neutrales Schwarz, geteilte Tinte mit der Schraffur). */ export const POCHE_STROKE = "#1a1a1a"; -/** Tinte für den Schwarz-Weiss-Modus: einheitliches Dunkel für alle Striche. */ -export const MONO_INK = "#111111"; - // ── Linienstärken in PAPIER-Millimeter (vgl. docs/design/plans-output.md §3.2) ── // Alle Stricharten sind in mm Papier definiert; die PlanView rechnet sie über // dpi = 96 in konstante Bildschirm-Pixel um (non-scaling-stroke), damit Linien @@ -58,7 +55,6 @@ export const LAYER_LINE_MM = 0.02; // seit [K3d] im Kern (`src-tauri/core/src/plan/style.rs`). /** Default-Umrandungs-Strichstärke (mm), falls die Kategorie keine lw trägt (Grundeinstellung für „normale Elemente"). */ -export const WALL_FALLBACK_MM = 0.18; /** * Aufgelöste Schraffur eines Polygons — alle Werte stammen aus einer diff --git a/src/plan/glPlan/glPlanHatch.ts b/src/plan/glPlan/glPlanHatch.ts index cc5f7f93..dd12cbf2 100644 --- a/src/plan/glPlan/glPlanHatch.ts +++ b/src/plan/glPlan/glPlanHatch.ts @@ -144,24 +144,6 @@ export function buildHatchRuns(poly: Vec2[], hatch: HatchRender): HatchRun[] { return toRuns(core().hatch_runs_flat(flat(poly), encodeHatch(hatch))); } -/** - * Streut kurze Striche deterministisch und MODELLRAUM-STABIL über ein Polygon (eine Zelle des - * absoluten Gitters je Strich, Lage/Winkel/Länge aus `hash(ix, iy, seed)`), aufs Polygon geclippt. - */ -export function scatterStrokes( - poly: Vec2[], - cell: number, - baseAngleRad: number, - seed: number, - strokeLen: number, - lenMin?: number, - lenMax?: number, -): HatchRun[] { - return toRuns( - core().scatter_strokes_flat(flat(poly), cell, baseAngleRad, seed, strokeLen, lenMin ?? NaN, lenMax ?? NaN), - ); -} - /** * Random-Vektor-Schraffur eines Polygons (Kies/Splitt): Dichte und Strichlänge an die Kachel * (8·scale px) gekoppelt, Seed nur aus Muster-Parametern + `hatch.seed`. diff --git a/src/plan/glPlan/glPlanTypes.ts b/src/plan/glPlan/glPlanTypes.ts index 59c82048..b84fe9e3 100644 --- a/src/plan/glPlan/glPlanTypes.ts +++ b/src/plan/glPlan/glPlanTypes.ts @@ -16,30 +16,6 @@ /** RGBA-Farbe, Komponenten in [0,1]. */ export type Rgba = [number, number, number, number]; -/** Shader-Programm mit kompiliertem Programm + Attribut-/Uniform-Orten. */ -export interface ShaderProgram { - program: WebGLProgram; - attribs: { - position?: GLint; - /** Bildschirm-Raum-Miter-Bisektor (Einheits-Versatzrichtung) für Linien. */ - normal?: GLint; - /** Seite der Linie: +1 oder -1. */ - side?: GLint; - /** Miter-Längenfaktor 1/cos(θ/2) (1 = gerade). */ - miter?: GLint; - }; - uniforms: { - viewProj?: WebGLUniformLocation | null; - color?: WebGLUniformLocation | null; - /** Basis-Strichbreite in Geräte-Pixeln (bei strokeScale=1). */ - strokePx?: WebGLUniformLocation | null; - /** Zoom-Skalierung der Strichbreite (>1 = reingezoomt → dicker, Papier). */ - strokeScale?: WebGLUniformLocation | null; - /** Zeichenpuffer-Größe in Geräte-Pixeln [w,h] (px→Clip-Umrechnung). */ - viewportPx?: WebGLUniformLocation | null; - }; -} - /** Ein Zeichen-Batch: zusammenhängender Index-Bereich mit einer Farbe. */ export interface FillBatch { startIndex: number; diff --git a/src/plan/planView/geometry.ts b/src/plan/planView/geometry.ts index 0a822882..50eb3166 100644 --- a/src/plan/planView/geometry.ts +++ b/src/plan/planView/geometry.ts @@ -207,21 +207,6 @@ export function pointInPolygon(pt: Vec2, poly: Vec2[]): boolean { return inside; } -/** Abstand Punkt→Strecke (alle in denselben Koordinaten, hier Client-Pixel). */ -export function pointSegDistPx( - p: { x: number; y: number }, - a: { x: number; y: number }, - b: { x: number; y: number }, -): number { - const dx = b.x - a.x; - const dy = b.y - a.y; - const len2 = dx * dx + dy * dy; - if (len2 < 1e-9) return Math.hypot(p.x - a.x, p.y - a.y); - let t = ((p.x - a.x) * dx + (p.y - a.y) * dy) / len2; - t = Math.max(0, Math.min(1, t)); - return Math.hypot(p.x - (a.x + dx * t), p.y - (a.y + dy * t)); -} - /** Achsenparalleles Rechteck in Modell-Metern (Auswahl-Marquee). */ export interface ModelRect { minX: number; diff --git a/src/plan/toWalls3d/shared.ts b/src/plan/toWalls3d/shared.ts index 6e6ac16b..349701cd 100644 --- a/src/plan/toWalls3d/shared.ts +++ b/src/plan/toWalls3d/shared.ts @@ -243,10 +243,6 @@ export interface RModel3d { /** Warmer, neutraler Wand-Grundton (wie render3d default). */ export const WALL_RGB: RRgb = [0.82, 0.8, 0.76]; -/** Etwas hellerer, kühlerer Ton für Deckenplatten (heben sich von Wänden ab). */ -export const SLAB_RGB: RRgb = [0.86, 0.86, 0.88]; -/** Fallback-Farbe für 2D-Zeichnungen ohne color/lineStyle/Kategorie (wie drawing2DColor in Viewport3D.tsx, "#888888"). */ -export const DRAWING_LINE_FALLBACK_RGB: RRgb = [0x88 / 255, 0x88 / 255, 0x88 / 255]; /** Ignoriere entartete vertikale Ausschnitte (Rundungsrauschen). */ export const EPS = 1e-4;