[279] Geländer als eigenes Bauteil: Modell, Grundriss, Schnitt, Ansicht, 3D, 3D-Dokument, IFC IfcRailing, DXF-Ebene, Umbau und Varianten, Befehl gelaender, Objekt-Info, Griffe, Beispiel Wettbewerb
This commit is contained in:
103 files changed
+2289
-73
No files matched your search
@@ -59,6 +59,7 @@ Neues Modul: `<modul>.rs` und `mod` in `lib.rs`, Bindungen in `web/<modul>.rs` u
|
||||
| `wall_arc.rs` | Bogenwände |
|
||||
| `ring_arc.rs` | Bögen in Umriss-Ringen (Decke, Dach, Raum): feine Teilung, exakte Fläche, Bögen aus Wandkreisen ([191]) |
|
||||
| `roof.rs`, `roof_skeleton.rs`, `skeleton.rs`, `roof_assembly.rs`, `roof_parapet.rs`, `dormer.rs` | Dächer (Straight Skeleton), Dach an Dach, Attika (Flachdach-Brüstung), Gauben |
|
||||
| `railing.rs` | [279] Geländer als eigenes Bauteil: Prismen (Pfosten, Stäbe, Tafel, Handlauf) aus einer Quelle für 3D, Schnitt, Ansicht, 3D-Dokument, IFC; Tests in `railing_tests.rs` |
|
||||
| `stair.rs`, `stair_rail.rs`, `stair_guard.rs` | Treppen-Geometrie, Handlauf, Absturzsicherung am Deckenloch (Grundriss, 3D, IFC) |
|
||||
| `opening_geom.rs`, `opening_shape.rs`, `opening_detail.rs`, `opening_presets.rs`, `opening_preview.rs`, `opening_slide.rs` | Öffnungen: Symbol, Formen, Rahmen, Vorlagen, Vorschau, Verschieben in der Wand |
|
||||
| `room_area.rs`, `room_boundary.rs` | Raumflächen nach SIA 416; Raum-Erkennung aus Wänden |
|
||||
|
||||
@@ -999,6 +999,48 @@ fn tree_ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
|
||||
add_op("trees", vec![obj(f)])
|
||||
}
|
||||
|
||||
/// [279] Geländer über die Punkte `pts` (Polylinie, mindestens zwei verschiedene) auf dem aktiven Geschoss: Ebene „41"
|
||||
/// (Geländer), falls vorhanden, sonst die aktive. Art, Höhe (Vorgabe 1.00 m), Fusshöhe, Handlauf, Stababstand, Stabquerschnitt,
|
||||
/// Dicke und Bauteil aus den Werkzeug-Vorgaben; fehlende oder unsinnige Werte bleiben weg (Vorgaben aus `railing.rs`).
|
||||
/// `closed` mit mindestens drei Punkten schliesst den Zug.
|
||||
fn railing_ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
|
||||
let mut pts: Vec<V> = pts_of(v, "pts").into_iter().filter(|q| q.0.is_finite() && q.1.is_finite()).collect();
|
||||
pts.dedup_by(|a, b| (a.0 - b.0).abs() < 1e-6 && (a.1 - b.1).abs() < 1e-6);
|
||||
if pts.len() < 2 {
|
||||
return Vec::new();
|
||||
}
|
||||
let pos = |k: &str| opt_n(v, k).filter(|x| *x > 0.0 && x.is_finite());
|
||||
let kind = ["bars", "glass", "solid", "perforated"].into_iter().find(|a| *a == s_of(v, "kind")).unwrap_or("bars");
|
||||
let mut f = vec![
|
||||
("id", s(&ids.next("railing"))),
|
||||
("type", s("railing")),
|
||||
("floorId", s(ctx.level)),
|
||||
("categoryCode", category_or(p, crate::railing::CATEGORY, ctx)),
|
||||
("points", pvs(&pts)),
|
||||
("height", js_num(pos("height").unwrap_or(crate::railing::DEFAULT_HEIGHT))),
|
||||
("kind", s(kind)),
|
||||
];
|
||||
if v.get("closed").and_then(Value::as_bool) == Some(true) && pts.len() >= 3 {
|
||||
f.push(("closed", Value::Bool(true)));
|
||||
}
|
||||
if let Some(b) = opt_n(v, "baseOffset").filter(|x| x.is_finite() && *x != 0.0) {
|
||||
f.push(("baseOffset", js_num(b)));
|
||||
}
|
||||
if let Some(h) = v.get("handrail").and_then(Value::as_bool) {
|
||||
f.push(("handrail", Value::Bool(h)));
|
||||
}
|
||||
for k in ["barSpacing", "barSize", "thickness", "handrailSize"] {
|
||||
if let Some(x) = pos(k) {
|
||||
f.push((k, js_num(x)));
|
||||
}
|
||||
}
|
||||
let comp = s_of(v, "componentId");
|
||||
if kind == "solid" && !comp.is_empty() {
|
||||
f.push(("componentId", s(comp)));
|
||||
}
|
||||
add_op("railings", vec![obj(f)])
|
||||
}
|
||||
|
||||
/// [149] „Kreise in Bäume umwandeln": die gewählten Kreise (`ids`), sonst alle Kreise der Baum-Ebene auf der
|
||||
/// aktiven Ebene, werden Baum-Objekte (Kronendurchmesser = Kreisdurchmesser, Höhe = `sunStudy.treeHeight`
|
||||
/// bzw. Vorgabe, Ebene und Geschoss des Kreises); die Kreise entfallen. Ein Undo-Schritt.
|
||||
@@ -1156,6 +1198,7 @@ pub fn ops(root: &Map<String, Value>, p: &Project, v: &Value) -> Option<Vec<Op>>
|
||||
"roof" => roof_ops(p, v, &ctx, ids),
|
||||
"column" => column_ops(v, &ctx, ids),
|
||||
"tree" => tree_ops(p, v, &ctx, ids),
|
||||
"railing" => railing_ops(p, v, &ctx, ids),
|
||||
"circlesToTrees" => circles_to_trees_ops(root, p, v, &ctx, ids),
|
||||
"extrude" => extrude_ops(root, v, &ctx, ids),
|
||||
// [222] Volumenstudie → Bauteile.
|
||||
|
||||
@@ -20,7 +20,7 @@ use std::collections::HashMap;
|
||||
|
||||
/// Listen der Zwischenablage: (Schlüssel in `clip`, Projekt-Liste, id-Präfix, Geschoss-Feld).
|
||||
/// Reihenfolge = Reihenfolge der ids und der Ops (Wände vor Öffnungen).
|
||||
const LISTS: [(&str, &str, &str, &str); 11] = [
|
||||
const LISTS: [(&str, &str, &str, &str); 12] = [
|
||||
("walls", "walls", "W", "floorId"),
|
||||
("drawings", "drawings2d", "dr2d", "levelId"),
|
||||
("ceilings", "ceilings", "C", "floorId"),
|
||||
@@ -31,6 +31,7 @@ const LISTS: [(&str, &str, &str, &str); 11] = [
|
||||
("extrudedSolids", "extrudedSolids", "extrude", "levelId"),
|
||||
("columns", "columns", "column", "floorId"),
|
||||
("trees", "trees", "tree", "floorId"),
|
||||
("railings", "railings", "railing", "floorId"),
|
||||
("cameras", "cameras", "camera", "floorId"),
|
||||
];
|
||||
|
||||
|
||||
@@ -307,6 +307,11 @@ fn mv_tree(t: &Value, xf: &Xf) -> Value {
|
||||
with(t, "position", pt(n.0, n.1))
|
||||
}
|
||||
|
||||
/// [279] Geländer: alle Punkte der Achse werden abgebildet (Höhe, Dicke und Teilung bleiben).
|
||||
fn mv_railing(r: &Value, xf: &Xf) -> Value {
|
||||
with(r, "points", xf.pts(field(r, "points")))
|
||||
}
|
||||
|
||||
/// [213] Kamera: Standpunkt und Ziel werden abgebildet (Drehen dreht beide um den Drehpunkt, Spiegeln spiegelt
|
||||
/// beide); Augenhöhe, Zielhöhe, Bildwinkel und Sichthöhe bleiben (Skalieren: Abstand Standpunkt–Ziel skaliert mit).
|
||||
fn mv_camera(c: &Value, xf: &Xf) -> Value {
|
||||
@@ -722,6 +727,8 @@ pub struct Sel {
|
||||
pub opening_ids: Option<Vec<String>>,
|
||||
/// [149] Gewählte Bäume.
|
||||
pub tree_ids: Option<Vec<String>>,
|
||||
/// [279] Gewählte Geländer (alle Punkte der Achse werden transformiert).
|
||||
pub railing_ids: Option<Vec<String>>,
|
||||
/// [213] Gewählte Kameras (Standpunkt und Ziel werden transformiert).
|
||||
pub camera_ids: Option<Vec<String>>,
|
||||
/// [193] Gewählte Gelände-/Umgebungs-Elemente (`Project.context`).
|
||||
@@ -781,6 +788,7 @@ enum Kind {
|
||||
Stair,
|
||||
Room,
|
||||
Tree,
|
||||
Railing,
|
||||
Camera,
|
||||
Context,
|
||||
}
|
||||
@@ -818,6 +826,7 @@ fn gather<'a>(root: &'a Map<String, Value>, sel: &Sel, op: &str, ignore_lock: bo
|
||||
each("stairs", Ids::opt(&sel.stair_ids), Kind::Stair);
|
||||
each("rooms", Ids::opt(&sel.room_ids), Kind::Room);
|
||||
each("trees", Ids::opt(&sel.tree_ids), Kind::Tree);
|
||||
each("railings", Ids::opt(&sel.railing_ids), Kind::Railing);
|
||||
each("cameras", Ids::opt(&sel.camera_ids), Kind::Camera);
|
||||
each("context", Ids::opt(&sel.context_ids), Kind::Context);
|
||||
out
|
||||
@@ -1005,6 +1014,10 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
|
||||
if !trees.is_empty() {
|
||||
patch("trees", &|t| trees.has(t) && !locked(t), &|t| mv_tree(t, &xf));
|
||||
}
|
||||
let railings = Ids::opt(&sel.railing_ids);
|
||||
if !railings.is_empty() {
|
||||
patch("railings", &|t| railings.has(t) && !locked(t), &|t| mv_railing(t, &xf));
|
||||
}
|
||||
let cams = Ids::opt(&sel.camera_ids);
|
||||
if !cams.is_empty() {
|
||||
patch("cameras", &|c| cams.has(c) && !locked(c), &|c| mv_camera(c, &xf));
|
||||
@@ -1029,7 +1042,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
|
||||
|
||||
// Kopien (Kopie/Reihe/Verteilen bzw. gespiegelte Kopie).
|
||||
let mut ids = IdGen::new(&req.stamp);
|
||||
let mut new: [Vec<Value>; 11] = Default::default();
|
||||
let mut new: [Vec<Value>; 12] = Default::default();
|
||||
let mut new_openings = Vec::new();
|
||||
// [213] Namen der vorhandenen Kameras (Kopien heissen „… Kopie“, nummeriert bei Kollision).
|
||||
let mut cam_names: std::collections::HashSet<String> = list(root, "cameras").iter().filter_map(|c| field(c, "name").and_then(Value::as_str).map(String::from)).collect();
|
||||
@@ -1047,6 +1060,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
|
||||
Kind::Stair => "ST",
|
||||
Kind::Room => "RM",
|
||||
Kind::Tree => "tree",
|
||||
Kind::Railing => "railing",
|
||||
Kind::Camera => "camera",
|
||||
Kind::Context => "ctx",
|
||||
})
|
||||
@@ -1074,6 +1088,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
|
||||
Kind::Stair => (6, mv_stair(e, &xf, k_at(t))),
|
||||
Kind::Room => (7, mv_room(e, &xf)),
|
||||
Kind::Tree => (8, mv_tree(e, &xf)),
|
||||
Kind::Railing => (11, mv_railing(e, &xf)),
|
||||
Kind::Camera => (10, mv_camera(e, &xf)),
|
||||
Kind::Context => (9, mv_context(e, &xf)),
|
||||
};
|
||||
@@ -1102,7 +1117,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
|
||||
}
|
||||
}
|
||||
}
|
||||
let keys = ["walls", "drawings2d", "extrudedSolids", "columns", "ceilings", "roofs", "stairs", "rooms", "trees", "context", "cameras"];
|
||||
let keys = ["walls", "drawings2d", "extrudedSolids", "columns", "ceilings", "roofs", "stairs", "rooms", "trees", "context", "cameras", "railings"];
|
||||
for (key, items) in keys.iter().zip(new) {
|
||||
ops.extend(add(key, items));
|
||||
}
|
||||
@@ -1418,6 +1433,7 @@ fn item_preview(p: &Project, kind: Kind, e: &Value, xf: &Xf, out: &mut Pending)
|
||||
let ring: Vec<(f64, f64)> = crate::tree::circle([c.0, c.1], d / 2.0, 24).into_iter().map(|q| (q[0], q[1])).collect();
|
||||
s.poly(&ring);
|
||||
}
|
||||
Kind::Railing => s.poly_open(&mapped(&pts_of(field(e, "points")), xf)),
|
||||
Kind::Camera => {
|
||||
// [213] Gehäuse am neuen Standpunkt und die Blicklinie zum neuen Ziel.
|
||||
let (px, py) = pt("position");
|
||||
|
||||
@@ -53,7 +53,7 @@ pub fn ops(root: &Map<String, Value>, p: &Project, text: &str) -> Result<Vec<Op>
|
||||
}
|
||||
|
||||
/// Listen, deren neue Elemente den Zeichen-Status bekommen ([271]).
|
||||
const RENOVATION_COLLECTIONS: [&str; 8] = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms"];
|
||||
const RENOVATION_COLLECTIONS: [&str; 9] = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms", "railings"];
|
||||
|
||||
/// [271] Neue Bauteile der Ops (`add` in [`RENOVATION_COLLECTIONS`]) erhalten `renovation` (ein Objekt mit gültigem
|
||||
/// `status`), sofern sie keines tragen; sonst unverändert.
|
||||
|
||||
@@ -13,7 +13,7 @@ use serde_json::{json, Map, Value};
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
|
||||
/// Listen, deren Elemente eine Variante tragen können (Wurzel-Schlüssel).
|
||||
pub const COLLECTIONS: [&str; 9] = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms", "drawings2d"];
|
||||
pub const COLLECTIONS: [&str; 10] = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms", "drawings2d", "railings"];
|
||||
|
||||
/// Höchstens so viele Kombinationen im Vergleich (Kreuzprodukt der Sätze).
|
||||
pub const MAX_COMPARE: usize = 24;
|
||||
@@ -54,6 +54,7 @@ pub fn active(p: &Project) -> bool {
|
||||
|| p.roofs.iter().flatten().any(|x| known(x.design_option.as_ref()))
|
||||
|| p.stairs.iter().flatten().any(|x| known(x.design_option.as_ref()))
|
||||
|| p.columns.iter().flatten().any(|x| known(x.design_option.as_ref()))
|
||||
|| p.railings.iter().flatten().any(|x| known(x.design_option.as_ref()))
|
||||
|| p.extruded_solids.iter().flatten().any(|x| known(x.design_option.as_ref()))
|
||||
|| p.rooms.iter().flatten().any(|x| known(x.design_option.as_ref()))
|
||||
|| p.drawings2d.iter().any(|x| known(x.design_option.as_ref()))
|
||||
@@ -180,7 +181,7 @@ impl Combination {
|
||||
}
|
||||
)*};
|
||||
}
|
||||
each!(ceilings, roofs, stairs, columns, extruded_solids, rooms);
|
||||
each!(ceilings, roofs, stairs, columns, extruded_solids, rooms, railings);
|
||||
for d in &p.drawings2d {
|
||||
if !self.shows(d.design_option.as_ref()) {
|
||||
out.insert(d.id.clone());
|
||||
@@ -268,7 +269,7 @@ impl Edit {
|
||||
}
|
||||
)*};
|
||||
}
|
||||
each!(ceilings, roofs, stairs, columns, extruded_solids, rooms);
|
||||
each!(ceilings, roofs, stairs, columns, extruded_solids, rooms, railings);
|
||||
out
|
||||
}
|
||||
|
||||
@@ -743,6 +744,7 @@ pub fn info(p: &Project) -> Value {
|
||||
p.roofs.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
|
||||
p.stairs.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
|
||||
p.columns.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
|
||||
p.railings.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
|
||||
p.extruded_solids.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
|
||||
p.rooms.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
|
||||
p.drawings2d.iter().for_each(|x| add(x.design_option.as_ref()));
|
||||
|
||||
@@ -51,6 +51,9 @@ impl<'a> Explode<'a> {
|
||||
for t in p.trees.as_deref().unwrap_or(&[]) {
|
||||
floor_of.insert(&t.id, &t.floor_id);
|
||||
}
|
||||
for t in p.railings.as_deref().unwrap_or(&[]) {
|
||||
floor_of.insert(&t.id, &t.floor_id);
|
||||
}
|
||||
// [137] Freie Körper (Pick, Hervorhebung) folgen ihrem Geschoss.
|
||||
for s in p.extruded_solids.as_deref().unwrap_or(&[]) {
|
||||
floor_of.insert(&s.id, &s.level_id);
|
||||
@@ -167,6 +170,7 @@ pub fn parts_filtered(p: &Project, layered: bool, detail: f64, for_section: bool
|
||||
let pick = |fid: &str| ex.in_group(fid, g);
|
||||
q.columns = p.columns.as_ref().map(|v| v.iter().filter(|c| pick(&c.floor_id)).cloned().collect());
|
||||
q.trees = p.trees.as_ref().map(|v| v.iter().filter(|t| pick(&t.floor_id)).cloned().collect());
|
||||
q.railings = p.railings.as_ref().map(|v| v.iter().filter(|t| pick(&t.floor_id)).cloned().collect());
|
||||
q.stairs = p.stairs.as_ref().map(|v| v.iter().filter(|s| pick(&s.floor_id)).cloned().collect());
|
||||
q.roofs = p.roofs.as_ref().map(|v| v.iter().filter(|r| pick(&r.floor_id)).cloned().collect());
|
||||
q.openings = p.openings.as_ref().map(|v| v.iter().filter(|o| filter.keep_opening(o) && pick(ex.floor_of.get(o.id.as_str()).copied().unwrap_or(""))).cloned().collect());
|
||||
@@ -177,6 +181,7 @@ pub fn parts_filtered(p: &Project, layered: bool, detail: f64, for_section: bool
|
||||
};
|
||||
out.column_meshes.extend(shifted(kept(&q, model3d::emit_columns(&q)), dz, shift_mesh));
|
||||
out.column_meshes.extend(shifted(kept(&q, model3d::emit_trees(&q)), dz, shift_mesh));
|
||||
out.column_meshes.extend(shifted(kept(&q, model3d::emit_railings(&q)), dz, shift_mesh));
|
||||
out.stair_meshes.extend(shifted(kept(&q, model3d::emit_stair_meshes(&q)), dz, shift_mesh));
|
||||
// Handläufe folgen der Treppe, die Absturzsicherung der Decke mit dem Loch (Geschoss `g`, [155]).
|
||||
out.stair_railings.extend(shifted(kept(&q, model3d::emit_stair_handrails(&q)), dz, shift_mesh));
|
||||
@@ -283,6 +288,12 @@ pub fn pick_geometry(p: &Project, gap: f64) -> Result<PickGeometry, String> {
|
||||
v[1] += dz;
|
||||
}
|
||||
}
|
||||
for t in &mut g.railings {
|
||||
let dz = ex.of(&t.railing_id);
|
||||
for v in t.tris.iter_mut().flatten() {
|
||||
v[1] += dz;
|
||||
}
|
||||
}
|
||||
for o in &mut g.opening_meshes {
|
||||
let dz = ex.of(&o.opening_id);
|
||||
for v in o.tris.iter_mut().flatten() {
|
||||
|
||||
@@ -118,6 +118,9 @@ pub fn translate_project(p: &Project, dx: f64, dy: f64) -> Project {
|
||||
for t in out.trees.iter_mut().flatten() {
|
||||
t.position = shift(t.position, dx, dy);
|
||||
}
|
||||
for r in out.railings.iter_mut().flatten() {
|
||||
shift_all(&mut r.points, dx, dy);
|
||||
}
|
||||
for c in out.cameras.iter_mut().flatten() {
|
||||
c.position = shift(c.position, dx, dy);
|
||||
c.target = shift(c.target, dx, dy);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
use serde_json::{json, Map, Value};
|
||||
|
||||
/// Projekt-Listen, die verschoben werden (jedes Element hat eine `id`), in Op-Reihenfolge.
|
||||
pub const TRANSLATED_LISTS: [&str; 12] = ["walls", "ceilings", "roofs", "stairs", "rooms", "columns", "extrudedSolids", "drawings2d", "context", "drawingLevels", "trees", "cameras"];
|
||||
pub const TRANSLATED_LISTS: [&str; 13] = ["walls", "ceilings", "roofs", "stairs", "rooms", "columns", "extrudedSolids", "drawings2d", "context", "drawingLevels", "trees", "cameras", "railings"];
|
||||
|
||||
fn shift(p: &Value, dx: f64, dy: f64) -> Value {
|
||||
let c = |k: &str| p.get(k).and_then(Value::as_f64).unwrap_or(f64::NAN);
|
||||
@@ -164,6 +164,7 @@ fn shift_element(key: &str, e: &Value, dx: f64, dy: f64) -> (Value, bool) {
|
||||
}
|
||||
"columns" => shift_pts_fields(&mut m, &["position"], dx, dy, &[]),
|
||||
"trees" => shift_pts_fields(&mut m, &["position"], dx, dy, &[]),
|
||||
"railings" => shift_pts_fields(&mut m, &[], dx, dy, &["points"]),
|
||||
"cameras" => shift_pts_fields(&mut m, &["position", "target"], dx, dy, &[]),
|
||||
"extrudedSolids" => {
|
||||
shift_pts_fields(&mut m, &[], dx, dy, &["points"]);
|
||||
|
||||
@@ -23,10 +23,12 @@ pub struct Membership {
|
||||
pub tree_ids: Vec<String>,
|
||||
/// [213] Kameras.
|
||||
pub camera_ids: Vec<String>,
|
||||
/// [279] Geländer.
|
||||
pub railing_ids: Vec<String>,
|
||||
}
|
||||
|
||||
/// Elementart (`MemberKind` in TS: `"wallIds"` …).
|
||||
pub const KINDS: [&str; 10] = ["wallIds", "drawingIds", "ceilingIds", "roomIds", "stairIds", "columnIds", "roofIds", "openingIds", "treeIds", "cameraIds"];
|
||||
pub const KINDS: [&str; 11] = ["wallIds", "drawingIds", "ceilingIds", "roomIds", "stairIds", "columnIds", "roofIds", "openingIds", "treeIds", "cameraIds", "railingIds"];
|
||||
|
||||
impl Membership {
|
||||
pub fn list(&self, kind: &str) -> Option<&Vec<String>> {
|
||||
@@ -41,6 +43,7 @@ impl Membership {
|
||||
"openingIds" => &self.opening_ids,
|
||||
"treeIds" => &self.tree_ids,
|
||||
"cameraIds" => &self.camera_ids,
|
||||
"railingIds" => &self.railing_ids,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
@@ -57,6 +60,7 @@ impl Membership {
|
||||
"openingIds" => &mut self.opening_ids,
|
||||
"treeIds" => &mut self.tree_ids,
|
||||
"cameraIds" => &mut self.camera_ids,
|
||||
"railingIds" => &mut self.railing_ids,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
@@ -73,6 +77,7 @@ impl Membership {
|
||||
opening_ids: g.opening_ids.clone(),
|
||||
tree_ids: g.tree_ids.clone().unwrap_or_default(),
|
||||
camera_ids: g.camera_ids.clone().unwrap_or_default(),
|
||||
railing_ids: g.railing_ids.clone().unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,9 @@ pub struct Args {
|
||||
pub solids: Vec<String>,
|
||||
/// [149] Bäume (Umriss-Prisma Kronendurchmesser × Fuss bis Spitze).
|
||||
pub trees: Vec<String>,
|
||||
/// [279] Geländer (Umriss-Prisma über der Achse, Fuss bis Oberkante).
|
||||
#[serde(default)]
|
||||
pub railings: Vec<String>,
|
||||
pub rgb: [f64; 3],
|
||||
/// Explosionsabstand ([65], `explode3d.rs`; fehlt/0 = aus): Linien folgen dem auseinandergezogenen Modell.
|
||||
#[serde(default)]
|
||||
@@ -274,6 +277,21 @@ pub fn selection_highlight_lines(p: &Project, a: &Args) -> Result<Vec<f32>, Stri
|
||||
}
|
||||
}
|
||||
}
|
||||
let railings = set(&a.railings);
|
||||
if !railings.is_empty() {
|
||||
for r in p.railings.as_deref().unwrap_or(&[]) {
|
||||
let (Some(s), Some(ax)) = (crate::railing::spec(p, r), crate::railing::axis(r)) else { continue };
|
||||
if railings.contains(r.id.as_str()) {
|
||||
let n = out.v.len();
|
||||
// Umriss der Achse mit Handlaufbreite, Fuss bis Oberkante.
|
||||
let (quads, _, _) = crate::railing::strips(&ax, s.rail_w().max(s.thickness) / 2.0);
|
||||
for q in quads {
|
||||
out.prism_edges(&q, s.z0, s.top());
|
||||
}
|
||||
lift(&mut out, n, &r.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
for s in p.extruded_solids.as_deref().unwrap_or(&[]) {
|
||||
if solids.contains(s.id.as_str()) {
|
||||
let n = out.v.len();
|
||||
|
||||
@@ -58,6 +58,7 @@ const REC_SPACE_ARC: f64 = 22.0;
|
||||
const REC_GUIDS: f64 = 23.0;
|
||||
const REC_CONTEXT: f64 = 24.0;
|
||||
const REC_LAYERS: f64 = 25.0;
|
||||
const REC_RAILING: f64 = 26.0;
|
||||
|
||||
/// Toleranz des Kerns (`wall_bands.rs::EPS`) für „Öffnung trifft Band".
|
||||
const BAND_EPS: f64 = 1e-4;
|
||||
@@ -978,6 +979,8 @@ enum Kind {
|
||||
Slab,
|
||||
Roof,
|
||||
Column,
|
||||
/// [279] Geländer.
|
||||
Railing,
|
||||
Stair,
|
||||
Window,
|
||||
Door,
|
||||
@@ -989,7 +992,7 @@ enum Kind {
|
||||
/// eBKP-H-Hauptgruppe zur Bauteilart, oder `None` (Tür, Raum: nicht eindeutig).
|
||||
fn ebkph_group(k: Kind) -> Option<(&'static str, &'static str)> {
|
||||
match k {
|
||||
Kind::Wall | Kind::Slab | Kind::Column | Kind::Stair => Some(("C", "Konstruktion Gebäude")),
|
||||
Kind::Wall | Kind::Slab | Kind::Column | Kind::Railing | Kind::Stair => Some(("C", "Konstruktion Gebäude")),
|
||||
Kind::Roof => Some(("F", "Bedachung Gebäude")),
|
||||
Kind::Window => Some(("E", "Äussere Wandbekleidung Gebäude")),
|
||||
Kind::Door | Kind::Space | Kind::Context => None,
|
||||
@@ -1874,6 +1877,50 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
w_mesh(&mut f, &positions, &indices, false);
|
||||
}
|
||||
|
||||
// ── [279] Geländer → IfcRailing (GUARDRAIL; HANDRAIL, wenn nur der Handlauf bleibt), Netz aus den Prismen ──
|
||||
for r in p.railings.as_deref().unwrap_or(&[]) {
|
||||
let (Some(s), Some(ax)) = (crate::railing::spec(&p, r), crate::railing::axis(r)) else { continue };
|
||||
let pieces = crate::railing::pieces(&p, r);
|
||||
let (mut positions, mut indices) = (Vec::new(), Vec::new());
|
||||
for q in &pieces {
|
||||
let (pp, ii) = crate::columns3d::prism(&q.outline, q.z0, q.z1);
|
||||
let at = (positions.len() / 3) as u32;
|
||||
positions.extend(pp);
|
||||
indices.extend(ii.into_iter().map(|k| k + at));
|
||||
}
|
||||
if indices.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let structure = structure_of(&r.floor_id);
|
||||
let base = base_of(structure);
|
||||
for z in positions.iter_mut().skip(2).step_by(3) {
|
||||
*z -= base;
|
||||
}
|
||||
classified.push((format!("railing/{}", r.id), Kind::Railing, r.category_code.clone()));
|
||||
let kind = match s.kind {
|
||||
RailingKind::Glass => "glass",
|
||||
RailingKind::Solid => "solid",
|
||||
RailingKind::Perforated => "perforated",
|
||||
_ => "bars",
|
||||
};
|
||||
let label = crate::railing::label(r);
|
||||
let mut psets = vec![Pset { name: "Pset_RailingCommon", props: vec![ident("Reference", &label)] }];
|
||||
renovation_props(&p, &mut psets, "Pset_RailingCommon", r.renovation.as_ref());
|
||||
psets.push(Pset { name: "Dossier_Railing", props: vec![ident("Kind", kind), ident("Handrail", if s.handrail { "yes" } else { "no" })] });
|
||||
let len = crate::railing::length(&ax);
|
||||
let q = vec![
|
||||
Qty { name: "Length", kind: QtyKind::Length, value: len },
|
||||
Qty { name: "Height", kind: QtyKind::Length, value: s.height },
|
||||
Qty { name: "NetSideArea", kind: QtyKind::Area, value: len * s.height },
|
||||
];
|
||||
psets.extend(qto("Dossier_Qto_Railing", q));
|
||||
let (id, name) = (f.str(&r.id), f.str(&label));
|
||||
let predefined = f.str("GUARDRAIL");
|
||||
f.nums(&[REC_RAILING, structure, id, name, predefined]);
|
||||
w_psets(&mut f, &psets);
|
||||
w_mesh(&mut f, &positions, &indices, false);
|
||||
}
|
||||
|
||||
// ── [259] Kontext (Option): Gelände und Nachbarn am IfcSite, Höhen absolut (Modell-z, ±0.00 = 0) ──
|
||||
if opt.context {
|
||||
for c in p.context.iter().flatten() {
|
||||
|
||||
@@ -22,6 +22,7 @@ pub mod roof_parapet;
|
||||
pub mod flat_read;
|
||||
pub mod sun;
|
||||
pub mod tree;
|
||||
pub mod railing;
|
||||
pub mod camera;
|
||||
pub mod site_rules;
|
||||
pub mod site_proof;
|
||||
|
||||
@@ -488,6 +488,15 @@ pub(crate) fn collect_scene(src: &Project, opt: &MeshOptions) -> Result<SceneDat
|
||||
groups.push(g);
|
||||
}
|
||||
p.trees = trees;
|
||||
// [279] Geländer: je Geländer eine Gruppe.
|
||||
let railings = p.railings.take();
|
||||
for r in railings.as_deref().unwrap_or(&[]) {
|
||||
let mut g = Group::new(format!("Gelaender_{}", sanitize_name(&r.id)), "railing", &r.id, level_of(Some(&r.floor_id)));
|
||||
p.railings = Some(vec![r.clone()]);
|
||||
add_meshes(&mut g, &mut mats, &model3d::emit_railings(&p), "Gelaender");
|
||||
groups.push(g);
|
||||
}
|
||||
p.railings = railings;
|
||||
let stairs = p.stairs.take();
|
||||
for st in stairs.as_deref().unwrap_or(&[]) {
|
||||
let mut g = Group::new(format!("Treppe_{}", sanitize_name(&st.id)), "stair", &st.id, level_of(Some(&st.floor_id)));
|
||||
|
||||
@@ -5560,6 +5560,107 @@ pub struct Tree {
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// Art der Füllung eines Geländers ([279]): Stäbe (Rundstahl/Flachstahl, lotrecht), Glas (Ganzglas-Brüstung),
|
||||
/// massive Brüstung (Mauer/Beton) oder Lochblech.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
pub enum RailingKind {
|
||||
/// Stäbe mit Pfosten, Handlauf und Fussschiene.
|
||||
#[default]
|
||||
#[serde(rename = "bars")]
|
||||
Bars,
|
||||
/// Glasscheibe (durchsichtig) mit Handlauf.
|
||||
#[serde(rename = "glass")]
|
||||
Glass,
|
||||
/// Massive Brüstung (Wand-ähnlich, mit Bauteil-Füllung im Schnitt).
|
||||
#[serde(rename = "solid")]
|
||||
Solid,
|
||||
/// Lochblech (Blechtafel).
|
||||
#[serde(rename = "perforated")]
|
||||
Perforated,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// Ein Geländer ([279]) — eigenes Bauteil für Balkon, Galerie, Treppenauge und Terrasse (Absturzsicherung,
|
||||
/// Vorgabe 1.00 m nach SIA 358): Polylinie `points` auf einem Geschoss, Höhe, Art der Füllung, Handlauf. Grundriss
|
||||
/// (Linie bzw. Doppellinie je Art), Schnitt/Ansicht (Stäbe, Glasfläche, Brüstung), 3D, IFC (`IfcRailing`).
|
||||
/// Fusshöhe = Geschoss-UK + `baseOffset` (z. B. auf einer Balkonplatte).
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct Railing {
|
||||
pub id: String,
|
||||
#[ts(type = "\"railing\"")]
|
||||
pub r#type: String,
|
||||
/// Zugehörige Zeichnungsebene (Geschoss).
|
||||
#[serde(rename = "floorId")]
|
||||
pub floor_id: String,
|
||||
/// Grafik-Kategorie (Ebene), Vorgabe "55" (Geländer).
|
||||
#[serde(rename = "categoryCode")]
|
||||
pub category_code: String,
|
||||
/// IFC-GlobalId des Quell-Bauteils (IFC-Import/Rundreise).
|
||||
#[serde(rename = "ifcGlobalId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub ifc_global_id: Option<String>,
|
||||
/// Objekt-Sperre, analog `Wall.locked`.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub locked: Option<bool>,
|
||||
/// Achse des Geländers (Polylinie im Grundriss, Meter, mindestens 2 Punkte).
|
||||
pub points: Vec<Vec2>,
|
||||
/// Geschlossener Zug (Treppenauge, Galerie ringsum); fehlt = offen.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub closed: Option<bool>,
|
||||
/// Höhe über dem Fuss bis Oberkante Handlauf bzw. Füllung (m, Vorgabe 1.00 nach SIA 358).
|
||||
pub height: f64,
|
||||
/// Fusshöhe relativ zur Geschoss-UK (m, Vorgabe 0), z. B. 0.18 auf einer Balkonplatte.
|
||||
#[serde(rename = "baseOffset", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub base_offset: Option<f64>,
|
||||
/// Art der Füllung.
|
||||
pub kind: RailingKind,
|
||||
/// Stäbe: Achsabstand der Stäbe (m, Vorgabe 0.12; lichtes Mass bleibt unter 12 cm).
|
||||
#[serde(rename = "barSpacing", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub bar_spacing: Option<f64>,
|
||||
/// Stäbe: Querschnitt (Kantenlänge bzw. Durchmesser, m, Vorgabe 0.014).
|
||||
#[serde(rename = "barSize", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub bar_size: Option<f64>,
|
||||
/// Dicke der Füllung (m): Glas (Vorgabe 0.02), Brüstung (Vorgabe 0.15), Lochblech (Vorgabe 0.004); bei Stäben ohne Wirkung.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub thickness: Option<f64>,
|
||||
/// Handlauf auf der Oberkante; fehlt = bei Stäben und Glas ja, sonst nein.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub handrail: Option<bool>,
|
||||
/// Handlauf: Durchmesser (m, Vorgabe 0.04).
|
||||
#[serde(rename = "handrailSize", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub handrail_size: Option<f64>,
|
||||
/// Optionales Bauteil (Component) für Füllung/Farbe, v. a. der massiven Brüstung.
|
||||
#[serde(rename = "componentId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub component_id: Option<String>,
|
||||
/// Optionale Übersteuerung der Strichfarbe; sonst gilt die Kategorie-Farbe.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub color: Option<String>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
/// [272] Variante, zu der das Element gehört. Fehlt ⇒ Hauptmodell (immer sichtbar).
|
||||
#[serde(rename = "designOption", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub design_option: Option<DesignOptionRef>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// Projektion einer Kamera ([213]): Perspektive, Axonometrie (Parallelprojektion mit schrägem Blick, z. B.
|
||||
/// Isometrie) oder Parallelprojektion (frei ausgerichtet). Axonometrie und Parallel zeichnen im 3D orthografisch.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
@@ -5660,6 +5761,10 @@ pub struct Group {
|
||||
#[serde(rename = "cameraIds", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub camera_ids: Option<Vec<String>>,
|
||||
/// [279] Geländer (fehlt in älteren Dateien).
|
||||
#[serde(rename = "railingIds", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub railing_ids: Option<Vec<String>>,
|
||||
/// Verschachtelte Gruppen (diese Gruppe enthält andere Gruppen als Ganzes).
|
||||
#[serde(rename = "groupIds")]
|
||||
pub group_ids: Vec<String>,
|
||||
@@ -7002,6 +7107,10 @@ pub struct Project {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub trees: Option<Vec<Tree>>,
|
||||
/// Geländer ([279]) — eigenes Bauteil (Balkon, Galerie, Treppenauge), siehe {@link Railing}. Optional.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub railings: Option<Vec<Railing>>,
|
||||
/// Kameras ([213]) — gespeicherte Standpunkte für 3D-Ansicht und Rendering, siehe {@link Camera}. Optional
|
||||
/// (Default: leer behandeln).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
@@ -7902,6 +8011,12 @@ impl Project {
|
||||
None => Default::default(),
|
||||
};
|
||||
}
|
||||
"railings" => {
|
||||
self.railings = match v {
|
||||
Some(v) => <Option<Vec<Railing>>>::deserialize(v).map_err(|e| e.to_string())?,
|
||||
None => Default::default(),
|
||||
};
|
||||
}
|
||||
"cameras" => {
|
||||
self.cameras = match v {
|
||||
Some(v) => <Option<Vec<Camera>>>::deserialize(v).map_err(|e| e.to_string())?,
|
||||
|
||||
@@ -37,6 +37,7 @@ impl Project {
|
||||
"extrudedSolids" => put_opt(&mut self.extruded_solids, i, v),
|
||||
"columns" => put_opt(&mut self.columns, i, v),
|
||||
"trees" => put_opt(&mut self.trees, i, v),
|
||||
"railings" => put_opt(&mut self.railings, i, v),
|
||||
"cameras" => put_opt(&mut self.cameras, i, v),
|
||||
"groups" => put_opt(&mut self.groups, i, v),
|
||||
"layouts" => put_opt(&mut self.layouts, i, v),
|
||||
|
||||
@@ -32,6 +32,8 @@ pub enum Owner {
|
||||
Roof(usize),
|
||||
Column(usize),
|
||||
Tree(usize),
|
||||
/// [279] Index in `Project::railings`.
|
||||
Railing(usize),
|
||||
Stair(usize),
|
||||
Context(usize),
|
||||
/// [115] Index in `Project::extruded_solids`.
|
||||
@@ -49,6 +51,7 @@ impl Owner {
|
||||
Owner::Roof(i) => at(&p.roofs, i).map(|e| e.id.as_str()),
|
||||
Owner::Column(i) => at(&p.columns, i).map(|e| e.id.as_str()),
|
||||
Owner::Tree(i) => at(&p.trees, i).map(|e| e.id.as_str()),
|
||||
Owner::Railing(i) => at(&p.railings, i).map(|e| e.id.as_str()),
|
||||
Owner::Stair(i) => at(&p.stairs, i).map(|e| e.id.as_str()),
|
||||
Owner::Context(i) => at(&p.context, i).map(|e| e.id()),
|
||||
Owner::Solid(i) => at(&p.extruded_solids, i).map(|e| e.id.as_str()),
|
||||
@@ -157,6 +160,9 @@ impl ClassFilter {
|
||||
for t in p.trees.as_deref().unwrap_or(&[]) {
|
||||
add(&t.category_code, &t.id, &t.floor_id);
|
||||
}
|
||||
for t in p.railings.as_deref().unwrap_or(&[]) {
|
||||
add(&t.category_code, &t.id, &t.floor_id);
|
||||
}
|
||||
for s in p.extruded_solids.as_deref().unwrap_or(&[]) {
|
||||
add(&s.category_code, &s.id, "");
|
||||
}
|
||||
@@ -187,6 +193,7 @@ impl ClassFilter {
|
||||
.chain(p.stairs.iter().flatten().map(|s| &s.id))
|
||||
.chain(p.columns.iter().flatten().map(|c| &c.id))
|
||||
.chain(p.trees.iter().flatten().map(|t| &t.id))
|
||||
.chain(p.railings.iter().flatten().map(|t| &t.id))
|
||||
.chain(p.extruded_solids.iter().flatten().map(|s| &s.id))
|
||||
.chain(p.drawings2d.iter().map(|d| &d.id))
|
||||
.chain(p.openings.iter().flatten().map(|o| &o.id));
|
||||
@@ -306,6 +313,7 @@ impl ClassFilter {
|
||||
g.stair_meshes.retain(|s| k(&s.stair_id));
|
||||
g.drawing_meshes.retain(|d| k(&d.drawing_id));
|
||||
g.trees.retain(|t| k(&t.tree_id));
|
||||
g.railings.retain(|t| k(&t.railing_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,6 +329,7 @@ pub fn parts_filtered(p: &Project, layered: bool, detail: f64, for_section: bool
|
||||
column_meshes: {
|
||||
let mut m = emit_columns(p);
|
||||
m.extend(emit_trees(p));
|
||||
m.extend(emit_railings(p));
|
||||
m
|
||||
},
|
||||
opening_meshes: emit_opening_meshes_with(p, detail, &|o| f.keep_opening(o)),
|
||||
|
||||
@@ -24,6 +24,7 @@ use crate::jsnum::round;
|
||||
mod ceilings;
|
||||
pub(crate) mod bearing;
|
||||
mod columns;
|
||||
mod railings;
|
||||
mod walls;
|
||||
mod wall_body;
|
||||
mod openings;
|
||||
@@ -39,6 +40,7 @@ mod arc_zone_tests;
|
||||
|
||||
pub use ceilings::*;
|
||||
pub use columns::*;
|
||||
pub use railings::*;
|
||||
pub use walls::*;
|
||||
pub use openings::*;
|
||||
pub use stairs::*;
|
||||
@@ -100,6 +102,8 @@ pub enum SlabSource {
|
||||
Stair { index: usize },
|
||||
/// [141] Index in `Project::columns` (Stützen-Prisma, je Höhenabschnitt von [`column_pieces`]).
|
||||
Column { index: usize },
|
||||
/// [279] Index in `Project::railings` (Prisma je Teil, `railing::pieces`).
|
||||
Railing { index: usize, fill: bool },
|
||||
}
|
||||
|
||||
/// Ein rohes Dreiecks-Mesh (`RMesh`).
|
||||
|
||||
@@ -48,6 +48,14 @@ pub struct PickColumn {
|
||||
pub column_id: String,
|
||||
}
|
||||
|
||||
/// [279] Geländer für den 3D-Pick.
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PickRailing {
|
||||
pub tris: Vec<Tri>,
|
||||
pub railing_id: String,
|
||||
}
|
||||
|
||||
/// [149] Baum für den 3D-Pick.
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@@ -115,6 +123,8 @@ pub struct PickGeometry {
|
||||
pub drawing_meshes: Vec<PickDrawingMesh>,
|
||||
/// [149] Bäume (Stamm + Krone).
|
||||
pub trees: Vec<PickTree>,
|
||||
/// [279] Geländer.
|
||||
pub railings: Vec<PickRailing>,
|
||||
}
|
||||
|
||||
/// Öffnungen als Quader (Laibung zu Laibung, Wanddicke, Brüstung bis Sturz) für Pick und Hervorhebung.
|
||||
@@ -275,6 +285,7 @@ pub fn pick_geometry(p: &Project) -> Result<PickGeometry, String> {
|
||||
stair_meshes: pick_stair_railings(p),
|
||||
drawing_meshes: pick_drawing_meshes(p, &HashMap::new()),
|
||||
trees: pick_trees(p),
|
||||
railings: pick_railings(p),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
//! [279] Geländer im 3D: Netze (`emit_railings`, im 3D bei den Stützen eingereiht), Platten für Schnitt, Ansicht und
|
||||
//! 3D-Dokument (`railing_slabs`, Herkunft `SlabSource::Railing`) und die Pick-Geometrie. Die Körper liefert
|
||||
//! `crate::railing::pieces` (lotrechte Prismen), eine Quelle für alle Ableitungen.
|
||||
|
||||
use super::*;
|
||||
use crate::railing::{self, Part, Piece};
|
||||
|
||||
/// Prismen der Teile `pieces` als ein Netz (Modell x, y, z).
|
||||
fn merge<'a>(pieces: impl Iterator<Item = &'a Piece>) -> Option<(Vec<f64>, Vec<u32>)> {
|
||||
let (mut positions, mut indices) = (Vec::new(), Vec::new());
|
||||
for q in pieces {
|
||||
if q.outline.len() < 3 || !(q.z1 - q.z0 > 1e-6) || !q.outline.iter().all(|v| v[0].is_finite() && v[1].is_finite()) {
|
||||
continue;
|
||||
}
|
||||
let (pp, ii) = crate::columns3d::prism(&q.outline, q.z0, q.z1);
|
||||
let base = (positions.len() / 3) as u32;
|
||||
positions.extend(pp);
|
||||
indices.extend(ii.into_iter().map(|i| i + base));
|
||||
}
|
||||
(!indices.is_empty()).then_some((positions, indices))
|
||||
}
|
||||
|
||||
/// Geländer als Netze: je Geländer die Tafel (Glas, Lochblech, Brüstung) und das Gestänge (Pfosten, Stäbe, Schienen,
|
||||
/// Handlauf) als eigene Netze mit eigener Farbe.
|
||||
pub fn emit_railings(p: &Project) -> Vec<RMesh> {
|
||||
let mut out = Vec::new();
|
||||
for (ri, r) in p.railings.as_deref().unwrap_or(&[]).iter().enumerate() {
|
||||
let pcs = railing::pieces(p, r);
|
||||
for fill in [true, false] {
|
||||
let Some((positions, indices)) = merge(pcs.iter().filter(|q| (q.part == Part::Fill) == fill)) else { continue };
|
||||
let color = railing::color(p, r, if fill { Part::Fill } else { Part::Rail });
|
||||
out.push(RMesh { crease_angle: None, positions, indices, kind: "extrusion", color, vertex_colors: None, material_index: None, owner: Owner::Railing(ri) });
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Geländer als lotrechte Prismen-Platten (Schnitt, Ansicht, 3D-Dokument), Herkunft `SlabSource::Railing`.
|
||||
pub fn railing_slabs(p: &Project) -> Vec<RSlab> {
|
||||
let mut out = Vec::new();
|
||||
for (index, r) in p.railings.as_deref().unwrap_or(&[]).iter().enumerate() {
|
||||
for q in railing::pieces(p, r) {
|
||||
if q.z1 - q.z0 > 1e-6 && q.outline.len() >= 3 {
|
||||
let color = railing::color(p, r, q.part);
|
||||
let fill = q.part == Part::Fill;
|
||||
out.push(RSlab { outline: q.outline, z_bottom: q.z0, z_top: q.z1, color, ceiling_id: r.id.clone(), hatch: None, cut: None, monolith: None, source: SlabSource::Railing { index, fill } });
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Geländer als Welt-Dreiecke für den 3D-Pick (wie [`emit_railings`]).
|
||||
pub fn pick_railings(p: &Project) -> Vec<PickRailing> {
|
||||
let mut out = Vec::new();
|
||||
for r in p.railings.as_deref().unwrap_or(&[]) {
|
||||
let pcs = railing::pieces(p, r);
|
||||
if let Some((pos, idx)) = merge(pcs.iter()) {
|
||||
let tris = extrusion_tris(&pos, &idx);
|
||||
if !tris.is_empty() {
|
||||
out.push(PickRailing { tris, railing_id: r.id.clone() });
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -417,7 +417,7 @@ impl Model3dCache {
|
||||
slabs,
|
||||
context_meshes: model3d::emit_context_meshes(p),
|
||||
solid_meshes: model3d::emit_solids(p),
|
||||
column_meshes: { let mut m = model3d::emit_columns(p); m.extend(model3d::emit_trees(p)); m },
|
||||
column_meshes: { let mut m = model3d::emit_columns(p); m.extend(model3d::emit_trees(p)); m.extend(model3d::emit_railings(p)); m },
|
||||
opening_meshes: Vec::new(),
|
||||
stair_meshes: model3d::emit_stair_meshes(p),
|
||||
stair_railings: model3d::emit_stair_railings(p),
|
||||
|
||||
@@ -26,6 +26,7 @@ Herkunft, kein Wegweiser.
|
||||
| `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 |
|
||||
| `railings.rs` | [279] Geländer im Grundriss (Linie/Doppellinie/Fläche je Art, über Schnitt gestrichelt, Pick `@railing:<id>`); Schnitt/Ansicht/Axo über die Platten `model3d::railing_slabs` |
|
||||
| `trees.rs` | Bäume in Grundriss, Schnitt und Ansicht; im Schnitt von näheren Bauteilen verdeckt (`occlude_in_section`, Verdecker `section::Output::occluders`), in der Ansicht Krone ohne Füllung vor der Fassade |
|
||||
| `cameras.rs` | [213] Kameras im Grundriss: Gehäuse, Sichtkegel, Ziel, Name, Pick-Bänder (Klasse „Kameras“) |
|
||||
| `stamp_place.rs` | Hindernisse für die Lage der Raumstempel |
|
||||
|
||||
@@ -676,6 +676,7 @@ pub fn axo_primitives(p: &Project, a: &AxoArgs, mono: bool) -> Result<Option<(Ve
|
||||
Kind::Mesh => *context_object_id = id,
|
||||
Kind::Slab if r.stair => *stair_id = id,
|
||||
Kind::Slab if r.column => *column_id = id,
|
||||
Kind::Slab if r.railing => *context_object_id = id.map(|i| crate::plan::railings::pick_id(&i)),
|
||||
Kind::Slab => *ceiling_id = id,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ pub const NOT_FOR_DRAWINGS: &[&str] = &[
|
||||
"units",
|
||||
"columns",
|
||||
"trees",
|
||||
"railings",
|
||||
"cameras",
|
||||
"extrudedSolids",
|
||||
// [157] `context` lesen die Zeichnungen: die Aussenbemassung rückt hinter die sichtbare Baugrube.
|
||||
|
||||
@@ -2012,6 +2012,8 @@ fn domains_before(c: &Ctx, out: &mut DomainPrims, bounds: &mut Bounds) -> Result
|
||||
super::wall_columns::hide_column_views(&mut out.columns, &filled(&out.walls, false));
|
||||
// [149] Bäume (Planzeichen) mit den Stützen in einer Gruppe.
|
||||
super::trees::plan_trees(c, &mut out.columns);
|
||||
// [279] Geländer mit den Stützen in einer Gruppe.
|
||||
super::railings::plan_railings(c, &mut out.columns);
|
||||
solids(c, &mut out.solids);
|
||||
// [271] Umbaufilter: Decken, Dächer, Treppen, Stützen und Körper in ihrer Umbau-Farbe (Wände: `plan_walls`).
|
||||
if c.renovation().is_some() {
|
||||
|
||||
@@ -787,6 +787,8 @@ struct Ids {
|
||||
opening: Option<String>,
|
||||
/// [271] Baum (Kronenumriss, Stamm): Id aus der Pick-Fläche `@tree:<id>`, den übrigen Teilen nachgetragen.
|
||||
tree: Option<String>,
|
||||
/// [279] Geländer (Pick-Fläche `@railing:<id>`, die übrigen Teile nachgetragen).
|
||||
railing: Option<String>,
|
||||
}
|
||||
|
||||
struct Entry {
|
||||
@@ -820,7 +822,10 @@ fn read_entry(part: &mut Part, i: usize, hatches: &[(i32, Hatch, i32)], text: Op
|
||||
6 => ids.room = Some(s),
|
||||
7 => ids.solid = Some(s),
|
||||
9 => ids.column = Some(s),
|
||||
8 => ids.tree = s.strip_prefix(crate::tree::TREE_PICK_PREFIX).map(str::to_string),
|
||||
8 => {
|
||||
ids.tree = s.strip_prefix(crate::tree::TREE_PICK_PREFIX).map(str::to_string);
|
||||
ids.railing = s.strip_prefix(crate::railing::PICK_PREFIX).map(str::to_string);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -1508,6 +1513,10 @@ fn renovation_layers(cx: &mut Ctx, cats: &[&LayerCategory]) -> HashMap<String, S
|
||||
for c in p.columns.iter().flatten() {
|
||||
items.push((&c.id, &c.category_code, crate::renovation::status_of(c.renovation.as_ref())));
|
||||
}
|
||||
// [279] Geländer.
|
||||
for c in p.railings.iter().flatten() {
|
||||
items.push((&c.id, &c.category_code, crate::renovation::status_of(c.renovation.as_ref())));
|
||||
}
|
||||
for o in p.openings.iter().flatten() {
|
||||
items.push((&o.id, &o.category_code, crate::renovation::status_of(crate::renovation::opening_renovation(p, o))));
|
||||
}
|
||||
@@ -1532,6 +1541,7 @@ fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code:
|
||||
let code_by_wall: HashMap<&str, &str> = project.walls.iter().map(|w| (w.id.as_str(), w.category_code.as_str())).collect();
|
||||
let code_by_drawing: HashMap<&str, &str> = project.drawings2d.iter().map(|d| (d.id.as_str(), d.category_code.as_str())).collect();
|
||||
let code_by_column: HashMap<&str, &str> = project.columns.iter().flatten().map(|c| (c.id.as_str(), c.category_code.as_str())).collect();
|
||||
let code_by_railing: HashMap<&str, &str> = project.railings.iter().flatten().map(|c| (c.id.as_str(), c.category_code.as_str())).collect();
|
||||
let code_by_room: HashMap<&str, &str> = project.rooms.iter().flatten().map(|r| (r.id.as_str(), r.category_code.as_str())).collect();
|
||||
let layer_of_code = |m: &HashMap<&str, &str>, id: &str| -> Option<String> { layer_by_code.get(m.get(id).copied().unwrap_or("")).cloned() };
|
||||
let drawing_layer = |id: Option<&String>, fallback: &str| -> String {
|
||||
@@ -1546,6 +1556,10 @@ fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code:
|
||||
if let Some(l) = e.ids.tree.as_ref().and_then(|id| ren_layer.get(id)) {
|
||||
return l.clone();
|
||||
}
|
||||
// [279] Teile eines Geländers: Status-Ebene bzw. Ebene der Klasse des Geländers.
|
||||
if let Some(r) = &e.ids.railing {
|
||||
return ren_layer.get(r).cloned().or_else(|| layer_of_code(&code_by_railing, r)).unwrap_or_else(|| LAYER_DEFAULT.to_string());
|
||||
}
|
||||
match e.tag {
|
||||
T_POLYGON => {
|
||||
if let Some(l) = e.ids.wall.as_ref().or(e.ids.column.as_ref()).and_then(|id| ren_layer.get(id)) {
|
||||
@@ -1755,6 +1769,25 @@ fn tag_tree_parts(entries: &mut [Entry]) {
|
||||
}
|
||||
}
|
||||
|
||||
/// [279] Geländer-Symbol (`plan/railings.rs`): Pick-Flächen `@railing:<id>` (je Teilstrecke eine), dann gefüllte Flächen
|
||||
/// (Brüstung, Pfosten) ohne Id und Linien (`railing-*`) — sie bekommen die Id des Geländers.
|
||||
fn tag_railing_parts(entries: &mut [Entry]) {
|
||||
let mut cur: Option<String> = None;
|
||||
for e in entries.iter_mut() {
|
||||
if e.ids.railing.is_some() {
|
||||
cur = e.ids.railing.clone();
|
||||
continue;
|
||||
}
|
||||
let part = matches!(&e.prim, Prim::Line { cls, .. } if cls.starts_with("railing-"));
|
||||
let bare = e.ids.wall.is_none() && e.ids.drawing.is_none() && e.ids.column.is_none() && e.ids.solid.is_none() && e.ids.room.is_none() && e.ids.opening.is_none() && e.ids.tree.is_none();
|
||||
if cur.is_some() && (part || bare && e.tag == T_POLYGON) {
|
||||
e.ids.railing = cur.clone();
|
||||
} else {
|
||||
cur = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Primitive der Abschnitte in Plan-Reihenfolge lesen (Texte gesetzt beim Massstab `scale`).
|
||||
fn read_entries(parts: &mut [Part], scale: f64, font: &str) -> Option<Vec<Entry>> {
|
||||
let mut entries: Vec<Entry> = Vec::new();
|
||||
@@ -1766,6 +1799,7 @@ fn read_entries(parts: &mut [Part], scale: f64, font: &str) -> Option<Vec<Entry>
|
||||
}
|
||||
}
|
||||
tag_tree_parts(&mut entries);
|
||||
tag_railing_parts(&mut entries);
|
||||
Some(entries)
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ pub(super) fn project_faces(frame: &[f64; 9], walls: &[RWall], slabs: &[RSlab],
|
||||
};
|
||||
let (id, fill) = match role {
|
||||
Role::Wall => (walls[f.src].wall_id.clone(), walls[f.src].color),
|
||||
Role::Slab | Role::Column | Role::Mesh | Role::Body => (slabs[f.src].ceiling_id.clone(), slabs[f.src].color),
|
||||
Role::Slab | Role::Column | Role::Railing | Role::Mesh | Role::Body => (slabs[f.src].ceiling_id.clone(), slabs[f.src].color),
|
||||
Role::Roof => (roofs[f.src].id.clone(), roofs[f.src].fill),
|
||||
};
|
||||
let pts = f.pts.iter().map(|q| [q.0, q.1]).collect();
|
||||
@@ -118,6 +118,16 @@ pub(super) fn collect_column_faces(p: &Project, frame: &[f64; 9]) -> Vec<Face> {
|
||||
faces
|
||||
}
|
||||
|
||||
/// [279] Geländer als lotrechte Prismen (Pfosten, Stäbe, Tafel, Handlauf wie im 3D, `model3d::railing_slabs`).
|
||||
pub(super) fn collect_railing_faces(p: &Project, frame: &[f64; 9]) -> Vec<Face> {
|
||||
let slabs = model3d::railing_slabs(p);
|
||||
let mut faces = project_faces(frame, &[], &slabs, &[]);
|
||||
for f in &mut faces {
|
||||
f.role = Role::Railing;
|
||||
}
|
||||
faces
|
||||
}
|
||||
|
||||
/// [152] Importierte Netze als Dreiecksflächen vor der Ansichtsebene (Hüllbox vorgefiltert): geschlossene
|
||||
/// Netze nur die zugewandten Dreiecke, offene beidseitig (Normale zum Betrachter). Farbe aus dem Import,
|
||||
/// sonst Kontext-Grau wie im 3D.
|
||||
|
||||
@@ -10,6 +10,8 @@ pub(super) enum Role {
|
||||
Roof,
|
||||
/// Stütze ([132]): Prisma aus dem Querschnitt, Flächen wie eine Platte.
|
||||
Column,
|
||||
/// [279] Geländer: Prismen (Pfosten, Stäbe, Tafeln, Handlauf), id = Geländer-id.
|
||||
Railing,
|
||||
/// [152] Importiertes Netz (`ImportedMesh`): Dreiecke, id = Netz-id.
|
||||
Mesh,
|
||||
/// [115] Freier Körper (`ExtrudedSolid`, Netz aus `solid_mesh.rs`): wie ein Netz, id = Körper-id.
|
||||
@@ -156,6 +158,7 @@ pub(super) fn face_overrides(p: &Project, faces: &mut [Face], v: RuleView) {
|
||||
surf_ov(p, v, "roof", &r.category_code, None, &layers, Some(0))
|
||||
}),
|
||||
Role::Column => p.columns.as_deref().unwrap_or(&[]).iter().find(|c| c.id == id).and_then(|c| surf_ov(p, v, "column", &c.category_code, Some(&super::super::domains::column_label(c)), &[], None)),
|
||||
Role::Railing => p.railings.as_deref().unwrap_or(&[]).iter().find(|r| r.id == id).and_then(|r| surf_ov(p, v, "railing", &r.category_code, Some(&crate::railing::label(r)), &[], None)),
|
||||
Role::Mesh => p.context.as_deref().unwrap_or(&[]).iter().find_map(|c| match c {
|
||||
ContextObject::ImportedMesh(m) if m.id == id => Some(m),
|
||||
_ => None,
|
||||
|
||||
@@ -124,7 +124,7 @@ pub(super) fn curved_slab_facets(faces: &[Face]) -> Vec<bool> {
|
||||
pub(super) fn paint_rank(r: Role) -> f64 {
|
||||
match r {
|
||||
Role::Slab => 0.0,
|
||||
Role::Wall | Role::Column | Role::Mesh | Role::Body => 1.0,
|
||||
Role::Wall | Role::Column | Role::Railing | Role::Mesh | Role::Body => 1.0,
|
||||
Role::Roof => 2.0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,6 +237,7 @@ pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, m
|
||||
cull_under_roofs(p, &frame, &walls, &mut faces, &|c| vis.visible(c) && vis.render(c));
|
||||
faces.extend(collect_roof_faces(p, &frame, &walls)?);
|
||||
faces.extend(collect_column_faces(p, &frame));
|
||||
faces.extend(collect_railing_faces(p, &frame));
|
||||
faces.extend(collect_mesh_faces(p, &frame));
|
||||
faces.extend(collect_body_faces(p, &frame));
|
||||
faces.extend(collect_shoring_faces(p, &frame));
|
||||
@@ -261,6 +262,7 @@ pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, m
|
||||
for r in p.roofs.as_deref().unwrap_or(&[]) {
|
||||
roof_cat.entry(r.id.as_str()).or_insert(r.category_code.as_str());
|
||||
}
|
||||
let rail_cat: HashMap<&str, &str> = p.railings.as_deref().unwrap_or(&[]).iter().map(|r| (r.id.as_str(), r.category_code.as_str())).collect();
|
||||
let mut col_cat: HashMap<&str, &str> = HashMap::new();
|
||||
for c in p.columns.as_deref().unwrap_or(&[]) {
|
||||
col_cat.entry(c.id.as_str()).or_insert(c.category_code.as_str());
|
||||
@@ -292,6 +294,7 @@ pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, m
|
||||
Role::Slab => ceil_cat.get(f.id.as_str()).copied(),
|
||||
Role::Roof => roof_cat.get(f.id.as_str()).copied(),
|
||||
Role::Column => col_cat.get(f.id.as_str()).copied(),
|
||||
Role::Railing => rail_cat.get(f.id.as_str()).copied(),
|
||||
Role::Mesh => mesh_cat.get(f.id.as_str()).copied(),
|
||||
Role::Body => body_cat.get(f.id.as_str()).copied(),
|
||||
}
|
||||
@@ -505,6 +508,7 @@ pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, m
|
||||
Role::Slab => *ceiling_id = Some(f.id.clone()),
|
||||
Role::Roof => *roof_id = Some(f.id.clone()),
|
||||
Role::Column => *column_id = Some(f.id.clone()),
|
||||
Role::Railing => *context_object_id = Some(super::railings::pick_id(&f.id)),
|
||||
Role::Mesh => *context_object_id = Some(f.id.clone()),
|
||||
Role::Body => *extruded_solid_id = Some(f.id.clone()),
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ pub mod stamp_place;
|
||||
pub mod floor_finish;
|
||||
pub mod model_view;
|
||||
pub mod trees;
|
||||
pub mod railings;
|
||||
pub mod cameras;
|
||||
pub mod mesh_plan;
|
||||
pub mod situation;
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
//! [279] Geländer im Grundriss (`Project.railings`). Geometrie aus `crate::railing`, die Zonen zur Schnitthöhe wie bei
|
||||
//! den Stützen (`view_range`): geschnitten oder darunter ausgezogen, darüber gestrichelt (Strich-Punkt, SIA 400),
|
||||
//! darunter sichtbar gepunktet.
|
||||
//!
|
||||
//! Zeichen je Art (Strichstärke der Klasse, Farbe der Klasse bzw. des Geländers):
|
||||
//! - **Stäbe:** eine Linie in der Achse (Handlauf über den Stäben) und kleine gefüllte Pfosten (bis 1:200).
|
||||
//! - **Glas:** Doppellinie im Abstand der Glasdicke (mindestens 0.7 mm Papier, damit die Linien nicht ineinanderlaufen),
|
||||
//! an offenen Enden geschlossen.
|
||||
//! - **Lochblech:** wie Glas, dazu eine gestrichelte Mittellinie.
|
||||
//! - **Brüstung (massiv):** geschnittene Fläche mit Bauteil-Schraffur (Poché wie die Stützen), Umriss ohne Gehrungsfugen.
|
||||
//!
|
||||
//! Pick: unsichtbare Fläche um die Achse (mindestens 4 mm Papier breit) mit `contextObjectId = "@railing:<id>"`.
|
||||
|
||||
use super::domains::Ctx;
|
||||
use super::prim::Primitive;
|
||||
use super::style::*;
|
||||
use super::view_range::{ViewRange, Zone};
|
||||
use crate::model::*;
|
||||
use crate::railing::{self, PICK_PREFIX};
|
||||
|
||||
fn v(q: [f64; 2]) -> Vec2 {
|
||||
Vec2 { x: q[0], y: q[1] }
|
||||
}
|
||||
|
||||
/// Pick-Id eines Geländers (Feld `contextObjectId`).
|
||||
pub fn pick_id(id: &str) -> String {
|
||||
format!("{PICK_PREFIX}{id}")
|
||||
}
|
||||
|
||||
/// Ist `q` ein Planzeichen eines Geländers (Linien, Pick-Fläche)?
|
||||
pub fn is_symbol_part(q: &Primitive) -> bool {
|
||||
match q {
|
||||
Primitive::Line { cls, .. } => cls.starts_with("railing-"),
|
||||
Primitive::Polygon { context_object_id: Some(id), .. } => id.starts_with(PICK_PREFIX),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Linie mit Strichstärke und Farbe.
|
||||
fn seg(a: [f64; 2], b: [f64; 2], cls: &str, w: f64, color: &str, dash: Option<&[f64]>, greyed: Option<bool>) -> Primitive {
|
||||
super::trees::line(v(a), v(b), cls, w, color, dash, greyed)
|
||||
}
|
||||
|
||||
/// Streckenzug als Linien.
|
||||
fn polyline(out: &mut Vec<Primitive>, pts: &[[f64; 2]], cls: &str, w: f64, color: &str, dash: Option<&[f64]>, greyed: Option<bool>) {
|
||||
for s in pts.windows(2) {
|
||||
out.push(seg(s[0], s[1], cls, w, color, dash, greyed));
|
||||
}
|
||||
}
|
||||
|
||||
/// Planzeichen aller Geländer dieses Geschosses (sichtbare Klasse, im Ansichtsbereich).
|
||||
pub(super) fn plan_railings(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
let p = c.p;
|
||||
let Some(list) = p.railings.as_deref() else { return };
|
||||
if list.iter().all(|r| r.floor_id != c.a.floor) {
|
||||
return;
|
||||
}
|
||||
let range = ViewRange::of(p, &c.a.floor);
|
||||
for r in list.iter().filter(|r| r.floor_id == c.a.floor && c.vis(&r.category_code, &r.id)) {
|
||||
let (Some(s), Some(ax)) = (railing::spec(p, r), railing::axis(r)) else { continue };
|
||||
let zone = range.classify(s.z0, s.top());
|
||||
if zone == Zone::Hidden {
|
||||
continue;
|
||||
}
|
||||
let from = out.len();
|
||||
let greyed = Some(c.greyed(&r.category_code));
|
||||
let category = c.cat(&r.category_code);
|
||||
let ov = c.overrides(Some("railing"), &r.category_code, Some(&railing::label(r)));
|
||||
let lw = ov.lineweight.unwrap_or_else(|| category.map_or(WALL_FALLBACK_MM, |k| k.lw));
|
||||
let color = ov.color.as_deref().or(r.color.as_deref());
|
||||
let stroke = color.or(category.map(|k| k.color.as_str())).unwrap_or(MONO_INK).to_string();
|
||||
let mm = (c.a.scale / 1000.0).max(1e-6);
|
||||
let closed = crate::stair_rail::is_closed(&ax);
|
||||
|
||||
// Pick: unsichtbare Fläche, mindestens 4 mm Papier breit.
|
||||
let pick_half = (s.thickness.max(s.rail_w()) / 2.0).max(2.0 * mm);
|
||||
for q in railing::strips(&ax, pick_half).0 {
|
||||
out.push(super::trees::poly(q.iter().map(|&q| v(q)).collect(), "none", "none", 0.0, Some(pick_id(&r.id)), greyed));
|
||||
}
|
||||
|
||||
match s.kind {
|
||||
RailingKind::Solid => {
|
||||
let (quads, l, rt) = railing::strips(&ax, s.thickness / 2.0);
|
||||
let (mut fill, mut hatch) = (color.or(category.map(|k| k.color.as_str())).unwrap_or(HATCH_PAPER).to_string(), no_hatch());
|
||||
if zone != Zone::Cut {
|
||||
fill = "none".into();
|
||||
} else if let Some(k) = r.component_id.as_deref().filter(|s| !s.is_empty()).and_then(|id| p.component(id)) {
|
||||
if let Some(h) = resolve_hatch(p, resolve_hatch_id(None, None, category, Some(&k.hatch_id)).unwrap_or(&k.hatch_id), None, resolve_foreground(k, None, category, None), None) {
|
||||
fill = resolve_background(k, None, category, None).unwrap_or(if h.pattern == HatchPattern::Solid { HATCH_INK } else { HATCH_PAPER }).to_string();
|
||||
hatch = h;
|
||||
}
|
||||
} else {
|
||||
fill = HATCH_PAPER.to_string();
|
||||
}
|
||||
if zone == Zone::Cut && c.solid_cut() && category.is_some() {
|
||||
fill = HATCH_INK.to_string();
|
||||
hatch = no_hatch();
|
||||
}
|
||||
for q in quads {
|
||||
let mut f = super::trees::poly(q.iter().map(|&q| v(q)).collect(), &fill, "none", 0.0, None, greyed);
|
||||
if let Primitive::Polygon { hatch: h, .. } = &mut f {
|
||||
**h = hatch.clone();
|
||||
}
|
||||
out.push(f);
|
||||
}
|
||||
polyline(out, &l, "railing-solid", lw, &stroke, None, greyed);
|
||||
polyline(out, &rt, "railing-solid", lw, &stroke, None, greyed);
|
||||
if !closed {
|
||||
out.push(seg(l[0], rt[0], "railing-solid", lw, &stroke, None, greyed));
|
||||
out.push(seg(l[l.len() - 1], rt[rt.len() - 1], "railing-solid", lw, &stroke, None, greyed));
|
||||
}
|
||||
}
|
||||
RailingKind::Glass | RailingKind::Perforated => {
|
||||
// Mindestabstand der Doppellinie: 0.7 mm Papier.
|
||||
let half = (s.thickness / 2.0).max(0.35 * mm);
|
||||
let (_, l, rt) = railing::strips(&ax, half);
|
||||
polyline(out, &l, "railing-glass", lw, &stroke, None, greyed);
|
||||
polyline(out, &rt, "railing-glass", lw, &stroke, None, greyed);
|
||||
if !closed {
|
||||
out.push(seg(l[0], rt[0], "railing-glass", lw, &stroke, None, greyed));
|
||||
out.push(seg(l[l.len() - 1], rt[rt.len() - 1], "railing-glass", lw, &stroke, None, greyed));
|
||||
}
|
||||
if s.kind == RailingKind::Perforated {
|
||||
polyline(out, &ax, "railing-perforated", lw * 0.6, &stroke, Some(&super::line_pattern::HIDDEN), greyed);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
polyline(out, &ax, "railing-bars", lw, &stroke, None, greyed);
|
||||
// Pfosten als kleine gefüllte Quadrate; bei kleinen Massstäben nicht mehr lesbar.
|
||||
if c.a.scale <= 200.0 {
|
||||
for (pt, d) in railing::stations(&ax, &s).0 {
|
||||
let (n, h) = ([-d[1], d[0]], 0.015);
|
||||
let q = |a: f64, b: f64| v([pt[0] + d[0] * a + n[0] * b, pt[1] + d[1] * a + n[1] * b]);
|
||||
out.push(super::trees::poly(vec![q(-h, -h), q(h, -h), q(h, h), q(-h, h)], &stroke, &stroke, 0.0, None, greyed));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Ganz über der Schnitthöhe: Strich-Punkt wie die übrigen Bauteile darüber (auch ohne eigenen Ansichtsbereich, wie die
|
||||
// Stufen und Handläufe der Treppen); unter der Schnitthöhe gepunktet nur mit eigenem Bereich.
|
||||
let dash = if zone == Zone::Above { Some(&super::view_range::ABOVE_DASH[..]) } else { range.restyle_dash(zone) };
|
||||
if let Some(d) = dash {
|
||||
super::view_range::restyle(out, from, d);
|
||||
}
|
||||
// [271] Umbaufilter: das Geländer in der Farbe seines Status (Bestand grau, Abbruch gelb gestrichelt, Neu rot).
|
||||
if let Some(st) = c.renovation().and_then(|rn| rn.styled.get(&r.id)) {
|
||||
crate::renovation::restyle_linework(out, from, st, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::plan::domains::{plan_domains, PlanArgs};
|
||||
|
||||
fn project(rail: serde_json::Value) -> Project {
|
||||
serde_json::from_value(serde_json::json!({
|
||||
"id": "p", "name": "t", "lineStyles": [], "hatches": [], "components": [{"id": "beton", "name": "Beton", "color": "#b0b0b0", "hatchId": "h", "joinPriority": 5}], "wallTypes": [],
|
||||
"layers": [{"code": "41", "name": "Geländer", "color": "#102030", "lw": 0.25, "visible": true, "locked": false}],
|
||||
"drawingLevels": [{"id": "eg", "name": "EG", "kind": "floor", "visible": true, "locked": false, "baseElevation": 0.0, "floorHeight": 2.6, "cutHeight": 1.0}],
|
||||
"walls": [], "openings": [], "drawings2d": [], "railings": [rail]
|
||||
}))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn plan(p: &Project, scale: f64) -> Vec<Primitive> {
|
||||
plan_codes(p, scale, &["41"])
|
||||
}
|
||||
|
||||
fn plan_codes(p: &Project, scale: f64, codes: &[&str]) -> Vec<Primitive> {
|
||||
let text = serde_json::json!({"floor": "eg", "show": codes, "scale": scale, "global": true}).to_string();
|
||||
let a = PlanArgs::parse(scale, &text).unwrap();
|
||||
plan_domains(p, &a).unwrap().columns
|
||||
}
|
||||
|
||||
fn rail(kind: &str, extra: serde_json::Value) -> serde_json::Value {
|
||||
let mut r = serde_json::json!({"id": "g1", "type": "railing", "floorId": "eg", "categoryCode": "41", "points": [{"x": 0, "y": 0}, {"x": 4, "y": 0}], "height": 1.0, "kind": kind});
|
||||
if let (Some(o), Some(e)) = (r.as_object_mut(), extra.as_object()) {
|
||||
o.extend(e.clone());
|
||||
}
|
||||
r
|
||||
}
|
||||
|
||||
fn lines(prims: &[Primitive], cls: &str) -> Vec<(Vec2, Vec2)> {
|
||||
prims.iter().filter_map(|q| match q {
|
||||
Primitive::Line { a, b, cls: c, .. } if c == cls => Some((*a, *b)),
|
||||
_ => None,
|
||||
}).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn staebe_eine_linie_und_pfosten() {
|
||||
let p = project(rail("bars", serde_json::json!({})));
|
||||
let prims = plan(&p, 50.0);
|
||||
let l = lines(&prims, "railing-bars");
|
||||
assert_eq!(l.len(), 1);
|
||||
assert!((l[0].0.x - 0.0).abs() < 1e-9 && (l[0].1.x - 4.0).abs() < 1e-9 && l[0].0.y == 0.0);
|
||||
// Pick-Fläche mit der Id.
|
||||
assert!(prims.iter().any(|q| matches!(q, Primitive::Polygon { context_object_id: Some(id), .. } if id == "@railing:g1")));
|
||||
// Pfosten: 5 (4 Felder à 1 m), gefüllt.
|
||||
let posts = prims.iter().filter(|q| matches!(q, Primitive::Polygon { fill, stroke_width_mm, context_object_id: None, .. } if fill != "none" && *stroke_width_mm == 0.0)).count();
|
||||
assert_eq!(posts, 5);
|
||||
// Ab 1:500 keine Pfosten mehr.
|
||||
let big = plan(&p, 500.0);
|
||||
assert_eq!(big.iter().filter(|q| matches!(q, Primitive::Polygon { fill, context_object_id: None, .. } if fill != "none")).count(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn glas_doppellinie_mit_mindestabstand() {
|
||||
let p = project(rail("glass", serde_json::json!({"thickness": 0.02})));
|
||||
let prims = plan(&p, 100.0);
|
||||
let l = lines(&prims, "railing-glass");
|
||||
// Zwei Längslinien und zwei Stirnlinien.
|
||||
assert_eq!(l.len(), 4);
|
||||
let long: Vec<_> = l.iter().filter(|(a, b)| (a.x - b.x).abs() > 1.0).collect();
|
||||
assert_eq!(long.len(), 2);
|
||||
// Abstand = 2 × max(0.01, 0.35 mm × 100/1000 = 0.035) = 0.07.
|
||||
assert!(((long[0].0.y - long[1].0.y).abs() - 0.07).abs() < 1e-9, "{long:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn brustung_flaeche_und_ueber_schnitt_gestrichelt() {
|
||||
let p = project(rail("solid", serde_json::json!({"thickness": 0.15})));
|
||||
let prims = plan(&p, 50.0);
|
||||
// Geschnitten (Höhe 0 bis 1.0, Schnitt bei 1.0): gefüllte Fläche und ausgezogener Umriss.
|
||||
assert!(prims.iter().any(|q| matches!(q, Primitive::Polygon { fill, context_object_id: None, .. } if fill != "none")));
|
||||
let ls = lines(&prims, "railing-solid");
|
||||
assert_eq!(ls.len(), 4);
|
||||
assert!(prims.iter().filter_map(|q| match q { Primitive::Line { cls, dash, .. } if cls == "railing-solid" => Some(dash), _ => None }).all(|d| d.is_none()));
|
||||
// Fuss über der Schnitthöhe (Geschoss-Offset 1.2): ganz darüber, gestrichelt, ohne Füllung.
|
||||
let p = project(rail("solid", serde_json::json!({"thickness": 0.15, "baseOffset": 1.2})));
|
||||
let prims = plan(&p, 50.0);
|
||||
assert!(!prims.iter().any(|q| matches!(q, Primitive::Polygon { fill, context_object_id: None, .. } if fill != "none")));
|
||||
assert!(prims.iter().filter_map(|q| match q { Primitive::Line { cls, dash, .. } if cls == "railing-solid" => Some(dash), _ => None }).all(|d| d.as_ref().is_some_and(|d| d.is_some())));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn klasse_aus_blendet_aus_und_unsinn_kein_absturz() {
|
||||
let p = project(rail("glass", serde_json::json!({})));
|
||||
assert!(plan_codes(&p, 50.0, &[]).iter().all(|q| !is_symbol_part(q)));
|
||||
for bad in [serde_json::json!({"points": [{"x": 1, "y": 1}]}), serde_json::json!({"height": 0}), serde_json::json!({"points": [{"x": 0, "y": 0}, {"x": 1e300, "y": 1e300}]})] {
|
||||
let p = project(rail("bars", bad));
|
||||
let _ = plan(&p, 50.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,6 +126,8 @@ pub enum SlabOwner<'a> {
|
||||
Ceiling(&'a Ceiling, Option<usize>),
|
||||
Stair(&'a Stair),
|
||||
Column(&'a Column),
|
||||
/// [279] Geländer; `true` = Tafel (Glas, Lochblech, Brüstung), sonst Gestänge.
|
||||
Railing(&'a Railing, bool),
|
||||
}
|
||||
|
||||
/// Je emittierter Platte (Deckenschicht, Treppentritt, Podest) ihre Herkunft (`RSlab::source`).
|
||||
@@ -138,6 +140,7 @@ pub fn slab_owners<'a>(p: &'a Project, slabs: &[RSlab]) -> Vec<SlabOwner<'a>> {
|
||||
SlabSource::Ceiling { index, layer } => ceilings.get(index).map_or(SlabOwner::None, |c| SlabOwner::Ceiling(c, layer)),
|
||||
SlabSource::Stair { index } => stairs.get(index).map_or(SlabOwner::None, SlabOwner::Stair),
|
||||
SlabSource::Column { index } => p.columns.as_deref().and_then(|c| c.get(index)).map_or(SlabOwner::None, SlabOwner::Column),
|
||||
SlabSource::Railing { index, fill } => p.railings.as_deref().and_then(|c| c.get(index)).map_or(SlabOwner::None, |r| SlabOwner::Railing(r, fill)),
|
||||
SlabSource::None => SlabOwner::None,
|
||||
})
|
||||
.collect()
|
||||
@@ -700,6 +703,37 @@ pub(super) fn attach_cut_styles(cuts: Vec<Cut>, p: &Project, plane: &Plane, wall
|
||||
}
|
||||
cp.join_priority = Some(comp.map_or(f64::MAX, |k| k.join_priority));
|
||||
}
|
||||
// [279] Geländer: Tafel nach Art (Brüstung wie eine Stütze mit Bauteil, Glas hell), Gestänge schwarz.
|
||||
SlabOwner::Railing(r, fill) => {
|
||||
cp.source_id = Some(r.id.clone());
|
||||
cp.railing_id = Some(r.id.clone());
|
||||
cp.category = Some(r.category_code.clone());
|
||||
match (fill, r.kind) {
|
||||
(true, RailingKind::Solid) => {
|
||||
let comp = r.component_id.as_deref().filter(|s| !s.is_empty()).and_then(|id| p.component(id));
|
||||
if let Some(k) = comp {
|
||||
let category = p.layer_category(&r.category_code);
|
||||
let hid = resolve_hatch_id(None, None, category, Some(&k.hatch_id)).unwrap_or(&k.hatch_id);
|
||||
if let Some(h) = resolve_hatch(p, hid, None, resolve_foreground(k, None, category, None), None) {
|
||||
cp.fill = Some(poche_fill(h.pattern).to_string());
|
||||
cp.hatch = Some(h);
|
||||
}
|
||||
cp.component_id = Some(k.id.clone());
|
||||
} else {
|
||||
cp.fill = Some(HATCH_PAPER.to_string());
|
||||
cp.hatch = Some(no_hatch());
|
||||
}
|
||||
}
|
||||
(true, RailingKind::Glass) => {
|
||||
cp.fill = Some("#cfe3ee".to_string());
|
||||
cp.hatch = Some(no_hatch());
|
||||
}
|
||||
_ => {
|
||||
cp.fill = Some(HATCH_INK.to_string());
|
||||
cp.hatch = Some(no_hatch());
|
||||
}
|
||||
}
|
||||
}
|
||||
SlabOwner::None => {}
|
||||
}
|
||||
bands.push(cp);
|
||||
|
||||
@@ -247,6 +247,8 @@ pub struct Cut {
|
||||
pub source_id: Option<String>,
|
||||
pub category: Option<String>,
|
||||
pub stair_id: Option<String>,
|
||||
/// [279] Geländer, zu dem das Band gehört (Pick `@railing:<id>`).
|
||||
pub railing_id: Option<String>,
|
||||
/// [33] Index der Schicht im Aufbau des Bauteils (Wand-, Decken-, Dachtyp), wo bekannt.
|
||||
pub layer_index: Option<usize>,
|
||||
/// [33] Override der Schicht (nur beim Zeichnen gesetzt, [`cut_overrides`]).
|
||||
@@ -255,7 +257,7 @@ pub struct Cut {
|
||||
|
||||
impl Cut {
|
||||
fn new(kind: Kind, index: usize, pts: Vec<[f64; 2]>) -> Cut {
|
||||
Cut { kind, index, pts, nse: None, fill: None, hatch: None, join_priority: None, component_id: None, source_id: None, category: None, stair_id: None, layer_index: None, ov: None }
|
||||
Cut { kind, index, pts, nse: None, fill: None, hatch: None, join_priority: None, component_id: None, source_id: None, category: None, stair_id: None, railing_id: None, layer_index: None, ov: None }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,6 +441,10 @@ pub fn without_elements(p: &Project, ids: &HashSet<String>) -> Project {
|
||||
if let Some(v) = &mut q.columns {
|
||||
v.retain(|x| !ids.contains(&x.id));
|
||||
}
|
||||
// [279] Geländer.
|
||||
if let Some(v) = &mut q.railings {
|
||||
v.retain(|x| !ids.contains(&x.id));
|
||||
}
|
||||
if let Some(v) = &mut q.rooms {
|
||||
v.retain(|x| !ids.contains(&x.id));
|
||||
}
|
||||
@@ -602,6 +608,7 @@ pub(crate) fn edge_categories(p: &Project, walls: &[Option<&Wall>], slabs: &[ban
|
||||
bands::SlabOwner::Ceiling(c, _) => &c.category_code,
|
||||
bands::SlabOwner::Stair(st) => &st.category_code,
|
||||
bands::SlabOwner::Column(c) => &c.category_code,
|
||||
bands::SlabOwner::Railing(c, _) => &c.category_code,
|
||||
bands::SlabOwner::None => continue,
|
||||
};
|
||||
m.insert((Kind::Slab, i), code.clone());
|
||||
@@ -628,6 +635,7 @@ pub(crate) fn edge_ids(p: &Project, walls: &[Option<&Wall>], slabs: &[bands::Sla
|
||||
bands::SlabOwner::Ceiling(c, _) => &c.id,
|
||||
bands::SlabOwner::Stair(st) => &st.id,
|
||||
bands::SlabOwner::Column(c) => &c.id,
|
||||
bands::SlabOwner::Railing(c, _) => &c.id,
|
||||
bands::SlabOwner::None => continue,
|
||||
};
|
||||
m.insert((Kind::Slab, i), id.clone());
|
||||
@@ -682,6 +690,8 @@ pub(super) fn compute_plane(p: &Project, level: &LevelSpec, bodies: &[BodyMesh],
|
||||
slabs_r.extend(model3d::emit_stairs(p, true));
|
||||
// [141] Stützen: geschnitten mit Bauteil-Stil (Rang gegen die Wände wie im Grundriss) und in der Projektion.
|
||||
slabs_r.extend(model3d::column_slabs(p));
|
||||
// [279] Geländer: geschnitten und in der Projektion.
|
||||
slabs_r.extend(model3d::railing_slabs(p));
|
||||
let wi: Vec<render3d::WallInput> = walls_r.iter().map(wall_input).collect();
|
||||
let si: Vec<render3d::SlabInput> = slabs_r.iter().map(slab_input).collect();
|
||||
// Die Ebene ging als Zahl-Argument (wasm-bindgen, `Math.fround`) hinein, nicht über JSON.
|
||||
|
||||
@@ -556,7 +556,11 @@ pub fn section_primitives_mv(out: &Output, mono: bool, hidden_lines: bool, vis:
|
||||
// [152] Importiertes Netz: Pick über die Kontext-Id.
|
||||
*context_object_id = if cp.kind == Kind::Mesh { src.clone() } else { None };
|
||||
*wall_id = if cp.kind == Kind::Wall { src.clone() } else { None };
|
||||
*ceiling_id = if cp.kind == Kind::Slab && cp.stair_id.is_none() { src.clone() } else { None };
|
||||
*ceiling_id = if cp.kind == Kind::Slab && cp.stair_id.is_none() && cp.railing_id.is_none() { src.clone() } else { None };
|
||||
// [279] Geländer: Pick über die Kontext-Id `@railing:<id>`.
|
||||
if let Some(r) = &cp.railing_id {
|
||||
*context_object_id = Some(crate::plan::railings::pick_id(r));
|
||||
}
|
||||
*roof_id = if cp.kind == Kind::Roof { src.clone() } else { None };
|
||||
*stair_id = cp.stair_id.clone();
|
||||
*extruded_solid_id = if cp.kind == Kind::Body { src } else { None };
|
||||
|
||||
@@ -315,6 +315,8 @@ pub(crate) struct OwnerRef {
|
||||
/// Treppe (Stufen, Wangen, Geländer) bzw. Stütze statt Decke, wenn `kind` = `Slab`.
|
||||
pub stair: bool,
|
||||
pub column: bool,
|
||||
/// [279] Geländer (Pick `@railing:<id>`).
|
||||
pub railing: bool,
|
||||
}
|
||||
|
||||
/// [266] Alle Flächen des Modells für eine beliebige Ansicht (Vektor-Axonometrie, `plan/axo.rs`): dieselben Körper wie
|
||||
@@ -325,6 +327,7 @@ pub(crate) fn model_view_faces(p: &Project, vis: &Visibility, view: &dyn Fn([f64
|
||||
let mut slabs_r = model3d::emit_slabs(p);
|
||||
slabs_r.extend(model3d::emit_stairs(p, true));
|
||||
slabs_r.extend(model3d::column_slabs(p));
|
||||
slabs_r.extend(model3d::railing_slabs(p));
|
||||
let wi: Vec<render3d::WallInput> = walls_r.iter().map(wall_input).collect();
|
||||
let walls = wall_owners(p, &walls_r);
|
||||
let slabs = slab_owners(p, &slabs_r);
|
||||
@@ -342,19 +345,20 @@ pub(crate) fn model_view_faces(p: &Project, vis: &Visibility, view: &dyn Fn([f64
|
||||
.owners
|
||||
.iter()
|
||||
.map(|&(kind, i)| {
|
||||
let (id, stair, column) = match kind {
|
||||
Kind::Wall => (walls_r.get(i).map(|w| w.wall_id.clone()), false, false),
|
||||
let (id, stair, column, railing) = match kind {
|
||||
Kind::Wall => (walls_r.get(i).map(|w| w.wall_id.clone()), false, false, false),
|
||||
Kind::Slab => match slabs.get(i) {
|
||||
Some(SlabOwner::Ceiling(c, _)) => (Some(c.id.clone()), false, false),
|
||||
Some(SlabOwner::Stair(s)) => (Some(s.id.clone()), true, false),
|
||||
Some(SlabOwner::Column(c)) => (Some(c.id.clone()), false, true),
|
||||
_ => (None, false, false),
|
||||
Some(SlabOwner::Ceiling(c, _)) => (Some(c.id.clone()), false, false, false),
|
||||
Some(SlabOwner::Stair(s)) => (Some(s.id.clone()), true, false, false),
|
||||
Some(SlabOwner::Column(c)) => (Some(c.id.clone()), false, true, false),
|
||||
Some(SlabOwner::Railing(r, _)) => (Some(r.id.clone()), false, false, true),
|
||||
_ => (None, false, false, false),
|
||||
},
|
||||
Kind::Roof => (roofs.get(i).map(|r| r.id.clone()), false, false),
|
||||
Kind::Body => (solids.get(i).map(|s| s.id.clone()), false, false),
|
||||
Kind::Mesh => (mrefs.get(i).map(|m| m.mesh.id.clone()), false, false),
|
||||
Kind::Roof => (roofs.get(i).map(|r| r.id.clone()), false, false, false),
|
||||
Kind::Body => (solids.get(i).map(|s| s.id.clone()), false, false, false),
|
||||
Kind::Mesh => (mrefs.get(i).map(|m| m.mesh.id.clone()), false, false, false),
|
||||
};
|
||||
OwnerRef { kind, id, stair, column }
|
||||
OwnerRef { kind, id, stair, column, railing }
|
||||
})
|
||||
.collect();
|
||||
Ok((vf, refs))
|
||||
|
||||
@@ -15,7 +15,7 @@ const REQUIRED_ARRAYS: [&str; 3] = ["walls", "layers", "drawingLevels"];
|
||||
const DEFAULT_ARRAYS: [&str; 5] = ["lineStyles", "hatches", "components", "wallTypes", "drawings2d"];
|
||||
|
||||
/// Bekannte Felder von `Project` (für die Meldung unbekannter Felder).
|
||||
const KNOWN_KEYS: [&str; 63] = [
|
||||
const KNOWN_KEYS: [&str; 64] = [
|
||||
"formatVersion", "id", "name", "lineStyles", "textStyles", "hatches", "components", "wallTypes",
|
||||
"ceilingTypes", "roofTypes", "blockDefs", "doorTypes", "windowTypes", "stairTypes", "pens",
|
||||
"penSets", "activePenSetId", "customPalettes", "builtinPaletteBanks", "drawingLevels", "layers",
|
||||
@@ -30,6 +30,7 @@ const KNOWN_KEYS: [&str; 63] = [
|
||||
"designOptionSets",
|
||||
"designOptionCombinations",
|
||||
"units",
|
||||
"railings",
|
||||
];
|
||||
|
||||
/// Ergebnis des Einlesens.
|
||||
|
||||
@@ -96,6 +96,11 @@ pub fn dangling_refs(p: &Project) -> Vec<String> {
|
||||
miss(&mut out, "Stütze", &c.id, "Bauteil", c.component_id.as_deref().unwrap_or(""), &components);
|
||||
miss(&mut out, "Stütze", &c.id, "Schraffur", c.hatch_id.as_deref().unwrap_or(""), &hatches);
|
||||
}
|
||||
// [279] Geländer.
|
||||
for r in p.railings.as_deref().unwrap_or(&[]) {
|
||||
miss(&mut out, "Geländer", &r.id, "Geschoss", &r.floor_id, &levels);
|
||||
miss(&mut out, "Geländer", &r.id, "Bauteil", r.component_id.as_deref().unwrap_or(""), &components);
|
||||
}
|
||||
for r in p.rooms.as_deref().unwrap_or(&[]) {
|
||||
miss(&mut out, "Raum", &r.id, "Geschoss", &r.floor_id, &levels);
|
||||
}
|
||||
@@ -167,7 +172,7 @@ pub fn dangling_refs(p: &Project) -> Vec<String> {
|
||||
// Gruppen: Mitglieder und Zyklen.
|
||||
let groups = p.groups.as_deref().unwrap_or(&[]);
|
||||
let group_ids = ids(groups, |g| g.id.as_str());
|
||||
let members: [(&str, HashSet<&str>); 9] = [
|
||||
let members: [(&str, HashSet<&str>); 10] = [
|
||||
("Zeichnung", ids(&p.drawings2d, |d| d.id.as_str())),
|
||||
("Decke", ids(p.ceilings.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
("Raum", ids(p.rooms.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
@@ -177,13 +182,14 @@ pub fn dangling_refs(p: &Project) -> Vec<String> {
|
||||
("Öffnung", ids(p.openings.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
("Baum", ids(p.trees.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
("Kamera", ids(p.cameras.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
("Geländer", ids(p.railings.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
];
|
||||
for g in groups {
|
||||
for w in &g.wall_ids {
|
||||
miss(&mut out, "Gruppe", &g.id, "Wand", w, &walls);
|
||||
}
|
||||
let none = Vec::new();
|
||||
let lists = [&g.drawing_ids, &g.ceiling_ids, &g.room_ids, &g.stair_ids, &g.column_ids, &g.roof_ids, &g.opening_ids, g.tree_ids.as_ref().unwrap_or(&none), g.camera_ids.as_ref().unwrap_or(&none)];
|
||||
let lists = [&g.drawing_ids, &g.ceiling_ids, &g.room_ids, &g.stair_ids, &g.column_ids, &g.roof_ids, &g.opening_ids, g.tree_ids.as_ref().unwrap_or(&none), g.camera_ids.as_ref().unwrap_or(&none), g.railing_ids.as_ref().unwrap_or(&none)];
|
||||
for (list, (kind, known)) in lists.into_iter().zip(&members) {
|
||||
for id in list {
|
||||
miss(&mut out, "Gruppe", &g.id, kind, id, known);
|
||||
|
||||
@@ -158,6 +158,8 @@ pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String,
|
||||
("materialMaps", _) => json(&model3d::wall_material_color_maps(p)),
|
||||
("slabs", _) => json(&model3d::emit_slabs(p)),
|
||||
("columnMeshes", _) => json(&model3d::emit_columns(p)),
|
||||
// [279] Kennzahlen eines Geländers (Objekt-Info): Länge, Fuss- und Oberkante, Stäbe, Pfosten; Text = Id.
|
||||
("railingInfo", _) => json(&crate::railing::info(p, text.trim())),
|
||||
("walls", 1) => json(&model3d::emit_walls(p, args[0] != 0.0)?),
|
||||
("openingMeshes", 1) => json(&model3d::emit_opening_meshes(p, args[0])),
|
||||
("stairSlabs", 1) => json(&model3d::emit_stairs(p, args[0] != 0.0)),
|
||||
|
||||
@@ -0,0 +1,416 @@
|
||||
//! [279] Geländer als eigenes Bauteil (`Project.railings`): Absturzsicherung für Balkon, Galerie, Treppenauge und
|
||||
//! Terrasse. **Eine Quelle** für die Körper: [`pieces`] zerlegt ein Geländer in lotrechte Prismen
|
||||
//! `(Querschnitt, z_unten, z_oben, Teil)` wie `model3d::column_pieces` bei den Stützen. Daraus entstehen das 3D-Netz
|
||||
//! (`model3d/railings.rs`), die Platten für Schnitt, Ansicht und 3D-Dokument (`model3d::railing_slabs`), die
|
||||
//! IFC-Mengen (`ifc_data.rs`) und die Netze der Auswahl. Der Grundriss (`plan/railings.rs`) zeichnet die Achse und
|
||||
//! die Streifen ([`strips`]) selbst. Teile, Masse und Obergrenzen:
|
||||
//!
|
||||
//! - **Achse:** Polylinie `points` (offen; mit `closed` oder letzter = erster Punkt geschlossen), Gehrungen an den
|
||||
//! Ecken über [`crate::stair_rail::offset_polyline`] — dieselbe Hilfe wie die Treppen-Handläufe und die
|
||||
//! Absturzsicherung am Deckenloch ([`crate::stair_guard`], [`crate::stairs3d::guard_mesh`]).
|
||||
//! - **Stäbe:** Pfosten an den Ecken und höchstens [`POST_GAP`] auseinander, Stäbe im Achsabstand `barSpacing`
|
||||
//! (lichtes Mass höchstens [`MAX_CLEAR_GAP`] = 12 cm nach SIA 358: der Abstand wird bei Bedarf verkleinert),
|
||||
//! Fussschiene und Handlauf bzw. Obergurt.
|
||||
//! - **Glas, Lochblech, massive Brüstung:** durchgehende Tafel der Dicke `thickness` (mit Gehrung); Handlauf obenauf.
|
||||
//! - **Höhe:** Fuss = Geschoss-UK + `baseOffset`, Oberkante = Fuss + `height` (Vorgabe [`DEFAULT_HEIGHT`] = 1.00 m).
|
||||
|
||||
use crate::model::*;
|
||||
use crate::stair_rail::{is_closed, offset_polyline, P};
|
||||
|
||||
/// Vorgabehöhe (m) nach SIA 358 (Absturzsicherung bis 12 m Fallhöhe: 1.00 m).
|
||||
pub const DEFAULT_HEIGHT: f64 = 1.0;
|
||||
/// Kategorie (Ebene) neuer Geländer.
|
||||
pub const CATEGORY: &str = "41";
|
||||
/// Pick-Id im Grundriss/Schnitt (`contextObjectId = "@railing:<id>"`), wie bei den Bäumen.
|
||||
pub const PICK_PREFIX: &str = "@railing:";
|
||||
/// Pfostenabstand (m) und höchstes lichtes Mass zwischen Stäben (m, SIA 358).
|
||||
pub const POST_GAP: f64 = 1.2;
|
||||
pub const MAX_CLEAR_GAP: f64 = 0.12;
|
||||
/// Obergrenzen gegen Eingabefehler (ein Geländer von 100 km Länge): Pfosten und Stäbe je Geländer.
|
||||
const MAX_POSTS: f64 = 5_000.0;
|
||||
const MAX_BARS: f64 = 20_000.0;
|
||||
/// Pfosten: Kantenlänge (m); Fussschiene: Breite, Höhe und Lage über dem Fuss (m); Obergurt ohne Handlauf (m).
|
||||
const POST_SIZE: f64 = 0.03;
|
||||
const FOOT_W: f64 = 0.03;
|
||||
const FOOT_Z: (f64, f64) = (0.05, 0.08);
|
||||
const TOP_BAR: (f64, f64) = (0.04, 0.03);
|
||||
|
||||
/// Teil eines Geländers (für Farbe, Schnittfüllung und Menge).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Part {
|
||||
Post,
|
||||
Bar,
|
||||
/// Handlauf bzw. Obergurt.
|
||||
Rail,
|
||||
/// Fussschiene.
|
||||
Foot,
|
||||
/// Tafel: Glas, Lochblech oder massive Brüstung.
|
||||
Fill,
|
||||
}
|
||||
|
||||
/// Ein lotrechtes Prisma des Geländers.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Piece {
|
||||
/// Querschnitt im Grundriss (Gegenuhrzeigersinn).
|
||||
pub outline: Vec<P>,
|
||||
pub z0: f64,
|
||||
pub z1: f64,
|
||||
pub part: Part,
|
||||
}
|
||||
|
||||
/// Aufgelöste Masse eines Geländers (Vorgaben eingesetzt, Unsinn begrenzt).
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Spec {
|
||||
pub kind: RailingKind,
|
||||
pub height: f64,
|
||||
/// Absolute Höhe des Fusses.
|
||||
pub z0: f64,
|
||||
pub thickness: f64,
|
||||
/// Achsabstand der Stäbe (nach der 12-cm-Regel begrenzt).
|
||||
pub bar_spacing: f64,
|
||||
pub bar_size: f64,
|
||||
pub handrail: bool,
|
||||
pub handrail_size: f64,
|
||||
}
|
||||
|
||||
impl Spec {
|
||||
/// Oberkante (absolut).
|
||||
pub fn top(&self) -> f64 {
|
||||
self.z0 + self.height
|
||||
}
|
||||
|
||||
/// Höhe des Handlaufs bzw. Obergurts (die Füllung endet darunter).
|
||||
pub fn rail_h(&self) -> f64 {
|
||||
if self.handrail {
|
||||
self.handrail_size
|
||||
} else if self.kind == RailingKind::Bars {
|
||||
TOP_BAR.1
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Breite des Handlaufs bzw. Obergurts.
|
||||
pub fn rail_w(&self) -> f64 {
|
||||
if self.handrail {
|
||||
self.handrail_size
|
||||
} else {
|
||||
TOP_BAR.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Hat das Geländer einen Handlauf als eigenes Teil (Stäbe immer: Handlauf oder Obergurt)?
|
||||
pub fn has_rail(&self) -> bool {
|
||||
self.handrail || self.kind == RailingKind::Bars
|
||||
}
|
||||
}
|
||||
|
||||
/// Vorgabe der Dicke je Art.
|
||||
pub fn default_thickness(kind: RailingKind) -> f64 {
|
||||
match kind {
|
||||
RailingKind::Glass => 0.02,
|
||||
RailingKind::Solid => 0.15,
|
||||
RailingKind::Perforated => 0.004,
|
||||
_ => 0.02,
|
||||
}
|
||||
}
|
||||
|
||||
/// Handlauf vorhanden? Fehlt die Angabe: bei Stäben und Glas ja, sonst nein.
|
||||
pub fn has_handrail(r: &Railing) -> bool {
|
||||
r.handrail.unwrap_or(matches!(r.kind, RailingKind::Bars | RailingKind::Glass))
|
||||
}
|
||||
|
||||
/// Fusshöhe (absolut): Geschoss-UK + `baseOffset`.
|
||||
pub fn base_z(p: &Project, r: &Railing) -> f64 {
|
||||
p.floor(&r.floor_id).map_or(0.0, |f| f.base_elevation.unwrap_or(0.0)) + r.base_offset.filter(|v| v.is_finite()).unwrap_or(0.0)
|
||||
}
|
||||
|
||||
/// Aufgelöste Masse; `None` bei Unsinn (nicht endliche Höhe, Höhe ≤ 0, weniger als 2 Punkte).
|
||||
pub fn spec(p: &Project, r: &Railing) -> Option<Spec> {
|
||||
let height = r.height;
|
||||
if !(height.is_finite() && height > 0.0) || height > 20.0 || axis(r).is_none() {
|
||||
return None;
|
||||
}
|
||||
let z0 = base_z(p, r);
|
||||
if !z0.is_finite() {
|
||||
return None;
|
||||
}
|
||||
let dim = |v: Option<f64>, d: f64, lo: f64, hi: f64| v.filter(|v| v.is_finite() && *v > 0.0).map_or(d, |v| v.clamp(lo, hi));
|
||||
let bar_size = dim(r.bar_size, 0.014, 0.004, 0.1);
|
||||
// Lichtes Mass ≤ 12 cm: Achsabstand höchstens 12 cm plus Stabbreite.
|
||||
let bar_spacing = dim(r.bar_spacing, 0.12, 0.03, 1.0).min(MAX_CLEAR_GAP + bar_size);
|
||||
Some(Spec {
|
||||
kind: if r.kind == RailingKind::Unknown { RailingKind::Bars } else { r.kind },
|
||||
height,
|
||||
z0,
|
||||
thickness: dim(r.thickness, default_thickness(r.kind), 0.002, 1.0),
|
||||
bar_spacing,
|
||||
bar_size,
|
||||
handrail: has_handrail(r),
|
||||
handrail_size: dim(r.handrail_size, 0.04, 0.02, 0.15).min(height / 2.0),
|
||||
})
|
||||
}
|
||||
|
||||
/// Achse als Zug: aufeinanderfolgende gleiche Punkte entfallen, ein geschlossener Zug endet auf seinem Anfang;
|
||||
/// `None` bei weniger als zwei verschiedenen Punkten oder nicht endlichen Koordinaten.
|
||||
pub fn axis(r: &Railing) -> Option<Vec<P>> {
|
||||
let mut pts: Vec<P> = Vec::with_capacity(r.points.len() + 1);
|
||||
for q in &r.points {
|
||||
if !q.x.is_finite() || !q.y.is_finite() {
|
||||
return None;
|
||||
}
|
||||
let q = [q.x, q.y];
|
||||
if pts.last().is_none_or(|l| (l[0] - q[0]).abs() > 1e-6 || (l[1] - q[1]).abs() > 1e-6) {
|
||||
pts.push(q);
|
||||
}
|
||||
}
|
||||
if pts.len() < 2 {
|
||||
return None;
|
||||
}
|
||||
// Ein Punkt am Ende gleich dem Anfang schliesst den Zug (mit mindestens drei Ecken).
|
||||
if r.closed == Some(true) && pts.len() >= 3 && !is_closed(&pts) {
|
||||
pts.push(pts[0]);
|
||||
}
|
||||
Some(pts)
|
||||
}
|
||||
|
||||
/// Länge der Achse (m).
|
||||
pub fn length(axis: &[P]) -> f64 {
|
||||
axis.windows(2).map(|w| crate::jsmath::hypot2(w[1][0] - w[0][0], w[1][1] - w[0][1])).sum()
|
||||
}
|
||||
|
||||
/// Streifen der Breite `2·half` um die Achse mit Gehrung: ein Viereck je Teilstrecke (gemeinsame Gehrungskanten,
|
||||
/// Gegenuhrzeigersinn), dazu die Ränder links und rechts der Laufrichtung.
|
||||
pub fn strips(axis: &[P], half: f64) -> (Vec<Vec<P>>, Vec<P>, Vec<P>) {
|
||||
let (l, r) = (offset_polyline(axis, half), offset_polyline(axis, -half));
|
||||
let quads = (0..axis.len().saturating_sub(1))
|
||||
.map(|i| vec![r[i], r[i + 1], l[i + 1], l[i]])
|
||||
.filter(|q| area(q).abs() > 1e-10 && q.iter().all(|v| v[0].is_finite() && v[1].is_finite()))
|
||||
.collect();
|
||||
(quads, l, r)
|
||||
}
|
||||
|
||||
fn area(q: &[P]) -> f64 {
|
||||
let n = q.len();
|
||||
(0..n).map(|i| q[i][0] * q[(i + 1) % n][1] - q[(i + 1) % n][0] * q[i][1]).sum::<f64>() / 2.0
|
||||
}
|
||||
|
||||
/// Quadrat der Kantenlänge `s` um `c`, in Richtung `d` (Einheit) gedreht (Gegenuhrzeigersinn).
|
||||
fn square(c: P, d: P, s: f64) -> Vec<P> {
|
||||
let (h, n) = (s / 2.0, [-d[1], d[0]]);
|
||||
let at = |a: f64, b: f64| [c[0] + d[0] * a + n[0] * b, c[1] + d[1] * a + n[1] * b];
|
||||
vec![at(-h, -h), at(h, -h), at(h, h), at(-h, h)]
|
||||
}
|
||||
|
||||
/// Pfosten- und Stabstellen längs der Achse: `(Lage, Richtung)`. Pfosten an jedem Eck und höchstens [`POST_GAP`]
|
||||
/// auseinander, Stäbe gleichmässig dazwischen, nicht nahe an einem Pfosten.
|
||||
pub fn stations(axis: &[P], spec: &Spec) -> (Vec<(P, P)>, Vec<(P, P)>) {
|
||||
let total = length(axis);
|
||||
let (mut posts, mut bars) = (Vec::new(), Vec::new());
|
||||
if !total.is_finite() || total / POST_GAP > MAX_POSTS {
|
||||
return (posts, bars);
|
||||
}
|
||||
let with_bars = total / spec.bar_spacing.max(1e-3) <= MAX_BARS;
|
||||
let closed = is_closed(axis);
|
||||
let nseg = axis.len() - 1;
|
||||
for (i, w) in axis.windows(2).enumerate() {
|
||||
let len = crate::jsmath::hypot2(w[1][0] - w[0][0], w[1][1] - w[0][1]);
|
||||
if len < 1e-9 {
|
||||
continue;
|
||||
}
|
||||
let d = [(w[1][0] - w[0][0]) / len, (w[1][1] - w[0][1]) / len];
|
||||
let at = |t: f64| [w[0][0] + (w[1][0] - w[0][0]) * t, w[0][1] + (w[1][1] - w[0][1]) * t];
|
||||
let n_post = (len / POST_GAP).ceil().max(1.0) as usize;
|
||||
// Letzter Eckpfosten nur am offenen Ende (geschlossen: der Anfang steht schon).
|
||||
for k in 0..n_post + usize::from(i + 1 == nseg && !closed) {
|
||||
posts.push((at(k as f64 / n_post as f64), d));
|
||||
}
|
||||
if with_bars {
|
||||
let n_bar = (len / spec.bar_spacing).round().max(1.0) as usize;
|
||||
let gap = len / n_post as f64;
|
||||
for k in 1..n_bar {
|
||||
let t = k as f64 / n_bar as f64;
|
||||
let f = (t * n_post as f64).fract();
|
||||
if f.min(1.0 - f) * gap > POST_SIZE / 2.0 + spec.bar_size / 2.0 + 0.01 {
|
||||
bars.push((at(t), d));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
(posts, bars)
|
||||
}
|
||||
|
||||
/// Prismen des Geländers; leer bei Unsinn.
|
||||
pub fn pieces(p: &Project, r: &Railing) -> Vec<Piece> {
|
||||
let (Some(s), Some(ax)) = (spec(p, r), axis(r)) else { return Vec::new() };
|
||||
let mut out = Vec::new();
|
||||
let top = s.top();
|
||||
let under = top - s.rail_h();
|
||||
let strip_pieces = |half: f64, z0: f64, z1: f64, part: Part, out: &mut Vec<Piece>| {
|
||||
if z1 - z0 > 1e-6 {
|
||||
out.extend(strips(&ax, half).0.into_iter().map(|outline| Piece { outline, z0, z1, part }));
|
||||
}
|
||||
};
|
||||
match s.kind {
|
||||
RailingKind::Bars | RailingKind::Unknown => {
|
||||
let (posts, bars) = stations(&ax, &s);
|
||||
for (c, d) in &posts {
|
||||
out.push(Piece { outline: square(*c, *d, POST_SIZE), z0: s.z0, z1: under, part: Part::Post });
|
||||
}
|
||||
for (c, d) in &bars {
|
||||
out.push(Piece { outline: square(*c, *d, s.bar_size), z0: s.z0 + FOOT_Z.1, z1: under, part: Part::Bar });
|
||||
}
|
||||
strip_pieces(FOOT_W / 2.0, s.z0 + FOOT_Z.0, s.z0 + FOOT_Z.1, Part::Foot, &mut out);
|
||||
}
|
||||
_ => strip_pieces(s.thickness / 2.0, s.z0, under, Part::Fill, &mut out),
|
||||
}
|
||||
if s.has_rail() {
|
||||
strip_pieces(s.rail_w() / 2.0, under, top, Part::Rail, &mut out);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Anzahl Stäbe und Pfosten (Kennzahl der Objekt-Info).
|
||||
pub fn counts(p: &Project, r: &Railing) -> (usize, usize) {
|
||||
let (Some(s), Some(ax)) = (spec(p, r), axis(r)) else { return (0, 0) };
|
||||
if s.kind != RailingKind::Bars {
|
||||
return (0, 0);
|
||||
}
|
||||
let (posts, bars) = stations(&ax, &s);
|
||||
(bars.len(), posts.len())
|
||||
}
|
||||
|
||||
/// Kennzahlen für die Objekt-Info: Länge der Achse, absolute Fuss- und Oberkante, Stäbe, Pfosten, Fläche der Ansicht (m²);
|
||||
/// `None` für ein unbekanntes oder unsinniges Geländer.
|
||||
pub fn info(p: &Project, id: &str) -> Option<serde_json::Value> {
|
||||
let r = p.railings.as_deref()?.iter().find(|r| r.id == id)?;
|
||||
let (s, ax) = (spec(p, r)?, axis(r)?);
|
||||
let len = length(&ax);
|
||||
let (bars, posts) = counts(p, r);
|
||||
Some(serde_json::json!({"length": len, "baseZ": s.z0, "topZ": s.top(), "height": s.height, "bars": bars, "posts": posts, "area": len * s.height, "closed": is_closed(&ax)}))
|
||||
}
|
||||
|
||||
/// Anzeigename für Regeln und Listen (`railing_label`): Art und Länge.
|
||||
pub fn label(r: &Railing) -> String {
|
||||
let kind = match r.kind {
|
||||
RailingKind::Glass => "Glasgeländer",
|
||||
RailingKind::Solid => "Brüstung",
|
||||
RailingKind::Perforated => "Lochblechgeländer",
|
||||
_ => "Stabgeländer",
|
||||
};
|
||||
let len = axis(r).map_or(0.0, |a| length(&a));
|
||||
format!("{kind} {} m", crate::js_fmt::js_number((len * 100.0).round() / 100.0))
|
||||
}
|
||||
|
||||
/// Farbe eines Teils im 3D und in der Ansicht (Bauteil-Farbe der massiven Brüstung, sonst nach Art).
|
||||
pub fn color(p: &Project, r: &Railing, part: Part) -> [f64; 3] {
|
||||
let hex = |h: &str, d: [f64; 3]| crate::style::hex_to_rgb(h, d);
|
||||
match (r.kind, part) {
|
||||
(RailingKind::Glass, Part::Fill) => hex("#b7d3e0", [0.72, 0.83, 0.88]),
|
||||
(RailingKind::Perforated, Part::Fill) => hex("#9aa3ab", [0.6, 0.64, 0.67]),
|
||||
(RailingKind::Solid, Part::Fill) => {
|
||||
let d = [0.72, 0.71, 0.68];
|
||||
r.component_id.as_deref().and_then(|id| p.component(id)).map_or(d, |k| hex(&k.color, d))
|
||||
}
|
||||
_ => hex("#74797f", [0.45, 0.47, 0.5]),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn rail(kind: RailingKind, pts: &[(f64, f64)]) -> Railing {
|
||||
Railing { id: "g".into(), r#type: "railing".into(), floor_id: "eg".into(), category_code: CATEGORY.into(), points: pts.iter().map(|&(x, y)| Vec2 { x, y }).collect(), height: 1.0, kind, ..Default::default() }
|
||||
}
|
||||
|
||||
fn proj() -> Project {
|
||||
let mut p = Project::default();
|
||||
p.drawing_levels.push(DrawingLevel { id: "eg".into(), kind: DrawingLevelKind::Floor, base_elevation: Some(3.0), ..Default::default() });
|
||||
p
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spec_vorgaben_und_unsinn() {
|
||||
let p = proj();
|
||||
let s = spec(&p, &rail(RailingKind::Bars, &[(0.0, 0.0), (3.0, 0.0)])).unwrap();
|
||||
assert_eq!((s.height, s.z0, s.top()), (1.0, 3.0, 4.0));
|
||||
assert!(s.handrail && s.has_rail());
|
||||
// Lichtes Mass höchstens 12 cm: Achsabstand ≤ 0.12 + Stabbreite.
|
||||
let mut g = rail(RailingKind::Bars, &[(0.0, 0.0), (3.0, 0.0)]);
|
||||
g.bar_spacing = Some(0.5);
|
||||
let s = spec(&p, &g).unwrap();
|
||||
assert!(s.bar_spacing - s.bar_size <= MAX_CLEAR_GAP + 1e-12);
|
||||
// Basis relativ zum Geschoss.
|
||||
g.base_offset = Some(0.18);
|
||||
assert!((spec(&p, &g).unwrap().z0 - 3.18).abs() < 1e-12);
|
||||
// Unsinn.
|
||||
for bad in [rail(RailingKind::Bars, &[(0.0, 0.0)]), rail(RailingKind::Bars, &[(1.0, 1.0), (1.0, 1.0)]), rail(RailingKind::Bars, &[(0.0, 0.0), (f64::NAN, 1.0)]), Railing { height: 0.0, ..rail(RailingKind::Glass, &[(0.0, 0.0), (1.0, 0.0)]) }, Railing { height: f64::INFINITY, ..rail(RailingKind::Glass, &[(0.0, 0.0), (1.0, 0.0)]) }] {
|
||||
assert!(spec(&p, &bad).is_none() && pieces(&p, &bad).is_empty());
|
||||
}
|
||||
// Handlauf: Vorgabe je Art, ausdrückliche Angabe gewinnt.
|
||||
assert!(!has_handrail(&rail(RailingKind::Solid, &[(0.0, 0.0), (1.0, 0.0)])));
|
||||
assert!(has_handrail(&Railing { handrail: Some(true), ..rail(RailingKind::Solid, &[(0.0, 0.0), (1.0, 0.0)]) }));
|
||||
assert!(!has_handrail(&Railing { handrail: Some(false), ..rail(RailingKind::Bars, &[(0.0, 0.0), (1.0, 0.0)]) }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn staebe_pfosten_und_masse() {
|
||||
let p = proj();
|
||||
let r = rail(RailingKind::Bars, &[(0.0, 0.0), (3.0, 0.0)]);
|
||||
let pcs = pieces(&p, &r);
|
||||
let n = |part| pcs.iter().filter(|q| q.part == part).count();
|
||||
// 3 m: 3 Felder à 1 m → 4 Pfosten, 1 Fussschiene, 1 Handlauf.
|
||||
assert_eq!((n(Part::Post), n(Part::Foot), n(Part::Rail)), (4, 1, 1));
|
||||
// Stäbe: gleichmässig, lichtes Mass ≤ 12 cm (Achsabstand ≈ 0.12: ≥ 24 Stäbe).
|
||||
assert!(n(Part::Bar) >= 24, "{}", n(Part::Bar));
|
||||
assert_eq!(counts(&p, &r), (n(Part::Bar), 4));
|
||||
// Oberkante = Fuss + Höhe; alle Teile im Höhenbereich.
|
||||
let z1 = pcs.iter().map(|q| q.z1).fold(f64::MIN, f64::max);
|
||||
let z0 = pcs.iter().map(|q| q.z0).fold(f64::MAX, f64::min);
|
||||
assert!((z1 - 4.0).abs() < 1e-12 && (z0 - 3.0).abs() < 1e-12);
|
||||
// Querschnitte im Gegenuhrzeigersinn.
|
||||
assert!(pcs.iter().all(|q| area(&q.outline) > 0.0));
|
||||
// Der Abstand zweier Stäbe ist (lichtes Mass) höchstens 12 cm.
|
||||
let mut xs: Vec<f64> = pcs.iter().filter(|q| q.part == Part::Bar).map(|q| q.outline.iter().map(|v| v[0]).sum::<f64>() / 4.0).collect();
|
||||
xs.sort_by(f64::total_cmp);
|
||||
assert!(xs.windows(2).all(|w| w[1] - w[0] - 0.014 <= 0.1201), "{xs:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tafel_mit_gehrung_und_geschlossen() {
|
||||
let p = proj();
|
||||
let r = rail(RailingKind::Glass, &[(0.0, 0.0), (2.0, 0.0), (2.0, 2.0)]);
|
||||
let pcs = pieces(&p, &r);
|
||||
// Zwei Tafel-Streifen (je Teilstrecke) und ein Handlauf-Streifen je Teilstrecke.
|
||||
assert_eq!(pcs.iter().filter(|q| q.part == Part::Fill).count(), 2);
|
||||
assert_eq!(pcs.iter().filter(|q| q.part == Part::Rail).count(), 2);
|
||||
// Gehrung: die beiden Streifen teilen die Gehrungskante, die Summe der Flächen = Länge × Dicke ohne Überlappung.
|
||||
let a: f64 = pcs.iter().filter(|q| q.part == Part::Fill).map(|q| area(&q.outline)).sum();
|
||||
assert!((a - 4.0 * 0.02).abs() < 1e-3, "{a}");
|
||||
// Glas bis unter den Handlauf.
|
||||
let fill = pcs.iter().find(|q| q.part == Part::Fill).unwrap();
|
||||
assert!((fill.z1 - (4.0 - 0.04)).abs() < 1e-12);
|
||||
// Geschlossen: ein Zug mit Anfang = Ende, vier Streifen.
|
||||
let mut sq = rail(RailingKind::Solid, &[(0.0, 0.0), (2.0, 0.0), (2.0, 2.0), (0.0, 2.0)]);
|
||||
sq.closed = Some(true);
|
||||
assert_eq!(pieces(&p, &sq).iter().filter(|q| q.part == Part::Fill).count(), 4);
|
||||
// Brüstung ohne Handlauf: Tafel bis zur Oberkante.
|
||||
let top = pieces(&p, &sq).iter().map(|q| q.z1).fold(f64::MIN, f64::max);
|
||||
assert!((top - 4.0).abs() < 1e-12);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn riesig_gibt_keine_millionen_stuecke() {
|
||||
let p = proj();
|
||||
let r = rail(RailingKind::Bars, &[(0.0, 0.0), (1.0e6, 0.0)]);
|
||||
assert!(pieces(&p, &r).len() < 10);
|
||||
let r = rail(RailingKind::Bars, &[(0.0, 0.0), (3000.0, 0.0)]);
|
||||
let n = pieces(&p, &r).len();
|
||||
assert!(n > 2000 && n < 30_000, "{n}");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "railing_tests.rs"]
|
||||
mod view_tests;
|
||||
@@ -0,0 +1,220 @@
|
||||
//! [279] Geländer in allen Ableitungen: 3D-Netze und Platten, Schnitt, Ansicht, 3D-Dokument, IFC, Umbaufilter, Varianten,
|
||||
//! Befehl „railing", Verschieben, Gruppen und Verweise.
|
||||
|
||||
use crate::model::*;
|
||||
use crate::plan::domains::{plan_domains, PlanArgs};
|
||||
use crate::plan::prim::Primitive;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
/// Projekt mit einem Geländer `g` (offen, 4 m entlang x bei y = 0, Höhe 1 m) auf dem EG (Sockel 3.0 m), dazu Schnitt und Ansicht.
|
||||
fn project(kind: &str, extra: Value) -> Project {
|
||||
let mut r = json!({"id": "g", "type": "railing", "floorId": "eg", "categoryCode": "41", "points": [{"x": 0, "y": 0}, {"x": 4, "y": 0}], "height": 1.0, "kind": kind});
|
||||
for (k, v) in extra.as_object().unwrap() {
|
||||
r[k] = v.clone();
|
||||
}
|
||||
serde_json::from_value(json!({
|
||||
"id": "p", "name": "P", "lineStyles": [], "hatches": [], "components": [{"id": "c", "name": "Beton", "color": "#b0b0b0", "hatchId": ""}], "wallTypes": [],
|
||||
"layers": [{"code": "41", "name": "Geländer", "color": "#102030", "lw": 0.25, "visible": true, "locked": false}],
|
||||
"drawingLevels": [
|
||||
{"id": "eg", "name": "EG", "kind": "floor", "visible": true, "locked": false, "floorHeight": 3.0, "cutHeight": 1.0, "baseElevation": 3.0},
|
||||
{"id": "ans", "name": "Ansicht Süd", "kind": "elevation", "visible": true, "locked": false, "linePoints": [{"x": -5, "y": -5}, {"x": 10, "y": -5}], "directionSign": 1},
|
||||
{"id": "sc", "name": "Schnitt", "kind": "section", "visible": true, "locked": false, "linePoints": [{"x": 1.5, "y": -5}, {"x": 1.5, "y": 5}], "directionSign": 1}
|
||||
],
|
||||
"walls": [], "openings": [], "drawings2d": [], "railings": [r]
|
||||
}))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn level(p: &Project, id: &str) -> crate::plan::section::LevelSpec {
|
||||
let l = p.drawing_levels.iter().find(|l| l.id == id).unwrap();
|
||||
crate::plan::section::LevelSpec::from_json(&serde_json::to_value(l).unwrap())
|
||||
}
|
||||
|
||||
fn hide41() -> crate::plan::section::Visibility {
|
||||
crate::plan::section::Visibility { has_vis: true, invisible: ["41".to_string()].into_iter().collect(), ..Default::default() }
|
||||
}
|
||||
|
||||
fn picks(prims: &[Primitive]) -> usize {
|
||||
prims.iter().filter(|q| matches!(q, Primitive::Polygon { context_object_id: Some(id), .. } if id == "@railing:g")).count()
|
||||
}
|
||||
|
||||
fn plan(p: &Project, extra: Value) -> Vec<Primitive> {
|
||||
let mut t = json!({"floor": "eg", "show": ["41"], "scale": 50, "global": true});
|
||||
for (k, x) in extra.as_object().unwrap() {
|
||||
t[k] = x.clone();
|
||||
}
|
||||
plan_domains(p, &PlanArgs::parse_in(p, 1.0, &t.to_string()).unwrap()).unwrap().columns
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn netze_platten_und_pick() {
|
||||
// Stäbe: nur das Gestänge; Glas: Tafel und Gestänge (Handlauf).
|
||||
let bars = project("bars", json!({}));
|
||||
let m = crate::model3d::emit_railings(&bars);
|
||||
assert_eq!(m.len(), 1);
|
||||
assert!(matches!(m[0].owner, crate::model3d::Owner::Railing(0)));
|
||||
// Höhen im Netz: Fuss 3.0, Oberkante 4.0.
|
||||
let zs: Vec<f64> = m[0].positions.chunks_exact(3).map(|c| c[2]).collect();
|
||||
assert!((zs.iter().cloned().fold(f64::MAX, f64::min) - 3.0).abs() < 1e-9 && (zs.iter().cloned().fold(f64::MIN, f64::max) - 4.0).abs() < 1e-9);
|
||||
let glass = project("glass", json!({}));
|
||||
assert_eq!(crate::model3d::emit_railings(&glass).len(), 2);
|
||||
let slabs = crate::model3d::railing_slabs(&glass);
|
||||
assert!(!slabs.is_empty() && slabs.iter().all(|s| s.ceiling_id == "g" && matches!(s.source, crate::model3d::SlabSource::Railing { index: 0, .. })));
|
||||
// Pick-Geometrie: ein Eintrag mit Dreiecken.
|
||||
let pk = crate::model3d::pick_railings(&glass);
|
||||
assert_eq!(pk.len(), 1);
|
||||
assert!(!pk[0].tris.is_empty() && pk[0].railing_id == "g");
|
||||
// Das 3D-Modell trägt das Geländer bei den Stützen; ausgeblendete Klasse „41" entfernt es.
|
||||
let parts = crate::model3d::parts(&glass, true, 1.0, false).unwrap();
|
||||
assert!(parts.column_meshes.iter().any(|m| matches!(m.owner, crate::model3d::Owner::Railing(_))));
|
||||
let f = crate::model3d::ClassFilter::from_text(&glass, r#"{"hide":["41"]}"#);
|
||||
let hidden = crate::model3d::parts_filtered(&glass, true, 1.0, false, &f).unwrap();
|
||||
assert!(!hidden.column_meshes.iter().any(|m| matches!(m.owner, crate::model3d::Owner::Railing(_))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schnitt_durch_gelaender() {
|
||||
let p = project("bars", json!({}));
|
||||
let out = crate::plan::section::compute_section(&p, &level(&p, "sc"), &[]).unwrap().unwrap();
|
||||
// Geschnitten: Handlauf und Fussschiene (Gestänge) mit Herkunft und Klasse; schwarz gefüllt.
|
||||
let cuts: Vec<_> = out.cuts.iter().filter(|c| c.railing_id.as_deref() == Some("g")).collect();
|
||||
assert!(cuts.len() >= 2, "{} Bänder", out.cuts.len());
|
||||
assert!(cuts.iter().all(|c| c.category.as_deref() == Some("41") && c.source_id.as_deref() == Some("g")));
|
||||
// In der Projektion stehen die Pfosten/Stäbe als Kanten (Schnitt an x = 1.5: Stäbe dahinter bei x > 1.5).
|
||||
assert!(!out.visible.is_empty());
|
||||
// Ausgeblendete Klasse: nichts mehr.
|
||||
let vis = hide41();
|
||||
let o2 = crate::plan::section::compute_section_vis(&p, &level(&p, "sc"), &[], &vis).unwrap().unwrap();
|
||||
assert!(!o2.cuts.iter().any(|c| c.railing_id.is_some()));
|
||||
// Glas: eine dünne Tafel (2 cm) wird quer geschnitten.
|
||||
let g = project("glass", json!({}));
|
||||
let og = crate::plan::section::compute_section(&g, &level(&g, "sc"), &[]).unwrap().unwrap();
|
||||
let panel = og.cuts.iter().find(|c| c.railing_id.is_some() && c.fill.as_deref() == Some("#cfe3ee")).expect("Glasband");
|
||||
let xs: Vec<f64> = panel.pts.iter().map(|q| q[0]).collect();
|
||||
assert!((xs.iter().cloned().fold(f64::MIN, f64::max) - xs.iter().cloned().fold(f64::MAX, f64::min) - 0.02).abs() < 1e-3, "{xs:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ansicht_zeigt_gelaender_anwaehlbar() {
|
||||
for kind in ["bars", "glass", "solid", "perforated"] {
|
||||
let p = project(kind, json!({}));
|
||||
let (prims, _) = crate::plan::elevation::elevation_primitives(&p, &level(&p, "ans"), false, false, &crate::plan::section::Visibility::default(), 50.0).unwrap().unwrap();
|
||||
assert!(picks(&prims) > 0, "{kind}: keine anwählbare Fläche in der Ansicht");
|
||||
}
|
||||
// Brüstung: ein gefüllter Streifen über 4 m Länge (x) und 1 m Höhe.
|
||||
let p = project("solid", json!({"thickness": 0.2}));
|
||||
let (prims, _) = crate::plan::elevation::elevation_primitives(&p, &level(&p, "ans"), false, false, &crate::plan::section::Visibility::default(), 50.0).unwrap().unwrap();
|
||||
let w: f64 = prims
|
||||
.iter()
|
||||
.filter_map(|q| match q {
|
||||
Primitive::Polygon { pts, context_object_id: Some(id), .. } if id == "@railing:g" => Some(pts.iter().map(|v| v.x).fold(f64::MIN, f64::max) - pts.iter().map(|v| v.x).fold(f64::MAX, f64::min)),
|
||||
_ => None,
|
||||
})
|
||||
.fold(0.0, f64::max);
|
||||
assert!((w - 4.0).abs() < 1e-6, "{w}");
|
||||
// Ausgeblendete Klasse: keine Fläche.
|
||||
let vis = hide41();
|
||||
let hidden = crate::plan::elevation::elevation_primitives(&p, &level(&p, "ans"), false, false, &vis, 50.0).unwrap().map(|r| r.0).unwrap_or_default();
|
||||
assert_eq!(picks(&hidden), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dokument_3d_axo() {
|
||||
let p = project("glass", json!({}));
|
||||
let a = crate::plan::axo::AxoArgs::parse(&p, &json!({"view": "southeast", "scale": 100})).unwrap();
|
||||
let (prims, _) = crate::plan::axo::axo_primitives(&p, &a, false).unwrap().expect("Bild");
|
||||
assert!(picks(&prims) > 0, "Fläche mit Pick-Id fehlt");
|
||||
assert!(prims.iter().any(|q| matches!(q, Primitive::Line { cls, .. } if cls == "axo-edge" || cls == "axo-outline")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ifc_datensatz_ifcrailing() {
|
||||
let p = project("bars", json!({}));
|
||||
let f = crate::ifc_data::ifc_export_data(&p, &Default::default()).unwrap();
|
||||
let strings: Vec<String> = f.strings.iter().cloned().collect();
|
||||
assert!(strings.iter().any(|s| s == "g") && strings.iter().any(|s| s == "GUARDRAIL") && strings.iter().any(|s| s == "Dossier_Qto_Railing"), "{strings:?}");
|
||||
assert!(f.nums.contains(&26.0), "Datensatz RAILING");
|
||||
// Unsinn: kein Datensatz.
|
||||
let bad = project("bars", json!({"height": 0}));
|
||||
let f = crate::ifc_data::ifc_export_data(&bad, &Default::default()).unwrap();
|
||||
assert!(!f.nums.contains(&26.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn umbau_und_varianten_blenden_aus() {
|
||||
let mut p = project("glass", json!({"renovation": {"status": "demolish"}}));
|
||||
// Neubauplan: Abbruch weg; Bestandsplan: Abbruch steht (gestrichelt in Umbau-Farbe im Abbruchplan).
|
||||
assert_eq!(picks(&plan(&p, json!({"renovation": "neubau"}))), 0);
|
||||
assert!(picks(&plan(&p, json!({"renovation": "bestand"}))) > 0);
|
||||
let ab = plan(&p, json!({"renovation": "abbruch"}));
|
||||
assert!(ab.iter().any(|q| matches!(q, Primitive::Line { cls, dash: Some(Some(_)), .. } if cls == "railing-glass")), "Abbruch gestrichelt");
|
||||
// 3D und Schnitt folgen dem Filter über das Projekt ohne Ausgeblendetes.
|
||||
let q = crate::renovation::project_in_state(&p, Some("neubau"), None);
|
||||
assert!(q.railings.as_deref().unwrap_or(&[]).is_empty());
|
||||
// Varianten: ein Geländer in Variante B fehlt in A.
|
||||
p.renovation = None;
|
||||
p.railings.as_mut().unwrap()[0].renovation = None;
|
||||
p.railings.as_mut().unwrap()[0].design_option = Some(DesignOptionRef { set: "s".into(), option: "b".into(), ..Default::default() });
|
||||
p.design_option_sets = Some(vec![serde_json::from_value(json!({"id": "s", "name": "Brüstung", "options": [{"id": "a", "name": "A"}, {"id": "b", "name": "B"}], "primary": "a"})).unwrap()]);
|
||||
assert_eq!(picks(&plan(&p, json!({}))), 0);
|
||||
assert!(picks(&plan(&p, json!({"designOptions": "Brüstung=B"}))) > 0);
|
||||
assert!(crate::design_options::active(&p));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn befehl_railing_baut_ops() {
|
||||
let p = project("bars", json!({}));
|
||||
let root: serde_json::Map<String, Value> = serde_json::from_value(serde_json::to_value(&p).unwrap()).unwrap();
|
||||
let req = |v: Value| {
|
||||
let mut base = json!({"cmd": "railing", "ctx": {"level": "eg", "floorHeight": 3.0, "cat": "20", "wallType": "t"}, "stamp": "s"});
|
||||
for (k, x) in v.as_object().unwrap() {
|
||||
base[k] = x.clone();
|
||||
}
|
||||
base
|
||||
};
|
||||
let add = |ops: Vec<crate::ops::Op>| -> (String, Value) {
|
||||
match ops.into_iter().next() {
|
||||
Some(crate::ops::Op::Add { collection, items, .. }) => (collection, items[0].clone()),
|
||||
other => panic!("erwartet Add, war {other:?}"),
|
||||
}
|
||||
};
|
||||
let (coll, it) = add(crate::cmd_create::ops(&root, &p, &req(json!({"pts": [[0, 0], [2, 0], [2, 2]], "kind": "glass", "height": 1.1, "closed": true, "handrail": false}))).unwrap());
|
||||
assert_eq!((coll.as_str(), it["type"].as_str(), it["floorId"].as_str(), it["categoryCode"].as_str(), it["kind"].as_str()), ("railings", Some("railing"), Some("eg"), Some("41"), Some("glass")));
|
||||
assert_eq!((it["height"].as_f64(), it["closed"].as_bool(), it["handrail"].as_bool(), it["points"].as_array().map(|a| a.len())), (Some(1.1), Some(true), Some(false), Some(3)));
|
||||
// Vorgaben bei Unsinn; ein einzelner Punkt oder doppelte Punkte ergeben nichts.
|
||||
let (_, it) = add(crate::cmd_create::ops(&root, &p, &req(json!({"pts": [[0, 0], [2, 0]], "kind": "foo", "height": -3}))).unwrap());
|
||||
assert_eq!((it["kind"].as_str(), it["height"].as_f64()), (Some("bars"), Some(1.0)));
|
||||
assert!(crate::cmd_create::ops(&root, &p, &req(json!({"pts": [[0, 0], [0, 0]]}))).unwrap().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verschieben_und_gruppen() {
|
||||
let p = project("bars", json!({}));
|
||||
let root: serde_json::Map<String, Value> = serde_json::from_value(serde_json::to_value(&p).unwrap()).unwrap();
|
||||
let req: crate::cmd_transform::TransformReq = serde_json::from_value(json!({"sel": {"wallIds": [], "railingIds": ["g"]}, "op": "move", "pts": [[0, 0], [3, 1]], "mode": "move", "count": 1, "stamp": "s"})).unwrap();
|
||||
let ops = crate::cmd_transform::transform_ops(&root, &p, &req);
|
||||
let Some(crate::ops::Op::Replace { collection, entity }) = ops.first() else { panic!("erwartet Replace: {ops:?}") };
|
||||
assert_eq!(collection, "railings");
|
||||
let pts = entity["points"].as_array().unwrap();
|
||||
assert_eq!((pts[0]["x"].as_f64(), pts[0]["y"].as_f64(), pts[1]["x"].as_f64()), (Some(3.0), Some(1.0), Some(7.0)));
|
||||
// Gruppen: die Mitgliedschaft kennt Geländer; Verweisprüfung bemerkt ein fehlendes Mitglied.
|
||||
let mut q = p.clone();
|
||||
q.groups = Some(vec![Group { id: "gr".into(), railing_ids: Some(vec!["g".into(), "weg".into()]), ..Default::default() }]);
|
||||
assert_eq!(crate::groups::transitive_membership(&q, "gr").railing_ids, ["g", "weg"]);
|
||||
assert!(crate::project_refs::dangling_refs(&q).iter().any(|m| m.contains("weg")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn projektdatei_und_georef() {
|
||||
// Das Feld ist bekannt: kein Hinweis „unbekanntes Feld".
|
||||
let p = project("bars", json!({}));
|
||||
let text = serde_json::to_string(&p).unwrap();
|
||||
let parsed = crate::project_format::parse_project_file(&text, 0.0);
|
||||
match parsed {
|
||||
crate::project_format::Parsed::Ok { warnings, project, .. } => {
|
||||
assert!(!warnings.iter().any(|w| w.contains("railings")), "{warnings:?}");
|
||||
assert!(project.contains_key("railings"));
|
||||
}
|
||||
crate::project_format::Parsed::Err(e) => panic!("{e}"),
|
||||
}
|
||||
}
|
||||
@@ -471,6 +471,10 @@ impl View {
|
||||
for x in p.columns.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), out);
|
||||
}
|
||||
// [279] Geländer.
|
||||
for x in p.railings.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), out);
|
||||
}
|
||||
for x in p.extruded_solids.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), out);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user