diff --git a/TODO.md b/TODO.md index f6f79240..d5f8c3ac 100644 --- a/TODO.md +++ b/TODO.md @@ -63,8 +63,15 @@ Kennwort, anonym) als PDF; Austausch mit Fachplanern über DXF/IFC. - Datensicherheit: Speichern/Autosave/Wiederherstellen auf dem Mac ([116]), Öffnen alter Beispielstände, kein Kern-Panic im Ablauf. ### Phase 2 (20.–26.11.): Wettbewerb lückenlos -- ○ **[207]** Schwarzplan / Situationsplan 1:500: Gebäude schwarz gefüllt, Nachbarbauten (Kataster/swisstopo) grau/schwarz, - Parzelle, Strassen, Nordpfeil, Massstabsbalken; als Ansichtsvorlage „Situation WBW“. · M +- ◐ **[207]** Schwarzplan / Situationsplan 1:500 (12.11.): Modelldarstellung mit `situation` (`ModelViewOption.situation`, Kern + `plan/situation.rs`) ersetzt im Grundriss die Bauteile durch den gefüllten Umriss des eigenen Gebäudes (Wände/Decken/Körper ab + Erdgeschoss + Dächer mit Überstand, Klasse „83 Situation Gebäude"), gefüllte Grundfläche der Kontextnetze ([181], auf ihrer Klasse; + grau, im Schwarzplan schwarz) und Nordpfeil + Massstabsbalken (Klasse „84 Planzeichen"); Raster/Wände/Möbel/Text/Masse/Koten/ + Schnittmarken über die Klassen der Vorlage aus, Parzelle, Strassen, Höhenlinien (enden an den Gebäuden) und Bäume bleiben. Standard- + Ressourcen „Situation WBW 1:500"/„Schwarzplan 1:500" (Vorlagen + Modelldarstellungen, Ressourcen-Tab „Modelldarstellung"), + Musterhaus komplex: Ausschnitt „Situation 1:500" nutzt sie, mit fünf Nachbargebäuden (Schnitte/Ansichten blenden Klasse 12 aus); CLI `plan --snapshot "Situation 1:500" --hatch`. + Offen: geschlossene Kataster-Polylinien (Klasse „Gebäude", nur 2D) bleiben Linien (gefüllt werden die Netze); Innenhöfe als weisse + Fläche statt Loch; Strassennamen/Gewässer nur als gewöhnliche Zeichnungen; nicht in der Tauri-App/auf dem Mac geprüft. · M - ○ **[208]** Wettbewerbs-Layouts: Plakat-Vorlagen A0/A1 hoch/quer mit Raster, Kennwort-Feld (Anonymität: kein Büroname, Metadaten im PDF leer), Planköpfe; Publikationssatz „WBW-Abgabe“ → PDF. · M - [61] Raumprogramm gegen Modell und Flächennachweis SIA 416 als Tabelle/Layout-Element ([70]); Kennzahlen (GF, GV, HNF/GF, Fassadenanteil). diff --git a/src-tauri/core/src/model/generated.rs b/src-tauri/core/src/model/generated.rs index 3b9096eb..0fcae7c4 100644 --- a/src-tauri/core/src/model/generated.rs +++ b/src-tauri/core/src/model/generated.rs @@ -2093,6 +2093,48 @@ pub struct ModelViewOption { #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub dimensions: Option, + /// [207] Situationsplan / Schwarzplan: fehlt ⇒ gewöhnlicher Grundriss; vorhanden ⇒ statt der Bauteile das + /// eigene Gebäude als gefüllter Umriss, die Kontextgebäude gefüllt, dazu Nordpfeil und Massstabsbalken. + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub situation: Option, + #[serde(flatten)] + #[ts(skip)] + pub extra: Extra, +} + +/// [207] Füllung eines Gebäudes im Situationsplan. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)] +pub enum SituationFill { + #[default] + #[serde(rename = "black")] + Black, + #[serde(rename = "grey")] + Grey, + #[serde(rename = "off")] + Off, + #[serde(other)] + #[ts(skip)] + Unknown, +} + +/// [207] Situationsplan in der Modelldarstellung (≙ Schwarzplan): jede Option fehlt ⇒ Standard des +/// Situationsplans (eigenes Gebäude schwarz, Kontext grau, mit Planzeichen). +#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)] +#[serde(default)] +pub struct ModelViewSituation { + /// Eigenes Gebäude: Umriss über alle Geschosse über Terrain und die Dächer, gefüllt (Basis: schwarz). + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub own: Option, + /// Kontextgebäude (importierte Netze, Grundfläche aus der Aufsicht), gefüllt (Basis: grau; „Schwarzplan": schwarz). + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub context: Option, + /// Nordpfeil und Massstabsbalken zeichnen (Basis: ja). + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub symbols: Option, #[serde(flatten)] #[ts(skip)] pub extra: Extra, diff --git a/src-tauri/core/src/plan/README.md b/src-tauri/core/src/plan/README.md index db5e2455..cd51b0b0 100644 --- a/src-tauri/core/src/plan/README.md +++ b/src-tauri/core/src/plan/README.md @@ -22,6 +22,7 @@ Herkunft, kein Wegweiser. | `drawings.rs` | freie 2D-Zeichnungen (Linie bis Bild, Bemassung, Blöcke), Zeichnungs-Stücke, kompakte Linien-Unterlage | | `context.rs` | Kontext (Höhenlinien, Fussabdrücke importierter Gebäude, Gelände) und Schnittführungs-Symbole | | `mesh_plan.rs` | importierte Netze und ([G1]) freie Körper über ihr Kern-Netz im Grundriss: geschnitten, darunter, darüber | +| `situation.rs` | Situationsplan/Schwarzplan ([207]): Modelldarstellung mit `situation` ersetzt die Bauteile durch den gefüllten Umriss des eigenen Gebäudes (Klasse 83), füllt Kontextnetze (Klasse des Netzes) und zeichnet Nordpfeil/Massstabsbalken (Klasse 84) | | `ceiling_plan.rs` | Deckenspiegel als eigene Ebenen-Art | | `floor_finish.rs` | Bodenbelag-Muster nach Massstab | | `model_view.rs` | Modelldarstellung ([173]): Optionen je Bauteilart über dem Detailgrad, Rangfolge Element > Typ > Stufe > Basis | diff --git a/src-tauri/core/src/plan/context.rs b/src-tauri/core/src/plan/context.rs index aa76990a..bea7ce6c 100644 --- a/src-tauri/core/src/plan/context.rs +++ b/src-tauri/core/src/plan/context.rs @@ -73,10 +73,23 @@ pub fn plan_context_with(c: &Ctx, out: &mut Vec, drawing_obstacles: & let mut late: Vec = Vec::new(); // [140]/[150] Höhenlinien, Böschungsschraffur und Beschriftungen enden am Fussabdruck des Geschosses. let mut house_cache: Option>> = None; - let mut house = || -> Vec> { house_cache.get_or_insert_with(|| terrain_footprint(c.p, &c.a.floor)).clone() }; + // [207] Situationsplan: Kontextgebäude gefüllt; die Höhenlinien enden auch an ihnen. + let sit = super::situation::opts(c); + let mut house = || -> Vec> { + house_cache + .get_or_insert_with(|| { + let mut h = terrain_footprint(c.p, &c.a.floor); + if let Some(s) = &sit { + h.extend(super::situation::own_rings(c.p)); + h.extend(super::situation::context_rings(c, s)); + } + h + }) + .clone() + }; let mut label_obst: Option = None; // [152] Importierte Netze im Geschoss nach dem Ansichtsbereich (`mesh_plan.rs`); sonst Fussabdruck. - let meshes_done = super::mesh_plan::plan_meshes(c, out); + let meshes_done = sit.is_none() && super::mesh_plan::plan_meshes(c, out); for obj in c.p.context.as_deref().unwrap_or(&[]) { if meshes_done && matches!(obj, ContextObject::ImportedMesh(_)) { continue; @@ -121,6 +134,11 @@ pub fn plan_context_with(c: &Ctx, out: &mut Vec, drawing_obstacles: & } } } + ContextObject::ImportedMesh(m) if sit.is_some() => { + if let Some(s) = &sit { + super::situation::context_mesh(c, s, m, out); + } + } ContextObject::ImportedMesh(m) => { let f = crate::plan::misc::context_footprint(&m.positions, &m.indices); let n = f.first().copied().unwrap_or(0.0) as usize; diff --git a/src-tauri/core/src/plan/domains.rs b/src-tauri/core/src/plan/domains.rs index 19d326fe..6dcfe621 100644 --- a/src-tauri/core/src/plan/domains.rs +++ b/src-tauri/core/src/plan/domains.rs @@ -189,6 +189,11 @@ impl<'a> Ctx<'a> { }) } + /// [207] Situationsplan der wirksamen Modelldarstellung (`None` = gewöhnlicher Grundriss). + pub fn situation(&self) -> Option<&ModelViewSituation> { + self.mv_sel.and_then(|m| m.situation.as_ref()) + } + /// [173] Aufgelöste Darstellungsoptionen dieser Plan-Erzeugung (`plan/model_view.rs`). pub fn mv(&self) -> &super::model_view::Options { &self.mv @@ -1737,6 +1742,12 @@ fn domains_before(c: &Ctx, out: &mut DomainPrims, bounds: &mut Bounds) -> Result if super::ceiling_plan::domains(c, out, bounds)? { return Ok(()); } + // [207] Situationsplan: das eigene Gebäude als gefüllter Umriss statt der Bauteile (nur Bäume bleiben). + if let Some(s) = super::situation::opts(c) { + super::situation::own_prims(c, &s, &mut out.roofs, bounds); + super::trees::plan_trees(c, &mut out.columns); + return Ok(()); + } ceilings(c, &mut out.ceilings, bounds)?; roofs(c, &mut out.roofs, bounds); super::walls::plan_walls(c, c.a.reference_lines, &mut out.walls, bounds)?; @@ -1768,7 +1779,9 @@ fn domains_after(c: &Ctx, out: &mut DomainPrims, bounds: &mut Bounds) { return; } let drawn = drawing_obstacles(c); - if c.a.global { + // [207] Situationsplan: keine Schnittführungen, Räume und Bodenbeläge; dafür Nordpfeil und Massstabsbalken. + let sit = super::situation::opts(c); + if c.a.global && sit.is_none() { // [150] Schnittführungen zuerst: ihre Beschriftungen sind Hindernisse der Höhenlinien-Beschriftungen. super::context::plan_section_lines(c, &mut out.sections); // [157] Marken und Beschriftungen der Schnittführungen gehören zum Ausmass (sonst oben abgeschnitten). @@ -1790,7 +1803,9 @@ fn domains_after(c: &Ctx, out: &mut DomainPrims, bounds: &mut Bounds) { // Höhenlinien-Beschriftungen; Stempel im Raum liegen im Fussabdruck, wo keine Beschriftung steht. let obstacles = stamp_obstacles_with(out, drawn.clone()); let mut top = Vec::new(); - rooms(c, &mut out.rooms, &mut top, bounds, &obstacles); + if sit.is_none() { + rooms(c, &mut out.rooms, &mut top, bounds, &obstacles); + } if c.a.global { let mut o = drawn; for q in out.sections.iter().filter(|q| matches!(q, Primitive::DrawingText { .. })) { @@ -1818,6 +1833,12 @@ fn domains_after(c: &Ctx, out: &mut DomainPrims, bounds: &mut Bounds) { } super::trees::plan_tree_labels(c, &o, &mut out.columns); } + if let Some(s) = &sit { + if c.a.global { + super::situation::symbol_prims(c, s, &mut out.sections, bounds); + } + return; + } // [156] Bodenbelag nach den Raumstempeln (spart sie aus), zuunterst in der Gruppe der Decken. let mut finish = Vec::new(); floor_finishes(c, &stamp_prims(&out.rooms, &top), &mut finish); @@ -1892,6 +1913,10 @@ fn extras_of(p: &Project, a: &PlanArgs) -> (Vec<(Primitive, u32)>, Vec, scale: f6 (under, violations) } +/// [207] Situationsplan: nur die Parzellengrenze des Baurechts (ohne Baubereich, Verstösse und Schatten), auf der +/// Klasse „01"; Strichstärke wie im Baurecht. +pub fn parcel_only(p: &Project) -> Vec<(Primitive, u32)> { + let mut under = Vec::new(); + if let Some(rules) = p.site_rules.as_ref().filter(|r| r.parcel.len() >= 3) { + ring_lines(&mut under, &rules.parcel, SITE_PARCEL_CLS, PARCEL_COLOR, 0.35, &PARCEL_DASH, 1); + } + under +} + // ── Abzugskörper ──────────────────────────────────────────────────────────────────────────────── const EPS: f64 = 1e-7; diff --git a/src-tauri/core/src/plan/mod.rs b/src-tauri/core/src/plan/mod.rs index a3113aed..ce865618 100644 --- a/src-tauri/core/src/plan/mod.rs +++ b/src-tauri/core/src/plan/mod.rs @@ -39,6 +39,7 @@ pub mod floor_finish; pub mod model_view; pub mod trees; pub mod mesh_plan; +pub mod situation; pub mod arc_fit; pub(crate) mod seams; pub(crate) mod wall_columns; diff --git a/src-tauri/core/src/plan/model_view_tests3.rs b/src-tauri/core/src/plan/model_view_tests3.rs index fccf266d..36397ac5 100644 --- a/src-tauri/core/src/plan/model_view_tests3.rs +++ b/src-tauri/core/src/plan/model_view_tests3.rs @@ -262,7 +262,7 @@ fn mitgelieferte_stufen_aus_den_standards() { .map(|v| serde_json::from_value(v).unwrap()) .collect(); let names: Vec<&str> = add.iter().map(|m| m.name.as_str()).collect(); - assert_eq!(names, ["Wettbewerb 1:200", "Baueingabe 1:100", "Ausführung 1:50", "Rohbau/Statik"]); + assert_eq!(names, ["Wettbewerb 1:200", "Baueingabe 1:100", "Ausführung 1:50", "Situation WBW", "Schwarzplan", "Rohbau/Statik"]); // Alles bekannt (keine verlorenen Felder) und unterscheidbar. for m in &add { assert!(m.extra.0.is_empty(), "{}: {:?}", m.name, m.extra); @@ -271,7 +271,7 @@ fn mitgelieferte_stufen_aus_den_standards() { let w = resolve(Some(&add[0]), crate::plan::style::Detail::Mittel, 200.0); assert_eq!(w.dims.chains, DimChains::Total); assert_eq!(w.stamp.number, Some(false)); - let r = resolve(Some(&add[3]), crate::plan::style::Detail::Mittel, 100.0); + let r = resolve(add.iter().find(|m| m.name == "Rohbau/Statik"), crate::plan::style::Detail::Mittel, 100.0); assert_eq!(r.wall.layers, LayerMode::Core); let a = resolve(Some(&add[2]), crate::plan::style::Detail::Fein, 50.0); assert!(a.stair.step_numbers && a.stamp.height == Some(true)); diff --git a/src-tauri/core/src/plan/situation.rs b/src-tauri/core/src/plan/situation.rs new file mode 100644 index 00000000..13eefd2d --- /dev/null +++ b/src-tauri/core/src/plan/situation.rs @@ -0,0 +1,314 @@ +//! [207] Situationsplan / Schwarzplan (Wettbewerb, 1:500): eine Modelldarstellung mit `situation` ersetzt im +//! Grundriss die Bauteile durch Flächen. +//! +//! - **Eigenes Gebäude** (Klasse „83 Situation Gebäude", [`OWN_CATEGORY`]): Umriss über alle Geschosse ab dem +//! Erdgeschoss (Wände, Decken, freie Körper) und die Dächer (mit Überstand, Dachaufsicht), vereinigt und +//! gefüllt (Standard schwarz). +//! - **Kontextgebäude** (importierte Netze, [181]; Klasse des Netzes, z. B. „12 Gebäude"): Grundfläche aus der +//! Aufsicht (Vereinigung der Dreiecke), gefüllt (Standard grau, „Schwarzplan": schwarz). +//! - **Planzeichen** (Klasse „84 Planzeichen", [`SYMBOL_CATEGORY`]): Nordpfeil und Massstabsbalken unter der +//! Lage, Grösse in Papier-mm. +//! +//! Wände, Treppen, Räume, Stützen, Körper, Bodenbeläge und Schnittmarken entfallen (`domains.rs`); Parzelle, +//! Strassen, Höhenlinien und Beschriftungen sind gewöhnliche Zeichnungen/Kontext auf ihren Klassen und +//! bleiben, solange die Klasse sichtbar ist (Ansichtsvorlage „Situation WBW", `standards.rs`). +//! Löcher (Innenhöfe) der Umrisse füllt eine weisse Fläche darüber. + +use super::domains::{Bounds, Ctx}; +use super::drawings::mm_to_model; +use super::prim::Primitive; +use super::style::no_hatch; +use crate::flat::{Polygon, Ring}; +use crate::model::*; + +/// Klasse des eigenen Gebäudes im Situationsplan. +pub const OWN_CATEGORY: &str = crate::standards::SITUATION_CATEGORY; +/// Klasse von Nordpfeil und Massstabsbalken. +pub const SYMBOL_CATEGORY: &str = crate::standards::SYMBOL_CATEGORY; + +const BLACK: (&str, &str) = ("#000000", "#000000"); +const GREY: (&str, &str) = ("#b8b8b8", "#7c7c7c"); +const OUTLINE_MM: f64 = 0.1; +/// Eine Dreiecksfläche unter 1 cm² trägt nichts zur Aufsicht bei (senkrechte Wände, Splitter). +const MIN_TRI_AREA: f64 = 1e-4; + +/// Aufgelöste Optionen des Situationsplans. +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct Opts { + pub own: SituationFill, + pub context: SituationFill, + pub symbols: bool, +} + +impl Opts { + pub fn of(s: &ModelViewSituation) -> Opts { + let fill = |f: Option, d: SituationFill| match f { + Some(SituationFill::Unknown) | None => d, + Some(f) => f, + }; + Opts { own: fill(s.own, SituationFill::Black), context: fill(s.context, SituationFill::Grey), symbols: s.symbols.unwrap_or(true) } + } +} + +fn colors(f: SituationFill) -> Option<(&'static str, &'static str)> { + match f { + SituationFill::Black => Some(BLACK), + SituationFill::Grey => Some(GREY), + _ => None, + } +} + +fn v2(q: [f64; 2]) -> Vec2 { + Vec2 { x: q[0], y: q[1] } +} + +fn polygon(pts: Vec, fill: &str, stroke: &str, w: f64, context_id: Option<&str>, greyed: bool) -> Primitive { + Primitive::Polygon { + pts, + fill: fill.into(), + stroke: stroke.into(), + stroke_width_mm: w, + hatch: Box::new(no_hatch()), + greyed: greyed.then_some(true), + opacity: None, + no_stroke_edges: None, + wall_id: None, + drawing_id: None, + ceiling_id: None, + opening_id: None, + stair_id: None, + room_id: None, + extruded_solid_id: None, + context_object_id: context_id.map(String::from), + column_id: None, + roof_id: None, + section_line_id: None, + } +} + +fn line(a: Vec2, b: Vec2, w: f64) -> Primitive { + Primitive::Line { a, b, cls: "situation-symbol".into(), weight_mm: w, dash: None, zigzag: None, motif: None, color: Some("#000000".into()), drawing_id: None, opening_id: None, stair_id: None, greyed: None, opacity: None } +} + +fn text(at: Vec2, s: &str, h: f64) -> Primitive { + Primitive::DrawingText { at, text: s.into(), height_m: h, angle: 0.0, color: "#000000".into(), marks: None, wrap_width: None, doc: None, drawing_id: None, greyed: None, opacity: None } +} + +/// Die Situation dieser Plan-Erzeugung (`None` = gewöhnlicher Grundriss). +pub fn opts(c: &Ctx) -> Option { + c.situation().map(Opts::of) +} + +/// Ist für diese Plan-Argumente der Situationsplan gewählt (ohne [`Ctx`], für die Zutaten)? +pub fn active(p: &Project, a: &super::domains::PlanArgs) -> bool { + super::model_view::selected_id(p, &a.floor, a.model_view.as_deref()).and_then(|id| super::model_view::find(p, id)).is_some_and(|m| m.situation.is_some()) +} + +/// Bodenhöhe des Erdgeschosses (Geschoss nächst ±0.00); `None` ohne Geschosse. +fn ground_base(p: &Project) -> Option { + super::extras::ground_floor_id(p).and_then(|id| p.floor(id)).map(|l| l.base_elevation.unwrap_or(0.0)) +} + +/// Eigenes Gebäude über dem Terrain: Wände, Decken und freie Körper der Geschosse ab dem Erdgeschoss +/// (Untergeschosse zählen nicht) und alle Dächer samt Überstand, vereinigt (Aussenringe mit Löchern). +pub fn own_polygons(p: &Project) -> Vec { + let base = ground_base(p); + let above = |floor: &str| match (base, p.floor(floor)) { + (Some(g), Some(l)) => l.base_elevation.unwrap_or(0.0) >= g - 0.05, + _ => true, + }; + let ok = |q: &[f64; 2]| q[0].is_finite() && q[1].is_finite(); + let mut parts: Vec = Vec::new(); + for w in p.walls.iter().filter(|w| above(&w.floor_id)) { + if let Some(f) = crate::site_rules::wall_footprint(p, w).filter(|f| f.len() >= 3 && f.iter().all(ok)) { + parts.push(vec![f]); + } + } + for c in p.ceilings.as_deref().unwrap_or(&[]).iter().filter(|c| above(&c.floor_id)) { + let r = c.ring_xy(); + if r.len() >= 3 && r.iter().all(ok) { + parts.push(vec![r]); + } + } + for s in p.extruded_solids.as_deref().unwrap_or(&[]).iter().filter(|s| above(&s.level_id) && s.operation.as_deref() != Some("subtract")) { + let r: Ring = s.points.iter().map(|q| [q.x, q.y]).collect(); + if r.len() >= 3 && r.iter().all(ok) { + parts.push(vec![r]); + } + } + for r in p.roofs.as_deref().unwrap_or(&[]) { + let g = crate::roof::roof_geometry(&r.params(), p.roof_base_elevation(r)); + if g.eaves.len() >= 3 && g.eaves.iter().all(ok) { + let mut poly = vec![g.eaves.clone()]; + poly.extend(g.eaves_holes.iter().filter(|h| h.len() >= 3 && h.iter().all(ok)).cloned()); + parts.push(poly); + } + } + if parts.is_empty() { + return Vec::new(); + } + crate::polygon_bool::union(&parts) +} + +/// Aussenringe des eigenen Gebäudes (Höhenlinien enden an ihnen). +pub fn own_rings(p: &Project) -> Vec> { + own_polygons(p).iter().filter_map(|poly| poly.first().filter(|r| r.len() >= 3)).map(|r| r.iter().map(|q| v2(*q)).collect()).collect() +} + +/// Grundfläche eines Netzes aus der Aufsicht: Vereinigung der Dreiecke in der Projektion (senkrechte Flächen +/// fallen weg). Ein Netz ohne Fläche ⇒ leer. +pub fn mesh_polygons(positions: &[f64], indices: &[f64]) -> Vec { + let n = positions.len() / 3; + let mut tris: Vec = Vec::new(); + for t in indices.chunks_exact(3) { + if t.iter().any(|i| !(*i >= 0.0) || i.fract() != 0.0 || *i as usize >= n) { + continue; + } + let q = |i: f64| [positions[i as usize * 3], positions[i as usize * 3 + 1]]; + let (a, b, c) = (q(t[0]), q(t[1]), q(t[2])); + if ![a, b, c].iter().all(|p| p[0].is_finite() && p[1].is_finite()) { + continue; + } + let area = ((b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1])) / 2.0; + if area.abs() < MIN_TRI_AREA { + continue; + } + // Gegen den Uhrzeigersinn (die Vereinigung verlangt einheitlichen Umlaufsinn). + tris.push(vec![if area > 0.0 { vec![a, b, c] } else { vec![a, c, b] }]); + } + if tris.is_empty() { + return Vec::new(); + } + crate::polygon_bool::union(&tris) +} + +/// Gefüllte Flächen: Aussenring in der Füllung, jedes Loch als weisse Fläche darüber. +fn fill_polygons(polys: &[Polygon], f: (&str, &str), context_id: Option<&str>, greyed: bool, out: &mut Vec) { + for poly in polys { + let Some(outer) = poly.first().filter(|r| r.len() >= 3) else { continue }; + out.push(polygon(outer.iter().map(|q| v2(*q)).collect(), f.0, f.1, OUTLINE_MM, context_id, greyed)); + for hole in poly.iter().skip(1).filter(|r| r.len() >= 3) { + out.push(polygon(hole.iter().map(|q| v2(*q)).collect(), "#ffffff", f.1, OUTLINE_MM, None, greyed)); + } + } +} + +fn acc_polys(polys: &[Polygon], bounds: &mut Bounds) { + for q in polys.iter().filter_map(|p| p.first()).flatten() { + bounds.acc(q[0], q[1]); + } +} + +/// Eigenes Gebäude als gefüllter Umriss (Gruppe „Dächer", unterhalb der Zeichnungen); Klasse „83". +pub fn own_prims(c: &Ctx, s: &Opts, out: &mut Vec, bounds: &mut Bounds) { + let Some(f) = colors(s.own) else { return }; + if !c.derived_shown(OWN_CATEGORY) { + return; + } + let polys = own_polygons(c.p); + acc_polys(&polys, bounds); + fill_polygons(&polys, f, None, c.greyed(OWN_CATEGORY), out); +} + +/// Aussenringe der Kontextgebäude, die diese Ansicht zeigt (Höhenlinien enden an ihnen). +pub fn context_rings(c: &Ctx, s: &Opts) -> Vec> { + let mut out = Vec::new(); + if colors(s.context).is_none() { + return out; + } + for m in imported_meshes(c) { + for poly in mesh_polygons(&m.positions, &m.indices) { + if let Some(o) = poly.first().filter(|r| r.len() >= 3) { + out.push(o.iter().map(|q| v2(*q)).collect()); + } + } + } + out +} + +/// Die importierten Netze, deren Klasse sichtbar ist. +fn imported_meshes<'a>(c: &'a Ctx) -> impl Iterator { + c.p.context.as_deref().unwrap_or(&[]).iter().filter_map(move |o| match o { + ContextObject::ImportedMesh(m) if c.shown(&m.category_code) => Some(m), + _ => None, + }) +} + +/// Ein Kontextgebäude als gefüllte Grundfläche (auf der Klasse des Netzes; Pick-Id = das Netz). +pub fn context_mesh(c: &Ctx, s: &Opts, m: &ImportedMesh, out: &mut Vec) { + let Some(f) = colors(s.context) else { return }; + let polys = mesh_polygons(&m.positions, &m.indices); + fill_polygons(&polys, f, Some(&m.id), c.greyed(&m.category_code), out); +} + +/// Nordpfeil und Massstabsbalken unter der Lage (Klasse „84"), rechtsbündig zum Ausmass von Gebäude, Parzelle +/// und Kontext. Ohne Gebäude kein Anhaltspunkt ⇒ keine Zeichen. +pub fn symbol_prims(c: &Ctx, s: &Opts, out: &mut Vec, bounds: &mut Bounds) { + if !s.symbols || !c.derived_shown(SYMBOL_CATEGORY) { + return; + } + let mut bb = Bounds::new(); + acc_polys(&own_polygons(c.p), &mut bb); + for m in imported_meshes(c) { + acc_polys(&mesh_polygons(&m.positions, &m.indices), &mut bb); + } + if let Some(r) = c.p.site_rules.as_ref().map(|r| &r.parcel) { + for q in r { + bb.acc(q.x, q.y); + } + } + let Some([_, min_y, max_x, _]) = bb.get() else { return }; + out.extend(symbols(c.a.scale, max_x, min_y)); + for q in out.iter() { + match q { + Primitive::Polygon { pts, .. } => pts.iter().for_each(|p| bounds.acc(p.x, p.y)), + Primitive::Line { a, b, .. } => { + bounds.acc(a.x, a.y); + bounds.acc(b.x, b.y); + } + Primitive::DrawingText { at, .. } => bounds.acc(at.x, at.y), + _ => {} + } + } +} + +/// Länge des Massstabsbalkens (m): die grösste runde Länge, die auf dem Papier höchstens 50 mm misst. +pub fn scalebar_total(scale: f64) -> f64 { + const TOTALS: [f64; 10] = [1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0, 500.0, 1000.0]; + TOTALS.iter().rev().copied().find(|m| m * 1000.0 / scale <= 50.0).unwrap_or(TOTALS[0]) +} + +/// Nordpfeil und Massstabsbalken; `right`/`below` = rechter Rand und Oberkante der Lage (Modell-Meter), die +/// Zeichen stehen darunter (Papierabstand 12 mm). Norden = +y. +pub fn symbols(scale: f64, right: f64, below: f64) -> Vec { + let mm = |v: f64| mm_to_model(v, scale); + let mut out = Vec::new(); + // Massstabsbalken: vier Felder, abwechselnd gefüllt; Beschriftung 0 / halbe Länge / Länge. + let total = scalebar_total(scale); + let len = total; + let (y1, h) = (below - mm(12.0), mm(1.6)); + let x0 = right - len; + for i in 0..4 { + let (a, b) = (x0 + len * i as f64 / 4.0, x0 + len * (i + 1) as f64 / 4.0); + let fill = if i % 2 == 0 { "#000000" } else { "#ffffff" }; + out.push(polygon(vec![Vec2 { x: a, y: y1 - h }, Vec2 { x: b, y: y1 - h }, Vec2 { x: b, y: y1 }, Vec2 { x: a, y: y1 }], fill, "#000000", 0.18, None, false)); + } + let th = mm(2.5); + let label = |v: f64| if v.fract() == 0.0 { format!("{v:.0}") } else { format!("{v}") }; + out.push(text(Vec2 { x: x0 - mm(0.6), y: y1 - h - th * 1.4 }, "0", th)); + out.push(text(Vec2 { x: x0 + len / 2.0 - mm(1.0), y: y1 - h - th * 1.4 }, &label(total / 2.0), th)); + out.push(text(Vec2 { x: right - mm(1.0) * (label(total).len() as f64 + 2.0), y: y1 - h - th * 1.4 }, &format!("{} m", label(total)), th)); + // Nordpfeil links vom Balken: halb gefüllte Spitze, „N" darüber. + let (cx, cy, r) = (x0 - mm(14.0), y1 - h / 2.0 - mm(3.0), mm(6.0)); + let top = Vec2 { x: cx, y: cy + r }; + let mid = Vec2 { x: cx, y: cy - r * 0.35 }; + out.push(polygon(vec![top, Vec2 { x: cx + r * 0.45, y: cy - r * 0.75 }, mid], "#000000", "#000000", 0.18, None, false)); + out.push(polygon(vec![top, mid, Vec2 { x: cx - r * 0.45, y: cy - r * 0.75 }], "#ffffff", "#000000", 0.18, None, false)); + out.push(line(top, Vec2 { x: cx, y: cy - r }, 0.18)); + out.push(text(Vec2 { x: cx - mm(1.0), y: cy + r + mm(1.2) }, "N", mm(3.5))); + out +} + +#[cfg(test)] +#[path = "situation_tests.rs"] +mod tests; diff --git a/src-tauri/core/src/plan/situation_tests.rs b/src-tauri/core/src/plan/situation_tests.rs new file mode 100644 index 00000000..74786dc6 --- /dev/null +++ b/src-tauri/core/src/plan/situation_tests.rs @@ -0,0 +1,149 @@ +//! [207] Situationsplan / Schwarzplan: eigenes Gebäude schwarz, Kontext grau (bzw. schwarz), Klassen, Planzeichen. + +use super::*; +use crate::plan::domains::{plan_domains_buf, PlanArgs}; +use crate::standards::{derived_categories, model_views, SITUATION_CATEGORY, SYMBOL_CATEGORY}; +use serde_json::{json, Value}; + +/// Würfel 10 × 6 × 8 m an (x0, y0), Dreiecke wie beim Import (aussen, ohne Boden-Duplikate). +fn box_mesh(id: &str, category: &str, x0: f64, y0: f64) -> Value { + let (x1, y1) = (x0 + 10.0, y0 + 6.0); + let positions = [x0, y0, 0.0, x1, y0, 0.0, x1, y1, 0.0, x0, y1, 0.0, x0, y0, 8.0, x1, y0, 8.0, x1, y1, 8.0, x0, y1, 8.0]; + let indices = [0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 0, 1, 5, 0, 5, 4, 1, 2, 6, 1, 6, 5, 2, 3, 7, 2, 7, 6, 3, 0, 4, 3, 4, 7]; + json!({"type": "importedMesh", "id": id, "name": id, "categoryCode": category, "positions": positions.to_vec(), "indices": indices.to_vec()}) +} + +fn project() -> Project { + let mut v: Value = serde_json::from_str(include_str!("../../tests/fixtures/sample_project.json")).unwrap(); + v["layers"].as_array_mut().unwrap().extend(derived_categories()); + v["layers"].as_array_mut().unwrap().push(json!({"code": "12", "name": "Gebäude", "color": "#888888", "lw": 0.18, "visible": true, "locked": false})); + // Untergeschoss mit einer Wand ausserhalb des Hauses: zählt nicht zum Gebäude über dem Terrain. + v["drawingLevels"].as_array_mut().unwrap().push(json!({"id": "ug", "name": "UG", "kind": "floor", "visible": true, "locked": false, "baseElevation": -2.7})); + v["walls"].as_array_mut().unwrap().push(json!({"id": "w-ug", "type": "wall", "floorId": "ug", "categoryCode": "20", "start": {"x": 20, "y": 0}, "end": {"x": 25, "y": 0}, "wallTypeId": "aw", "height": 2.6})); + v["modelViewOptions"] = Value::Array(model_views()); + v["context"] = json!([box_mesh("nachbar-1", "12", 12.0, -1.0), box_mesh("nachbar-2", "12", -14.0, 5.0)]); + serde_json::from_value(v).unwrap() +} + +fn codes(p: &Project) -> Vec { + p.flat_categories().iter().map(|c| c.code.clone()).collect() +} + +fn plan(p: &Project, show: &[String], model_view: &str) -> Vec { + let a = PlanArgs::parse(1.0, &json!({"floor": "eg", "show": show, "global": true, "scale": 500, "modelView": model_view}).to_string()).unwrap(); + let buf = plan_domains_buf(p, &a).unwrap(); + crate::plan::buf::View::parse(&buf).unwrap().prims().unwrap() +} + +fn without(codes: &[String], code: &str) -> Vec { + codes.iter().filter(|c| *c != code).cloned().collect() +} + +fn fills<'a>(ps: &'a [Primitive], color: &str) -> Vec<&'a Primitive> { + ps.iter().filter(|q| matches!(q, Primitive::Polygon { fill, .. } if fill == color)).collect() +} + +fn ring_area(pts: &[Vec2]) -> f64 { + (0..pts.len()).map(|i| (pts[i].x * pts[(i + 1) % pts.len()].y - pts[(i + 1) % pts.len()].x * pts[i].y) / 2.0).sum::().abs() +} + +#[test] +fn eigenes_gebaeude_schwarz_ohne_bauteile() { + let p = project(); + let ps = plan(&p, &codes(&p), "std-mv-situation-wbw"); + // Keine Wand-Poché, keine Raumstempel, keine Schnittmarken. + assert!(!ps.iter().any(|q| matches!(q, Primitive::Polygon { wall_id: Some(_), .. })), "Wände entfallen"); + assert!(!ps.iter().any(|q| matches!(q, Primitive::Text { room_id: Some(_), .. })), "Raumstempel entfallen"); + let black: Vec<_> = fills(&ps, "#000000").into_iter().filter(|q| matches!(q, Primitive::Polygon { context_object_id: None, stroke_width_mm, .. } if *stroke_width_mm == 0.1)).collect(); + assert_eq!(black.len(), 1, "ein schwarzer Umriss (UG-Wand zählt nicht)"); + let Primitive::Polygon { pts, .. } = black[0] else { unreachable!() }; + assert!(pts.iter().all(|q| q.x < 6.0), "nur das Haus über dem Terrain: {pts:?}"); + let a = ring_area(pts); + assert!(a > 15.0 && a < 40.0, "Fläche des Hauses: {a}"); +} + +#[test] +fn kontext_grau_und_schwarzplan_schwarz() { + let p = project(); + let wbw = plan(&p, &codes(&p), "std-mv-situation-wbw"); + let grey: Vec<_> = wbw.iter().filter(|q| matches!(q, Primitive::Polygon { context_object_id: Some(_), fill, .. } if fill == "#b8b8b8")).collect(); + assert_eq!(grey.len(), 2, "zwei Nachbarn grau"); + let Primitive::Polygon { pts, context_object_id, .. } = grey[0] else { unreachable!() }; + assert_eq!(context_object_id.as_deref(), Some("nachbar-1")); + assert!((ring_area(pts) - 60.0).abs() < 1e-6, "Grundfläche aus der Aufsicht: {}", ring_area(pts)); + let sp = plan(&p, &codes(&p), "std-mv-schwarzplan"); + let black_ctx = sp.iter().filter(|q| matches!(q, Primitive::Polygon { context_object_id: Some(_), fill, .. } if fill == "#000000")).count(); + assert_eq!(black_ctx, 2, "Schwarzplan: Nachbarn schwarz"); +} + +#[test] +fn alles_auf_klassen() { + let p = project(); + let all = codes(&p); + let own = |ps: &[Primitive]| ps.iter().filter(|q| matches!(q, Primitive::Polygon { context_object_id: None, fill, stroke_width_mm, .. } if fill == "#000000" && *stroke_width_mm == 0.1)).count(); + let ctx = |ps: &[Primitive]| ps.iter().filter(|q| matches!(q, Primitive::Polygon { context_object_id: Some(_), .. })).count(); + let north = |ps: &[Primitive]| ps.iter().any(|q| matches!(q, Primitive::DrawingText { text, .. } if text == "N")); + let base = plan(&p, &all, "std-mv-situation-wbw"); + assert!(own(&base) == 1 && ctx(&base) == 2 && north(&base)); + let no_own = plan(&p, &without(&all, SITUATION_CATEGORY), "std-mv-situation-wbw"); + assert!(own(&no_own) == 0 && ctx(&no_own) == 2 && north(&no_own), "Klasse 83 schaltet das eigene Gebäude"); + let no_ctx = plan(&p, &without(&all, "12"), "std-mv-situation-wbw"); + assert!(own(&no_ctx) == 1 && ctx(&no_ctx) == 0, "Klasse der Netze schaltet den Kontext"); + let no_sym = plan(&p, &without(&all, SYMBOL_CATEGORY), "std-mv-situation-wbw"); + assert!(own(&no_sym) == 1 && !north(&no_sym), "Klasse 84 schaltet Nordpfeil und Massstabsbalken"); +} + +#[test] +fn gewoehnlicher_grundriss_bleibt() { + let p = project(); + let ps = plan(&p, &codes(&p), "mittel"); + assert!(ps.iter().any(|q| matches!(q, Primitive::Polygon { wall_id: Some(_), .. }))); + assert!(fills(&ps, "#b8b8b8").is_empty()); + assert!(!ps.iter().any(|q| matches!(q, Primitive::DrawingText { text, .. } if text == "N"))); +} + +#[test] +fn dachaufsicht_zaehlt_zum_gebaeude() { + let p = project(); + let Some(r) = p.roofs.as_deref().and_then(|r| r.first()) else { panic!("Fixture hat ein Dach") }; + let g = crate::roof::roof_geometry(&r.params(), p.roof_base_elevation(r)); + let polys = own_polygons(&p); + let (min_x, max_x) = g.eaves.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |a, q| (a.0.min(q[0]), a.1.max(q[0]))); + let xs: Vec = polys.iter().flat_map(|q| q[0].iter().map(|r| r[0])).collect(); + assert!(xs.iter().cloned().fold(f64::INFINITY, f64::min) <= min_x + 1e-6 && xs.iter().cloned().fold(f64::NEG_INFINITY, f64::max) >= max_x - 1e-6, "Umriss deckt die Traufe"); +} + +#[test] +fn netz_flaeche_ohne_senkrechte() { + // Nur senkrechte Dreiecke: keine Fläche in der Aufsicht. + let pos = [0.0, 0.0, 0.0, 5.0, 0.0, 0.0, 5.0, 0.0, 3.0]; + assert!(mesh_polygons(&pos, &[0.0, 1.0, 2.0]).is_empty()); + // Ungültige Indizes und NaN: ohne Panic leer. + assert!(mesh_polygons(&[0.0, 0.0, 0.0, f64::NAN, 0.0, 0.0, 1.0, 1.0, 0.0], &[0.0, 1.0, 2.0, 0.0, 9.0, 1.0]).is_empty()); +} + +#[test] +fn massstabsbalken_rund_und_im_papiermass() { + assert_eq!(scalebar_total(500.0), 20.0); + assert_eq!(scalebar_total(1000.0), 50.0); + assert_eq!(scalebar_total(200.0), 10.0); + let s = symbols(500.0, 40.0, -10.0); + // Vier Balkenfelder + zwei Spitzenhälften, alle unter der Lage (Papierabstand 12 mm = 6 m). + let polys: Vec<_> = s.iter().filter_map(|q| if let Primitive::Polygon { pts, .. } = q { Some(pts) } else { None }).collect(); + assert_eq!(polys.len(), 6); + assert!(polys.iter().flat_map(|p| p.iter()).all(|q| q.y < -10.0), "unter der Oberkante der Lage"); +} + +#[test] +fn baurecht_nur_parzellengrenze() { + let mut p = project(); + p.site_rules = Some(serde_json::from_value(json!({"parcel": [{"x": -8, "y": -8}, {"x": 16, "y": -8}, {"x": 16, "y": 12}, {"x": -8, "y": 12}], "setbacks": [3, 3, 3, 3], "defaultSetback": 3, "show": true})).unwrap()); + let mut all = codes(&p); + all.push("01".into()); + let ps = plan(&p, &all, "std-mv-situation-wbw"); + let cls = |c: &str| ps.iter().filter(|q| matches!(q, Primitive::Line { cls, .. } if cls == c)).count(); + assert!(cls("site-parcel") >= 4, "Parzellengrenze bleibt"); + assert_eq!(cls("site-allowed"), 0, "kein Baubereich"); + let normal = plan(&p, &all, "mittel"); + assert!(normal.iter().filter(|q| matches!(q, Primitive::Line { cls, .. } if cls == "site-allowed")).count() > 0, "im gewöhnlichen Grundriss schon"); +} diff --git a/src-tauri/core/src/site_rules.rs b/src-tauri/core/src/site_rules.rs index f097e6d2..25ae76b5 100644 --- a/src-tauri/core/src/site_rules.rs +++ b/src-tauri/core/src/site_rules.rs @@ -496,7 +496,7 @@ pub(crate) fn wall_corners(start: Vec2, end: Vec2, thickness: f64) -> Vec<[f64; } /// Grundriss einer Wand (Bogenwand [T2]: Kreisringsektor); `None` bei Länge 0. -fn wall_footprint(p: &Project, w: &crate::model::Wall) -> Option { +pub(crate) fn wall_footprint(p: &Project, w: &crate::model::Wall) -> Option { if hypot2(w.end.x - w.start.x, w.end.y - w.start.y) < 1e-9 { return None; } diff --git a/src-tauri/core/src/standards.rs b/src-tauri/core/src/standards.rs index bc2c114f..740699fd 100644 --- a/src-tauri/core/src/standards.rs +++ b/src-tauri/core/src/standards.rs @@ -281,9 +281,19 @@ pub fn view_templates() -> Vec { "layerVisibility": {"99": false}}), json!({"id": "std-vt-ausfuehrung-50", "name": "Ausführungsplan 1:50", "detail": "fein", "scaleDenominator": 50, "mono": true, "shadows": false, "scaleLineWeights": true, "layerVisibility": {"99": false}}), + // [207] Situationsplan 1:500 für Wettbewerbe: eigenes Gebäude schwarz, Kontext grau (bzw. alles schwarz im Schwarzplan); + // ohne Raster, Bauteil-Zeichnungen, Text, Bemassung, Koten und Referenzen. Parzelle, Strassen, Höhenlinien und Bäume bleiben. + json!({"id": "std-vt-situation-wbw", "name": "Situation WBW 1:500", "detail": "grob", "scaleDenominator": 500, "mono": true, "shadows": false, + "showTerrain": true, "modelViewOptionId": "std-mv-situation-wbw", "layerVisibility": SITUATION_HIDDEN.iter().map(|c| (c.to_string(), json!(false))).collect::>()}), + json!({"id": "std-vt-schwarzplan", "name": "Schwarzplan 1:500", "detail": "grob", "scaleDenominator": 500, "mono": true, "shadows": false, + "showTerrain": false, "modelViewOptionId": "std-mv-schwarzplan", "layerVisibility": SITUATION_HIDDEN.iter().chain(["02", "14"].iter()).map(|c| (c.to_string(), json!(false))).collect::>()}), ] } +/// [207] Klassen, die der Situationsplan ausblendet: Raster, Wände (samt Türen/Fenster, Möbel, Stützen), Decken, Dächer, +/// Träger, Treppen, Baugrube, Text, Räume, Bemassung, Auto-Bemassung, Höhenkoten, Details, Referenzen, Schnittmarken, Konstruktion. +const SITUATION_HIDDEN: [&str; 18] = ["00", "07", "20", "21", "22", "25", "30", "35", "40", "50", "60", "80", "81", "82", "85", "90", "91", "99"]; + /// [173] Stufen der Modelldarstellung als Vorlagen (≙ Archicad „Modelldarstellung"): Wettbewerb 1:200 (Wände als /// Fläche, Räume mit Name und Fläche ohne Nummer, nur das Gesamtmass, ohne Koten), Baueingabe 1:100 (SIA-Kategorie, /// alle Ketten), Ausführung 1:50 (fein: alle Schichten, Schwellen, Stufennummern, Raumhöhe und Belag) und @@ -316,6 +326,12 @@ pub fn model_views() -> Vec { "slabs": {"floorFinish": "all", "layers": "all"}, "roomStamps": {"number": true, "area": true, "height": true, "finish": true, "divider": true}, "dimensions": {"chains": "all", "levelMarks": true}}), + // [207] Situationsplan: eigenes Gebäude schwarz, Kontext grau, mit Nordpfeil und Massstabsbalken. + json!({"id": "std-mv-situation-wbw", "name": "Situation WBW", "baseDetail": "grob", + "situation": {"own": "black", "context": "grey", "symbols": true}}), + // [207] Schwarzplan: alle Gebäude schwarz. + json!({"id": "std-mv-schwarzplan", "name": "Schwarzplan", "baseDetail": "grob", + "situation": {"own": "black", "context": "black", "symbols": true}}), json!({"id": "std-mv-rohbau", "name": "Rohbau/Statik", "baseDetail": "mittel", "doors": {"frame": false, "swingArc": false, "threshold": "off", "sectionDetail": false}, "windows": {"sill": false, "sashFrames": false, "sectionDetail": false}, @@ -363,13 +379,19 @@ pub const AUTO_DIM_CATEGORY: &str = "81"; pub const LEVEL_MARK_CATEGORY: &str = "82"; /// Schnitt- und Ansichtsmarken im Grundriss (Schnittführung mit Pfeilen und Beschriftung). pub const SECTION_MARK_CATEGORY: &str = "91"; +/// [207] Eigenes Gebäude im Situationsplan/Schwarzplan (gefüllter Umriss über alle Geschosse, `plan/situation.rs`). +pub const SITUATION_CATEGORY: &str = "83"; +/// [207] Planzeichen des Situationsplans: Nordpfeil und Massstabsbalken. +pub const SYMBOL_CATEGORY: &str = "84"; /// Die Klassen der abgeleiteten Darstellung (Code, Name, Farbe, Strichstärke). -pub const DERIVED_CATEGORIES: [(&str, &str, &str, f64); 4] = [ +pub const DERIVED_CATEGORIES: [(&str, &str, &str, f64); 6] = [ (SHADOW_CATEGORY, "Schatten", "#707078", 0.13), (AUTO_DIM_CATEGORY, "Auto-Bemassung", "#303038", 0.13), (LEVEL_MARK_CATEGORY, "Höhenkoten", "#1a1a1a", 0.13), (SECTION_MARK_CATEGORY, "Schnittmarken", "#1a1a1a", 0.18), + (SITUATION_CATEGORY, "Situation Gebäude", "#000000", 0.13), + (SYMBOL_CATEGORY, "Planzeichen", "#000000", 0.18), ]; pub fn derived_categories() -> Vec { @@ -841,7 +863,7 @@ mod tests { // Andere Kategorien bleiben, die neue kommt ans Ende. own.insert("layers".into(), json!([{"code": "20", "name": "Wände", "color": "#000", "lw": 0.35, "visible": true, "locked": false}])); let op = merge_ops(&own).into_iter().find(|o| o["key"] == "layers").unwrap(); - assert_eq!(op["value"].as_array().unwrap().iter().map(|l| l["code"].as_str().unwrap()).collect::>(), ["20", "65", "08", "81", "82", "91"]); + assert_eq!(op["value"].as_array().unwrap().iter().map(|l| l["code"].as_str().unwrap()).collect::>(), ["20", "65", "08", "81", "82", "91", "83", "84"]); } /// [180] Klassen der abgeleiteten Darstellung: „Standards laden" legt sie an, einmal; vorhandene (Code oder Name) bleiben. @@ -857,7 +879,7 @@ mod tests { own.insert("layers".into(), json!([{"code": "77", "name": "schatten", "color": "#000", "lw": 0.13, "visible": true, "locked": false}])); let op = merge_ops(&own).into_iter().find(|o| o["key"] == "layers").unwrap(); let codes: Vec<&str> = op["value"].as_array().unwrap().iter().map(|l| l["code"].as_str().unwrap()).collect(); - assert_eq!(codes, ["77", "65", "81", "82", "91"]); + assert_eq!(codes, ["77", "65", "81", "82", "91", "83", "84"]); // Sichtbar, solange die Klasse fehlt; sonst nach der Klassen-Sichtbarkeit. assert!(derived_visible(&p, SHADOW_CATEGORY, |c| c == SHADOW_CATEGORY)); assert!(!derived_visible(&p, SHADOW_CATEGORY, |_| false)); diff --git a/src/cli/main.ts b/src/cli/main.ts index 2378f9ca..a8cbe67a 100644 --- a/src/cli/main.ts +++ b/src/cli/main.ts @@ -20,6 +20,7 @@ // das Massstab-Kriterium einer Regel (ab/bis 1:n) gilt nach --scale; // --model-view wählt eine Modelldarstellung (eigene Stufe oder grob/mittel/fein) [173] // --hide blendet Klassen aus (z. B. --hide "Schatten,Auto-Bemassung") [180] +// --snapshot übernimmt Geschoss, Massstab, Vorlage und Sichtbarkeit eines Ausschnitts [207] // dossier-cli ifc [--ebkph] [--ebenen] (IFC mit eBKP-H-Hauptgruppen bzw. Modell-Ebenen als Klassifikation) // --schema 4|2x3: IFC4 (Standard) oder IFC2x3 (Coordination View 2.0) // dossier-cli dxf [--binary] [--scale 100] [--dim-unit cm] [--layout]|dwg|ifc|step|obj [--no-mtl]|stl|glb|gltf|schedule [--openings|--elements|--rooms] [--format json|csv|svg|pdf]|kennzahlen [--sia416] [--ivhb] [--format json|csv|svg|pdf] [--agsf m2] [--gruenflaeche m2] [--agf-basis gf|ngf|nf] [--untergeschosse]|raumprogramm [--import tabelle] [--sheet name|nr] [--mode replace|append] [--tolerance %] [--generate] [--format json|csv|svg|pdf] [--save projekt.obp]|sun [--level EG] [--out datei] @@ -685,6 +686,24 @@ async function execute(project: Project, file: string, command: string, rest: st }; collectCodes(project.layers); + // [207] `--snapshot ` (plan/section/elevation): Geschoss, Massstab, verknüpfte Ansichtsvorlage und Sichtbarkeit eines + // Ausschnitts (`viewSnapshots`) übernehmen, z. B. `plan --snapshot "Situation 1:500" --hatch`. Ausdrückliche Flags gehen vor. + const snapName = args.flags.get("snapshot"); + if (snapName && (command === "plan" || command === "section" || command === "elevation")) { + const n = snapName.toLowerCase(); + const snap = (project.viewSnapshots ?? []).find((s) => s.id.toLowerCase() === n || s.name.toLowerCase() === n); + if (!snap) fail(`Ausschnitt nicht gefunden: ${snapName}`); + const level = project.drawingLevels.find((l) => l.id === snap.activeLevelId); + if (!level) fail(`Ausschnitt ${snap.name}: Ebene ${snap.activeLevelId} fehlt`); + const f = args.flags; + if (!f.has("level")) f.set("level", level.id); + if (!f.has("scale")) f.set("scale", String(snap.scaleDenominator)); + if (!f.has("template") && snap.templateId && snap.templateLinked) f.set("template", snap.templateId); + const hidden = [...allCodes].filter((c) => snap.layerVisibility[c] === false || !(c in snap.layerVisibility)); + if (!f.has("hide") && hidden.length) f.set("hide", hidden.join(",")); + if (command !== "plan") rest = [rest[0] ?? level.id]; + } + switch (command) { case "info": { const levels = project.drawingLevels.map((l) => `${l.kind}:${l.name}`); diff --git a/src/commands/cmds/presentation.test.ts b/src/commands/cmds/presentation.test.ts index e1415dea..a6bf70c7 100644 --- a/src/commands/cmds/presentation.test.ts +++ b/src/commands/cmds/presentation.test.ts @@ -38,5 +38,5 @@ describe("[66] Befehl praesentation", () => { expect(q.layouts?.some((l) => l.id === id)).toBe(false); expect(q.drawingLevels.some((l) => l.sketch)).toBe(false); expect(q.drawingLevels.length).toBe(before.drawingLevels.length); - }); + }, 60_000); }); diff --git a/src/i18n/de.ts b/src/i18n/de.ts index 30945037..16650437 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -1336,6 +1336,12 @@ export const de = { "resources.modelViews.opt.roomStamps.divider": "Trennlinie", "resources.modelViews.opt.dimensions.chains": "Ketten der Aussenbemassung", "resources.modelViews.opt.dimensions.levelMarks": "Höhenkoten", + "resources.modelViews.section.situation": "Situationsplan / Schwarzplan", + "resources.modelViews.opt.situation.own": "Eigenes Gebäude (Umriss über alle Geschosse)", + "resources.modelViews.opt.situation.context": "Kontextgebäude (Grundfläche)", + "resources.modelViews.opt.situation.symbols": "Nordpfeil und Massstabsbalken", + "resources.modelViews.val.black": "schwarz", + "resources.modelViews.val.grey": "grau", "resources.modelViews.opt.stairs.stepNumbers": "Stufennummern", "resources.modelViews.val.outer": "ohne Öffnungen", "resources.modelViews.val.total": "nur Gesamtmass", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 2efc7b7f..69b7fa6b 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -1330,6 +1330,12 @@ export const en: Record = { "resources.modelViews.opt.roomStamps.divider": "Divider line", "resources.modelViews.opt.dimensions.chains": "Exterior dimension chains", "resources.modelViews.opt.dimensions.levelMarks": "Level marks", + "resources.modelViews.section.situation": "Site plan / figure-ground plan", + "resources.modelViews.opt.situation.own": "Own building (outline over all floors)", + "resources.modelViews.opt.situation.context": "Context buildings (footprint)", + "resources.modelViews.opt.situation.symbols": "North arrow and scale bar", + "resources.modelViews.val.black": "black", + "resources.modelViews.val.grey": "grey", "resources.modelViews.opt.stairs.stepNumbers": "Step numbers", "resources.modelViews.val.outer": "without openings", "resources.modelViews.val.total": "overall only", diff --git a/src/model/derivedCategories.ts b/src/model/derivedCategories.ts index 3ad64a3e..526df582 100644 --- a/src/model/derivedCategories.ts +++ b/src/model/derivedCategories.ts @@ -16,7 +16,12 @@ export const LEVEL_MARK_CATEGORY = "82"; /** Schnitt- und Ansichtsmarken im Grundriss. */ export const SECTION_MARK_CATEGORY = "91"; -export const DERIVED_CATEGORY_CODES: readonly string[] = [SHADOW_CATEGORY, AUTO_DIM_CATEGORY, LEVEL_MARK_CATEGORY, SECTION_MARK_CATEGORY]; +/** [207] Eigenes Gebäude im Situationsplan/Schwarzplan (gefüllter Umriss über alle Geschosse). */ +export const SITUATION_CATEGORY = "83"; +/** [207] Planzeichen des Situationsplans: Nordpfeil und Massstabsbalken. */ +export const SYMBOL_CATEGORY = "84"; + +export const DERIVED_CATEGORY_CODES: readonly string[] = [SHADOW_CATEGORY, AUTO_DIM_CATEGORY, LEVEL_MARK_CATEGORY, SECTION_MARK_CATEGORY, SITUATION_CATEGORY, SYMBOL_CATEGORY]; /** Abgeleitete Darstellung der Klasse `code` sichtbar: Klasse eingeblendet (`shown`) oder im Projekt nicht vorhanden. */ export function derivedVisible(layers: LayerCategory[], code: string, shown: (code: string) => boolean): boolean { diff --git a/src/model/sampleProject.ts b/src/model/sampleProject.ts index 55b97e72..e3ed45a6 100644 --- a/src/model/sampleProject.ts +++ b/src/model/sampleProject.ts @@ -416,6 +416,9 @@ export const sampleProject: Project = { { code: "82", name: "Höhenkoten", color: "#1a1a1a", lw: 0.13, visible: true, locked: false }, { code: "90", name: "Referenzen", color: "#1a1a1a", lw: 0.13, visible: true, locked: false }, { code: "91", name: "Schnittmarken", color: "#1a1a1a", lw: 0.18, visible: true, locked: false }, + // [207] Situationsplan/Schwarzplan: eigenes Gebäude als gefüllter Umriss, Nordpfeil und Massstabsbalken. + { code: "83", name: "Situation Gebäude", color: "#000000", lw: 0.13, visible: true, locked: false }, + { code: "84", name: "Planzeichen", color: "#000000", lw: 0.18, visible: true, locked: false }, { code: "99", name: "Konstruktion", color: "#404040", lw: 0.13, visible: true, locked: false }, ], // [140] Strichstärken folgen dem Massstab (neue Projekte; bestehende behalten ihre Einstellung). diff --git a/src/model/sampleProjectComplex.situation.test.ts b/src/model/sampleProjectComplex.situation.test.ts new file mode 100644 index 00000000..033f1a04 --- /dev/null +++ b/src/model/sampleProjectComplex.situation.test.ts @@ -0,0 +1,51 @@ +// [207] Musterhaus komplex: Ausschnitt „Situation 1:500" nutzt die Ansichtsvorlage „Situation WBW"; Situationsplan +// mit schwarzem eigenem Gebäude, grauen Nachbarn, Planzeichen und Klassen. +import { describe, expect, it } from "vitest"; +import { generatePlan, planToSvgString, projectWithTemplate } from "../core"; +import { buildComplexSampleProject } from "./sampleProjectComplex"; + +const p = buildComplexSampleProject(); +const snap = p.viewSnapshots?.find((s) => s.id === "vs-situation"); +const tpl = p.viewTemplates?.find((t) => t.id === "std-vt-situation-wbw"); + +type Plan = ReturnType; +type Poly = { kind: "polygon"; fill: string; wallId?: string; contextObjectId?: string; strokeWidthMm: number }; + +function planOf(hide: string[] = []): Plan { + const tp = projectWithTemplate(p, "eg", tpl!); + const show = new Set(Object.entries(snap!.layerVisibility).filter(([c, v]) => v && !hide.includes(c)).map(([c]) => c)); + return generatePlan(tp, "eg", show, undefined, "grob", false, true, true, 500); +} +const polys = (pl: Plan): Poly[] => pl.primitives.filter((q) => q.kind === "polygon") as unknown as Poly[]; +const isCtx = (q: Poly) => q.contextObjectId === "nachbarn"; +const isOwn = (q: Poly) => q.fill === "#000000" && !q.contextObjectId && q.strokeWidthMm < 0.12; // Umriss 0.1 mm (nach Massstab skaliert), Planzeichen 0.18 mm + +describe("Situation 1:500 im Musterhaus komplex", () => { + it("Ausschnitt ist an die Vorlage gebunden, Klassen der Vorlage sind aus", () => { + expect(snap?.templateId).toBe("std-vt-situation-wbw"); + expect(snap?.templateLinked).toBe(true); + expect(tpl?.modelViewOptionId).toBe("std-mv-situation-wbw"); + for (const [code, v] of Object.entries(tpl?.layerVisibility ?? {})) expect(snap?.layerVisibility[code], code).toBe(v); + }); + + it("eigenes Gebäude schwarz, Nachbarn grau, keine Bauteile", () => { + const ps = polys(planOf()); + expect(ps.some((q) => q.wallId)).toBe(false); + expect(ps.filter(isOwn).length).toBeGreaterThanOrEqual(1); + expect(ps.filter((q) => isCtx(q) && q.fill === "#b8b8b8").length).toBe(5); + }); + + it("Klassen: Nachbarn (12), eigenes Gebäude (83), Planzeichen (84) schaltbar", () => { + expect(polys(planOf(["12"])).filter(isCtx).length).toBe(0); + expect(polys(planOf(["83"])).filter(isOwn).length).toBe(0); + const hasN = (pl: Plan) => pl.primitives.some((q) => q.kind === "drawingText" && (q as unknown as { text: string }).text === "N"); + expect(hasN(planOf())).toBe(true); + expect(hasN(planOf(["84"]))).toBe(false); + }); + + it("SVG enthält schwarze und graue Flächen", () => { + const svg = planToSvgString(planOf(), { scaleDenominator: 500 }); + expect(svg).toContain('fill="#000000"'); + expect(svg).toContain('fill="#b8b8b8"'); + }); +}); diff --git a/src/model/sampleProjectComplex.test.ts b/src/model/sampleProjectComplex.test.ts index 42f869a9..300f9f89 100644 --- a/src/model/sampleProjectComplex.test.ts +++ b/src/model/sampleProjectComplex.test.ts @@ -43,7 +43,7 @@ describe("Musterhaus komplex", () => { expect(p.rooms!.length).toBeGreaterThanOrEqual(20); expect(p.roofs!.some((r) => (r.dormers ?? []).length === 2)).toBe(true); expect(p.stairs!.map((s) => s.shape).sort()).toEqual(["L", "spiral", "straight"]); - expect(p.context!.map((c) => c.type).sort()).toEqual(["contourSet", "excavation", "terrainMesh"]); + expect(p.context!.map((c) => c.type).sort()).toEqual(["contourSet", "excavation", "importedMesh", "terrainMesh"]); expect(p.extrudedSolids!.filter((s) => s.brep).length).toBe(2); expect(p.drawings2d.filter((d) => d.geom.shape === "dimension").length).toBeGreaterThan(8); const frameKinds = new Set(p.doorTypes!.map((d) => d.frameKind ?? d.kind)); diff --git a/src/model/sampleProjectComplex.ts b/src/model/sampleProjectComplex.ts index b467bde6..47e22692 100644 --- a/src/model/sampleProjectComplex.ts +++ b/src/model/sampleProjectComplex.ts @@ -16,6 +16,7 @@ import type { CeilingType, + ContextObject, Drawing2D, Drawing2DGeom, DoorType, @@ -35,6 +36,7 @@ import type { } from "./types"; import { sampleProject } from "./sampleProject"; import { withStandards } from "./standards"; +import { buildingsToMesh, type GeoFeature } from "../io/geoContext"; import { applyOps, type CoreOp } from "../core/ops"; import { withDocument } from "../core/document"; @@ -527,6 +529,26 @@ const isMainContour = (z: number) => Math.abs((z + 2.7) * 2 - Math.round((z + 2. // Parzelle (Kataster) mit Nachbarparzellen; Grenzabstände je Kante, Baulinie an der Strasse (Nord). const PARCEL = [P(-14, -12), P(28, -13), P(29, 23), P(-15, 24)]; +/** + * [207] Nachbargebäude (Kataster/swisstopo-Stil): ein Volumen-Netz auf der Klasse „12 Gebäude" ([181]), im Situationsplan + * grau (Schwarzplan: schwarz). Westen (Kat.-Nr. 2416, L-Form), Osten (2418, zwei Häuser), Norden jenseits des Musterwegs (nach Süden bleibt der Schnitt A-A ohne Fernkörper). + */ +function neighbours(): ContextObject { + const b = (pts: Vec2[], height: number): GeoFeature => ({ category: "building", pts, closed: true, height }); + const mesh = buildingsToMesh( + [ + b([P(-34, 0), P(-22, 0), P(-22, 9), P(-27, 9), P(-27, 14), P(-34, 14)], 7.5), + b([P(36, -6), P(46, -6), P(46, 4), P(36, 4)], 6.5), + b([P(36, 9), P(44, 9), P(44, 16), P(36, 16)], 6.5), + b([P(-8, 35), P(16, 35), P(16, 43), P(-8, 43)], 11), + b([P(22, 34), P(40, 34), P(40, 40), P(22, 40)], 9), + ], + "Kataster (fiktiv)", + ); + if (!mesh) throw new Error("Musterhaus komplex: Nachbargebäude nicht erzeugt"); + return { ...mesh, id: "nachbarn", name: "Nachbargebäude" }; +} + function cadastre(): Drawing2D[] { const d: Drawing2D[] = []; const add = (id: string, geom: Drawing2DGeom, extra: Partial = {}) => @@ -695,7 +717,10 @@ function addRooms(p: Project): Project { /** Sichtbarkeit je Kategorie: Ausschnitte listen jede sichtbare Kategorie ausdrücklich (fehlt = aus). */ const codesOf = (ls: LayerCategory[]): string[] => ls.flatMap((l) => [l.code, ...codesOf(l.children ?? [])]); const vis = (hidden: string[] = []): Record => Object.fromEntries(codesOf(LAYERS).map((c) => [c, !hidden.includes(c)])); -const ALL = vis(); +/** [207] Schnitte und Ansichten ohne die Nachbargebäude (Klasse „12 Gebäude"): sie weiten sonst den Ausschnitt weit über das Haus. */ +const NO_NEIGHBOURS = vis(["12"]); +/** [207] Klassen, die die Ansichtsvorlage „Situation WBW" ausblendet (`standards.rs::SITUATION_HIDDEN`; Test `sampleProjectComplex.situation.test.ts`). */ +const SITUATION_HIDDEN = ["00", "07", "20", "21", "22", "25", "30", "35", "40", "50", "60", "80", "81", "82", "85", "90", "91", "99"]; const LEVEL_VIS: Record = Object.fromEntries(LEVELS.map((l) => [l.id, true])); /** Grundrisse auf Blättern: ohne Kataster, Strasse, Höhenlinien und Gelände. */ const PLAN_VIS = vis(["01", "02", "10", "11", "13", "14"]); @@ -729,14 +754,15 @@ function views(): Pick ({ z, pts: contourAt(z), closed: false, layer: isMainContour(z) ? "HL-Haupt" : "HL" })), diff --git a/src/model/standards.test.ts b/src/model/standards.test.ts index 6d41ddaa..d3fd7c52 100644 --- a/src/model/standards.test.ts +++ b/src/model/standards.test.ts @@ -36,7 +36,7 @@ describe("Standard-Bibliothek ([100]–[102])", () => { expect(c.lineStyles).toBeGreaterThan(5); expect(c.wallTypes + c.ceilingTypes + c.roofTypes).toBe(5); expect(c.overrideRules).toBe(2); - expect(c.modelViewOptions).toBe(4); + expect(c.modelViewOptions).toBe(6); expect(standardsMergeCounts(standardsMergeOps(withStandards(empty)))).toEqual({ lineStyles: 0, hatches: 0, components: 0, wallTypes: 0, ceilingTypes: 0, roofTypes: 0, viewTemplates: 0, blockDefs: 0, overrideRules: 0, modelViewOptions: 0 }); }); diff --git a/src/model/types.generated.ts b/src/model/types.generated.ts index edddd884..ff731dcc 100644 --- a/src/model/types.generated.ts +++ b/src/model/types.generated.ts @@ -2152,6 +2152,11 @@ export type ModelViewOption = { roomStamps?: ModelViewRoomStamps; /** [173] Bemassung: Massketten der automatischen Aussenbemassung, Höhenkoten. */ dimensions?: ModelViewDimensions; + /** + * [207] Situationsplan / Schwarzplan: fehlt ⇒ gewöhnlicher Grundriss; vorhanden ⇒ statt der Bauteile das + * eigene Gebäude als gefüllter Umriss, die Kontextgebäude gefüllt, dazu Nordpfeil und Massstabsbalken. + */ + situation?: ModelViewSituation; }; /** [173] Dächer in der Modelldarstellung (fehlt ⇒ wie Basis). */ @@ -2196,6 +2201,23 @@ export type ModelViewSite = { terrain?: boolean; }; +/** + * [207] Situationsplan in der Modelldarstellung (≙ Schwarzplan): jede Option fehlt ⇒ Standard des + * Situationsplans (eigenes Gebäude schwarz, Kontext grau, mit Planzeichen). + */ +export type ModelViewSituation = { + /** + * Eigenes Gebäude: Umriss über alle Geschosse über Terrain und die Dächer, gefüllt (Basis: schwarz). + */ + own?: SituationFill; + /** + * Kontextgebäude (importierte Netze, Grundfläche aus der Aufsicht), gefüllt (Basis: grau; „Schwarzplan": schwarz). + */ + context?: SituationFill; + /** Nordpfeil und Massstabsbalken zeichnen (Basis: ja). */ + symbols?: boolean; +}; + /** [173] Decken und Böden in der Modelldarstellung. */ export type ModelViewSlabs = { /** Bodenbelag-Muster im Grundriss (die Ebene geht vor; Basis: automatisch). */ @@ -3454,6 +3476,9 @@ export type SiteRules = { profileHeight?: number; }; +/** [207] Füllung eines Gebäudes im Situationsplan. */ +export type SituationFill = "black" | "grey" | "off"; + /** Terminierungs-Regel einer Wand am Deckenanschluss (siehe {@link Wall.sliceTermination}). */ export type SliceTermination = "both" | "below" | "above"; diff --git a/src/plan/__golden__/komplex-ansicht-ansicht-sued.txt b/src/plan/__golden__/komplex-ansicht-ansicht-sued.txt index bc9eb9ee..3ed9d98f 100644 --- a/src/plan/__golden__/komplex-ansicht-ansicht-sued.txt +++ b/src/plan/__golden__/komplex-ansicht-ansicht-sued.txt @@ -1,12 +1,12 @@ -viewBox -4.2 0 37.045 18.478 -bytes 207135 +viewBox -25.5 0 81 18.478 +bytes 209902 circle 4 g 1 -line 495 +line 503 path 3 -polygon 998 -polyline 179 +polygon 1031 +polyline 184 rect 1 svg 1 text 4 -hash 7dd0774a2af69fe3 +hash d3224b3989291365 diff --git a/src/plan/__golden__/komplex-model3d.txt b/src/plan/__golden__/komplex-model3d.txt index b2960bc9..f70dbd0f 100644 --- a/src/plan/__golden__/komplex-model3d.txt +++ b/src/plan/__golden__/komplex-model3d.txt @@ -1,5 +1,5 @@ -meshes [1962] -meshes[].color [3] x1962 +meshes [1963] +meshes[].color [3] x1963 meshes[].indices [108] x6 meshes[].indices [1152] meshes[].indices [1248] x3 @@ -9,6 +9,7 @@ meshes[].indices [154014] meshes[].indices [1584] meshes[].indices [1716] meshes[].indices [180] +meshes[].indices [204] meshes[].indices [2376] meshes[].indices [31104] meshes[].indices [348] x6 @@ -25,6 +26,7 @@ meshes[].positions [1044] x6 meshes[].positions [108] x30 meshes[].positions [1188] meshes[].positions [120] +meshes[].positions [132] meshes[].positions [16428] meshes[].positions [180] x9 meshes[].positions [1890] x3 @@ -73,4 +75,4 @@ walls[].start [2] x1273 walls[].startCut [4] x873 walls[].topDrop [2] x115 walls[].topPlane [3] x271 -hash 5af7a0a70a5b3624 +hash 32750c509c57a271 diff --git a/src/plan/__golden__/komplex-schwarzplan-500.txt b/src/plan/__golden__/komplex-schwarzplan-500.txt new file mode 100644 index 00000000..2d609235 --- /dev/null +++ b/src/plan/__golden__/komplex-schwarzplan-500.txt @@ -0,0 +1,11 @@ +viewBox -41.5 0 95 63.6 +bytes 3579 +g 1 +line 3 +path 1 +polygon 10 +polyline 2 +rect 1 +svg 1 +text 8 +hash c546873f54a3e7ff diff --git a/src/plan/__golden__/komplex-situation-500.txt b/src/plan/__golden__/komplex-situation-500.txt new file mode 100644 index 00000000..2d609235 --- /dev/null +++ b/src/plan/__golden__/komplex-situation-500.txt @@ -0,0 +1,11 @@ +viewBox -41.5 0 95 63.6 +bytes 3579 +g 1 +line 3 +path 1 +polygon 10 +polyline 2 +rect 1 +svg 1 +text 8 +hash c546873f54a3e7ff diff --git a/src/plan/golden.test.ts b/src/plan/golden.test.ts index ab4e6d9d..8e9f5802 100644 --- a/src/plan/golden.test.ts +++ b/src/plan/golden.test.ts @@ -5,7 +5,7 @@ // und den Diff der Dateien im Commit ansehen. Zahlen sind gerundet (Plan 1e-3 m, 3D 1e-4 m). import { describe, expect, it } from "vitest"; import { createHash } from "node:crypto"; -import { computeSection, generateElevationPlan, generatePlan, generateSectionPlan, planToSvgString, projectToModel3d } from "../core"; +import { computeSection, generateElevationPlan, generatePlan, generateSectionPlan, planToSvgString, projectToModel3d, projectWithTemplate } from "../core"; import { sampleProject } from "../model/sampleProject"; import { buildComplexSampleProject } from "../model/sampleProjectComplex"; import type { Project } from "../model/types"; @@ -77,6 +77,18 @@ for (const [name, make] of projects) { } } + // [207] Situationsplan 1:500 (Ansichtsvorlage „Situation WBW") und Schwarzplan. + for (const [id, file] of [["std-vt-situation-wbw", "situation"], ["std-vt-schwarzplan", "schwarzplan"]]) { + it(`${file} 1:500`, async () => { + const tpl = p.viewTemplates?.find((t) => t.id === id); + if (!tpl) return; + const tp = projectWithTemplate(p, "eg", tpl); + const show = new Set([...codes].filter((c) => tpl.layerVisibility?.[c] !== false)); + const svg = planToSvgString(generatePlan(tp, "eg", show, undefined, tpl.detail ?? "grob", false, true, true, 500), { scaleDenominator: 500 }); + await expect(svgDigest(svg)).toMatchFileSnapshot(`__golden__/${name}-${file}-500.txt`); + }); + } + it("Schnitt", async () => { const sec = p.drawingLevels.find((l) => l.kind === "section"); if (!sec) return; diff --git a/src/plan/presentationSheet.test.ts b/src/plan/presentationSheet.test.ts index 5a8ddbdc..ede8d89d 100644 --- a/src/plan/presentationSheet.test.ts +++ b/src/plan/presentationSheet.test.ts @@ -78,7 +78,8 @@ describe("[66] Präsentationsplan", () => { st().undo(); expect((st().project.layouts ?? []).length).toBe(layoutsBefore); expect(st().project.viewSnapshots?.some((s) => s.id.startsWith("vs-pres-"))).toBe(false); - }); + // [207] 60 s: mit den Nachbargebäuden des Musterhauses rechnet das Blatt im Container knapp über die 30 s des Standards. + }, 60_000); it("gewählte Geschosse, ohne Ansichten/Schnitt, Skizze an, A3: kleinerer Massstab", () => { const floors = project.drawingLevels.filter((l) => l.kind === "floor" && !l.layoutId).slice(0, 2).map((l) => l.id); diff --git a/src/state/modelViews.test.ts b/src/state/modelViews.test.ts index cc38df5c..40ef4fe2 100644 --- a/src/state/modelViews.test.ts +++ b/src/state/modelViews.test.ts @@ -136,7 +136,7 @@ describe("modelViews", () => { it("[173] Etappe 3: Vorlagen aus den Standards übernehmen; wirken auf Raumstempel und Treppe", () => { const lib = standardModelViews(sampleProject); - expect(lib.map((m) => m.id)).toEqual(["std-mv-wettbewerb-200", "std-mv-baueingabe-100", "std-mv-ausfuehrung-50", "std-mv-rohbau"]); + expect(lib.map((m) => m.id)).toEqual(["std-mv-wettbewerb-200", "std-mv-baueingabe-100", "std-mv-ausfuehrung-50", "std-mv-situation-wbw", "std-mv-schwarzplan", "std-mv-rohbau"]); let p = applyOps(sampleProject, adoptModelViewOps(sampleProject, lib[2]!)); expect(p.modelViewOptions?.map((m) => m.id)).toEqual(["std-mv-ausfuehrung-50"]); expect(adoptModelViewOps(p, lib[2]!)).toEqual([]); diff --git a/src/state/modelViews.ts b/src/state/modelViews.ts index 361939c9..3ce6b969 100644 --- a/src/state/modelViews.ts +++ b/src/state/modelViews.ts @@ -34,7 +34,8 @@ export type ModelViewSection = | "site" | "sectionMarks" | "roomStamps" - | "dimensions"; + | "dimensions" + | "situation"; /** Ein Eintrag der Auswahl (Werkzeugleiste, Vorlage): eingebaute Stufen zuerst, dann die eigenen. */ export interface ModelViewChoice { @@ -216,6 +217,10 @@ export const MODEL_VIEW_FIELDS: readonly ModelViewField[] = [ { section: "roomStamps", key: "divider", values: "bool" }, { section: "dimensions", key: "chains", values: ["all", "outer", "total"] }, { section: "dimensions", key: "levelMarks", values: "bool" }, + // [207] Situationsplan/Schwarzplan: Füllung des eigenen Gebäudes und der Kontextgebäude, Nordpfeil + Massstabsbalken. + { section: "situation", key: "own", values: ["black", "grey", "off"] }, + { section: "situation", key: "context", values: ["black", "grey", "off"] }, + { section: "situation", key: "symbols", values: "bool" }, ]; /** Auswahlwert eines Feldes als Text (`""` = wie Basis); Gegenstück: {@link parseFieldValue}. */ diff --git a/src/ui/resourceManager/ModelViewsTab.tsx b/src/ui/resourceManager/ModelViewsTab.tsx index adb45ee2..b3769c6c 100644 --- a/src/ui/resourceManager/ModelViewsTab.tsx +++ b/src/ui/resourceManager/ModelViewsTab.tsx @@ -35,7 +35,7 @@ export interface ModelViewHandlers { onSetModelViewOption?: (id: string, section: ModelViewSection, key: string, value: string | number | boolean | null) => void; } -const SECTIONS: ModelViewSection[] = ["doors", "windows", "stairs", "walls", "slabs", "roofs", "columns", "elevation", "site", "sectionMarks", "roomStamps", "dimensions"]; +const SECTIONS: ModelViewSection[] = ["doors", "windows", "stairs", "walls", "slabs", "roofs", "columns", "elevation", "site", "sectionMarks", "roomStamps", "dimensions", "situation"]; /** Anzeige eines Auswahlwerts (Zahlen mit Einheit, Rest übersetzt). */ function valueLabel(f: ModelViewField, v: string | number): string {