[94][95] Merge: Fenster/Türen – Leibung/Anschlag/Sturz/Fensterbank/Storenkasten, Schiebe-/Hebeschiebe-/Pendeltür, Oberlicht-Teilungen, Typen-Bibliothek

Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-10-29 23:04:17 +00:00
commit a385997282
29 files changed
+1570 -177

No files matched your search

+24
View File
@@ -1422,6 +1422,30 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
Tabelle noch nicht als Element auf dem Layout-Blatt (Layout-Blatt hat keinen Tabellen-Baustein); Typ-Vorgaben
(Brand/Schall/U am Tür-/Fenstertyp) fehlen — die Werte liegen je Öffnung; Nummern nicht stabil bei
Umordnung (automatisch nach Dokumentreihenfolge); nicht in der Tauri-App getestet.
- ◐ **[94] Fenster/Türen: Konstruktionsdetails.** (29.10., Wunsch Maintainer vor den Lukarnen) Neue Typ-Felder (Fenster- und
Türtyp, optional, ohne sie bleibt alles wie bisher): Leibung `insetFace: "mitte"` (neben aussen/innen + `insetFromFace`
= Mass), Anschlag `rebateDepth` (Wandnase zwischen Anschlag-Fläche und Rahmen-Vorderkante; Grundriss je Wandschicht in
deren Schraffur, 3D Teil „Anschlag", Ansicht von der Anschlag-Seite mit kleinerer Rahmenfläche), Sturz `lintelHeight`
(Schnitt: eigener Querschnitt, neben einem Storenkasten nur über die Restdicke), Fensterbank nach `sillBoard` (Grundriss
fein: aussen bis 4 cm vor die Fassade, innen bis 2 cm vor die Innenfläche; Schnitt nur bei ausdrücklicher Wahl, aussen
mit Gefälle), Storenkasten `shading.mount: "sturz"` (Schweizer Lamellenstoren: Kasten im Sturz verdeckt — Grundriss
Überkopf-Rechteck ab Aussenfläche, fein Führungsschienen neben dem Anschlag; Schnitt Kasten + Lamellenpaket, vorgesetzter
Kasten jetzt auch im Schnitt; 3D nur Schienen). UI: „Fenster bearbeiten" (Rahmen/Sonnenschutz). Geprüft: Rust-Tests,
CLI-Grundriss/-Schnitt/-Ansicht als PNG angesehen (Linux). Offen: Anschlag im Schnitt (Sturz-Nase), Brüstung als
eigenes Bauteil, Anschlag/Leibung in den Ressourcen-Tabs (nur im Bearbeiten-Dialog).
- ◐ **[95] Fenster/Türen: mehr Bauarten und Typen-Bibliothek.** (29.10.) Türtyp `kind` neu `hebeschiebe` und `pendel`;
`schiebe` wird jetzt auch gezeichnet: Grundriss nach SIA (Schiebetür: Blatt-Rechteck vor der Wand auf der Aufschlagseite +
Pfeil zur Parkseite, zweiflügelig zwei Pfeile; Hebeschiebe: zwei Flügel auf versetzten Gleisen im Rahmen mit Glaslinien
und Pfeil; Pendel: Blatt + gepunktetes Gegenblatt, Bögen beidseitig), Schnitt (Blatt vor der Fläche bzw. zwei Flügel),
Ansicht (Pfeil, zwei Glasfelder), 3D (Blatt vor der Wand, Hebeschiebe mit Flügelrahmen und Glas), IFC-OperationType
(Pendel → DOUBLE_SWING_*, Hebeschiebe → SLIDING_*). Türtyp `kind: "wandoeffnung"` wirkt jetzt auch im Grundriss/Schnitt.
Tür-Oberlicht (`transomHeight`) jetzt auch in der Ansicht. Fenster `transomSashes` (Pfosten/Riegel: Einteilung des
Oberlichts, je Feld fest/kipp/dreh): Ansicht und 3D (Pfosten, Flügelrahmen, Symbole). Zweiflügelige Türen gab es schon
(`leafCount`). Bibliothek: `opening_presets.rs` (6 Fenster-, 7 Türvorlagen, Namen über `preset.<id>`), Ressourcen-Tabs
„Aus Bibliothek…“; Dialog „Fenster bearbeiten“: Türarten, Oberlicht-Felder/-Öffnung. Geprüft: Rust-/vitest-Tests,
CLI-Grundriss/-Schnitt/-Ansicht angesehen (Linux). Offen: Taschen-Schiebetür (in der Wand), Ansicht zeigt bei
zweiflügeliger Schiebetür nur einen Pfeil, 3D/Ansicht ohne Hebeschiebe-Bandseite in der Ansicht, Brüstungs-/Riegel-
Einteilung unten (nur Oberlicht), nicht in der Tauri-App geprüft.
## Priorität 4 — später
+3 -2
View File
@@ -362,7 +362,7 @@ struct FillParams {
wing_count: f64,
panes: f64,
sashes: Vec<FillSash>,
/// Tür: 0 Dreh, 1 Schiebe, 2 reine Wandöffnung.
/// Tür: 0 Dreh, 1 Schiebe (auch Hebeschiebe), 2 reine Wandöffnung, 3 Pendel.
door_kind: f64,
leaf_count: f64,
/// +1 Aufschlag links der Achse, −1 rechts; Richtung +1 innen, −1 aussen.
@@ -404,7 +404,8 @@ fn fill_params(p: &Project, o: &Opening) -> FillParams {
.collect(),
// Türart: Typ vor Öffnung.
door_kind: match dt.map(|t| t.kind) {
Some(DoorTypeKind::Schiebe) => 1.0,
Some(DoorTypeKind::Schiebe | DoorTypeKind::Hebeschiebe) => 1.0,
Some(DoorTypeKind::Pendel) => 3.0,
Some(DoorTypeKind::Wandoeffnung) => 2.0,
Some(_) => 0.0,
None if o.door_type == Some(OpeningDoorType::Wandoeffnung) => 2.0,
+1
View File
@@ -108,6 +108,7 @@ pub mod cmd_split;
pub mod snap_model;
pub mod solid_specs;
pub mod highlight3d;
pub mod opening_presets;
#[cfg(feature = "web")]
mod web;
+57
View File
@@ -574,6 +574,12 @@ pub enum DoorTypeKind {
Schiebe,
#[serde(rename = "wandoeffnung")]
Wandoeffnung,
/// Hebeschiebetür: Rahmen in der Wand, ein festes und ein schiebbares Glasfeld ([95]).
#[serde(rename = "hebeschiebe")]
Hebeschiebe,
/// Pendeltür: schlägt nach beiden Seiten auf ([95]).
#[serde(rename = "pendel")]
Pendel,
#[serde(other)]
#[ts(skip)]
Unknown,
@@ -638,6 +644,9 @@ pub enum DoorTypeInsetFace {
Aussen,
#[serde(rename = "innen")]
Innen,
/// Rahmen mittig in der Wand (Leibung beidseitig gleich tief); `insetFromFace` wirkt nicht.
#[serde(rename = "mitte")]
Mitte,
#[serde(other)]
#[ts(skip)]
Unknown,
@@ -729,6 +738,17 @@ pub struct DoorType {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub threshold: Option<bool>,
/// Anschlag (Maueranschlag): so weit (Meter, je Seite und oben) springt die Wand zwischen
/// der Fläche aus {@link insetFace} und der Rahmen-Vorderkante in die Öffnung vor. Wirkt nur
/// mit Leibung (`insetFromFace` > 0 bzw. `insetFace: "mitte"`). 0/fehlt ⇒ stumpf (bisher).
#[serde(rename = "rebateDepth", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub rebate_depth: Option<f64>,
/// Sturz: Höhe des Sturzes über der Öffnung (Meter), im Schnitt als eigener Querschnitt
/// gezeichnet. 0/fehlt ⇒ kein eigener Sturz (bisher).
#[serde(rename = "lintelHeight", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub lintel_height: Option<f64>,
#[serde(flatten)]
#[ts(skip)]
pub extra: Extra,
@@ -830,6 +850,19 @@ pub enum WindowShadingKind {
Unknown,
}
/// Einbau des Sonnenschutzkastens ({@link WindowShading.mount}).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
pub enum WindowShadingMount {
#[default]
#[serde(rename = "vorgesetzt")]
Vorgesetzt,
#[serde(rename = "sturz")]
Sturz,
#[serde(other)]
#[ts(skip)]
Unknown,
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
#[serde(default)]
pub struct WindowShadingBox {
@@ -851,6 +884,11 @@ pub struct WindowShading {
/// Kastenmasse (Meter): Breite (quer, meist = Öffnung), Höhe, Tiefe.
#[ts(inline)]
pub r#box: WindowShadingBox,
/// Einbau des Kastens: "vorgesetzt" (vor der Rahmenebene, bisher) oder "sturz" (Storenkasten
/// im Sturz, in der Wand verdeckt — in der Schweiz üblich bei Lamellenstoren). Fehlt ⇒ vorgesetzt.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub mount: Option<WindowShadingMount>,
#[serde(flatten)]
#[ts(skip)]
pub extra: Extra,
@@ -877,6 +915,9 @@ pub enum WindowTypeInsetFace {
Aussen,
#[serde(rename = "innen")]
Innen,
/// Rahmen mittig in der Wand (Leibung beidseitig gleich tief); `insetFromFace` wirkt nicht.
#[serde(rename = "mitte")]
Mitte,
#[serde(other)]
#[ts(skip)]
Unknown,
@@ -1020,6 +1061,11 @@ pub struct WindowType {
#[serde(rename = "transomHeight", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub transom_height: Option<f64>,
/// Einteilung des Oberlichts über dem Riegel (Pfosten/Riegel, [95]): Felder und Pfosten wie
/// {@link sashes}, je Feld fest oder öffenbar (meist Kipp). Fehlt ⇒ ein festes Feld (bisher).
#[serde(rename = "transomSashes", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub transom_sashes: Option<Vec<SashDef>>,
/// Auf-/Untersicht-Andeutung im Grundriss (mittel/fein): eine Referenzlinie an
/// der gewählten Fläche(n) — sinnvoll, wenn die Öffnung die Schnittebene NICHT
/// regulär durchschneidet (z. B. bodentiefes Fenster oder hoch sitzendes
@@ -1042,6 +1088,17 @@ pub struct WindowType {
#[serde(rename = "sillBoard", default, skip_serializing_if = "Option::is_none")]
#[ts(optional, inline)]
pub sill_board: Option<WindowTypeSillBoard>,
/// Anschlag (Maueranschlag): so weit (Meter, je Seite und oben) springt die Wand zwischen
/// der Fläche aus {@link insetFace} und der Rahmen-Vorderkante in die Öffnung vor. Wirkt nur
/// mit Leibung (`insetFromFace` > 0 bzw. `insetFace: "mitte"`). 0/fehlt ⇒ stumpf (bisher).
#[serde(rename = "rebateDepth", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub rebate_depth: Option<f64>,
/// Sturz: Höhe des Sturzes über der Öffnung (Meter), im Schnitt als eigener Querschnitt
/// gezeichnet. 0/fehlt ⇒ kein eigener Sturz (bisher).
#[serde(rename = "lintelHeight", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub lintel_height: Option<f64>,
#[serde(flatten)]
#[ts(skip)]
pub extra: Extra,
+42 -5
View File
@@ -570,13 +570,14 @@ pub fn emit_walls(p: &Project, layered: bool) -> Result<Vec<RWall>, String> {
// ── Öffnungs-Einbauteile (Glas, Rahmen, Sprossen, Bank, Kasten) ─────────────
/// Farbe je Bauteil-Klasse (Index = `Part` in `openings3d.rs`).
const PART_RGB: [Rgb; 6] = [
const PART_RGB: [Rgb; 7] = [
[0.62, 0.76, 0.85],
[0.85, 0.85, 0.83],
[0.88, 0.88, 0.9],
[0.8, 0.8, 0.78],
[0.25, 0.27, 0.3],
[0.93, 0.9, 0.85],
[0.9, 0.89, 0.86],
];
/// Dreiecke eines Öffnungs-Quaders (Ecken-Bits: bit0 = Achse, bit1 = Höhe, bit2 = quer).
@@ -614,8 +615,9 @@ fn opening_kind_code(k: Option<OpeningKind>) -> f64 {
}
}
fn write_common(w: &mut FlatWriter, frame_depth: Option<f64>, inset: Option<f64>, inner: bool, join: Option<FrameCornerJoin>, frame_width: Option<f64>, transom: Option<f64>) {
w.nums(&[opt(frame_depth), opt(inset), flag(inner), join_code(join), opt(frame_width), opt(transom)]);
#[allow(clippy::too_many_arguments)]
fn write_common(w: &mut FlatWriter, frame_depth: Option<f64>, inset: Option<f64>, side: f64, join: Option<FrameCornerJoin>, frame_width: Option<f64>, transom: Option<f64>, rebate: Option<f64>) {
w.nums(&[opt(frame_depth), opt(inset), side, join_code(join), opt(frame_width), opt(transom), opt(rebate)]);
}
fn glazing_panes_of(wt: &WindowType) -> f64 {
@@ -636,7 +638,14 @@ fn write_opening(w: &mut FlatWriter, p: &Project, op: &Opening) {
return;
};
w.num(1.0);
write_common(w, wt.frame_depth, wt.inset_from_face, wt.inset_face == Some(WindowTypeInsetFace::Innen), wt.frame_corner_join, wt.frame_width, wt.transom_height);
let side = match wt.inset_face {
Some(WindowTypeInsetFace::Innen) => 1.0,
Some(WindowTypeInsetFace::Mitte) => 2.0,
_ => 0.0,
};
write_common(w, wt.frame_depth, wt.inset_from_face, side, wt.frame_corner_join, wt.frame_width, wt.transom_height, wt.rebate_depth);
let sturz = wt.shading.as_ref().is_some_and(|s| s.mount == Some(WindowShadingMount::Sturz));
let rails = sturz && wt.shading.as_ref().is_some_and(|s| s.kind != WindowShadingKind::Markise);
let shading = wt.shading.as_ref().filter(|s| s.create).map(|s| &s.r#box);
w.nums(&[
glazing_panes_of(wt),
@@ -652,6 +661,8 @@ fn write_opening(w: &mut FlatWriter, p: &Project, op: &Opening) {
shading.map_or(0.0, |b| b.width),
shading.map_or(0.0, |b| b.height),
shading.map_or(0.0, |b| b.depth),
flag(sturz),
flag(rails),
op.wing_count.unwrap_or(wt.wing_count),
opening_kind_code(Some(wt.kind)),
]);
@@ -667,6 +678,18 @@ fn write_opening(w: &mut FlatWriter, p: &Project, op: &Opening) {
flag(s.hinge_side != Some(SashDefHingeSide::Right)),
]);
}
let transom = wt.transom_sashes.as_deref().unwrap_or(&[]);
w.num(transom.len() as f64);
for s in transom {
w.nums(&[
if s.kind == SashDefKind::Fluegel { 0.0 } else { 1.0 },
flag(s.auto_width == Some(false)),
opt(s.width),
opt(s.post_width),
opening_kind_code(s.opening),
flag(s.hinge_side != Some(SashDefHingeSide::Right)),
]);
}
return;
}
let Some(dt) = p.door_type(op) else {
@@ -674,7 +697,12 @@ fn write_opening(w: &mut FlatWriter, p: &Project, op: &Opening) {
return;
};
w.num(1.0);
write_common(w, dt.frame_depth, dt.inset_from_face, dt.inset_face == Some(DoorTypeInsetFace::Innen), dt.frame_corner_join, dt.frame_width, dt.transom_height);
let side = match dt.inset_face {
Some(DoorTypeInsetFace::Innen) => 1.0,
Some(DoorTypeInsetFace::Mitte) => 2.0,
_ => 0.0,
};
write_common(w, dt.frame_depth, dt.inset_from_face, side, dt.frame_corner_join, dt.frame_width, dt.transom_height, dt.rebate_depth);
w.nums(&[
flag(dt.threshold == Some(true)),
dt.leaf_count,
@@ -687,6 +715,15 @@ fn write_opening(w: &mut FlatWriter, p: &Project, op: &Opening) {
flag(dt.frame_kind != Some(DoorTypeFrameKind::Blockrahmen)),
opt(dt.panel_cols),
opt(dt.panel_rows),
match dt.kind {
DoorTypeKind::Schiebe => 1.0,
DoorTypeKind::Hebeschiebe => 2.0,
DoorTypeKind::Pendel => 3.0,
_ => 0.0,
},
// Aufschlagseite wie im Grundriss (linke Normale), hier entlang der rechten Normalen.
-(if matches!(op.swing, None | Some(SwingSide::Left)) { 1.0 } else { -1.0 }) * (if matches!(op.opening_dir, None | Some(OpeningOpeningDir::In)) { 1.0 } else { -1.0 }),
flag(op.hinge == Some(OpeningHinge::End)),
]);
}
+3 -2
View File
@@ -145,6 +145,8 @@ pub struct WindowSpec {
/// NaN = nicht gesetzt
pub inset_from_face: f64,
pub inset_inner: bool,
/// Rahmen mittig in der Wand (`insetFace: "mitte"`); hat Vorrang vor `inset_inner`/Einzug.
pub inset_mid: bool,
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
@@ -230,8 +232,7 @@ pub fn window_symbol(
let inset = max(0.0, or_zero(spec.inset_from_face));
let half_t = total / 2.0;
let sign = if spec.inset_inner { 1.0 } else { -1.0 };
let mut front_rel = sign * (half_t - inset);
let mut back_rel = front_rel - sign * depth;
let (mut front_rel, mut back_rel) = if spec.inset_mid { (-depth / 2.0, depth / 2.0) } else { (sign * (half_t - inset), sign * (half_t - inset) - sign * depth) };
front_rel = max(-half_t, min(half_t, front_rel));
back_rel = max(-half_t, min(half_t, back_rel));
let frame_outer_n = ref_off + max(front_rel, back_rel);
+109
View File
@@ -0,0 +1,109 @@
//! Kleine Typen-Bibliothek für Fenster und Türen ([95]): übliche Schweizer Bauarten als Vorlagen,
//! die das Projekt über `typeId` wiederverwendet. Die ids sind stabil (die UI übersetzt den Namen
//! über `preset.<id>`); der Name hier ist nur der deutsche Rückfall.
use crate::model::{DoorType, WindowType};
const WINDOWS: &str = r#"[
{"id": "fe-dk-1", "name": "Dreh-Kipp 1-flügelig", "kind": "drehkipp", "wingCount": 1, "glazing": "dreifach",
"frameThickness": 0.08, "frameDepth": 0.08, "frameWidth": 0.08, "insetFromFace": 0.12, "insetFace": "aussen",
"rebateDepth": 0.05, "lintelHeight": 0.2, "sillBoard": "beide",
"shading": {"create": true, "kind": "raffstore", "box": {"width": 0, "height": 0.3, "depth": 0.16}, "mount": "sturz"},
"defaultSillHeight": 0.9, "defaultWidth": 1.2, "defaultHeight": 1.4},
{"id": "fe-dk-2", "name": "Dreh-Kipp 2-flügelig (Stulp)", "kind": "drehkipp", "wingCount": 2, "glazing": "dreifach",
"frameThickness": 0.08, "frameDepth": 0.08, "frameWidth": 0.08, "insetFromFace": 0.12, "insetFace": "aussen",
"rebateDepth": 0.05, "lintelHeight": 0.2, "sillBoard": "beide",
"sashes": [{"kind": "fluegel", "autoWidth": true, "opening": "dreh", "hingeSide": "left"},
{"kind": "fluegel", "autoWidth": true, "opening": "drehkipp", "hingeSide": "right"}],
"shading": {"create": true, "kind": "raffstore", "box": {"width": 0, "height": 0.3, "depth": 0.16}, "mount": "sturz"},
"defaultSillHeight": 0.9, "defaultWidth": 1.6, "defaultHeight": 1.5},
{"id": "fe-fest", "name": "Festverglasung", "kind": "fest", "wingCount": 1, "glazing": "dreifach",
"frameThickness": 0.07, "frameDepth": 0.08, "frameWidth": 0.06, "insetFromFace": 0.12, "insetFace": "aussen",
"rebateDepth": 0.05, "sillBoard": "aussen", "defaultSillHeight": 0.9, "defaultWidth": 1.0, "defaultHeight": 1.4},
{"id": "fe-oberlicht", "name": "Dreh-Kipp mit Kipp-Oberlicht", "kind": "drehkipp", "wingCount": 1, "glazing": "dreifach",
"frameThickness": 0.08, "frameDepth": 0.08, "frameWidth": 0.08, "insetFromFace": 0.12, "insetFace": "aussen",
"rebateDepth": 0.05, "lintelHeight": 0.2, "sillBoard": "beide", "transomHeight": 0.5,
"transomSashes": [{"kind": "fluegel", "autoWidth": true, "opening": "kipp"}],
"defaultSillHeight": 0.6, "defaultWidth": 1.2, "defaultHeight": 2.0},
{"id": "fe-pfosten-riegel", "name": "Pfosten-Riegel 3-teilig", "kind": "drehkipp", "wingCount": 3, "glazing": "dreifach",
"frameThickness": 0.08, "frameDepth": 0.1, "frameWidth": 0.06, "insetFace": "mitte", "rebateDepth": 0.05,
"lintelHeight": 0.25, "sillBoard": "beide", "transomHeight": 0.6,
"sashes": [{"kind": "fluegel", "autoWidth": true, "opening": "drehkipp", "hingeSide": "left"},
{"kind": "pfosten", "postWidth": 0.08},
{"kind": "fluegel", "autoWidth": true, "opening": "fest"},
{"kind": "pfosten", "postWidth": 0.08},
{"kind": "fluegel", "autoWidth": true, "opening": "drehkipp", "hingeSide": "right"}],
"transomSashes": [{"kind": "fluegel", "autoWidth": true, "opening": "kipp"},
{"kind": "pfosten", "postWidth": 0.08},
{"kind": "fluegel", "autoWidth": true, "opening": "fest"},
{"kind": "pfosten", "postWidth": 0.08},
{"kind": "fluegel", "autoWidth": true, "opening": "kipp"}],
"defaultSillHeight": 0.3, "defaultWidth": 3.0, "defaultHeight": 2.3},
{"id": "fe-schiebe", "name": "Schiebefenster 2-teilig", "kind": "schiebe", "wingCount": 2, "glazing": "dreifach",
"frameThickness": 0.1, "frameDepth": 0.12, "frameWidth": 0.08, "insetFromFace": 0.12, "insetFace": "aussen",
"rebateDepth": 0.05, "sillBoard": "beide",
"sashes": [{"kind": "fluegel", "autoWidth": true, "opening": "fest"},
{"kind": "fluegel", "autoWidth": true, "opening": "schiebe", "hingeSide": "right"}],
"defaultSillHeight": 0.9, "defaultWidth": 2.0, "defaultHeight": 1.4}
]"#;
const DOORS: &str = r#"[
{"id": "tu-zimmer", "name": "Zimmertür (Zarge)", "kind": "dreh", "leafCount": 1, "leafStyle": "glatt",
"frameThickness": 0.05, "frameKind": "zarge", "frameWidth": 0.06, "defaultWidth": 0.8, "defaultHeight": 2.0},
{"id": "tu-zimmer-2", "name": "Zimmertür 2-flügelig", "kind": "dreh", "leafCount": 2, "leafStyle": "glatt",
"frameThickness": 0.05, "frameKind": "zarge", "frameWidth": 0.06, "defaultWidth": 1.4, "defaultHeight": 2.0},
{"id": "tu-schiebe", "name": "Schiebetür vor der Wand", "kind": "schiebe", "leafCount": 1, "leafStyle": "glatt",
"frameThickness": 0.04, "frameWidth": 0.04, "defaultWidth": 0.9, "defaultHeight": 2.1},
{"id": "tu-hebeschiebe", "name": "Hebeschiebetür", "kind": "hebeschiebe", "leafCount": 2, "leafStyle": "glas",
"frameThickness": 0.1, "frameDepth": 0.16, "frameKind": "blockrahmen", "frameWidth": 0.1, "insetFromFace": 0.12,
"insetFace": "aussen", "rebateDepth": 0.05, "lintelHeight": 0.25, "threshold": true,
"defaultWidth": 2.4, "defaultHeight": 2.2},
{"id": "tu-pendel", "name": "Pendeltür", "kind": "pendel", "leafCount": 1, "leafStyle": "glatt",
"frameThickness": 0.05, "frameKind": "zarge", "frameWidth": 0.06, "defaultWidth": 0.9, "defaultHeight": 2.1},
{"id": "tu-haus", "name": "Haustür mit Oberlicht", "kind": "dreh", "leafCount": 1, "leafStyle": "glas", "glazingRatio": 0.3,
"frameThickness": 0.08, "frameKind": "blockrahmen", "frameWidth": 0.09, "insetFromFace": 0.12, "insetFace": "aussen",
"rebateDepth": 0.05, "lintelHeight": 0.25, "transomHeight": 0.4, "threshold": true,
"defaultWidth": 1.1, "defaultHeight": 2.5},
{"id": "tu-wand", "name": "Wandöffnung", "kind": "wandoeffnung", "leafCount": 1, "leafStyle": "glatt",
"frameThickness": 0.0, "defaultWidth": 1.0, "defaultHeight": 2.1}
]"#;
/// Fenstertyp-Vorlagen.
pub fn window_presets() -> Vec<WindowType> {
serde_json::from_str(WINDOWS).unwrap_or_default()
}
/// Türtyp-Vorlagen.
pub fn door_presets() -> Vec<DoorType> {
serde_json::from_str(DOORS).unwrap_or_default()
}
/// Beide Listen als JSON `{ windowTypes, doorTypes }` (Bindung `opening_type_presets_json`).
pub fn presets_json() -> String {
serde_json::json!({ "windowTypes": window_presets(), "doorTypes": door_presets() }).to_string()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn vorlagen_lesen_sich_vollstaendig_und_ohne_unbekannte_felder() {
let w = window_presets();
let d = door_presets();
assert_eq!(w.len(), 6);
assert_eq!(d.len(), 7);
for t in &w {
assert!(t.extra.0.is_empty(), "{}: {:?}", t.id, t.extra);
assert!(t.default_width > 0.0 && t.default_height > 0.0);
}
for t in &d {
assert!(t.extra.0.is_empty(), "{}: {:?}", t.id, t.extra);
assert!(t.kind != crate::model::DoorTypeKind::Unknown, "{}", t.id);
}
let mut ids: Vec<&str> = w.iter().map(|t| t.id.as_str()).chain(d.iter().map(|t| t.id.as_str())).collect();
ids.sort();
ids.dedup();
assert_eq!(ids.len(), 13);
}
}
+285 -79
View File
@@ -44,6 +44,8 @@ pub enum Part {
Sill = 3,
Symbol = 4,
DoorLeaf = 5,
/// Maueranschlag (Wandnase in der Leibung, [94]).
Rebate = 6,
}
/// Ein Quader: Bauteil-Klasse und 8 Ecken (x, y, z), Ecken-Bits wie `OPENING_BOX_TRIS`.
@@ -133,6 +135,12 @@ pub struct DoorTypeIn {
pub zarge: bool,
pub panel_cols: f64,
pub panel_rows: f64,
/// Türart ([95]): 0 Dreh, 1 Schiebe (vor der Wand), 2 Hebeschiebe, 3 Pendel.
pub kind: f64,
/// Schiebetür: Seite des Blatts (+1 = +n, aussen; −1 innen).
pub slide_side: f64,
/// Bandseite am Ende (Hebeschiebe: festes Feld dort).
pub hinge_end: bool,
}
/// Fenster-spezifische Typwerte (NaN = fehlt).
@@ -151,6 +159,12 @@ pub struct WindowTypeIn {
pub default_opening: SashOpening,
/// Rollladenkasten (Breite, Höhe, Tiefe), nur bei `shading.create`.
pub shading: Option<[f64; 3]>,
/// Einteilung des Oberlichts (Pfosten/Riegel, [95]); leer ⇒ ein festes Feld.
pub transom_sashes: Vec<SashIn>,
/// Kasten im Sturz (verdeckt, kein Quader) statt vorgesetzt.
pub shading_sturz: bool,
/// Führungsschienen in der Leibung (Kasten im Sturz, nicht Markise).
pub shading_rails: bool,
}
#[derive(Clone, Debug, PartialEq)]
@@ -166,6 +180,10 @@ pub struct TypeIn {
pub inset_from_face: f64,
/// `(insetFace ?? "aussen") === "innen"`.
pub inset_inner: bool,
/// `insetFace === "mitte"`: Rahmen symmetrisch um die Wandmitte.
pub inset_mid: bool,
/// Maueranschlag je Seite und oben (Meter), NaN/0 = keiner.
pub rebate_depth: f64,
pub corner_join: CornerJoin,
pub frame_width: f64,
pub transom_height: f64,
@@ -389,6 +407,7 @@ struct FrameParams<'a> {
glazing_panes: f64,
glazed_fraction: f64,
sashes: std::borrow::Cow<'a, [SashIn]>,
transom_sashes: &'a [SashIn],
half_thickness: f64,
draw_sill: bool,
draw_interior_sill: bool,
@@ -398,6 +417,9 @@ struct FrameParams<'a> {
panel_cols: f64,
panel_rows: f64,
corner_join: CornerJoin,
door_kind: f64,
slide_side: f64,
hinge_end: bool,
}
/// Rahmentiefe quer zur Wand: `frame_depth` (> EPS) oder Default, auf die Wanddicke geklemmt.
@@ -408,10 +430,9 @@ fn across_wall_depth(frame_depth: f64, wall_thickness: f64) -> f64 {
/// Quer-Versatz `[n_min, n_max]` des Rahmenkörpers: Vorderkante bündig mit der gewählten
/// Wandfläche (minus Schichteinzug), `depth` zur Wandmitte hin, auf die halbe Dicke geklemmt.
fn frame_normal_range(half: f64, depth: f64, inset: f64, inner: bool) -> (f64, f64) {
fn frame_normal_range(half: f64, depth: f64, inset: f64, inner: bool, mid: bool) -> (f64, f64) {
let sign = if inner { -1.0 } else { 1.0 };
let front = sign * (half - inset);
let back = front - sign * depth;
let (front, back) = if mid { (depth / 2.0, -depth / 2.0) } else { (sign * (half - inset), sign * (half - inset) - sign * depth) };
let a = clamp_range(front, -half, half);
let b = clamp_range(back, -half, half);
(jmin(a, b), jmax(a, b))
@@ -421,7 +442,7 @@ fn resolve_frame(o: &OpeningIn) -> Option<FrameParams<'_>> {
let ty = o.ty.as_ref()?;
let half = o.wall_thickness / 2.0;
let depth = across_wall_depth(ty.frame_depth, o.wall_thickness);
let (n_min, n_max) = frame_normal_range(half, depth, or(ty.inset_from_face, 0.0), ty.inset_inner);
let (n_min, n_max) = frame_normal_range(half, depth, or(ty.inset_from_face, 0.0), ty.inset_inner, ty.inset_mid);
let frame_width = or(ty.frame_width, DEFAULT_FRAME_WIDTH);
let transom_height = jmax(0.0, or(ty.transom_height, 0.0));
Some(match &ty.kind {
@@ -435,10 +456,12 @@ fn resolve_frame(o: &OpeningIn) -> Option<FrameParams<'_>> {
wing_count: jmax(1.0, js_round(or(d.leaf_count, 1.0))),
mullion_rows: 1.0,
mullion_cols: 1.0,
glazed: d.leaf_style == LeafStyle::Glass,
// Schiebe-/Hebeschiebeflügel zeichnet `door_leaf` selbst (eigene Lage bzw. Glasfelder).
glazed: d.leaf_style == LeafStyle::Glass && d.kind != 1.0 && d.kind != 2.0,
glazing_panes: 1.0,
glazed_fraction: jmax(0.05, jmin(1.0, or(d.glazing_ratio, 1.0))),
sashes: std::borrow::Cow::Borrowed(&[]),
transom_sashes: &[],
half_thickness: half,
draw_sill: false,
draw_interior_sill: false,
@@ -447,6 +470,9 @@ fn resolve_frame(o: &OpeningIn) -> Option<FrameParams<'_>> {
panelled: d.leaf_style == LeafStyle::Panelled,
panel_cols: jmax(1.0, js_round(or(d.panel_cols, 2.0))),
panel_rows: jmax(1.0, js_round(or(d.panel_rows, 3.0))),
door_kind: d.kind,
slide_side: d.slide_side,
hinge_end: d.hinge_end,
},
KindIn::Window(w) => {
// Flügeltabelle: explizite gewinnt; sonst gleichmässig aus der effektiven Flügelzahl.
@@ -484,6 +510,7 @@ fn resolve_frame(o: &OpeningIn) -> Option<FrameParams<'_>> {
glazing_panes: w.glazing_panes,
glazed_fraction: 1.0,
sashes,
transom_sashes: &w.transom_sashes,
half_thickness: half,
draw_sill: w.sill_board != SillBoard::None && w.sill_board != SillBoard::Inner,
draw_interior_sill: w.sill_board == SillBoard::Inner || w.sill_board == SillBoard::Both,
@@ -492,11 +519,31 @@ fn resolve_frame(o: &OpeningIn) -> Option<FrameParams<'_>> {
panelled: false,
panel_cols: 1.0,
panel_rows: 1.0,
door_kind: 0.0,
slide_side: 1.0,
hinge_end: false,
}
}
})
}
/// Maueranschlag: Wandnasen links, rechts und oben in der Zone zwischen der Anschlag-Fläche und
/// der Rahmen-Vorderkante (aussen bzw. bei `insetFace: "innen"` innen; mittig: aussen).
fn rebate_boxes(em: &mut Emitter, o: &OpeningIn, ty: &TypeIn, p: &FrameParams) {
let rd = jmin(or(ty.rebate_depth, 0.0), (o.to - o.from) / 2.0 - 0.01);
if !(rd > EPS) {
return;
}
let half = p.half_thickness;
let (n0, n1) = if ty.inset_inner && !ty.inset_mid { (-half, p.n_min) } else { (p.n_max, half) };
if n1 - n0 <= EPS {
return;
}
em.axis_box(o.from, o.from + rd, o.z_bottom, o.z_top, n0, n1, Part::Rebate);
em.axis_box(o.to - rd, o.to, o.z_bottom, o.z_top, n0, n1, Part::Rebate);
em.axis_box(o.from + rd, o.to - rd, o.z_top - rd, o.z_top, n0, n1, Part::Rebate);
}
/// Flügeleinteilung auf `[from, to]`: feste Breiten exakt, der Rest gleichmässig.
fn sash_spans(sashes: &[SashIn], from: f64, to: f64) -> Vec<(SashIn, f64, f64)> {
let width = jmax(0.0, to - from);
@@ -551,11 +598,22 @@ fn frame_meshes(em: &mut Emitter, o: &OpeningIn, p: &FrameParams, detail: Detail
let sash_to = to0 - fw;
let sash_bottom = zb0 + if p.has_sill { fw } else { 0.0 };
let mut sash_top = zt0 - fw;
// Oberlicht-Band (über dem Riegel) für dessen Einteilung.
let mut transom_band: Option<(f64, f64)> = None;
if p.transom_height > EPS {
let split_z = clamp_range(zt0 - p.transom_height, sash_bottom, sash_top);
em.axis_box(sash_from, sash_to, split_z - fw / 2.0, split_z + fw / 2.0, p.n_min, p.n_max, Part::Frame);
transom_band = Some((split_z + fw / 2.0, sash_top));
sash_top = split_z - fw / 2.0;
}
// Pfosten im Oberlicht (mittel/fein).
if let (true, Some((tb, tt))) = (sashes_on, transom_band) {
for (s, cf, ct) in sash_spans(p.transom_sashes, sash_from, sash_to) {
if s.kind == SashKind::Post {
em.axis_box(cf, ct, tb, tt, p.n_min, p.n_max, Part::Frame);
}
}
}
if fine {
// Senkrechte Teiler laufen durch, waagrechte Kämpfer-Zeilen dazwischen unterbrochen.
let mut posts: Vec<f64> = Vec::new();
@@ -597,60 +655,66 @@ fn frame_meshes(em: &mut Emitter, o: &OpeningIn, p: &FrameParams, detail: Detail
}
}
// Flügelrahmen je öffenbarem Flügel (zurückgesetztes, flacheres Quer-Band) + SIA-Symbole.
if sashes_on && !p.sashes.is_empty() && sash_to - sash_from > EPS && sash_top - sash_bottom > EPS {
let segs = sash_spans(&p.sashes, sash_from, sash_to);
let sfw = fw * 0.7;
let sash_front_n = p.n_max - 0.005;
let sash_back_n = jmax(p.n_min, p.n_max - 0.055);
let glass_front_n = p.n_max - 0.02;
let sym_back_n = glass_front_n;
let sym_front_n = glass_front_n + 0.003;
let symbol = |em: &mut Emitter, u0: f64, h0: f64, u1: f64, h1: f64| {
em.plane_box(u0, h0, u1, h1, SYMBOL_HALF_WIDTH, sym_front_n, sym_back_n, Part::Symbol);
};
for (s, cf, ct) in segs {
if s.kind != SashKind::Sash || s.opening == SashOpening::None || s.opening == SashOpening::Fixed {
continue;
}
let bz = sash_bottom;
let tz = sash_top;
if ct - cf <= EPS || tz - bz <= EPS {
continue;
}
for q in frame_ring_quads(cf, ct, bz, tz, sfw, p.corner_join, true) {
em.plane_quad(&q, sash_back_n, sash_front_n, Part::Frame);
}
if !fine {
continue;
}
let g_a = cf + sfw;
let g_b = ct - sfw;
let gbz = bz + sfw;
let gtz = tz - sfw;
if g_b - g_a <= EPS || gtz - gbz <= EPS {
continue;
}
let kind = s.opening;
if kind == SashOpening::Turn || kind == SashOpening::TurnTilt {
let apex_u = if s.hinge_left { g_a } else { g_b };
let apex_h = (gbz + gtz) / 2.0;
let far_u = if s.hinge_left { g_b } else { g_a };
symbol(em, far_u, gbz, apex_u, apex_h);
symbol(em, far_u, gtz, apex_u, apex_h);
}
if kind == SashOpening::Tilt || kind == SashOpening::TurnTilt {
let apex_u = (g_a + g_b) / 2.0;
symbol(em, g_a, gbz, apex_u, gtz);
symbol(em, g_b, gbz, apex_u, gtz);
}
if kind == SashOpening::Slide {
let zc = (gbz + gtz) / 2.0;
let tail = if s.hinge_left { g_a } else { g_b };
let head = if s.hinge_left { g_b } else { g_a };
let barb = (head - tail) * 0.22;
symbol(em, tail, zc, head, zc);
symbol(em, head - barb, gbz + (gtz - gbz) * 0.32, head, zc);
symbol(em, head - barb, gbz + (gtz - gbz) * 0.68, head, zc);
let mut bands: Vec<(&[SashIn], f64, f64)> = vec![(&p.sashes, sash_bottom, sash_top)];
if let Some((tb, tt)) = transom_band {
bands.push((p.transom_sashes, tb, tt));
}
for (band_sashes, band_bottom, band_top) in bands {
if sashes_on && !band_sashes.is_empty() && sash_to - sash_from > EPS && band_top - band_bottom > EPS {
let segs = sash_spans(band_sashes, sash_from, sash_to);
let sfw = fw * 0.7;
let sash_front_n = p.n_max - 0.005;
let sash_back_n = jmax(p.n_min, p.n_max - 0.055);
let glass_front_n = p.n_max - 0.02;
let sym_back_n = glass_front_n;
let sym_front_n = glass_front_n + 0.003;
let symbol = |em: &mut Emitter, u0: f64, h0: f64, u1: f64, h1: f64| {
em.plane_box(u0, h0, u1, h1, SYMBOL_HALF_WIDTH, sym_front_n, sym_back_n, Part::Symbol);
};
for (s, cf, ct) in segs {
if s.kind != SashKind::Sash || s.opening == SashOpening::None || s.opening == SashOpening::Fixed {
continue;
}
let bz = band_bottom;
let tz = band_top;
if ct - cf <= EPS || tz - bz <= EPS {
continue;
}
for q in frame_ring_quads(cf, ct, bz, tz, sfw, p.corner_join, true) {
em.plane_quad(&q, sash_back_n, sash_front_n, Part::Frame);
}
if !fine {
continue;
}
let g_a = cf + sfw;
let g_b = ct - sfw;
let gbz = bz + sfw;
let gtz = tz - sfw;
if g_b - g_a <= EPS || gtz - gbz <= EPS {
continue;
}
let kind = s.opening;
if kind == SashOpening::Turn || kind == SashOpening::TurnTilt {
let apex_u = if s.hinge_left { g_a } else { g_b };
let apex_h = (gbz + gtz) / 2.0;
let far_u = if s.hinge_left { g_b } else { g_a };
symbol(em, far_u, gbz, apex_u, apex_h);
symbol(em, far_u, gtz, apex_u, apex_h);
}
if kind == SashOpening::Tilt || kind == SashOpening::TurnTilt {
let apex_u = (g_a + g_b) / 2.0;
symbol(em, g_a, gbz, apex_u, gtz);
symbol(em, g_b, gbz, apex_u, gtz);
}
if kind == SashOpening::Slide {
let zc = (gbz + gtz) / 2.0;
let tail = if s.hinge_left { g_a } else { g_b };
let head = if s.hinge_left { g_b } else { g_a };
let barb = (head - tail) * 0.22;
symbol(em, tail, zc, head, zc);
symbol(em, head - barb, gbz + (gtz - gbz) * 0.32, head, zc);
symbol(em, head - barb, gbz + (gtz - gbz) * 0.68, head, zc);
}
}
}
}
@@ -736,11 +800,22 @@ fn door_leaf(em: &mut Emitter, o: &OpeningIn, p: &FrameParams) {
let split_z = clamp_range(o.z_top - p.transom_height, leaf_bottom, field_top);
field_top = split_z - fw / 2.0;
}
if p.door_kind == 2.0 {
lift_slide_sashes(em, leaf_from, leaf_to, leaf_bottom, field_top, p);
return;
}
let frac = if p.glazed { jmax(0.05, jmin(1.0, p.glazed_fraction)) } else { 0.0 };
let leaf_top = field_top - frac * (field_top - leaf_bottom);
if leaf_top - leaf_bottom <= EPS || leaf_to - leaf_from <= EPS {
return;
}
if p.door_kind == 1.0 {
// Schiebetür vor der Wand: Blatt in Schliessstellung vor der Fläche, beidseitig 5 cm über die Lichte.
let side = if p.slide_side < 0.0 { -1.0 } else { 1.0 };
let (a, b) = (side * (p.half_thickness + 0.01), side * (p.half_thickness + 0.01 + DOOR_LEAF_THICK));
em.axis_box(o.from - 0.05, o.to + 0.05, o.z_bottom, leaf_top, jmin(a, b), jmax(a, b), Part::DoorLeaf);
return;
}
let n1 = p.n_max - 0.02 + DOOR_LEAF_THICK / 2.0;
let n0 = jmax(p.n_min, n1 - DOOR_LEAF_THICK);
if p.panelled {
@@ -750,6 +825,30 @@ fn door_leaf(em: &mut Emitter, o: &OpeningIn, p: &FrameParams) {
em.axis_box(leaf_from, leaf_to, leaf_bottom, leaf_top, n0, n1, Part::DoorLeaf);
}
/// Hebeschiebetür: festes Feld (Bandseite, aussen) und Schiebefeld (innen) auf versetzten Gleisen,
/// je Flügelrahmen + Glas, in der Mitte überlappend.
fn lift_slide_sashes(em: &mut Emitter, from: f64, to: f64, bottom: f64, top: f64, p: &FrameParams) {
let span = p.n_max - p.n_min;
if to - from <= EPS || top - bottom <= EPS || span <= EPS {
return;
}
let ts = jmin(0.05, span / 2.5);
let gap = (span - 2.0 * ts) / 3.0;
let outer = (p.n_max - gap - ts, p.n_max - gap);
let inner = (p.n_min + gap, p.n_min + gap + ts);
let mid = (from + to) / 2.0;
let ov = 0.03;
let (fixed, slide) = if p.hinge_end { ((mid - ov, to), (from, mid + ov)) } else { ((from, mid + ov), (mid - ov, to)) };
let sfw = jmin(p.frame_width, (to - from) / 6.0);
for ((u0, u1), (n0, n1)) in [(fixed, outer), (slide, inner)] {
for q in frame_ring_quads(u0, u1, bottom, top, sfw, p.corner_join, true) {
em.plane_quad(&q, n0, n1, Part::Frame);
}
let c = (n0 + n1) / 2.0;
em.axis_box(u0 + sfw, u1 - sfw, bottom + sfw, top - sfw, c - GLASS_HALF_THICK, c + GLASS_HALF_THICK, Part::Glass);
}
}
/// Kassettentür-Blatt: Rahmen + Trennstege in voller Blattdicke, Felder dünner und vertieft.
#[allow(clippy::too_many_arguments)]
fn kassette(em: &mut Emitter, leaf_from: f64, leaf_to: f64, leaf_bottom: f64, leaf_top: f64, n0: f64, n1: f64, p: &FrameParams) {
@@ -822,6 +921,9 @@ pub fn opening_meshes(walls: &[WallIn], detail: Detail) -> Vec<BoxMesh> {
door_leaf(&mut em, o, &p);
glass_panes(&mut em, o, &p);
}
if let (Some(ty), Some(p)) = (&o.ty, resolve_frame(o)) {
rebate_boxes(&mut em, o, ty, &p);
}
}
}
if detail == Detail::Coarse {
@@ -841,6 +943,18 @@ pub fn opening_meshes(walls: &[WallIn], detail: Detail) -> Vec<BoxMesh> {
let Some(TypeIn { kind: KindIn::Window(wt), .. }) = &o.ty else { continue };
let Some([bw, bh, bd]) = wt.shading else { continue };
let Some(p) = resolve_frame(o) else { continue };
if wt.shading_sturz {
// Storenkasten im Sturz: verdeckt; sichtbar sind nur die Führungsschienen vor dem Rahmen.
if wt.shading_rails {
let (rail_u, rail_n) = (0.03, 0.04);
let (n0, n1) = if o.ty.as_ref().is_some_and(|t| t.inset_inner) { (p.n_min - 0.005 - rail_n, p.n_min - 0.005) } else { (p.n_max + 0.005, p.n_max + 0.005 + rail_n) };
// Neben dem Anschlag (Wandnase) in der Leibung.
let rd = o.ty.as_ref().map_or(0.0, |t| jmax(0.0, jmin(or(t.rebate_depth, 0.0), (o.to - o.from) / 2.0 - 0.01)));
em.axis_box(o.from + rd, o.from + rd + rail_u, o.z_bottom, o.z_top, n0, n1, Part::Shading);
em.axis_box(o.to - rd - rail_u, o.to - rd, o.z_bottom, o.z_top, n0, n1, Part::Shading);
}
continue;
}
let h = jmax(0.0, bh);
let d = jmax(0.0, bd);
if h <= EPS || d <= EPS {
@@ -862,13 +976,14 @@ pub fn opening_meshes(walls: &[WallIn], detail: Detail) -> Vec<BoxMesh> {
// Eingabe: `[detail (0 grob, 1 mittel, 2 fein, sonst andere), nWände, Wand…]`
// Wand = `sx, sy, ex, ey, nÖffnungen, Öffnung…`
// Öffnung = `from, to, zBottom, zTop, istTür, Wanddicke, typisiert (0/1)[, Typ]`
// Typ = `frameDepth, insetFromFace, insetInnen, Eckstoss (0 vertikal, 1 horizontal, 2 Gehrung),
// frameWidth, transomHeight,` dann
// Typ = `frameDepth, insetFromFace, einzugSeite (0 aussen, 1 innen, 2 mitte), Eckstoss (0 vertikal,
// 1 horizontal, 2 Gehrung), frameWidth, transomHeight, Anschlag,` dann
// Tür: `threshold, leafCount, leafStyle (0 glatt, 1 glas, 2 kassette), glazingRatio, zarge,
// panelCols, panelRows`
// panelCols, panelRows, Türart (0 Dreh, 1 Schiebe, 2 Hebeschiebe, 3 Pendel), Schiebeseite (±1),
// BandEnde`
// Fenster: `glazingPanes, mullionRows, mullionCols, sillBoard (0 aussen/fehlt, 1 keine,
// 2 innen, 3 beide), Rollladen (0/1), Breite, Höhe, Tiefe, Flügelzahl-Default,
// Öffnungsart-Default, nFlügel, Flügel…`
// 2 innen, 3 beide), Rollladen (0/1), Breite, Höhe, Tiefe, imSturz, Schienen, Flügelzahl-Default,
// Öffnungsart-Default, nFlügel, Flügel…, nOberlicht, Flügel… ([95])`
// Flügel = `Art (0 Flügel, 1 Pfosten, 2 andere), festeBreite, width, postWidth, Öffnungsart,
// BandLinks`
// Öffnungsart: 0 fehlt, 1 dreh, 2 kipp, 3 drehkipp, 4 fest, 5 schiebe, 6 andere. NaN = fehlt.
@@ -894,7 +1009,8 @@ fn flag(r: &mut Reader) -> Option<bool> {
fn decode_type(r: &mut Reader, door: bool) -> Option<TypeIn> {
let frame_depth = r.num()?;
let inset_from_face = r.num()?;
let inset_inner = flag(r)?;
let inset_side = r.num()?;
let (inset_inner, inset_mid) = (inset_side == 1.0, inset_side == 2.0);
let corner_join = match r.num()? as i64 {
1 => CornerJoin::Horizontal,
2 => CornerJoin::Mitre,
@@ -902,6 +1018,7 @@ fn decode_type(r: &mut Reader, door: bool) -> Option<TypeIn> {
};
let frame_width = r.num()?;
let transom_height = r.num()?;
let rebate_depth = r.num()?;
let kind = if door {
KindIn::Door(DoorTypeIn {
threshold: flag(r)?,
@@ -915,6 +1032,9 @@ fn decode_type(r: &mut Reader, door: bool) -> Option<TypeIn> {
zarge: flag(r)?,
panel_cols: r.num()?,
panel_rows: r.num()?,
kind: r.num()?,
slide_side: r.num()?,
hinge_end: flag(r)?,
})
} else {
let glazing_panes = r.num()?;
@@ -928,8 +1048,31 @@ fn decode_type(r: &mut Reader, door: bool) -> Option<TypeIn> {
};
let create = flag(r)?;
let shading_box = [r.num()?, r.num()?, r.num()?];
let shading_sturz = flag(r)?;
let shading_rails = flag(r)?;
let default_wing_count = r.num()?;
let default_opening = opening_kind(r.num()?);
let sashes = decode_sashes(r)?;
let transom_sashes = decode_sashes(r)?;
KindIn::Window(WindowTypeIn {
glazing_panes,
mullion_rows,
mullion_cols,
sill_board,
sashes,
transom_sashes,
default_wing_count,
default_opening,
shading: if create { Some(shading_box) } else { None },
shading_sturz,
shading_rails,
})
};
Some(TypeIn { frame_depth, inset_from_face, inset_inner, inset_mid, rebate_depth, corner_join, frame_width, transom_height, kind })
}
/// Flügelliste `[n, Flügel × n]`.
fn decode_sashes(r: &mut Reader) -> Option<Vec<SashIn>> {
let n = r.count()?;
let mut sashes = Vec::with_capacity(n.min(1024));
for _ in 0..n {
@@ -946,18 +1089,7 @@ fn decode_type(r: &mut Reader, door: bool) -> Option<TypeIn> {
hinge_left: flag(r)?,
});
}
KindIn::Window(WindowTypeIn {
glazing_panes,
mullion_rows,
mullion_cols,
sill_board,
sashes,
default_wing_count,
default_opening,
shading: if create { Some(shading_box) } else { None },
})
};
Some(TypeIn { frame_depth, inset_from_face, inset_inner, corner_join, frame_width, transom_height, kind })
Some(sashes)
}
fn decode(buf: &[f64]) -> Option<(Vec<WallIn>, Detail)> {
@@ -1019,6 +1151,8 @@ mod tests {
frame_depth: f64::NAN,
inset_from_face: f64::NAN,
inset_inner: false,
inset_mid: false,
rebate_depth: f64::NAN,
corner_join: CornerJoin::Vertical,
frame_width: f64::NAN,
transom_height: f64::NAN,
@@ -1028,9 +1162,12 @@ mod tests {
mullion_cols: f64::NAN,
sill_board: sill,
sashes: vec![],
transom_sashes: vec![],
default_wing_count: 1.0,
default_opening: SashOpening::TurnTilt,
shading: None,
shading_sturz: false,
shading_rails: false,
}),
}
}
@@ -1040,6 +1177,8 @@ mod tests {
frame_depth: f64::NAN,
inset_from_face: f64::NAN,
inset_inner: false,
inset_mid: false,
rebate_depth: f64::NAN,
corner_join: CornerJoin::Vertical,
frame_width: f64::NAN,
transom_height: f64::NAN,
@@ -1051,6 +1190,9 @@ mod tests {
zarge: true,
panel_cols: f64::NAN,
panel_rows: f64::NAN,
kind: 0.0,
slide_side: 1.0,
hinge_end: false,
}),
}
}
@@ -1189,9 +1331,13 @@ mod tests {
assert!(jmin(0.0, -0.0).is_sign_negative());
assert!(jmax(1.0, f64::NAN).is_nan());
assert_eq!(clamp_range(5.0, 0.0, 1.0), 1.0);
let (a, b) = frame_normal_range(0.15, 0.07, 0.0, false);
let (a, b) = frame_normal_range(0.15, 0.07, 0.0, false, false);
assert!(close(a, 0.08) && close(b, 0.15));
let (a, b) = frame_normal_range(0.15, 0.07, 0.0, true);
let (a, b) = frame_normal_range(0.15, 0.07, 0.0, true, false);
assert!(close(a, -0.15) && close(b, -0.08));
let (a, b) = frame_normal_range(0.15, 0.08, 0.1, true, true);
assert!(close(a, -0.04) && close(b, 0.04));
let (a, b) = frame_normal_range(0.15, 0.07, 0.0, true, false);
assert!(close(a, -0.15) && close(b, -0.08));
}
@@ -1226,4 +1372,64 @@ mod tests {
assert!(opening_meshes_flat(&big)[0] >= 0.0);
let _ = frame_ring_quads(f64::NAN, f64::INFINITY, -1.0, 1.0, -3.0, CornerJoin::Mitre, false);
}
#[test]
fn anschlag_und_storenschienen() {
let mut ty = window_type(SillBoard::None);
ty.inset_from_face = 0.12;
ty.frame_depth = 0.08;
ty.rebate_depth = 0.05;
let parts = |ty: &TypeIn, d: Detail| -> Vec<Part> { opening_meshes(&[wall(op(false, Some(ty.clone())))], d).into_iter().map(|m| m.part).collect() };
let n = |v: &[Part], p: Part| v.iter().filter(|x| **x == p).count();
assert_eq!(n(&parts(&ty, Detail::Coarse), Part::Rebate), 3);
// Mittig: Anschlag-Zone aussen bis zur Rahmen-Vorderkante.
ty.inset_mid = true;
assert_eq!(n(&parts(&ty, Detail::Fine), Part::Rebate), 3);
ty.inset_mid = false;
ty.rebate_depth = f64::NAN;
assert_eq!(n(&parts(&ty, Detail::Fine), Part::Rebate), 0);
if let KindIn::Window(w) = &mut ty.kind {
w.shading = Some([0.0, 0.25, 0.2]);
}
assert_eq!(n(&parts(&ty, Detail::Fine), Part::Shading), 1);
if let KindIn::Window(w) = &mut ty.kind {
w.shading_sturz = true;
w.shading_rails = true;
}
assert_eq!(n(&parts(&ty, Detail::Fine), Part::Shading), 2, "im Sturz: nur zwei Führungsschienen");
}
/// [95] Oberlicht-Einteilung (Pfosten + Kippflügel) und Türarten in 3D.
#[test]
fn oberlicht_einteilung_und_tuerarten() {
let count = |ty: &TypeIn, door: bool, part: Part| opening_meshes(&[wall(op(door, Some(ty.clone())))], Detail::Fine).iter().filter(|m| m.part == part).count();
let mut ty = window_type(SillBoard::None);
ty.transom_height = 0.4;
let base = count(&ty, false, Part::Frame);
let sash = |kind: SashKind, opening: SashOpening| SashIn { kind, fixed_width: false, width: f64::NAN, post_width: f64::NAN, opening, hinge_left: true };
if let KindIn::Window(w) = &mut ty.kind {
w.transom_sashes = vec![sash(SashKind::Sash, SashOpening::Tilt), sash(SashKind::Post, SashOpening::None), sash(SashKind::Sash, SashOpening::Fixed)];
}
// + Pfosten + Flügelrahmen (4 Profile) des Kippflügels.
assert_eq!(count(&ty, false, Part::Frame), base + 1 + 4);
assert!(count(&ty, false, Part::Symbol) >= 2 + 2);
let mut d = door_type(LeafStyle::Glass);
if let KindIn::Door(k) = &mut d.kind {
k.kind = 2.0;
}
assert_eq!(count(&d, true, Part::DoorLeaf), 0);
assert_eq!(count(&d, true, Part::Glass), 2, "Hebeschiebe: zwei Glasfelder");
if let KindIn::Door(k) = &mut d.kind {
k.kind = 1.0;
k.slide_side = -1.0;
}
let m = opening_meshes(&[wall(op(true, Some(d.clone())))], Detail::Fine);
let leaf = m.iter().find(|m| m.part == Part::DoorLeaf).expect("Schiebeblatt");
// Vor der Innenfläche (y > 0.15 bei Wand entlang +x, rechte Normale −y) und breiter als die Lichte.
let ys: Vec<f64> = (0..8).map(|i| leaf.positions[i * 3 + 1]).collect();
assert!(ys.iter().all(|y| *y > 0.15), "{ys:?}");
let xs: Vec<f64> = (0..8).map(|i| leaf.positions[i * 3]).collect();
assert!(xs.iter().cloned().fold(f64::INFINITY, f64::min) < 1.0 && xs.iter().cloned().fold(f64::NEG_INFINITY, f64::max) > 2.2);
}
}
+27 -1
View File
@@ -267,11 +267,24 @@ fn collect_openings(p: &Project, frame: &[f64; 9]) -> Vec<ProjOpening> {
if dt.is_some_and(|d| d.leaf_style == DoorTypeLeafStyle::Glas) { 1.0 } else { 0.0 },
dt.and_then(|d| d.glazing_ratio).unwrap_or(f64::NAN),
wt.and_then(|t| t.frame_width).unwrap_or(0.06),
wt.and_then(|t| t.transom_height).unwrap_or(0.0),
if door { dt.and_then(|t| t.transom_height) } else { wt.and_then(|t| t.transom_height) }.unwrap_or(0.0),
wt.and_then(|t| t.mullion_rows).unwrap_or(f64::NAN),
wt.and_then(|t| t.mullion_cols).unwrap_or(f64::NAN),
if matches!(wt.and_then(|t| t.sill_board), Some(WindowTypeSillBoard::Keine | WindowTypeSillBoard::Innen)) { 0.0 } else { 1.0 },
wt.map_or(0.0, |t| sash_kind(t.kind)),
// Anschlag nur mit Leibung (Einzug > 0 oder mittig), sonst gibt es keine Wandnase.
match (dt, wt) {
(Some(t), _) if t.inset_face == Some(DoorTypeInsetFace::Mitte) || t.inset_from_face.unwrap_or(0.0) > 1e-4 => t.rebate_depth.unwrap_or(0.0),
(_, Some(t)) if t.inset_face == Some(WindowTypeInsetFace::Mitte) || t.inset_from_face.unwrap_or(0.0) > 1e-4 => t.rebate_depth.unwrap_or(0.0),
_ => 0.0,
},
if (door && dt.and_then(|t| t.inset_face) == Some(DoorTypeInsetFace::Innen)) || (!door && wt.and_then(|t| t.inset_face) == Some(WindowTypeInsetFace::Innen)) { -1.0 } else { 1.0 },
match dt.map(|t| t.kind) {
Some(DoorTypeKind::Schiebe) => 1.0,
Some(DoorTypeKind::Hebeschiebe) => 2.0,
Some(DoorTypeKind::Pendel) => 3.0,
_ => 0.0,
},
]);
// Flügel: (pfosten, postWidth, autoWidth, width, opening, hingeLeft).
let mut sashes: Vec<[f64; 6]> = Vec::new();
@@ -305,6 +318,19 @@ fn collect_openings(p: &Project, frame: &[f64; 9]) -> Vec<ProjOpening> {
for s in &sashes {
b.extend(s);
}
// Oberlicht-Einteilung (Pfosten/Riegel, [95]).
let transom = if door { &[][..] } else { wt.and_then(|t| t.transom_sashes.as_deref()).unwrap_or(&[]) };
b.push(transom.len() as f64);
for s in transom {
b.extend([
if s.kind == SashDefKind::Pfosten { 1.0 } else { 0.0 },
s.post_width.unwrap_or(f64::NAN),
if s.auto_width == Some(false) { 0.0 } else { 1.0 },
s.width.unwrap_or(f64::NAN),
s.opening.map_or(0.0, sash_kind),
if s.hinge_side.unwrap_or(SashDefHingeSide::Left) == SashDefHingeSide::Left { 1.0 } else { 0.0 },
]);
}
ids.push(&op.id);
b[0] += 1.0;
}
+111 -3
View File
@@ -1321,6 +1321,8 @@ const DEFAULT_FRAME_DEPTH: f64 = 0.07;
const DEFAULT_FRAME_WIDTH: f64 = 0.06;
const DOOR_LEAF_THICKNESS: f64 = 0.04;
const MIN_CROSS: f64 = 0.15;
const LINTEL_FILL: &str = "#d4d7db";
const SHADING_PACK_FILL: &str = "#e6e8eb";
fn rect(u0: f64, u1: f64, v0: f64, v1: f64) -> Vec<Vec2> {
vec![v2(min(u0, u1), v0), v2(max(u0, u1), v0), v2(max(u0, u1), v1), v2(min(u0, u1), v1)]
@@ -1418,6 +1420,7 @@ fn window_cut(p: &Project, wall: &Wall, o: &Opening, c: &CrossSection) -> Result
frame_depth: t.frame_depth.unwrap_or(f64::NAN),
inset_from_face: t.inset_from_face.unwrap_or(f64::NAN),
inset_inner: t.inset_face == Some(WindowTypeInsetFace::Innen),
inset_mid: t.inset_face == Some(WindowTypeInsetFace::Mitte),
});
let finite = [wall.start.x, wall.start.y, wall.end.x, wall.end.y, total, ref_off, o.position, o.width].iter().all(|x| x.is_finite());
let sym = if finite {
@@ -1463,17 +1466,92 @@ fn window_cut(p: &Project, wall: &Wall, o: &Opening, c: &CrossSection) -> Result
}
out.push(l);
}
if let Some(t) = wt {
let shading = t.shading.as_ref().filter(|s| s.create);
let sturz_box = shading.filter(|s| s.mount == Some(WindowShadingMount::Sturz)).map_or(0.0, |s| max(0.0, s.r#box.depth));
lintel_cut(&mut out, o, c, t.lintel_height, sturz_box);
// Fensterbänke nur bei ausdrücklicher Wahl (bisherige Schnitte bleiben gleich).
let zb = c.z_bottom;
if matches!(t.sill_board, Some(WindowTypeSillBoard::Aussen | WindowTypeSillBoard::Beide)) {
// Aussen: mit Gefälle, bis 4 cm vor die Aussenfläche.
let out_s = min(f_min, c.face_min) - 0.04;
let pts = vec![v2(c.u_at(f_min), zb), v2(c.u_at(out_s), zb - 0.015), v2(c.u_at(out_s), zb - 0.045), v2(c.u_at(f_min), zb - 0.03)];
out.push(opening_poly(pts, true, &o.id));
}
if matches!(t.sill_board, Some(WindowTypeSillBoard::Innen | WindowTypeSillBoard::Beide)) {
let in_s = max(f_max, c.face_max) + 0.02;
out.push(opening_poly(rect(c.u_at(f_max), c.u_at(in_s), zb - 0.025, zb), true, &o.id));
}
if let Some(sh) = shading {
let h = max(0.0, sh.r#box.height);
let d = max(0.0, sh.r#box.depth);
if h > 1e-4 && d > 1e-4 {
// Im Sturz: ab der Aussenfläche in die Wand; vorgesetzt: vor der Rahmen-Vorderkante.
let (s0, s1) = if sturz_box > 0.0 { (c.face_min, c.face_min + d) } else { (f_min - d, f_min) };
out.push(opening_poly(rect(c.u_at(s0), c.u_at(s1), c.z_top, c.z_top + h), true, &o.id));
// Lamellen-/Rollpaket im Kasten.
let m = min(0.02, d / 4.0);
let mut pack = polygon(rect(c.u_at(s0 + m), c.u_at(s1 - m), c.z_top + m, c.z_top + h * 0.6), SHADING_PACK_FILL, OPENING_INK, GLASS_MM, no_hatch_base());
if let Primitive::Polygon { opening_id, .. } = &mut pack {
*opening_id = Some(o.id.clone());
}
out.push(pack);
}
}
}
Ok(out)
}
fn door_cut(o: &Opening, c: &CrossSection) -> Vec<Primitive> {
/// Sturz im Schnitt ([94]): eigener Querschnitt über der Öffnung (Beton grau), neben einem
/// Storenkasten im Sturz (`box_depth` ab der Aussenfläche) nur über den Rest der Wanddicke.
fn lintel_cut(out: &mut Vec<Primitive>, o: &Opening, c: &CrossSection, height: Option<f64>, box_depth: f64) {
let h = height.unwrap_or(0.0);
if !(h > 1e-4) {
return;
}
let s0 = min(c.face_max, c.face_min + box_depth);
if c.face_max - s0 <= 1e-4 {
return;
}
let mut pr = polygon(rect(c.u_at(s0), c.u_at(c.face_max), c.z_top, c.z_top + h), LINTEL_FILL, OPENING_INK, FRAME_MM, no_hatch_base());
if let Primitive::Polygon { opening_id, .. } = &mut pr {
*opening_id = Some(o.id.clone());
}
out.push(pr);
}
fn door_cut(p: &Project, o: &Opening, c: &CrossSection) -> Vec<Primitive> {
let mut out = vec![opening_poly(rect(c.u_at(c.face_min), c.u_at(c.face_max), c.z_bottom, c.z_top), false, &o.id)];
if o.door_type == Some(OpeningDoorType::Wandoeffnung) {
lintel_cut(&mut out, o, c, p.door_type(o).and_then(|t| t.lintel_height), 0.0);
let kind = p.door_type(o).map(|t| t.kind);
if o.door_type == Some(OpeningDoorType::Wandoeffnung) || kind == Some(DoorTypeKind::Wandoeffnung) {
return out;
}
let mid = (c.face_min + c.face_max) / 2.0;
let fw = min(DEFAULT_FRAME_WIDTH, (c.z_top - c.z_bottom) / 4.0);
if kind == Some(DoorTypeKind::Schiebe) {
// Schiebetür vor der Wand ([95]): Blatt vor der Fläche auf der Aufschlagseite (linke Normale wie im Grundriss).
let swing = if matches!(o.swing, None | Some(SwingSide::Left)) { 1.0 } else { -1.0 };
let dir = if matches!(o.opening_dir, None | Some(OpeningOpeningDir::In)) { 1.0 } else { -1.0 };
let face = if swing * dir > 0.0 { c.face_max } else { c.face_min };
let s = swing * dir;
out.push(opening_poly(rect(c.u_at(face + s * 0.01), c.u_at(face + s * (0.01 + DOOR_LEAF_THICKNESS)), c.z_bottom + 0.01, c.z_top + 0.03), true, &o.id));
return out;
}
out.push(opening_poly(rect(c.u_at(mid - DEFAULT_FRAME_DEPTH / 2.0), c.u_at(mid + DEFAULT_FRAME_DEPTH / 2.0), c.z_top - fw, c.z_top), true, &o.id));
if kind == Some(DoorTypeKind::Hebeschiebe) {
// Zwei Flügel auf versetzten Gleisen, je mit Glaslinie.
for off in [-0.035, 0.035] {
let (a, b) = (mid + off - 0.02, mid + off + 0.02);
out.push(opening_poly(rect(c.u_at(a), c.u_at(b), c.z_bottom + 0.03, c.z_top - fw), true, &o.id));
let mut l = line(v2(c.u_at(mid + off), c.z_bottom + 0.03 + fw), v2(c.u_at(mid + off), c.z_top - 2.0 * fw), "section-window-glass", GLASS_MM, OPENING_INK);
if let Primitive::Line { opening_id, .. } = &mut l {
*opening_id = Some(o.id.clone());
}
out.push(l);
}
return out;
}
out.push(opening_poly(rect(c.u_at(mid - DOOR_LEAF_THICKNESS / 2.0), c.u_at(mid + DOOR_LEAF_THICKNESS / 2.0), c.z_bottom + 0.01, c.z_top - fw), true, &o.id));
out
}
@@ -1503,7 +1581,7 @@ pub fn section_opening_primitives(p: &Project, level: &LevelSpec, vis: &Visibili
continue;
}
let Some(c) = cross_section(p, wall, o, p0, u)? else { continue };
let prims = if o.kind == ElementKind::Window { window_cut(p, wall, o, &c)? } else { door_cut(o, &c) };
let prims = if o.kind == ElementKind::Window { window_cut(p, wall, o, &c)? } else { door_cut(p, o, &c) };
let greyed = vis.greyed(&o.category_code);
for pr in prims {
out.push(if greyed { pr.with_greyed(true) } else { pr });
@@ -1644,6 +1722,36 @@ mod tests {
assert!(!serde_json::to_string(&hidden).unwrap().contains("\"roofId\""));
}
/// [94] Sturz, Fensterbänke und Storenkasten im Sturz erscheinen im Schnitt nur, wenn gesetzt.
#[test]
fn sturz_baenke_und_storenkasten_im_schnitt() {
let mut p = sample();
// Schnittlinie quer durch die Mitte von O1 (Wand W1).
let o1 = p.openings.as_deref().unwrap().iter().find(|o| o.id == "O1").unwrap().clone();
let w1 = p.walls.iter().find(|w| w.id == o1.host_wall_id).unwrap().clone();
let (u, n) = axis_frame(&w1);
let m = o1.position + o1.width / 2.0;
let c = (w1.start.x + u.0 * m, w1.start.y + u.1 * m);
let l = LevelSpec { kind: "section".into(), line: Some([Vec2 { x: c.0 - n.0 * 3.0, y: c.1 - n.1 * 3.0 }, Vec2 { x: c.0 + n.0 * 3.0, y: c.1 + n.1 * 3.0 }]), ..Default::default() };
let vis = Visibility::default();
let base = section_opening_primitives(&p, &l, &vis).unwrap();
assert!(!base.is_empty());
let typed = p.openings.as_deref().unwrap_or(&[]).iter().filter(|o| o.type_id.is_some()).count();
assert!(typed > 0);
for t in p.window_types.iter_mut().flatten() {
t.lintel_height = Some(0.2);
t.sill_board = Some(WindowTypeSillBoard::Beide);
t.shading = Some(WindowShading { create: true, kind: WindowShadingKind::Raffstore, r#box: WindowShadingBox { width: 0.0, height: 0.3, depth: 0.18, ..Default::default() }, mount: Some(WindowShadingMount::Sturz), ..Default::default() });
}
for t in p.door_types.iter_mut().flatten() {
t.lintel_height = Some(0.2);
}
let more = section_opening_primitives(&p, &l, &vis).unwrap();
assert!(more.len() > base.len(), "{} {}", more.len(), base.len());
let json = serde_json::to_string(&more).unwrap();
assert!(json.contains(LINTEL_FILL) && json.contains(SHADING_PACK_FILL), "{json}");
}
#[test]
fn beschnittene_baender_behalten_ihre_ebene() {
// Von der Dominanz beschnittene Wand-/Deckenstücke tragen ihre Kategorie weiter: Ebene aus → weg.
+76 -11
View File
@@ -184,12 +184,7 @@ fn wall_poche(c: &Ctx, out: &mut Vec<Primitive>, e: &EffWall, gaps: &[(f64, f64)
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_or_fallback(&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_none(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();
let (hatch, fill) = layer_style(p, w, wt, li, category, angle)?;
styles.insert(li, (hatch.clone(), fill.clone()));
Ok((hatch, fill))
};
@@ -249,6 +244,17 @@ fn wall_poche(c: &Ctx, out: &mut Vec<Primitive>, e: &EffWall, gaps: &[(f64, f64)
Ok(())
}
/// Schraffur und Füllung der Schicht `li` im Wandschnitt (Bauteil, Wand- und Kategorie-Übersteuerung).
fn layer_style(p: &Project, w: &Wall, wt: &WallType, li: usize, category: Option<&LayerCategory>, angle: f64) -> Result<(HatchRender, String), String> {
let layer = wt.layers.get(li).ok_or("Schicht fehlt")?;
let comp = p.component_or_fallback(&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_none(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();
Ok((hatch, fill))
}
/// 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()) {
@@ -272,7 +278,7 @@ fn window_type<'a>(p: &'a Project, o: &Opening) -> Option<&'a WindowType> {
/// Ö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> {
fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, color: Option<&str>, greyed: bool, detail: Detail, lw: f64, wall_line: (&str, 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);
@@ -305,7 +311,7 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
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(b01(o.door_type == Some(OpeningDoorType::Wandoeffnung) || (door && door_type(p, o).is_some_and(|t| t.kind == DoorTypeKind::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,
@@ -321,7 +327,11 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
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)),
match t.inset_face {
Some(DoorTypeInsetFace::Innen) => 1.0,
Some(DoorTypeInsetFace::Mitte) => 2.0,
_ => 0.0,
},
]),
None => b.extend([0.0, 0.0, 0.0, 0.0, 0.0]),
}
@@ -330,7 +340,11 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
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(match wt.and_then(|t| t.inset_face) {
Some(WindowTypeInsetFace::Innen) => 1.0,
Some(WindowTypeInsetFace::Mitte) => 2.0,
_ => 0.0,
});
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());
@@ -351,6 +365,28 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
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));
// Details ([94]): Anschlag, Fensterbank, Storenkasten.
b.push(if door { dt.and_then(|t| t.rebate_depth) } else { wt.and_then(|t| t.rebate_depth) }.unwrap_or(0.0));
b.push(match wt.and_then(|t| t.sill_board) {
Some(WindowTypeSillBoard::Keine) => 1.0,
Some(WindowTypeSillBoard::Innen) => 2.0,
Some(WindowTypeSillBoard::Beide) => 3.0,
Some(WindowTypeSillBoard::Aussen) => 4.0,
_ => 0.0,
});
b.push(b01(shading.is_some_and(|s| s.mount == Some(WindowShadingMount::Sturz))));
b.push(shading.map_or(0.0, |s| s.r#box.depth));
b.push(match shading.map(|s| s.kind) {
Some(WindowShadingKind::Raffstore) => 1.0,
Some(WindowShadingKind::Markise) => 2.0,
_ => 0.0,
});
b.push(match dt.map(|t| t.kind) {
Some(DoorTypeKind::Schiebe) => 1.0,
Some(DoorTypeKind::Hebeschiebe) => 2.0,
Some(DoorTypeKind::Pendel) => 3.0,
_ => 0.0,
});
b.push(sash_list.len() as f64);
for s in &sash_list {
b.extend([
@@ -374,6 +410,34 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
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;
if f[i + 1] == 2.0 {
// Anschlag: Wandnase, je Wandschicht (aussen → innen) in deren Schnitt-Darstellung.
i += 5 + 2 * count;
if pts.len() != 4 {
continue;
}
let wtype = wall_type(p, w)?;
let category = c.cat(&w.category_code);
let angle = atan2(w.end.y - w.start.y, w.end.x - w.start.x) * 180.0 / std::f64::consts::PI;
let (_, n) = 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, ref_off }.frame();
let off = |q: &Vec2| (q.x - w.start.x) * n.x + (q.y - w.start.y) * n.y;
let (lo, hi) = (off(&pts[0]), off(&pts[2]));
let a = v2(pts[0].x - n.x * lo, pts[0].y - n.y * lo);
let bq = v2(pts[1].x - n.x * lo, pts[1].y - n.y * lo);
let at = |q: Vec2, d: f64| v2(q.x + n.x * d, q.y + n.y * d);
let mut l0 = ref_off - total / 2.0;
for (li, layer) in wtype.layers.iter().enumerate() {
let l1 = l0 + layer.thickness;
let (s0, s1) = (lo.max(l0), hi.min(l1));
l0 = l1;
if s1 - s0 <= 1e-6 {
continue;
}
let (hatch, fill) = layer_style(p, w, wtype, li, category, angle)?;
out.push(wall_polygon(vec![at(a, s0), at(bq, s0), at(bq, s1), at(a, s1)], &fill, wall_line.0, wall_line.1, hatch, greyed, None, Some(&w.id), id));
}
continue;
}
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 {
@@ -460,7 +524,8 @@ pub fn plan_walls(c: &Ctx, reference_lines: bool, out: &mut Vec<Primitive>, boun
Some(DetailLevel::Fein) => Detail::Fein,
_ => c.a.detail,
};
opening_symbol(c, out, w, o, color, c.greyed(&o.category_code), detail, olw)?;
let wall_line = (e.color.as_deref().unwrap_or(POCHE_STROKE), lw * c.a.detail.outline_factor());
opening_symbol(c, out, w, o, color, c.greyed(&o.category_code), detail, olw, wall_line)?;
}
}
Ok(())
+167 -40
View File
@@ -38,7 +38,8 @@
//! istTuer, glasBlatt, glasAnteil (NaN = 1),
//! rahmenbreite, kaempferHoehe, sprossenZeilen (NaN = 1), sprossenSpalten (NaN = 1),
//! bankAn, typArt (0 fest, 1 dreh, 2 kipp, 3 drehkipp, 4 schiebe),
//! nFluegel, (pfosten, pfostenBreite (NaN), autoBreite (0/1), breite (NaN), art (-1 = typArt), bandLinks) × nFluegel
//! anschlag (Meter, 0 keiner), anschlagSeite (1 aussen | −1 innen; [94]),
//! tuerArt (0 Dreh | 1 Schiebe | 2 Hebeschiebe | 3 Pendel; [95]), nFluegel, (pfosten, pfostenBreite (NaN), autoBreite (0/1), breite (NaN), art (-1 = typArt), bandLinks) × nFluegel
//! ```
//! → `[n, (ok, tiefe, istTuer, 8 Ecken, Listen) × n]`; `ok` 0 = nicht sichtbar (sonst nichts mehr).
//! Listen in dieser Reihenfolge, je `[anzahl, Einträge]`: glas, tuerblatt (Vierecke à 8 Werte),
@@ -825,8 +826,16 @@ fn rect(q: &Quad, fa0: f64, fa1: f64, fz0: f64, fz1: f64) -> Quad {
[quad_at(q, fa0, fz0), quad_at(q, fa1, fz0), quad_at(q, fa1, fz1), quad_at(q, fa0, fz1)]
}
/// Feste Werte je Öffnung vor der Flügelliste (der letzte = Flügelzahl).
const REC: usize = 22;
/// Projiziert die zum Betrachter zeigende Wand-Langseite der Öffnung; `None` ohne sichtbare Seite.
fn project_opening_rect(f: &Frame, o: &[f64]) -> Option<(Quad, f64)> {
project_opening_side(f, o).map(|(q, d, _)| (q, d))
}
/// Wie [`project_opening_rect`], dazu die Seite (+1 = Seite +n, die Aussenseite; −1 = innen).
fn project_opening_side(f: &Frame, o: &[f64]) -> Option<(Quad, f64, f64)> {
let (sx, sz) = (o[0], o[1]);
let ax = o[2] - o[0];
let az = o[3] - o[1];
@@ -859,39 +868,14 @@ fn project_opening_rect(f: &Frame, o: &[f64]) -> Option<(Quad, f64)> {
if depth <= EPS {
continue;
}
return Some((pts, depth));
return Some((pts, depth, if side > 0.0 { 1.0 } else { -1.0 }));
}
None
}
fn layout_opening(o: &[f64], sashes: &[f64], pts: &Quad) -> OpeningOut {
let mut out = OpeningOut::default();
let (from, to, z_bottom, z_top) = (o[5], o[6], o[7], o[8]);
let w = to - from;
let h = z_top - z_bottom;
if o[9] != 0.0 {
// Tür: Blatt-Fläche, bei Glasblatt mit Teilverglasung (Kämpferhöhe von OBEN).
if o[10] != 0.0 {
let ratio = max(0.05, min(1.0, if o[11].is_nan() { 1.0 } else { o[11] }));
if ratio >= 1.0 - EPS {
out.glass.push(rect(pts, 0.04, 0.96, 0.0, 0.97));
} else {
let split_z = 0.97 * (1.0 - ratio);
out.glass.push(rect(pts, 0.04, 0.96, split_z, 0.97));
out.door_leaf.push(rect(pts, 0.04, 0.96, 0.0, split_z));
out.divisions.push((quad_at(pts, 0.04, split_z), quad_at(pts, 0.96, split_z)));
}
} else {
out.door_leaf.push(rect(pts, 0.04, 0.96, 0.0, 0.97));
}
return out;
}
let fw = o[12];
let fa = min(0.45, fw / max(w, 1e-6));
let fz = min(0.45, fw / max(h, 1e-6));
let transom = max(0.0, o[13]);
let f_tr = if transom > EPS && transom < h - fw { 1.0 - transom / h } else { 0.0 };
let field_top = if f_tr > 0.0 { f_tr - fz / 2.0 } else { 1.0 - fz };
/// Flügel/Pfosten eines Feldbands `fz..field_top` (Anteile der Öffnungshöhe) über die lichte Breite.
#[allow(clippy::too_many_arguments)]
fn sash_band(out: &mut OpeningOut, o: &[f64], sashes: &[f64], pts: &Quad, w: f64, h: f64, fa: f64, fw: f64, fz: f64, field_top: f64, rows_in: f64, cols_in: f64) {
let inner_w = max(1e-6, w * (1.0 - 2.0 * fa));
let n_sashes = sashes.len() / 6;
let sash = |k: usize| &sashes[6 * k..6 * k + 6];
@@ -933,8 +917,8 @@ fn layout_opening(o: &[f64], sashes: &[f64], pts: &Quad) -> OpeningOut {
let g_b = fa1 - g_u;
let gz0 = fz + g_v;
let gz1 = field_top - g_v;
let rows = max(1.0, round(if o[14].is_nan() { 1.0 } else { o[14] })) as usize;
let cols = max(1.0, round(if o[15].is_nan() { 1.0 } else { o[15] })) as usize;
let rows = max(1.0, round(if rows_in.is_nan() { 1.0 } else { rows_in })) as usize;
let cols = max(1.0, round(if cols_in.is_nan() { 1.0 } else { cols_in })) as usize;
if g_b - g_a > 1e-6 && gz1 - gz0 > 1e-6 {
for r in 0..rows {
let rf = r as f64;
@@ -991,6 +975,59 @@ fn layout_opening(o: &[f64], sashes: &[f64], pts: &Quad) -> OpeningOut {
out.symbol.push((quad_at(pts, head - barb, gz0 + (gz1 - gz0) * 0.68), head_pt));
}
}
}
fn layout_opening(o: &[f64], sashes: &[f64], transom_sashes: &[f64], pts: &Quad) -> OpeningOut {
let mut out = OpeningOut::default();
let (from, to, z_bottom, z_top) = (o[5], o[6], o[7], o[8]);
let w = to - from;
let h = z_top - z_bottom;
if o[9] != 0.0 {
// Oberlicht über dem Kämpfer ([95]): festes Glasfeld, das Blatt endet darunter.
let transom = if o[13].is_nan() { 0.0 } else { o[13] };
let top = if transom > EPS && transom < h * 0.8 {
let f_tr = 1.0 - transom / h;
out.glass.push(rect(pts, 0.04, 0.96, f_tr + 0.015, 0.97));
out.divisions.push((quad_at(pts, 0.0, f_tr), quad_at(pts, 1.0, f_tr)));
f_tr - 0.015
} else {
0.97
};
let kind = o[20];
if kind == 2.0 {
// Hebeschiebetür: zwei Glasfelder, Pfeil auf dem Schiebefeld (zur Mitte hin).
out.glass.push(rect(pts, 0.04, 0.5, 0.03, top));
out.glass.push(rect(pts, 0.5, 0.96, 0.03, top));
out.divisions.push((quad_at(pts, 0.5, 0.0), quad_at(pts, 0.5, top)));
slide_arrow(&mut out, pts, 0.85, 0.6, top * 0.5, top);
return out;
}
// Tür: Blatt-Fläche, bei Glasblatt mit Teilverglasung (Kämpferhöhe von OBEN).
if o[10] != 0.0 {
let ratio = max(0.05, min(1.0, if o[11].is_nan() { 1.0 } else { o[11] }));
if ratio >= 1.0 - EPS {
out.glass.push(rect(pts, 0.04, 0.96, 0.0, top));
} else {
let split_z = top * (1.0 - ratio);
out.glass.push(rect(pts, 0.04, 0.96, split_z, top));
out.door_leaf.push(rect(pts, 0.04, 0.96, 0.0, split_z));
out.divisions.push((quad_at(pts, 0.04, split_z), quad_at(pts, 0.96, split_z)));
}
} else {
out.door_leaf.push(rect(pts, 0.04, 0.96, 0.0, top));
}
if kind == 1.0 {
slide_arrow(&mut out, pts, 0.75, 0.25, top * 0.5, top);
}
return out;
}
let fw = o[12];
let fa = min(0.45, fw / max(w, 1e-6));
let fz = min(0.45, fw / max(h, 1e-6));
let transom = max(0.0, o[13]);
let f_tr = if transom > EPS && transom < h - fw { 1.0 - transom / h } else { 0.0 };
let field_top = if f_tr > 0.0 { f_tr - fz / 2.0 } else { 1.0 - fz };
sash_band(&mut out, o, sashes, pts, w, h, fa, fw, fz, field_top, o[14], o[15]);
if o[16] != 0.0 {
let ov1 = 0.02 / max(w, 1e-6);
let ov2 = 0.05 / max(w, 1e-6);
@@ -1000,12 +1037,26 @@ fn layout_opening(o: &[f64], sashes: &[f64], pts: &Quad) -> OpeningOut {
out.sill.push(rect(pts, -ov2, 1.0 + ov2, -(h1 + h2), -h1));
}
if f_tr > 0.0 {
out.glass.push(rect(pts, fa, 1.0 - fa, f_tr + fz / 2.0, 1.0 - fz));
if transom_sashes.is_empty() {
out.glass.push(rect(pts, fa, 1.0 - fa, f_tr + fz / 2.0, 1.0 - fz));
} else {
// Oberlicht mit Einteilung (Pfosten/Riegel, [95]).
sash_band(&mut out, o, transom_sashes, pts, w, h, fa, fw, f_tr + fz / 2.0, 1.0 - fz, f64::NAN, f64::NAN);
}
out.divisions.push((quad_at(pts, 0.0, f_tr), quad_at(pts, 1.0, f_tr)));
}
out
}
/// Schiebe-Pfeil (Schaft + zwei Widerhaken) von `tail` nach `head` (Anteile der Breite) auf Höhe `zc`.
fn slide_arrow(out: &mut OpeningOut, pts: &Quad, tail: f64, head: f64, zc: f64, top: f64) {
let barb = (head - tail) * 0.22;
let head_pt = quad_at(pts, head, zc);
out.symbol.push((quad_at(pts, tail, zc), head_pt));
out.symbol.push((quad_at(pts, head - barb, zc - top * 0.08), head_pt));
out.symbol.push((quad_at(pts, head - barb, zc + top * 0.08), head_pt));
}
fn push_quads(f: &mut Vec<f64>, list: &[Quad]) {
f.push(list.len() as f64);
for q in list {
@@ -1038,21 +1089,39 @@ pub fn openings(frame: &[f64], inp: &[f64]) -> Vec<f64> {
let mut f = vec![n as f64];
let mut i = 1;
for _ in 0..n {
if i + 19 > inp.len() {
if i + REC > inp.len() {
return Vec::new();
}
let o = &inp[i..i + 19];
let ns = o[18];
if !(ns >= 0.0) || ns.fract() != 0.0 || i + 19 + 6 * ns as usize > inp.len() {
let o = &inp[i..i + REC];
let ns = o[REC - 1];
if !(ns >= 0.0) || ns.fract() != 0.0 || i + REC + 6 * ns as usize > inp.len() {
return Vec::new();
}
let ns = ns as usize;
let sashes = &inp[i + 19..i + 19 + 6 * ns];
i += 19 + 6 * ns;
let sashes = &inp[i + REC..i + REC + 6 * ns];
i += REC + 6 * ns;
// Oberlicht-Einteilung ([95]): `[n, Flügel × n]`.
let nt = inp.get(i).copied().unwrap_or(f64::NAN);
if !(nt >= 0.0) || nt.fract() != 0.0 || i + 1 + 6 * nt as usize > inp.len() {
return Vec::new();
}
let transom_sashes = &inp[i + 1..i + 1 + 6 * nt as usize];
i += 1 + 6 * nt as usize;
let geo = &o[..9];
if geo.iter().any(|v| !v.is_finite()) {
return Vec::new();
}
// Anschlag ([94]): von der Anschlag-Seite aus deckt die Wandnase Rahmen links, rechts und oben ab.
let mut oo = o.to_vec();
if let Some((_, _, side)) = project_opening_side(&fr, o) {
let rd = min(if o[18].is_nan() { 0.0 } else { o[18] }, (o[6] - o[5]) / 2.0 - 0.01);
if rd > 1e-4 && side * o[19] > 0.0 && o[8] - o[7] > 2.0 * rd {
oo[5] += rd;
oo[6] -= rd;
oo[8] -= rd;
}
}
let o = &oo[..];
match project_opening_rect(&fr, o) {
None => f.push(0.0),
Some((pts, depth)) => {
@@ -1060,7 +1129,7 @@ pub fn openings(frame: &[f64], inp: &[f64]) -> Vec<f64> {
for p in &pts {
f.extend([p.0, p.1]);
}
let out = layout_opening(o, sashes, &pts);
let out = layout_opening(o, sashes, transom_sashes, &pts);
push_quads(&mut f, &out.glass);
push_quads(&mut f, &out.door_leaf);
push_lines(&mut f, &out.divisions);
@@ -1163,4 +1232,62 @@ mod tests_ts {
let f = occluded_points(&occ, &[3.0, 10.5, 0.5, 5.0, 10.5, 0.5, 0.5, 99.0, 0.5, 5.0]);
assert_eq!(f, vec![3.0, 1.0, 0.0, 0.0]);
}
/// [94] Anschlag: von der Anschlag-Seite aus ist die sichtbare Öffnung um die Wandnasen kleiner.
#[test]
fn anschlag_verkleinert_die_ansicht_nur_von_seiner_seite() {
let frame = [0.0, 0.0, -3.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0];
let rec = |rebate: f64, side: f64| {
vec![1.0, 0.0, 0.0, 5.0, 0.0, 0.3, 1.0, 2.2, 0.9, 2.3, 0.0, 0.0, f64::NAN, 0.06, 0.0, f64::NAN, f64::NAN, 1.0, 1.0, rebate, side, 0.0, 0.0, 0.0]
};
let width = |f: &[f64]| {
assert_eq!(f[1], 1.0);
let xs = [f[4], f[6], f[8], f[10]];
xs.iter().cloned().fold(f64::NEG_INFINITY, f64::max) - xs.iter().cloned().fold(f64::INFINITY, f64::min)
};
let w0 = width(&openings(&frame, &rec(0.0, 1.0)));
let w1 = width(&openings(&frame, &rec(0.05, 1.0)));
let w2 = width(&openings(&frame, &rec(0.05, -1.0)));
assert!((w0 - 1.2).abs() < 1e-9 && (w1 - 1.1).abs() < 1e-9 && (w2 - 1.2).abs() < 1e-9, "{w0} {w1} {w2}");
}
/// [95] Türarten/Oberlicht in der Ansicht: Hebeschiebe = zwei Glasfelder + Pfeil; Tür-Oberlicht;
/// Oberlicht-Einteilung eines Fensters mit Kippflügel und Pfosten.
#[test]
fn tuerarten_und_oberlicht_in_der_ansicht() {
let frame = [0.0, 0.0, -3.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0];
let rec = |door: f64, transom: f64, kind: f64, transom_sashes: &[[f64; 6]]| {
let mut b = vec![1.0, 0.0, 0.0, 5.0, 0.0, 0.3, 1.0, 2.2, 0.0, 2.3, door, 0.0, f64::NAN, 0.06, transom, f64::NAN, f64::NAN, 1.0, 1.0, 0.0, 1.0, kind];
if door == 0.0 {
b.extend([1.0, 0.0, f64::NAN, 1.0, f64::NAN, 3.0, 1.0]);
} else {
b.push(0.0);
}
b.push(transom_sashes.len() as f64);
for t in transom_sashes {
b.extend(t);
}
b
};
// Listen ab Index 12: glas, tuerblatt, teilungen, fluegel, bank, symbol.
let lists = |f: &[f64]| {
let mut i = 12;
let mut n = Vec::new();
for size in [8, 8, 4, 8, 8, 4] {
let c = f[i] as usize;
n.push(c);
i += 1 + c * size;
}
assert_eq!(i, f.len());
n
};
let hs = lists(&openings(&frame, &rec(1.0, 0.0, 2.0, &[])));
assert_eq!((hs[0], hs[1], hs[5]), (2, 0, 3));
let tr = lists(&openings(&frame, &rec(1.0, 0.4, 0.0, &[])));
assert_eq!((tr[0], tr[1], tr[2]), (1, 1, 1));
let plain = lists(&openings(&frame, &rec(0.0, 0.5, 0.0, &[])));
let split = lists(&openings(&frame, &rec(0.0, 0.5, 0.0, &[[0.0, f64::NAN, 1.0, f64::NAN, 2.0, 1.0], [1.0, 0.08, 1.0, f64::NAN, 0.0, 1.0], [0.0, f64::NAN, 1.0, f64::NAN, 0.0, 1.0]])));
assert_eq!(split[3], plain[3] + 2, "zwei Oberlicht-Felder");
assert!(split[5] >= plain[5] + 2, "Kipp-Symbol im Oberlicht");
}
}
+337 -20
View File
@@ -7,16 +7,20 @@
//! detail (0 grob | 1 mittel | 2 fein),
//! Tür: schwenkRechts, ausen, anschlagEnde, schwenkwinkel (NaN = 90), wandoeffnung, fluegel,
//! sturz (0 keine | 1 aussen | 2 innen | 3 beide),
//! Rahmen: hat, breite, art (0 Zarge | 1 Blockrahmen), einzug, einzugInnen,
//! Fenster: hatTyp, profilbreite, rahmentiefe (NaN), einzug (NaN), einzugInnen, altFluegel (NaN = 1),
//! Rahmen: hat, breite, art (0 Zarge | 1 Blockrahmen), einzug, einzugSeite (0 aussen | 1 innen | 2 mitte),
//! Fenster: hatTyp, profilbreite, rahmentiefe (NaN), einzug (NaN), einzugSeite (0 | 1 | 2), altFluegel (NaN = 1),
//! glasAlt, sims (0 keine | 1 aussen | 2 innen | 3 beide), simsUnter (0|1), kasten (0|1),
//! kastenBreite, kastenHoehe,
//! Stärken: haar, rahmenHaar, rahmenAufsicht, fluegel, sims,
//! Details ([94]): anschlag (Meter, 0 keiner), bank (0 fehlt | 1 keine | 2 innen | 3 beide | 4 aussen),
//! kastenSturz (0 vorgesetzt | 1 im Sturz), kastenTiefe, kastenArt (0 Rollladen | 1 Raffstore | 2 Markise),
//! Türart ([95]): 0 Dreh | 1 Schiebe (vor der Wand, Aufschlagseite) | 2 Hebeschiebe | 3 Pendel,
//! nFluegel, (pfosten, auto, breite, pfostenbreite, oeffenbar) × n]`.
//!
//! Ausgabe `[n, Eintrag × n]` in Zeichenreihenfolge:
//! ```text
//! 1 polygon [1, art (0 Pick-Fläche | 1 Rahmen-Aufsicht), weightMm, farbSlot, nPts, x, y …]
//! 1 polygon [1, art (0 Pick-Fläche | 1 Rahmen-Aufsicht | 2 Anschlag, Wandschnitt der Fläche
//! `einzugSeite`), weightMm, farbSlot, nPts, x, y …]
//! 2 line [2, cls, weightMm, farbSlot, strich, ax, ay, bx, by]
//! 3 arc [3, weightMm, cx, cy, fromX, fromY, toX, toY, r] (cls door-swing)
//! cls 0 door-leaf · 1 door-frame · 2 door-lintel · 3 opening-frame · 4 window-glass ·
@@ -95,12 +99,12 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
let frame_width = r.num()?;
let frame_block = r.num()? != 0.0;
let frame_inset = r.num()?;
let frame_inset_inner = r.num()? != 0.0;
let frame_inset_side = r.num()?;
let has_type = r.num()? != 0.0;
let win_frame_width = r.num()?;
let win_frame_depth = r.num()?;
let win_inset = r.num()?;
let win_inset_inner = r.num()? != 0.0;
let win_inset_side = r.num()?;
let wing_count = r.num()?;
let glass_alt = r.num()?;
let sill_faces = r.num()? as i64;
@@ -109,6 +113,12 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
let shading_width = r.num()?;
let shading_height = r.num()?;
let (hair, frame_hair, frame_view_w, sash_w, sill_w) = (r.num()?, r.num()?, r.num()?, r.num()?, r.num()?);
let rebate = r.num()?;
let sill_board = r.num()? as i64;
let shading_sturz = r.num()? != 0.0;
let shading_depth = r.num()?;
let shading_kind = r.num()? as i64;
let door_kind = r.num()? as i64;
let n_sash = r.count()?;
let mut sashes = Vec::with_capacity(n_sash);
for _ in 0..n_sash {
@@ -132,14 +142,47 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
if let Some(gap) = opening_gap_quad(&w, position, width) {
o.polygon(0.0, 0.0, 0.0, &gap);
}
if !wandoeffnung {
let count = max(1.0, round(if leaf_count.is_nan() { 1.0 } else { leaf_count }));
let count = max(1.0, round(if leaf_count.is_nan() { 1.0 } else { leaf_count }));
if wandoeffnung {
// Reine Wandöffnung: nur Lücke (und Sturzlinien).
} else if door_kind == 1 {
sliding_leaves(&mut o, &w, jamb_start, jamb_end, &door, count, hair);
} else if door_kind == 2 {
// Gleise im Rahmen: hinter der Anschlag-Zone (bzw. mittig ohne Rahmentyp).
let half = total / 2.0;
let depth = max(0.12, if frame_width.is_nan() { 0.0 } else { frame_width });
let (lo, hi) = if !has_frame {
(ref_off - depth / 2.0, ref_off + depth / 2.0)
} else if frame_inset_side == 1.0 {
let e = ref_off + half - max(0.0, min(frame_inset, total));
(max(ref_off - half, e - depth), e)
} else if frame_inset_side == 2.0 {
(ref_off - depth / 2.0, ref_off + depth / 2.0)
} else {
let e = ref_off - half + max(0.0, min(frame_inset, total));
(e, min(ref_off + half, e + depth))
};
lift_slide(&mut o, jamb_start, jamb_end, wn, lo, hi, door.hinge_end, hair);
} else {
for leaf in door_leaves(&w, position, width, &door, count) {
o.line(C_LEAF, hair, 0.0, 0.0, leaf.hinge, leaf.open_end);
if detail != Detail::Grob {
o.arc(hair, leaf.hinge, leaf.closed_end, leaf.open_end, leaf.radius);
}
}
if door_kind == 3 {
// Pendeltür: schlägt auch zur Gegenseite auf (Blatt gepunktet, Bogen).
let other = DoorParams { swing_right: !door.swing_right, ..door };
for leaf in door_leaves(&w, position, width, &other, count) {
o.line(C_LEAF, hair, 0.0, 3.0, leaf.hinge, leaf.open_end);
if detail != Detail::Grob {
// Bögen laufen gegen den Uhrzeigersinn von `from` nach `to`: kurzen Bogen wählen.
let (a, b) = (sub(leaf.closed_end, leaf.hinge), sub(leaf.open_end, leaf.hinge));
let (from, to) = if a.x * b.y - a.y * b.x >= 0.0 { (leaf.closed_end, leaf.open_end) } else { (leaf.open_end, leaf.closed_end) };
o.arc(hair, leaf.hinge, from, to, leaf.radius);
}
}
}
}
if detail == Detail::Fein {
let reveal = 0.06;
@@ -148,7 +191,8 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
}
}
if has_frame {
frame_band(&mut o, &w, position, width, frame_width, frame_block, frame_inset, frame_inset_inner, hair);
let zone = frame_band(&mut o, &w, position, width, frame_width, frame_block, frame_inset, frame_inset_side, hair);
rebate_nibs(&mut o, &w, position, width, rebate, zone);
}
if lintel != 0 {
let half_d = total / 2.0;
@@ -174,7 +218,8 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
frame_width: win_frame_width,
frame_depth: win_frame_depth,
inset_from_face: win_inset,
inset_inner: win_inset_inner,
inset_inner: win_inset_side == 1.0,
inset_mid: win_inset_side == 2.0,
})
} else {
None
@@ -183,6 +228,19 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
if let Some(gap) = opening_gap_quad(&w, position, width) {
o.polygon(0.0, 0.0, 0.0, &gap);
}
// Rahmenlage quer zur Wand (absolut entlang der linken Normalen).
let (f_lo, f_hi) = match opening_jambs(&w, position, width) {
Some((js, _)) => {
let a = dot(sub(sym.frame[0], js), wn);
let b = dot(sub(sym.frame[2], js), wn);
(min(a, b), max(a, b))
}
None => (ref_off - total / 2.0, ref_off + total / 2.0),
};
if has_type {
let zone = if win_inset_side == 1.0 { (f_hi, ref_off + total / 2.0) } else { (ref_off - total / 2.0, f_lo) };
rebate_nibs(&mut o, &w, position, width, rebate, Some(zone));
}
if detail == Detail::Grob {
let idx = sym.glass_lines.len() / 2;
if let Some(g) = sym.glass_lines.get(idx).or_else(|| sym.glass_lines.first()) {
@@ -209,16 +267,31 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
}
if detail == Detail::Fein {
if let Some((js, je)) = opening_jambs(&w, position, width) {
let outer_n = min(dot(sub(sym.frame[0], js), wn), dot(sub(sym.frame[2], js), wn));
let outer_n = f_lo;
let (ov, proj) = (0.03, 0.04);
let s0 = along(js, je, -ov);
let s1 = along(je, js, -ov);
let b0 = add(s0, scale(wn, outer_n));
let b1 = add(s1, scale(wn, outer_n));
let b2 = add(s1, scale(wn, outer_n - proj));
let b3 = add(s0, scale(wn, outer_n - proj));
for (a, b) in [(b0, b1), (b1, b2), (b2, b3), (b3, b0)] {
o.line(C_SILL, hair, 1.0, 0.0, a, b);
// Fensterbank aussen (fehlt/aussen/beide): von der Rahmen-Vorderkante bis vor die Aussenfläche.
if sill_board == 0 || sill_board == 3 || sill_board == 4 {
let far = min(outer_n, ref_off - total / 2.0) - proj;
let b0 = add(s0, scale(wn, outer_n));
let b1 = add(s1, scale(wn, outer_n));
let b2 = add(s1, scale(wn, far));
let b3 = add(s0, scale(wn, far));
for (a, b) in [(b0, b1), (b1, b2), (b2, b3), (b3, b0)] {
o.line(C_SILL, hair, 1.0, 0.0, a, b);
}
}
// Fensterbank innen (innen/beide): von der Rahmen-Hinterkante bis vor die Innenfläche.
if sill_board == 2 || sill_board == 3 {
let far = max(f_hi, ref_off + total / 2.0) + 0.02;
let b0 = add(s0, scale(wn, f_hi));
let b1 = add(s1, scale(wn, f_hi));
let b2 = add(s1, scale(wn, far));
let b3 = add(s0, scale(wn, far));
for (a, b) in [(b0, b1), (b1, b2), (b2, b3), (b3, b0)] {
o.line(C_SILL, hair, 1.0, 0.0, a, b);
}
}
let reveal = 0.06;
for jamb in [js, je] {
@@ -248,7 +321,8 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
let outer_face = ref_off - total / 2.0;
let axis_width = hypot2(je.x - js.x, je.y - js.y);
let box_width = if shading_width > 0.0 { shading_width } else { axis_width };
let box_height = max(0.0, shading_height);
// Im Sturz: Kasten verdeckt in der Wand, Tiefe quer zur Wand ab der Aussenfläche.
let box_height = max(0.0, if shading_sturz { shading_depth } else { shading_height });
let center = add(js, scale(u, axis_width / 2.0));
let half = box_width / 2.0;
let c1 = add(center, scale(u, -half));
@@ -260,11 +334,93 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
for (a, b) in [(p1, p2), (p2, p3), (p3, p4), (p4, p1)] {
o.line(C_SHADING, hair, 1.0, 2.0, a, b);
}
// Führungsschienen der Storen (fein, Kasten im Sturz, nicht bei Markise) vor dem Rahmen.
if shading_sturz && detail == Detail::Fein && shading_kind != 2 {
let (rail_u, rail_n) = (0.03, 0.04);
let front = if win_inset_side == 1.0 { f_hi } else { f_lo };
let dir = if win_inset_side == 1.0 { 1.0 } else { -1.0 };
// Neben dem Anschlag (Wandnase) in der Leibung.
let rd = if has_type && rebate > 1e-4 { min(rebate, axis_width / 2.0 - 0.01) } else { 0.0 };
for (u0, u1) in [(rd, rd + rail_u), (axis_width - rd - rail_u, axis_width - rd)] {
let a = along(js, je, u0);
let b = along(js, je, u1);
let n0 = front + dir * 0.005;
let n1 = front + dir * (0.005 + rail_n);
o.ring(C_SHADING, hair, 1.0, &[add(a, scale(nrm, n0)), add(b, scale(nrm, n0)), add(b, scale(nrm, n1)), add(a, scale(nrm, n1))]);
}
}
}
}
Some(finish(o))
}
/// Pfeil von `a` nach `b` (Schaft + zwei Widerhaken) in Richtung der Schiebebewegung.
fn arrow(o: &mut Out, a: V, b: V, side: V, hair: f64) {
let d = normalize(sub(b, a));
let l = hypot2(b.x - a.x, b.y - a.y);
let barb = min(0.12, l * 0.35);
o.line(C_LEAF, hair, 0.0, 0.0, a, b);
for k in [-1.0, 1.0] {
o.line(C_LEAF, hair, 0.0, 0.0, b, add(sub(b, scale(d, barb)), scale(side, k * barb * 0.45)));
}
}
/// Schiebetür vor der Wand (SIA): Blatt als schmales Rechteck in Schliessstellung auf der
/// Aufschlagseite vor der Wandfläche, je Blatt ein Pfeil zur Parkseite (Bandseite bzw. aussen).
fn sliding_leaves(o: &mut Out, w: &WallRef, js: V, je: V, p: &DoorParams, count: f64, hair: f64) {
let n = w.frame().1;
let side = (if p.swing_right { -1.0 } else { 1.0 }) * (if p.open_out { -1.0 } else { 1.0 });
let face = w.ref_off + side * w.total / 2.0;
let (n0, n1) = (face + side * 0.01, face + side * 0.05);
let wd = hypot2(je.x - js.x, je.y - js.y);
let ov = 0.05;
let leaf = |o: &mut Out, u0: f64, u1: f64| {
let a = along(js, je, u0);
let b = along(js, je, u1);
o.ring(C_LEAF, hair, 0.0, &[add(a, scale(n, n0)), add(b, scale(n, n0)), add(b, scale(n, n1)), add(a, scale(n, n1))]);
};
let mid_n = face + side * 0.12;
let at = |u: f64| add(along(js, je, u), scale(n, mid_n));
if count >= 2.0 {
leaf(o, -ov, wd / 2.0);
leaf(o, wd / 2.0, wd + ov);
arrow(o, at(wd * 0.4), at(wd * 0.1), n, hair);
arrow(o, at(wd * 0.6), at(wd * 0.9), n, hair);
} else {
leaf(o, -ov, wd + ov);
let (from, to) = if p.hinge_end { (wd * 0.25, wd * 0.75) } else { (wd * 0.75, wd * 0.25) };
arrow(o, at(from), at(to), n, hair);
}
}
/// Hebeschiebetür (SIA wie Schiebefenster): zwei Flügel auf versetzten Gleisen im Rahmen
/// (`lo..hi` quer zur Wand), das feste Feld an der Bandseite, das Schiebefeld mit Pfeil dorthin.
#[allow(clippy::too_many_arguments)]
fn lift_slide(o: &mut Out, js: V, je: V, n: V, lo: f64, hi: f64, hinge_end: bool, hair: f64) {
let wd = hypot2(je.x - js.x, je.y - js.y);
let span = hi - lo;
if span <= 1e-3 || wd <= 1e-3 {
return;
}
let ts = min(0.05, span / 2.5);
let gap = (span - 2.0 * ts) / 3.0;
let outer = (lo + gap, lo + gap + ts);
let inner = (hi - gap - ts, hi - gap);
let ov = 0.03;
let (fixed_u, slide_u) = if hinge_end { ((wd / 2.0 - ov, wd), (0.0, wd / 2.0 + ov)) } else { ((0.0, wd / 2.0 + ov), (wd / 2.0 - ov, wd)) };
for ((u0, u1), (n0, n1)) in [(fixed_u, outer), (slide_u, inner)] {
let a = along(js, je, u0);
let b = along(js, je, u1);
o.ring(C_LEAF, hair, 0.0, &[add(a, scale(n, n0)), add(b, scale(n, n0)), add(b, scale(n, n1)), add(a, scale(n, n1))]);
let g = (n0 + n1) / 2.0;
o.line(C_GLASS, hair, 0.0, 0.0, add(a, scale(n, g)), add(b, scale(n, g)));
}
// Pfeil auf der Innenseite des Schiebefelds, zur Bandseite (über das feste Feld).
let an = inner.1 + gap.max(0.04);
let (from, to) = if hinge_end { (wd * 0.15, wd * 0.6) } else { (wd * 0.85, wd * 0.4) };
arrow(o, add(along(js, je, from), scale(n, an)), add(along(js, je, to), scale(n, an)), n, hair);
}
fn finish(o: Out) -> Vec<f64> {
let mut out = Vec::with_capacity(o.buf.len() + 1);
out.push(o.n as f64);
@@ -274,15 +430,21 @@ fn finish(o: Out) -> Vec<f64> {
/// Rahmenband einer Tür (Zarge/Blockrahmen) aus dem Typ der Tür.
#[allow(clippy::too_many_arguments)]
fn frame_band(o: &mut Out, w: &WallRef, position: f64, width: f64, frame_width: f64, block: bool, inset_from_face: f64, inset_inner: bool, hair: f64) {
let Some((js, je)) = opening_jambs(w, position, width) else { return };
fn frame_band(o: &mut Out, w: &WallRef, position: f64, width: f64, frame_width: f64, block: bool, inset_from_face: f64, inset_side: f64, hair: f64) -> Option<(f64, f64)> {
let (js, je) = opening_jambs(w, position, width)?;
let inset_inner = inset_side == 1.0;
let mid = inset_side == 2.0;
let n = w.frame().1;
let total = w.total;
let outer_face = w.ref_off - total / 2.0;
let inner_face = w.ref_off + total / 2.0;
let clamped_inset = max(0.0, min(inset_from_face, total));
let near_is_aussen = !inset_inner;
let face_near = if near_is_aussen { outer_face + clamped_inset } else { inner_face - clamped_inset };
let mut face_near = if near_is_aussen { outer_face + clamped_inset } else { inner_face - clamped_inset };
if mid {
// Mittig: Blockrahmen symmetrisch um die Wandmitte (Anschlag-Zone aussen bis zum Rahmen).
face_near = w.ref_off - max(0.0, min(frame_width, total)) / 2.0;
}
let face_far = if near_is_aussen { inner_face } else { outer_face };
let lo = min(face_near, face_far);
let hi = max(face_near, face_far);
@@ -312,6 +474,25 @@ fn frame_band(o: &mut Out, w: &WallRef, position: f64, width: f64, frame_width:
for (a, b) in [(p1, p2), (p2, p3), (p3, p4), (p4, p1)] {
o.line(C_OPENING_FRAME, weight, 1.0, 0.0, a, b);
}
// Anschlag-Zone: zwischen der gewählten Fläche und der Rahmen-Vorderkante.
Some(if near_is_aussen { (outer_face, lo) } else { (hi, inner_face) })
}
/// Anschlag (Maueranschlag): Wand-Nasen an beiden Leibungen über die Zone `zone` (absolut quer zur
/// Wand), je `rebate` tief in die Öffnung. Keine bei fehlender Zone/Tiefe.
fn rebate_nibs(o: &mut Out, w: &WallRef, position: f64, width: f64, rebate: f64, zone: Option<(f64, f64)>) {
let (Some((lo, hi)), Some((js, je))) = (zone, opening_jambs(w, position, width)) else { return };
let axis_width = hypot2(je.x - js.x, je.y - js.y);
let rd = min(rebate, axis_width / 2.0 - 0.01);
if !(rd > 1e-4) || !(hi - lo > 1e-4) {
return;
}
let n = w.frame().1;
for (u0, u1) in [(0.0, rd), (axis_width - rd, axis_width)] {
let a = along(js, je, u0);
let b = along(js, je, u1);
o.polygon(2.0, 0.0, 1.0, &[add(a, scale(n, lo)), add(b, scale(n, lo)), add(b, scale(n, hi)), add(a, scale(n, hi))]);
}
}
// ── Fenster-Symbol als Einzelaufruf (für die Fassade `windowSymbol`, z. B. im Schnitt) ──────────
@@ -330,6 +511,8 @@ mod tests {
b.extend([0.0, 0.06, 0.0, 0.0, 0.0]); // kein Rahmenband
b.extend([has_type as u8 as f64, 0.06, NAN, NAN, 0.0, NAN, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]); // Fenster
b.extend([0.02, 0.02, 0.02, 0.02, 0.02]); // Strichstärken
b.extend([0.0, 0.0, 0.0, 0.0, 0.0]); // Details: kein Anschlag, Bank fehlt, Kasten vorgesetzt
b.push(0.0); // Türart Dreh
b.push(sashes.len() as f64);
for s in sashes {
b.extend(s);
@@ -388,4 +571,138 @@ mod tests {
let g = plan_opening(&input(false, 1.0, true, &sashes));
assert!(a[0] > g[0]);
}
/// Index des ersten Werts der Detail-Felder ([94]) in `input`.
const DETAILS: usize = 10 + 7 + 5 + 12 + 5;
fn polygons(buf: &[f64], art: f64) -> Vec<Vec<(f64, f64)>> {
let (mut i, mut out) = (1, Vec::new());
for _ in 0..buf[0] as usize {
if buf[i] == 1.0 {
let n = buf[i + 4] as usize;
if buf[i + 1] == art {
out.push((0..n).map(|k| (buf[i + 5 + 2 * k], buf[i + 6 + 2 * k])).collect());
}
i += 5 + 2 * n;
} else {
i += 9;
}
}
out
}
fn count_cls(buf: &[f64], cls: f64) -> usize {
let (mut i, mut c) = (1, 0);
for _ in 0..buf[0] as usize {
match buf[i] as i64 {
1 => i += 5 + 2 * buf[i + 4] as usize,
2 => {
if buf[i + 1] == cls {
c += 1;
}
i += 9
}
_ => i += 9,
}
}
c
}
#[test]
fn fenster_mitte_sitzt_symmetrisch_in_der_wand() {
let sashes = [[0.0, 1.0, NAN, NAN, 1.0]];
let mut b = input(false, 1.0, true, &sashes);
b[24] = 0.08; // Rahmentiefe
b[26] = 2.0; // einzugSeite mitte
let f = plan_opening(&b);
let frame = &polygons(&f, 1.0)[0];
let ys: Vec<f64> = frame.iter().map(|p| p.1).collect();
let (lo, hi) = (ys.iter().cloned().fold(f64::INFINITY, f64::min), ys.iter().cloned().fold(f64::NEG_INFINITY, f64::max));
assert!((lo + 0.04).abs() < 1e-9 && (hi - 0.04).abs() < 1e-9, "{lo} {hi}");
}
#[test]
fn anschlag_ergibt_zwei_wandnasen_vor_dem_rahmen() {
let sashes = [[0.0, 1.0, NAN, NAN, 1.0]];
let mut b = input(false, 1.0, true, &sashes);
assert!(polygons(&plan_opening(&b), 2.0).is_empty());
b[24] = 0.08;
b[25] = 0.12; // Einzug 12 cm von aussen
b[DETAILS] = 0.05;
let nibs = polygons(&plan_opening(&b), 2.0);
assert_eq!(nibs.len(), 2);
// Wand 0.3 dick um die Achse: Aussenfläche bei y = -0.15, Rahmen-Vorderkante bei -0.03.
let ys: Vec<f64> = nibs[0].iter().map(|p| p.1).collect();
assert!(ys.iter().any(|y| (y + 0.15).abs() < 1e-9) && ys.iter().any(|y| (y + 0.03).abs() < 1e-9), "{ys:?}");
let xs: Vec<f64> = nibs[0].iter().map(|p| p.0).collect();
assert!(xs.iter().all(|x| *x >= 1.0 - 1e-9 && *x <= 1.05 + 1e-9), "{xs:?}");
// Bündig (ohne Einzug): keine Anschlag-Zone.
b[25] = NAN;
assert!(polygons(&plan_opening(&b), 2.0).is_empty());
}
#[test]
fn fensterbank_folgt_der_wahl() {
let sashes = [[0.0, 1.0, NAN, NAN, 1.0]];
let mut b = input(false, 2.0, true, &sashes);
let base = count_cls(&plan_opening(&b), C_SILL);
assert_eq!(base, 4, "fehlt: Bank aussen wie bisher");
b[DETAILS + 1] = 1.0;
assert_eq!(count_cls(&plan_opening(&b), C_SILL), 0);
b[DETAILS + 1] = 3.0;
assert_eq!(count_cls(&plan_opening(&b), C_SILL), 8);
}
#[test]
fn storenkasten_im_sturz_mit_fuehrungsschienen() {
let sashes = [[0.0, 1.0, NAN, NAN, 1.0]];
let mut b = input(false, 2.0, true, &sashes);
b[31] = 1.0; // Kasten
b[33] = 0.25; // Höhe
let vorgesetzt = count_cls(&plan_opening(&b), C_SHADING);
assert_eq!(vorgesetzt, 4);
b[DETAILS + 2] = 1.0;
b[DETAILS + 3] = 0.18;
b[DETAILS + 4] = 1.0; // Raffstore
assert_eq!(count_cls(&plan_opening(&b), C_SHADING), 4 + 8);
}
#[test]
fn tuer_blockrahmen_mit_anschlag() {
let mut b = input(true, 1.0, false, &[]);
b[17] = 1.0; // Rahmen
b[18] = 0.06;
b[19] = 1.0; // Blockrahmen
b[20] = 0.1; // Einzug aussen
b[DETAILS] = 0.04;
assert_eq!(polygons(&plan_opening(&b), 2.0).len(), 2);
}
/// [95] Türarten im Grundriss: Schiebetür (Blatt-Rechteck + Pfeil, kein Bogen), Hebeschiebe
/// (zwei Flügel auf versetzten Gleisen + Glaslinien + Pfeil), Pendel (Bögen beidseitig).
#[test]
fn tuerarten_nach_sia() {
const KIND: usize = DETAILS + 5;
let mut b = input(true, 1.0, false, &[]);
let arcs = |f: &[f64]| tags(f).iter().filter(|t| **t == 3.0).count();
assert_eq!(arcs(&plan_opening(&b)), 1);
b[KIND] = 1.0;
let f = plan_opening(&b);
assert_eq!(arcs(&f), 0);
assert_eq!(count_cls(&f, C_LEAF), 4 + 3);
b[15] = 2.0; // zwei Blätter
assert_eq!(count_cls(&plan_opening(&b), C_LEAF), 8 + 6);
b[15] = 1.0;
b[KIND] = 2.0;
let f = plan_opening(&b);
assert_eq!(count_cls(&f, C_LEAF), 8 + 3);
assert_eq!(count_cls(&f, C_GLASS), 2);
b[KIND] = 3.0;
assert_eq!(arcs(&plan_opening(&b)), 2);
// Grob: keine Bögen, aber beide Blätter.
b[9] = 0.0;
let f = plan_opening(&b);
assert_eq!(arcs(&f), 0);
assert_eq!(count_cls(&f, C_LEAF), 2);
}
}
+1
View File
@@ -44,6 +44,7 @@ mod cmd_create;
mod area_report;
mod rich_text;
mod geo_mesh;
mod opening_presets;
use wasm_bindgen::prelude::wasm_bindgen;
@@ -0,0 +1,9 @@
//! Bindung der Fenster-/Türtyp-Vorlagen (`crate::opening_presets`, [95]).
use wasm_bindgen::prelude::wasm_bindgen;
/// Vorlagen als JSON `{ windowTypes, doorTypes }`.
#[wasm_bindgen]
pub fn opening_type_presets_json() -> String {
crate::opening_presets::presets_json()
}
+2
View File
@@ -463,6 +463,7 @@ impl<'a> Reader<'a> {
0 => DoorKind::Swing,
1 => DoorKind::Sliding,
2 => DoorKind::WallOpening,
3 => DoorKind::DoubleSwing,
k => return Err(format!("unbekannte Türart {k} bei {}", self.pos - 1)),
};
let leaf_count = self.f()?;
@@ -2258,6 +2259,7 @@ mod tests {
DoorKind::Swing => 0.0,
DoorKind::Sliding => 1.0,
DoorKind::WallOpening => 2.0,
DoorKind::DoubleSwing => 3.0,
};
self.n(&[k, p.leaf_count, p.swing_sign, p.dir_sign, if p.hinge_at_start { 1.0 } else { 0.0 }, p.transom_height]);
self.n(&[if p.glazed { 1.0 } else { 0.0 }]);
+11
View File
@@ -122,6 +122,8 @@ pub enum DoorKind {
Swing,
Sliding,
WallOpening,
/// Pendeltür (schlägt nach beiden Seiten auf).
DoubleSwing,
}
/// Parameter einer Füllung aus dem Modell (TS `fillParams`); fehlende Typwerte als `None`.
@@ -387,6 +389,14 @@ pub fn fill_geometry(p: &FillParams) -> FillGeometry {
} else {
"SLIDING_TO_RIGHT"
}
} else if p.door_kind == DoorKind::DoubleSwing {
if p.leaf_count >= 2.0 {
"DOUBLE_DOOR_DOUBLE_SWING"
} else if left {
"DOUBLE_SWING_LEFT"
} else {
"DOUBLE_SWING_RIGHT"
}
} else if p.leaf_count >= 2.0 {
"DOUBLE_DOOR_SINGLE_SWING"
} else if left {
@@ -556,6 +566,7 @@ mod tests {
assert_eq!(kind(FillParams { swing_sign: -1.0, ..door() }), Some("SINGLE_SWING_LEFT"));
assert_eq!(kind(FillParams { door_kind: DoorKind::Sliding, ..door() }), Some("SLIDING_TO_RIGHT"));
assert_eq!(kind(FillParams { door_kind: DoorKind::Sliding, leaf_count: 2.0, ..door() }), Some("DOUBLE_DOOR_SLIDING"));
assert_eq!(kind(FillParams { door_kind: DoorKind::DoubleSwing, leaf_count: 2.0, ..door() }), Some("DOUBLE_DOOR_DOUBLE_SWING"));
let g = fill_geometry(&door());
assert_eq!(g.origin, (1.5, 0.0));
assert!(close(g.u.0, 1.0) && close(g.u.1, 0.0));
+29
View File
@@ -575,10 +575,15 @@ export const de = {
"oed.f.frameDepth": "Rahmentiefe (m)",
"oed.f.frameWidth": "Rahmenbreite Ansicht (m)",
"oed.f.cornerJoin": "Rahmen-Ecken",
"oed.f.rebateDepth": "Anschlag (m)",
"oed.f.lintelHeight": "Sturzhöhe (m)",
"oed.f.sillBoard": "Fensterbank",
"oed.cornerJoin.vertikal": "Pfosten durchlaufend",
"oed.cornerJoin.horizontal": "Riegel durchlaufend",
"oed.cornerJoin.gehrung": "Gehrung",
"oed.f.transomHeight": "Oberlichthöhe (m)",
"oed.f.transomFields": "Oberlicht-Felder",
"oed.f.transomOpening": "Oberlicht-Öffnung",
"oed.f.mullionRows": "Kämpfer-/Sprossenzeilen",
"oed.f.mullionCols": "Sprossen-Spalten",
"oed.f.sillLineFaces": "Auf-/Untersicht-Linie",
@@ -597,6 +602,7 @@ export const de = {
"oed.glazing.3": "Dreifach",
"oed.insetFace.aussen": "Aussenfläche",
"oed.insetFace.innen": "Innenfläche",
"oed.insetFace.mitte": "Mitte (Leibung beidseitig)",
"oed.fluegel.hint": "Flügel und Pfosten von links nach rechts. Öffnungsart und Anschlag je Flügel.",
"oed.fluegel.col.kind": "Typ",
"oed.fluegel.col.opening": "Öffnung",
@@ -612,6 +618,9 @@ export const de = {
"oed.shading.raffstore": "Raffstore",
"oed.shading.markise": "Markise",
"oed.shading.boxHeight": "Kastenhöhe (m)",
"oed.shading.mount": "Kasten",
"oed.shading.vorgesetzt": "Vorgesetzt",
"oed.shading.sturz": "Im Sturz (Storenkasten)",
"oed.shading.boxDepth": "Kastentiefe (m)",
"oed.door.leafCount": "Türblätter",
"oed.door.leaf1": "Einflüglig",
@@ -621,6 +630,8 @@ export const de = {
"oed.door.kassette": "Kassette",
"oed.door.glas": "Glas",
"oed.door.wandoeffnung": "Wandöffnung",
"oed.door.hebeschiebe": "Hebeschiebetür",
"oed.door.pendel": "Pendeltür",
"objinfo.stair.type": "Typ",
"objinfo.type.none": "(kein Typ)",
"objinfo.opening.kind": "Art",
@@ -1005,6 +1016,21 @@ export const de = {
"Wiederverwendbare Fenstertypen mit Öffnungsart, Verglasung und Standardmaßen für neu platzierte Fenster.",
"resources.windowTypes.empty": "Noch keine Fenstertypen.",
"resources.windowTypes.placeholder": "Fenstertyp",
"resources.addPreset": "Aus Bibliothek…",
"resources.addPreset.hint": "Übliche Bauart als Vorlage übernehmen",
"preset.fe-dk-1": "Dreh-Kipp 1-flügelig",
"preset.fe-dk-2": "Dreh-Kipp 2-flügelig (Stulp)",
"preset.fe-fest": "Festverglasung",
"preset.fe-oberlicht": "Dreh-Kipp mit Kipp-Oberlicht",
"preset.fe-pfosten-riegel": "Pfosten-Riegel 3-teilig",
"preset.fe-schiebe": "Schiebefenster 2-teilig",
"preset.tu-zimmer": "Zimmertür (Zarge)",
"preset.tu-zimmer-2": "Zimmertür 2-flügelig",
"preset.tu-schiebe": "Schiebetür vor der Wand",
"preset.tu-hebeschiebe": "Hebeschiebetür",
"preset.tu-pendel": "Pendeltür",
"preset.tu-haus": "Haustür mit Oberlicht",
"preset.tu-wand": "Wandöffnung",
"resources.stairTypes.hint":
"Wiederverwendbare Treppentypen mit Tragart, Stufenausbildung und Geländer für neu platzierte Treppen.",
"resources.stairTypes.empty": "Noch keine Treppentypen.",
@@ -1036,6 +1062,7 @@ export const de = {
"resources.frameKind.blockrahmen": "Blockrahmen",
"resources.insetFace.aussen": "Aussen",
"resources.insetFace.innen": "Innen",
"resources.insetFace.mitte": "Mitte",
"resources.field.windowKind": "Öffnungsart",
"resources.field.wingCount": "Flügelzahl",
"resources.field.glazing": "Verglasung",
@@ -1050,6 +1077,8 @@ export const de = {
"resources.doorKind.dreh": "Drehflügel",
"resources.doorKind.schiebe": "Schiebe",
"resources.doorKind.hebeschiebe": "Hebeschiebe",
"resources.doorKind.pendel": "Pendel",
"resources.doorKind.wandoeffnung": "Wandöffnung",
"resources.leafCount.1": "1-flügelig",
"resources.leafCount.2": "2-flügelig",
+29
View File
@@ -574,10 +574,15 @@ export const en: Record<TranslationKey, string> = {
"oed.f.frameDepth": "Frame depth (m)",
"oed.f.frameWidth": "Frame face width (m)",
"oed.f.cornerJoin": "Frame corners",
"oed.f.rebateDepth": "Rebate / stop (m)",
"oed.f.lintelHeight": "Lintel height (m)",
"oed.f.sillBoard": "Window sill",
"oed.cornerJoin.vertikal": "Stiles through",
"oed.cornerJoin.horizontal": "Rails through",
"oed.cornerJoin.gehrung": "Mitre",
"oed.f.transomHeight": "Transom height (m)",
"oed.f.transomFields": "Transom fields",
"oed.f.transomOpening": "Transom opening",
"oed.f.mullionRows": "Transom/muntin rows",
"oed.f.mullionCols": "Muntin columns",
"oed.f.sillLineFaces": "Top-/bottom-view line",
@@ -596,6 +601,7 @@ export const en: Record<TranslationKey, string> = {
"oed.glazing.3": "Triple",
"oed.insetFace.aussen": "Outer face",
"oed.insetFace.innen": "Inner face",
"oed.insetFace.mitte": "Centre (reveal on both sides)",
"oed.fluegel.hint": "Sashes and posts from left to right. Opening type and hinge per sash.",
"oed.fluegel.col.kind": "Type",
"oed.fluegel.col.opening": "Opening",
@@ -611,6 +617,9 @@ export const en: Record<TranslationKey, string> = {
"oed.shading.raffstore": "Venetian blind",
"oed.shading.markise": "Awning",
"oed.shading.boxHeight": "Box height (m)",
"oed.shading.mount": "Box",
"oed.shading.vorgesetzt": "Surface-mounted",
"oed.shading.sturz": "In lintel (concealed blind box)",
"oed.shading.boxDepth": "Box depth (m)",
"oed.door.leafCount": "Door leaves",
"oed.door.leaf1": "Single leaf",
@@ -620,6 +629,8 @@ export const en: Record<TranslationKey, string> = {
"oed.door.kassette": "Panelled",
"oed.door.glas": "Glass",
"oed.door.wandoeffnung": "Wall opening",
"oed.door.hebeschiebe": "Lift-and-slide door",
"oed.door.pendel": "Swing door (double-acting)",
"objinfo.stair.type": "Type",
"objinfo.type.none": "(no type)",
"objinfo.opening.kind": "Type",
@@ -999,6 +1010,21 @@ export const en: Record<TranslationKey, string> = {
"Reusable window types with opening style, glazing and default dimensions for newly placed windows.",
"resources.windowTypes.empty": "No window types yet.",
"resources.windowTypes.placeholder": "Window type",
"resources.addPreset": "From library…",
"resources.addPreset.hint": "Add a common construction as a template",
"preset.fe-dk-1": "Tilt-and-turn, single sash",
"preset.fe-dk-2": "Tilt-and-turn, double sash",
"preset.fe-fest": "Fixed glazing",
"preset.fe-oberlicht": "Tilt-and-turn with tilting transom",
"preset.fe-pfosten-riegel": "Mullion-transom, 3 bays",
"preset.fe-schiebe": "Sliding window, 2 parts",
"preset.tu-zimmer": "Interior door (frame)",
"preset.tu-zimmer-2": "Interior door, double leaf",
"preset.tu-schiebe": "Surface sliding door",
"preset.tu-hebeschiebe": "Lift-and-slide door",
"preset.tu-pendel": "Double-acting swing door",
"preset.tu-haus": "Entrance door with transom",
"preset.tu-wand": "Wall opening",
"resources.stairTypes.hint":
"Reusable stair types with structure, tread style and railing for newly placed stairs.",
"resources.stairTypes.empty": "No stair types yet.",
@@ -1030,6 +1056,7 @@ export const en: Record<TranslationKey, string> = {
"resources.frameKind.blockrahmen": "Block frame",
"resources.insetFace.aussen": "Outer",
"resources.insetFace.innen": "Inner",
"resources.insetFace.mitte": "Centre",
"resources.field.windowKind": "Opening style",
"resources.field.wingCount": "Wing count",
"resources.field.glazing": "Glazing",
@@ -1044,6 +1071,8 @@ export const en: Record<TranslationKey, string> = {
"resources.doorKind.dreh": "Hinged",
"resources.doorKind.schiebe": "Sliding",
"resources.doorKind.hebeschiebe": "Lift-and-slide",
"resources.doorKind.pendel": "Double-acting",
"resources.doorKind.wandoeffnung": "Wall opening",
"resources.leafCount.1": "Single-leaf",
"resources.leafCount.2": "Double-leaf",
+26
View File
@@ -0,0 +1,26 @@
import { describe, expect, it } from "vitest";
import { instantiatePreset, openingTypePresets } from "./openingPresets";
import { de } from "../i18n/de";
import { en } from "../i18n/en";
describe("openingTypePresets ([95])", () => {
it("liefert Fenster- und Türvorlagen mit übersetzten Namen", () => {
const { windowTypes, doorTypes } = openingTypePresets();
expect(windowTypes.length).toBeGreaterThanOrEqual(5);
expect(doorTypes.map((d) => d.kind)).toEqual(expect.arrayContaining(["schiebe", "hebeschiebe", "pendel"]));
for (const t of [...windowTypes, ...doorTypes]) {
expect((de as Record<string, string>)[`preset.${t.id}`]).toBeTruthy();
expect((en as Record<string, string>)[`preset.${t.id}`]).toBeTruthy();
}
expect(windowTypes.some((w) => (w.transomSashes ?? []).length > 1)).toBe(true);
});
it("instantiatePreset kopiert tief und setzt id/Name", () => {
const w = openingTypePresets().windowTypes.find((t) => t.sashes)!;
const c = instantiatePreset(w, "ft-neu", "Neu");
expect(c.id).toBe("ft-neu");
expect(c.name).toBe("Neu");
c.sashes![0].opening = "fest";
expect(w.sashes![0].opening).not.toBe("fest");
});
});
+31
View File
@@ -0,0 +1,31 @@
// Fenster-/Türtyp-Bibliothek ([95]) — dünne Fassade über die Vorlagen des Rust-Kerns
// (`src-tauri/core/src/opening_presets.rs`). Die Vorlagen kommen ohne Projekt-ids; wer eine
// übernimmt, vergibt eine neue id (`instantiatePreset`).
import { core } from "../engine/coreWasm";
import type { DoorType, WindowType } from "./types";
export interface OpeningTypePresets {
windowTypes: WindowType[];
doorTypes: DoorType[];
}
let cache: OpeningTypePresets | null = null;
/** Alle Vorlagen (einmal aus dem Kern gelesen). `id` ist die stabile Vorlagen-id (i18n `preset.<id>`). */
export function openingTypePresets(): OpeningTypePresets {
if (!cache) {
try {
const parsed = JSON.parse(core().opening_type_presets_json()) as Partial<OpeningTypePresets>;
cache = { windowTypes: parsed.windowTypes ?? [], doorTypes: parsed.doorTypes ?? [] };
} catch {
cache = { windowTypes: [], doorTypes: [] };
}
}
return cache;
}
/** Kopie einer Vorlage mit neuer id und Namen (tiefe Kopie, damit Flügellisten nicht geteilt werden). */
export function instantiatePreset<T extends { id: string; name: string }>(preset: T, id: string, name: string): T {
return { ...(JSON.parse(JSON.stringify(preset)) as T), id, name };
}
+38 -3
View File
@@ -504,7 +504,7 @@ export type DoorType = {
* Bauart: normaler Drehflügel, reine Wandöffnung (kein Blatt/Schwenk),
* Schiebetür. Ersetzt/ergänzt das Inline-Feld `Opening.doorType`.
*/
kind: "dreh" | "schiebe" | "wandoeffnung";
kind: "dreh" | "schiebe" | "wandoeffnung" | "hebeschiebe" | "pendel";
/** Anzahl Türblätter (1 = einflügelig, 2 = zweiflügelig). */
leafCount: 1 | 2;
/** Blatt-Ausführung (3D/Detail): glatt, Kassette, Glasfüllung. */
@@ -550,7 +550,7 @@ export type DoorType = {
*/
insetFromFace?: number;
/** Von welcher Wandfläche der {@link insetFromFace} gemessen wird; Default "aussen". */
insetFace?: "aussen" | "innen";
insetFace?: "aussen" | "innen" | "mitte";
/**
* Oberlicht: Höhe eines festen, verglasten Oberlichts über dem Türblatt
* (Meter). 0/fehlt ⇒ kein Oberlicht. Das Oberlicht sitzt oberhalb eines
@@ -563,6 +563,17 @@ export type DoorType = {
defaultHeight: number;
/** Bodenschwelle/Anschlag zeichnen (3D/Detail). */
threshold?: boolean;
/**
* Anschlag (Maueranschlag): so weit (Meter, je Seite und oben) springt die Wand zwischen
* der Fläche aus {@link insetFace} und der Rahmen-Vorderkante in die Öffnung vor. Wirkt nur
* mit Leibung (`insetFromFace` > 0 bzw. `insetFace: "mitte"`). 0/fehlt ⇒ stumpf (bisher).
*/
rebateDepth?: number;
/**
* Sturz: Höhe des Sturzes über der Öffnung (Meter), im Schnitt als eigener Querschnitt
* gezeichnet. 0/fehlt ⇒ kein eigener Sturz (bisher).
*/
lintelHeight?: number;
};
/** Ein freies 2D-Zeichenelement auf einer Zeichnungsebene. */
@@ -2780,8 +2791,16 @@ export type WindowShading = {
kind: "rollladen" | "raffstore" | "markise";
/** Kastenmasse (Meter): Breite (quer, meist = Öffnung), Höhe, Tiefe. */
box: { width: number; height: number; depth: number };
/**
* Einbau des Kastens: "vorgesetzt" (vor der Rahmenebene, bisher) oder "sturz" (Storenkasten
* im Sturz, in der Wand verdeckt — in der Schweiz üblich bei Lamellenstoren). Fehlt ⇒ vorgesetzt.
*/
mount?: WindowShadingMount;
};
/** Einbau des Sonnenschutzkastens ({@link WindowShading.mount}). */
export type WindowShadingMount = "vorgesetzt" | "sturz";
export type WindowType = {
id: string;
name: string;
@@ -2841,7 +2860,7 @@ export type WindowType = {
*/
insetFromFace?: number;
/** Von welcher Wandfläche der {@link insetFromFace} gemessen wird; Default "aussen". */
insetFace?: "aussen" | "innen";
insetFace?: "aussen" | "innen" | "mitte";
/**
* Schicht-Rücksprung an der Laibung: weicht die INNERSTE Wandschicht (meist
* Gipsplatte/Holzverkleidung) an diesem Fenster um ihre eigene Dicke von der
@@ -2855,6 +2874,11 @@ export type WindowType = {
* (Meter), abgeteilt durch einen Kämpfer. 0/fehlt ⇒ kein Oberlicht.
*/
transomHeight?: number;
/**
* Einteilung des Oberlichts über dem Riegel (Pfosten/Riegel, [95]): Felder und Pfosten wie
* {@link sashes}, je Feld fest oder öffenbar (meist Kipp). Fehlt ⇒ ein festes Feld (bisher).
*/
transomSashes?: Array<SashDef>;
/**
* Auf-/Untersicht-Andeutung im Grundriss (mittel/fein): eine Referenzlinie an
* der gewählten Fläche(n) — sinnvoll, wenn die Öffnung die Schnittebene NICHT
@@ -2872,4 +2896,15 @@ export type WindowType = {
defaultHeight: number;
/** Fensterbank zeichnen (Detail): keine / innen / aussen / beide. */
sillBoard?: "keine" | "innen" | "aussen" | "beide";
/**
* Anschlag (Maueranschlag): so weit (Meter, je Seite und oben) springt die Wand zwischen
* der Fläche aus {@link insetFace} und der Rahmen-Vorderkante in die Öffnung vor. Wirkt nur
* mit Leibung (`insetFromFace` > 0 bzw. `insetFace: "mitte"`). 0/fehlt ⇒ stumpf (bisher).
*/
rebateDepth?: number;
/**
* Sturz: Höhe des Sturzes über der Öffnung (Meter), im Schnitt als eigener Querschnitt
* gezeichnet. 0/fehlt ⇒ kein eigener Sturz (bisher).
*/
lintelHeight?: number;
};
+3 -2
View File
@@ -287,8 +287,9 @@ describe("generatePlan — Fensterbank (window-sill) folgt der eingezogenen Rahm
// die volle Wandfläche (−0.15 — der alte, fehlerhafte Wert vor dem Fix).
expect(Math.max(...ys)).toBeCloseTo(-0.1, 6);
expect(Math.max(...ys)).not.toBeCloseTo(-0.15, 2);
// Auskragung geht weiter nach aussen (algebraisch kleiner): −0.10 − 0.04.
expect(Math.min(...ys)).toBeCloseTo(-0.14, 6);
// Auskragung über die ganze Leibung bis 4 cm vor die Fassade ([94]): −0.15 − 0.04
// (früher endete die Bank bei −0.14, also in der Leibung).
expect(Math.min(...ys)).toBeCloseTo(-0.19, 6);
});
});
+6 -2
View File
@@ -13,6 +13,7 @@ import { addItems, fieldOps, patchItem, removeItems } from "../core";
import type { CoreOp } from "../core";
import { t } from "../i18n";
import { uniqueId } from "../tools/types";
import { instantiatePreset } from "../model/openingPresets";
import type {
CeilingType,
ContextObject,
@@ -208,8 +209,10 @@ export function useProjectActions(
// (kein eigener Slice). Löschen ist geschützt, solange ein Element den Typ
// per `typeId` referenziert. Defaults orientieren sich an den Element-Inline-
// Werten (Tür 0.9×2.0, Fenster 1.2×1.4 Brüstung 0.9).
const addDoorType = () =>
const addDoorType = (preset?: DoorType) =>
applyChange(() => {
// Aus der Typen-Bibliothek ([95]): Kopie der Vorlage mit neuer id.
if (preset) return addItems("doorTypes", [instantiatePreset(preset, uniqueId("dt"), preset.name)]);
const dt: DoorType = {
id: uniqueId("dt"),
name: t("default.doorTypeName"),
@@ -234,8 +237,9 @@ export function useProjectActions(
}
return removeItems(p, "doorTypes", [id]);
});
const addWindowType = () =>
const addWindowType = (preset?: WindowType) =>
applyChange(() => {
if (preset) return addItems("windowTypes", [instantiatePreset(preset, uniqueId("ft"), preset.name)]);
const wt: WindowType = {
id: uniqueId("ft"),
name: t("default.windowTypeName"),
+101
View File
@@ -291,6 +291,8 @@ const DOOR_KIND_OPTS = (): { value: DoorKind; label: string }[] => [
{ value: "dreh", label: t("oed.kind.dreh") },
{ value: "schiebe", label: t("oed.kind.schiebe") },
{ value: "wandoeffnung", label: t("oed.door.wandoeffnung") },
{ value: "hebeschiebe", label: t("oed.door.hebeschiebe") },
{ value: "pendel", label: t("oed.door.pendel") },
];
function BasisPanel({
@@ -341,6 +343,7 @@ function BasisPanel({
options={[
{ value: "aussen", label: t("oed.insetFace.aussen") },
{ value: "innen", label: t("oed.insetFace.innen") },
{ value: "mitte", label: t("oed.insetFace.mitte") },
]}
onChange={(v) => patchWt({ insetFace: v })}
/>
@@ -460,6 +463,34 @@ function RahmenPanel({
options={cornerJoinOptions()}
onChange={(v) => patchDt({ frameCornerJoin: v })}
/>
<SelField
label={t("oed.f.insetFace")}
value={dt.insetFace ?? "aussen"}
options={[
{ value: "aussen", label: t("oed.insetFace.aussen") },
{ value: "innen", label: t("oed.insetFace.innen") },
{ value: "mitte", label: t("oed.insetFace.mitte") },
]}
onChange={(v) => patchDt({ insetFace: v })}
/>
<NumField
label={t("oed.f.insetFromFace")}
value={dt.insetFromFace ?? 0}
min={0}
onCommit={(n) => patchDt({ insetFromFace: n })}
/>
<NumField
label={t("oed.f.rebateDepth")}
value={dt.rebateDepth ?? 0}
min={0}
onCommit={(n) => patchDt({ rebateDepth: n || undefined })}
/>
<NumField
label={t("oed.f.lintelHeight")}
value={dt.lintelHeight ?? 0}
min={0}
onCommit={(n) => patchDt({ lintelHeight: n || undefined })}
/>
</>
);
}
@@ -490,6 +521,29 @@ function RahmenPanel({
options={cornerJoinOptions()}
onChange={(v) => patchWt({ frameCornerJoin: v })}
/>
<NumField
label={t("oed.f.rebateDepth")}
value={wt.rebateDepth ?? 0}
min={0}
onCommit={(n) => patchWt({ rebateDepth: n || undefined })}
/>
<NumField
label={t("oed.f.lintelHeight")}
value={wt.lintelHeight ?? 0}
min={0}
onCommit={(n) => patchWt({ lintelHeight: n || undefined })}
/>
<SelField
label={t("oed.f.sillBoard")}
value={wt.sillBoard ?? "aussen"}
options={[
{ value: "keine", label: t("resources.sillBoard.keine") },
{ value: "aussen", label: t("resources.sillBoard.aussen") },
{ value: "innen", label: t("resources.sillBoard.innen") },
{ value: "beide", label: t("resources.sillBoard.beide") },
]}
onChange={(v) => patchWt({ sillBoard: v })}
/>
</>
);
}
@@ -505,6 +559,23 @@ function cornerJoinOptions(): { value: FrameCornerJoin; label: string }[] {
];
}
/** Oberlicht-Einteilung ([95]): Anzahl Felder und Öffnungsart des ersten Felds. */
function transomFields(wt: WindowType): { count: number; opening: OpeningKind } {
const fields = (wt.transomSashes ?? []).filter((s) => s.kind === "fluegel");
return { count: Math.max(1, fields.length), opening: fields[0]?.opening ?? "fest" };
}
/** Gleichmässige Oberlicht-Einteilung: `count` Felder, dazwischen Pfosten; ein festes Feld = keine Liste. */
function transomSashes(count: number, opening: OpeningKind): SashDef[] | undefined {
if (count <= 1 && opening === "fest") return undefined;
const out: SashDef[] = [];
for (let i = 0; i < count; i++) {
if (i > 0) out.push({ kind: "pfosten", postWidth: 0.06 });
out.push({ kind: "fluegel", autoWidth: true, opening, hingeSide: i % 2 === 0 ? "left" : "right" });
}
return out;
}
/** Flügeleinteilung: Tabelle mit Flügel/Pfosten, Öffnungsart + Anschlag je Zeile. */
function FluegelPanel({
wt,
@@ -537,6 +608,27 @@ function FluegelPanel({
min={0}
onCommit={(n) => patchWt({ transomHeight: n || undefined })}
/>
{(wt.transomHeight ?? 0) > 0 && (
<>
<NumField
label={t("oed.f.transomFields")}
value={transomFields(wt).count}
step={1}
min={1}
onCommit={(n) => patchWt({ transomSashes: transomSashes(Math.max(1, Math.min(6, Math.round(n))), transomFields(wt).opening) })}
/>
<SelField<OpeningKind>
label={t("oed.f.transomOpening")}
value={transomFields(wt).opening}
options={[
{ value: "fest", label: t("oed.kind.fest") },
{ value: "kipp", label: t("oed.kind.kipp") },
{ value: "dreh", label: t("oed.kind.dreh") },
]}
onChange={(v) => patchWt({ transomSashes: transomSashes(transomFields(wt).count, v) })}
/>
</>
)}
<NumField
label={t("oed.f.mullionRows")}
value={wt.mullionRows ?? 1}
@@ -681,6 +773,15 @@ function SonnenschutzPanel({
set({ kind: v as NonNullable<WindowType["shading"]>["kind"] })
}
/>
<SelField
label={t("oed.shading.mount")}
value={sh.mount ?? "vorgesetzt"}
options={[
{ value: "vorgesetzt", label: t("oed.shading.vorgesetzt") },
{ value: "sturz", label: t("oed.shading.sturz") },
]}
onChange={(v) => set({ mount: v })}
/>
<NumField
label={t("oed.shading.boxHeight")}
value={box.height}
+2 -2
View File
@@ -126,10 +126,10 @@ export interface ResourceManagerHandlers {
* Deckentypen. Optional, damit ältere Einbettungen ohne diesen Handler
* weiter kompilieren; ohne Handler bleiben die Tabs verborgen.
*/
onAddDoorType?: () => void;
onAddDoorType?: (preset?: DoorType) => void;
onPatchDoorType?: (id: string, patch: Partial<DoorType>) => void;
onDeleteDoorType?: (id: string) => void;
onAddWindowType?: () => void;
onAddWindowType?: (preset?: WindowType) => void;
onPatchWindowType?: (id: string, patch: Partial<WindowType>) => void;
onDeleteWindowType?: (id: string) => void;
onAddStairType?: () => void;
+10 -2
View File
@@ -6,6 +6,7 @@ import { t } from "../../i18n";
import { FieldRow, NumberField, Segmented, SelectField } from "./fields";
import { INSET_FACE_OPTIONS, TypeLibraryTab } from "./TypeLibraryTab";
import { ElevationPreview } from "../ElevationPreview";
import { openingTypePresets } from "../../model/openingPresets";
/**
* Synthetische Öffnungs-Instanz NUR für die Vorschau — s. WindowStylesTab.
@@ -30,6 +31,8 @@ const DOOR_KIND_OPTIONS: { value: DoorType["kind"]; labelKey: string }[] = [
{ value: "dreh", labelKey: "resources.doorKind.dreh" },
{ value: "schiebe", labelKey: "resources.doorKind.schiebe" },
{ value: "wandoeffnung", labelKey: "resources.doorKind.wandoeffnung" },
{ value: "hebeschiebe", labelKey: "resources.doorKind.hebeschiebe" },
{ value: "pendel", labelKey: "resources.doorKind.pendel" },
];
const DOOR_LEAF_STYLE_OPTIONS: { value: DoorType["leafStyle"]; labelKey: string }[] = [
@@ -50,7 +53,7 @@ export function DoorStylesTab({
onDeleteDoorType,
}: {
project: Project;
onAddDoorType?: () => void;
onAddDoorType?: (preset?: DoorType) => void;
onPatchDoorType?: (id: string, patch: Partial<DoorType>) => void;
onDeleteDoorType?: (id: string) => void;
}) {
@@ -61,7 +64,12 @@ export function DoorStylesTab({
emptyKey="resources.doorTypes.empty"
placeholderKey="resources.doorTypes.placeholder"
deleteKeyPrefix="resources.delete.doorType"
onAdd={onAddDoorType}
onAdd={() => onAddDoorType?.()}
presets={openingTypePresets().doorTypes.map((p) => ({ id: p.id, label: t(`preset.${p.id}`) }))}
onAddPreset={(id) => {
const p = openingTypePresets().doorTypes.find((x) => x.id === id);
if (p) onAddDoorType?.({ ...p, name: t(`preset.${p.id}`) });
}}
onPatch={onPatchDoorType}
onDelete={onDeleteDoorType}
renderFields={(door, patch) => (
+22 -1
View File
@@ -13,9 +13,10 @@ import { DeleteButton } from "./fields";
// Bezugsfläche des Schichteinzugs — von aussen oder innen gemessen. Für Tür UND
// Fenster genutzt (gleiche Semantik).
export const INSET_FACE_OPTIONS: { value: "aussen" | "innen"; labelKey: string }[] = [
export const INSET_FACE_OPTIONS: { value: "aussen" | "innen" | "mitte"; labelKey: string }[] = [
{ value: "aussen", labelKey: "resources.insetFace.aussen" },
{ value: "innen", labelKey: "resources.insetFace.innen" },
{ value: "mitte", labelKey: "resources.insetFace.mitte" },
];
export function TypeLibraryTab<T extends { id: string; name: string }>({
@@ -25,6 +26,8 @@ export function TypeLibraryTab<T extends { id: string; name: string }>({
placeholderKey,
deleteKeyPrefix,
onAdd,
presets,
onAddPreset,
onPatch,
onDelete,
renderFields,
@@ -35,6 +38,9 @@ export function TypeLibraryTab<T extends { id: string; name: string }>({
placeholderKey: string;
deleteKeyPrefix: string;
onAdd?: () => void;
/** Vorlagen aus der Typen-Bibliothek ([95]); Auswahl legt eine Kopie an. */
presets?: { id: string; label: string }[];
onAddPreset?: (presetId: string) => void;
onPatch?: (id: string, patch: Partial<T>) => void;
onDelete?: (id: string) => void;
renderFields: (item: T, onPatch: (patch: Partial<T>) => void) => React.ReactNode;
@@ -63,6 +69,21 @@ export function TypeLibraryTab<T extends { id: string; name: string }>({
<button className="res-add" onClick={() => onAdd?.()}>
<span className="res-add-plus">+</span> {t("resources.add")}
</button>
{presets && presets.length > 0 && onAddPreset && (
<select
className="res-input res-add-preset"
value=""
title={t("resources.addPreset.hint")}
onChange={(e) => e.target.value && onAddPreset(e.target.value)}
>
<option value="">{t("resources.addPreset")}</option>
{presets.map((p) => (
<option key={p.id} value={p.id}>
{p.label}
</option>
))}
</select>
)}
</div>
</div>
<div className="res-md-detail">
+8 -2
View File
@@ -6,6 +6,7 @@ import { t } from "../../i18n";
import { FieldRow, NumberField, SelectField } from "./fields";
import { INSET_FACE_OPTIONS, TypeLibraryTab } from "./TypeLibraryTab";
import { ElevationPreview } from "../ElevationPreview";
import { openingTypePresets } from "../../model/openingPresets";
/**
* Synthetische Öffnungs-Instanz NUR für die Vorschau: `ElevationPreview`
@@ -56,7 +57,7 @@ export function WindowStylesTab({
onDeleteWindowType,
}: {
project: Project;
onAddWindowType?: () => void;
onAddWindowType?: (preset?: WindowType) => void;
onPatchWindowType?: (id: string, patch: Partial<WindowType>) => void;
onDeleteWindowType?: (id: string) => void;
}) {
@@ -67,7 +68,12 @@ export function WindowStylesTab({
emptyKey="resources.windowTypes.empty"
placeholderKey="resources.windowTypes.placeholder"
deleteKeyPrefix="resources.delete.windowType"
onAdd={onAddWindowType}
onAdd={() => onAddWindowType?.()}
presets={openingTypePresets().windowTypes.map((p) => ({ id: p.id, label: t(`preset.${p.id}`) }))}
onAddPreset={(id) => {
const p = openingTypePresets().windowTypes.find((x) => x.id === id);
if (p) onAddWindowType?.({ ...p, name: t(`preset.${p.id}`) });
}}
onPatch={onPatchWindowType}
onDelete={onDeleteWindowType}
renderFields={(win, patch) => (