Merge [K3d][K4] Plan-Erzeugung auf dem Rust-Dokument: Override-Regeln und neun Domaenen (Decken, Daecher, Raeume, Waende+Oeffnungen, Treppen, Stuetzen, Koerper, Kontext, Schnittlinien), TS-Fassungen geloescht
Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
42 files changed
+1908
-2645
No files matched your search
@@ -114,12 +114,37 @@ truck (`trucksolid`) bleibt eigenes WASM-Modul (Panic-Isolation), wird vom Kern
|
||||
Rest in TS (28.10.): Stil-Auflösung (Bauteil, Schraffur, Farbe, Linienstil, Pick-IDs, Painter-Reihenfolge) in `generatePlan*.ts`,
|
||||
`toSection.ts` (Besitzer-Zuordnung, Schichtbänder), `toElevation.ts` (Orchestrierung), `sectionOpenings.ts`, `planUnderlay.ts`,
|
||||
`drawing2d.ts`. Das ist kein Rechenanteil mehr, sondern liest das Modell; es zieht mit [K4] um.
|
||||
- ○ **[K3d] Aufräumen:** TS-Primitive-Erzeugung löschen, SVG/PDF/DXF-Export lesen den Puffer. Hängt an [K4]: Rust braucht das
|
||||
- ◐ **[K3d] Aufräumen:** TS-Primitive-Erzeugung löschen, SVG/PDF/DXF-Export lesen den Puffer. Hängt an [K4]: Rust braucht das
|
||||
typisierte Modell (Bauteil-Typen, Schraffuren, Linienstile, Kategorien) und einen Plan-Puffer v2 mit Pick-IDs + vollem `Primitive`-Umfang
|
||||
(Text, Schraffur-Optionen, Zickzack/Motiv); die Verbraucher von `Primitive[]` (SVG/PDF/DXF, Auswahl, Overlay) lesen dann den Puffer.
|
||||
Stand 28.10.: Rust-Grundlage `core/src/plan/{prim,style}.rs` (Primitive-Typ mit TS-gleicher JSON-Form, Auflösung By-Layer/By-Object,
|
||||
`resolve_hatch`). Offen: Overrides-Engine, Raum-Stempel/richText, Domänen (Decken, Dächer, Räume, Wände+Öffnungen, Treppen, Stützen,
|
||||
Körper, Kontext, Schnittlinien), Orchestrator (drawings2d bleibt vorerst TS), Plan-Puffer v2 (GPU-Chunk-Cache braucht Inhalts-Hash statt Objekt-Identität).
|
||||
✅ (28.10.) Plan-Erzeugung auf dem Dokument, Abfrage `planDomains` (`plan/{domains,walls,stairs,overrides}.rs`): Override-Regeln
|
||||
(`overrides.rs`, wie `overrides/engine.ts` inkl. JS-`trim`), Decken (Brücken-Trick, Wand-Footprints, Umriss-Verdeckung), Dächer
|
||||
(Ansichts-Schraffur der Eindeckung), Räume mit Raumstempel-Daten (`roomStampToDoc`/`roomStampExtraLines`/`formatStampArea`/
|
||||
`docFromText` portiert; `js_fmt::js_number` = JS-`String(Zahl)`; Text-Layout bleibt TS), Wände mit Verschneidung, Poché-Stil,
|
||||
Fugen-Linienstil (Zickzack/Motiv), Referenzlinie und Öffnungs-Symbolen, Treppen, Stützen, Extrusions-Umrisse und das Ausmass
|
||||
dieser Domänen; mit `global` auch Kontext-Konturen (Höhenlinien, Mesh-Fussabdruck, Gelände-Rahmen, Pick-Bänder — die Meshes
|
||||
gehen nicht mehr über die WASM-Grenze) und Schnittführungs-Symbole. `generatePlan` ruft die Abfrage einmal je Geschoss und setzt die Primitive an ihre Stelle der Zeichenreihenfolge;
|
||||
Sichtbarkeit/Darstellungsmodus gehen als Code-Mengen mit (`show`/`grey`). Gelöscht: `generatePlan/{ceilings,roofs,rooms,structures,
|
||||
walls,openings,stairs,context,sections}.ts`, `model/joins.ts` (+ Test, fehlende Fälle in `joins.rs` nachgezogen), Bindungen `compute_joins_flat`,
|
||||
`join_priority_resolution`, `plan_wall_poche_flat`, `plan_opening_flat`, `plan_ceiling_outline_flat`, `plan_stair_flat`, `context_footprint_flat`, `context_bbox_flat`,
|
||||
`section_line_flat`, TS-Helfer
|
||||
`stairsOfFloor`/`stairLabel`/`columnsOfFloor`/`roomsOfFloor`. Gleichheit: Primitive-JSON (Schlüssel sortiert) bitgleich zur alten
|
||||
TS-Fassung über Beispielprojekt + 80 Zufallsprojekte (mit Kontext-Meshes/Höhenlinien, variierten Schnittlinien, Override-Regeln,
|
||||
Fenster-/Türtypen, Fugen-Linienstilen) × 2 Geschosse × 3 Detailgrade × 2 Sichtbarkeits-/Graustufen-/Mono-/
|
||||
Referenzlinien-Varianten (972 Pläne inkl. Fehlermeldungen kaputter Decken/Schraffuren), CLI-SVG Beispiel-EG/OG und grosses Projekt
|
||||
byte-gleich (temporärer Paritätstest, danach entfernt). Nicht in der Tauri-App angesehen.
|
||||
Messung (`generatePlan`, Node, Linux-Container unter Last, Min/Median über Wiederholungen, alter Stand mit gleich gebautem Kern):
|
||||
Beispiel-EG 0,3–0,35 → 0,65–0,7 ms (feste Kosten der Abfrage und der JSON-Übergabe); grosses Projekt (Beispielhaus 20×20: 3600
|
||||
Wände, 400 Decken/Räume/Treppen, 1600 Stützen) EG 320–340 → 355–370 ms, also ~10 % langsamer. Die Rechnung selbst ist schneller,
|
||||
aber die Antwort ist ~14 MB JSON (Wände 9,3 MB, Treppen 3,7 MB): Abfrage inkl. Serialisierung ~160–210 ms, `JSON.parse` ~145–225 ms.
|
||||
Die JSON-Form ist damit der Engpass → Plan-Puffer v2.
|
||||
Offen: `drawing2d.ts` (Verteiler), Schatten/Baurecht (dünner Stil-Glue um `analysis/`, Datum/Sonnenstand in TS), Abzugskörper
|
||||
(`voids.ts`), Mono, Strichstärken-Massstab und `generateVisibleLevelsPlan` bleiben TS; die Override-Engine in TS bedient nur noch 2D-Zeichnungen. Plan-Puffer v2 (Primitive binär mit Pick-IDs und vollem
|
||||
Umfang statt JSON, gemeinsame Tabellen für Schraffuren/Farben, damit nicht jedes Polygon seine `HatchRender` wiederholt) ist nicht
|
||||
begonnen; erst sinnvoll, wenn die Verbraucher (SVG/PDF/DXF, Auswahl, Overlay) den Puffer lesen statt `Primitive[]`.
|
||||
Nachteile (bewusst): Übergang mit doppelter Datenhaltung, Format muss TS/Rust gleich bleiben
|
||||
(Versionsnummer + Hin-und-zurück-Tests), Text-Layout bleibt bis [K4] in TS.
|
||||
- ◐ **[K4] Modell und Ops in Rust** [2]; TS bekommt die Typen generiert (z. B. `ts-rs`). · XL
|
||||
@@ -147,6 +172,8 @@ truck (`trucksolid`) bleibt eigenes WASM-Modul (Panic-Isolation), wird vom Kern
|
||||
Abfragen `objFile`/`stlFile` sind gelöscht. Die Exporte holen ihre 3D-Teile über `export/model3dParts.ts` aus dem
|
||||
Dokument (`queries.rs`). Offen: `fileio`-Schreiber direkt aus dem Dokument füttern statt über den TS-Sammler.
|
||||
Nächste: Export (Schedule/CSV, STL/OBJ, STEP), Plan/Schnitt/Ansicht-Sammler (generatePlan, toSection, toElevation) — hängt an Plan-Puffer v2.
|
||||
Grundriss (28.10.): Decken, Dächer, Räume, Wände+Öffnungen, Treppen, Stützen, Extrusionen, Kontext und Schnittlinien
|
||||
kommen über `planDomains` aus dem Dokument ([K3d]); übrig in `generatePlan`: 2D-Zeichnungen, Schatten/Baurecht, Abzugskörper.
|
||||
Ziel: Plan/Schnitt/Ansicht, 3D, Export rechnen mit `doc`-Handle statt flach gesammelter Arrays; TS-Sammler/-Adapter werden gelöscht
|
||||
([K3d] hängt hier dran: Plan-Puffer v2 mit Pick-IDs und vollem Primitive-Umfang).
|
||||
- ○ **S3 Änderungen kommen aus Rust**: Befehle (Zustandsautomaten, Werkzeuge) erzeugen Ops im Kern; Undo/Redo, Validierung
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Wand-Verschneidung (Gehrung, T-Stoss, Kreuzung): berechnet je Wand die optionalen
|
||||
//! Schnittlinien an Start- und Endpunkt, materialbewusste Pro-Schicht-Cuts am T-Stoss und die
|
||||
//! Nah-Putz-Aussparungen der Durchgangswand. Portiert aus `src/model/joins.ts` (dort bleiben die
|
||||
//! Typen und das Sammeln aus dem `Project`).
|
||||
//! Nah-Putz-Aussparungen der Durchgangswand. Portiert aus `src/model/joins.ts`; gesammelt wird im
|
||||
//! Kern (`model3d.rs` für 3D, `plan/walls.rs` für den Grundriss).
|
||||
//!
|
||||
//! Behandelt: L-Ecken (zwei Wandenden im Knoten), T-Knoten (drei Enden, zwei kollinear),
|
||||
//! Mittelspannen-T-Stösse (freies Ende trifft auf die Seite einer anderen Wand) und
|
||||
@@ -773,6 +773,38 @@ mod tests {
|
||||
assert!(close(s.to - s.from, 0.15), "{s:?}");
|
||||
}
|
||||
|
||||
// Aus `model/joins.test.ts` übernommen ([K3d]: der TS-Sammler ist weg).
|
||||
#[test]
|
||||
fn stern_knoten_bleibt_rechtwinklig() {
|
||||
let w = vec![mono((0.0, 5.0), (5.0, 5.0), 0.3), mono((5.0, 5.0), (10.0, 5.0), 0.3), mono((5.0, 5.0), (5.0, 0.0), 0.3), mono((5.0, 5.0), (5.0, 10.0), 0.3)];
|
||||
for c in compute_joins(&w).unwrap() {
|
||||
assert!(c.start_cut.is_none() && c.end_cut.is_none());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rangfolge_zweier_bauteile() {
|
||||
use JoinResolution::*;
|
||||
assert_eq!(resolve_join_priority(50.0, 50.0, true), Merge);
|
||||
assert_eq!(resolve_join_priority(20.0, 20.0, false), Coexist);
|
||||
assert_eq!(resolve_join_priority(10.0, 50.0, false), TrimA);
|
||||
assert_eq!(resolve_join_priority(50.0, 10.0, false), TrimB);
|
||||
assert_eq!(resolve_join_priority(100.0, 50.0, false), TrimB);
|
||||
assert_eq!(resolve_join_priority(50.0, 100.0, false), TrimA);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn l_ecke_ohne_aussparung_und_abzweig_ohne_materialgleichheit() {
|
||||
let c = compute_joins(&[mono((0.0, 0.0), (5.0, 0.0), 0.4), mono((5.0, 0.0), (5.0, 4.0), 0.4)]).unwrap();
|
||||
assert!(c.iter().all(|k| k.span_cutouts.is_empty()));
|
||||
// Durchgang Putz|Backstein|Putz, Abzweig nur Putz (kein Bauteil des Rückgrats): kein layerCuts.
|
||||
let lay = || vec![layer(0.015, 0, 10.0), layer(0.12, 1, 50.0), layer(0.015, 0, 10.0)];
|
||||
let w = vec![wall((0.0, 0.0), (5.0, 0.0), lay()), wall((5.0, 0.0), (10.0, 0.0), lay()), wall((5.0, 0.0), (5.0, 3.0), vec![layer(0.1, 0, 10.0)])];
|
||||
let c = compute_joins(&w).unwrap();
|
||||
assert!(c[2].layer_cuts.is_none());
|
||||
assert!(c[2].start_cut.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hypot_wie_js() {
|
||||
assert_eq!(js_hypot(3.0, 4.0), 5.0);
|
||||
|
||||
@@ -49,10 +49,63 @@ pub fn to_fixed(x: f64, d: usize) -> String {
|
||||
s
|
||||
}
|
||||
|
||||
/// `String(x)` für Zahlen (ECMAScript `Number::toString`): kürzeste Ziffernfolge, Exponent erst ab
|
||||
/// 1e21 bzw. unter 1e-6, `-0` → `"0"`.
|
||||
pub fn js_number(x: f64) -> String {
|
||||
if x.is_nan() {
|
||||
return "NaN".into();
|
||||
}
|
||||
if x == 0.0 {
|
||||
return "0".into();
|
||||
}
|
||||
if x.is_infinite() {
|
||||
return if x > 0.0 { "Infinity".into() } else { "-Infinity".into() };
|
||||
}
|
||||
let sign = if x < 0.0 { "-" } else { "" };
|
||||
// Rusts `{:e}` liefert die kürzeste Ziffernfolge, z. B. "1.2345e3".
|
||||
let e = format!("{:e}", x.abs());
|
||||
let (mant, exp) = e.split_once('e').expect("Exponent");
|
||||
let digits: String = mant.chars().filter(|c| *c != '.').collect();
|
||||
let k = digits.len() as i64;
|
||||
let n = exp.parse::<i64>().expect("Exponent") + 1;
|
||||
let body = if k <= n && n <= 21 {
|
||||
format!("{digits}{}", "0".repeat((n - k) as usize))
|
||||
} else if 0 < n && n <= 21 {
|
||||
format!("{}.{}", &digits[..n as usize], &digits[n as usize..])
|
||||
} else if -6 < n && n <= 0 {
|
||||
format!("0.{}{digits}", "0".repeat((-n) as usize))
|
||||
} else {
|
||||
let es = if n > 0 { format!("+{}", n - 1) } else { format!("{}", n - 1) };
|
||||
if k == 1 {
|
||||
format!("{digits}e{es}")
|
||||
} else {
|
||||
format!("{}.{}e{es}", &digits[..1], &digits[1..])
|
||||
}
|
||||
};
|
||||
format!("{sign}{body}")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn zahl_als_text_wie_js() {
|
||||
assert_eq!(js_number(3.0), "3");
|
||||
assert_eq!(js_number(-0.0), "0");
|
||||
assert_eq!(js_number(0.1 + 0.2), "0.30000000000000004");
|
||||
assert_eq!(js_number(1e21), "1e+21");
|
||||
assert_eq!(js_number(1.5e21), "1.5e+21");
|
||||
assert_eq!(js_number(1e20), "100000000000000000000");
|
||||
assert_eq!(js_number(1e-7), "1e-7");
|
||||
assert_eq!(js_number(1.25e-7), "1.25e-7");
|
||||
assert_eq!(js_number(0.000001), "0.000001");
|
||||
assert_eq!(js_number(-12.5), "-12.5");
|
||||
assert_eq!(js_number(123456.789), "123456.789");
|
||||
assert_eq!(js_number(f64::NAN), "NaN");
|
||||
assert_eq!(js_number(f64::NEG_INFINITY), "-Infinity");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rundet_halbwerte_auf_wie_js() {
|
||||
assert_eq!(to_fixed(0.0078125, 6), "0.007813"); // JS: "0.007813"; Rust {:.6}: 0.007812
|
||||
|
||||
@@ -373,7 +373,7 @@ fn kv(v: Vec2) -> KVec {
|
||||
KVec::new(v.x, v.y)
|
||||
}
|
||||
|
||||
fn wall_reference(w: &Wall) -> Reference {
|
||||
pub(crate) fn wall_reference(w: &Wall) -> Reference {
|
||||
match (w.reference_offset, w.reference_line) {
|
||||
(Some(v), _) => Reference::Offset(v),
|
||||
(None, Some(WallReferenceLine::Left)) => Reference::Left,
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
//! Projektglobale Referenzen im Grundriss auf dem Dokument ([K3d]): Kontext-Konturen (Höhenlinien,
|
||||
//! Fussabdruck importierter Gebäude, Rahmen von Gelände-Meshes, Pick-Bänder) und Schnittführungs-
|
||||
//! Symbole der Schnitt-/Ansichtsebenen — Rust-Gegenstück zu `generatePlan/{context,sections}.ts`.
|
||||
//! Die Geometrie liegt in `plan_misc.rs`; die Meshes werden direkt aus dem Dokument gelesen.
|
||||
|
||||
use super::domains::Ctx;
|
||||
use super::overrides::{js_space, js_trim};
|
||||
use super::prim::Primitive;
|
||||
use super::style::no_hatch;
|
||||
use crate::model::*;
|
||||
|
||||
const CONTEXT_LINE_COLOR: &str = "#9aa3ad";
|
||||
const CONTEXT_LINE_MM: f64 = 0.1;
|
||||
/// Kategorie der Schnittführungs-Symbole (Referenzen).
|
||||
const SECTION_LINE_CATEGORY: &str = "90";
|
||||
const SECTION_LINE_INK: &str = "#1f242c";
|
||||
const SECTION_LINE_MM: f64 = 0.18;
|
||||
const SECTION_LINE_MARK_MM: f64 = 0.5;
|
||||
const SECTION_LINE_DASH: [f64; 4] = [6.0, 1.5, 0.4, 1.5];
|
||||
const SECTION_LABEL_H: f64 = 0.5;
|
||||
|
||||
fn v2(x: f64, y: f64) -> Vec2 {
|
||||
Vec2 { x, y }
|
||||
}
|
||||
|
||||
fn context_line(a: Vec2, b: Vec2) -> Primitive {
|
||||
Primitive::Line { a, b, cls: "context-line".into(), weight_mm: CONTEXT_LINE_MM, dash: None, zigzag: None, motif: None, color: Some(CONTEXT_LINE_COLOR.into()), drawing_id: None, opening_id: None, stair_id: None, greyed: None, opacity: None }
|
||||
}
|
||||
|
||||
fn pick_band(pts: Vec<Vec2>, context_id: Option<&str>, section_id: Option<&str>) -> Primitive {
|
||||
Primitive::Polygon {
|
||||
pts,
|
||||
fill: "none".into(),
|
||||
stroke: "none".into(),
|
||||
stroke_width_mm: 0.0,
|
||||
hatch: no_hatch(),
|
||||
greyed: None,
|
||||
opacity: None,
|
||||
no_stroke_edges: None,
|
||||
wall_id: None,
|
||||
drawing_id: None,
|
||||
ceiling_id: None,
|
||||
opening_id: None,
|
||||
stair_id: None,
|
||||
room_id: None,
|
||||
extruded_solid_id: None,
|
||||
context_object_id: context_id.map(String::from),
|
||||
column_id: None,
|
||||
roof_id: None,
|
||||
section_line_id: section_id.map(String::from),
|
||||
}
|
||||
}
|
||||
|
||||
/// Rahmen-Ecken eines Meshes (x/y), `None` ohne Punkte.
|
||||
fn bbox_corners(positions: &[f64]) -> Option<Vec<Vec2>> {
|
||||
let b = crate::plan_misc::bbox(positions);
|
||||
(b.len() == 4).then(|| vec![v2(b[0], b[1]), v2(b[2], b[1]), v2(b[2], b[3]), v2(b[0], b[3])])
|
||||
}
|
||||
|
||||
/// Kontext-Schicht (`addContextContours`). Objekte ohne Kategorie bleiben immer sichtbar.
|
||||
pub fn plan_context(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
for obj in c.p.context.as_deref().unwrap_or(&[]) {
|
||||
let code = match obj {
|
||||
ContextObject::ImportedMesh(m) => m.category_code.as_deref(),
|
||||
ContextObject::ContourSet(s) => s.category_code.as_deref(),
|
||||
ContextObject::TerrainMesh(t) => t.category_code.as_deref(),
|
||||
ContextObject::Image(i) => i.category_code.as_deref(),
|
||||
};
|
||||
if code.is_some_and(|k| !c.shown(k)) {
|
||||
continue;
|
||||
}
|
||||
match obj {
|
||||
ContextObject::ContourSet(s) => {
|
||||
for k in &s.contours {
|
||||
let pts = &k.pts;
|
||||
if pts.len() < 2 {
|
||||
continue;
|
||||
}
|
||||
let seg_end = if k.closed { pts.len() } else { pts.len() - 1 };
|
||||
for i in 0..seg_end {
|
||||
out.push(context_line(pts[i], pts[(i + 1) % pts.len()]));
|
||||
}
|
||||
}
|
||||
}
|
||||
ContextObject::ImportedMesh(m) => {
|
||||
let f = crate::plan_misc::context_footprint(&m.positions, &m.indices);
|
||||
let n = f.first().copied().unwrap_or(0.0) as usize;
|
||||
for i in 0..n {
|
||||
out.push(context_line(v2(f[1 + 4 * i], f[2 + 4 * i]), v2(f[3 + 4 * i], f[4 + 4 * i])));
|
||||
}
|
||||
if let Some(pts) = bbox_corners(&m.positions) {
|
||||
out.push(pick_band(pts, Some(&m.id), None));
|
||||
}
|
||||
}
|
||||
ContextObject::TerrainMesh(t) => {
|
||||
if let Some(q) = bbox_corners(&t.positions) {
|
||||
for i in 0..4 {
|
||||
out.push(context_line(q[i], q[(i + 1) % 4]));
|
||||
}
|
||||
out.push(pick_band(q, Some(&t.id), None));
|
||||
}
|
||||
}
|
||||
ContextObject::Image(_) => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Kurz-Tag eines Schnitt-Labels: letztes Wort des Namens, sonst der ganze (getrimmte) Name.
|
||||
pub fn section_label_tag(name: &str) -> String {
|
||||
let t = js_trim(name);
|
||||
let parts: Vec<&str> = t.split(js_space).filter(|s| !s.is_empty()).collect();
|
||||
if parts.len() > 1 {
|
||||
parts[parts.len() - 1].to_string()
|
||||
} else {
|
||||
t.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Schnittführungs-Symbole aller Schnitt-/Ansichtsebenen mit Linie (`addSectionLines`).
|
||||
pub fn plan_section_lines(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
if !c.shown(SECTION_LINE_CATEGORY) {
|
||||
return;
|
||||
}
|
||||
let greyed = Some(c.greyed(SECTION_LINE_CATEGORY));
|
||||
for level in &c.p.drawing_levels {
|
||||
if !matches!(level.kind, DrawingLevelKind::Section | DrawingLevelKind::Elevation) {
|
||||
continue;
|
||||
}
|
||||
let Some([p0, p1]) = level.line_points else { continue };
|
||||
let f = crate::plan_misc::section_line(p0.x, p0.y, p1.x, p1.y, level.direction_sign.unwrap_or(1.0));
|
||||
if f.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let n = f[0] as usize;
|
||||
let mut i = 1;
|
||||
for _ in 0..n {
|
||||
if f[i] == 2.0 {
|
||||
let main = f[i + 1] == 0.0;
|
||||
out.push(Primitive::Line {
|
||||
a: v2(f[i + 2], f[i + 3]),
|
||||
b: v2(f[i + 4], f[i + 5]),
|
||||
cls: "section-line".into(),
|
||||
weight_mm: if main { SECTION_LINE_MM } else { SECTION_LINE_MARK_MM },
|
||||
dash: main.then(|| Some(SECTION_LINE_DASH.to_vec())),
|
||||
zigzag: None,
|
||||
motif: None,
|
||||
color: Some(SECTION_LINE_INK.into()),
|
||||
drawing_id: None,
|
||||
opening_id: None,
|
||||
stair_id: None,
|
||||
greyed,
|
||||
opacity: None,
|
||||
});
|
||||
i += 6;
|
||||
} else if f[i] == 5.0 {
|
||||
out.push(Primitive::DrawingText {
|
||||
at: v2(f[i + 1], f[i + 2]),
|
||||
text: section_label_tag(&level.name),
|
||||
height_m: SECTION_LABEL_H,
|
||||
angle: 0.0,
|
||||
color: SECTION_LINE_INK.into(),
|
||||
marks: None,
|
||||
wrap_width: None,
|
||||
doc: None,
|
||||
drawing_id: None,
|
||||
greyed,
|
||||
opacity: None,
|
||||
});
|
||||
i += 3;
|
||||
} else {
|
||||
let pts = (0..4).map(|j| v2(f[i + 1 + 2 * j], f[i + 2 + 2 * j])).collect();
|
||||
out.push(pick_band(pts, None, Some(&level.id)));
|
||||
i += 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn label_tag_wie_ts() {
|
||||
assert_eq!(section_label_tag("Schnitt A"), "A");
|
||||
assert_eq!(section_label_tag(" Ansicht Süd "), "Süd");
|
||||
assert_eq!(section_label_tag("Längsschnitt"), "Längsschnitt");
|
||||
assert_eq!(section_label_tag(" "), "");
|
||||
assert_eq!(section_label_tag("a\u{A0}b"), "b");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,608 @@
|
||||
//! Plan-Domänen auf dem Dokument ([K3d]): Decken, Dächer, Räume (mit Raumstempel-Daten), Wände mit
|
||||
//! Öffnungen (`walls.rs`), Treppen (`stairs.rs`), Kontext und Schnittlinien (`context.rs`), Stützen und Extrusions-Umrisse als fertige [`Primitive`] — Rust-Gegenstück zu `generatePlan/{ceilings,roofs,
|
||||
//! rooms,structures}.ts` samt Filter, Override-Regeln und Stil-Auflösung aus `generatePlan.ts`.
|
||||
//! Die JSON-Ausgabe gleicht Feld für Feld der früheren TS-Ausgabe.
|
||||
//!
|
||||
//! Sichtbarkeit/Darstellungsmodus kommen als Code-Mengen vom Aufrufer (`show`: sichtbar und
|
||||
//! gezeichnet, `grey`: gedimmt), weil der Resolver in TS (UI-Zustand) lebt.
|
||||
|
||||
use super::overrides::{self, js_trim, Actions, Subject};
|
||||
use super::prim::{HatchRender, Primitive, StampLine};
|
||||
use super::style::*;
|
||||
use crate::js_fmt::{js_number, to_fixed};
|
||||
use crate::jsnum::{max, min, round};
|
||||
use crate::model::*;
|
||||
use crate::plan_walls::{ceiling_outline_lines, wall_footprint, WallFootprint};
|
||||
use serde::Serialize;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
/// Footprint-Farbe der Extrusionen (wie das 3D-Orange).
|
||||
const EXTRUSION_STROKE: &str = "#d98c40";
|
||||
/// Rückfall-Füllung einer Stütze ohne auflösbares Bauteil.
|
||||
const COLUMN_FALLBACK_FILL: &str = "#3a3f47";
|
||||
/// Alpha-Suffix der (unsichtbaren) Raumfüllung.
|
||||
const ROOM_FILL_ALPHA: &str = "00";
|
||||
/// Basis-Schriftgrösse des Raumstempels (pt).
|
||||
const ROOM_STAMP_PT: f64 = 10.0;
|
||||
const NAME_PT: f64 = 12.0;
|
||||
const NUMBER_PT: f64 = 9.0;
|
||||
const LINE2_PT: f64 = 9.0;
|
||||
|
||||
/// Eingabe einer Plan-Abfrage.
|
||||
pub struct PlanArgs {
|
||||
pub floor: String,
|
||||
pub detail: Detail,
|
||||
pub show: HashSet<String>,
|
||||
pub grey: HashSet<String>,
|
||||
/// Wand-Achslinien zeichnen (Oberleiste).
|
||||
pub reference_lines: bool,
|
||||
/// Projektglobale Zutaten (Kontext, Schnittlinien) — nur der aktive Aufruf einer Überlagerung.
|
||||
pub global: bool,
|
||||
}
|
||||
|
||||
impl PlanArgs {
|
||||
/// `detail`: 0 grob, 1 mittel, 2 fein; `text`: `{"floor": id, "show": [code…], "grey": [code…],
|
||||
/// "referenceLines": bool, "global": bool}`.
|
||||
pub fn parse(detail: f64, text: &str) -> Result<PlanArgs, String> {
|
||||
let v: serde_json::Value = serde_json::from_str(text).map_err(|e| format!("Plan-Argumente: {e}"))?;
|
||||
let set = |k: &str| -> HashSet<String> { v.get(k).and_then(|a| a.as_array()).map(|a| a.iter().filter_map(|s| s.as_str().map(String::from)).collect()).unwrap_or_default() };
|
||||
Ok(PlanArgs {
|
||||
floor: v.get("floor").and_then(|f| f.as_str()).unwrap_or_default().to_string(),
|
||||
detail: match detail as i64 {
|
||||
0 => Detail::Grob,
|
||||
2 => Detail::Fein,
|
||||
_ => Detail::Mittel,
|
||||
},
|
||||
show: set("show"),
|
||||
grey: set("grey"),
|
||||
reference_lines: v.get("referenceLines").and_then(|b| b.as_bool()).unwrap_or(false),
|
||||
global: v.get("global").and_then(|b| b.as_bool()).unwrap_or(false),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Gemeinsamer Zustand einer Plan-Erzeugung.
|
||||
pub struct Ctx<'a> {
|
||||
pub p: &'a Project,
|
||||
pub a: &'a PlanArgs,
|
||||
/// Code → Kategorie (bei doppeltem Code gewinnt die letzte, wie `Map.set` in TS).
|
||||
cats: HashMap<&'a str, &'a LayerCategory>,
|
||||
}
|
||||
|
||||
impl<'a> Ctx<'a> {
|
||||
pub fn new(p: &'a Project, a: &'a PlanArgs) -> Self {
|
||||
let mut cats = HashMap::new();
|
||||
for c in p.flat_categories() {
|
||||
cats.insert(c.code.as_str(), c);
|
||||
}
|
||||
Ctx { p, a, cats }
|
||||
}
|
||||
|
||||
pub fn shown(&self, code: &str) -> bool {
|
||||
self.a.show.contains(code)
|
||||
}
|
||||
|
||||
pub fn greyed(&self, code: &str) -> bool {
|
||||
self.a.grey.contains(code)
|
||||
}
|
||||
|
||||
pub fn cat(&self, code: &str) -> Option<&'a LayerCategory> {
|
||||
self.cats.get(code).copied()
|
||||
}
|
||||
|
||||
/// Effektive Override-Aktionen eines Elements (`overrideFor` in TS).
|
||||
pub fn overrides(&self, code: &str, object_name: Option<&str>) -> Actions {
|
||||
overrides::effective(self.p.override_rules.as_deref(), &Subject { layer_name: self.cat(code).map(|c| c.name.as_str()), layer_code: Some(code), object_name })
|
||||
}
|
||||
}
|
||||
|
||||
/// Ergebnis der Abfrage `planDomains`: Primitive je Domäne (TS setzt sie an ihre Stelle in der
|
||||
/// Zeichenreihenfolge) und das Ausmass der Decken, Räume und Dach-Traufen.
|
||||
#[derive(Serialize, Default)]
|
||||
pub struct DomainPrims {
|
||||
pub ceilings: Vec<Primitive>,
|
||||
/// Wände (Poché, Referenzlinie) mit ihren Öffnungs-Symbolen, je Wand nacheinander.
|
||||
pub walls: Vec<Primitive>,
|
||||
/// Treppen-Symbole (`stairs.rs`).
|
||||
pub stairs: Vec<Primitive>,
|
||||
/// Kontext-Konturen und Schnittführungs-Symbole (`context.rs`), nur mit `global`.
|
||||
pub context: Vec<Primitive>,
|
||||
pub sections: Vec<Primitive>,
|
||||
pub roofs: Vec<Primitive>,
|
||||
pub rooms: Vec<Primitive>,
|
||||
pub columns: Vec<Primitive>,
|
||||
pub solids: Vec<Primitive>,
|
||||
/// `[minX, minY, maxX, maxY]`; fehlt ohne Punkte.
|
||||
pub bounds: Option<[f64; 4]>,
|
||||
}
|
||||
|
||||
pub struct Bounds([f64; 4]);
|
||||
|
||||
impl Bounds {
|
||||
fn new() -> Self {
|
||||
Bounds([f64::INFINITY, f64::INFINITY, f64::NEG_INFINITY, f64::NEG_INFINITY])
|
||||
}
|
||||
pub fn acc(&mut self, x: f64, y: f64) {
|
||||
let b = &mut self.0;
|
||||
b[0] = min(b[0], x);
|
||||
b[1] = min(b[1], y);
|
||||
b[2] = max(b[2], x);
|
||||
b[3] = max(b[3], y);
|
||||
}
|
||||
fn get(&self) -> Option<[f64; 4]> {
|
||||
self.0[0].is_finite().then_some(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Pick-Bezug eines Polygons.
|
||||
enum Pick<'a> {
|
||||
Ceiling(&'a str),
|
||||
Roof(&'a str),
|
||||
Room(&'a str),
|
||||
Column(&'a str),
|
||||
Solid(&'a str),
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn polygon(pts: Vec<Vec2>, fill: &str, stroke: &str, w: f64, hatch: HatchRender, greyed: Option<bool>, no_stroke_edges: Option<Vec<f64>>, pick: Pick) -> Primitive {
|
||||
let (mut ceiling_id, mut roof_id, mut room_id, mut column_id, mut extruded_solid_id) = (None, None, None, None, None);
|
||||
match pick {
|
||||
Pick::Ceiling(s) => ceiling_id = Some(s.to_string()),
|
||||
Pick::Roof(s) => roof_id = Some(s.to_string()),
|
||||
Pick::Room(s) => room_id = Some(s.to_string()),
|
||||
Pick::Column(s) => column_id = Some(s.to_string()),
|
||||
Pick::Solid(s) => extruded_solid_id = Some(s.to_string()),
|
||||
}
|
||||
Primitive::Polygon {
|
||||
pts,
|
||||
fill: fill.into(),
|
||||
stroke: stroke.into(),
|
||||
stroke_width_mm: w,
|
||||
hatch,
|
||||
greyed,
|
||||
opacity: None,
|
||||
no_stroke_edges,
|
||||
wall_id: None,
|
||||
drawing_id: None,
|
||||
ceiling_id,
|
||||
opening_id: None,
|
||||
stair_id: None,
|
||||
room_id,
|
||||
extruded_solid_id,
|
||||
context_object_id: None,
|
||||
column_id,
|
||||
roof_id,
|
||||
section_line_id: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn line(a: Vec2, b: Vec2, cls: &str, w: f64, dash: super::prim::Dash, color: &str, greyed: Option<bool>) -> Primitive {
|
||||
Primitive::Line { a, b, cls: cls.into(), weight_mm: w, dash, zigzag: None, motif: None, color: Some(color.into()), drawing_id: None, opening_id: None, stair_id: None, greyed, opacity: None }
|
||||
}
|
||||
|
||||
fn pv(p: [f64; 2]) -> Vec2 {
|
||||
Vec2 { x: p[0], y: p[1] }
|
||||
}
|
||||
|
||||
/// `getComponent` (wirft in TS).
|
||||
fn component<'a>(p: &'a Project, id: &str) -> Result<&'a Component, String> {
|
||||
p.component(id).ok_or_else(|| format!("Unbekanntes Bauteil-Material: {id}"))
|
||||
}
|
||||
|
||||
/// `resolveHatch` mit der Fehlermeldung von TS (`getHatch`/`getLineStyle` werfen).
|
||||
pub(super) fn resolve_hatch_or_err(p: &Project, hatch_id: &str, wall_angle_deg: Option<f64>, fg: Option<&str>) -> Result<HatchRender, String> {
|
||||
let h = p.hatch(hatch_id).ok_or_else(|| format!("Unbekannte Schraffur: {hatch_id}"))?;
|
||||
if let Some(ls) = h.line_style_id.as_deref().filter(|s| !s.is_empty()) {
|
||||
p.line_style(ls).ok_or_else(|| format!("Unbekannter Linienstil: {ls}"))?;
|
||||
}
|
||||
resolve_hatch(p, hatch_id, wall_angle_deg, fg, None).ok_or_else(|| format!("Unbekannte Schraffur: {hatch_id}"))
|
||||
}
|
||||
|
||||
/// Footprints der gezeichneten Wände dieses Geschosses (`buildWallFootprints`).
|
||||
pub fn wall_footprints(c: &Ctx) -> Vec<WallFootprint> {
|
||||
c.p.walls
|
||||
.iter()
|
||||
.filter(|w| w.floor_id == c.a.floor && c.shown(&w.category_code))
|
||||
.map(|w| {
|
||||
let t = c.p.wall_thickness(w, 0.2);
|
||||
let ref_off = crate::joins::reference_offset(crate::model3d::wall_reference(w), t);
|
||||
wall_footprint([w.start.x, w.start.y], [w.end.x, w.end.y], t, ref_off)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
// ── Decken ──────────────────────────────────────────────────────────────────
|
||||
|
||||
/// Schichten des Deckentyps (`getCeilingType`; wirft ohne Typ).
|
||||
fn ceiling_layers<'a>(p: &'a Project, c: &Ceiling) -> Result<&'a [Layer], String> {
|
||||
if let Some(id) = c.ceiling_type_id.as_deref().filter(|s| !s.is_empty()) {
|
||||
if let Some(ct) = p.ceiling_types.as_deref().unwrap_or(&[]).iter().find(|t| t.id == id) {
|
||||
return Ok(&ct.layers);
|
||||
}
|
||||
}
|
||||
p.wall_types.iter().find(|t| t.id == c.wall_type_id).map(|t| t.layers.as_slice()).ok_or_else(|| format!("Unbekannter Deckentyp: {}", c.ceiling_type_id.as_deref().unwrap_or(&c.wall_type_id)))
|
||||
}
|
||||
|
||||
/// Typname einer Decke für `object_name` (Maps in TS: letzter Eintrag je id gewinnt).
|
||||
fn ceiling_type_name<'a>(p: &'a Project, c: &Ceiling) -> Option<&'a str> {
|
||||
let ct = c.ceiling_type_id.as_deref().filter(|s| !s.is_empty()).and_then(|id| p.ceiling_types.as_deref().unwrap_or(&[]).iter().rev().find(|t| t.id == id));
|
||||
ct.map(|t| t.name.as_str()).or_else(|| p.wall_types.iter().rev().find(|t| t.id == c.wall_type_id).map(|t| t.name.as_str()))
|
||||
}
|
||||
|
||||
fn ceilings(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) -> Result<(), String> {
|
||||
let p = c.p;
|
||||
let list: Vec<&Ceiling> = p.ceilings.as_deref().unwrap_or(&[]).iter().filter(|x| x.floor_id == c.a.floor && c.shown(&x.category_code)).collect();
|
||||
if list.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
let fps = wall_footprints(c);
|
||||
for ce in list {
|
||||
for q in &ce.outline {
|
||||
bounds.acc(q.x, q.y);
|
||||
}
|
||||
let ov = c.overrides(&ce.category_code, ceiling_type_name(p, ce));
|
||||
let color = ov.color.as_deref().or(ce.color.as_deref());
|
||||
let greyed = c.greyed(&ce.category_code);
|
||||
let category = c.cat(&ce.category_code);
|
||||
let lw = resolve_stroke_weight(ce.stroke_weight, ce.stroke_weight_source, category, category.map_or(LAYER_LINE_MM, |k| k.lw));
|
||||
if ce.outline.len() < 3 {
|
||||
continue;
|
||||
}
|
||||
let pts: Vec<[f64; 2]> = ce.outline.iter().map(|v| [v.x, v.y]).collect();
|
||||
let holes: Vec<Vec<[f64; 2]>> = ce.openings.as_deref().unwrap_or(&[]).iter().map(|h| h.iter().map(|v| [v.x, v.y]).collect()).collect();
|
||||
let merged = crate::polygon_holes::merge_holes(&pts, &holes, 1e-4);
|
||||
let layers = ceiling_layers(p, ce)?;
|
||||
let comp = match layers.first() {
|
||||
Some(l) => Some(component(p, &l.component_id)?),
|
||||
None => None,
|
||||
};
|
||||
let stroke = color.unwrap_or(POCHE_STROKE);
|
||||
let view_hatch_id = resolve_hatch_id(ce.hatch_id.as_deref(), ce.hatch_source, category, comp.and_then(|k| k.view_hatch_id.as_deref()));
|
||||
let hatch = match (c.a.detail != Detail::Grob, comp, view_hatch_id.filter(|s| !s.is_empty())) {
|
||||
(true, Some(k), Some(id)) => resolve_hatch_or_err(p, id, None, resolve_foreground(k, ce.foreground.as_deref(), category, ce.foreground_source))?,
|
||||
_ => no_hatch(),
|
||||
};
|
||||
let fill = match comp {
|
||||
Some(k) => resolve_background(k, ce.background.as_deref(), category, ce.background_source).unwrap_or(poche_fill(hatch.pattern)).to_string(),
|
||||
None => "none".to_string(),
|
||||
};
|
||||
let ring: Vec<Vec2> = merged.ring.iter().map(|q| pv(*q)).collect();
|
||||
let bridges = (!merged.bridge_edges.is_empty()).then(|| merged.bridge_edges.iter().map(|&k| k as f64).collect());
|
||||
out.push(polygon(ring, &fill, "none", 0.0, hatch, Some(greyed), bridges, Pick::Ceiling(&ce.id)));
|
||||
let w = lw * c.a.detail.layer_factor();
|
||||
for [a, b] in ceiling_outline_lines(&merged.ring, &merged.bridge_edges, &fps) {
|
||||
out.push(line(pv(a), pv(b), "ceiling-outline", w, Some(Some(OVERHEAD_DASH.to_vec())), stroke, Some(greyed)));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ── Dächer ──────────────────────────────────────────────────────────────────
|
||||
|
||||
fn roofs(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) {
|
||||
let p = c.p;
|
||||
for roof in p.roofs.as_deref().unwrap_or(&[]).iter().filter(|r| r.floor_id == c.a.floor && c.shown(&r.category_code)) {
|
||||
let greyed = Some(c.greyed(&roof.category_code));
|
||||
let category = c.cat(&roof.category_code);
|
||||
let stroke = roof.color.as_deref().or(category.map(|k| k.color.as_str())).unwrap_or(POCHE_STROKE);
|
||||
let geo = crate::roof::roof_geometry(&roof.params(), 0.0);
|
||||
for q in &geo.eaves {
|
||||
bounds.acc(q[0], q[1]);
|
||||
}
|
||||
// Ansichts-Schraffur der äussersten Schicht (Eindeckung); Fehler → ohne.
|
||||
let layers = p.roof_layers(roof);
|
||||
let view_hatch = layers
|
||||
.first()
|
||||
.filter(|l| !l.component_id.is_empty())
|
||||
.and_then(|l| p.component(&l.component_id))
|
||||
.and_then(|k| k.view_hatch_id.as_deref().filter(|s| !s.is_empty()))
|
||||
.and_then(|id| resolve_hatch(p, id, None, None, None))
|
||||
.unwrap_or_else(no_hatch);
|
||||
let eaves: Vec<Vec2> = geo.eaves.iter().map(|q| pv(*q)).collect();
|
||||
if eaves.len() >= 3 {
|
||||
out.push(polygon(eaves.clone(), "none", "none", 0.0, view_hatch, greyed, None, Pick::Roof(&roof.id)));
|
||||
}
|
||||
let n = eaves.len();
|
||||
for i in 0..n {
|
||||
out.push(line(eaves[i], eaves[(i + 1) % n], "roof-eaves", ROOF_EAVES_MM, None, stroke, greyed));
|
||||
}
|
||||
for l in &geo.ridges {
|
||||
out.push(line(pv(l[0]), pv(l[1]), "roof-ridge", ROOF_RIDGE_MM, None, stroke, greyed));
|
||||
}
|
||||
for l in &geo.hips {
|
||||
out.push(line(pv(l[0]), pv(l[1]), "roof-hip", ROOF_HIP_MM, None, stroke, greyed));
|
||||
}
|
||||
for l in &geo.breaks {
|
||||
out.push(line(pv(l[0]), pv(l[1]), "roof-break", ROOF_BREAK_MM, Some(Some(ROOF_BREAK_DASH.to_vec())), stroke, greyed));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Räume ───────────────────────────────────────────────────────────────────
|
||||
|
||||
fn sia_key(s: SiaCategory) -> &'static str {
|
||||
match s {
|
||||
SiaCategory::HNF => "HNF",
|
||||
SiaCategory::NNF => "NNF",
|
||||
SiaCategory::VF => "VF",
|
||||
SiaCategory::FF => "FF",
|
||||
SiaCategory::KGF => "KGF",
|
||||
SiaCategory::AGF => "AGF",
|
||||
SiaCategory::Unknown => "undefined",
|
||||
}
|
||||
}
|
||||
|
||||
fn sia_label(s: SiaCategory) -> &'static str {
|
||||
match s {
|
||||
SiaCategory::HNF => "Hauptnutzfläche",
|
||||
SiaCategory::NNF => "Nebennutzfläche",
|
||||
SiaCategory::VF => "Verkehrsfläche",
|
||||
SiaCategory::FF => "Funktionsfläche",
|
||||
SiaCategory::KGF => "Konstruktionsfläche",
|
||||
SiaCategory::AGF => "Aussengeschossfläche",
|
||||
SiaCategory::Unknown => "undefined",
|
||||
}
|
||||
}
|
||||
|
||||
fn run(text: String, marks: Marks) -> TextRun {
|
||||
TextRun { text, marks, ..Default::default() }
|
||||
}
|
||||
|
||||
/// `docFromText`: je Zeile ein Absatz (leere Zeile = ohne Run).
|
||||
pub fn doc_from_text(text: &str) -> RichTextDoc {
|
||||
RichTextDoc {
|
||||
version: 1.0,
|
||||
paragraphs: text.split('\n').map(|l| Paragraph { runs: if l.is_empty() { vec![] } else { vec![run(l.into(), Marks::default())] }, ..Default::default() }).collect(),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// `roomStampToDoc`: Zeile 1 = Nummer (klein) + Name (fett), Zeile 2 optional (kursiv).
|
||||
pub fn room_stamp_to_doc(s: &RoomStamp) -> RichTextDoc {
|
||||
let mut line1 = Vec::new();
|
||||
let number = js_trim(s.number.as_deref().unwrap_or(""));
|
||||
if !number.is_empty() {
|
||||
line1.push(run(format!("{number} "), Marks { size_pt: Some(NUMBER_PT), ..Default::default() }));
|
||||
}
|
||||
line1.push(run(s.name.clone(), Marks { bold: Some(true), size_pt: Some(NAME_PT), ..Default::default() }));
|
||||
let mut paragraphs = vec![Paragraph { runs: line1, align: s.name_align, ..Default::default() }];
|
||||
let line2 = js_trim(s.name_line2.as_deref().unwrap_or(""));
|
||||
if !line2.is_empty() {
|
||||
paragraphs.push(Paragraph { runs: vec![run(line2.into(), Marks { italic: Some(true), size_pt: Some(LINE2_PT), ..Default::default() })], align: s.line2_align, ..Default::default() });
|
||||
}
|
||||
RichTextDoc { version: 1.0, paragraphs, ..Default::default() }
|
||||
}
|
||||
|
||||
/// `formatStampArea`.
|
||||
pub fn format_stamp_area(area: f64, step: Option<f64>) -> String {
|
||||
match step {
|
||||
Some(st) if st > 0.0 => {
|
||||
let rounded = round(area / st) * st;
|
||||
js_number(round(rounded * 100.0) / 100.0)
|
||||
}
|
||||
_ => to_fixed(area, 2),
|
||||
}
|
||||
}
|
||||
|
||||
/// `roomStampExtraLines`.
|
||||
pub fn room_stamp_extra_lines(s: &RoomStamp, net_area: f64, sia: SiaCategory) -> Vec<StampLine> {
|
||||
let mut lines = Vec::new();
|
||||
if s.show_floor_area {
|
||||
let prefix = s.floor_area_prefix.as_deref().unwrap_or("");
|
||||
lines.push(StampLine { text: format!("{prefix}{} m²", format_stamp_area(net_area, s.rounding_step)), align: s.floor_area_align.unwrap_or(Align::Center) });
|
||||
}
|
||||
if s.show_usage {
|
||||
lines.push(StampLine { text: format!("{} · {}", sia_key(sia), sia_label(sia)), align: s.usage_align.unwrap_or(Align::Center) });
|
||||
}
|
||||
if let Some(o) = s.occupancy {
|
||||
lines.push(StampLine { text: format!("{} Pers.", js_number(o)), align: Align::Center });
|
||||
}
|
||||
lines
|
||||
}
|
||||
|
||||
/// Farbe mit Alpha-Suffix, nur bei 6-stelligem Hex (`/^#[0-9a-fA-F]{6}$/`).
|
||||
fn with_alpha(color: &str, alpha: &str) -> String {
|
||||
let b = color.as_bytes();
|
||||
if b.len() == 7 && b[0] == b'#' && b[1..].iter().all(|c| c.is_ascii_hexdigit()) {
|
||||
format!("{color}{alpha}")
|
||||
} else {
|
||||
color.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
fn rooms(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) {
|
||||
for room in c.p.rooms.as_deref().unwrap_or(&[]).iter().filter(|r| r.floor_id == c.a.floor && c.shown(&r.category_code)) {
|
||||
for q in &room.boundary {
|
||||
bounds.acc(q.x, q.y);
|
||||
}
|
||||
let ov = c.overrides(&room.category_code, Some(&room.name));
|
||||
let color = ov.color.as_deref().unwrap_or(&room.color);
|
||||
let greyed = Some(c.greyed(&room.category_code));
|
||||
if room.boundary.len() < 3 {
|
||||
continue;
|
||||
}
|
||||
let pts: Vec<[f64; 2]> = room.boundary.iter().map(|v| [v.x, v.y]).collect();
|
||||
let res = crate::room_area::evaluate(&pts, 0.0);
|
||||
out.push(polygon(room.boundary.clone(), &with_alpha(color, ROOM_FILL_ALPHA), color, LAYER_LINE_MM * c.a.detail.layer_factor(), no_hatch(), greyed, None, Pick::Room(&room.id)));
|
||||
if c.a.detail == Detail::Grob {
|
||||
continue;
|
||||
}
|
||||
let at = room.stamp_anchor.unwrap_or(pv(res.centroid));
|
||||
let (doc, extra_lines) = match &room.stamp {
|
||||
Some(s) => (room_stamp_to_doc(s), room_stamp_extra_lines(s, res.net, room.sia_category)),
|
||||
None => (
|
||||
room.stamp_doc.clone().unwrap_or_else(|| doc_from_text(&room.name)),
|
||||
vec![
|
||||
StampLine { text: format!("{} m²", to_fixed(res.net, 2)), align: Align::Center },
|
||||
StampLine { text: format!("{} · {}", sia_key(room.sia_category), sia_label(room.sia_category)), align: Align::Center },
|
||||
],
|
||||
),
|
||||
};
|
||||
out.push(Primitive::Text { at, doc, extra_lines, base_pt: ROOM_STAMP_PT, color: color.into(), room_id: Some(room.id.clone()), greyed, opacity: None });
|
||||
}
|
||||
}
|
||||
|
||||
// ── Stützen ─────────────────────────────────────────────────────────────────
|
||||
|
||||
/// `columnLabel` (für `object_name`).
|
||||
pub fn column_label(col: &Column) -> String {
|
||||
match &col.profile {
|
||||
ColumnProfile::Round { radius } => format!("Stütze Ø{}", to_fixed(radius * 200.0, 0)),
|
||||
ColumnProfile::Rect { width, depth } => format!("Stütze {}×{}", to_fixed(width * 100.0, 0), to_fixed(depth * 100.0, 0)),
|
||||
}
|
||||
}
|
||||
|
||||
fn columns(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
let p = c.p;
|
||||
for col in p.columns.as_deref().unwrap_or(&[]).iter().filter(|k| k.floor_id == c.a.floor && c.shown(&k.category_code)) {
|
||||
let greyed = Some(c.greyed(&col.category_code));
|
||||
let category = c.cat(&col.category_code);
|
||||
let ov = c.overrides(&col.category_code, Some(&column_label(col)));
|
||||
let lw = ov.lineweight.unwrap_or_else(|| resolve_stroke_weight(col.stroke_weight, col.stroke_weight_source, category, category.map_or(WALL_FALLBACK_MM, |k| k.lw)));
|
||||
let color = ov.color.as_deref().or(col.color.as_deref());
|
||||
let cat_color = category.map(|k| k.color.as_str());
|
||||
let stroke = color.or(cat_color).unwrap_or(MONO_INK);
|
||||
let mut fill = color.or(cat_color).unwrap_or(COLUMN_FALLBACK_FILL).to_string();
|
||||
let mut hatch = no_hatch();
|
||||
if let Some(k) = col.component_id.as_deref().filter(|s| !s.is_empty()).and_then(|id| p.component(id)) {
|
||||
let hatch_id = resolve_hatch_id(col.hatch_id.as_deref(), col.hatch_source, category, Some(&k.hatch_id)).unwrap_or(&k.hatch_id);
|
||||
if let Some(h) = resolve_hatch(p, hatch_id, None, resolve_foreground(k, col.foreground.as_deref(), category, col.foreground_source), None) {
|
||||
let bg = resolve_background(k, col.background.as_deref(), category, col.background_source);
|
||||
fill = bg.unwrap_or(if h.pattern == HatchPattern::Solid { HATCH_INK } else { HATCH_PAPER }).to_string();
|
||||
hatch = h;
|
||||
}
|
||||
}
|
||||
out.push(polygon(crate::model3d::column_footprint(col), &fill, stroke, lw, hatch, greyed, None, Pick::Column(&col.id)));
|
||||
}
|
||||
}
|
||||
|
||||
// ── Extrusionen ─────────────────────────────────────────────────────────────
|
||||
|
||||
fn solids(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
for s in c.p.extruded_solids.as_deref().unwrap_or(&[]).iter().filter(|s| s.level_id == c.a.floor) {
|
||||
if s.operation.as_deref() == Some("subtract") {
|
||||
out.push(polygon(s.points.clone(), "none", "none", 0.0, no_hatch(), None, None, Pick::Solid(&s.id)));
|
||||
let n = s.points.len();
|
||||
let seg = |a: Vec2, b: Vec2, dash: Option<Vec<f64>>| line(a, b, "void", SYMBOL_HAIRLINE_MM, Some(dash), EXTRUSION_STROKE, None);
|
||||
for i in 0..n {
|
||||
out.push(seg(s.points[i], s.points[(i + 1) % n], Some(vec![2.0, 1.0])));
|
||||
}
|
||||
if n == 4 {
|
||||
out.push(seg(s.points[0], s.points[2], None));
|
||||
out.push(seg(s.points[1], s.points[3], None));
|
||||
}
|
||||
} else {
|
||||
out.push(polygon(s.points.clone(), "none", EXTRUSION_STROKE, SYMBOL_HAIRLINE_MM, no_hatch(), None, None, Pick::Solid(&s.id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Abfrage `planDomains`.
|
||||
pub fn plan_domains(p: &Project, a: &PlanArgs) -> Result<DomainPrims, String> {
|
||||
let c = Ctx::new(p, a);
|
||||
let mut out = DomainPrims::default();
|
||||
let mut bounds = Bounds::new();
|
||||
ceilings(&c, &mut out.ceilings, &mut bounds)?;
|
||||
roofs(&c, &mut out.roofs, &mut bounds);
|
||||
rooms(&c, &mut out.rooms, &mut bounds);
|
||||
super::walls::plan_walls(&c, a.reference_lines, &mut out.walls, &mut bounds)?;
|
||||
super::stairs::plan_stairs(&c, &mut out.stairs, &mut bounds);
|
||||
columns(&c, &mut out.columns);
|
||||
solids(&c, &mut out.solids);
|
||||
if a.global {
|
||||
super::context::plan_context(&c, &mut out.context);
|
||||
super::context::plan_section_lines(&c, &mut out.sections);
|
||||
}
|
||||
out.bounds = bounds.get();
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn sample() -> Project {
|
||||
serde_json::from_str(include_str!("../../tests/fixtures/sample_project.json")).unwrap()
|
||||
}
|
||||
|
||||
fn args(floor: &str, detail: f64, codes: &[&str]) -> PlanArgs {
|
||||
let t = serde_json::json!({ "floor": floor, "show": codes, "grey": [] }).to_string();
|
||||
PlanArgs::parse(detail, &t).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn beispiel_eg_decke_raum() {
|
||||
let p = sample();
|
||||
let r = plan_domains(&p, &args("eg", 1.0, &["20", "30", "60"])).unwrap();
|
||||
let s = serde_json::to_string(&r.ceilings).unwrap();
|
||||
assert!(s.contains("\"ceilingId\":\"C1\"") && s.contains("\"kind\":\"polygon\""), "{s}");
|
||||
// Decke deckungsgleich unter den Wänden: kein freier Umriss.
|
||||
assert!(!s.contains("ceiling-outline"));
|
||||
let rooms = serde_json::to_value(&r.rooms).unwrap();
|
||||
assert_eq!(rooms[1]["kind"], "text");
|
||||
assert_eq!(rooms[1]["extraLines"][0]["text"], "17.01 m²");
|
||||
assert_eq!(rooms[1]["extraLines"][1]["text"], "HNF · Hauptnutzfläche");
|
||||
assert!(r.bounds.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsichtbare_codes_fehlen() {
|
||||
let p = sample();
|
||||
let r = plan_domains(&p, &args("eg", 1.0, &[])).unwrap();
|
||||
assert!(r.ceilings.is_empty() && r.rooms.is_empty() && r.bounds.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stempel_flaeche_und_personen() {
|
||||
assert_eq!(format_stamp_area(17.0125, None), "17.01");
|
||||
assert_eq!(format_stamp_area(17.26, Some(0.5)), "17.5");
|
||||
assert_eq!(format_stamp_area(17.26, Some(0.1)), "17.3");
|
||||
let s = RoomStamp { name: "Bad".into(), show_floor_area: false, show_usage: false, occupancy: Some(1e21), ..Default::default() };
|
||||
assert_eq!(room_stamp_extra_lines(&s, 1.0, SiaCategory::VF)[0].text, "1e+21 Pers.");
|
||||
let d = room_stamp_to_doc(&RoomStamp { number: Some(" 2 ".into()), name: "Bad".into(), name_line2: Some(" ".into()), ..Default::default() });
|
||||
assert_eq!(d.paragraphs.len(), 1);
|
||||
assert_eq!(d.paragraphs[0].runs[0].text, "2 ");
|
||||
}
|
||||
|
||||
fn stamp(name: &str) -> RoomStamp {
|
||||
RoomStamp { name: name.into(), show_floor_area: true, show_usage: true, ..Default::default() }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stempel_dokument() {
|
||||
assert_eq!(room_stamp_to_doc(&stamp("Bad")).paragraphs.len(), 1);
|
||||
assert_eq!(room_stamp_to_doc(&RoomStamp { name_line2: Some("WC".into()), ..stamp("Bad") }).paragraphs.len(), 2);
|
||||
let d = room_stamp_to_doc(&RoomStamp { number: Some("1.01".into()), ..stamp("Bad") });
|
||||
assert_eq!(d.paragraphs[0].runs.len(), 2);
|
||||
assert_eq!(d.paragraphs[0].runs[0].text, "1.01 ");
|
||||
assert_eq!(d.paragraphs[0].runs[1].text, "Bad");
|
||||
assert_eq!(d.paragraphs[0].runs[1].marks.bold, Some(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stempel_zeilen() {
|
||||
let l = room_stamp_extra_lines(&RoomStamp { floor_area_prefix: Some("BF ".into()), ..stamp("Bad") }, 12.345, SiaCategory::HNF);
|
||||
assert_eq!(l[0].text, "BF 12.35 m²");
|
||||
assert_eq!(l[1].text, "HNF · Hauptnutzfläche");
|
||||
let off = RoomStamp { show_floor_area: false, show_usage: false, ..stamp("Bad") };
|
||||
assert!(room_stamp_extra_lines(&off, 12.345, SiaCategory::HNF).is_empty());
|
||||
let r = room_stamp_extra_lines(&RoomStamp { show_usage: false, rounding_step: Some(0.5), ..stamp("Bad") }, 12.34, SiaCategory::HNF);
|
||||
assert_eq!(r[0].text, "12.5 m²");
|
||||
let o = room_stamp_extra_lines(&RoomStamp { occupancy: Some(4.0), ..off.clone() }, 12.345, SiaCategory::HNF);
|
||||
assert_eq!(o.len(), 1);
|
||||
assert_eq!(o[0].text, "4 Pers.");
|
||||
assert_eq!(o[0].align, Align::Center);
|
||||
assert_eq!(format_stamp_area(12.345, None), "12.35");
|
||||
assert_eq!(format_stamp_area(12.0, None), "12.00");
|
||||
assert_eq!(format_stamp_area(12.24, Some(0.5)), "12");
|
||||
assert_eq!(format_stamp_area(12.26, Some(0.5)), "12.5");
|
||||
assert_eq!(format_stamp_area(12.3, Some(0.1)), "12.3");
|
||||
assert_eq!(format_stamp_area(12.34, Some(1.0)), "12");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stuetzen_label() {
|
||||
let col = Column { profile: ColumnProfile::Round { radius: 0.125 }, ..Default::default() };
|
||||
assert_eq!(column_label(&col), "Stütze Ø25");
|
||||
}
|
||||
}
|
||||
@@ -3,3 +3,8 @@
|
||||
|
||||
pub mod prim;
|
||||
pub mod style;
|
||||
pub mod overrides;
|
||||
pub mod domains;
|
||||
pub mod walls;
|
||||
pub mod stairs;
|
||||
pub mod context;
|
||||
@@ -0,0 +1,150 @@
|
||||
//! Grafische Overrides ([K3d]): wertet `Project.overrideRules` für ein Element aus — Rust-Gegenstück
|
||||
//! zu `src/overrides/engine.ts`. Pro Aktions-Feld gewinnt die OBERSTE aktive Regel, deren Bedingung
|
||||
//! passt; spätere Regeln füllen nur noch offene Felder. Vergleiche ohne Gross-/Kleinschreibung, Werte
|
||||
//! getrimmt (wie JS `trim()`/`toLowerCase()`).
|
||||
|
||||
use crate::model::*;
|
||||
|
||||
/// Die vergleichbaren Eigenschaften eines Elements.
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
pub struct Subject<'a> {
|
||||
/// Name der Ebene (`LayerCategory.name`).
|
||||
pub layer_name: Option<&'a str>,
|
||||
/// Code der Ebene (`categoryCode`).
|
||||
pub layer_code: Option<&'a str>,
|
||||
/// Element-/Typ-Name (Wandtyp, Raum, Öffnungs-Label …).
|
||||
pub object_name: Option<&'a str>,
|
||||
}
|
||||
|
||||
/// Effektive Aktionen (alle `None` = kein Override).
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct Actions {
|
||||
pub color: Option<String>,
|
||||
pub lineweight: Option<f64>,
|
||||
pub linetype_id: Option<String>,
|
||||
}
|
||||
|
||||
impl Actions {
|
||||
pub fn any(&self) -> bool {
|
||||
self.color.is_some() || self.lineweight.is_some() || self.linetype_id.is_some()
|
||||
}
|
||||
}
|
||||
|
||||
/// Leerraum im Sinne von JS `String.prototype.trim` (WhiteSpace + LineTerminator).
|
||||
pub fn js_space(c: char) -> bool {
|
||||
matches!(c, '\u{9}' | '\u{A}' | '\u{B}' | '\u{C}' | '\u{D}' | ' ' | '\u{A0}' | '\u{1680}' | '\u{2000}'..='\u{200A}' | '\u{2028}' | '\u{2029}' | '\u{202F}' | '\u{205F}' | '\u{3000}' | '\u{FEFF}')
|
||||
}
|
||||
|
||||
/// JS `s.trim()`.
|
||||
pub fn js_trim(s: &str) -> &str {
|
||||
s.trim_matches(js_space)
|
||||
}
|
||||
|
||||
fn norm(s: &str) -> String {
|
||||
js_trim(s).to_lowercase()
|
||||
}
|
||||
|
||||
/// `matchesCondition`: `layer_name` vergleicht Name UND Code (positive Operatoren: einer passt;
|
||||
/// `not_equals`: keiner gleich), `object_name` den Element-Namen. Fehlt die Eigenschaft, trifft nur
|
||||
/// `not_equals`.
|
||||
pub fn matches_condition(c: &OverrideCondition, s: &Subject) -> bool {
|
||||
let value = norm(&c.value);
|
||||
let mut cands: Vec<String> = Vec::with_capacity(2);
|
||||
if c.r#type == OverrideConditionType::LayerName {
|
||||
cands.extend(s.layer_name.map(norm));
|
||||
cands.extend(s.layer_code.map(norm));
|
||||
} else {
|
||||
cands.extend(s.object_name.map(norm));
|
||||
}
|
||||
if cands.is_empty() {
|
||||
return c.operator == OverrideOperator::NotEquals;
|
||||
}
|
||||
match c.operator {
|
||||
OverrideOperator::NotEquals => cands.iter().all(|x| *x != value),
|
||||
OverrideOperator::Equals => cands.contains(&value),
|
||||
OverrideOperator::Contains => cands.iter().any(|x| x.contains(value.as_str())),
|
||||
OverrideOperator::StartsWith => cands.iter().any(|x| x.starts_with(value.as_str())),
|
||||
OverrideOperator::Unknown => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// `effectiveOverrides`: kollabiert die Regelliste für ein Subjekt.
|
||||
pub fn effective(rules: Option<&[OverrideRule]>, s: &Subject) -> Actions {
|
||||
let mut out = Actions::default();
|
||||
let Some(rules) = rules else { return out };
|
||||
for rule in rules {
|
||||
if !rule.enabled || !matches_condition(&rule.condition, s) {
|
||||
continue;
|
||||
}
|
||||
let a = &rule.actions;
|
||||
if out.color.is_none() {
|
||||
out.color = a.color.clone();
|
||||
}
|
||||
if out.lineweight.is_none() {
|
||||
out.lineweight = a.lineweight;
|
||||
}
|
||||
if out.linetype_id.is_none() {
|
||||
out.linetype_id = a.linetype_id.clone();
|
||||
}
|
||||
if out.color.is_some() && out.lineweight.is_some() && out.linetype_id.is_some() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const WALL: Subject = Subject { layer_name: Some("Wände"), layer_code: Some("20"), object_name: Some("AW 24") };
|
||||
|
||||
fn cond(t: OverrideConditionType, op: OverrideOperator, v: &str) -> OverrideCondition {
|
||||
OverrideCondition { r#type: t, operator: op, value: v.into(), ..Default::default() }
|
||||
}
|
||||
|
||||
fn rule(enabled: bool, c: OverrideCondition, color: Option<&str>, lw: Option<f64>, lt: Option<&str>) -> OverrideRule {
|
||||
OverrideRule {
|
||||
enabled,
|
||||
condition: c,
|
||||
actions: OverrideActions { color: color.map(Into::into), lineweight: lw, linetype_id: lt.map(Into::into), ..Default::default() },
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
use OverrideConditionType::*;
|
||||
use OverrideOperator::*;
|
||||
|
||||
#[test]
|
||||
fn operatoren_wie_ts() {
|
||||
assert!(matches_condition(&cond(LayerName, Equals, " wände "), &WALL));
|
||||
assert!(!matches_condition(&cond(LayerName, Equals, "Decken"), &WALL));
|
||||
assert!(matches_condition(&cond(LayerName, Equals, "20"), &WALL));
|
||||
assert!(matches_condition(&cond(ObjectName, Contains, "24"), &WALL));
|
||||
assert!(matches_condition(&cond(ObjectName, StartsWith, "aw"), &WALL));
|
||||
assert!(!matches_condition(&cond(ObjectName, StartsWith, "24"), &WALL));
|
||||
assert!(!matches_condition(&cond(LayerName, NotEquals, "20"), &WALL));
|
||||
assert!(!matches_condition(&cond(LayerName, NotEquals, "Wände"), &WALL));
|
||||
assert!(matches_condition(&cond(LayerName, NotEquals, "Decken"), &WALL));
|
||||
let no_obj = Subject { object_name: None, ..WALL };
|
||||
assert!(!matches_condition(&cond(ObjectName, Contains, "x"), &no_obj));
|
||||
assert!(matches_condition(&cond(ObjectName, NotEquals, "x"), &no_obj));
|
||||
// JS-trim kennt U+FEFF, aber nicht U+0085.
|
||||
assert!(matches_condition(&cond(LayerName, Equals, "\u{FEFF}20\u{FEFF}"), &WALL));
|
||||
assert!(!matches_condition(&cond(LayerName, Equals, "\u{85}20"), &WALL));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn oberste_regel_gewinnt_je_feld() {
|
||||
let rules = vec![
|
||||
rule(false, cond(LayerName, Equals, "20"), Some("#000"), None, None),
|
||||
rule(true, cond(LayerName, Equals, "20"), Some("#f00"), None, None),
|
||||
rule(true, cond(ObjectName, Contains, "aw"), Some("#0f0"), Some(0.7), None),
|
||||
rule(true, cond(LayerName, Equals, "Wände"), None, Some(0.1), Some("dashed")),
|
||||
];
|
||||
let a = effective(Some(&rules), &WALL);
|
||||
assert_eq!(a, Actions { color: Some("#f00".into()), lineweight: Some(0.7), linetype_id: Some("dashed".into()) });
|
||||
assert!(!effective(None, &WALL).any());
|
||||
assert!(!effective(Some(&[]), &WALL).any());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
//! Treppen im Grundriss auf dem Dokument ([K3d]): Filter, Override-Regeln, Stil und Pick-ID um
|
||||
//! das Treppen-Symbol aus `plan_stairs.rs` — Rust-Gegenstück zu `generatePlan/stairs.ts` und der
|
||||
//! Treppen-Schleife in `generatePlan.ts`.
|
||||
|
||||
use super::domains::{Bounds, Ctx};
|
||||
use super::prim::Primitive;
|
||||
use super::style::*;
|
||||
use crate::js_fmt::js_number;
|
||||
use crate::model::*;
|
||||
|
||||
/// Linienklassen der Kern-Kodierung (`plan_stairs.rs`).
|
||||
const LINE_CLS: [&str; 5] = ["stair-outline", "stair-tread", "stair-break", "stair-run", "stair-arrow"];
|
||||
/// Strichmuster der verdeckten Tritte.
|
||||
const TREAD_DASH: [f64; 2] = [0.12, 0.08];
|
||||
|
||||
/// `stairLabel` (für `object_name`).
|
||||
pub fn stair_label(s: &Stair) -> String {
|
||||
let shape = match s.shape {
|
||||
StairShape::Straight => "Gerade",
|
||||
StairShape::L => "L-Treppe",
|
||||
_ => "Wendel",
|
||||
};
|
||||
format!("{shape} {} STG", js_number(s.step_count))
|
||||
}
|
||||
|
||||
fn v2(x: f64, y: f64) -> Vec2 {
|
||||
Vec2 { x, y }
|
||||
}
|
||||
|
||||
/// Treppen des Geschosses in Zeichenreihenfolge; Tritte und Podest ins Ausmass.
|
||||
pub fn plan_stairs(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) {
|
||||
let p = c.p;
|
||||
let cut_height = p.floor(&c.a.floor).and_then(|f| f.cut_height).unwrap_or(1.0);
|
||||
for s in p.stairs.as_deref().unwrap_or(&[]).iter().filter(|s| s.floor_id == c.a.floor && c.shown(&s.category_code)) {
|
||||
let greyed = Some(c.greyed(&s.category_code));
|
||||
let ov = c.overrides(&s.category_code, Some(&stair_label(s)));
|
||||
let lw = ov.lineweight.unwrap_or_else(|| c.cat(&s.category_code).map_or(WALL_FALLBACK_MM, |k| k.lw));
|
||||
let stroke = ov.color.as_deref().or(s.color.as_deref()).unwrap_or(POCHE_STROKE).to_string();
|
||||
let (zb, zt) = p.stair_vertical_extent(s);
|
||||
let params = s.encode();
|
||||
if let Some(sp) = crate::stair::decode_params(¶ms).filter(|_| (zt - zb).is_finite()) {
|
||||
let geo = kernel2d::stair_geometry(&sp, zt - zb);
|
||||
for t in &geo.treads {
|
||||
for q in &t.pts {
|
||||
bounds.acc(q.x, q.y);
|
||||
}
|
||||
}
|
||||
for q in geo.landing.iter().flatten() {
|
||||
bounds.acc(q.x, q.y);
|
||||
}
|
||||
}
|
||||
let f = crate::plan_stairs::plan_stair(¶ms, zt - zb, cut_height, lw, s.arrow_style == Some(StairArrowStyle::Filled));
|
||||
if f.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let n = f[0] as usize;
|
||||
let mut i = 1;
|
||||
for _ in 0..n {
|
||||
match f[i] as i64 {
|
||||
1 => {
|
||||
let count = f[i + 3] as usize;
|
||||
let pts = (0..count).map(|j| v2(f[i + 4 + 2 * j], f[i + 5 + 2 * j])).collect();
|
||||
out.push(Primitive::Polygon {
|
||||
pts,
|
||||
fill: if f[i + 2] != 0.0 { stroke.clone() } else { "none".into() },
|
||||
stroke: stroke.clone(),
|
||||
stroke_width_mm: f[i + 1],
|
||||
hatch: no_hatch(),
|
||||
greyed,
|
||||
opacity: None,
|
||||
no_stroke_edges: None,
|
||||
wall_id: None,
|
||||
drawing_id: None,
|
||||
ceiling_id: None,
|
||||
opening_id: None,
|
||||
stair_id: Some(s.id.clone()),
|
||||
room_id: None,
|
||||
extruded_solid_id: None,
|
||||
context_object_id: None,
|
||||
column_id: None,
|
||||
roof_id: None,
|
||||
section_line_id: None,
|
||||
});
|
||||
i += 4 + 2 * count;
|
||||
}
|
||||
2 => {
|
||||
let cls = LINE_CLS.get(f[i + 1] as usize).copied().unwrap_or("");
|
||||
let dash = (cls == "stair-tread").then(|| (f[i + 3] != 0.0).then(|| TREAD_DASH.to_vec()));
|
||||
out.push(Primitive::Line {
|
||||
a: v2(f[i + 4], f[i + 5]),
|
||||
b: v2(f[i + 6], f[i + 7]),
|
||||
cls: cls.into(),
|
||||
weight_mm: f[i + 2],
|
||||
dash,
|
||||
zigzag: None,
|
||||
motif: None,
|
||||
color: Some(stroke.clone()),
|
||||
drawing_id: None,
|
||||
opening_id: None,
|
||||
stair_id: Some(s.id.clone()),
|
||||
greyed,
|
||||
opacity: None,
|
||||
});
|
||||
i += 8;
|
||||
}
|
||||
_ => {
|
||||
out.push(Primitive::Arc {
|
||||
center: v2(f[i + 2], f[i + 3]),
|
||||
from: v2(f[i + 4], f[i + 5]),
|
||||
to: v2(f[i + 6], f[i + 7]),
|
||||
r: f[i + 8],
|
||||
cls: "stair-outline".into(),
|
||||
weight_mm: f[i + 1],
|
||||
dash: None,
|
||||
opening_id: None,
|
||||
stair_id: Some(s.id.clone()),
|
||||
greyed,
|
||||
opacity: None,
|
||||
});
|
||||
i += 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn label_wie_ts() {
|
||||
let s = Stair { shape: StairShape::L, step_count: 16.0, ..Default::default() };
|
||||
assert_eq!(stair_label(&s), "L-Treppe 16 STG");
|
||||
assert_eq!(stair_label(&Stair { shape: StairShape::Spiral, step_count: 12.0, ..Default::default() }), "Wendel 12 STG");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,495 @@
|
||||
//! Wände und Öffnungen im Grundriss auf dem Dokument ([K3d]): Filter, Override-Regeln,
|
||||
//! Verschneidung, Stil (Bauteil, Schraffur, Farbe, Fugen-Linienstil) und Pick-IDs um die schon
|
||||
//! portierte Geometrie (`plan_walls.rs`, `plan_openings.rs`) — Rust-Gegenstück zu
|
||||
//! `generatePlan/{walls,openings}.ts` und der Wand-Schleife in `generatePlan.ts`.
|
||||
//!
|
||||
//! Die Geometrie-Funktionen nehmen weiter ihren flachen Puffer; er wird hier genau so aufgebaut wie
|
||||
//! früher in TS, damit das Ergebnis bitgleich bleibt.
|
||||
|
||||
use super::domains::Ctx;
|
||||
use super::prim::{HatchRender, Primitive};
|
||||
use super::style::*;
|
||||
use crate::joins::{self, WallCuts};
|
||||
use crate::js_fmt::to_fixed;
|
||||
use crate::jsnum::{atan2, round};
|
||||
use crate::model::*;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Linienklassen der Öffnungs-Kodierung (`plan_openings.rs`).
|
||||
const LINE_CLS: [&str; 11] = [
|
||||
"door-leaf", "door-frame", "door-lintel", "opening-frame", "window-glass", "window-mullion", "window-sash", "window-stulp", "window-sill", "window-frame", "window-shading",
|
||||
];
|
||||
|
||||
fn dash_of(code: f64) -> Option<Vec<f64>> {
|
||||
match code as i64 {
|
||||
1 => Some(vec![0.18, 0.09]),
|
||||
2 => Some(OVERHEAD_DASH.to_vec()),
|
||||
3 => Some(vec![0.04, 0.08]),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// `openingLabel` (für `object_name`).
|
||||
pub fn opening_label(o: &Opening) -> String {
|
||||
format!("{} {}×{}", if o.kind == ElementKind::Door { "Tür" } else { "Fenster" }, to_fixed(o.width * 100.0, 0), to_fixed(o.height * 100.0, 0))
|
||||
}
|
||||
|
||||
fn wall_type<'a>(p: &'a Project, w: &Wall) -> Result<&'a WallType, String> {
|
||||
p.wall_type(w).ok_or_else(|| format!("Unbekannter Wandtyp: {}", w.wall_type_id))
|
||||
}
|
||||
|
||||
/// Verschneidung der gezeichneten Wände (`computeJoins` in TS, gleicher Puffer). Fehler wie die
|
||||
/// Modell-Helfer in TS (unbekannter Wandtyp/Bauteil).
|
||||
fn plan_joins(p: &Project, walls: &[EffWall]) -> Result<Vec<WallCuts>, String> {
|
||||
let mut buf = vec![walls.len() as f64];
|
||||
let mut comp_index: HashMap<&str, usize> = HashMap::new();
|
||||
for e in walls {
|
||||
let w = e.w;
|
||||
buf.extend([w.start.x, w.start.y, w.end.x, w.end.y]);
|
||||
match (w.reference_offset, w.reference_line) {
|
||||
(Some(v), _) => buf.extend([3.0, v]),
|
||||
(None, Some(WallReferenceLine::Left)) => buf.extend([1.0, 0.0]),
|
||||
(None, Some(WallReferenceLine::Right)) => buf.extend([2.0, 0.0]),
|
||||
_ => buf.extend([0.0, 0.0]),
|
||||
}
|
||||
let Some(wt) = p.wall_type(w) else {
|
||||
buf.extend([0.0, 0.0]);
|
||||
continue;
|
||||
};
|
||||
buf.extend([1.0, wt.layers.len() as f64]);
|
||||
for l in &wt.layers {
|
||||
let comp = p.component(&l.component_id);
|
||||
let idx = match comp {
|
||||
Some(c) => {
|
||||
let n = comp_index.len();
|
||||
*comp_index.entry(c.id.as_str()).or_insert(n) as f64
|
||||
}
|
||||
None => -1.0,
|
||||
};
|
||||
buf.extend([l.thickness, idx, comp.map_or(f64::NAN, |c| c.join_priority)]);
|
||||
}
|
||||
}
|
||||
let out = joins::compute_joins_flat(&buf);
|
||||
if out.first() == Some(&1.0) {
|
||||
let bad = out.get(1).and_then(|i| walls.get(*i as usize));
|
||||
if let Some(e) = bad {
|
||||
for l in &wall_type(p, e.w)?.layers {
|
||||
p.component(&l.component_id).ok_or_else(|| format!("Unbekanntes Bauteil-Material: {}", l.component_id))?;
|
||||
}
|
||||
}
|
||||
return Err("computeJoins: unbekannter Wandtyp oder Bauteil".into());
|
||||
}
|
||||
if out.first() != Some(&0.0) {
|
||||
return Ok(vec![WallCuts::default(); walls.len()]);
|
||||
}
|
||||
let mut r = crate::flat_read::Reader::new(&out[1..]);
|
||||
let mut cuts = Vec::with_capacity(walls.len());
|
||||
for _ in walls {
|
||||
cuts.push(joins::decode_cuts(&mut r).unwrap_or_default());
|
||||
}
|
||||
Ok(cuts)
|
||||
}
|
||||
|
||||
/// Wand mit angewandten Override-Regeln (Farbe → Umriss/Fugen, Strichstärke).
|
||||
struct EffWall<'a> {
|
||||
w: &'a Wall,
|
||||
color: Option<String>,
|
||||
stroke_weight: Option<f64>,
|
||||
}
|
||||
|
||||
/// `wallTypeThickness` (Summe ab 0 wie `reduce` in TS).
|
||||
fn thickness(layers: &[Layer]) -> f64 {
|
||||
layers.iter().fold(0.0, |s, l| s + l.thickness)
|
||||
}
|
||||
|
||||
fn line_buf(out: &mut Vec<f64>, l: Option<&joins::Line>) {
|
||||
match l {
|
||||
Some(l) => out.extend([1.0, l.point.x, l.point.y, l.dir.x, l.dir.y]),
|
||||
None => out.extend([0.0; 5]),
|
||||
}
|
||||
}
|
||||
|
||||
/// Eingabe von `plan_walls::wall_poche` (wie `encodeWallPoche` in TS).
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn encode_wall_poche(w: &Wall, layers: &[f64], total: f64, ref_off: f64, gaps: &[(f64, f64)], cuts: &WallCuts, grob: bool, view_only: bool) -> Vec<f64> {
|
||||
let mut b = vec![w.start.x, w.start.y, w.end.x, w.end.y, total, ref_off, if grob { 1.0 } else { 0.0 }, if view_only { 1.0 } else { 0.0 }];
|
||||
b.push(layers.len() as f64);
|
||||
b.extend_from_slice(layers);
|
||||
line_buf(&mut b, cuts.start_cut.as_ref());
|
||||
line_buf(&mut b, cuts.end_cut.as_ref());
|
||||
match &cuts.layer_cuts {
|
||||
Some(lc) => {
|
||||
b.push(1.0);
|
||||
let at = |v: &Vec<Option<joins::Line>>, i: usize| v.get(i).copied().flatten();
|
||||
for i in 0..layers.len() {
|
||||
line_buf(&mut b, at(&lc.start, i).as_ref());
|
||||
line_buf(&mut b, at(&lc.end, i).as_ref());
|
||||
line_buf(&mut b, at(&lc.start_side, i).as_ref());
|
||||
line_buf(&mut b, at(&lc.end_side, i).as_ref());
|
||||
}
|
||||
}
|
||||
None => b.push(0.0),
|
||||
}
|
||||
b.push(cuts.span_cutouts.len() as f64);
|
||||
for c in &cuts.span_cutouts {
|
||||
b.extend([c.from, c.to, c.off_a, c.off_b]);
|
||||
}
|
||||
b.push(gaps.len() as f64);
|
||||
for g in gaps {
|
||||
b.extend([g.0, g.1]);
|
||||
}
|
||||
b
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn wall_polygon(pts: Vec<Vec2>, fill: &str, stroke: &str, w: f64, hatch: HatchRender, greyed: bool, no_stroke_edges: Option<Vec<f64>>, wall_id: Option<&str>, opening_id: Option<&str>) -> Primitive {
|
||||
Primitive::Polygon {
|
||||
pts,
|
||||
fill: fill.into(),
|
||||
stroke: stroke.into(),
|
||||
stroke_width_mm: w,
|
||||
hatch,
|
||||
greyed: Some(greyed),
|
||||
opacity: None,
|
||||
no_stroke_edges,
|
||||
wall_id: wall_id.map(String::from),
|
||||
drawing_id: None,
|
||||
ceiling_id: None,
|
||||
opening_id: opening_id.map(String::from),
|
||||
stair_id: None,
|
||||
room_id: None,
|
||||
extruded_solid_id: None,
|
||||
context_object_id: None,
|
||||
column_id: None,
|
||||
roof_id: None,
|
||||
section_line_id: None,
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn mk_line(a: Vec2, b: Vec2, cls: &str, w: f64, dash: super::prim::Dash, color: Option<&str>, greyed: bool, opening_id: Option<&str>) -> Primitive {
|
||||
Primitive::Line { a, b, cls: cls.into(), weight_mm: w, dash, zigzag: None, motif: None, color: color.map(String::from), drawing_id: None, opening_id: opening_id.map(String::from), stair_id: None, greyed: Some(greyed), opacity: None }
|
||||
}
|
||||
|
||||
fn v2(x: f64, y: f64) -> Vec2 {
|
||||
Vec2 { x, y }
|
||||
}
|
||||
|
||||
/// Wand-Poché (`addWallPoche`).
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn wall_poche(c: &Ctx, out: &mut Vec<Primitive>, e: &EffWall, gaps: &[(f64, f64)], cuts: &WallCuts, greyed: bool, wall_lw: f64, category: Option<&LayerCategory>, view_only: bool) -> Result<(), String> {
|
||||
let p = c.p;
|
||||
let w = e.w;
|
||||
let detail = c.a.detail;
|
||||
let wt = wall_type(p, w)?;
|
||||
let total = thickness(&wt.layers);
|
||||
let ref_off = joins::reference_offset(crate::model3d::wall_reference(w), total);
|
||||
let angle = atan2(w.end.y - w.start.y, w.end.x - w.start.x) * 180.0 / std::f64::consts::PI;
|
||||
let stroke = e.color.as_deref().unwrap_or(POCHE_STROKE);
|
||||
let outline_mm = wall_lw * detail.outline_factor();
|
||||
let layer_mm = LAYER_LINE_MM * detail.layer_factor();
|
||||
let thick: Vec<f64> = wt.layers.iter().map(|l| l.thickness).collect();
|
||||
let f = crate::plan_walls::wall_poche(&encode_wall_poche(w, &thick, total, ref_off, gaps, cuts, detail == Detail::Grob, view_only));
|
||||
if f.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
let mut styles: HashMap<usize, (HatchRender, String)> = HashMap::new();
|
||||
let mut style_of = |li: usize| -> Result<(HatchRender, String), String> {
|
||||
if let Some(s) = styles.get(&li) {
|
||||
return Ok(s.clone());
|
||||
}
|
||||
let layer = wt.layers.get(li).ok_or("Schicht fehlt")?;
|
||||
let comp = p.component(&layer.component_id).ok_or_else(|| format!("Unbekanntes Bauteil-Material: {}", layer.component_id))?;
|
||||
let hid = resolve_hatch_id(w.hatch_id.as_deref(), w.hatch_source, category, Some(&comp.hatch_id)).unwrap_or(&comp.hatch_id);
|
||||
let hatch = super::domains::resolve_hatch_or_err(p, hid, Some(angle), resolve_foreground(comp, w.foreground.as_deref(), category, w.foreground_source))?;
|
||||
let bg = resolve_background(comp, w.background.as_deref(), category, w.background_source);
|
||||
let fill = bg.unwrap_or(if hatch.pattern == HatchPattern::Solid { HATCH_INK } else { HATCH_PAPER }).to_string();
|
||||
styles.insert(li, (hatch.clone(), fill.clone()));
|
||||
Ok((hatch, fill))
|
||||
};
|
||||
let n = f[0] as usize;
|
||||
let mut i = 1;
|
||||
for _ in 0..n {
|
||||
if f[i] == 1.0 {
|
||||
let art = f[i + 1];
|
||||
let li = f[i + 2] as usize;
|
||||
let n_no = f[i + 3] as usize;
|
||||
let no_stroke = f[i + 4..i + 4 + n_no].to_vec();
|
||||
let q = i + 4 + n_no;
|
||||
let pts: Vec<Vec2> = (0..4).map(|j| v2(f[q + 2 * j], f[q + 2 * j + 1])).collect();
|
||||
i = q + 8;
|
||||
if art == 2.0 {
|
||||
let (hatch, fill) = style_of(li)?;
|
||||
out.push(wall_polygon(pts, &fill, "none", 0.0, hatch, greyed, Some(no_stroke), Some(&w.id), None));
|
||||
} else {
|
||||
let fill = if art == 1.0 { HATCH_INK } else { "none" };
|
||||
let sw = if art == 0.0 { layer_mm } else { outline_mm };
|
||||
out.push(wall_polygon(pts, fill, stroke, sw, no_hatch(), greyed, Some(no_stroke), Some(&w.id), None));
|
||||
}
|
||||
} else {
|
||||
let art = f[i + 1];
|
||||
let li = f[i + 2] as usize;
|
||||
let a = v2(f[i + 3], f[i + 4]);
|
||||
let b = v2(f[i + 5], f[i + 6]);
|
||||
i += 7;
|
||||
if art == 0.0 {
|
||||
out.push(mk_line(a, b, "layer-joint-l", layer_mm, None, Some(stroke), greyed, None));
|
||||
} else if art == 1.0 {
|
||||
let jls = wt.layers.get(li).and_then(|l| l.joint_line_style_id.as_deref()).filter(|s| !s.is_empty()).and_then(|id| p.line_style(id));
|
||||
let mut l = mk_line(
|
||||
a,
|
||||
b,
|
||||
"layer-joint",
|
||||
jls.map_or(layer_mm, |s| s.weight * detail.layer_factor()),
|
||||
Some(jls.and_then(|s| s.dash.clone())),
|
||||
Some(jls.map_or(stroke, |s| s.color.as_str())),
|
||||
greyed,
|
||||
None,
|
||||
);
|
||||
if let (Primitive::Line { zigzag, motif, .. }, Some(s)) = (&mut l, jls) {
|
||||
if s.kind == Some(LineStyleKind::Zigzag) {
|
||||
*zigzag = s.zigzag.clone();
|
||||
}
|
||||
if s.kind == Some(LineStyleKind::Custom) {
|
||||
*motif = s.motif.clone();
|
||||
}
|
||||
}
|
||||
out.push(l);
|
||||
} else {
|
||||
out.push(mk_line(a, b, "wall-outline", outline_mm, None, Some(stroke), greyed, None));
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Sashes eines Fenstertyps (`sashesOfWindowType`): fehlend → aus `wingCount` gleichmässig.
|
||||
fn sashes(wt: &WindowType) -> Vec<SashDef> {
|
||||
if let Some(s) = wt.sashes.as_ref().filter(|s| !s.is_empty()) {
|
||||
return s.clone();
|
||||
}
|
||||
let wc = if wt.wing_count == 0.0 || wt.wing_count.is_nan() { 1.0 } else { wt.wing_count };
|
||||
let n = crate::jsnum::max(1.0, round(wc)) as usize;
|
||||
let opening = if wt.kind == OpeningKind::Fest { OpeningKind::Fest } else { wt.kind };
|
||||
(0..n).map(|i| SashDef { kind: SashDefKind::Fluegel, auto_width: Some(true), opening: Some(opening), hinge_side: Some(if i % 2 == 0 { SashDefHingeSide::Left } else { SashDefHingeSide::Right }), ..Default::default() }).collect()
|
||||
}
|
||||
|
||||
fn door_type<'a>(p: &'a Project, o: &Opening) -> Option<&'a DoorType> {
|
||||
let id = o.type_id.as_deref().filter(|s| !s.is_empty())?;
|
||||
p.door_types.as_deref()?.iter().find(|t| t.id == id)
|
||||
}
|
||||
|
||||
fn window_type<'a>(p: &'a Project, o: &Opening) -> Option<&'a WindowType> {
|
||||
let id = o.type_id.as_deref().filter(|s| !s.is_empty())?;
|
||||
p.window_types.as_deref()?.iter().find(|t| t.id == id)
|
||||
}
|
||||
|
||||
/// Öffnungs-Symbol (`addOpeningSymbol`).
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, color: Option<&str>, greyed: bool, detail: Detail, lw: f64) -> Result<(), String> {
|
||||
let p = c.p;
|
||||
let total = thickness(&wall_type(p, w)?.layers);
|
||||
let ref_off = joins::reference_offset(crate::model3d::wall_reference(w), total);
|
||||
let door = o.kind == ElementKind::Door;
|
||||
let wt = if door { None } else { window_type(p, o) };
|
||||
// Rahmenband nur bei Türen mit Typ (Fenster zeichnen es selbst).
|
||||
let dt = if door { door_type(p, o) } else { None };
|
||||
let sash_list = wt.map(sashes).unwrap_or_default();
|
||||
let stroke = color.unwrap_or(POCHE_STROKE);
|
||||
let frame_color = o.frame_line.as_ref().and_then(|l| l.color.as_deref()).unwrap_or(stroke);
|
||||
let frame_weight = o.frame_line.as_ref().and_then(|l| l.weight).unwrap_or(lw);
|
||||
let frame_view_weight = o.frame_view_line.as_ref().and_then(|l| l.weight).unwrap_or(frame_weight);
|
||||
let colors = [
|
||||
"",
|
||||
stroke,
|
||||
frame_color,
|
||||
o.frame_view_line.as_ref().and_then(|l| l.color.as_deref()).unwrap_or(frame_color),
|
||||
o.sash_line.as_ref().and_then(|l| l.color.as_deref()).unwrap_or(stroke),
|
||||
o.sill_line_style.as_ref().and_then(|l| l.color.as_deref()).unwrap_or(stroke),
|
||||
];
|
||||
let b01 = |b: bool| if b { 1.0 } else { 0.0 };
|
||||
let detail_code = match detail {
|
||||
Detail::Grob => 0.0,
|
||||
Detail::Mittel => 1.0,
|
||||
Detail::Fein => 2.0,
|
||||
};
|
||||
let mut b: Vec<f64> = vec![w.start.x, w.start.y, w.end.x, w.end.y, total, ref_off, o.position, o.width, b01(door), detail_code];
|
||||
// Tür
|
||||
b.push(b01(o.swing.is_some_and(|s| s != SwingSide::Left)));
|
||||
b.push(b01(o.opening_dir.is_some_and(|s| s != OpeningOpeningDir::In)));
|
||||
b.push(b01(o.hinge.is_some_and(|s| s != OpeningHinge::Start)));
|
||||
b.push(o.swing_angle.unwrap_or(f64::NAN));
|
||||
b.push(b01(o.door_type == Some(OpeningDoorType::Wandoeffnung)));
|
||||
b.push(if door { crate::jsnum::max(1.0, round(door_type(p, o).map_or(1.0, |t| t.leaf_count))) } else { 1.0 });
|
||||
b.push(match o.lintel_lines.unwrap_or(OpeningLintelLines::Beide) {
|
||||
OpeningLintelLines::Keine => 0.0,
|
||||
OpeningLintelLines::Aussen => 1.0,
|
||||
OpeningLintelLines::Innen => 2.0,
|
||||
OpeningLintelLines::Beide => 3.0,
|
||||
OpeningLintelLines::Unknown => f64::NAN,
|
||||
});
|
||||
// Rahmenband (Tür mit Typ)
|
||||
match dt {
|
||||
Some(t) => b.extend([
|
||||
1.0,
|
||||
t.frame_width.unwrap_or(0.06),
|
||||
b01(t.frame_kind == Some(DoorTypeFrameKind::Blockrahmen)),
|
||||
t.inset_from_face.unwrap_or(0.0),
|
||||
b01(t.inset_face == Some(DoorTypeInsetFace::Innen)),
|
||||
]),
|
||||
None => b.extend([0.0, 0.0, 0.0, 0.0, 0.0]),
|
||||
}
|
||||
// Fenster
|
||||
b.push(b01(wt.is_some()));
|
||||
b.push(wt.map_or(0.0, |t| t.frame_width.unwrap_or(0.06)));
|
||||
b.push(wt.and_then(|t| t.frame_depth).unwrap_or(f64::NAN));
|
||||
b.push(wt.and_then(|t| t.inset_from_face).unwrap_or(f64::NAN));
|
||||
b.push(b01(wt.and_then(|t| t.inset_face) == Some(WindowTypeInsetFace::Innen)));
|
||||
b.push(o.wing_count.unwrap_or(f64::NAN));
|
||||
b.push(if detail == Detail::Fein { 2.0 } else { 1.0 });
|
||||
let sill = wt.and_then(|t| t.sill_line.as_ref());
|
||||
b.push(sill.map_or(0.0, |s| match s.faces {
|
||||
WindowTypeSillLineFaces::Aussen => 1.0,
|
||||
WindowTypeSillLineFaces::Innen => 2.0,
|
||||
WindowTypeSillLineFaces::Beide => 3.0,
|
||||
WindowTypeSillLineFaces::Unknown => f64::NAN,
|
||||
}));
|
||||
b.push(b01(sill.is_some_and(|s| s.view == WindowTypeSillLineView::Unter)));
|
||||
let shading = wt.and_then(|t| t.shading.as_ref());
|
||||
b.push(b01(shading.is_some_and(|s| s.create)));
|
||||
b.push(shading.map_or(0.0, |s| s.r#box.width));
|
||||
b.push(shading.map_or(0.0, |s| s.r#box.height));
|
||||
// Strichstärken
|
||||
b.push(SYMBOL_HAIRLINE_MM);
|
||||
b.push(o.frame_line.as_ref().and_then(|l| l.weight).unwrap_or(SYMBOL_HAIRLINE_MM));
|
||||
b.push(frame_view_weight);
|
||||
b.push(o.sash_line.as_ref().and_then(|l| l.weight).unwrap_or(SYMBOL_HAIRLINE_MM));
|
||||
b.push(o.sill_line_style.as_ref().and_then(|l| l.weight).unwrap_or(SYMBOL_HAIRLINE_MM));
|
||||
b.push(sash_list.len() as f64);
|
||||
for s in &sash_list {
|
||||
b.extend([
|
||||
b01(s.kind == SashDefKind::Pfosten),
|
||||
if s.auto_width == Some(false) { 0.0 } else { 1.0 },
|
||||
s.width.unwrap_or(f64::NAN),
|
||||
s.post_width.unwrap_or(f64::NAN),
|
||||
b01(s.opening.is_some_and(|k| k != OpeningKind::Fest)),
|
||||
]);
|
||||
}
|
||||
let f = crate::plan_openings::plan_opening(&b);
|
||||
if f.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
let id = Some(o.id.as_str());
|
||||
let slot = |k: f64| colors.get(k as usize).copied().unwrap_or("");
|
||||
let n = f[0] as usize;
|
||||
let mut i = 1;
|
||||
for _ in 0..n {
|
||||
if f[i] == 1.0 {
|
||||
let count = f[i + 4] as usize;
|
||||
let pts: Vec<Vec2> = (0..count).map(|j| v2(f[i + 5 + 2 * j], f[i + 6 + 2 * j])).collect();
|
||||
let frame = f[i + 1] == 1.0;
|
||||
out.push(wall_polygon(pts, "none", if frame { slot(f[i + 3]) } else { "none" }, f[i + 2], no_hatch(), greyed, None, None, id));
|
||||
i += 5 + 2 * count;
|
||||
} else if f[i] == 2.0 {
|
||||
let s = f[i + 3];
|
||||
let cls = LINE_CLS.get(f[i + 1] as usize).copied().unwrap_or("");
|
||||
out.push(mk_line(v2(f[i + 5], f[i + 6]), v2(f[i + 7], f[i + 8]), cls, f[i + 2], dash_of(f[i + 4]).map(Some), (s != 0.0).then(|| slot(s)), greyed, id));
|
||||
i += 9;
|
||||
} else {
|
||||
out.push(Primitive::Arc {
|
||||
center: v2(f[i + 2], f[i + 3]),
|
||||
from: v2(f[i + 4], f[i + 5]),
|
||||
to: v2(f[i + 6], f[i + 7]),
|
||||
r: f[i + 8],
|
||||
cls: "door-swing".into(),
|
||||
weight_mm: f[i + 1],
|
||||
dash: None,
|
||||
opening_id: Some(o.id.clone()),
|
||||
stair_id: None,
|
||||
greyed: Some(greyed),
|
||||
opacity: None,
|
||||
});
|
||||
i += 9;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Wände (Poché, Referenzlinie) und ihre Öffnungs-Symbole in Zeichenreihenfolge, dazu das Ausmass
|
||||
/// der Wand-Ecken (`computeBounds`).
|
||||
pub fn plan_walls(c: &Ctx, reference_lines: bool, out: &mut Vec<Primitive>, bounds: &mut super::domains::Bounds) -> Result<(), String> {
|
||||
let p = c.p;
|
||||
let type_names: HashMap<&str, &str> = p.wall_types.iter().map(|t| (t.id.as_str(), t.name.as_str())).collect();
|
||||
let walls: Vec<EffWall> = p
|
||||
.walls
|
||||
.iter()
|
||||
.filter(|w| w.floor_id == c.a.floor && c.shown(&w.category_code))
|
||||
.map(|w| {
|
||||
let ov = c.overrides(&w.category_code, type_names.get(w.wall_type_id.as_str()).copied());
|
||||
EffWall { w, color: ov.color.or_else(|| w.color.clone()), stroke_weight: ov.lineweight.or(w.stroke_weight) }
|
||||
})
|
||||
.collect();
|
||||
let cuts = plan_joins(p, &walls)?;
|
||||
let floor = p.floor(&c.a.floor);
|
||||
let cut_z = floor.and_then(|f| f.base_elevation).unwrap_or(0.0) + floor.and_then(|f| f.cut_height).unwrap_or(1.0);
|
||||
// Bei doppelten Wand-ids gewinnt in TS (Map) die letzte Verschneidung.
|
||||
let mut cut_by_id: HashMap<&str, &WallCuts> = HashMap::new();
|
||||
for (e, k) in walls.iter().zip(&cuts) {
|
||||
cut_by_id.insert(e.w.id.as_str(), k);
|
||||
}
|
||||
for e in &walls {
|
||||
let w = e.w;
|
||||
bounds_wall(p, w, bounds);
|
||||
let greyed = c.greyed(&w.category_code);
|
||||
let category = c.cat(&w.category_code);
|
||||
let lw = resolve_stroke_weight(e.stroke_weight, w.stroke_weight_source, category, category.map_or(WALL_FALLBACK_MM, |k| k.lw));
|
||||
let openings: Vec<&Opening> = p.openings_of_wall(&w.id).collect();
|
||||
let wr_total = p.wall_thickness(w, 0.2);
|
||||
let wr = crate::opening_geom::WallRef {
|
||||
start: crate::opening_geom::v(w.start.x, w.start.y),
|
||||
end: crate::opening_geom::v(w.end.x, w.end.y),
|
||||
total: wr_total,
|
||||
ref_off: joins::reference_offset(crate::model3d::wall_reference(w), wr_total),
|
||||
};
|
||||
let mut gaps: Vec<(f64, f64)> = openings.iter().filter_map(|o| crate::opening_geom::opening_interval(&wr, o.position, o.width)).collect();
|
||||
gaps.sort_by(|a, b| (a.0 - b.0).partial_cmp(&0.0).unwrap_or(std::cmp::Ordering::Equal));
|
||||
let empty = WallCuts::default();
|
||||
let cut = cut_by_id.get(w.id.as_str()).copied().unwrap_or(&empty);
|
||||
let (zb, zt) = p.wall_vertical_extent(w);
|
||||
let view_only = zt < cut_z || zb > cut_z;
|
||||
wall_poche(c, out, e, &gaps, cut, greyed, lw, category, view_only)?;
|
||||
if reference_lines {
|
||||
out.push(mk_line(w.start, w.end, "wall-axis", 0.13, Some(Some(vec![0.18, 0.06, 0.04, 0.06])), None, greyed, None));
|
||||
}
|
||||
for o in openings {
|
||||
if !c.shown(&o.category_code) {
|
||||
continue;
|
||||
}
|
||||
let ov = c.overrides(&o.category_code, Some(&opening_label(o)));
|
||||
let olw = ov.lineweight.unwrap_or_else(|| c.cat(&o.category_code).map_or(LAYER_LINE_MM, |k| k.lw));
|
||||
let color = ov.color.as_deref().or(o.color.as_deref());
|
||||
let detail = match o.detail_level {
|
||||
Some(DetailLevel::Grob) => Detail::Grob,
|
||||
Some(DetailLevel::Mittel) => Detail::Mittel,
|
||||
Some(DetailLevel::Fein) => Detail::Fein,
|
||||
_ => c.a.detail,
|
||||
};
|
||||
opening_symbol(c, out, w, o, color, c.greyed(&o.category_code), detail, olw)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Wand-Ecken (`wallCorners` mit Typ-Dicke) ins Ausmass.
|
||||
fn bounds_wall(p: &Project, w: &Wall, bounds: &mut super::domains::Bounds) {
|
||||
let Some(wt) = p.wall_type(w) else { return };
|
||||
let h = thickness(&wt.layers) / 2.0;
|
||||
let (dx, dy) = (w.end.x - w.start.x, w.end.y - w.start.y);
|
||||
let l = crate::jsmath::hypot2(dx, dy);
|
||||
let l = if l == 0.0 || l.is_nan() { 1.0 } else { l };
|
||||
let (ux, uy) = (dx / l, dy / l);
|
||||
let (nx, ny) = (-uy, ux);
|
||||
for (q, off) in [(w.start, h), (w.end, h), (w.end, -h), (w.start, -h)] {
|
||||
bounds.acc(q.x + nx * off, q.y + ny * off);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Öffnungs-Symbol (Tür/Fenster) im Grundriss ([K3a]): Port von `generatePlan/openings.ts`
|
||||
//! (`addOpeningSymbol`, `addOpeningFrameBand`). Geometrie aus `opening_geom.rs`. Stil löst TS aus dem
|
||||
//! (`addOpeningSymbol`, `addOpeningFrameBand`). Geometrie aus `opening_geom.rs`. Stil löst `plan/walls.rs` aus dem
|
||||
//! Modell: Strichstärken kommen als Zahlen herein, Farben als Platz (Slot) heraus (0 = keine,
|
||||
//! 1 Strichfarbe, 2 Rahmen, 3 Rahmen-Aufsicht, 4 Flügel/Sprossen, 5 Fensterbank-/Sims-Linie).
|
||||
//!
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Treppen-Symbol im Grundriss ([K3a]): Tritte, Lauflinie, Pfeil, Podest, SIA-Bruchlinie und
|
||||
//! Aussenlinie als flache Primitivliste. Port von `src/plan/generatePlan/stairs.ts`; die Geometrie
|
||||
//! kommt aus `kernel2d` (`stair_geometry`, `stair_cut`, `stair_outline`), Farbe, Pick-ID und
|
||||
//! Graustufen setzt der Aufrufer.
|
||||
//! Graustufen setzt der Aufrufer (`plan/stairs.rs`, [K3d]).
|
||||
//!
|
||||
//! Eingabe: Treppen-Parameter (16 Zahlen, s. `stair.rs`), Gesamt-Steighöhe, Schnitthöhe über der
|
||||
//! Treppen-UK, Strichstärke `lw_mm` (Papier-mm), `filled_arrow` (0/1).
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! Wand-Poché und Decken-Umriss im Grundriss ([K3a]): die Geometrie von `generatePlan/walls.ts`
|
||||
//! Wand-Poché und Decken-Umriss im Grundriss ([K3a]): die Geometrie der früheren `generatePlan/walls.ts`
|
||||
//! und `ceilings.ts` (Segmente zwischen Öffnungen, Gehrungsbänder, Schichtfugen, Durchgangswand-
|
||||
//! Aussparungen, Verdeckung von Decken-Umrissen durch Wand-Footprints). Stil (Bauteil, Schraffur,
|
||||
//! Farbe, Strichstärke, Linienstil der Fuge) löst TS aus dem Modell auf und ordnet ihn über den
|
||||
//! Schichtindex zu — das Modell bleibt bis [K4] in TS.
|
||||
//! Farbe, Strichstärke, Linienstil der Fuge) löst `plan/walls.rs` auf dem Dokument auf und ordnet
|
||||
//! ihn über den Schichtindex zu ([K3d]).
|
||||
//!
|
||||
//! Rechenreihenfolge und Zahlsemantik wie in TS (`Math.hypot` über `jsmath`, `Math.min/max` über
|
||||
//! `jsnum`), damit die Ausgabe bitgleich bleibt.
|
||||
@@ -22,8 +22,8 @@
|
||||
//! ```
|
||||
//!
|
||||
//! ## Decken-Umriss
|
||||
//! Eingabe `[nRing, x, y …, nBruecken, kante…, nFootprints, (ax, ay, ux, uy, mx, my, len, half,
|
||||
//! refOff)×n]`; Ausgabe `[n, ax, ay, bx, by …]` (freie Teilstücke der Umrisskanten).
|
||||
//! [`ceiling_outline_lines`]: freie Teilstücke der Umrisskanten gegen die Wand-Footprints; Aufrufer
|
||||
//! ist die Decken-Domäne auf dem Dokument (`plan/domains.rs`, [K3d]).
|
||||
|
||||
use crate::flat_read::Reader;
|
||||
use crate::jsmath::hypot2;
|
||||
@@ -164,44 +164,50 @@ fn segment_inside(pa: V, pb: V, fp: &Footprint) -> Option<(f64, f64)> {
|
||||
|
||||
// ── Decken-Umriss ───────────────────────────────────────────────────────────
|
||||
|
||||
pub fn ceiling_outline(buf: &[f64]) -> Vec<f64> {
|
||||
(|| {
|
||||
let mut r = Reader::new(buf);
|
||||
let ring: Vec<V> = r.ring()?.into_iter().map(|p| v(p[0], p[1])).collect();
|
||||
let n_bridge = r.count()?;
|
||||
let mut bridge = Vec::with_capacity(n_bridge);
|
||||
for _ in 0..n_bridge {
|
||||
bridge.push(r.num()?);
|
||||
/// Wand-Footprint (OBB) für das Verdecken von Decken-Umrissen (`buildWallFootprints` in TS).
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct WallFootprint {
|
||||
pub a: [f64; 2],
|
||||
pub u: [f64; 2],
|
||||
pub m: [f64; 2],
|
||||
pub len: f64,
|
||||
pub half: f64,
|
||||
pub ref_off: f64,
|
||||
}
|
||||
|
||||
/// Footprint einer Wand aus Achse, Dicke und Referenz-Querversatz.
|
||||
pub fn wall_footprint(start: [f64; 2], end: [f64; 2], thickness: f64, ref_off: f64) -> WallFootprint {
|
||||
let (s, e) = (v(start[0], start[1]), v(end[0], end[1]));
|
||||
let u = normalize(sub(e, s));
|
||||
let m = left_normal(u);
|
||||
WallFootprint { a: start, u: [u.x, u.y], m: [m.x, m.y], len: hypot2(e.x - s.x, e.y - s.y), half: thickness / 2.0, ref_off }
|
||||
}
|
||||
|
||||
/// Freie Teilstücke der Umrisskanten eines Decken-Rings (ohne Brückenkanten), die nicht unter einem
|
||||
/// Wand-Footprint liegen.
|
||||
pub fn ceiling_outline_lines(ring: &[[f64; 2]], bridge: &[usize], fps: &[WallFootprint]) -> Vec<[[f64; 2]; 2]> {
|
||||
let fps: Vec<Footprint> = fps
|
||||
.iter()
|
||||
.map(|f| Footprint { a: v(f.a[0], f.a[1]), u: v(f.u[0], f.u[1]), m: v(f.m[0], f.m[1]), len: f.len, half: f.half, ref_off: f.ref_off })
|
||||
.collect();
|
||||
let ring: Vec<V> = ring.iter().map(|p| v(p[0], p[1])).collect();
|
||||
let n = ring.len();
|
||||
let mut out = Vec::new();
|
||||
for i in 0..n {
|
||||
if bridge.contains(&i) {
|
||||
continue;
|
||||
}
|
||||
let n_fp = r.count()?;
|
||||
let mut fps = Vec::with_capacity(n_fp);
|
||||
for _ in 0..n_fp {
|
||||
let a = [r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?];
|
||||
fps.push(Footprint { a: v(a[0], a[1]), u: v(a[2], a[3]), m: v(a[4], a[5]), len: a[6], half: a[7], ref_off: a[8] });
|
||||
let a = ring[i];
|
||||
let b = ring[(i + 1) % n];
|
||||
let holes: Vec<(f64, f64)> = fps.iter().filter_map(|fp| segment_inside(a, b, fp)).collect();
|
||||
let d = sub(b, a);
|
||||
for (t0, t1) in subtract_intervals(0.0, 1.0, &holes) {
|
||||
let p = add(a, scale(d, t0));
|
||||
let q = add(a, scale(d, t1));
|
||||
out.push([[p.x, p.y], [q.x, q.y]]);
|
||||
}
|
||||
let n = ring.len();
|
||||
let mut lines: Vec<f64> = Vec::new();
|
||||
let mut count = 0usize;
|
||||
for i in 0..n {
|
||||
if bridge.contains(&(i as f64)) {
|
||||
continue;
|
||||
}
|
||||
let a = ring[i];
|
||||
let b = ring[(i + 1) % n];
|
||||
let holes: Vec<(f64, f64)> = fps.iter().filter_map(|fp| segment_inside(a, b, fp)).collect();
|
||||
let d = sub(b, a);
|
||||
for (t0, t1) in subtract_intervals(0.0, 1.0, &holes) {
|
||||
let p = add(a, scale(d, t0));
|
||||
let q = add(a, scale(d, t1));
|
||||
lines.extend([p.x, p.y, q.x, q.y]);
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
let mut out = vec![count as f64];
|
||||
out.extend(lines);
|
||||
Some(out)
|
||||
})()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
// ── Wand-Poché ──────────────────────────────────────────────────────────────
|
||||
@@ -513,15 +519,17 @@ mod tests {
|
||||
let mut b = wall(4.0, false, &[]);
|
||||
b[0] = f64::NAN;
|
||||
assert!(wall_poche(&b).is_empty());
|
||||
assert!(ceiling_outline(&[3.0, 0.0]).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decken_umriss_wird_von_wand_verdeckt() {
|
||||
// Quadrat 4×4, Wand entlang der unteren Kante (Mitte y=0, Dicke 0.4)
|
||||
let mut b = vec![4.0, 0.0, 0.0, 4.0, 0.0, 4.0, 4.0, 0.0, 4.0, 0.0, 1.0];
|
||||
b.extend([0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 4.0, 0.2, 0.0]);
|
||||
let o = ceiling_outline(&b);
|
||||
assert_eq!(o[0], 3.0); // untere Kante entfällt, drei freie Kanten
|
||||
let ring = [[0.0, 0.0], [4.0, 0.0], [4.0, 4.0], [0.0, 4.0]];
|
||||
let fp = wall_footprint([0.0, 0.0], [4.0, 0.0], 0.4, 0.0);
|
||||
assert_eq!(fp, WallFootprint { a: [0.0, 0.0], u: [1.0, 0.0], m: [0.0, 1.0], len: 4.0, half: 0.2, ref_off: 0.0 });
|
||||
let o = ceiling_outline_lines(&ring, &[], &[fp]);
|
||||
assert_eq!(o.len(), 3); // untere Kante entfällt, drei freie Kanten
|
||||
// Brückenkanten werden nie gestrichen.
|
||||
assert_eq!(ceiling_outline_lines(&ring, &[1], &[fp]).len(), 2);
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String,
|
||||
("scheduleRows", _) => json(&export_schedule::schedule_rows(p)),
|
||||
("scheduleCsv", 1) => Ok(export_schedule::export_schedule_csv(p, text, args[0] != 0.0)),
|
||||
("pickGeometry", _) => json(&model3d::pick_geometry(p)?),
|
||||
("planDomains", 1) => json(&crate::plan::domains::plan_domains(p, &crate::plan::domains::PlanArgs::parse(args[0], text)?)?),
|
||||
("model3dParts", 3) => json(&model3d::parts(p, args[0] != 0.0, args[1], args[2] != 0.0)?),
|
||||
_ => Err(format!("Unbekannte Abfrage: {name}")),
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
//! Bindungen der Wand-Verschneidung (`crate::joins`). Kodierung s. dort.
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Wände flach → `[0, (Cuts je Wand)…]`; `[1, wandIndex]` = Wandtyp/Bauteil unbekannt;
|
||||
/// kaputte Eingabe → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn compute_joins_flat(walls: &[f64]) -> Vec<f64> {
|
||||
crate::joins::compute_joins_flat(walls)
|
||||
}
|
||||
|
||||
/// Verschneidungs-Entscheidung: 0 merge, 1 trim-a, 2 trim-b, 3 coexist.
|
||||
#[wasm_bindgen]
|
||||
pub fn join_priority_resolution(prio_a: f64, prio_b: f64, same_component: bool) -> u8 {
|
||||
use crate::joins::JoinResolution::*;
|
||||
match crate::joins::resolve_join_priority(prio_a, prio_b, same_component) {
|
||||
Merge => 0,
|
||||
TrimA => 1,
|
||||
TrimB => 2,
|
||||
Coexist => 3,
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ mod auto_dimensions;
|
||||
mod kennzahlen;
|
||||
mod bulge;
|
||||
mod stair;
|
||||
mod joins;
|
||||
mod room_area;
|
||||
mod room_boundary;
|
||||
mod polygon_holes;
|
||||
@@ -21,8 +20,6 @@ mod wall_mesh_cut;
|
||||
mod plan_buf;
|
||||
mod project_format;
|
||||
mod gpu_compile;
|
||||
mod plan_stairs;
|
||||
mod plan_walls;
|
||||
mod plan_openings;
|
||||
mod delaunay;
|
||||
mod document;
|
||||
|
||||
@@ -1,25 +1,8 @@
|
||||
//! Bindungen kleiner Plan-Bausteine (`crate::plan_misc`). Layouts s. dort.
|
||||
//! Bindung der Linienenden (`crate::plan_misc`, für 2D-Zeichnungen). Kontext-Fussabdruck und
|
||||
//! Schnittführung ruft die Plan-Erzeugung im Kern direkt (`plan/context.rs`).
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Grundriss-Fussabdruck eines Meshes (Sockelkanten); Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn context_footprint_flat(positions: &[f64], indices: &[f64]) -> Vec<f64> {
|
||||
crate::plan_misc::context_footprint(positions, indices)
|
||||
}
|
||||
|
||||
/// `[minX, minY, maxX, maxY]` der x/y-Werte eines [x,y,z…]-Arrays; leer ohne Punkte.
|
||||
#[wasm_bindgen]
|
||||
pub fn context_bbox_flat(positions: &[f64]) -> Vec<f64> {
|
||||
crate::plan_misc::bbox(positions)
|
||||
}
|
||||
|
||||
/// Schnittführungs-Symbol einer Linie; leer bei zu kurzer Linie.
|
||||
#[wasm_bindgen]
|
||||
pub fn section_line_flat(p0x: f64, p0y: f64, p1x: f64, p1y: f64, sign: f64) -> Vec<f64> {
|
||||
crate::plan_misc::section_line(p0x, p0y, p1x, p1y, sign)
|
||||
}
|
||||
|
||||
/// Linienende (Pfeil, Punkt, Schrägstrich, Quadrat); leer ohne Wirkung.
|
||||
#[wasm_bindgen]
|
||||
pub fn end_mark_flat(x: f64, y: f64, dx: f64, dy: f64, art: f64, mm: f64, scale_denominator: f64) -> Vec<f64> {
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
//! Bindungen von Öffnungs-Symbol und Fenster-Symbol (`crate::plan_openings`). Layout s. dort.
|
||||
//! Bindung des Fenster-Symbols (`crate::plan_openings`, für Schnitt/Ansicht). Layout s. dort. Das
|
||||
//! Öffnungs-Symbol im Grundriss ruft die Plan-Erzeugung im Kern direkt (`plan/walls.rs`).
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Tür-/Fenster-Symbol einer Öffnung im Grundriss; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn plan_opening_flat(buf: &[f64]) -> Vec<f64> {
|
||||
crate::plan_openings::plan_opening(buf)
|
||||
}
|
||||
|
||||
/// Fenster-Symbol (Rahmen, Glas, Flügel, Stulp) einer Öffnung; Unsinn/entartet → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn window_symbol_flat(buf: &[f64]) -> Vec<f64> {
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
//! Bindung des Treppen-Symbols im Grundriss (`crate::plan_stairs`). Ausgabe-Layout s. dort.
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Treppen-Parameter (16 Zahlen), Gesamt-Steighöhe, Schnitthöhe über der UK, Strichstärke (mm),
|
||||
/// gefüllter Pfeil (0/1) → Primitivliste; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn plan_stair_flat(params: &[f64], total_rise: f64, cut_rise: f64, lw_mm: f64, filled_arrow: f64) -> Vec<f64> {
|
||||
crate::plan_stairs::plan_stair(params, total_rise, cut_rise, lw_mm, filled_arrow != 0.0)
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
//! Bindungen von Wand-Poché und Decken-Umriss im Grundriss (`crate::plan_walls`). Layout s. dort.
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Wand-Poché-Geometrie einer Wand; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn plan_wall_poche_flat(buf: &[f64]) -> Vec<f64> {
|
||||
crate::plan_walls::wall_poche(buf)
|
||||
}
|
||||
|
||||
/// Freie Teilstücke eines Decken-Umrisses gegen Wand-Footprints; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn plan_ceiling_outline_flat(buf: &[f64]) -> Vec<f64> {
|
||||
crate::plan_walls::ceiling_outline(buf)
|
||||
}
|
||||
@@ -172,7 +172,7 @@ function wallDraft(points: Vec2[], cursor: Vec2 | null, thickness: number): Tool
|
||||
* Hängt je Achssegment ein `Wall` des aktiven Typs ans Projekt (immutabel). Höhe
|
||||
* aus dem aktiven Geschoss (floorHeight), Geschoss + Kategorie + Wandtyp aus dem
|
||||
* Context. Null-Strecken werden übersprungen. Gehrung an Ecken entsteht später
|
||||
* automatisch aus computeJoins (generatePlan).
|
||||
* automatisch aus der Verschneidung im Kern (`joins.rs`).
|
||||
*/
|
||||
function appendWalls(
|
||||
p: Project,
|
||||
|
||||
@@ -28,7 +28,8 @@ export type QueryName =
|
||||
| "scheduleRows"
|
||||
| "scheduleCsv"
|
||||
| "pickGeometry"
|
||||
| "model3dParts";
|
||||
| "model3dParts"
|
||||
| "planDomains";
|
||||
|
||||
export class ProjectDocument {
|
||||
private handle = 0;
|
||||
|
||||
@@ -1,454 +0,0 @@
|
||||
/**
|
||||
* Unit-Tests für die Wand-Gehrung (computeJoins / miterLine):
|
||||
* • Rechtwinklige L-Ecke: die Gehrung liegt auf der 45°-Diagonalen und trifft
|
||||
* die korrekten Fläche×Fläche-Apexe.
|
||||
* • SPITZE L-Ecke (Öffnungswinkel < 90°): die Gehrung muss weiterhin Außen mit
|
||||
* Außen und Innen mit Innen paaren. Die frühere Distanz-Heuristik kippte hier
|
||||
* und lieferte eine um 90° verdrehte Gehrung (Kreuz-Overlap der Poché-Bänder);
|
||||
* dieser Test fängt den Regress.
|
||||
* • T-Knoten (drei Wandenden am selben Punkt): das abzweigende Ende bekommt
|
||||
* einen Schnitt auf der zugewandten Fläche der Durchgangswand, die beiden
|
||||
* kollinearen Enden bleiben ungeschnitten.
|
||||
* • Mittelspannen-T-Stoß: ein freies Ende, das mitten auf die Seite einer
|
||||
* anderen Wand trifft, bekommt einen Schnitt auf deren Fläche; ohne Treffer
|
||||
* bleibt es rechtwinklig (null).
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { computeJoins, resolveJoinPriority } from "./joins";
|
||||
import { cross, len, sub } from "./geometry";
|
||||
import type { Line } from "./geometry";
|
||||
import type { Component, Project, Vec2, Wall } from "./types";
|
||||
|
||||
/** Abstand eines Punktes P von der unendlichen Geraden `line`. */
|
||||
function distToLine(line: Line, p: Vec2): number {
|
||||
return Math.abs(cross(line.dir, sub(p, line.point))) / len(line.dir);
|
||||
}
|
||||
|
||||
/** Minimalprojekt aus zwei Wänden mit einem Wandtyp gegebener Gesamtdicke. */
|
||||
function twoWallProject(w1: Wall, w2: Wall, thickness: number): Project {
|
||||
return {
|
||||
id: "t",
|
||||
name: "T",
|
||||
lineStyles: [],
|
||||
hatches: [],
|
||||
components: [{ id: "c", name: "C", color: "#ccc", hatchId: "none", joinPriority: 10 }],
|
||||
wallTypes: [
|
||||
{ id: "aw", name: "AW", layers: [{ componentId: "c", thickness }] },
|
||||
],
|
||||
drawingLevels: [
|
||||
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 },
|
||||
],
|
||||
layers: [{ code: "20", name: "Wände", color: "#0a0a0a", lw: 0.5, visible: true, locked: false }],
|
||||
walls: [w1, w2],
|
||||
openings: [],
|
||||
ceilings: [],
|
||||
stairs: [],
|
||||
rooms: [],
|
||||
drawings2d: [],
|
||||
context: [],
|
||||
};
|
||||
}
|
||||
|
||||
/** Minimalprojekt aus drei Wänden mit einem Wandtyp gegebener Gesamtdicke. */
|
||||
function threeWallProject(
|
||||
w1: Wall,
|
||||
w2: Wall,
|
||||
w3: Wall,
|
||||
thickness: number,
|
||||
): Project {
|
||||
const proj = twoWallProject(w1, w2, thickness);
|
||||
proj.walls = [w1, w2, w3];
|
||||
return proj;
|
||||
}
|
||||
|
||||
function wall(id: string, start: Vec2, end: Vec2): Wall {
|
||||
return {
|
||||
id,
|
||||
type: "wall",
|
||||
floorId: "eg",
|
||||
categoryCode: "20",
|
||||
start,
|
||||
end,
|
||||
wallTypeId: "aw",
|
||||
height: 2.6,
|
||||
};
|
||||
}
|
||||
|
||||
describe("computeJoins — Gehrung an der L-Ecke", () => {
|
||||
it("legt die rechtwinklige Gehrung auf die 45°-Diagonale (Fläche×Fläche-Apexe)", () => {
|
||||
// W1 (0,0)→(5,0), W2 (5,0)→(5,4); Knoten (5,0). T=0.4, half=0.2.
|
||||
const proj = twoWallProject(
|
||||
wall("W1", { x: 0, y: 0 }, { x: 5, y: 0 }),
|
||||
wall("W2", { x: 5, y: 0 }, { x: 5, y: 4 }),
|
||||
0.4,
|
||||
);
|
||||
const joins = computeJoins(proj, proj.walls);
|
||||
const cut = joins.get("W1")!.endCut;
|
||||
expect(cut).not.toBeNull();
|
||||
// Außen-Apex (5.2,−0.2) und Innen-Apex (4.8,0.2) liegen auf der Gehrung;
|
||||
// Richtung ist die 45°-Diagonale.
|
||||
expect(distToLine(cut!, { x: 5.2, y: -0.2 })).toBeCloseTo(0, 6);
|
||||
expect(distToLine(cut!, { x: 4.8, y: 0.2 })).toBeCloseTo(0, 6);
|
||||
expect(Math.abs(cut!.dir.x)).toBeCloseTo(Math.abs(cut!.dir.y), 6);
|
||||
});
|
||||
|
||||
it("paart bei SPITZEM Winkel Außen-mit-Außen und Innen-mit-Innen (kein Kreuz-Overlap)", () => {
|
||||
// Symmetrische V-Ecke, Knoten (0,0), Öffnungswinkel 60° (spitz), nach oben.
|
||||
// Beide Wandkörper laufen unter ±30° zur +y-Achse aus:
|
||||
// gA = (−sin30, cos30) = (−0.5, √3/2), gB = (+0.5, √3/2).
|
||||
// W_A: end im Knoten (start = gA·2), W_B: start im Knoten (end = gB·2).
|
||||
const s3 = Math.sqrt(3) / 2;
|
||||
const proj = twoWallProject(
|
||||
wall("WA", { x: -1, y: 2 * s3 }, { x: 0, y: 0 }),
|
||||
wall("WB", { x: 0, y: 0 }, { x: 1, y: 2 * s3 }),
|
||||
0.4,
|
||||
);
|
||||
const joins = computeJoins(proj, proj.walls);
|
||||
// Beide Wände teilen dieselbe Gehrung; WA endet im Knoten, WB startet dort.
|
||||
const cut = joins.get("WA")!.endCut ?? joins.get("WB")!.startCut;
|
||||
expect(cut).not.toBeNull();
|
||||
|
||||
// Korrekt: Außen-Apex (0,−0.4) und Innen-Apex (0,0.4) → vertikale Gehrung
|
||||
// (Richtung parallel zur y-Achse). Die buggy Distanz-Heuristik lieferte
|
||||
// stattdessen eine HORIZONTALE Gehrung (Apexe (±0.23,0)) → hier rot.
|
||||
expect(distToLine(cut!, { x: 0, y: -0.4 })).toBeCloseTo(0, 6);
|
||||
expect(distToLine(cut!, { x: 0, y: 0.4 })).toBeCloseTo(0, 6);
|
||||
// Gehrung vertikal: dir.x ≈ 0 (die falsche, horizontale Gehrung hätte dir.y ≈ 0).
|
||||
const dir = cut!.dir;
|
||||
expect(Math.abs(dir.x) / len(dir)).toBeCloseTo(0, 6);
|
||||
});
|
||||
});
|
||||
|
||||
describe("computeJoins — T-Knoten (drei Wandenden am selben Punkt)", () => {
|
||||
it("schneidet nur das abzweigende Ende, auf der zugewandten Fläche der Durchgangswand", () => {
|
||||
// Durchgangswand in zwei Hälften WA1 (0,0)→(5,0) und WA2 (5,0)→(10,0),
|
||||
// Abzweig WB (5,0)→(5,3) nach oben. T=0.4 → halbe Dicke 0.2.
|
||||
const proj = threeWallProject(
|
||||
wall("WA1", { x: 0, y: 0 }, { x: 5, y: 0 }),
|
||||
wall("WA2", { x: 5, y: 0 }, { x: 10, y: 0 }),
|
||||
wall("WB", { x: 5, y: 0 }, { x: 5, y: 3 }),
|
||||
0.4,
|
||||
);
|
||||
const joins = computeJoins(proj, proj.walls);
|
||||
|
||||
// Die kollinearen Hälften der Durchgangswand bleiben ungeschnitten.
|
||||
expect(joins.get("WA1")!.endCut).toBeNull();
|
||||
expect(joins.get("WA2")!.startCut).toBeNull();
|
||||
|
||||
// Der Abzweig bekommt einen Schnitt auf der ihm zugewandten (oberen)
|
||||
// Fläche der Durchgangswand: die horizontale Gerade y = 0.2.
|
||||
const cut = joins.get("WB")!.startCut;
|
||||
expect(cut).not.toBeNull();
|
||||
expect(distToLine(cut!, { x: 5, y: 0.2 })).toBeCloseTo(0, 6);
|
||||
expect(distToLine(cut!, { x: 0, y: 0.2 })).toBeCloseTo(0, 6);
|
||||
// Gehrungsgerade horizontal (parallel zur Durchgangsachse).
|
||||
expect(Math.abs(cut!.dir.y) / len(cut!.dir)).toBeCloseTo(0, 6);
|
||||
});
|
||||
});
|
||||
|
||||
describe("computeJoins — Mittelspannen-T-Stoß (Ende trifft Wandseite)", () => {
|
||||
it("schneidet ein freies Ende, das auf die Seite einer anderen Wand trifft, entlang deren Fläche", () => {
|
||||
// Durchgangswand W (0,0)→(10,0), T=0.4 → halbe Dicke 0.2. Abzweig WB2
|
||||
// trifft mit seinem freien Ende (4, 0.2) genau auf die obere Fläche.
|
||||
const proj = threeWallProject(
|
||||
wall("W", { x: 0, y: 0 }, { x: 10, y: 0 }),
|
||||
wall("WB2", { x: 4, y: 3 }, { x: 4, y: 0.2 }),
|
||||
wall("Filler", { x: 100, y: 100 }, { x: 100, y: 103 }), // unbeteiligt
|
||||
0.4,
|
||||
);
|
||||
const joins = computeJoins(proj, proj.walls);
|
||||
|
||||
const cut = joins.get("WB2")!.endCut;
|
||||
expect(cut).not.toBeNull();
|
||||
expect(distToLine(cut!, { x: 0, y: 0.2 })).toBeCloseTo(0, 6);
|
||||
expect(distToLine(cut!, { x: 5, y: 0.2 })).toBeCloseTo(0, 6);
|
||||
expect(Math.abs(cut!.dir.y) / len(cut!.dir)).toBeCloseTo(0, 6);
|
||||
|
||||
// Die Wand W selbst bleibt an ihren (freien) Enden ungeschnitten.
|
||||
expect(joins.get("W")!.startCut).toBeNull();
|
||||
expect(joins.get("W")!.endCut).toBeNull();
|
||||
// Das obere, unbeteiligte Ende von WB2 bleibt ebenfalls ungeschnitten.
|
||||
expect(joins.get("WB2")!.startCut).toBeNull();
|
||||
});
|
||||
|
||||
it("lässt ein freies Ende rechtwinklig (null), wenn keine Wand nah genug getroffen wird", () => {
|
||||
// Gleiche Anordnung, aber Abzweig-Ende bei y=0.5 — außerhalb der
|
||||
// Wandfläche (Dicke/2 + Toleranz = 0.201).
|
||||
const proj = twoWallProject(
|
||||
wall("W", { x: 0, y: 0 }, { x: 10, y: 0 }),
|
||||
wall("WB3", { x: 4, y: 3 }, { x: 4, y: 0.5 }),
|
||||
0.4,
|
||||
);
|
||||
const joins = computeJoins(proj, proj.walls);
|
||||
expect(joins.get("WB3")!.endCut).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("computeJoins — „+\"-Kreuzung (zwei kollineare Enden kreuzen eine durchlaufende Wand)", () => {
|
||||
it("schneidet BEIDE kollinearen Hälften gegen die jeweils zugewandte (gegenüberliegende) Fläche der durchlaufenden Wand", () => {
|
||||
// Vertikale Durchgangswand V (6,2)→(6,11), T=0.3 → halbe Dicke 0.15. Zwei
|
||||
// kollineare horizontale Hälften HL (0,6)→(6,6) und HR (6,6)→(12,6) treffen
|
||||
// sich exakt AUF DER ACHSE von V (x=6) — eine reale „+"-Kreuzung, wie sie
|
||||
// beim Zeichnen einer durchlaufenden Trennwand entsteht, die von einer
|
||||
// weiteren durchlaufenden Wand gekreuzt wird (Regressionstest für den per
|
||||
// Massstabsprobe gefundenen Bug: vorher blieb V für Fall 1 unsichtbar, weil
|
||||
// sie an diesem Punkt keinen eigenen Endpunkt hat, und Fall 2 prüfte nur
|
||||
// echte EINZEL-Enden — HL/HR bekamen dadurch gar keinen Schnitt).
|
||||
const proj = threeWallProject(
|
||||
wall("V", { x: 6, y: 2 }, { x: 6, y: 11 }),
|
||||
wall("HL", { x: 0, y: 6 }, { x: 6, y: 6 }),
|
||||
wall("HR", { x: 6, y: 6 }, { x: 12, y: 6 }),
|
||||
0.3,
|
||||
);
|
||||
const joins = computeJoins(proj, proj.walls);
|
||||
|
||||
// Die Durchgangswand V bleibt an ihren (freien) Enden unangetastet.
|
||||
expect(joins.get("V")!.startCut).toBeNull();
|
||||
expect(joins.get("V")!.endCut).toBeNull();
|
||||
|
||||
// HL läuft nach −x aus → Schnitt an der LINKEN Fläche von V (x=5.85).
|
||||
const cutL = joins.get("HL")!.endCut;
|
||||
expect(cutL).not.toBeNull();
|
||||
expect(distToLine(cutL!, { x: 5.85, y: 2 })).toBeCloseTo(0, 6);
|
||||
expect(distToLine(cutL!, { x: 5.85, y: 11 })).toBeCloseTo(0, 6);
|
||||
|
||||
// HR läuft nach +x aus → Schnitt an der RECHTEN Fläche von V (x=6.15) —
|
||||
// die GEGENÜBERLIEGENDE Fläche, nicht dieselbe wie HL (der eigentliche Bug:
|
||||
// beide Enden teilen sich denselben Kreuzungspunkt, `perp` allein kann sie
|
||||
// nicht unterscheiden — erst die eigene Auslaufrichtung tut das).
|
||||
const cutR = joins.get("HR")!.startCut;
|
||||
expect(cutR).not.toBeNull();
|
||||
expect(distToLine(cutR!, { x: 6.15, y: 2 })).toBeCloseTo(0, 6);
|
||||
expect(distToLine(cutR!, { x: 6.15, y: 11 })).toBeCloseTo(0, 6);
|
||||
expect(distToLine(cutL!, { x: 6.15, y: 6 })).not.toBeCloseTo(0, 3);
|
||||
});
|
||||
|
||||
it("lässt einen echten Stern-Knoten (4 Wandenden treffen sich, keine läuft durch) weiterhin rechtwinklig", () => {
|
||||
// Vier Wand-STUMMEL enden alle exakt bei (5,5), keiner läuft darüber
|
||||
// hinaus weiter — kein Durchgang erkennbar, bewusst dokumentierte
|
||||
// Restlücke (s. Kommentar in computeJoins).
|
||||
const proj: Project = twoWallProject(
|
||||
wall("A", { x: 0, y: 5 }, { x: 5, y: 5 }),
|
||||
wall("B", { x: 5, y: 5 }, { x: 10, y: 5 }),
|
||||
0.3,
|
||||
);
|
||||
proj.walls.push(
|
||||
wall("C", { x: 5, y: 5 }, { x: 5, y: 0 }),
|
||||
wall("D", { x: 5, y: 5 }, { x: 5, y: 10 }),
|
||||
);
|
||||
const joins = computeJoins(proj, proj.walls);
|
||||
for (const id of ["A", "B", "C", "D"]) {
|
||||
const c = joins.get(id)!;
|
||||
expect(c.startCut ?? c.endCut).toBeNull();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveJoinPriority — Ordnungslogik zweier Bauteile am Stoss", () => {
|
||||
const brick: Component = { id: "brick", name: "Backstein", color: "#8c5544", hatchId: "none", joinPriority: 50 };
|
||||
const brick2: Component = { id: "brick", name: "Backstein (Kopie)", color: "#000", hatchId: "none", joinPriority: 50 };
|
||||
const render: Component = { id: "render", name: "Putz", color: "#efece6", hatchId: "none", joinPriority: 10 };
|
||||
const insulation: Component = { id: "insulation", name: "Dämmung", color: "#fff", hatchId: "none", joinPriority: 20 };
|
||||
const concrete: Component = { id: "concrete", name: "Beton", color: "#9aa0a6", hatchId: "none", joinPriority: 100 };
|
||||
|
||||
it("verschmilzt bei gleicher Priorität UND gleicher Komponente", () => {
|
||||
expect(resolveJoinPriority(brick, brick2)).toBe("merge");
|
||||
});
|
||||
|
||||
it("koexistiert bei gleicher Priorität, aber verschiedener Komponente", () => {
|
||||
// Zwei fiktive Komponenten mit zufällig gleicher Priorität, aber
|
||||
// unterschiedlicher Identität — keine eindeutige Rangfolge.
|
||||
const other: Component = { id: "other-30", name: "X", color: "#123", hatchId: "none", joinPriority: 20 };
|
||||
expect(resolveJoinPriority(insulation, other)).toBe("coexist");
|
||||
});
|
||||
|
||||
it("lässt die höhere Priorität gewinnen (die niedrigere wird getrimmt)", () => {
|
||||
expect(resolveJoinPriority(render, brick)).toBe("trim-a"); // a=Putz verliert
|
||||
expect(resolveJoinPriority(brick, render)).toBe("trim-b"); // b=Putz verliert
|
||||
expect(resolveJoinPriority(concrete, brick)).toBe("trim-b");
|
||||
expect(resolveJoinPriority(brick, concrete)).toBe("trim-a");
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Minimalprojekt mit einem mehrschichtigen, W9-artigen Wandtyp
|
||||
* (Innenputz/Backstein-Kern/Innenputz, wie `sampleProject`s "iw") — für die
|
||||
* materialbewusste T-Stoss-Erweiterung (layerCuts).
|
||||
*/
|
||||
function layeredWallProject(w1: Wall, w2: Wall, w3: Wall): Project {
|
||||
return {
|
||||
id: "t",
|
||||
name: "T",
|
||||
lineStyles: [],
|
||||
hatches: [],
|
||||
components: [
|
||||
{ id: "render-int", name: "Innenputz", color: "#efece6", hatchId: "none", joinPriority: 10 },
|
||||
{ id: "brick", name: "Backstein", color: "#8c5544", hatchId: "none", joinPriority: 50 },
|
||||
],
|
||||
wallTypes: [
|
||||
{
|
||||
id: "iw",
|
||||
name: "Innenwand",
|
||||
layers: [
|
||||
{ componentId: "render-int", thickness: 0.015 },
|
||||
{ componentId: "brick", thickness: 0.12 },
|
||||
{ componentId: "render-int", thickness: 0.015 },
|
||||
],
|
||||
},
|
||||
],
|
||||
drawingLevels: [
|
||||
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 },
|
||||
],
|
||||
layers: [{ code: "20", name: "Wände", color: "#0a0a0a", lw: 0.5, visible: true, locked: false }],
|
||||
walls: [w1, w2, w3],
|
||||
openings: [],
|
||||
ceilings: [],
|
||||
stairs: [],
|
||||
rooms: [],
|
||||
drawings2d: [],
|
||||
context: [],
|
||||
};
|
||||
}
|
||||
|
||||
function iwWall(id: string, start: Vec2, end: Vec2): Wall {
|
||||
return {
|
||||
id,
|
||||
type: "wall",
|
||||
floorId: "eg",
|
||||
categoryCode: "20",
|
||||
start,
|
||||
end,
|
||||
wallTypeId: "iw",
|
||||
height: 2.6,
|
||||
};
|
||||
}
|
||||
|
||||
describe("computeJoins — materialbewusster T-Stoss (layerCuts)", () => {
|
||||
it("W9-artiger T-Knoten: Backstein-Kern des Abzweigs sticht bis zur Rückgrat-Nahfläche durch, Putz wird getrimmt — materialgleicher Nah-Putz ⇒ KEINE L-Trennnaht", () => {
|
||||
// Durchgangswand WA1 (0,0)→(5,0) / WA2 (5,0)→(10,0), Abzweig WB (5,0)→(5,3),
|
||||
// alle vom selben Wandtyp "iw" (Innenputz/Backstein/Innenputz, T=0.15).
|
||||
const proj = layeredWallProject(
|
||||
iwWall("WA1", { x: 0, y: 0 }, { x: 5, y: 0 }),
|
||||
iwWall("WA2", { x: 5, y: 0 }, { x: 10, y: 0 }),
|
||||
iwWall("WB", { x: 5, y: 0 }, { x: 5, y: 3 }),
|
||||
);
|
||||
const joins = computeJoins(proj, proj.walls);
|
||||
const cuts = joins.get("WB")!;
|
||||
|
||||
// Aggregat-Cut bleibt unverändert (bit-identisch zum bisherigen Verhalten).
|
||||
expect(cuts.startCut).not.toBeNull();
|
||||
expect(distToLine(cuts.startCut!, { x: 5, y: 0.075 })).toBeCloseTo(0, 6);
|
||||
|
||||
// layerCuts ist gesetzt (mindestens eine Schicht verschmilzt).
|
||||
expect(cuts.layerCuts).toBeDefined();
|
||||
const lc = cuts.layerCuts!;
|
||||
expect(lc.start.length).toBe(3);
|
||||
|
||||
// Schicht 1 (Backstein-Kern, Index 1) verschmilzt: Cut an der Nahfläche des
|
||||
// Durchgangs-Rückgrats — NICHT null (Achse) und NICHT die Aggregat-Nahfläche
|
||||
// (0.075). Durchgangswand-Halbdicke 0.075 minus Nah-Putz 0.015 → y = 0.06.
|
||||
expect(lc.start[1]).not.toBeNull();
|
||||
expect(distToLine(lc.start[1]!, { x: 5, y: 0.06 })).toBeCloseTo(0, 6);
|
||||
expect(distToLine(lc.start[1]!, { x: 0, y: 0.06 })).toBeCloseTo(0, 6);
|
||||
// Der Kern läuft NICHT bis zur Achse (y=0) durch.
|
||||
expect(distToLine(lc.start[1]!, { x: 5, y: 0 })).not.toBeCloseTo(0, 6);
|
||||
expect(lc.startSide[1]).toBeNull();
|
||||
|
||||
// Schichten 0 und 2 (Innenputz) werden getrimmt: derselbe Nahflächen-Cut
|
||||
// wie das Aggregat...
|
||||
expect(lc.start[0]).not.toBeNull();
|
||||
expect(lc.start[2]).not.toBeNull();
|
||||
expect(distToLine(lc.start[0]!, { x: 5, y: 0.075 })).toBeCloseTo(0, 6);
|
||||
expect(distToLine(lc.start[2]!, { x: 5, y: 0.075 })).toBeCloseTo(0, 6);
|
||||
// ... aber KEINE L-Seitenlinie: der Nah-Putz der Durchgangswand ist
|
||||
// materialgleicher Innenputz und füllt den getrimmten Abzweig-Putz an den
|
||||
// Flanken durchgehend (der spanCutout schneidet nur die Kernbreite aus).
|
||||
// Es entsteht ein durchgehendes Putz-L ohne Trennnaht. Nur bei material-
|
||||
// FREMDEM Nah-Putz stünde hier eine L-Linie.
|
||||
expect(lc.startSide[0]).toBeNull();
|
||||
expect(lc.startSide[2]).toBeNull();
|
||||
|
||||
// Die kollinearen Hälften der Durchgangswand bleiben bei den layerCuts
|
||||
// unangetastet (keine Pro-Schicht-Cuts für sie).
|
||||
expect(joins.get("WA1")!.layerCuts).toBeUndefined();
|
||||
expect(joins.get("WA2")!.layerCuts).toBeUndefined();
|
||||
|
||||
// Die als Durchgang gewählte Wandhälfte bekommt eine Durchgangswand-Aussparung
|
||||
// (Phase 1c): über die Backstein-Kernbreite (0.12) im Nah-Putz-Bereich
|
||||
// (Offset 0.06…0.075). Welche Hälfte den Durchgang bildet, hängt von der
|
||||
// Knoten-Reihenfolge ab — wir prüfen die, die den Cutout trägt.
|
||||
const throughCuts = joins.get("WA1")!.spanCutouts ?? joins.get("WA2")!.spanCutouts;
|
||||
expect(throughCuts).toBeDefined();
|
||||
expect(throughCuts!.length).toBe(1);
|
||||
const sc = throughCuts![0];
|
||||
// Achsen-Intervall: Kernbreite 0.12, zentriert am Knoten (x=5 → [4.94,5.06]).
|
||||
expect(sc.to - sc.from).toBeCloseTo(0.12, 6);
|
||||
// offA = Nahfläche (0.075), offB = Rückgrat-Nahfläche (0.06).
|
||||
expect(sc.offA).toBeCloseTo(0.075, 6);
|
||||
expect(sc.offB).toBeCloseTo(0.06, 6);
|
||||
// Der Abzweig selbst trägt keine Aussparung (die gehört der Durchgangswand).
|
||||
expect(joins.get("WB")!.spanCutouts).toBeUndefined();
|
||||
// L-Ecke bzw. Wände ohne T bleiben cutout-frei (die kollineare Nicht-Durchgangs-
|
||||
// Hälfte hat keinen Cutout).
|
||||
expect(
|
||||
joins.get("WA1")!.spanCutouts === undefined ||
|
||||
joins.get("WA2")!.spanCutouts === undefined,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("Mittelspannen-T-Stoss: die Durchgangswand bekommt einen spanCutout mit korrekter Kernbreite und Nah-Putz-Offsetzone", () => {
|
||||
// Realer W9-Fall: Durchgangswand als EINE Wand W (0,0)→(10,0), Abzweig WB
|
||||
// trifft mit seinem freien Ende (4,0) mittig auf ihre Seite. Beide iw.
|
||||
const proj = layeredWallProject(
|
||||
iwWall("W", { x: 0, y: 0 }, { x: 10, y: 0 }),
|
||||
iwWall("WB", { x: 4, y: 3 }, { x: 4, y: 0 }),
|
||||
iwWall("Filler", { x: 100, y: 100 }, { x: 100, y: 103 }), // unbeteiligt
|
||||
);
|
||||
const joins = computeJoins(proj, proj.walls);
|
||||
|
||||
const wCuts = joins.get("W")!;
|
||||
expect(wCuts.spanCutouts).toBeDefined();
|
||||
expect(wCuts.spanCutouts!.length).toBe(1);
|
||||
const sc = wCuts.spanCutouts![0];
|
||||
// Intervall um x=4, Breite = Kernbreite 0.12 → [3.94, 4.06].
|
||||
expect(sc.from).toBeCloseTo(3.94, 6);
|
||||
expect(sc.to).toBeCloseTo(4.06, 6);
|
||||
expect(sc.offA).toBeCloseTo(0.075, 6);
|
||||
expect(sc.offB).toBeCloseTo(0.06, 6);
|
||||
// Der Abzweig und die unbeteiligte Wand tragen keine Aussparung.
|
||||
expect(joins.get("WB")!.spanCutouts).toBeUndefined();
|
||||
expect(joins.get("Filler")!.spanCutouts).toBeUndefined();
|
||||
});
|
||||
|
||||
it("L-Ecke und einfacher (nicht materialbewusster) Stoss bekommen KEINEN spanCutout", () => {
|
||||
// Reine L-Ecke zweier Wände: keine Durchgangswand, kein Durchstoss.
|
||||
const proj = twoWallProject(
|
||||
wall("L1", { x: 0, y: 0 }, { x: 5, y: 0 }),
|
||||
wall("L2", { x: 5, y: 0 }, { x: 5, y: 4 }),
|
||||
0.4,
|
||||
);
|
||||
const joins = computeJoins(proj, proj.walls);
|
||||
expect(joins.get("L1")!.spanCutouts).toBeUndefined();
|
||||
expect(joins.get("L2")!.spanCutouts).toBeUndefined();
|
||||
});
|
||||
|
||||
it("setzt layerCuts NICHT, wenn kein Bauteil des Abzweigs mit dem Rückgrat der Durchgangswand übereinstimmt", () => {
|
||||
// Gleiche Anordnung, aber der Abzweig ist eine reine Einschicht-Wand ohne
|
||||
// Materialübereinstimmung zum Backstein-Rückgrat → Default-Verhalten.
|
||||
const proj = layeredWallProject(
|
||||
iwWall("WA1", { x: 0, y: 0 }, { x: 5, y: 0 }),
|
||||
iwWall("WA2", { x: 5, y: 0 }, { x: 10, y: 0 }),
|
||||
iwWall("WB", { x: 5, y: 0 }, { x: 5, y: 3 }),
|
||||
);
|
||||
proj.wallTypes.push({
|
||||
id: "solo",
|
||||
name: "Solo",
|
||||
layers: [{ componentId: "render-int", thickness: 0.1 }],
|
||||
});
|
||||
proj.walls[2] = { ...proj.walls[2], wallTypeId: "solo" };
|
||||
const joins = computeJoins(proj, proj.walls);
|
||||
expect(joins.get("WB")!.layerCuts).toBeUndefined();
|
||||
expect(joins.get("WB")!.startCut).not.toBeNull(); // Aggregat-Cut bleibt normal
|
||||
});
|
||||
});
|
||||
@@ -1,196 +0,0 @@
|
||||
// Wand-Verschneidung (Gehrung): an einer Ecke, wo zwei Wände aufeinander
|
||||
// treffen, sollen sich die Schicht-Bänder nicht überlappen, sondern an einer
|
||||
// gemeinsamen Gehrungslinie sauber stoßen. Pro Wand entstehen die optionalen
|
||||
// Schnittlinien an Start- und Endpunkt.
|
||||
//
|
||||
// Gerechnet wird im Rust-Kern (`src-tauri/core/src/joins.rs`); hier bleiben die
|
||||
// Typen, das Sammeln der Wand-Angaben aus dem `Project` und die flache Übergabe.
|
||||
|
||||
import type { Component, Project, Wall } from "./types";
|
||||
import { getComponent, getWallType } from "./types";
|
||||
import type { Line } from "./geometry";
|
||||
import { core } from "../engine/coreWasm";
|
||||
import { FlatReader, FlatWriter } from "../geometry/coreFlat";
|
||||
|
||||
/**
|
||||
* Pro-Schicht-Override der Nahflächen-Cuts (materialbewusster T-Stoss, siehe
|
||||
* {@link resolveJoinPriority}). Index = Schicht-Index im Wandtyp DIESER Wand
|
||||
* (der Abzweig-Wand). `start`/`end` ersetzen — wo gesetzt — den einheitlichen
|
||||
* `startCut`/`endCut` NUR für die jeweilige Schicht; `null` an einem Index
|
||||
* heisst: diese Schicht bekommt KEINEN Cut (verschmilzt, läuft durch).
|
||||
* `startSide`/`endSide` tragen die zusätzliche seitliche Cut-Linie einer
|
||||
* getrimmten Schicht, die an eine verschmelzende Nachbarschicht angrenzt
|
||||
* (L-Anschluss, z. B. Putz neben durchlaufendem Backstein-Kern).
|
||||
*/
|
||||
export interface LayerCuts {
|
||||
start: (Line | null)[];
|
||||
end: (Line | null)[];
|
||||
startSide: (Line | null)[];
|
||||
endSide: (Line | null)[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Aussparung der DURCHGANGSWAND an einem materialbewussten T-Stoss: über das
|
||||
* Achsen-Intervall `[from,to]` (Meter ab `wall.start` entlang der Achse) und den
|
||||
* Quer-Offsetbereich `[offA,offB]` wird die Nah-Putz-Zone der Durchgangswand
|
||||
* echt ausgeschnitten, damit der durchstechende Abzweig-Kern (Phase 1b) die
|
||||
* Durchgangswand nicht nur übermalt, sondern geometrisch aufbricht.
|
||||
*
|
||||
* OFFSET-KONVENTION (identisch zu den Schicht-Bändern in `addWallPoche`):
|
||||
* `offA`/`offB` sind Querabstände von der Wandachse ENTLANG der linken Normalen
|
||||
* `leftNormal(dir)`, inkl. Referenzversatz — also im selben Bereich wie
|
||||
* `refOff − total/2` (außen) … `refOff + total/2` (innen). `offA` ist stets die
|
||||
* NAHFLÄCHE (Wandoberfläche, `refOff + sign·total/2`), `offB` die dem Abzweig
|
||||
* zugewandte Fläche des Rückgrat-KERNS (`refOff + sign·(total/2 − nearPlaster)`)
|
||||
* — die Zone dazwischen ist exakt der Nah-Putz, den der Abzweig-Kern durchstösst.
|
||||
* `from ≤ to` ist die Projektion der Abzweig-Kernbreite auf die Durchgangsachse.
|
||||
*/
|
||||
export interface SpanCutout {
|
||||
from: number;
|
||||
to: number;
|
||||
offA: number;
|
||||
offB: number;
|
||||
}
|
||||
|
||||
/** Schnittlinien einer Wand an ihren beiden Achsenden. */
|
||||
export interface WallCuts {
|
||||
startCut: Line | null;
|
||||
endCut: Line | null;
|
||||
/**
|
||||
* Additive Erweiterung: fehlt dieses Feld, gilt weiterhin `startCut`/
|
||||
* `endCut` für ALLE Schichten (bisheriges Verhalten, bit-identisch). Wird
|
||||
* nur gesetzt, wenn an einem T-Stoss mindestens eine Schicht materialbewusst
|
||||
* verschmilzt (siehe {@link resolveJoinPriority}).
|
||||
*/
|
||||
layerCuts?: LayerCuts;
|
||||
/**
|
||||
* Additive Erweiterung (Durchgangswand-Seite): Aussparungen der Nah-Putz-Zone,
|
||||
* durch die ein Abzweig-Kern sticht. Fehlt/leer ⇒ die Wand wird unverändert
|
||||
* gezeichnet. Wird nur an der DURCHGANGSWAND gesetzt (nie am Abzweig), analog
|
||||
* additiv zu {@link layerCuts}. Siehe {@link SpanCutout}.
|
||||
*/
|
||||
spanCutouts?: SpanCutout[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Verschneidungs-Entscheidung zweier Bauteile (Komponenten) am Stoss:
|
||||
* • "merge" — gleiche Priorität UND gleiche Komponente (z. B. Backstein-
|
||||
* Kern trifft Backstein-Kern): die Schichten verschmelzen, kein Cut.
|
||||
* • "coexist" — gleiche Priorität, aber VERSCHIEDENE Komponente: keine
|
||||
* eindeutige Rangfolge, bleibt beim heutigen (getrimmten) Verhalten.
|
||||
* • "trim-a" — `b` hat die höhere Priorität und gewinnt; `a` wird getrimmt.
|
||||
* • "trim-b" — `a` hat die höhere Priorität und gewinnt; `b` wird getrimmt.
|
||||
*/
|
||||
export type JoinPriorityResolution = "merge" | "trim-a" | "trim-b" | "coexist";
|
||||
|
||||
const RESOLUTIONS: JoinPriorityResolution[] = ["merge", "trim-a", "trim-b", "coexist"];
|
||||
|
||||
export function resolveJoinPriority(
|
||||
a: Component,
|
||||
b: Component,
|
||||
): JoinPriorityResolution {
|
||||
return RESOLUTIONS[core().join_priority_resolution(a.joinPriority, b.joinPriority, a.id === b.id)] ?? "coexist";
|
||||
}
|
||||
|
||||
/**
|
||||
* Berechnet für jede Wand die Gehrungs-/Anschluss-Schnittlinien.
|
||||
* Behandelt werden: L-Ecken (genau zwei Wandenden treffen sich), T-Knoten
|
||||
* (drei Wandenden treffen sich, zwei davon kollinear), Mittelspannen-T-Stöße
|
||||
* (ein freies Wandende trifft auf die Seite einer anderen Wand) UND „+"-
|
||||
* Kreuzungen (zwei kollineare Wandenden treffen sich exakt auf der Achse einer
|
||||
* dritten, durchlaufenden Wand). Echte Stern-Knoten (vier oder mehr Wand-
|
||||
* STUMMEL am selben Punkt, keiner als Durchgang erkennbar) bleiben rechtwinklig.
|
||||
* An T-Stössen kommen die materialbewussten Pro-Schicht-Cuts (`layerCuts`) und
|
||||
* die Nah-Putz-Aussparungen der Durchgangswand (`spanCutouts`) dazu.
|
||||
*
|
||||
* `walls` ist die bereits gefilterte Wandmenge (z. B. ein Geschoss); die
|
||||
* Gehrung wird nur innerhalb dieser Menge gebildet. Wirft wie früher, wenn ein
|
||||
* benötigter Wandtyp oder ein Bauteil unbekannt ist.
|
||||
*/
|
||||
export function computeJoins(
|
||||
project: Project,
|
||||
walls: Wall[],
|
||||
): Map<string, WallCuts> {
|
||||
const w = new FlatWriter().num(walls.length);
|
||||
const compIndex = new Map<string, number>();
|
||||
for (const wall of walls) {
|
||||
w.num(wall.start.x, wall.start.y, wall.end.x, wall.end.y);
|
||||
if (wall.referenceOffset != null) w.num(3, wall.referenceOffset);
|
||||
else w.num(wall.referenceLine === "left" ? 1 : wall.referenceLine === "right" ? 2 : 0, 0);
|
||||
const wt = project.wallTypes.find((t) => t.id === wall.wallTypeId);
|
||||
if (!wt) {
|
||||
w.num(0, 0);
|
||||
continue;
|
||||
}
|
||||
w.num(1, wt.layers.length);
|
||||
for (const l of wt.layers) {
|
||||
const comp = project.components.find((c) => c.id === l.componentId);
|
||||
let idx = -1;
|
||||
if (comp) {
|
||||
idx = compIndex.get(comp.id) ?? compIndex.size;
|
||||
compIndex.set(comp.id, idx);
|
||||
}
|
||||
w.num(l.thickness, idx, comp ? comp.joinPriority : Number.NaN);
|
||||
}
|
||||
}
|
||||
const out = core().compute_joins_flat(w.done());
|
||||
const r = new FlatReader(out);
|
||||
const status = r.num();
|
||||
if (status === 1) {
|
||||
// Wandtyp oder Bauteil unbekannt: denselben Fehler werfen wie die Modell-Helfer.
|
||||
const bad = walls[r.num()];
|
||||
if (bad) for (const l of getWallType(project, bad).layers) getComponent(project, l.componentId);
|
||||
throw new Error("computeJoins: unbekannter Wandtyp oder Bauteil");
|
||||
}
|
||||
const result = new Map<string, WallCuts>();
|
||||
if (status !== 0) {
|
||||
// Kaputte Eingabe (z. B. NaN-Koordinaten): keine Verschneidung.
|
||||
for (const wall of walls) result.set(wall.id, { startCut: null, endCut: null });
|
||||
return result;
|
||||
}
|
||||
for (const wall of walls) result.set(wall.id, readWallCuts(r));
|
||||
return result;
|
||||
}
|
||||
|
||||
// ── Flache Kodierung der Cuts (s. `joins.rs`), auch für `toWalls3d/bands.ts` ──
|
||||
|
||||
function writeLine(w: FlatWriter, l: Line | null | undefined): void {
|
||||
if (l) w.num(1, l.point.x, l.point.y, l.dir.x, l.dir.y);
|
||||
else w.num(0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
function readLine(r: FlatReader): Line | null {
|
||||
const set = r.num();
|
||||
const point = { x: r.num(), y: r.num() };
|
||||
const dir = { x: r.num(), y: r.num() };
|
||||
return set === 1 ? { point, dir } : null;
|
||||
}
|
||||
|
||||
/** Hängt die Cuts einer Wand flach an (fehlend = keine Cuts). */
|
||||
export function writeWallCuts(w: FlatWriter, cuts: WallCuts | undefined): void {
|
||||
writeLine(w, cuts?.startCut);
|
||||
writeLine(w, cuts?.endCut);
|
||||
const lc = cuts?.layerCuts;
|
||||
const n = lc ? lc.start.length : 0;
|
||||
w.num(n);
|
||||
if (lc) for (const arr of [lc.start, lc.end, lc.startSide, lc.endSide]) for (let i = 0; i < n; i++) writeLine(w, arr[i]);
|
||||
const sc = cuts?.spanCutouts ?? [];
|
||||
w.num(sc.length);
|
||||
for (const s of sc) w.num(s.from, s.to, s.offA, s.offB);
|
||||
}
|
||||
|
||||
/** Liest die Cuts einer Wand; `layerCuts`/`spanCutouts` nur, wenn vorhanden. */
|
||||
export function readWallCuts(r: FlatReader): WallCuts {
|
||||
const cuts: WallCuts = { startCut: readLine(r), endCut: readLine(r) };
|
||||
const n = r.count();
|
||||
if (n > 0) {
|
||||
const arr = () => Array.from({ length: n }, () => readLine(r));
|
||||
cuts.layerCuts = { start: arr(), end: arr(), startSide: arr(), endSide: arr() };
|
||||
}
|
||||
const m = r.count();
|
||||
if (m > 0) {
|
||||
cuts.spanCutouts = [];
|
||||
for (let k = 0; k < m; k++) cuts.spanCutouts.push({ from: r.num(), to: r.num(), offA: r.num(), offB: r.num() });
|
||||
}
|
||||
return cuts;
|
||||
}
|
||||
+1
-103
@@ -1,11 +1,5 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
defaultRoomStamp,
|
||||
roomStampToDoc,
|
||||
roomStampExtraLines,
|
||||
roomDisplayName,
|
||||
formatStampArea,
|
||||
} from "./roomStamp";
|
||||
import { defaultRoomStamp, roomDisplayName } from "./roomStamp";
|
||||
import type { Room } from "./types";
|
||||
|
||||
function makeRoom(over: Partial<Room> = {}): Room {
|
||||
@@ -37,102 +31,6 @@ describe("defaultRoomStamp", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("roomStampToDoc", () => {
|
||||
it("eine Zeile ohne nameLine2", () => {
|
||||
const doc = roomStampToDoc({ name: "Bad", showFloorArea: true, showUsage: true });
|
||||
expect(doc.paragraphs).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("zwei Zeilen mit nameLine2", () => {
|
||||
const doc = roomStampToDoc({
|
||||
name: "Bad",
|
||||
nameLine2: "WC",
|
||||
showFloorArea: true,
|
||||
showUsage: true,
|
||||
});
|
||||
expect(doc.paragraphs).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("Nummer als Präfix-Run in Zeile 1", () => {
|
||||
const doc = roomStampToDoc({
|
||||
number: "1.01",
|
||||
name: "Bad",
|
||||
showFloorArea: true,
|
||||
showUsage: true,
|
||||
});
|
||||
expect(doc.paragraphs[0].runs).toHaveLength(2);
|
||||
expect(doc.paragraphs[0].runs[0].text).toBe("1.01 ");
|
||||
expect(doc.paragraphs[0].runs[1].text).toBe("Bad");
|
||||
});
|
||||
});
|
||||
|
||||
describe("roomStampExtraLines", () => {
|
||||
it("beachtet Flags und Präfix", () => {
|
||||
const lines = roomStampExtraLines(
|
||||
{ name: "Bad", showFloorArea: true, showUsage: true, floorAreaPrefix: "BF " },
|
||||
{ netArea: 12.345, siaCategory: "HNF", siaLabel: "Hauptnutzfläche" },
|
||||
);
|
||||
expect(lines[0].text).toBe("BF 12.35 m²");
|
||||
expect(lines[1].text).toBe("HNF · Hauptnutzfläche");
|
||||
});
|
||||
|
||||
it("blendet Zeilen aus, wenn Flags falsch", () => {
|
||||
const lines = roomStampExtraLines(
|
||||
{ name: "Bad", showFloorArea: false, showUsage: false },
|
||||
{ netArea: 12.345, siaCategory: "HNF", siaLabel: "Hauptnutzfläche" },
|
||||
);
|
||||
expect(lines).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("rundet die Fläche auf roundingStep, falls gesetzt", () => {
|
||||
const lines = roomStampExtraLines(
|
||||
{ name: "Bad", showFloorArea: true, showUsage: false, roundingStep: 0.5 },
|
||||
{ netArea: 12.34, siaCategory: "HNF", siaLabel: "Hauptnutzfläche" },
|
||||
);
|
||||
expect(lines[0].text).toBe("12.5 m²");
|
||||
});
|
||||
|
||||
it("nutzt 2 Nachkommastellen ohne roundingStep (Alt-Verhalten)", () => {
|
||||
const lines = roomStampExtraLines(
|
||||
{ name: "Bad", showFloorArea: true, showUsage: false },
|
||||
{ netArea: 12.345, siaCategory: "HNF", siaLabel: "Hauptnutzfläche" },
|
||||
);
|
||||
expect(lines[0].text).toBe("12.35 m²");
|
||||
});
|
||||
|
||||
it("zeigt die Personenzahl als eigene Zeile, wenn gesetzt", () => {
|
||||
const lines = roomStampExtraLines(
|
||||
{ name: "Bad", showFloorArea: false, showUsage: false, occupancy: 4 },
|
||||
{ netArea: 12.345, siaCategory: "HNF", siaLabel: "Hauptnutzfläche" },
|
||||
);
|
||||
expect(lines).toHaveLength(1);
|
||||
expect(lines[0].text).toBe("4 Pers.");
|
||||
expect(lines[0].align).toBe("center");
|
||||
});
|
||||
|
||||
it("blendet die Personenzahl-Zeile aus, wenn occupancy fehlt", () => {
|
||||
const lines = roomStampExtraLines(
|
||||
{ name: "Bad", showFloorArea: false, showUsage: false },
|
||||
{ netArea: 12.345, siaCategory: "HNF", siaLabel: "Hauptnutzfläche" },
|
||||
);
|
||||
expect(lines).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatStampArea", () => {
|
||||
it("2 Nachkommastellen ohne roundingStep", () => {
|
||||
expect(formatStampArea(12.345)).toBe("12.35");
|
||||
expect(formatStampArea(12)).toBe("12.00");
|
||||
});
|
||||
|
||||
it("rundet auf das nächste Vielfache von roundingStep", () => {
|
||||
expect(formatStampArea(12.24, 0.5)).toBe("12");
|
||||
expect(formatStampArea(12.26, 0.5)).toBe("12.5");
|
||||
expect(formatStampArea(12.3, 0.1)).toBe("12.3");
|
||||
expect(formatStampArea(12.34, 1)).toBe("12");
|
||||
});
|
||||
});
|
||||
|
||||
describe("roomDisplayName", () => {
|
||||
it("faellt auf room.name zurück ohne Stempel", () => {
|
||||
expect(roomDisplayName(makeRoom())).toBe("Wohnen");
|
||||
|
||||
+4
-92
@@ -1,21 +1,9 @@
|
||||
// Reines Modul für den strukturierten Raum-Stempel (Feldmodell). App-frei und
|
||||
// unit-getestet: baut aus einem RoomStamp das gerenderte Rich-Text-Dokument
|
||||
// (roomStampToDoc) und die Live-Zeilen (roomStampExtraLines), und liefert den
|
||||
// Anzeigenamen für Listen (roomDisplayName). Keine React-/Store-Abhängigkeit.
|
||||
//
|
||||
// Folge-Arbeit: Fensterfläche (braucht Öffnung-in-Raum-Geometrie).
|
||||
// Reines Modul für den strukturierten Raum-Stempel (Feldmodell): Standard-Stempel und Anzeigename
|
||||
// für Listen. Das Stempel-Dokument und die Live-Zeilen (Fläche, Nutzung, Personen) baut der Kern
|
||||
// beim Plan-Aufbau (`src-tauri/core/src/plan/domains.rs`, [K3d]).
|
||||
|
||||
import type { Room, RoomStamp } from "./types";
|
||||
import type { SiaCategory } from "../geometry/roomArea";
|
||||
import type { RichTextDoc, Paragraph, TextRun, Align } from "../text/richText";
|
||||
import { makeRun } from "../text/richText";
|
||||
|
||||
/** Grösse (pt) des Raumnamens (Zeile 1) relativ zur Stempel-Basis. */
|
||||
const NAME_PT = 12;
|
||||
/** Grösse (pt) der kleinen Raumnummer als Präfix. */
|
||||
const NUMBER_PT = 9;
|
||||
/** Grösse (pt) der zweiten Namenszeile. */
|
||||
const LINE2_PT = 9;
|
||||
import type { Align } from "../text/richText";
|
||||
|
||||
/**
|
||||
* Standard-Stempel aus einem Raum ableiten: Name = Raum-Name, Bodenfläche und
|
||||
@@ -29,88 +17,12 @@ export function defaultRoomStamp(room: Room): RoomStamp {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut das Rich-Text-Dokument des Stempels:
|
||||
* • Zeile 1: optionale Raumnummer (kleiner Präfix) + Raumname (grösser, fett).
|
||||
* • Zeile 2 (optional): nameLine2 (kursiv, kleiner).
|
||||
* Die Live-Zeilen (Fläche/Nutzung) werden separat als extraLines gesetzt.
|
||||
*/
|
||||
export function roomStampToDoc(stamp: RoomStamp): RichTextDoc {
|
||||
const line1: TextRun[] = [];
|
||||
const number = (stamp.number ?? "").trim();
|
||||
if (number) {
|
||||
line1.push(makeRun(`${number} `, { sizePt: NUMBER_PT }));
|
||||
}
|
||||
line1.push(makeRun(stamp.name, { bold: true, sizePt: NAME_PT }));
|
||||
|
||||
const paragraphs: Paragraph[] = [{ runs: line1, align: stamp.nameAlign }];
|
||||
const line2 = (stamp.nameLine2 ?? "").trim();
|
||||
if (line2) {
|
||||
paragraphs.push({
|
||||
runs: [makeRun(line2, { italic: true, sizePt: LINE2_PT })],
|
||||
align: stamp.line2Align,
|
||||
});
|
||||
}
|
||||
return { version: 1, paragraphs };
|
||||
}
|
||||
|
||||
/** Kontext für die Live-Zeilen (nicht gespeichert, bei jedem Rendern frisch). */
|
||||
export interface RoomStampContext {
|
||||
netArea: number;
|
||||
siaCategory: SiaCategory;
|
||||
siaLabel: string;
|
||||
}
|
||||
|
||||
/** Eine Live-Zeile des Stempels mit Text und Ausrichtung. */
|
||||
export interface RoomStampLine {
|
||||
text: string;
|
||||
align: Align;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatiert die Bodenfläche für die Stempel-Anzeige: ohne `roundingStep` wie
|
||||
* bisher auf 2 Nachkommastellen; mit `roundingStep` auf das nächste Vielfache
|
||||
* davon gerundet (z. B. 0.5 → halbe m²), ohne Nachkommastellen-Rauschen.
|
||||
*/
|
||||
export function formatStampArea(area: number, roundingStep?: number): string {
|
||||
if (roundingStep && roundingStep > 0) {
|
||||
const rounded = Math.round(area / roundingStep) * roundingStep;
|
||||
// Rundungsfehler aus der Fliesskomma-Division kappen (max. 2 Nachkommastellen).
|
||||
return `${Math.round(rounded * 100) / 100}`;
|
||||
}
|
||||
return area.toFixed(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Live-Zeilen unter dem Stempel: Bodenfläche (mit Präfix) wenn showFloorArea,
|
||||
* Nutzung (SIA-Kürzel · Bezeichnung) wenn showUsage, Personenzahl wenn gesetzt.
|
||||
* Die Ausrichtung folgt den Stempel-Feldern; fehlt sie, gilt „zentriert"
|
||||
* (Alt-Verhalten).
|
||||
*/
|
||||
export function roomStampExtraLines(stamp: RoomStamp, ctx: RoomStampContext): RoomStampLine[] {
|
||||
const lines: RoomStampLine[] = [];
|
||||
if (stamp.showFloorArea) {
|
||||
const prefix = stamp.floorAreaPrefix ?? "";
|
||||
lines.push({
|
||||
text: `${prefix}${formatStampArea(ctx.netArea, stamp.roundingStep)} m²`,
|
||||
align: stamp.floorAreaAlign ?? "center",
|
||||
});
|
||||
}
|
||||
if (stamp.showUsage) {
|
||||
lines.push({
|
||||
text: `${ctx.siaCategory} · ${ctx.siaLabel}`,
|
||||
align: stamp.usageAlign ?? "center",
|
||||
});
|
||||
}
|
||||
if (stamp.occupancy != null) {
|
||||
lines.push({
|
||||
text: `${stamp.occupancy} Pers.`,
|
||||
align: "center",
|
||||
});
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Anzeigename für Listen: strukturierter Name (name + optional nameLine2 zu
|
||||
* einem Namen zusammengezogen), sonst der Alt-Raumname.
|
||||
|
||||
+1
-20
@@ -2377,7 +2377,7 @@ export interface ImportedMesh {
|
||||
* Grafik-Kategorie-Code (s. {@link LayerCategory}, `model/contextCategories.ts`)
|
||||
* — steuert Sichtbarkeit/Grau/Sperren wie bei jedem anderen Bauteil (Ebenen-
|
||||
* Panel). Fehlt er (ältere Importe vor dieser Erweiterung), bleibt das Objekt
|
||||
* IMMER sichtbar (Rückwärtskompatibilität), s. `generatePlan/context.ts`.
|
||||
* IMMER sichtbar (Rückwärtskompatibilität), s. `plan/context.rs` im Kern.
|
||||
*/
|
||||
categoryCode?: string;
|
||||
/** Farbe aus der Quelldatei (`#rrggbb`, z. B. IFC-Oberflächenstil/Material); fehlt sie, gilt die Kontext-Grundfarbe. */
|
||||
@@ -3193,21 +3193,6 @@ export const openingLabel = (o: Opening): string =>
|
||||
o.height * 100
|
||||
).toFixed(0)}`;
|
||||
|
||||
/** Alle Treppen eines Geschosses (leere Liste, wenn keine oder `stairs` fehlt). */
|
||||
export const stairsOfFloor = (project: Project, floorId: string): Stair[] =>
|
||||
(project.stairs ?? []).filter((s) => s.floorId === floorId);
|
||||
|
||||
/** Menschenlesbarer Standardname einer Treppe (Grundform + Stufenanzahl). */
|
||||
export const stairLabel = (s: Stair): string => {
|
||||
const shape =
|
||||
s.shape === "straight" ? "Gerade" : s.shape === "L" ? "L-Treppe" : "Wendel";
|
||||
return `${shape} ${s.stepCount} STG`;
|
||||
};
|
||||
|
||||
/** Alle Stützen eines Geschosses (leere Liste, wenn keine oder `columns` fehlt). */
|
||||
export const columnsOfFloor = (project: Project, floorId: string): Column[] =>
|
||||
(project.columns ?? []).filter((c) => c.floorId === floorId);
|
||||
|
||||
/** Menschenlesbarer Standardname einer Stütze (Profil + Masse in cm). */
|
||||
export const columnLabel = (c: Column): string => {
|
||||
if (c.profile.kind === "round") {
|
||||
@@ -3216,10 +3201,6 @@ export const columnLabel = (c: Column): string => {
|
||||
return `Stütze ${(c.profile.width * 100).toFixed(0)}×${(c.profile.depth * 100).toFixed(0)}`;
|
||||
};
|
||||
|
||||
/** Alle Räume eines Geschosses (leere Liste, wenn keine oder `rooms` fehlt). */
|
||||
export const roomsOfFloor = (project: Project, floorId: string): Room[] =>
|
||||
(project.rooms ?? []).filter((r) => r.floorId === floorId);
|
||||
|
||||
/** 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);
|
||||
|
||||
@@ -18,7 +18,7 @@ import { solidProps } from "../engine/truckSolid";
|
||||
import type { SolidProps, SolidSpec } from "../engine/truckSolid";
|
||||
import { useEffect, useState } from "react";
|
||||
// Anzeige-Fallbacks für die Öffnungs-Linien-Übersteuerung (LineStyleRow) —
|
||||
// dieselben Werte wie POCHE_STROKE/SYMBOL_HAIRLINE_MM in plan/generatePlan.ts
|
||||
// dieselben Werte wie POCHE_STROKE/SYMBOL_HAIRLINE_MM im Grundriss (Kern: plan/style.rs)
|
||||
// (reine UI-Default-Anzeige, kein Re-Export nötig).
|
||||
const OPENING_LINE_DEFAULT_COLOR = "#1a1a1a";
|
||||
const OPENING_LINE_DEFAULT_WEIGHT = 0.02;
|
||||
|
||||
+16
-31
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* `addColumnPoche` — By-Layer/By-Object-Override für Stützen (Nutzer-Wunsch:
|
||||
* Stützen-Poché im Grundriss (Kern: `plan/domains.rs`) — By-Layer/By-Object-Override für Stützen (Nutzer-Wunsch:
|
||||
* "generell sollten alle BIM Teile ... die weiteren Attribute haben" — Stütze
|
||||
* hat bereits eine Poché UND nutzt dieselben Resolver wie Wand/Decke, daher
|
||||
* hier zuerst fertig verdrahtet). Regressionsschutz: die neuen
|
||||
@@ -8,9 +8,9 @@
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { addColumnPoche } from "./structures";
|
||||
import type { Column, Component, LayerCategory, Project } from "../../model/types";
|
||||
import type { Primitive } from "./shared";
|
||||
import { generatePlan } from "./generatePlan";
|
||||
import type { Column, Component, LayerCategory, Project } from "../model/types";
|
||||
import type { Primitive } from "./generatePlan/shared";
|
||||
|
||||
const comp: Component = {
|
||||
id: "beton",
|
||||
@@ -69,62 +69,47 @@ function column(overrides: Partial<Column> = {}): Column {
|
||||
};
|
||||
}
|
||||
|
||||
/** Grundriss des Geschosses „eg" mit genau dieser Stütze. */
|
||||
function planColumn(p: Project, col: Column): Primitive[] {
|
||||
return generatePlan({ ...p, columns: [col] }, "eg", new Set(["50"])).primitives;
|
||||
}
|
||||
|
||||
function polygonOf(out: Primitive[]): Extract<Primitive, { kind: "polygon" }> {
|
||||
const p = out.find((x) => x.kind === "polygon");
|
||||
if (!p || p.kind !== "polygon") throw new Error("kein Poché-Polygon gefunden");
|
||||
return p;
|
||||
}
|
||||
|
||||
describe("addColumnPoche — Attribut-Override greift", () => {
|
||||
describe("Stützen-Poché — Attribut-Override greift", () => {
|
||||
it("ohne Override: Bauteil-Schraffur/-Farbe bestimmen die Poché (Default 'Nach Bauteil')", () => {
|
||||
const out: Primitive[] = [];
|
||||
addColumnPoche(out, project(), column(), false, 0.35, category);
|
||||
const out = planColumn(project(), column());
|
||||
const poly = polygonOf(out);
|
||||
expect(poly.hatch.pattern).toBe("solid");
|
||||
});
|
||||
|
||||
it("mit explizitem background-Override: die Poché-Füllung wird die Override-Farbe", () => {
|
||||
const out: Primitive[] = [];
|
||||
addColumnPoche(out, project(), column({ background: "#ff00ff" }), false, 0.35, category);
|
||||
const out = planColumn(project(), column({ background: "#ff00ff" }));
|
||||
expect(polygonOf(out).fill).toBe("#ff00ff");
|
||||
});
|
||||
|
||||
it("mit hatchSource:'layer': die Kategorie-Schraffur wird verwendet, nicht die Bauteil-Schraffur", () => {
|
||||
const out: Primitive[] = [];
|
||||
const catWithHatch: LayerCategory = { ...category, hatch: "sia-other" };
|
||||
addColumnPoche(
|
||||
out,
|
||||
project({ layers: [catWithHatch] }),
|
||||
column({ hatchSource: "layer" }),
|
||||
false,
|
||||
0.35,
|
||||
catWithHatch,
|
||||
);
|
||||
const out = planColumn(project({ layers: [catWithHatch] }), column({ hatchSource: "layer" }));
|
||||
expect(polygonOf(out).hatch.pattern).toBe("none");
|
||||
});
|
||||
|
||||
it("mit explizitem hatchId-Override: gewinnt gegenüber Bauteil UND Kategorie", () => {
|
||||
const out: Primitive[] = [];
|
||||
addColumnPoche(
|
||||
out,
|
||||
project(),
|
||||
column({ hatchId: "sia-other" }),
|
||||
false,
|
||||
0.35,
|
||||
category,
|
||||
);
|
||||
const out = planColumn(project(), column({ hatchId: "sia-other" }));
|
||||
expect(polygonOf(out).hatch.pattern).toBe("none");
|
||||
});
|
||||
|
||||
it("ohne gesetzten Vordergrund: Schraffurfarbe bleibt die neutrale Tinte (Default unverändert)", () => {
|
||||
const out: Primitive[] = [];
|
||||
addColumnPoche(out, project(), column(), false, 0.35, category);
|
||||
const out = planColumn(project(), column());
|
||||
expect(polygonOf(out).hatch.color).toBe("#0f0f0f");
|
||||
});
|
||||
|
||||
it("mit explizitem foreground-Override: die Schraffurfarbe wird die Override-Farbe (vorher wirkungslos)", () => {
|
||||
const out: Primitive[] = [];
|
||||
addColumnPoche(out, project(), column({ foreground: "#00ff88" }), false, 0.35, category);
|
||||
const out = planColumn(project(), column({ foreground: "#00ff88" }));
|
||||
expect(polygonOf(out).hatch.color).toBe("#00ff88");
|
||||
});
|
||||
});
|
||||
+112
-257
@@ -7,13 +7,14 @@
|
||||
//
|
||||
// Diese Datei ist nur noch der ORCHESTRATOR: `generatePlan()`/
|
||||
// `generateSectionPlan()` sowie die `resolve*SectionStyle`-Helfer (für den
|
||||
// Schnitt-Pfad, `toSection.ts`). Das gemeinsame `Primitive`-Vokabular, die
|
||||
// By-Layer/By-Object-Attribut-Auflösung (`resolveHatch`/`resolveForeground`/…)
|
||||
// und die Papier-mm-/Tinten-Konstanten leben in `generatePlan/shared.ts`; jede
|
||||
// Bauteil-Domäne (Wände, Decken, Öffnungen, Treppen, Dächer, Kontext,
|
||||
// Schnittführung, Räume, sonstige Tragwerks-/Fremdkörper, freie 2D-Geometrie)
|
||||
// hat ihre eigene Datei unter `generatePlan/` — siehe dort für die konkrete
|
||||
// Zeichenlogik je Bauteil.
|
||||
// Schnitt-Pfad, `toSection.ts`). Die Bauteil-Domänen (Decken, Dächer, Räume,
|
||||
// Wände mit Öffnungen, Treppen, Stützen, Extrusionen, Kontext, Schnittführung)
|
||||
// rechnet der Rust-Kern auf dem Projekt-Dokument (`src-tauri/core/src/plan/`,
|
||||
// Abfrage `planDomains`, [K3d]) und liefert fertige `Primitive`. In TS bleiben
|
||||
// die freie 2D-Geometrie (`generatePlan/drawing2d.ts`), Schattenstudie und
|
||||
// Baurecht, die Abzugskörper (`voids.ts`), Mono und der Strichstärken-Massstab.
|
||||
// Das `Primitive`-Vokabular und die Attribut-Auflösung für die übrigen TS-Pfade
|
||||
// leben in `generatePlan/shared.ts`.
|
||||
|
||||
import type {
|
||||
Ceiling,
|
||||
@@ -24,54 +25,34 @@ import type {
|
||||
LayerCategory,
|
||||
OverrideActions,
|
||||
Project,
|
||||
Roof,
|
||||
Room,
|
||||
Stair,
|
||||
Vec2,
|
||||
Wall,
|
||||
} from "../model/types";
|
||||
import {
|
||||
columnLabel,
|
||||
columnsOfFloor,
|
||||
flattenCategories,
|
||||
getCeilingType,
|
||||
getComponent,
|
||||
getLayerCategory,
|
||||
getWallType,
|
||||
openingLabel,
|
||||
openingsOfWall,
|
||||
roomsOfFloor,
|
||||
stairLabel,
|
||||
stairsOfFloor,
|
||||
wallTypeThickness,
|
||||
} from "../model/types";
|
||||
import { roofGeometry } from "../geometry/roof";
|
||||
import { documentFor } from "../core/document";
|
||||
import { effectiveOverrides, hasOverrides } from "../overrides/engine";
|
||||
import { stairVerticalExtent, wallVerticalExtent } from "../model/wall";
|
||||
import { stairGeometry } from "../geometry/stair";
|
||||
import { wallCorners } from "../model/geometry";
|
||||
import { computeJoins } from "../model/joins";
|
||||
import type { SectionOutput } from "./toSection";
|
||||
import {
|
||||
HATCH_INK,
|
||||
HATCH_PAPER,
|
||||
LAYER_LINE_MM,
|
||||
MONO_INK,
|
||||
SHOW_ALL,
|
||||
WALL_FALLBACK_MM,
|
||||
resolveBackground,
|
||||
resolveForeground,
|
||||
resolveHatch,
|
||||
resolveHatchId,
|
||||
resolveStrokeWeight,
|
||||
type CategoryDisplayResolver,
|
||||
type DetailLevel,
|
||||
type HatchRender,
|
||||
type Primitive,
|
||||
} from "./generatePlan/shared";
|
||||
import { addCeilingPoche } from "./generatePlan/ceilings";
|
||||
import { subtractVoidsInPlan } from "./voids";
|
||||
import { addContextContours } from "./generatePlan/context";
|
||||
import { addSunShadow } from "./generatePlan/sunShadow";
|
||||
import { addSiteRules, addSiteViolations } from "./generatePlan/siteRules";
|
||||
import { lineWeightFactor, scalePrimitiveWeights } from "./lineWeightScale";
|
||||
@@ -84,13 +65,6 @@ import {
|
||||
} from "./generatePlan/drawing2d";
|
||||
import { drawingBox } from "../geometry/drawingBounds";
|
||||
import { layersStyleSig } from "./generatePlan/layerSig";
|
||||
import { addOpeningSymbol } from "./generatePlan/openings";
|
||||
import { addRoof } from "./generatePlan/roofs";
|
||||
import { addRoomArea } from "./generatePlan/rooms";
|
||||
import { addSectionLines } from "./generatePlan/sections";
|
||||
import { addStairSymbol } from "./generatePlan/stairs";
|
||||
import { addColumnPoche, addExtrudedSolidOutline } from "./generatePlan/structures";
|
||||
import { addReferenceLine, addWallPoche, buildWallFootprints, wallGaps } from "./generatePlan/walls";
|
||||
|
||||
// Re-Export des gemeinsamen Vokabulars — externe Konsumenten (Export-Pipeline,
|
||||
// PlanView, toSection.ts, toWalls3d.ts, toRenderScene.ts, …) importieren
|
||||
@@ -382,33 +356,6 @@ export function generatePlan(
|
||||
layerCode: categoryCode,
|
||||
objectName,
|
||||
});
|
||||
const wallTypeNameById = new Map(project.wallTypes.map((t) => [t.id, t.name]));
|
||||
const ceilingTypeNameById = new Map(
|
||||
(project.ceilingTypes ?? []).map((t) => [t.id, t.name]),
|
||||
);
|
||||
|
||||
// Sichtbarkeit wie bisher; der Darstellungsmodus verfeinert sie zusätzlich:
|
||||
// render=false blendet die Wand aus, greyed=true dimmt sie.
|
||||
const walls = project.walls
|
||||
.filter(
|
||||
(w) =>
|
||||
w.floorId === floorId &&
|
||||
visibleCodes.has(w.categoryCode) &&
|
||||
categoryDisplay(w.categoryCode).render,
|
||||
)
|
||||
.map((w) => {
|
||||
// Regel-Override gewinnt über den Per-Instanz-Wert (oberste Schicht):
|
||||
// Farbe → Umriss-/Fugenfarbe (Wall.color), Strichstärke → strokeWeight
|
||||
// (der topmost-Wert der bestehenden resolveStrokeWeight-Kette).
|
||||
const ov = overrideFor(w.categoryCode, wallTypeNameById.get(w.wallTypeId));
|
||||
if (!hasOverrides(ov)) return w;
|
||||
return {
|
||||
...w,
|
||||
color: ov.color ?? w.color,
|
||||
strokeWeight: ov.lineweight ?? w.strokeWeight,
|
||||
};
|
||||
});
|
||||
|
||||
// Freie 2D-Zeichengeometrie dieses Geschosses (wie Wände nach sichtbaren
|
||||
// Kategorien + Darstellungsmodus gefiltert). Wird über der Wand-Poché
|
||||
// gezeichnet (am Ende angehängt).
|
||||
@@ -434,169 +381,24 @@ export function generatePlan(
|
||||
};
|
||||
});
|
||||
|
||||
// Decken dieses Geschosses (wie Wände nach sichtbaren Kategorien +
|
||||
// Darstellungsmodus gefiltert). Eine Decke liegt (als Slab) über der
|
||||
// Schnittebene → im Grundriss als gefüllter/schraffierter Umriss dargestellt,
|
||||
// UNTER der Wand-Poché (damit die Wände darüber lesbar bleiben).
|
||||
const ceilings = (project.ceilings ?? [])
|
||||
.filter(
|
||||
(c) =>
|
||||
c.floorId === floorId &&
|
||||
visibleCodes.has(c.categoryCode) &&
|
||||
categoryDisplay(c.categoryCode).render,
|
||||
)
|
||||
.map((c) => {
|
||||
// Decken: nur der Farb-Override wirkt (der Umriss ist eine feste
|
||||
// Überkopf-Haarlinie, siehe addCeilingPoche — keine Strichstärke).
|
||||
const typeName =
|
||||
(c.ceilingTypeId ? ceilingTypeNameById.get(c.ceilingTypeId) : undefined) ??
|
||||
wallTypeNameById.get(c.wallTypeId);
|
||||
const ov = overrideFor(c.categoryCode, typeName);
|
||||
return ov.color !== undefined ? { ...c, color: ov.color } : c;
|
||||
});
|
||||
// Wand-Footprints für das Verdecken der (darunterliegenden) Decken-Umrisse:
|
||||
// die Decke liegt als Slab über der Schnittebene, ihre Umrisslinie soll dort,
|
||||
// wo eine Wand darüber steht, NICHT durch die Wand-Poché schlagen. Nur nötig,
|
||||
// wenn es überhaupt Decken gibt.
|
||||
const wallFootprints = ceilings.length ? buildWallFootprints(project, walls) : [];
|
||||
for (const ceiling of ceilings) {
|
||||
const greyed = categoryDisplay(ceiling.categoryCode).greyed;
|
||||
const category = catByCode.get(ceiling.categoryCode);
|
||||
// Strichstärke wie bei der Wand (Attribut-Override > Kategorie > Fallback);
|
||||
// der Umriss bleibt trotzdem eine gestrichelte Überkopf-Ansichtslinie
|
||||
// (Dash-Muster unverändert, s. addCeilingPoche) — nur die Dicke ist editierbar.
|
||||
const ceilingLwMm = resolveStrokeWeight(
|
||||
ceiling.strokeWeight,
|
||||
ceiling.strokeWeightSource,
|
||||
category,
|
||||
lwByCode.get(ceiling.categoryCode) ?? LAYER_LINE_MM,
|
||||
);
|
||||
addCeilingPoche(primitives, project, ceiling, greyed, detail, category, wallFootprints, ceilingLwMm);
|
||||
}
|
||||
// Decken, Dächer, Räume, Wände mit Öffnungen, Treppen, Stützen und Extrusions-Umrisse rechnet der
|
||||
// Kern auf dem Dokument ([K3d], `plan/{domains,walls,stairs}.rs`): Filter, Override-Regeln,
|
||||
// Verschneidung, Stil und Raumstempel-Daten. Decken, Dächer und Räume liegen unter der Wand-Poché; Stützen folgen
|
||||
// nach den Treppen, Extrusionen nach den 2D-Zeichnungen.
|
||||
const dom = planDomains(project, floorId, visibleCodes, categoryDisplay, detail, showReferenceLines, includeGlobal);
|
||||
for (const pr of dom.ceilings) primitives.push(pr);
|
||||
for (const pr of dom.roofs) primitives.push(pr);
|
||||
for (const pr of dom.rooms) primitives.push(pr);
|
||||
|
||||
// Dächer dieses Geschosses (Dachaufsicht): reine Grundriss-Linien (Traufe/
|
||||
// First/Grat/Knick), kein Poché. Über der Wand-Poché gezeichnet.
|
||||
const roofs = (project.roofs ?? []).filter(
|
||||
(r) =>
|
||||
r.floorId === floorId &&
|
||||
visibleCodes.has(r.categoryCode) &&
|
||||
categoryDisplay(r.categoryCode).render,
|
||||
);
|
||||
for (const roof of roofs) {
|
||||
const greyed = categoryDisplay(roof.categoryCode).greyed;
|
||||
const category = catByCode.get(roof.categoryCode);
|
||||
addRoof(primitives, project, roof, greyed, category);
|
||||
}
|
||||
// Wände (Poché, Referenzlinie) mit ihren Öffnungs-Symbolen, je Wand nacheinander.
|
||||
for (const pr of dom.walls) primitives.push(pr);
|
||||
|
||||
// Räume (SIA-416-Flächen) dieses Geschosses: transluzente Farbfüllung + Stempel
|
||||
// (Name + Fläche + SIA-Tag). UNTER der Wand-Poché gezeichnet, damit die Wände
|
||||
// lesbar bleiben. Der Stempel (Text) entfällt beim Detailgrad „grob".
|
||||
const rooms = roomsOfFloor(project, floorId)
|
||||
.filter(
|
||||
(r) =>
|
||||
visibleCodes.has(r.categoryCode) && categoryDisplay(r.categoryCode).render,
|
||||
)
|
||||
.map((r) => {
|
||||
// Räume: `object_name` matcht den Raum-Namen; der Farb-Override färbt
|
||||
// Fläche + Stempel (Room.color) um.
|
||||
const ov = overrideFor(r.categoryCode, r.name);
|
||||
return ov.color !== undefined ? { ...r, color: ov.color } : r;
|
||||
});
|
||||
for (const room of rooms) {
|
||||
const greyed = categoryDisplay(room.categoryCode).greyed;
|
||||
addRoomArea(primitives, room, greyed, detail);
|
||||
}
|
||||
// Treppen: Tritte + Lauflinie + Auf-/Abpfeil mit dem Grundriss-Schnitt (unter der Schnitthöhe
|
||||
// durchgezogen, darüber gestrichelt + SIA-Bruchlinie), über der Wand-Poché.
|
||||
for (const pr of dom.stairs) primitives.push(pr);
|
||||
|
||||
// Gehrungs-Schnittlinien einmal pro Plan berechnen (auf der gefilterten Menge).
|
||||
const joins = computeJoins(project, walls);
|
||||
|
||||
for (const wall of walls) {
|
||||
const wallGreyed = categoryDisplay(wall.categoryCode).greyed;
|
||||
const wallCategory = catByCode.get(wall.categoryCode);
|
||||
const wallLwMm = resolveStrokeWeight(
|
||||
wall.strokeWeight,
|
||||
wall.strokeWeightSource,
|
||||
wallCategory,
|
||||
lwByCode.get(wall.categoryCode) ?? WALL_FALLBACK_MM,
|
||||
);
|
||||
// Öffnungen (Fenster/Türen) am Wandhost sparen die Wand-Poché aus (Lücken-Intervall-Liste).
|
||||
const openings = openingsOfWall(project, wall.id);
|
||||
const gaps = wallGaps(wall, openings);
|
||||
const cuts = joins.get(wall.id) ?? { startCut: null, endCut: null };
|
||||
// Schnitt vs. Ansicht nach Schnitthöhe (BIM-Standard): erreicht die Wand die
|
||||
// Grundriss-Schnittebene nicht (z. B. eine Brüstung/ein Podestrand), wird sie
|
||||
// nur als Ansichts-Umriss gezeichnet — keine Schnitt-Poché. Normale Wände
|
||||
// (Schnittebene liegt in ihrer vertikalen Ausdehnung) sind unberührt. Über
|
||||
// `wallVerticalExtent` aufgelöst (nicht nur `wall.height`), damit ein
|
||||
// `bottom`/`top`-Override (VerticalAnchor) korrekt einfliesst — sonst würde
|
||||
// z. B. eine hochgesetzte Wand (angehobenes UK, Höhe allein sieht „hoch genug"
|
||||
// aus) fälschlich als Schnitt-Poché statt als Ansichts-Umriss gezeichnet.
|
||||
const { zBottom: wallZBottom, zTop: wallZTop } = wallVerticalExtent(project, wall);
|
||||
const cutPlaneZ = (floor?.baseElevation ?? 0) + (floor?.cutHeight ?? 1.0);
|
||||
const wallViewOnly = wallZTop < cutPlaneZ || wallZBottom > cutPlaneZ;
|
||||
addWallPoche(
|
||||
primitives, project, wall, gaps, cuts, wallGreyed, detail, wallLwMm, wallCategory, wallViewOnly,
|
||||
);
|
||||
// Referenzlinie: dünne gestrichelte Wand-Achslinie (von der Oberleiste
|
||||
// umschaltbar). Wird über der Poché gezeichnet, damit sie sichtbar bleibt.
|
||||
if (showReferenceLines) addReferenceLine(primitives, wall, wallGreyed);
|
||||
// Öffnungs-Symbole (Fenster/Tür) je Detailgrad + Auswahl-taggbar.
|
||||
for (const o of openings) {
|
||||
const d = categoryDisplay(o.categoryCode);
|
||||
if (visibleCodes.has(o.categoryCode) && d.render) {
|
||||
// Override-Regeln: `object_name` matcht das Öffnungs-Label
|
||||
// („Tür 90×210" / „Fenster 120×140").
|
||||
const ov = overrideFor(o.categoryCode, openingLabel(o));
|
||||
const oLwMm =
|
||||
ov.lineweight ?? lwByCode.get(o.categoryCode) ?? LAYER_LINE_MM;
|
||||
const effO = ov.color !== undefined ? { ...o, color: ov.color } : o;
|
||||
// Per-Element-Detailstufe (`Opening.detailLevel`) übersteuert die
|
||||
// ansichtsweite `detail`, sonst gilt Letztere unverändert.
|
||||
const effDetail = o.detailLevel ?? detail;
|
||||
addOpeningSymbol(primitives, project, wall, effO, d.greyed, effDetail, oLwMm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Treppen dieses Geschosses: Tritte + Lauflinie + Auf-/Abpfeil, mit dem
|
||||
// Grundriss-Schnitt (Tritte unter der Schnitthöhe durchgezogen, darüber
|
||||
// gestrichelt/verdeckt + SIA-Bruchlinie). Über der Wand-Poché gezeichnet.
|
||||
const cutHeight = floor?.cutHeight ?? 1.0;
|
||||
const stairs = stairsOfFloor(project, floorId).filter(
|
||||
(s) =>
|
||||
visibleCodes.has(s.categoryCode) && categoryDisplay(s.categoryCode).render,
|
||||
);
|
||||
for (const stair of stairs) {
|
||||
const greyed = categoryDisplay(stair.categoryCode).greyed;
|
||||
// Override-Regeln: `object_name` matcht das Treppen-Label („Gerade 16 STG").
|
||||
const ov = overrideFor(stair.categoryCode, stairLabel(stair));
|
||||
const lwMm =
|
||||
ov.lineweight ?? lwByCode.get(stair.categoryCode) ?? WALL_FALLBACK_MM;
|
||||
const effStair = ov.color !== undefined ? { ...stair, color: ov.color } : stair;
|
||||
addStairSymbol(primitives, project, effStair, greyed, lwMm, cutHeight);
|
||||
}
|
||||
|
||||
// Stützen (Tragwerk) dieses Geschosses: Querschnitt-Poché (Rechteck/Kreis),
|
||||
// um `rotation` gedreht, auf Kategorie „50". Über der Wand-Poché gezeichnet.
|
||||
const columns = columnsOfFloor(project, floorId).filter(
|
||||
(col) =>
|
||||
visibleCodes.has(col.categoryCode) && categoryDisplay(col.categoryCode).render,
|
||||
);
|
||||
for (const column of columns) {
|
||||
const greyed = categoryDisplay(column.categoryCode).greyed;
|
||||
const category = catByCode.get(column.categoryCode);
|
||||
const ov = overrideFor(column.categoryCode, columnLabel(column));
|
||||
const lwMm =
|
||||
ov.lineweight ??
|
||||
resolveStrokeWeight(
|
||||
column.strokeWeight,
|
||||
column.strokeWeightSource,
|
||||
category,
|
||||
lwByCode.get(column.categoryCode) ?? WALL_FALLBACK_MM,
|
||||
);
|
||||
const effCol = ov.color !== undefined ? { ...column, color: ov.color } : column;
|
||||
addColumnPoche(primitives, project, effCol, greyed, lwMm, category);
|
||||
}
|
||||
// Stützen (Tragwerk): Querschnitt-Poché, über der Wand-Poché.
|
||||
for (const pr of dom.columns) primitives.push(pr);
|
||||
|
||||
// 2D-Zeichengeometrie zuletzt (über der Poché).
|
||||
const compact = compactUnderlay && !mono && !forPrint;
|
||||
@@ -636,26 +438,17 @@ export function generatePlan(
|
||||
});
|
||||
for (const grp of underGroups.values()) underlay.push(mkGroup(grp.ds, grp.greyed));
|
||||
|
||||
// Extrudierte Körper (truck-Integration): das Quell-Profil wurde beim
|
||||
// Extrudieren aus `drawings2d` entfernt (s. `extrude.ts` appendExtrudedSolid)
|
||||
// — im Grundriss erscheint stattdessen der Footprint-Umriss des Körpers
|
||||
// selbst (Haarlinie, kein Poché/Schraffur; Farbe wie das 3D-Orange).
|
||||
for (const solid of project.extrudedSolids ?? []) {
|
||||
if (solid.levelId === floorId) addExtrudedSolidOutline(primitives, solid);
|
||||
}
|
||||
// Extrudierte Körper: Footprint-Umriss (Quell-Profil wurde beim Extrudieren entfernt).
|
||||
for (const pr of dom.solids) primitives.push(pr);
|
||||
|
||||
// Kontext-Konturen (Höhenlinien) als dezente Linien zeichnen — UNTER der
|
||||
// Wand-Poché wäre ideal, aber da sie eine eigene gedämpfte Farbe tragen, ist
|
||||
// die Reihenfolge unkritisch; wir hängen sie als Referenz an. Projektglobal
|
||||
// (nicht je Geschoss) → nur beim aktiven Aufruf einer Mehrfach-Überlagerung.
|
||||
if (includeGlobal) {
|
||||
addContextContours(primitives, project, visibleCodes, categoryDisplay);
|
||||
|
||||
// Schnittführungs-Symbole (klassische Schnittlinien) aller Schnitt-/
|
||||
// Ansichtsebenen mit gesetzter Linie — ebenfalls projektglobal. Sichtbarkeit
|
||||
// läuft über die Kategorie "90" (Referenzen), wie jedes andere Bauteil.
|
||||
addSectionLines(primitives, project, visibleCodes, categoryDisplay);
|
||||
}
|
||||
for (const pr of dom.context) primitives.push(pr);
|
||||
// Schnittführungs-Symbole aller Schnitt-/Ansichtsebenen mit Linie — ebenfalls projektglobal,
|
||||
// Sichtbarkeit über die Kategorie "90" (Referenzen).
|
||||
for (const pr of dom.sections) primitives.push(pr);
|
||||
|
||||
// Schwarz-Weiss (mono): nachträglich alle Farben auf reine Tinte zwingen.
|
||||
// Element-/Kategorie-/Hatch-Farben werden ignoriert, Füllungen werden weiss,
|
||||
@@ -697,7 +490,7 @@ export function generatePlan(
|
||||
}));
|
||||
return {
|
||||
primitives: lwf === 1 ? primitives : primitives.map((p) => scalePrimitiveWeights(p, lwf)),
|
||||
bounds: computeBounds(project, walls, drawings, ceilings, stairs, rooms, roofs, primitives.slice(0, underlayCount)),
|
||||
bounds: computeBounds(project, drawings, dom.bounds, primitives.slice(0, underlayCount)),
|
||||
backgroundImages,
|
||||
...(scaledUnderlay.length ? { underlay: scaledUnderlay } : {}),
|
||||
};
|
||||
@@ -1070,14 +863,87 @@ function categoryMap(layers: LayerCategory[]): Map<string, LayerCategory> {
|
||||
return map;
|
||||
}
|
||||
|
||||
/** Primitive der Kern-Domänen (`planDomains` in `queries.rs`). */
|
||||
interface DomainPrims {
|
||||
ceilings: Primitive[];
|
||||
walls: Primitive[];
|
||||
stairs: Primitive[];
|
||||
context: Primitive[];
|
||||
sections: Primitive[];
|
||||
roofs: Primitive[];
|
||||
rooms: Primitive[];
|
||||
columns: Primitive[];
|
||||
solids: Primitive[];
|
||||
bounds?: [number, number, number, number];
|
||||
}
|
||||
|
||||
const NO_DOMAINS: DomainPrims = { ceilings: [], walls: [], stairs: [], context: [], sections: [], roofs: [], rooms: [], columns: [], solids: [] };
|
||||
const DETAIL_CODE: Record<DetailLevel, number> = { grob: 0, mittel: 1, fein: 2 };
|
||||
|
||||
/**
|
||||
* Decken, Dächer, Räume, Wände mit Öffnungen, Treppen, Stützen, Extrusions-Umrisse eines Geschosses
|
||||
* und (mit `global`) Kontext-Konturen und Schnittführungs-Symbole aus dem Kern. Sichtbarkeit und Darstellungsmodus (UI-Zustand) gehen als Code-Mengen mit: `show` =
|
||||
* sichtbar und gezeichnet, `grey` = gedimmt.
|
||||
*/
|
||||
function planDomains(
|
||||
project: Project,
|
||||
floorId: string,
|
||||
visibleCodes: Set<string>,
|
||||
categoryDisplay: CategoryDisplayResolver,
|
||||
detail: DetailLevel,
|
||||
referenceLines: boolean,
|
||||
global: boolean,
|
||||
): DomainPrims {
|
||||
const codes = new Set<string>();
|
||||
let any = false;
|
||||
const take = (list: ReadonlyArray<{ floorId: string; categoryCode: string }> | undefined) => {
|
||||
for (const e of list ?? []) {
|
||||
if (e.floorId !== floorId) continue;
|
||||
codes.add(e.categoryCode);
|
||||
any = true;
|
||||
}
|
||||
};
|
||||
take(project.ceilings);
|
||||
take(project.roofs);
|
||||
take(project.rooms);
|
||||
take(project.columns);
|
||||
take(project.walls);
|
||||
take(project.stairs);
|
||||
if (global) {
|
||||
// Kontext-Objekte ohne Kategorie sind immer sichtbar; Schnittlinien hängen an "90".
|
||||
for (const o of project.context ?? []) {
|
||||
if (o.type === "image") continue;
|
||||
any = true;
|
||||
if (o.categoryCode !== undefined) codes.add(o.categoryCode);
|
||||
}
|
||||
if (project.drawingLevels.some((l) => (l.kind === "section" || l.kind === "elevation") && l.linePoints)) {
|
||||
any = true;
|
||||
codes.add("90");
|
||||
}
|
||||
}
|
||||
if (!any && !(project.extrudedSolids ?? []).some((x) => x.levelId === floorId)) return NO_DOMAINS;
|
||||
for (const o of project.openings ?? []) codes.add(o.categoryCode);
|
||||
const show: string[] = [];
|
||||
const grey: string[] = [];
|
||||
for (const c of codes) {
|
||||
if (!visibleCodes.has(c)) continue;
|
||||
const d = categoryDisplay(c);
|
||||
if (!d.render) continue;
|
||||
show.push(c);
|
||||
if (d.greyed) grey.push(c);
|
||||
}
|
||||
return documentFor(project).query<DomainPrims>(
|
||||
"planDomains",
|
||||
[DETAIL_CODE[detail] ?? 1],
|
||||
JSON.stringify({ floor: floorId, show, grey, referenceLines, global }),
|
||||
);
|
||||
}
|
||||
|
||||
function computeBounds(
|
||||
project: Project,
|
||||
walls: Wall[],
|
||||
drawings: Drawing2D[] = [],
|
||||
ceilings: Ceiling[] = [],
|
||||
stairs: Stair[] = [],
|
||||
rooms: Room[] = [],
|
||||
roofs: Roof[] = [],
|
||||
/** Ausmass der Kern-Domänen (Wand-Ecken, Decken, Räume, Dach-Traufen, Treppen), s. `planDomains`. */
|
||||
domainBox: [number, number, number, number] | undefined = undefined,
|
||||
/** Zusätzlich einzurahmende Primitive (Schatten, Parzelle), damit Druck/Einpassen sie ganz zeigen. */
|
||||
extra: Primitive[] = [],
|
||||
) {
|
||||
@@ -1086,25 +952,14 @@ function computeBounds(
|
||||
minX = Math.min(minX, p.x); minY = Math.min(minY, p.y);
|
||||
maxX = Math.max(maxX, p.x); maxY = Math.max(maxY, p.y);
|
||||
};
|
||||
for (const w of walls) {
|
||||
const t = wallTypeThickness(getWallType(project, w));
|
||||
for (const c of wallCorners(w.start, w.end, t)) acc(c);
|
||||
if (domainBox) {
|
||||
acc({ x: domainBox[0], y: domainBox[1] });
|
||||
acc({ x: domainBox[2], y: domainBox[3] });
|
||||
}
|
||||
for (const c of ceilings) for (const p of c.outline) acc(p);
|
||||
for (const r of rooms) for (const p of r.boundary) acc(p);
|
||||
for (const e of extra) {
|
||||
if (e.kind === "polygon") e.pts.forEach(acc);
|
||||
else if (e.kind === "line") { acc(e.a); acc(e.b); }
|
||||
}
|
||||
// Traufe (inkl. Überstand) statt reinem Umriss, damit ein weit auskragendes
|
||||
// Dach das „Einpassen" korrekt mit einrahmt.
|
||||
for (const roof of roofs) for (const p of roofGeometry(roof, 0).eaves) acc(p);
|
||||
for (const s of stairs) {
|
||||
const { zBottom, zTop } = stairVerticalExtent(project, s);
|
||||
const geo = stairGeometry(s, zTop - zBottom);
|
||||
for (const tr of geo.treads) for (const p of tr.pts) acc(p);
|
||||
if (geo.landing) for (const p of geo.landing) acc(p);
|
||||
}
|
||||
for (const d of drawings) {
|
||||
const g = d.geom;
|
||||
if (g.shape === "line" || g.shape === "polyline") {
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
// Decken-Domäne des Grundriss-Generators: die Decke liegt als Slab ÜBER der
|
||||
// Grundriss-Schnittebene und wird daher als flächiger Aufsicht-Umriss
|
||||
// gezeichnet (nicht als Schicht-Querschnitt wie eine Wand) — die Kante wird
|
||||
// gegen die {@link WallFootprint}s der darunterliegenden Wände geclippt, damit
|
||||
// sie dort nicht durch die Wand-Poché schlägt.
|
||||
|
||||
import type { Ceiling, LayerCategory, Project } from "../../model/types";
|
||||
import { getCeilingType, getComponent } from "../../model/types";
|
||||
import { mergeHoles } from "../../geometry/polygonHoles";
|
||||
import { core } from "../../engine/coreWasm";
|
||||
import {
|
||||
NO_HATCH,
|
||||
OVERHEAD_DASH,
|
||||
POCHE_STROKE,
|
||||
LAYER_DETAIL_FACTOR,
|
||||
pocheFill,
|
||||
resolveBackground,
|
||||
resolveForeground,
|
||||
resolveHatch,
|
||||
resolveHatchId,
|
||||
type DetailLevel,
|
||||
type Primitive,
|
||||
} from "./shared";
|
||||
import type { WallFootprint } from "./walls";
|
||||
|
||||
/**
|
||||
* Decken-Poché im Grundriss: die Decke liegt als Slab ÜBER der Schnittebene und
|
||||
* wird daher als geschlossener Umriss ihres Grundriss-Polygons gezeichnet — eine
|
||||
* gefüllte + schraffierte Fläche plus eine kräftige Umrisslinie. Fill/Schraffur
|
||||
* stammen aus dem BAUTEIL der ersten (obersten) Schicht des Aufbau-Typs (analog
|
||||
* zur Wand-Schichtauflösung); die Umrissfarbe aus der optionalen Decken-Farbe
|
||||
* bzw. dem Poché-Strich. Jedes Polygon trägt die `ceilingId` für die Auswahl.
|
||||
*
|
||||
* BEWUSST FLÄCHIG, auch bei mehrschichtigem Deckentyp: anders als die Wand
|
||||
* (deren Schichten im Grundriss als Querschnitt sichtbar sind) liegt der
|
||||
* Schichtaufbau einer Decke in Z (oben → unten) — von oben unsichtbar. Die
|
||||
* Schichtbänderung erscheint daher NUR im Schnitt (siehe `toSection.ts`), nicht
|
||||
* hier. Im Detailgrad „grob" entfällt die Schraffur (nur Fläche + Umriss);
|
||||
* „mittel"/„fein" zeigen die Ansichts-Schraffur des Bauteils (`viewHatchId`,
|
||||
* Default weiss) — die frontal gesehene Aufsicht ist kein Schnitt. `lwMm` ist
|
||||
* die aufgelöste Umriss-Strichstärke (Attribut-Override > Kategorie > Fallback,
|
||||
* vom Aufrufer via `resolveStrokeWeight` bestimmt, analog zur Wand).
|
||||
*/
|
||||
export function addCeilingPoche(
|
||||
out: Primitive[],
|
||||
project: Project,
|
||||
ceiling: Ceiling,
|
||||
greyed: boolean,
|
||||
detail: DetailLevel,
|
||||
category: LayerCategory | undefined,
|
||||
wallFootprints: WallFootprint[],
|
||||
lwMm: number,
|
||||
): void {
|
||||
const pts = ceiling.outline;
|
||||
if (pts.length < 3) return;
|
||||
// Aussparungen (Treppenauge/Schacht) über den Brücken-Trick in EINEN
|
||||
// einfachen Poché-Ring einfügen: kein `openings` ⇒ `ring === pts` und
|
||||
// `bridgeEdges` leer (exakt heutiger Codepfad, siehe {@link mergeHoles}).
|
||||
const ceilingHoles = ceiling.openings ?? [];
|
||||
const { ring, bridgeEdges } = ceilingHoles.length
|
||||
? mergeHoles(pts, ceilingHoles)
|
||||
: { ring: pts, bridgeEdges: [] as number[] };
|
||||
const wt = getCeilingType(project, ceiling);
|
||||
const comp = wt.layers.length > 0 ? getComponent(project, wt.layers[0].componentId) : null;
|
||||
const stroke = ceiling.color ?? POCHE_STROKE;
|
||||
const ceilingId = ceiling.id;
|
||||
|
||||
// Gefüllte Fläche mit der Ansichts-Schraffur: die Decke wird im Grundriss
|
||||
// frontal von unten gesehen, nicht aufgeschnitten — daher greift hier
|
||||
// NICHT die Schnitt-Schraffur (die gehört auf echte Schnittflächen, siehe
|
||||
// resolveCeilingSectionStyle/splitSlabLayers), sondern `viewHatchId`. Fehlt
|
||||
// sie (Default), bleibt die Aufsicht weiss. Im Detailgrad „grob" entfällt
|
||||
// die Schraffur ganz (nur Fläche + Umriss). Das Attribut-Override
|
||||
// `ceiling.hatchId` (+ `hatchSource`) überschreibt diese Ansichts-Schraffur
|
||||
// genauso wie die Schnitt-Schraffur in {@link resolveCeilingSectionStyle}.
|
||||
const effectiveViewHatchId = resolveHatchId(
|
||||
ceiling.hatchId,
|
||||
ceiling.hatchSource,
|
||||
category,
|
||||
comp?.viewHatchId,
|
||||
);
|
||||
const hatch =
|
||||
detail !== "grob" && comp && effectiveViewHatchId
|
||||
? resolveHatch(
|
||||
project,
|
||||
effectiveViewHatchId,
|
||||
undefined,
|
||||
resolveForeground(comp, ceiling.foreground, category, ceiling.foregroundSource),
|
||||
)
|
||||
: NO_HATCH;
|
||||
// Poché-Füllfarbe: Attribut-Override (By-Layer/By-Object) hat Vorrang vor der
|
||||
// neutralen SIA-Fläche, analog zur Wand-Poché (siehe walls.ts).
|
||||
const bgOverride = comp
|
||||
? resolveBackground(comp, ceiling.background, category, ceiling.backgroundSource)
|
||||
: undefined;
|
||||
// Gefüllte Fläche OHNE eigenen Umriss (stroke:"none"): die Decke liegt unter
|
||||
// der Wand-Poché; ihre Kante wird separat als verdeckungs-geclippte Linie
|
||||
// gezeichnet (s. u.), damit sie nicht durch die darüberstehenden Wände schlägt.
|
||||
// Trägt weiterhin die `ceilingId` für die Links-Klick-Auswahl der Fläche.
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts: ring,
|
||||
fill: comp ? bgOverride ?? pocheFill(hatch.pattern) : "none",
|
||||
stroke: "none",
|
||||
strokeWidthMm: 0,
|
||||
hatch,
|
||||
greyed,
|
||||
ceilingId,
|
||||
...(bridgeEdges.length ? { noStrokeEdges: bridgeEdges } : {}),
|
||||
});
|
||||
// Kräftige Umrisslinie NUR dort, wo keine Wand die Decke verdeckt: jede
|
||||
// Umriss-Kante (inkl. Lochränder, die als Teil des Rings automatisch
|
||||
// mitgestrichen werden) gegen die Wand-Footprints clippen und die freien
|
||||
// Teilstücke als Linien ausgeben. Liegt die Decke deckungsgleich unter den
|
||||
// Wänden (Regelfall: Deckenumriss = Gebäude-/Wand-Mittellinien), entfällt
|
||||
// der Umriss ganz; nur Überstände (Vordach/Balkon jenseits der Wand)
|
||||
// bleiben sichtbar. Brückenkanten (künstliche Verbindung Aussenring↔Loch)
|
||||
// werden NICHT gestrichen.
|
||||
// Die freien Teilstücke berechnet der Kern (`plan_walls.rs`, [K3a]).
|
||||
const buf: number[] = [ring.length];
|
||||
for (const p of ring) buf.push(p.x, p.y);
|
||||
buf.push(bridgeEdges.length, ...bridgeEdges, wallFootprints.length);
|
||||
for (const fp of wallFootprints) buf.push(fp.a.x, fp.a.y, fp.u.x, fp.u.y, fp.m.x, fp.m.y, fp.len, fp.half, fp.refOff);
|
||||
const f = core().plan_ceiling_outline_flat(Float64Array.from(buf));
|
||||
for (let i = 0; i < f[0]; i++) {
|
||||
out.push({
|
||||
kind: "line",
|
||||
a: { x: f[1 + 4 * i], y: f[2 + 4 * i] },
|
||||
b: { x: f[3 + 4 * i], y: f[4 + 4 * i] },
|
||||
cls: "ceiling-outline",
|
||||
// Überkopf-Ansichtslinie (Decke liegt als Slab über der Schnittebene) →
|
||||
// gestrichelt statt durchgezogen (BIM-Konvention) — die DICKE folgt
|
||||
// aber ceiling.strokeWeight/-Source wie bei der Wand (s. Aufrufer).
|
||||
weightMm: lwMm * LAYER_DETAIL_FACTOR[detail],
|
||||
dash: OVERHEAD_DASH,
|
||||
color: stroke,
|
||||
greyed,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
// Kontext-Domäne des Grundriss-Generators: zeichnet `project.context`
|
||||
// (Höhenlinien, importierte Gebäude/Terrain-Meshes) als dezente Referenz-
|
||||
// Konturen — für Meshes der Grundriss-Fussabdruck nahe der Objekt-Unterkante,
|
||||
// nicht das volle Drahtgitter. Fussabdruck (Sockelkanten, entdoppelt) und Rahmen berechnet der
|
||||
// Rust-Kern (`src-tauri/core/src/plan_misc.rs`, [K3a]).
|
||||
|
||||
import type { Project } from "../../model/types";
|
||||
import { core } from "../../engine/coreWasm";
|
||||
import { NO_HATCH, SHOW_ALL, type CategoryDisplayResolver, type Primitive } from "./shared";
|
||||
|
||||
/** Dezente Plan-Farbe der Kontext-Konturen (gedämpftes Grau). */
|
||||
const CONTEXT_LINE_COLOR = "#9aa3ad";
|
||||
/** Strichstärke der Kontext-Konturen (mm Papier, dünn). */
|
||||
const CONTEXT_LINE_MM = 0.1;
|
||||
|
||||
/**
|
||||
* Zeichnet die Kontext-Schicht `project.context` in den Grundriss:
|
||||
* • ContourSet (Höhenlinien) → dünne Referenz-Linien (Z ignoriert).
|
||||
* • ImportedMesh (Gebäude) → GRUNDRISS-FUSSABDRUCK: die Dreieckskanten nahe
|
||||
* der Objekt-Unterkante (Sockel), auf die XY-Ebene projiziert und über
|
||||
* quantisierte Endpunkte entdoppelt — so erscheint das importierte Haus als
|
||||
* erkennbarer Umriss im Plan (Nutzer-Wunsch: „ich sehe es sonst nicht"),
|
||||
* ohne das gesamte Dach-Drahtgitter dicht darüberzulegen.
|
||||
* • TerrainMesh → nur der 2D-Umriss (Bounding-Box), da ein volles TIN-Gitter
|
||||
* im Plan unbrauchbar dicht wäre.
|
||||
* Rein additiv — Wand-/Drawing-Darstellung bleibt unberührt.
|
||||
*
|
||||
* SICHTBARKEIT: jedes Objekt trägt (seit der Ebenen-Zuordnung der Kontext-
|
||||
* Schicht) optional eine `categoryCode` (s. `model/contextCategories.ts`) —
|
||||
* genau wie jedes andere Bauteil wird sie gegen `visibleCodes`/
|
||||
* `categoryDisplay` geprüft (Muster 1:1 aus `sections.ts::addSectionLines`).
|
||||
* Objekte OHNE `categoryCode` (ältere Importe vor dieser Erweiterung) bleiben
|
||||
* bewusst IMMER sichtbar (Rückwärtskompatibilität) statt stillschweigend zu
|
||||
* verschwinden.
|
||||
*/
|
||||
export function addContextContours(
|
||||
out: Primitive[],
|
||||
project: Project,
|
||||
visibleCodes?: Set<string>,
|
||||
categoryDisplay: CategoryDisplayResolver = SHOW_ALL,
|
||||
): void {
|
||||
const context = project.context ?? [];
|
||||
for (const obj of context) {
|
||||
const code = obj.categoryCode;
|
||||
if (code !== undefined) {
|
||||
const d = categoryDisplay(code);
|
||||
if ((visibleCodes && !visibleCodes.has(code)) || !d.render) continue;
|
||||
}
|
||||
if (obj.type === "contourSet") {
|
||||
for (const c of obj.contours) {
|
||||
const pts = c.pts;
|
||||
if (pts.length < 2) continue;
|
||||
const segEnd = c.closed ? pts.length : pts.length - 1;
|
||||
for (let i = 0; i < segEnd; i++) {
|
||||
out.push({
|
||||
kind: "line",
|
||||
a: pts[i],
|
||||
b: pts[(i + 1) % pts.length],
|
||||
cls: "context-line",
|
||||
weightMm: CONTEXT_LINE_MM,
|
||||
color: CONTEXT_LINE_COLOR,
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (obj.type === "importedMesh") {
|
||||
addMeshFootprint(out, obj.positions, obj.indices);
|
||||
addContextPickRegion(out, obj.positions, obj.id);
|
||||
} else if (obj.type === "terrainMesh") {
|
||||
addMeshBboxOutline(out, obj.positions);
|
||||
addContextPickRegion(out, obj.positions, obj.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeichnet den Grundriss-Fussabdruck eines Meshes: Dreieckskanten nahe der
|
||||
* Unterkante (minZ + 0.6 m), auf XY projiziert, über 1-cm-quantisierte Endpunkte
|
||||
* entdoppelt. `positions` = flaches [x,y,z…]-Array (Modell-Meter, z = Höhe),
|
||||
* `indices` = Dreiecks-Indizes.
|
||||
*/
|
||||
function addMeshFootprint(out: Primitive[], positions: number[], indices: number[]): void {
|
||||
const f = core().context_footprint_flat(Float64Array.from(positions), Float64Array.from(indices));
|
||||
for (let i = 0; i < f[0]; i++) {
|
||||
out.push({
|
||||
kind: "line",
|
||||
a: { x: f[1 + 4 * i], y: f[2 + 4 * i] },
|
||||
b: { x: f[3 + 4 * i], y: f[4 + 4 * i] },
|
||||
cls: "context-line",
|
||||
weightMm: CONTEXT_LINE_MM,
|
||||
color: CONTEXT_LINE_COLOR,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** Grundriss-Rahmen eines Meshes (nur x/y) als vier Eckpunkte, oder `null` ohne Punkte. */
|
||||
function meshBboxCorners(positions: number[]): { x: number; y: number }[] | null {
|
||||
const b = core().context_bbox_flat(Float64Array.from(positions));
|
||||
if (b.length === 0) return null;
|
||||
return [
|
||||
{ x: b[0], y: b[1] },
|
||||
{ x: b[2], y: b[1] },
|
||||
{ x: b[2], y: b[3] },
|
||||
{ x: b[0], y: b[3] },
|
||||
];
|
||||
}
|
||||
|
||||
/** Zeichnet nur den achsenparallelen 2D-Umriss (Bounding-Box) eines Meshes —
|
||||
* für Terrain, dessen volles TIN-Gitter im Plan zu dicht wäre. */
|
||||
function addMeshBboxOutline(out: Primitive[], positions: number[]): void {
|
||||
const corners = meshBboxCorners(positions);
|
||||
if (!corners) return;
|
||||
for (let i = 0; i < 4; i++) {
|
||||
out.push({
|
||||
kind: "line",
|
||||
a: corners[i],
|
||||
b: corners[(i + 1) % 4],
|
||||
cls: "context-line",
|
||||
weightMm: CONTEXT_LINE_MM,
|
||||
color: CONTEXT_LINE_COLOR,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsichtbares Pick-Band (Grundriss-Bounding-Box) für ein Kontext-Objekt
|
||||
* (importiertes Gebäude/Terrain) — klickbar per Punkt-in-Polygon in PlanView,
|
||||
* trägt die `ContextObject.id` (analog `sectionLineId`, s. dort). Macht das
|
||||
* Objekt IRGENDWO innerhalb seiner Grundfläche anklickbar (nicht nur exakt auf
|
||||
* der dünnen Umriss-/Fussabdrucklinie) — wie bei Wänden, deren Poché-Fläche
|
||||
* ebenfalls als Ganzes klickbar ist.
|
||||
*/
|
||||
function addContextPickRegion(out: Primitive[], positions: number[], id: string): void {
|
||||
const pts = meshBboxCorners(positions);
|
||||
if (!pts) return;
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts,
|
||||
fill: "none",
|
||||
stroke: "none",
|
||||
strokeWidthMm: 0,
|
||||
hatch: NO_HATCH,
|
||||
contextObjectId: id,
|
||||
});
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
// Öffnungs-Domäne des Grundriss-Generators: Tür-/Fenstersymbole je Detailgrad
|
||||
// (Blatt/Schwenkbogen/Anschlag bzw. Rahmen/Sprossen/Glas), das optionale
|
||||
// Rahmenband (Zarge/Blockrahmen) samt Schichteinzug aus der Typ-Bibliothek.
|
||||
//
|
||||
// Die Geometrie entsteht im Rust-Kern (`src-tauri/core/src/plan_openings.rs`, [K3a]); hier bleibt
|
||||
// die Auflösung aus dem Modell (Typ-Bibliothek, Linien-Overrides) und die Übersetzung in
|
||||
// `Primitive`-Objekte mit Farbe, Strichstärke und `openingId`. Fällt mit [K3d] weg.
|
||||
|
||||
import type { Opening, Project, Wall } from "../../model/types";
|
||||
import {
|
||||
getDoorType,
|
||||
getWindowType,
|
||||
getWallType,
|
||||
sashesOfWindowType,
|
||||
wallTypeThickness,
|
||||
} from "../../model/types";
|
||||
import { wallReferenceOffset } from "../../model/wall";
|
||||
import { core } from "../../engine/coreWasm";
|
||||
import {
|
||||
NO_HATCH,
|
||||
OVERHEAD_DASH,
|
||||
POCHE_STROKE,
|
||||
SYMBOL_HAIRLINE_MM,
|
||||
type DetailLevel,
|
||||
type Primitive,
|
||||
} from "./shared";
|
||||
|
||||
/** Linienklassen in der Reihenfolge der Kern-Kodierung (`plan_openings.rs`). */
|
||||
const LINE_CLS = [
|
||||
"door-leaf", "door-frame", "door-lintel", "opening-frame", "window-glass", "window-mullion",
|
||||
"window-sash", "window-stulp", "window-sill", "window-frame", "window-shading",
|
||||
] as const;
|
||||
/** Strichmuster (Kern-Kodierung): 1 Sturz, 2 Überkopf, 3 gepunktet. */
|
||||
const DASHES: (number[] | undefined)[] = [undefined, [0.18, 0.09], OVERHEAD_DASH, [0.04, 0.08]];
|
||||
const DETAIL_CODE: Record<DetailLevel, number> = { grob: 0, mittel: 1, fein: 2 };
|
||||
const LINTEL_CODE = { keine: 0, aussen: 1, innen: 2, beide: 3 } as const;
|
||||
const SILL_CODE = { aussen: 1, innen: 2, beide: 3 } as const;
|
||||
|
||||
/**
|
||||
* Aufgelöste Rahmen-Parameter (Typ-Bibliothek) einer Tür-/Fenster-Öffnung —
|
||||
* nur vorhanden, wenn die Öffnung einen Bauteil-Typ referenziert (`typeId`).
|
||||
* Fehlt der Typ, bleibt das heutige Inline-Verhalten unverändert (kein
|
||||
* Rahmenband, kein Oberlicht) — siehe `resolveOpeningFrameSpec`.
|
||||
*/
|
||||
interface OpeningFrameSpec {
|
||||
frameWidth: number;
|
||||
/** Nur bei Türen relevant; Fenster zeichnen stets die schmale Zargen-Optik. */
|
||||
frameKind: "zarge" | "blockrahmen";
|
||||
insetFromFace: number;
|
||||
insetFace: "aussen" | "innen";
|
||||
transomHeight: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Löst die Rahmen-Parameter aus dem referenzierten Tür-/Fenstertyp auf (samt
|
||||
* Defaults); `undefined`, wenn kein Typ referenziert/auflösbar ist — die
|
||||
* Öffnung bleibt dann beim heutigen Inline-Verhalten (rückwärtskompatibel).
|
||||
*/
|
||||
function resolveOpeningFrameSpec(project: Project, o: Opening): OpeningFrameSpec | undefined {
|
||||
if (o.kind === "door") {
|
||||
const t = getDoorType(project, o);
|
||||
if (!t) return undefined;
|
||||
return {
|
||||
frameWidth: t.frameWidth ?? 0.06,
|
||||
frameKind: t.frameKind ?? "zarge",
|
||||
insetFromFace: t.insetFromFace ?? 0,
|
||||
insetFace: t.insetFace ?? "aussen",
|
||||
transomHeight: t.transomHeight ?? 0,
|
||||
};
|
||||
}
|
||||
const t = getWindowType(project, o);
|
||||
if (!t) return undefined;
|
||||
return {
|
||||
frameWidth: t.frameWidth ?? 0.06,
|
||||
frameKind: "zarge",
|
||||
insetFromFace: t.insetFromFace ?? 0,
|
||||
insetFace: t.insetFace ?? "aussen",
|
||||
transomHeight: t.transomHeight ?? 0,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Öffnungs-Symbol (Fenster/Tür) je Detailgrad. Arbeitet über den Kern (`plan_openings.rs`) und
|
||||
* taggt ihre Primitive mit `openingId`, sodass die Öffnung im Plan selektierbar ist.
|
||||
*
|
||||
* Tür:
|
||||
* • grob — gerade Türblatt-Linie (die Lücke kommt aus der ausgesparten Poché).
|
||||
* • mittel — + Schwenkbogen (Öffnungswinkel).
|
||||
* • fein — + Anschlag-Striche an beiden Pfosten.
|
||||
* Fenster:
|
||||
* • grob — eine einzelne Glaslinie über die Lücke.
|
||||
* • mittel — Rahmen-Rechteck (Umriss) + Pfosten/Stulp.
|
||||
* • fein — + Flügelrahmen, Fensterbank, Anschlagkerben.
|
||||
*/
|
||||
export function addOpeningSymbol(
|
||||
out: Primitive[],
|
||||
project: Project,
|
||||
wall: Wall,
|
||||
o: Opening,
|
||||
greyed: boolean,
|
||||
detail: DetailLevel,
|
||||
lwMm: number,
|
||||
): void {
|
||||
const total = wallTypeThickness(getWallType(project, wall));
|
||||
const refOff = wallReferenceOffset(wall, total);
|
||||
const door = o.kind === "door";
|
||||
const wt = door ? undefined : getWindowType(project, o);
|
||||
const frameSpec = door ? resolveOpeningFrameSpec(project, o) : undefined;
|
||||
const sashes = wt ? sashesOfWindowType(wt) : [];
|
||||
const strokeColor = o.color ?? POCHE_STROKE;
|
||||
// Linien-Kategorien einzeln übersteuerbar: Rahmen-Schnitt, Rahmen-Aufsicht, Fenster
|
||||
// (Flügelrahmen/Sprossen), Sims. `undefined` ⇒ Strichfarbe/Haarlinie.
|
||||
const frameColor = o.frameLine?.color ?? strokeColor;
|
||||
const frameWeight = o.frameLine?.weight ?? lwMm;
|
||||
const frameViewWeight = o.frameViewLine?.weight ?? frameWeight;
|
||||
const colors = [
|
||||
"",
|
||||
strokeColor,
|
||||
frameColor,
|
||||
o.frameViewLine?.color ?? frameColor,
|
||||
o.sashLine?.color ?? strokeColor,
|
||||
o.sillLineStyle?.color ?? strokeColor,
|
||||
];
|
||||
const b: number[] = [
|
||||
wall.start.x, wall.start.y, wall.end.x, wall.end.y, total, refOff,
|
||||
o.position, o.width, door ? 1 : 0, DETAIL_CODE[detail],
|
||||
// Tür
|
||||
(o.swing ?? "left") !== "left" ? 1 : 0,
|
||||
(o.openingDir ?? "in") !== "in" ? 1 : 0,
|
||||
(o.hinge ?? "start") !== "start" ? 1 : 0,
|
||||
o.swingAngle ?? Number.NaN,
|
||||
(o.doorType ?? "normal") === "wandoeffnung" ? 1 : 0,
|
||||
door ? Math.max(1, Math.round(getDoorType(project, o)?.leafCount ?? 1)) : 1,
|
||||
LINTEL_CODE[o.lintelLines ?? "beide"],
|
||||
// Rahmenband
|
||||
frameSpec ? 1 : 0,
|
||||
frameSpec?.frameWidth ?? 0,
|
||||
frameSpec?.frameKind === "blockrahmen" ? 1 : 0,
|
||||
frameSpec?.insetFromFace ?? 0,
|
||||
frameSpec?.insetFace === "innen" ? 1 : 0,
|
||||
// Fenster
|
||||
wt ? 1 : 0,
|
||||
wt ? wt.frameWidth ?? 0.06 : 0,
|
||||
wt?.frameDepth ?? Number.NaN,
|
||||
wt?.insetFromFace ?? Number.NaN,
|
||||
wt?.insetFace === "innen" ? 1 : 0,
|
||||
o.wingCount ?? Number.NaN,
|
||||
detail === "fein" ? 2 : 1,
|
||||
wt?.sillLine ? SILL_CODE[wt.sillLine.faces] : 0,
|
||||
wt?.sillLine?.view === "unter" ? 1 : 0,
|
||||
wt?.shading?.create ? 1 : 0,
|
||||
wt?.shading?.box.width ?? 0,
|
||||
wt?.shading?.box.height ?? 0,
|
||||
// Strichstärken
|
||||
SYMBOL_HAIRLINE_MM,
|
||||
o.frameLine?.weight ?? SYMBOL_HAIRLINE_MM,
|
||||
frameViewWeight,
|
||||
o.sashLine?.weight ?? SYMBOL_HAIRLINE_MM,
|
||||
o.sillLineStyle?.weight ?? SYMBOL_HAIRLINE_MM,
|
||||
sashes.length,
|
||||
];
|
||||
for (const s of sashes) {
|
||||
b.push(s.kind === "pfosten" ? 1 : 0, s.autoWidth === false ? 0 : 1, s.width ?? Number.NaN, s.postWidth ?? Number.NaN,
|
||||
s.opening && s.opening !== "fest" ? 1 : 0);
|
||||
}
|
||||
const f = core().plan_opening_flat(Float64Array.from(b));
|
||||
if (f.length === 0) return;
|
||||
const openingId = o.id;
|
||||
const n = f[0];
|
||||
let i = 1;
|
||||
for (let k = 0; k < n; k++) {
|
||||
if (f[i] === 1) {
|
||||
const count = f[i + 4];
|
||||
const pts = new Array<{ x: number; y: number }>(count);
|
||||
for (let j = 0; j < count; j++) pts[j] = { x: f[i + 5 + 2 * j], y: f[i + 6 + 2 * j] };
|
||||
const frame = f[i + 1] === 1;
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts,
|
||||
fill: "none",
|
||||
stroke: frame ? colors[f[i + 3]] : "none",
|
||||
strokeWidthMm: f[i + 2],
|
||||
hatch: NO_HATCH,
|
||||
greyed,
|
||||
openingId,
|
||||
});
|
||||
i += 5 + 2 * count;
|
||||
} else if (f[i] === 2) {
|
||||
const slot = f[i + 3];
|
||||
const dash = DASHES[f[i + 4]];
|
||||
out.push({
|
||||
kind: "line",
|
||||
a: { x: f[i + 5], y: f[i + 6] },
|
||||
b: { x: f[i + 7], y: f[i + 8] },
|
||||
cls: LINE_CLS[f[i + 1]],
|
||||
weightMm: f[i + 2],
|
||||
...(dash ? { dash } : {}),
|
||||
...(slot ? { color: colors[slot] } : {}),
|
||||
greyed,
|
||||
openingId,
|
||||
});
|
||||
i += 9;
|
||||
} else {
|
||||
out.push({
|
||||
kind: "arc",
|
||||
center: { x: f[i + 2], y: f[i + 3] },
|
||||
from: { x: f[i + 4], y: f[i + 5] },
|
||||
to: { x: f[i + 6], y: f[i + 7] },
|
||||
r: f[i + 8],
|
||||
cls: "door-swing",
|
||||
weightMm: f[i + 1],
|
||||
greyed,
|
||||
openingId,
|
||||
});
|
||||
i += 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
// Dach-Domäne des Grundriss-Generators (Dachaufsicht): reine Linien-Darstellung
|
||||
// ohne Poché — Traufe/First/Grat/Knick aus `roofGeometry`.
|
||||
|
||||
import type { LayerCategory, Project, Roof } from "../../model/types";
|
||||
import { getComponent, roofLayers } from "../../model/types";
|
||||
import { roofGeometry } from "../../geometry/roof";
|
||||
import {
|
||||
NO_HATCH,
|
||||
POCHE_STROKE,
|
||||
ROOF_BREAK_DASH,
|
||||
ROOF_BREAK_MM,
|
||||
ROOF_EAVES_MM,
|
||||
ROOF_HIP_MM,
|
||||
ROOF_RIDGE_MM,
|
||||
resolveHatch,
|
||||
type Primitive,
|
||||
} from "./shared";
|
||||
|
||||
/**
|
||||
* Dach im Grundriss (Dachaufsicht): reine Linien-Darstellung ohne Poché — die
|
||||
* 2D-Geometrie aus `roofGeometry` (First/Grat/Knick hängen NICHT von der
|
||||
* Traufhöhe ab, daher `eavesZ=0`):
|
||||
* • Traufe (`eaves`): geschlossener Umriss-Ring als mittlere Haarlinie.
|
||||
* • First (`ridges`): kräftige Volllinie, etwas stärker als die Traufe.
|
||||
* • Grat (`hips`, Walm/Zelt): Volllinie zwischen Traufe- und First-Stärke.
|
||||
* • Knick (`breaks`, Mansarde): dünne gestrichelte Linie.
|
||||
* Farbe: `roof.color` übersteuert sonst die Kategorie-Farbe (analog Stützen-
|
||||
* Poché), Default die neutrale Poché-Tinte.
|
||||
*/
|
||||
export function addRoof(
|
||||
out: Primitive[],
|
||||
project: Project,
|
||||
roof: Roof,
|
||||
greyed: boolean,
|
||||
category: LayerCategory | undefined,
|
||||
): void {
|
||||
const stroke = roof.color ?? category?.color ?? POCHE_STROKE;
|
||||
const geo = roofGeometry(roof, 0);
|
||||
|
||||
// Ansichts-Poché der Dachaufsicht: das Dach liegt ÜBER der Schnittebene und
|
||||
// wird von oben gesehen (nicht geschnitten) → Ansichts-Schraffur
|
||||
// (viewHatchId) der ÄUSSERSTEN Schicht (Eindeckung) des Dachtyps, analog dem
|
||||
// Decken-Poché (Aufsicht = erste Lage). Ohne Dachtyp/viewHatchId keine
|
||||
// Schraffur (weiss) — die Fläche bleibt trotzdem das Pick-Polygon.
|
||||
let viewHatch = NO_HATCH;
|
||||
const firstLayer = roofLayers(project, roof)[0];
|
||||
if (firstLayer?.componentId) {
|
||||
try {
|
||||
const comp = getComponent(project, firstLayer.componentId);
|
||||
if (comp.viewHatchId) viewHatch = resolveHatch(project, comp.viewHatchId);
|
||||
} catch {
|
||||
viewHatch = NO_HATCH;
|
||||
}
|
||||
}
|
||||
|
||||
// Pick-Polygon über der Traufe-Fläche (macht das Dach über die ganze Fläche
|
||||
// per Links-Klick selektierbar) — trägt jetzt zusätzlich die Ansichts-
|
||||
// Schraffur der Eindeckung (fill bleibt "none": keine Volltonfüllung, nur
|
||||
// Musterlinien). PlanView testet die `pts` (Punkt-in-Polygon).
|
||||
if (geo.eaves.length >= 3) {
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts: geo.eaves,
|
||||
fill: "none",
|
||||
stroke: "none",
|
||||
strokeWidthMm: 0,
|
||||
hatch: viewHatch,
|
||||
greyed,
|
||||
roofId: roof.id,
|
||||
});
|
||||
}
|
||||
|
||||
const n = geo.eaves.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
out.push({
|
||||
kind: "line",
|
||||
a: geo.eaves[i],
|
||||
b: geo.eaves[(i + 1) % n],
|
||||
cls: "roof-eaves",
|
||||
weightMm: ROOF_EAVES_MM,
|
||||
color: stroke,
|
||||
greyed,
|
||||
});
|
||||
}
|
||||
for (const [a, b] of geo.ridges) {
|
||||
out.push({ kind: "line", a, b, cls: "roof-ridge", weightMm: ROOF_RIDGE_MM, color: stroke, greyed });
|
||||
}
|
||||
for (const [a, b] of geo.hips) {
|
||||
out.push({ kind: "line", a, b, cls: "roof-hip", weightMm: ROOF_HIP_MM, color: stroke, greyed });
|
||||
}
|
||||
for (const [a, b] of geo.breaks) {
|
||||
out.push({
|
||||
kind: "line",
|
||||
a,
|
||||
b,
|
||||
cls: "roof-break",
|
||||
weightMm: ROOF_BREAK_MM,
|
||||
dash: ROOF_BREAK_DASH,
|
||||
color: stroke,
|
||||
greyed,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
// Raum-Domäne des Grundriss-Generators (SIA-416-Flächen): eine (unsichtbare,
|
||||
// nur klickbare) Füllfläche + dünne neutrale Umrisslinie + ein Raum-Stempel
|
||||
// (Name, Fläche, SIA-Kürzel) am Anker.
|
||||
|
||||
import type { Room } from "../../model/types";
|
||||
import { evaluateRoom, siaLabel } from "../../geometry/roomArea";
|
||||
import { docFromText } from "../../text/richText";
|
||||
import { roomStampExtraLines, roomStampToDoc } from "../../model/roomStamp";
|
||||
import { LAYER_DETAIL_FACTOR, LAYER_LINE_MM, NO_HATCH, type DetailLevel, type Primitive } from "./shared";
|
||||
|
||||
/**
|
||||
* Deckkraft (0..255) der Raum-Füllung → 2-stelliges Hex-Suffix. Transluzente
|
||||
* Farbfüllung entfällt — Plandarstellung schwarz/grau; Farbe bleibt späteren
|
||||
* Schema-Ebenen vorbehalten. Alpha 0 = unsichtbar; das Polygon bleibt als
|
||||
* `roomId`-Primitiv erhalten (Auswahl per Punkt-in-Polygon in PlanView, NICHT
|
||||
* über die native Pointer-Trefferfläche der Füllung — die volle Fläche bleibt
|
||||
* damit trotz Alpha 0 klickbar).
|
||||
*/
|
||||
const ROOM_FILL_ALPHA = "00";
|
||||
/** Basis-Schriftgrösse des Raum-Stempels in Punkt (pt). */
|
||||
const ROOM_STAMP_PT = 10;
|
||||
|
||||
/** Farbe mit Alpha-Suffix versehen (nur, wenn `color` ein 6-stelliges Hex ist). */
|
||||
function withAlpha(color: string, alphaHex: string): string {
|
||||
return /^#[0-9a-fA-F]{6}$/.test(color) ? `${color}${alphaHex}` : color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Raum (SIA-416-Fläche) im Grundriss: eine (unsichtbare, nur klickbare) Füll-
|
||||
* fläche über dem lichten Umriss + eine dünne neutrale Umrisslinie (beide
|
||||
* `roomId`-getaggt für die Auswahl) + ein Raum-Stempel (Text) am Anker
|
||||
* (Centroid oder `stampAnchor`) mit Name, Fläche „24.30 m²" und SIA-Kürzel.
|
||||
* Keine Farbwäsche — Plandarstellung schwarz/grau, Farbe bleibt späteren
|
||||
* Schema-Ebenen vorbehalten. Der Stempel entfällt beim Detailgrad „grob";
|
||||
* Fläche/Umfang/Schwerpunkt werden aus `boundary` abgeleitet (nie gespeichert).
|
||||
* Wird UNTER der Wand-Poché gezeichnet.
|
||||
*/
|
||||
export function addRoomArea(
|
||||
out: Primitive[],
|
||||
room: Room,
|
||||
greyed: boolean,
|
||||
detail: DetailLevel,
|
||||
): void {
|
||||
const pts = room.boundary;
|
||||
if (pts.length < 3) return;
|
||||
const res = evaluateRoom(pts, room.siaCategory);
|
||||
const stroke = room.color;
|
||||
|
||||
// Unsichtbare Füllfläche (Alpha 0): keine Farbwäsche im Plan, das Polygon
|
||||
// bleibt aber als `roomId`-Primitiv für die Punkt-in-Polygon-Auswahl erhalten.
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts,
|
||||
fill: withAlpha(room.color, ROOM_FILL_ALPHA),
|
||||
stroke,
|
||||
strokeWidthMm: LAYER_LINE_MM * LAYER_DETAIL_FACTOR[detail],
|
||||
hatch: NO_HATCH,
|
||||
greyed,
|
||||
roomId: room.id,
|
||||
});
|
||||
|
||||
// Raum-Stempel: frei editierbarer Rich-Text (Name/Notizen) + LIVE-Flächenzeile
|
||||
// + SIA-Kürzel. Anker fix (stampAnchor, sonst Centroid). Nur ab Detailgrad
|
||||
// „mittel". Die Flächenzeile aktualisiert sich unabhängig vom editierten Text.
|
||||
if (detail !== "grob") {
|
||||
const at = room.stampAnchor ?? res.centroid;
|
||||
// Strukturierter Stempel (Feldmodell) hat Vorrang; sonst Alt-Pfad (Rich-Text
|
||||
// bzw. Raum-Name als einfacher Text).
|
||||
const doc = room.stamp
|
||||
? roomStampToDoc(room.stamp)
|
||||
: room.stampDoc ?? docFromText(room.name);
|
||||
const extraLines = room.stamp
|
||||
? roomStampExtraLines(room.stamp, {
|
||||
netArea: res.netArea,
|
||||
siaCategory: room.siaCategory,
|
||||
siaLabel: siaLabel(room.siaCategory),
|
||||
})
|
||||
: [
|
||||
{ text: `${res.netArea.toFixed(2)} m²`, align: "center" as const },
|
||||
{
|
||||
text: `${room.siaCategory} · ${siaLabel(room.siaCategory)}`,
|
||||
align: "center" as const,
|
||||
},
|
||||
];
|
||||
out.push({
|
||||
kind: "text",
|
||||
at,
|
||||
doc,
|
||||
extraLines,
|
||||
basePt: ROOM_STAMP_PT,
|
||||
color: stroke,
|
||||
roomId: room.id,
|
||||
greyed,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
// Schnittführungs-Symbol-Domäne des Grundriss-Generators (klassische
|
||||
// Strichpunkt-Schnittlinie mit Endmarken + Label) — NICHT zu verwechseln mit
|
||||
// `generateSectionPlan()` (der Schnitt-ALS-Plan-Übersetzung, bleibt Orchestrator
|
||||
// in `../generatePlan.ts`): diese Domäne zeichnet nur das Führungssymbol EINER
|
||||
// Schnitt-/Ansichtsebene IM Grundriss. Die Geometrie berechnet der Rust-Kern (`plan_misc.rs`, [K3a]).
|
||||
|
||||
import { core } from "../../engine/coreWasm";
|
||||
import type { Project } from "../../model/types";
|
||||
import { NO_HATCH, SHOW_ALL, type CategoryDisplayResolver, type Primitive } from "./shared";
|
||||
|
||||
/**
|
||||
* Kategorie-Code der Schnittführungs-Symbole — feste Zuordnung zu "90"
|
||||
* (Referenzen), derselben Kategorie wie Kontext-Konturen/Höhenlinien:
|
||||
* Schnittlinien sind Dokumentations-/Referenzelemente, keine Bauteile, und
|
||||
* bekommen deshalb kein eigenes Sichtbarkeits-Flag mehr am DrawingLevel —
|
||||
* sie sind ein Element AUF einer Ebene und werden NUR darüber (Ebenen-Panel,
|
||||
* visibleCodes/categoryDisplay) ein-/ausgeblendet, wie jedes andere Bauteil.
|
||||
*/
|
||||
const SECTION_LINE_CATEGORY = "90";
|
||||
|
||||
/** Tinte der Schnittführungs-Linie/Marken (kräftiges Grau). */
|
||||
const SECTION_LINE_INK = "#1f242c";
|
||||
/** Haarlinie der Strichpunkt-Schnittlinie (mm Papier). */
|
||||
const SECTION_LINE_MM = 0.18;
|
||||
/** Kräftige Endmarken (Querstrich + Pfeil) (mm Papier). */
|
||||
const SECTION_LINE_MARK_MM = 0.5;
|
||||
/** Strichpunkt-Muster der Schnittlinie (lange Striche + Punkt, mm Papier). */
|
||||
const SECTION_LINE_DASH: number[] = [6, 1.5, 0.4, 1.5];
|
||||
/** Schrifthöhe des Schnitt-Labels (Modell-Meter). */
|
||||
const SECTION_LABEL_H = 0.5;
|
||||
|
||||
/**
|
||||
* Kurz-Tag eines Schnitt-Labels: der letzte „Wort"-Teil des Ebenennamens (z. B.
|
||||
* „Schnitt A" → „A"); enthält der Name kein Leerzeichen, der ganze Name. Klassisch
|
||||
* wird der Schnitt an beiden Enden mit diesem Tag beschriftet (A–A).
|
||||
*/
|
||||
function sectionLabelTag(name: string): string {
|
||||
const parts = name.trim().split(/\s+/);
|
||||
return parts.length > 1 ? parts[parts.length - 1] : name.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeichnet für jede Schnitt-/Ansichtsebene MIT gesetzter `linePoints` das
|
||||
* klassische Schnittführungs-Symbol in den Grundriss: eine Strichpunkt-Haarlinie
|
||||
* über die volle Länge, an beiden Enden einen kräftigen Querstrich + Richtungspfeil
|
||||
* auf der Blickseite (`directionSign`) und das Schnitt-Label (Kurz-Tag) daneben.
|
||||
* Zusätzlich ein unsichtbares Pick-Band (Polygon mit `sectionLineId`), damit die
|
||||
* Linie im Grundriss anklickbar ist (analog dem Dach-Traufe-Pick-Polygon).
|
||||
*
|
||||
* Sichtbarkeit/Dimmen läuft über die Kategorie "90" (Referenzen) — genau wie
|
||||
* bei Wänden/Decken/Räumen, NICHT über das eigene Sichtbarkeits-Flag der
|
||||
* Schnitt-/Ansichtsebene (Nutzer-Feedback: "diese sollten Elemente sein, die
|
||||
* sich auf einer Ebene befinden und nur damit ein-/ausgeblendet werden").
|
||||
* `visibleCodes`/`categoryDisplay` fehlen sie (Export-/Print-Pfad ohne
|
||||
* Ebenen-Filter) → immer sichtbar, wie bisher.
|
||||
*/
|
||||
export function addSectionLines(
|
||||
out: Primitive[],
|
||||
project: Project,
|
||||
visibleCodes?: Set<string>,
|
||||
categoryDisplay: CategoryDisplayResolver = SHOW_ALL,
|
||||
): void {
|
||||
const d = categoryDisplay(SECTION_LINE_CATEGORY);
|
||||
if ((visibleCodes && !visibleCodes.has(SECTION_LINE_CATEGORY)) || !d.render) return;
|
||||
const greyed = d.greyed;
|
||||
for (const level of project.drawingLevels) {
|
||||
if (level.kind !== "section" && level.kind !== "elevation") continue;
|
||||
const line = level.linePoints;
|
||||
if (!line) continue;
|
||||
const [p0, p1] = line;
|
||||
const f = core().section_line_flat(p0.x, p0.y, p1.x, p1.y, level.directionSign ?? 1);
|
||||
if (f.length === 0) continue;
|
||||
let i = 1;
|
||||
for (let k = 0; k < f[0]; k++) {
|
||||
if (f[i] === 2) {
|
||||
const main = f[i + 1] === 0;
|
||||
out.push({
|
||||
kind: "line",
|
||||
a: { x: f[i + 2], y: f[i + 3] },
|
||||
b: { x: f[i + 4], y: f[i + 5] },
|
||||
cls: "section-line",
|
||||
weightMm: main ? SECTION_LINE_MM : SECTION_LINE_MARK_MM,
|
||||
...(main ? { dash: SECTION_LINE_DASH } : {}),
|
||||
color: SECTION_LINE_INK,
|
||||
greyed,
|
||||
});
|
||||
i += 6;
|
||||
} else if (f[i] === 5) {
|
||||
out.push({
|
||||
kind: "drawingText",
|
||||
at: { x: f[i + 1], y: f[i + 2] },
|
||||
text: sectionLabelTag(level.name),
|
||||
heightM: SECTION_LABEL_H,
|
||||
angle: 0,
|
||||
color: SECTION_LINE_INK,
|
||||
greyed,
|
||||
});
|
||||
i += 3;
|
||||
} else {
|
||||
// Unsichtbares Pick-Band (Rechteck entlang der Linie) — klickbar per Punkt-in-Polygon in
|
||||
// PlanView, trägt die DrawingLevel-Id.
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts: [0, 1, 2, 3].map((j) => ({ x: f[i + 1 + 2 * j], y: f[i + 2 + 2 * j] })),
|
||||
fill: "none",
|
||||
stroke: "none",
|
||||
strokeWidthMm: 0,
|
||||
hatch: NO_HATCH,
|
||||
sectionLineId: level.id,
|
||||
});
|
||||
i += 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
// Gemeinsame Grundlage des Grundriss-Generators: das `Primitive`-Vokabular
|
||||
// (das EINZIGE Austauschformat zwischen `generatePlan()`/`generateSectionPlan()`
|
||||
// und allen Bauteil-Domänen unter `generatePlan/`), die By-Layer/By-Object-
|
||||
// und den Domänen — unter `generatePlan/` in TS, die meisten im Rust-Kern mit
|
||||
// derselben JSON-Form, `src-tauri/core/src/plan/prim.rs`), die By-Layer/By-Object-
|
||||
// Attribut-Auflösung (`resolve*`) sowie die Papier-mm-/Tinten-Konstanten, die
|
||||
// über mehrere Domänen hinweg identisch gelten müssen (SIA-Poché, Haarlinien).
|
||||
//
|
||||
@@ -53,33 +54,8 @@ export const MONO_INK = "#111111";
|
||||
* gleiche Stärke wie die Schraffur-Tinte. Pro Fuge im Wandstil überschreibbar
|
||||
* (z. B. 0.13, wenn zwei massive Materialien aufeinandertreffen). */
|
||||
export const LAYER_LINE_MM = 0.02;
|
||||
/** Haarlinie für Tür-/Fenstersymbole (Flügel, Bogen, Rahmen, Glas) in mm. */
|
||||
export const SYMBOL_HAIRLINE_MM = 0.02;
|
||||
/** Strichmuster (mm Papier) für ÜBERKOPF-Ansichtslinien: Bauteile über der
|
||||
* Grundriss-Schnittebene (Decken-/Slab-Überstände, Unterzüge) werden nach
|
||||
* BIM-Konvention gestrichelt gezeichnet (Aufsicht auf ein Bauteil über einem). */
|
||||
export const OVERHEAD_DASH: number[] = [0.4, 0.25];
|
||||
/** Strichstärken der Dach-Grundrisslinien (mm Papier): Traufe = mittlere
|
||||
* Haarlinie, First etwas kräftiger als die Traufe, Grat dazwischen, Knick dünn
|
||||
* + gestrichelt (vgl. addRoof). */
|
||||
export const ROOF_EAVES_MM = 0.13;
|
||||
export const ROOF_RIDGE_MM = 0.25;
|
||||
export const ROOF_HIP_MM = 0.18;
|
||||
export const ROOF_BREAK_MM = 0.09;
|
||||
/** Strichmuster (mm Papier) der Dach-Knicklinie (Mansarde). */
|
||||
export const ROOF_BREAK_DASH: number[] = [0.12, 0.08];
|
||||
/** Stärke der Wand-Umrisslinie je Detailgrad, als Faktor auf die Ebenen-lw. */
|
||||
export const OUTLINE_DETAIL_FACTOR: Record<DetailLevel, number> = {
|
||||
grob: 1.6, // dickere Sammellinie
|
||||
mittel: 1.0, // wie die Kategorie-Strichstärke
|
||||
fein: 0.6, // feiner
|
||||
};
|
||||
/** Stärke der Schichtfugen je Detailgrad (mittel/fein; grob hat keine Fugen). */
|
||||
export const LAYER_DETAIL_FACTOR: Record<DetailLevel, number> = {
|
||||
grob: 1.0,
|
||||
mittel: 1.0,
|
||||
fein: 0.7,
|
||||
};
|
||||
// Strichstärken und -muster der Bauteil-Domänen (Symbole, Überkopf, Dach, Detailgrad-Faktoren) stehen
|
||||
// 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;
|
||||
@@ -611,11 +587,6 @@ export function resolveStrokeWeight(
|
||||
// einheitlich Tinte auf hellem Papier, unabhängig von Material-/Bauteilfarbe.
|
||||
export const HATCH_PAPER = "#f0f0f0";
|
||||
export const HATCH_INK = "#0f0f0f";
|
||||
/** Neutrale Poché-Füllfarbe für ein Muster: "solid" → Tinte, sonst Papier. */
|
||||
export function pocheFill(pattern: HatchPattern): string {
|
||||
return pattern === "solid" ? HATCH_INK : HATCH_PAPER;
|
||||
}
|
||||
|
||||
/** Schraffur-Platzhalter „ohne" (für reine Umriss-/Sammelflächen). */
|
||||
export const NO_HATCH: HatchRender = {
|
||||
pattern: "none",
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
// Treppen-Domäne des Grundriss-Generators (DOSSIER/SIA): Tritte, Lauflinie mit
|
||||
// Auf-/Abpfeil, Zwischenpodest und Aussenlinie — mit dem Grundriss-Schnitt
|
||||
// (Tritte unter der Schnitthöhe durchgezogen, darüber gestrichelt/verdeckt +
|
||||
// SIA-Bruchlinie).
|
||||
//
|
||||
// Die Primitive entstehen im Rust-Kern (`src-tauri/core/src/plan_stairs.rs`, [K3a]); hier nur die
|
||||
// Übersetzung der flachen Liste in `Primitive`-Objekte (Farbe, Graustufen, `stairId`).
|
||||
// Fällt mit [K3d] weg, wenn der Plan-Puffer direkt aus Rust kommt.
|
||||
|
||||
import type { Project, Stair } from "../../model/types";
|
||||
import { stairVerticalExtent } from "../../model/wall";
|
||||
import { encodeStair } from "../../geometry/stair";
|
||||
import { core } from "../../engine/coreWasm";
|
||||
import { NO_HATCH, POCHE_STROKE, type Primitive } from "./shared";
|
||||
|
||||
/** Linienklassen in der Reihenfolge der Kern-Kodierung (`plan_stairs.rs`). */
|
||||
const LINE_CLS = ["stair-outline", "stair-tread", "stair-break", "stair-run", "stair-arrow"] as const;
|
||||
/** Strichmuster der verdeckten Tritte (Meter). */
|
||||
const TREAD_DASH = [0.12, 0.08];
|
||||
|
||||
/**
|
||||
* Treppen-Symbol im Grundriss (DOSSIER/SIA):
|
||||
* • Tritte als Rechtecke: die Tritt-Trennlinien werden gezeichnet — unter der
|
||||
* Schnittebene DURCHGEZOGEN (sichtbar), darüber GESTRICHELT (verdeckt).
|
||||
* • Der erste Tritt oberhalb der Schnittebene trägt die diagonale SIA-Bruchlinie
|
||||
* (Doppelstrich quer über den Lauf).
|
||||
* • Zwischenpodest (L/Wendel) als Umriss-Polygon.
|
||||
* • Lauflinie (Lauflinie) mit Auf-/Abpfeil (Auf-/Abpfeil) und Stufenanzahl-Label.
|
||||
* Alle Primitive tragen `stairId` für die Auswahl.
|
||||
*/
|
||||
export function addStairSymbol(
|
||||
out: Primitive[],
|
||||
project: Project,
|
||||
stair: Stair,
|
||||
greyed: boolean,
|
||||
lwMm: number,
|
||||
cutHeight: number,
|
||||
): void {
|
||||
const { zBottom, zTop } = stairVerticalExtent(project, stair);
|
||||
const f = core().plan_stair_flat(
|
||||
encodeStair(stair),
|
||||
zTop - zBottom,
|
||||
cutHeight,
|
||||
lwMm,
|
||||
stair.arrowStyle === "filled" ? 1 : 0,
|
||||
);
|
||||
if (f.length === 0) return;
|
||||
const stroke = stair.color ?? POCHE_STROKE;
|
||||
const stairId = stair.id;
|
||||
const n = f[0];
|
||||
let i = 1;
|
||||
for (let k = 0; k < n; k++) {
|
||||
switch (f[i]) {
|
||||
case 1: {
|
||||
const count = f[i + 3];
|
||||
const pts = new Array<{ x: number; y: number }>(count);
|
||||
for (let j = 0; j < count; j++) pts[j] = { x: f[i + 4 + 2 * j], y: f[i + 5 + 2 * j] };
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts,
|
||||
fill: f[i + 2] ? stroke : "none",
|
||||
stroke,
|
||||
strokeWidthMm: f[i + 1],
|
||||
hatch: NO_HATCH,
|
||||
greyed,
|
||||
stairId,
|
||||
});
|
||||
i += 4 + 2 * count;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
out.push({
|
||||
kind: "line",
|
||||
a: { x: f[i + 4], y: f[i + 5] },
|
||||
b: { x: f[i + 6], y: f[i + 7] },
|
||||
cls: LINE_CLS[f[i + 1]],
|
||||
weightMm: f[i + 2],
|
||||
...(LINE_CLS[f[i + 1]] === "stair-tread" ? { dash: f[i + 3] ? TREAD_DASH : null } : {}),
|
||||
color: stroke,
|
||||
greyed,
|
||||
stairId,
|
||||
});
|
||||
i += 8;
|
||||
break;
|
||||
default:
|
||||
out.push({
|
||||
kind: "arc",
|
||||
center: { x: f[i + 2], y: f[i + 3] },
|
||||
from: { x: f[i + 4], y: f[i + 5] },
|
||||
to: { x: f[i + 6], y: f[i + 7] },
|
||||
r: f[i + 8],
|
||||
cls: "stair-outline",
|
||||
weightMm: f[i + 1],
|
||||
greyed,
|
||||
stairId,
|
||||
});
|
||||
i += 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
// Sonstige Tragwerks-/Fremdkörper-Domäne des Grundriss-Generators: Stützen
|
||||
// (Poché-Querschnitt, analog zur Wand-/Deckenschicht-Auflösung) und der
|
||||
// Footprint-Umriss einer truck-Extrusion (Haarlinie ohne Poché/Schraffur, da
|
||||
// Extrusionen noch keine Kategorie-/Bauteil-Zuordnung tragen).
|
||||
|
||||
import type { Column, ExtrudedSolid, LayerCategory, Project } from "../../model/types";
|
||||
import { getComponent } from "../../model/types";
|
||||
import { columnFootprint } from "../../geometry/column";
|
||||
import {
|
||||
HATCH_INK,
|
||||
HATCH_PAPER,
|
||||
MONO_INK,
|
||||
NO_HATCH,
|
||||
SYMBOL_HAIRLINE_MM,
|
||||
resolveBackground,
|
||||
resolveForeground,
|
||||
resolveHatch,
|
||||
resolveHatchId,
|
||||
type HatchRender,
|
||||
type Primitive,
|
||||
} from "./shared";
|
||||
|
||||
/** Footprint-Farbe der truck-Extrusionen im Grundriss (identisch zum 3D-Orange EXTRUSION_RGB in toWalls3d.ts). */
|
||||
const EXTRUSION_STROKE = "#d98c40";
|
||||
|
||||
/**
|
||||
* Footprint-Umriss eines extrudierten Körpers (truck-Integration) im Grundriss:
|
||||
* reine Haarlinie ohne Füllung/Schraffur — analog zur Ansichtslinie einer Wand
|
||||
* unter der Schnitthöhe (`addWallPoche` `viewOnly`), da der Körper (noch)
|
||||
* keine Schnitt-Poché/Kategorie-Zuordnung hat.
|
||||
*/
|
||||
export function addExtrudedSolidOutline(out: Primitive[], solid: ExtrudedSolid): void {
|
||||
if (solid.operation === "subtract") {
|
||||
// Abzugskörper (Aussparung): gestrichelter Umriss + Diagonalkreuz (Durchbruch-Symbol),
|
||||
// darunter eine unsichtbare Fläche für die Auswahl.
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts: solid.points,
|
||||
fill: "none",
|
||||
stroke: "none",
|
||||
strokeWidthMm: 0,
|
||||
hatch: NO_HATCH,
|
||||
extrudedSolidId: solid.id,
|
||||
});
|
||||
const n = solid.points.length;
|
||||
const seg = (a: (typeof solid.points)[number], b: (typeof solid.points)[number], dash: number[] | null) =>
|
||||
out.push({ kind: "line", a, b, cls: "void", weightMm: SYMBOL_HAIRLINE_MM, dash, color: EXTRUSION_STROKE });
|
||||
for (let i = 0; i < n; i++) seg(solid.points[i], solid.points[(i + 1) % n], [2, 1]);
|
||||
if (n === 4) {
|
||||
seg(solid.points[0], solid.points[2], null);
|
||||
seg(solid.points[1], solid.points[3], null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts: solid.points,
|
||||
fill: "none",
|
||||
stroke: EXTRUSION_STROKE,
|
||||
strokeWidthMm: SYMBOL_HAIRLINE_MM,
|
||||
hatch: NO_HATCH,
|
||||
extrudedSolidId: solid.id,
|
||||
});
|
||||
}
|
||||
|
||||
/** Fallback-Poché-Füllung einer Stütze ohne (auflösbares) Bauteil: neutrale Tinte. */
|
||||
const COLUMN_FALLBACK_FILL = "#3a3f47";
|
||||
|
||||
/**
|
||||
* Grundriss-Querschnitt einer Stütze (Column) als Schnitt-Poché: gefülltes
|
||||
* Polygon (Rechteck bzw. tesselliertes Kreisprofil), an `position` platziert und
|
||||
* um `rotation` gedreht. Trägt — sofern ein Bauteil (`componentId`) auflösbar ist
|
||||
* — dessen Füllung + Schraffur (dieselbe Auflösung wie Wand/Decke, {@link
|
||||
* ./shared.resolveHatch}); sonst eine neutrale Vollton-Poché. `columnId` macht
|
||||
* die Fläche links-klick-selektierbar (analog Extrusion/Raum).
|
||||
*/
|
||||
export function addColumnPoche(
|
||||
out: Primitive[],
|
||||
project: Project,
|
||||
column: Column,
|
||||
greyed: boolean,
|
||||
lwMm: number,
|
||||
category: LayerCategory | undefined,
|
||||
): void {
|
||||
const pts = columnFootprint(column);
|
||||
const stroke = column.color ?? category?.color ?? MONO_INK;
|
||||
let fill = column.color ?? category?.color ?? COLUMN_FALLBACK_FILL;
|
||||
let hatch: HatchRender = NO_HATCH;
|
||||
if (column.componentId) {
|
||||
try {
|
||||
const comp = getComponent(project, column.componentId);
|
||||
const hatchId =
|
||||
resolveHatchId(column.hatchId, column.hatchSource, category, comp.hatchId) ?? comp.hatchId;
|
||||
const resolved = resolveHatch(
|
||||
project,
|
||||
hatchId,
|
||||
undefined,
|
||||
resolveForeground(comp, column.foreground, category, column.foregroundSource),
|
||||
);
|
||||
hatch = resolved;
|
||||
// SIA-Poché: neutraler Hintergrund (Tinte/Papier je nach Muster) statt
|
||||
// Bauteil-Albedo, es sei denn ein expliziter Hintergrund-Override greift
|
||||
// (analog addWallPoche: bgOverride ?? neutrale Poché).
|
||||
const bgOverride = resolveBackground(comp, column.background, category, column.backgroundSource);
|
||||
fill = bgOverride ?? (resolved.pattern === "solid" ? HATCH_INK : HATCH_PAPER);
|
||||
} catch {
|
||||
// Bauteil nicht auflösbar → neutrale Poché (Fallback bleibt bestehen).
|
||||
}
|
||||
}
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts,
|
||||
fill,
|
||||
stroke,
|
||||
strokeWidthMm: lwMm,
|
||||
hatch,
|
||||
greyed,
|
||||
columnId: column.id,
|
||||
});
|
||||
}
|
||||
@@ -1,289 +0,0 @@
|
||||
// Wand-Domäne des Grundriss-Generators: Öffnungs-Lücken entlang der Wandachse,
|
||||
// die Wand-Footprints (für das Verdecken darunterliegender Decken-Umrisse, s.
|
||||
// {@link ../ceilings}) und die eigentliche Wand-Poché (Schichten + Umriss +
|
||||
// Öffnungsaussparungen + T-Stoss-/Gehrungs-Behandlung).
|
||||
//
|
||||
// Die Geometrie der Poché entsteht im Rust-Kern (`src-tauri/core/src/plan_walls.rs`, [K3a]); hier
|
||||
// bleibt die Stilauflösung aus dem Modell (Bauteil, Schraffur, Farbe, Fugen-Linienstil) und die
|
||||
// Übersetzung in `Primitive`-Objekte. Fällt mit [K3d] weg.
|
||||
|
||||
import type { LayerCategory, Opening, Project, Vec2, Wall } from "../../model/types";
|
||||
import { getComponent, getWallType, wallTypeThickness } from "../../model/types";
|
||||
import { wallReferenceOffset } from "../../model/wall";
|
||||
import { openingInterval } from "../../geometry/opening";
|
||||
import { leftNormal, normalize, sub } from "../../model/geometry";
|
||||
import type { Line } from "../../model/geometry";
|
||||
import type { WallCuts } from "../../model/joins";
|
||||
import { core } from "../../engine/coreWasm";
|
||||
import {
|
||||
HATCH_INK,
|
||||
HATCH_PAPER,
|
||||
LAYER_DETAIL_FACTOR,
|
||||
LAYER_LINE_MM,
|
||||
NO_HATCH,
|
||||
OUTLINE_DETAIL_FACTOR,
|
||||
POCHE_STROKE,
|
||||
resolveBackground,
|
||||
resolveForeground,
|
||||
resolveHatch,
|
||||
resolveHatchId,
|
||||
type DetailLevel,
|
||||
type HatchRender,
|
||||
type Primitive,
|
||||
} from "./shared";
|
||||
|
||||
/** Ein Öffnungs-Intervall entlang der Wandachse (from..to in Metern). `headHeight`
|
||||
* = Sturzhöhe (OK der Öffnung über der Wand-UK) für die 3D-Aussparung; im Plan
|
||||
* ungenutzt, aber Teil des gemeinsamen Vertrags mit dem 3D-Pfad. */
|
||||
export interface WallGap {
|
||||
from: number;
|
||||
to: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wandet die Öffnungen (`Opening`: Fenster und Türen) einer Wand zu einer
|
||||
* sortierten Lücken-Intervall-Liste entlang der Wandachse. Entartete Intervalle
|
||||
* (Breite ≤ 0 oder außerhalb der Achse) werden verworfen.
|
||||
*/
|
||||
export function wallGaps(
|
||||
wall: Wall,
|
||||
openings: Opening[],
|
||||
): WallGap[] {
|
||||
const gaps: WallGap[] = [];
|
||||
for (const o of openings) {
|
||||
const iv = openingInterval(wall, o);
|
||||
if (iv) gaps.push(iv);
|
||||
}
|
||||
return gaps.sort((a, b) => a.from - b.from);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wand-Footprint als orientiertes Rechteck (OBB) für das Verdecken der
|
||||
* darunterliegenden Decke im Grundriss: Achs-Startpunkt + Einheits-Richtung `u`
|
||||
* und -Normale `m`, Halbdicke, Referenz-Querversatz (Wandachse↔Bandmitte) und
|
||||
* Achslänge. Die u-Ausdehnung wird beim Test an beiden Enden um die Halbdicke
|
||||
* verlängert, damit auch die Eck-Überlappe (Gehrungen) sicher abgedeckt sind.
|
||||
*/
|
||||
export interface WallFootprint {
|
||||
a: Vec2;
|
||||
u: Vec2;
|
||||
m: Vec2;
|
||||
len: number;
|
||||
half: number;
|
||||
refOff: number;
|
||||
}
|
||||
|
||||
/** Baut die Wand-Footprints (OBBs) aus den gerenderten Wänden. Nicht auflösbarer
|
||||
* Wandtyp ⇒ Default-Dicke 0.2 m (wie der Vollkörper-Fallback im 3D-Emitter). */
|
||||
export function buildWallFootprints(project: Project, walls: Wall[]): WallFootprint[] {
|
||||
const out: WallFootprint[] = [];
|
||||
for (const w of walls) {
|
||||
let t = 0.2;
|
||||
try {
|
||||
t = wallTypeThickness(getWallType(project, w));
|
||||
} catch {
|
||||
// Default-Dicke behalten.
|
||||
}
|
||||
const u = normalize(sub(w.end, w.start));
|
||||
out.push({
|
||||
a: w.start,
|
||||
u,
|
||||
m: leftNormal(u),
|
||||
len: Math.hypot(w.end.x - w.start.x, w.end.y - w.start.y),
|
||||
half: t / 2,
|
||||
refOff: wallReferenceOffset(w, t),
|
||||
});
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
const lineBuf = (l: Line | null | undefined): number[] =>
|
||||
l ? [1, l.point.x, l.point.y, l.dir.x, l.dir.y] : [0, 0, 0, 0, 0];
|
||||
|
||||
/** Eingabe der Kern-Funktion `plan_wall_poche_flat` (Aufbau: `plan_walls.rs`). */
|
||||
function encodeWallPoche(
|
||||
wall: Wall,
|
||||
layerThickness: number[],
|
||||
total: number,
|
||||
refOff: number,
|
||||
gaps: WallGap[],
|
||||
cuts: WallCuts,
|
||||
grob: boolean,
|
||||
viewOnly: boolean,
|
||||
): Float64Array {
|
||||
const b: number[] = [wall.start.x, wall.start.y, wall.end.x, wall.end.y, total, refOff, grob ? 1 : 0, viewOnly ? 1 : 0];
|
||||
b.push(layerThickness.length, ...layerThickness);
|
||||
b.push(...lineBuf(cuts.startCut), ...lineBuf(cuts.endCut));
|
||||
const lc = cuts.layerCuts;
|
||||
b.push(lc ? 1 : 0);
|
||||
if (lc) {
|
||||
for (let i = 0; i < layerThickness.length; i++) {
|
||||
b.push(...lineBuf(lc.start[i]), ...lineBuf(lc.end[i]), ...lineBuf(lc.startSide[i]), ...lineBuf(lc.endSide[i]));
|
||||
}
|
||||
}
|
||||
const sc = cuts.spanCutouts ?? [];
|
||||
b.push(sc.length);
|
||||
for (const c of sc) b.push(c.from, c.to, c.offA, c.offB);
|
||||
b.push(gaps.length);
|
||||
for (const g of gaps) b.push(g.from, g.to);
|
||||
return Float64Array.from(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wand als gefüllte Schnittfläche (Poché), um Öffnungen ausgespart.
|
||||
*
|
||||
* Detailgrad:
|
||||
* • mittel/fein — jede Schicht des Wandtyps als eigenes Band (Füllfarbe +
|
||||
* Schraffur des Bauteils), dazu eine kräftige Wand-Umrisslinie. fein zeichnet
|
||||
* Schichtfugen und Umriss dünner als mittel.
|
||||
* • grob — KEINE Schichten, KEINE Schraffur: eine einzige Sammelfläche über die
|
||||
* volle Wanddicke (Füllung = Farbe des „Backbone"-Bauteils mit höchster
|
||||
* joinPriority) mit dicker Umrisslinie. Bewusst vereinfacht (≙ DOSSIER
|
||||
* „Einfach").
|
||||
*
|
||||
* Segmente, Gehrungsbänder, Schichtfugen und Durchgangswand-Aussparungen berechnet der Kern;
|
||||
* hier kommen nur Stil und Pick-ID (`wallId`) dazu.
|
||||
*/
|
||||
export function addWallPoche(
|
||||
out: Primitive[],
|
||||
project: Project,
|
||||
wall: Wall,
|
||||
gaps: WallGap[],
|
||||
cuts: WallCuts,
|
||||
greyed: boolean,
|
||||
detail: DetailLevel,
|
||||
wallLwMm: number,
|
||||
category: LayerCategory | undefined,
|
||||
// Wand liegt GANZ unter der Grundriss-Schnittebene (z. B. 30-cm-Brüstung bei
|
||||
// 1 m Schnitthöhe) → „von oben gesehen": nur Ansichts-Umriss (Haarlinie), KEINE
|
||||
// Schnitt-Poché/Schraffur/Schichten. Der reguläre Schnittfall bleibt `false`.
|
||||
viewOnly: boolean,
|
||||
): void {
|
||||
const wt = getWallType(project, wall);
|
||||
const total = wallTypeThickness(wt);
|
||||
const refOff = wallReferenceOffset(wall, total);
|
||||
const wallId = wall.id;
|
||||
// Achswinkel der Wand (Modell, Grad) — treibt wandbezogene Schraffuren ({@link resolveHatch}).
|
||||
const wallAngleDeg =
|
||||
(Math.atan2(wall.end.y - wall.start.y, wall.end.x - wall.start.x) * 180) / Math.PI;
|
||||
// Strich-/Umrandungsfarbe der Wand: optionale Übersteuerung (wall.color), sonst der
|
||||
// Default-Poché-Strich. Betrifft NUR die Linienfarbe, nicht die Schicht-Füllfarben/Schraffuren.
|
||||
const stroke = wall.color ?? POCHE_STROKE;
|
||||
const outlineMm = wallLwMm * OUTLINE_DETAIL_FACTOR[detail];
|
||||
const layerLineMm = LAYER_LINE_MM * LAYER_DETAIL_FACTOR[detail];
|
||||
|
||||
const f = core().plan_wall_poche_flat(
|
||||
encodeWallPoche(wall, wt.layers.map((l) => l.thickness), total, refOff, gaps, cuts, detail === "grob", viewOnly),
|
||||
);
|
||||
if (f.length === 0) return;
|
||||
|
||||
// Stil je Schicht erst beim ersten Band lösen (wie zuvor: nur wenn die Wand Segmente hat).
|
||||
const layerStyle = new Map<number, { hatch: HatchRender; fill: string }>();
|
||||
const styleOf = (li: number) => {
|
||||
let st = layerStyle.get(li);
|
||||
if (!st) {
|
||||
const comp = getComponent(project, wt.layers[li].componentId);
|
||||
const layerHatchId =
|
||||
resolveHatchId(wall.hatchId, wall.hatchSource, category, comp.hatchId) ?? comp.hatchId;
|
||||
const hatch = resolveHatch(
|
||||
project,
|
||||
layerHatchId,
|
||||
wallAngleDeg,
|
||||
resolveForeground(comp, wall.foreground, category, wall.foregroundSource),
|
||||
);
|
||||
// SIA-Poché: neutraler Hintergrund (Papier) statt Bauteil-Albedo, die Schichtschraffur
|
||||
// (fest in HATCH_INK, siehe resolveHatch) liegt darüber; Vollmuster ("solid") = Tinten-Poché.
|
||||
const bgOverride = resolveBackground(comp, wall.background, category, wall.backgroundSource);
|
||||
st = { hatch, fill: bgOverride ?? (hatch.pattern === "solid" ? HATCH_INK : HATCH_PAPER) };
|
||||
layerStyle.set(li, st);
|
||||
}
|
||||
return st;
|
||||
};
|
||||
|
||||
const n = f[0];
|
||||
let i = 1;
|
||||
for (let k = 0; k < n; k++) {
|
||||
if (f[i] === 1) {
|
||||
const art = f[i + 1];
|
||||
const li = f[i + 2];
|
||||
const nNo = f[i + 3];
|
||||
const noStrokeEdges = Array.from(f.subarray(i + 4, i + 4 + nNo));
|
||||
const q = i + 4 + nNo;
|
||||
const pts = [0, 1, 2, 3].map((j) => ({ x: f[q + 2 * j], y: f[q + 2 * j + 1] }));
|
||||
i = q + 8;
|
||||
if (art === 2) {
|
||||
const st = styleOf(li);
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts,
|
||||
fill: st.fill,
|
||||
// Band ohne Umriss: keine Schichtfuge über die Bandkante, keine 45°-Naht am Knoten.
|
||||
// Die Fugen kommen als separate `line`-Primitive.
|
||||
stroke: "none",
|
||||
strokeWidthMm: 0,
|
||||
hatch: st.hatch,
|
||||
greyed,
|
||||
noStrokeEdges,
|
||||
wallId,
|
||||
});
|
||||
} else {
|
||||
out.push({
|
||||
kind: "polygon",
|
||||
pts,
|
||||
// Grob: immer Vollschwarz-Füllung gemäss SIA 400 Anhang B.9, Figur 36.
|
||||
fill: art === 1 ? HATCH_INK : "none",
|
||||
stroke,
|
||||
strokeWidthMm: art === 0 ? layerLineMm : outlineMm,
|
||||
hatch: NO_HATCH,
|
||||
greyed,
|
||||
noStrokeEdges,
|
||||
wallId,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const art = f[i + 1];
|
||||
const li = f[i + 2];
|
||||
const a = { x: f[i + 3], y: f[i + 4] };
|
||||
const b = { x: f[i + 5], y: f[i + 6] };
|
||||
i += 7;
|
||||
if (art === 0) {
|
||||
out.push({ kind: "line", a, b, cls: "layer-joint-l", weightMm: layerLineMm, color: stroke, greyed });
|
||||
} else if (art === 1) {
|
||||
// Innere Schichtfuge: Stil aus layer.jointLineStyleId (Gewicht/Farbe/Strich), Rückfall =
|
||||
// Haarlinie in Wandfarbe.
|
||||
const id = wt.layers[li].jointLineStyleId;
|
||||
const jls = id ? project.lineStyles.find((l) => l.id === id) : undefined;
|
||||
out.push({
|
||||
kind: "line",
|
||||
a,
|
||||
b,
|
||||
cls: "layer-joint",
|
||||
weightMm: jls ? jls.weight * LAYER_DETAIL_FACTOR[detail] : layerLineMm,
|
||||
color: jls ? jls.color : stroke,
|
||||
dash: jls ? jls.dash : null,
|
||||
zigzag: jls?.kind === "zigzag" ? jls.zigzag : undefined,
|
||||
motif: jls?.kind === "custom" ? jls.motif : undefined,
|
||||
greyed,
|
||||
});
|
||||
} else {
|
||||
out.push({ kind: "line", a, b, cls: "wall-outline", weightMm: outlineMm, color: stroke, greyed });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Referenzlinie einer Wand: dünne, gestrichelte Achslinie entlang der Wandachse
|
||||
* (start → end). Von der Oberleiste umschaltbar; rein darstellend.
|
||||
*/
|
||||
export function addReferenceLine(out: Primitive[], wall: Wall, greyed: boolean): void {
|
||||
out.push({
|
||||
kind: "line",
|
||||
a: wall.start,
|
||||
b: wall.end,
|
||||
cls: "wall-axis",
|
||||
weightMm: 0.13,
|
||||
dash: [0.18, 0.06, 0.04, 0.06], // Strich-Punkt-Achse in mm Papier
|
||||
greyed,
|
||||
});
|
||||
}
|
||||
@@ -399,8 +399,8 @@ export function useSelectAllAndDeleteShortcut(opts: {
|
||||
.filter((r) => r.floorId === activeLevelId)
|
||||
.map((r) => r.id);
|
||||
// Schnittführungs-Symbole sind projektweit (kein floorId-Bezug — sie
|
||||
// werden auf JEDEM Grundriss gezeichnet, s. generatePlan/sections.ts::
|
||||
// addSectionLines), anders als die übrigen, geschossgefilterten Kanäle.
|
||||
// werden auf JEDEM Grundriss gezeichnet, s. plan/context.rs im Kern,
|
||||
// plan_section_lines), anders als die übrigen, geschossgefilterten Kanäle.
|
||||
const sectionLineIds = project.drawingLevels
|
||||
.filter((l) => (l.kind === "section" || l.kind === "elevation") && l.linePoints)
|
||||
.map((l) => l.id);
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ const selectTool: Tool = {
|
||||
|
||||
// ── Wall ─────────────────────────────────────────────────────────────────────
|
||||
// Zeichnet eine Achs-Polylinie; jedes Segment wird ein eigenständiges Wall.
|
||||
// Die Gehrung an Ecken entsteht automatisch aus computeJoins (generatePlan).
|
||||
// Die Gehrung an Ecken entsteht automatisch aus der Verschneidung im Kern (`joins.rs`).
|
||||
|
||||
interface WallDrawing {
|
||||
phase: "drawing";
|
||||
|
||||
Reference in new issue
Block a user