[155] [150] Absturzsicherung am Deckenloch als 3D-Körper und IfcRailing (GUARDRAIL), gemeinsame Lage in stair_guard.rs; Höhenlinien-Beschriftungen weichen Stempeln ausserhalb ihres Raums aus und rücken an Bündeln statt zu fehlen
This commit is contained in:
15 files changed
+487
-187
No files matched your search
@@ -114,15 +114,16 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `*
|
||||
eigene Vorschau; Raumstempel setzt ohne Klemmung (nichts zu zeigen). · S
|
||||
- ◐ **[146]** Linienenden/-ecken. Druck-SVG achtet seit 9.11. auf `noStrokeEdges` (offene Kantenzüge, Test
|
||||
`ungestrichene_kante_ohne_strich`); Nähen in Metal-Chunks nur innerhalb eines Chunks (Kern `plan/line_ends.rs`, `render2d`). · M
|
||||
- ◐ **[150]** Gelände im Grundriss am Gebäude. Raumstempel ausserhalb ihres Raums sind kein Hindernis für
|
||||
Höhenlinien-Beschriftungen; Beschriftungen an Bündeln fehlen statt versetzt zu werden. · S
|
||||
- ◐ **[153]** Strichmuster in Papier-mm. Bögen mit Phase seit 9.11. ([169]: Plan-/Druck-SVG, PDF, Bogen-Shader; seit
|
||||
10.11. auch Ellipsenbögen, Länge numerisch),
|
||||
Kreise ohne (geschlossen), DXF/DWG ohne Phase je Objekt,
|
||||
Metal-Chunks verketten nur über das Ketten-Flag, React-SVG-Ansicht ohne Phase. · M
|
||||
- ◐ **[155]** Treppensymbol. (10.11.) Lauflinie hinter der Bruchlinie gestrichelt wie die Tritte (Pfeil bleibt ausgezogen); Raumstempel weichen allen Treppen-Linien aus (`stamp_obstacles_with` nimmt `d.stairs` ganz, Test `stempel_weichen_den_treppenlinien_aus`). Offen:
|
||||
Absturzsicherung nur im Grundriss (kein Geländer-Bauteil in 3D/IFC); Ende eines freien Lochrings ohne Gehrung;
|
||||
dichtes Belagsmuster in 1:100. · M
|
||||
- ◐ **[155]** Treppensymbol. (10.11.) Lauflinie hinter der Bruchlinie gestrichelt wie die Tritte (Pfeil bleibt ausgezogen); Raumstempel weichen allen Treppen-Linien aus (`stamp_obstacles_with` nimmt `d.stairs` ganz, Test `stempel_weichen_den_treppenlinien_aus`). (11.11.)
|
||||
Absturzsicherung am Deckenloch auch in 3D (Körper aus Pfosten, Handlauf, Stäben, `stairs3d::guard_mesh`; Lage aus dem
|
||||
gemeinsamen `stair_guard.rs`, gleiche Quelle wie der Grundriss; Teil der Treppen-Handläufe, pickbar mit der Treppe) und im
|
||||
IFC (eigenes IfcRailing GUARDRAIL an der IfcStair, Länge als Basismenge; Wire-Format STAIR: `n_rails` statt `has_rail`). Offen:
|
||||
Ende eines freien Lochrings ohne Gehrung; dichtes Belagsmuster in 1:100; im Explosionsbild steht die Sicherung beim
|
||||
Geschoss der Treppe statt der Decke; 3D-Darstellung nur als Zahlen/Golden geprüft (Metal nur macOS). · M
|
||||
- ◐ **[156]** Bodenbelag-Muster massstabsgerecht. Möbel nur als Blöcke/Körper (geschlossene 2D-Formen der Kategorie
|
||||
„Möbel“ sparen nicht aus); Deckenspiegel-Untersicht unverändert (alte Ausdünnung). Nassraum nach Name ist durch
|
||||
[158] ersetzt. · S
|
||||
@@ -563,3 +564,7 @@ exakte Durchdringung, [61] Zuordnung per Hand, [63] Profil je Kante, [70] Fläch
|
||||
`src/views/plan/planView/`), `plan/elevation.rs` → Ordner `plan/elevation/`, `ObjectInfoPanel.tsx` 2847 → rund 370
|
||||
Zeilen (Abschnitte in `src/panels/objectInfo/`); Liste in `doc/ARCHITEKTUR.md` Abschnitt 13. Rust-Testzahl gleich;
|
||||
Plan-Ansicht nur im Browser-Test (Chromium/e2e) geprüft, nicht in der Tauri-App
|
||||
- [150] Gelände im Grundriss am Gebäude (11.11.): Raumstempel ausserhalb ihres Raums (eigener Anker im Gelände) sind
|
||||
Hindernis der Höhenlinien-Beschriftungen (Räume werden vor dem Kontext gesetzt, `outside_stamps`); Beschriftungen an
|
||||
dichten Bündeln fehlen nicht mehr, sondern rücken entlang der Linie auf freie Stellen (Abschnitt, dann ganze Linie, erst
|
||||
zuletzt auf dem Bündel; `contour_prims`)
|
||||
@@ -53,7 +53,7 @@ Neues Modul: `<modul>.rs` und `mod` in `lib.rs`, Bindungen in `web/<modul>.rs` u
|
||||
| `joins.rs` | Wandknoten: Gehrung, T-Stoss, Kreuzung, je Schicht nach Priorität (`compute_joins()`) |
|
||||
| `wall_arc.rs` | Bogenwände |
|
||||
| `roof.rs`, `roof_skeleton.rs`, `skeleton.rs`, `roof_assembly.rs`, `dormer.rs` | Dächer (Straight Skeleton), Dach an Dach, Gauben |
|
||||
| `stair.rs`, `stair_rail.rs` | Treppen-Geometrie, Handlauf |
|
||||
| `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 |
|
||||
| `polygon_bool.rs`, `polygon_holes.rs`, `bulge.rs`, `curves.rs`, `delaunay.rs` | 2D-Booleans (i_overlay), Löcher, Bögen, Kurven, Triangulierung |
|
||||
|
||||
@@ -1627,16 +1627,14 @@ fn w_stair(f: &mut Flat, structure: f64, id: &str, predefined: &str, footprint:
|
||||
f.nums(&[l.z_rel, l.depth]);
|
||||
w_psets(f, &qto("Qto_SlabBaseQuantities", l.quantities.clone()));
|
||||
}
|
||||
match &parts.rail {
|
||||
Some(r) => {
|
||||
let (n, pre) = (f.str("Handlauf"), f.str("HANDRAIL"));
|
||||
f.nums(&[1.0, n, pre]);
|
||||
w_psets(f, &qto("Qto_RailingBaseQuantities", r.quantities.clone()));
|
||||
w_mesh(f, &r.mesh.positions, &r.mesh.indices, false);
|
||||
}
|
||||
None => {
|
||||
f.num(0.0);
|
||||
}
|
||||
// Geländer: Anzahl, dann je Geländer (Handlauf der Treppe, [155] Absturzsicherung am Deckenloch).
|
||||
let rails: Vec<(&str, &str, &crate::ifc_stairs::Rail)> = parts.rail.iter().map(|r| ("Handlauf", "HANDRAIL", r)).chain(parts.guard.iter().map(|r| ("Absturzsicherung", "GUARDRAIL", r))).collect();
|
||||
f.num(rails.len() as f64);
|
||||
for (name, predefined, r) in rails {
|
||||
let (n, pre) = (f.str(name), f.str(predefined));
|
||||
f.nums(&[n, pre]);
|
||||
w_psets(f, &qto("Qto_RailingBaseQuantities", r.quantities.clone()));
|
||||
w_mesh(f, &r.mesh.positions, &r.mesh.indices, false);
|
||||
}
|
||||
match &parts.column {
|
||||
Some(c) => {
|
||||
|
||||
@@ -77,6 +77,8 @@ pub struct StairParts {
|
||||
/// Podeste (IfcSlab LANDING), unteres zuerst; U mit Mittellauf: zwei.
|
||||
pub landings: Vec<Landing>,
|
||||
pub rail: Option<Rail>,
|
||||
/// [155] Absturzsicherung am Deckenloch, in dem die Treppe ankommt (IfcRailing GUARDRAIL).
|
||||
pub guard: Option<Rail>,
|
||||
/// Mittelsäule (Spindel) einer Wendel: Prisma + Stützen-Basismengen.
|
||||
pub column: Option<Landing>,
|
||||
}
|
||||
@@ -377,13 +379,25 @@ pub fn stair_parts(one: &Project, stair: &Stair, base: f64) -> StairParts {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let rail_meshes = model3d::emit_stair_railings(one);
|
||||
let rail_meshes = model3d::emit_stair_handrails(one);
|
||||
let rail = (!rail_meshes.is_empty()).then(|| {
|
||||
let (positions, indices) = concat(&rail_meshes);
|
||||
let sides = if one.stair_type(stair).and_then(|t| t.railing) == Some(StairTypeRailing::Beide) { 2.0 } else { 1.0 };
|
||||
Rail { mesh: ifc_mesh(positions, &indices, base), quantities: railing_quantities(walk_length(stair, rise) * sides) }
|
||||
});
|
||||
StairParts { flights, landings, rail, column }
|
||||
let guard_meshes = model3d::stair_guard_meshes(one);
|
||||
let guard = (!guard_meshes.is_empty()).then(|| {
|
||||
let (mut positions, mut indices) = (Vec::new(), Vec::new());
|
||||
for (_, m) in &guard_meshes {
|
||||
let off = (positions.len() / 3) as u32;
|
||||
positions.extend_from_slice(&m.positions);
|
||||
indices.extend(m.indices.iter().map(|k| k + off));
|
||||
}
|
||||
// Länge der Achsen aller Löcher, in denen die Treppe ankommt
|
||||
let length: f64 = one.drawing_levels.iter().map(|f| crate::stair_guard::arrivals(one, &f.id, &|_| true, &|| model3d::wall_footprints_of_floor(one, &f.id)).iter().map(|a| crate::stair_guard::axes_length(&a.axes)).sum::<f64>()).sum();
|
||||
Rail { mesh: ifc_mesh(positions, &indices, base), quantities: railing_quantities(length) }
|
||||
});
|
||||
StairParts { flights, landings, rail, guard, column }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -41,6 +41,7 @@ pub mod js_fmt;
|
||||
pub use dossier_hatch::jsmath;
|
||||
pub mod stairs3d;
|
||||
pub mod stair_rail;
|
||||
pub mod stair_guard;
|
||||
pub mod mesh3d;
|
||||
pub mod mesh_repair;
|
||||
pub mod ceilings3d;
|
||||
|
||||
@@ -274,7 +274,7 @@ pub fn pick_geometry(p: &Project) -> Result<PickGeometry, String> {
|
||||
|
||||
/// [137] Handläufe und Pfosten der Treppen als Welt-Dreiecke je Treppe (wie [`emit_stair_railings`]).
|
||||
pub fn pick_stair_railings(p: &Project) -> Vec<PickStairMesh> {
|
||||
let Some((stairs, buf)) = stair_input(p, |s, st| s.shape != StairShape::Unknown && st.and_then(|t| t.railing).is_some_and(|r| r != StairTypeRailing::Keine)) else { return vec![] };
|
||||
let (stairs, buf) = stair_input(p, |s, st| s.shape != StairShape::Unknown && st.and_then(|t| t.railing).is_some_and(|r| r != StairTypeRailing::Keine)).unwrap_or_default();
|
||||
let mut out: Vec<PickStairMesh> = Vec::new();
|
||||
for m in crate::stairs3d::railings(&buf) {
|
||||
let Some(&(_, stair)) = stairs.get(m.src) else { continue };
|
||||
@@ -284,6 +284,15 @@ pub fn pick_stair_railings(p: &Project) -> Vec<PickStairMesh> {
|
||||
None => out.push(PickStairMesh { tris, stair_id: stair.id.clone() }),
|
||||
}
|
||||
}
|
||||
// [155] Absturzsicherung gehört zur Treppe, die darin ankommt.
|
||||
for (si, m) in stair_guard_meshes(p) {
|
||||
let Some(stair) = p.stairs.as_deref().and_then(|v| v.get(si)) else { continue };
|
||||
let tris = extrusion_tris(&m.positions, &m.indices);
|
||||
match out.iter_mut().find(|o| o.stair_id == stair.id) {
|
||||
Some(o) => o.tris.extend(tris),
|
||||
None => out.push(PickStairMesh { tris, stair_id: stair.id.clone() }),
|
||||
}
|
||||
}
|
||||
out.retain(|o| !o.tris.is_empty());
|
||||
out
|
||||
}
|
||||
|
||||
@@ -126,9 +126,35 @@ pub fn stair_view_meshes(p: &Project) -> Vec<(usize, crate::mesh3d::Mesh, bool)>
|
||||
|
||||
/// Handlauf und Pfosten der Treppen (`emitStairRailings`); bei Wendeltreppen als Schraubensweep, bei
|
||||
/// Podesttreppen (L, U, gerade mit Podest) über die Podeste ([151]).
|
||||
pub fn emit_stair_railings(p: &Project) -> Vec<RMesh> {
|
||||
pub fn emit_stair_handrails(p: &Project) -> Vec<RMesh> {
|
||||
match stair_input(p, |s, st| s.shape != StairShape::Unknown && st.and_then(|t| t.railing).is_some_and(|r| r != StairTypeRailing::Keine)) {
|
||||
Some((_, buf)) => meshes_of(crate::stairs3d::railings(&buf), rail_rgb()),
|
||||
None => vec![],
|
||||
}
|
||||
}
|
||||
|
||||
/// Alle Wandumrisse eines Geschosses (Wände stehen der Absturzsicherung im Weg).
|
||||
pub fn wall_footprints_of_floor(p: &Project, floor: &str) -> Vec<crate::plan::wall_poche::WallFootprint> {
|
||||
crate::plan::domains::wall_footprints_of(p, floor, |_| true)
|
||||
}
|
||||
|
||||
/// [155] Absturzsicherung am Deckenloch ankommender Treppen (Lage: [`crate::stair_guard`]) als Körper je Treppe
|
||||
/// (Index in `p.stairs`), Modell [x, y, Höhe]; alle Wände des Geschosses stehen der Sicherung im Weg.
|
||||
pub fn stair_guard_meshes(p: &Project) -> Vec<(usize, crate::mesh3d::Mesh)> {
|
||||
let mut out: Vec<(usize, crate::mesh3d::Mesh)> = Vec::new();
|
||||
for f in p.drawing_levels.iter().filter(|f| f.kind == DrawingLevelKind::Floor) {
|
||||
for a in crate::stair_guard::arrivals(p, &f.id, &|_| true, &|| wall_footprints_of_floor(p, &f.id)) {
|
||||
if let Some(m) = crate::stairs3d::guard_mesh(&a.axes, a.z, a.stair) {
|
||||
out.push((a.stair, m));
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Handlauf, Pfosten und Absturzsicherung der Treppen (`emitStairRailings`).
|
||||
pub fn emit_stair_railings(p: &Project) -> Vec<RMesh> {
|
||||
let mut out = emit_stair_handrails(p);
|
||||
out.extend(meshes_of(stair_guard_meshes(p).into_iter().map(|(_, m)| m).collect(), rail_rgb()));
|
||||
out
|
||||
}
|
||||
@@ -662,50 +662,56 @@ fn contour_prims(c: &Ctx, st: &crate::excavation::SiteTerrain, iv: f64, every: i
|
||||
if hi < lo {
|
||||
continue;
|
||||
}
|
||||
let mut cands: Vec<f64> = Vec::new();
|
||||
let mut s = lo;
|
||||
while s <= hi + 1e-12 && cands.len() < 20_000 {
|
||||
cands.push(s);
|
||||
s += step;
|
||||
}
|
||||
cands.sort_by(|a, b| (a - target).abs().total_cmp(&(b - target).abs()));
|
||||
let mut best: Option<(usize, f64, [f64; 2], [f64; 2])> = None;
|
||||
for s in cands {
|
||||
if mine.iter().any(|m| {
|
||||
let d = (s - m).abs();
|
||||
(if l.closed { d.min(len - d) } else { d }) < spacing / 2.5
|
||||
}) {
|
||||
continue;
|
||||
// [150] Erst im Abschnitt auf einer wenig gekreuzten Stelle, sonst entlang der Linie verschoben (ganze
|
||||
// Linie, nächste Stelle zur Zielmitte zuerst), erst zuletzt auf dem Bündel — statt ganz ohne Beschriftung.
|
||||
let whole = if l.closed { (0.0, len) } else { (reserve, len - reserve) };
|
||||
let search = |lo: f64, hi: f64, max_x: usize| -> Option<(usize, f64, [f64; 2], [f64; 2])> {
|
||||
let mut cands: Vec<f64> = Vec::new();
|
||||
let mut s = lo;
|
||||
while s <= hi + 1e-12 && cands.len() < 20_000 {
|
||||
cands.push(s);
|
||||
s += step;
|
||||
}
|
||||
let (a, b) = (l.at(s - hw), l.at(s + hw));
|
||||
let cl = (b[0] - a[0]).hypot(b[1] - a[1]);
|
||||
if !(cl > 1.6 * hw) || l.bend(s - hw, s + hw) > 0.3 * text_h {
|
||||
continue;
|
||||
cands.sort_by(|a, b| (a - target).abs().total_cmp(&(b - target).abs()));
|
||||
let mut best: Option<(usize, f64, [f64; 2], [f64; 2])> = None;
|
||||
for s in cands {
|
||||
if mine.iter().any(|m| {
|
||||
let d = (s - m).abs();
|
||||
(if l.closed { d.min(len - d) } else { d }) < spacing / 2.5
|
||||
}) {
|
||||
continue;
|
||||
}
|
||||
let (a, b) = (l.at(s - hw), l.at(s + hw));
|
||||
let cl = (b[0] - a[0]).hypot(b[1] - a[1]);
|
||||
if !(cl > 1.6 * hw) || l.bend(s - hw, s + hw) > 0.3 * text_h {
|
||||
continue;
|
||||
}
|
||||
let u = [(b[0] - a[0]) / cl, (b[1] - a[1]) / cl];
|
||||
let m = [(a[0] + b[0]) / 2.0, (a[1] + b[1]) / 2.0];
|
||||
let padded = rot_rect(m, u, hw + pad_house, hv + pad_house);
|
||||
if in_house(&padded) || obst_grid.hits_convex(&padded) {
|
||||
continue;
|
||||
}
|
||||
let grown = rot_rect(m, u, hw + pad_label, hv + pad_label / 2.0);
|
||||
// [159] Rechteck zuerst (getrennte Rechtecke überlappen nicht).
|
||||
let gb = super::stamp_place::ring_bbox(&grown);
|
||||
if placed.iter().any(|(r, rb)| rb[2] >= gb[0] && rb[0] <= gb[2] && rb[3] >= gb[1] && rb[1] <= gb[3] && super::stamp_place::convex_overlap(r, &grown)) {
|
||||
continue;
|
||||
}
|
||||
let x = grid.crossings(&rot_rect(m, u, hw, hv), li);
|
||||
if x > max_x {
|
||||
continue;
|
||||
}
|
||||
if best.as_ref().is_none_or(|b| x < b.0) {
|
||||
best = Some((x, s, m, u));
|
||||
}
|
||||
if x == 0 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let u = [(b[0] - a[0]) / cl, (b[1] - a[1]) / cl];
|
||||
let m = [(a[0] + b[0]) / 2.0, (a[1] + b[1]) / 2.0];
|
||||
let padded = rot_rect(m, u, hw + pad_house, hv + pad_house);
|
||||
if in_house(&padded) || obst_grid.hits_convex(&padded) {
|
||||
continue;
|
||||
}
|
||||
let grown = rot_rect(m, u, hw + pad_label, hv + pad_label / 2.0);
|
||||
// [159] Rechteck zuerst (getrennte Rechtecke überlappen nicht).
|
||||
let gb = super::stamp_place::ring_bbox(&grown);
|
||||
if placed.iter().any(|(r, rb)| rb[2] >= gb[0] && rb[0] <= gb[2] && rb[3] >= gb[1] && rb[1] <= gb[3] && super::stamp_place::convex_overlap(r, &grown)) {
|
||||
continue;
|
||||
}
|
||||
let x = grid.crossings(&rot_rect(m, u, hw, hv), li);
|
||||
// Auf einem Bündel (Stützmauer, Baugrubenwand): lieber keine Beschriftung.
|
||||
if x > 1 {
|
||||
continue;
|
||||
}
|
||||
if best.as_ref().is_none_or(|b| x < b.0) {
|
||||
best = Some((x, s, m, u));
|
||||
}
|
||||
if x == 0 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
best
|
||||
};
|
||||
let best = search(lo, hi, 1).or_else(|| search(whole.0, whole.1, 1)).or_else(|| search(lo, hi, usize::MAX));
|
||||
let Some((_, s, m, u)) = best else { continue };
|
||||
mine.push(s);
|
||||
let r = rot_rect(m, u, hw, hv);
|
||||
@@ -1636,6 +1642,31 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// [150] Hindernis (z. B. Raumstempel ausserhalb seines Raums) auf einem Teil der Linien: die Beschriftungen
|
||||
/// rücken entlang der Linie auf freie Stellen, statt zu fehlen; keine liegt auf dem Hindernis.
|
||||
#[test]
|
||||
fn hoehenlinien_beschriftung_rueckt_vom_hindernis_weg() {
|
||||
let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 10.0, 40.0, 0.0, 10.0, 40.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() };
|
||||
let p = Project { context: Some(vec![ContextObject::TerrainMesh(t)]), ..Default::default() };
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "scale": 100}"#).unwrap();
|
||||
let c = Ctx::new(&p, &a);
|
||||
let run = |o: &super::super::stamp_place::Obstacles| {
|
||||
let mut out = Vec::new();
|
||||
plan_context_with(&c, &mut out, o);
|
||||
out.iter().filter_map(label_rect).collect::<Vec<_>>()
|
||||
};
|
||||
let free = run(&super::super::stamp_place::Obstacles::default());
|
||||
assert!(free.len() >= 6, "{}", free.len());
|
||||
// Stempel-Rechteck mitten auf dem Gelände (4 × 8 m): keine Beschriftung darauf, aber auch nicht weniger.
|
||||
let mut o = super::super::stamp_place::Obstacles::default();
|
||||
o.area(vec![[16.0, 1.0], [24.0, 1.0], [24.0, 9.0], [16.0, 9.0]]);
|
||||
let moved = run(&o);
|
||||
for (t, r) in &moved {
|
||||
assert!(!o.hits_convex(r), "Beschriftung {t} auf dem Stempel");
|
||||
}
|
||||
assert!(moved.len() >= free.len(), "Beschriftungen fehlen: {} statt {}", moved.len(), free.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn label_tag_wie_ts() {
|
||||
assert_eq!(section_label_tag("Schnitt A"), "A");
|
||||
|
||||
@@ -356,11 +356,16 @@ pub(super) fn resolve_hatch_or_none(p: &Project, hatch_id: &str, wall_angle_deg:
|
||||
|
||||
/// Footprints der gezeichneten Wände dieses Geschosses (`buildWallFootprints`).
|
||||
pub fn wall_footprints(c: &Ctx) -> Vec<WallFootprint> {
|
||||
c.p.walls
|
||||
wall_footprints_of(c.p, &c.a.floor, |w| c.vis(&w.category_code, &w.id))
|
||||
}
|
||||
|
||||
/// Wandumrisse eines Geschosses (`keep` wählt die Wände vor; 3D: alle).
|
||||
pub fn wall_footprints_of(p: &Project, floor: &str, keep: impl Fn(&Wall) -> bool) -> Vec<WallFootprint> {
|
||||
p.walls
|
||||
.iter()
|
||||
.filter(|w| w.floor_id == c.a.floor && c.vis(&w.category_code, &w.id))
|
||||
.filter(|w| w.floor_id == floor && keep(w))
|
||||
.map(|w| {
|
||||
let t = c.p.wall_thickness(w, 0.2);
|
||||
let t = p.wall_thickness(w, 0.2);
|
||||
let ref_off = crate::joins::reference_offset(crate::model3d::wall_reference(w), t);
|
||||
wall_footprint([w.start.x, w.start.y], [w.end.x, w.end.y], t, ref_off)
|
||||
})
|
||||
@@ -1658,14 +1663,21 @@ fn domains_after(c: &Ctx, out: &mut DomainPrims, bounds: &mut Bounds) {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let mut o = drawn.clone();
|
||||
}
|
||||
// Räume vor dem Kontext: Stempel ausserhalb ihres Raums (eigener Anker im Gelände) sind Hindernisse der
|
||||
// Höhenlinien-Beschriftungen; Stempel im Raum liegen im Fussabdruck, wo keine Beschriftung steht.
|
||||
let obstacles = stamp_obstacles_with(out, drawn.clone());
|
||||
rooms(c, &mut out.rooms, bounds, &obstacles);
|
||||
if c.a.global {
|
||||
let mut o = drawn;
|
||||
for q in out.sections.iter().filter(|q| matches!(q, Primitive::DrawingText { .. })) {
|
||||
o.add_prim(q);
|
||||
}
|
||||
for r in outside_stamps(c, &out.rooms) {
|
||||
o.area(r);
|
||||
}
|
||||
super::context::plan_context_with(c, &mut out.context, &o);
|
||||
}
|
||||
let obstacles = stamp_obstacles_with(out, drawn);
|
||||
rooms(c, &mut out.rooms, bounds, &obstacles);
|
||||
// [156] Bodenbelag nach den Raumstempeln (spart sie aus), zuunterst in der Gruppe der Decken.
|
||||
let mut finish = Vec::new();
|
||||
floor_finishes(c, &out.rooms, &mut finish);
|
||||
@@ -1674,6 +1686,24 @@ fn domains_after(c: &Ctx, out: &mut DomainPrims, bounds: &mut Bounds) {
|
||||
}
|
||||
}
|
||||
|
||||
/// [150] Rechtecke der Raumstempel, deren Mitte ausserhalb ihres Raums liegt (eigener Anker im Gelände).
|
||||
fn outside_stamps(c: &Ctx, rooms: &[Primitive]) -> Vec<Vec<[f64; 2]>> {
|
||||
let mut out = Vec::new();
|
||||
for q in rooms {
|
||||
let Primitive::Text { at, doc, extra_lines, base_pt, room_id: Some(id), .. } = q else { continue };
|
||||
let Some(room) = c.p.rooms.as_deref().unwrap_or(&[]).iter().find(|r| &r.id == id) else { continue };
|
||||
let ring: Vec<[f64; 2]> = room.boundary.iter().map(|v| [v.x, v.y]).collect();
|
||||
if ring.len() < 3 || crate::surface_pattern::point_in([at.x, at.y], &ring) {
|
||||
continue;
|
||||
}
|
||||
let (w, h) = stamp_size_m(doc, extra_lines, *base_pt, c.a.scale);
|
||||
if w.is_finite() && h.is_finite() {
|
||||
out.push(vec![[at.x - w / 2.0, at.y - h / 2.0], [at.x + w / 2.0, at.y - h / 2.0], [at.x + w / 2.0, at.y + h / 2.0], [at.x - w / 2.0, at.y + h / 2.0]]);
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Reihenfolge der Gruppen im Plan-Puffer der Abfrage `planDomains`: Schatten und Baurecht
|
||||
/// zuunterst, die Domänen, die Baurechts-Verstösse zuoberst (`extras.rs`).
|
||||
pub const GROUPS: [&str; 12] = ["under", "ceilings", "roofs", "rooms", "walls", "stairs", "columns", "drawings", "solids", "context", "sections", "violations"];
|
||||
@@ -3088,6 +3118,22 @@ mod tests {
|
||||
assert!(st.iter().all(|x| !matches!(x, Primitive::Line { stair_id, .. } if stair_id.as_deref() == Some("ST1"))), "{st:?}");
|
||||
}
|
||||
|
||||
/// [150] Nur der Stempel mit Anker ausserhalb seines Raums wird Hindernis der Höhenlinien-Beschriftungen.
|
||||
#[test]
|
||||
fn stempel_ausserhalb_des_raums_ist_hindernis() {
|
||||
let mut p = sample();
|
||||
let t = serde_json::json!({ "floor": "eg", "show": ["20", "21", "30", "40", "50", "60"], "grey": [], "scale": 100 }).to_string();
|
||||
let a = PlanArgs::parse(1.0, &t).unwrap();
|
||||
let rooms = |p: &Project| plan_domains(p, &a).unwrap().rooms;
|
||||
let idx = p.rooms.as_ref().unwrap().iter().position(|r| r.floor_id == "eg" && r.boundary.len() >= 3).unwrap();
|
||||
assert!(outside_stamps(&Ctx::new(&p, &a), &rooms(&p)).is_empty(), "Stempel im Raum: kein Hindernis");
|
||||
p.rooms.as_mut().unwrap()[idx].stamp_anchor = Some(Vec2 { x: -30.0, y: -30.0 });
|
||||
let r = rooms(&p);
|
||||
let out = outside_stamps(&Ctx::new(&p, &a), &r);
|
||||
assert_eq!(out.len(), 1);
|
||||
assert!(out[0].iter().all(|q| (q[0] + 30.0).abs() < 5.0 && (q[1] + 30.0).abs() < 5.0), "{out:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn puffer_gruppen_wie_domaenen() {
|
||||
let p = sample();
|
||||
|
||||
@@ -12,11 +12,6 @@ use crate::model::*;
|
||||
const LINE_CLS: [&str; 7] = ["stair-outline", "stair-tread", "stair-break", "stair-run", "stair-arrow", "stair-handrail", "stair-guard"];
|
||||
/// Strichmuster der verdeckten Tritte.
|
||||
const TREAD_DASH: [f64; 2] = super::line_pattern::HIDDEN;
|
||||
/// [155] Achse der Absturzsicherung: so weit vom Lochrand auf die Decke gerückt wie der Handlauf von der
|
||||
/// Treppenkante (Rohr ganz auf der Decke).
|
||||
const GUARD_INSET: f64 = crate::stair_rail::RAIL_INSET;
|
||||
/// [155] Lochrand am Austritt: bis zu diesem Abstand von der Austrittskante keine Absturzsicherung.
|
||||
const ARRIVAL_TOL: f64 = 0.15;
|
||||
|
||||
/// `stairLabel` (für `object_name`).
|
||||
pub fn stair_label(s: &Stair) -> String {
|
||||
@@ -264,120 +259,31 @@ fn run_opts(o: &super::model_view::StairOpts, scale: f64) -> crate::plan::stair_
|
||||
|
||||
/// [155] Treppen tieferer Geschosse, die auf diesem Geschoss ankommen: durch das Loch der Decke, auf der
|
||||
/// das Geschoss steht, von oben gesehen (ausgezogen, auf das Loch beschnitten), dazu die Absturzsicherung
|
||||
/// an den freien Lochrändern (nicht unter Wänden, nicht am Austritt der Treppe).
|
||||
/// an den freien Lochrändern (nicht unter Wänden, nicht am Austritt der Treppe; Lage: [`crate::stair_guard`]).
|
||||
fn arriving(c: &Ctx, out: &mut Vec<Primitive>, double: bool, opts: &super::model_view::StairOpts) {
|
||||
use crate::stair_rail::P;
|
||||
let p = c.p;
|
||||
let Some(floor) = p.floor(&c.a.floor) else { return };
|
||||
// [157] Nur Geschoss-Grundrisse (nicht die 2D-Ebene eines Schnitts/einer Ansicht, Bezugshöhe sonst 0).
|
||||
if floor.kind != DrawingLevelKind::Floor {
|
||||
return;
|
||||
}
|
||||
let base = floor.base_elevation.unwrap_or(0.0);
|
||||
// Löcher der Decken unter dem Geschossboden (Oberkante wie bei den Bodenbelägen).
|
||||
let holes: Vec<Vec<P>> = p
|
||||
.ceilings
|
||||
.as_deref()
|
||||
.unwrap_or(&[])
|
||||
.iter()
|
||||
.filter(|ce| {
|
||||
let top = p.ceiling_vertical_extent(ce).1;
|
||||
top >= base - 0.3 && top <= base + 0.05
|
||||
})
|
||||
.flat_map(|ce| crate::opening_shape::ceiling_hole_rings(p, ce))
|
||||
.map(|h| h.iter().map(|q| [q.x, q.y]).collect::<Vec<P>>())
|
||||
.filter(|h| h.len() >= 3 && h.iter().all(|q| q[0].is_finite() && q[1].is_finite()))
|
||||
.collect();
|
||||
if holes.is_empty() {
|
||||
return;
|
||||
}
|
||||
let mut fps: Option<Vec<super::wall_poche::WallFootprint>> = None;
|
||||
for s in p.stairs.as_deref().unwrap_or(&[]).iter().filter(|s| s.floor_id != c.a.floor && c.vis(&s.category_code, &s.id)) {
|
||||
let (zb, zt) = p.stair_vertical_extent(s);
|
||||
if !((zt - base).abs() <= 0.05 && zb < base - 1e-6 && (zt - zb).is_finite()) {
|
||||
continue;
|
||||
}
|
||||
let params = s.encode();
|
||||
let Some(sp) = crate::stair::decode_params(¶ms) else { continue };
|
||||
let geo = kernel2d::stair_geometry(&sp, zt - zb);
|
||||
let centroid = |t: &kernel2d::TreadRect| {
|
||||
let n = t.pts.len().max(1) as f64;
|
||||
[t.pts.iter().map(|q| q.x).sum::<f64>() / n, t.pts.iter().map(|q| q.y).sum::<f64>() / n]
|
||||
};
|
||||
let own: Vec<Vec<P>> = holes.iter().filter(|h| geo.treads.iter().any(|t| crate::surface_pattern::point_in(centroid(t), h))).cloned().collect();
|
||||
if own.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let arrivals = crate::stair_guard::arrivals(p, &c.a.floor, &|s| c.vis(&s.category_code, &s.id), &|| super::domains::wall_footprints(c));
|
||||
for a in arrivals {
|
||||
let s = &p.stairs.as_deref().unwrap_or(&[])[a.stair];
|
||||
let greyed = Some(c.greyed(&s.category_code));
|
||||
let ov = c.overrides(Some("stair"), &s.category_code, Some(&stair_label(s)));
|
||||
let lw = ov.lineweight.unwrap_or_else(|| c.cat(&s.category_code).map_or(WALL_FALLBACK_MM, |k| k.lw));
|
||||
let stroke = ov.color.as_deref().or(s.color.as_deref()).unwrap_or(POCHE_STROKE).to_string();
|
||||
// ganz unter der Schnittebene: alles ausgezogen, keine Bruchlinie
|
||||
let f = crate::plan::stair_symbol::plan_stair_run(¶ms, zt - zb, zt - zb + 1.0, lw, s.arrow_style == Some(StairArrowStyle::Filled), 0.0, railing_code(p, s), double, &own, &run_opts(opts, c.a.scale));
|
||||
let f = crate::plan::stair_symbol::plan_stair_run(&a.params, a.rise, a.rise + 1.0, lw, s.arrow_style == Some(StairArrowStyle::Filled), 0.0, railing_code(p, s), double, &a.rings, &run_opts(opts, c.a.scale));
|
||||
emit(out, &f, &stroke, greyed, &s.id, opts);
|
||||
// Austrittskante: Hinterkante des obersten Tritts.
|
||||
let Some(last) = geo.treads.iter().filter(|t| t.pts.len() >= 4).max_by(|a, b| a.top_rise.total_cmp(&b.top_rise)) else { continue };
|
||||
let arrival = if sp.shape == "spiral" { (last.pts[3], last.pts[2]) } else { (last.pts[1], last.pts[2]) };
|
||||
let fps = fps.get_or_insert_with(|| super::domains::wall_footprints(c));
|
||||
for ring in &own {
|
||||
for pts in guard_chains(ring, fps, ([arrival.0.x, arrival.0.y], [arrival.1.x, arrival.1.y])) {
|
||||
let area: f64 = (0..ring.len()).map(|i| ring[i][0] * ring[(i + 1) % ring.len()][1] - ring[(i + 1) % ring.len()][0] * ring[i][1]).sum();
|
||||
// nach aussen (auf die Decke): rechts der Ringrichtung bei Gegenuhrzeigersinn
|
||||
let d = if area > 0.0 { -GUARD_INSET } else { GUARD_INSET };
|
||||
let axis = crate::stair_rail::offset_polyline(&pts, d);
|
||||
let r = crate::stair_rail::RAIL_THICK / 2.0;
|
||||
let lines = if double { vec![crate::stair_rail::offset_polyline(&axis, r), crate::stair_rail::offset_polyline(&axis, -r)] } else { vec![axis] };
|
||||
for l in lines {
|
||||
for w in l.windows(2) {
|
||||
out.push(stair_line(v2(w[0][0], w[0][1]), v2(w[1][0], w[1][1]), LINE_CLS[6], crate::plan::stair_symbol::HANDRAIL_MM, None, &stroke, greyed, &s.id));
|
||||
}
|
||||
for axis in &a.axes {
|
||||
let r = crate::stair_rail::RAIL_THICK / 2.0;
|
||||
let lines = if double { vec![crate::stair_rail::offset_polyline(axis, r), crate::stair_rail::offset_polyline(axis, -r)] } else { vec![axis.clone()] };
|
||||
for l in lines {
|
||||
for w in l.windows(2) {
|
||||
out.push(stair_line(v2(w[0][0], w[0][1]), v2(w[1][0], w[1][1]), LINE_CLS[6], crate::plan::stair_symbol::HANDRAIL_MM, None, &stroke, greyed, &s.id));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// [155] Freie Lochränder als Züge in Ringrichtung: ohne Stücke unter Wänden und ohne die Austrittskante.
|
||||
fn guard_chains(ring: &[[f64; 2]], fps: &[super::wall_poche::WallFootprint], arrival: ([f64; 2], [f64; 2])) -> Vec<Vec<[f64; 2]>> {
|
||||
let near = |a: [f64; 2], b: [f64; 2]| (a[0] - b[0]).abs() < 1e-7 && (a[1] - b[1]).abs() < 1e-7;
|
||||
let mut pieces: Vec<[[f64; 2]; 2]> = Vec::new();
|
||||
for [a, b] in super::wall_poche::ceiling_outline_lines(ring, &[], fps) {
|
||||
// Teil, der an der Austrittskante liegt (beide Enden der Kante nahe der Geraden a–b), entfällt.
|
||||
let d = [b[0] - a[0], b[1] - a[1]];
|
||||
let l = d[0].hypot(d[1]);
|
||||
if !(l > 1e-9) {
|
||||
continue;
|
||||
}
|
||||
let u = [d[0] / l, d[1] / l];
|
||||
let off = |q: [f64; 2]| ((q[0] - a[0]) * u[1] - (q[1] - a[1]) * u[0]).abs();
|
||||
let t = |q: [f64; 2]| ((q[0] - a[0]) * u[0] + (q[1] - a[1]) * u[1]) / l;
|
||||
let mut keep = vec![(0.0, 1.0)];
|
||||
if off(arrival.0) < ARRIVAL_TOL && off(arrival.1) < ARRIVAL_TOL {
|
||||
let pad = ARRIVAL_TOL / l;
|
||||
let (t0, t1) = (t(arrival.0).min(t(arrival.1)) - pad, t(arrival.0).max(t(arrival.1)) + pad);
|
||||
keep = [(0.0, t0.min(1.0)), (t1.max(0.0), 1.0)].into_iter().filter(|(x, y)| (y - x) * l > 1e-6).collect();
|
||||
}
|
||||
for (t0, t1) in keep {
|
||||
pieces.push([[a[0] + d[0] * t0, a[1] + d[1] * t0], [a[0] + d[0] * t1, a[1] + d[1] * t1]]);
|
||||
}
|
||||
}
|
||||
// aneinanderhängende Stücke zu Zügen
|
||||
let mut chains: Vec<Vec<[f64; 2]>> = Vec::new();
|
||||
for [a, b] in pieces {
|
||||
match chains.last_mut() {
|
||||
Some(ch) if ch.last().is_some_and(|q| near(*q, a)) => ch.push(b),
|
||||
_ => chains.push(vec![a, b]),
|
||||
}
|
||||
}
|
||||
// letzter Zug schliesst an den ersten an
|
||||
if chains.len() >= 2 && near(*chains.last().unwrap().last().unwrap(), chains[0][0]) {
|
||||
let mut last = chains.pop().unwrap();
|
||||
last.extend(chains[0].iter().skip(1).copied());
|
||||
chains[0] = last;
|
||||
}
|
||||
chains
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
//! [155] Absturzsicherung am Deckenloch einer ankommenden Treppe: eine Quelle für Grundriss
|
||||
//! (`plan/stairs.rs`), 3D (`model3d/stairs.rs`, Körper aus `stairs3d::guard_mesh`) und IFC (`ifc_stairs`).
|
||||
//!
|
||||
//! Eine Treppe, deren Oberkante auf der Höhe eines Geschossbodens liegt, kommt durch das Loch der Decke
|
||||
//! darunter an (`ceiling_hole_rings`). An den freien Lochrändern (nicht unter Wänden, nicht an der
|
||||
//! Austrittskante der Treppe) steht ein Geländer; die Achse liegt wie der Handlauf der Treppe um
|
||||
//! [`GUARD_INSET`] vom Lochrand auf der Decke.
|
||||
|
||||
use crate::model::*;
|
||||
use crate::plan::wall_poche::{ceiling_outline_lines, WallFootprint};
|
||||
use crate::stair_rail::{offset_polyline, P, RAIL_INSET};
|
||||
|
||||
/// Achse der Absturzsicherung: so weit vom Lochrand auf die Decke gerückt wie der Handlauf von der
|
||||
/// Treppenkante (Rohr ganz auf der Decke).
|
||||
pub const GUARD_INSET: f64 = RAIL_INSET;
|
||||
/// Lochrand am Austritt: bis zu diesem Abstand von der Austrittskante keine Absturzsicherung.
|
||||
const ARRIVAL_TOL: f64 = 0.15;
|
||||
|
||||
/// Eine auf einem Geschoss ankommende Treppe.
|
||||
pub struct Arrival {
|
||||
/// Index in `Project::stairs`.
|
||||
pub stair: usize,
|
||||
/// Treppen-Parameter (`Stair::encode`) und Höhe von Unter- bis Oberkante.
|
||||
pub params: Vec<f64>,
|
||||
pub rise: f64,
|
||||
/// Löcher der Decke, in denen die Treppe liegt.
|
||||
pub rings: Vec<Vec<P>>,
|
||||
/// Achsen der Absturzsicherung (offene Züge, schon nach aussen auf die Decke versetzt).
|
||||
pub axes: Vec<Vec<P>>,
|
||||
/// Höhe des Geschossbodens (Standhöhe der Sicherung).
|
||||
pub z: f64,
|
||||
}
|
||||
|
||||
/// Löcher der Decken, deren Oberkante auf dem Geschossboden `base` steht.
|
||||
fn floor_holes(p: &Project, base: f64) -> Vec<Vec<P>> {
|
||||
p.ceilings
|
||||
.as_deref()
|
||||
.unwrap_or(&[])
|
||||
.iter()
|
||||
.filter(|ce| {
|
||||
let top = p.ceiling_vertical_extent(ce).1;
|
||||
top >= base - 0.3 && top <= base + 0.05
|
||||
})
|
||||
.flat_map(|ce| crate::opening_shape::ceiling_hole_rings(p, ce))
|
||||
.map(|h| h.iter().map(|q| [q.x, q.y]).collect::<Vec<P>>())
|
||||
.filter(|h| h.len() >= 3 && h.iter().all(|q| q[0].is_finite() && q[1].is_finite()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Treppen anderer Geschosse (`stair_ok` wählt vor), die auf dem Geschoss `floor_id` durch ein Deckenloch
|
||||
/// ankommen. Nur Geschoss-Grundrisse ([157]: nicht die 2D-Ebene eines Schnitts/einer Ansicht). `footprints`
|
||||
/// liefert die Wandumrisse des Geschosses (nur bei Bedarf, einmal).
|
||||
pub fn arrivals(p: &Project, floor_id: &str, stair_ok: &dyn Fn(&Stair) -> bool, footprints: &dyn Fn() -> Vec<WallFootprint>) -> Vec<Arrival> {
|
||||
let mut out = Vec::new();
|
||||
let Some(floor) = p.floor(floor_id) else { return out };
|
||||
if floor.kind != DrawingLevelKind::Floor {
|
||||
return out;
|
||||
}
|
||||
let base = floor.base_elevation.unwrap_or(0.0);
|
||||
let holes = floor_holes(p, base);
|
||||
if holes.is_empty() {
|
||||
return out;
|
||||
}
|
||||
let mut fps: Option<Vec<WallFootprint>> = None;
|
||||
for (si, s) in p.stairs.as_deref().unwrap_or(&[]).iter().enumerate().filter(|(_, s)| s.floor_id != floor_id && stair_ok(s)) {
|
||||
let (zb, zt) = p.stair_vertical_extent(s);
|
||||
if !((zt - base).abs() <= 0.05 && zb < base - 1e-6 && (zt - zb).is_finite()) {
|
||||
continue;
|
||||
}
|
||||
let params = s.encode();
|
||||
let Some(sp) = crate::stair::decode_params(¶ms) else { continue };
|
||||
let geo = kernel2d::stair_geometry(&sp, zt - zb);
|
||||
let centroid = |t: &kernel2d::TreadRect| {
|
||||
let n = t.pts.len().max(1) as f64;
|
||||
[t.pts.iter().map(|q| q.x).sum::<f64>() / n, t.pts.iter().map(|q| q.y).sum::<f64>() / n]
|
||||
};
|
||||
let rings: Vec<Vec<P>> = holes.iter().filter(|h| geo.treads.iter().any(|t| crate::surface_pattern::point_in(centroid(t), h))).cloned().collect();
|
||||
if rings.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let mut axes = Vec::new();
|
||||
// Austrittskante: Hinterkante des obersten Tritts.
|
||||
if let Some(last) = geo.treads.iter().filter(|t| t.pts.len() >= 4).max_by(|a, b| a.top_rise.total_cmp(&b.top_rise)) {
|
||||
let arrival = if sp.shape == "spiral" { (last.pts[3], last.pts[2]) } else { (last.pts[1], last.pts[2]) };
|
||||
let fps = fps.get_or_insert_with(footprints);
|
||||
for ring in &rings {
|
||||
for pts in guard_chains(ring, fps, ([arrival.0.x, arrival.0.y], [arrival.1.x, arrival.1.y])) {
|
||||
let area: f64 = (0..ring.len()).map(|i| ring[i][0] * ring[(i + 1) % ring.len()][1] - ring[(i + 1) % ring.len()][0] * ring[i][1]).sum();
|
||||
// nach aussen (auf die Decke): rechts der Ringrichtung bei Gegenuhrzeigersinn
|
||||
let d = if area > 0.0 { -GUARD_INSET } else { GUARD_INSET };
|
||||
axes.push(offset_polyline(&pts, d));
|
||||
}
|
||||
}
|
||||
}
|
||||
out.push(Arrival { stair: si, params: params.to_vec(), rise: zt - zb, rings, axes, z: base });
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Freie Lochränder als Züge in Ringrichtung: ohne Stücke unter Wänden und ohne die Austrittskante.
|
||||
fn guard_chains(ring: &[[f64; 2]], fps: &[WallFootprint], arrival: ([f64; 2], [f64; 2])) -> Vec<Vec<[f64; 2]>> {
|
||||
let near = |a: [f64; 2], b: [f64; 2]| (a[0] - b[0]).abs() < 1e-7 && (a[1] - b[1]).abs() < 1e-7;
|
||||
let mut pieces: Vec<[[f64; 2]; 2]> = Vec::new();
|
||||
for [a, b] in ceiling_outline_lines(ring, &[], fps) {
|
||||
// Teil, der an der Austrittskante liegt (beide Enden der Kante nahe der Geraden a–b), entfällt.
|
||||
let d = [b[0] - a[0], b[1] - a[1]];
|
||||
let l = d[0].hypot(d[1]);
|
||||
if !(l > 1e-9) {
|
||||
continue;
|
||||
}
|
||||
let u = [d[0] / l, d[1] / l];
|
||||
let off = |q: [f64; 2]| ((q[0] - a[0]) * u[1] - (q[1] - a[1]) * u[0]).abs();
|
||||
let t = |q: [f64; 2]| ((q[0] - a[0]) * u[0] + (q[1] - a[1]) * u[1]) / l;
|
||||
let mut keep = vec![(0.0, 1.0)];
|
||||
if off(arrival.0) < ARRIVAL_TOL && off(arrival.1) < ARRIVAL_TOL {
|
||||
let pad = ARRIVAL_TOL / l;
|
||||
let (t0, t1) = (t(arrival.0).min(t(arrival.1)) - pad, t(arrival.0).max(t(arrival.1)) + pad);
|
||||
keep = [(0.0, t0.min(1.0)), (t1.max(0.0), 1.0)].into_iter().filter(|(x, y)| (y - x) * l > 1e-6).collect();
|
||||
}
|
||||
for (t0, t1) in keep {
|
||||
pieces.push([[a[0] + d[0] * t0, a[1] + d[1] * t0], [a[0] + d[0] * t1, a[1] + d[1] * t1]]);
|
||||
}
|
||||
}
|
||||
// aneinanderhängende Stücke zu Zügen
|
||||
let mut chains: Vec<Vec<[f64; 2]>> = Vec::new();
|
||||
for [a, b] in pieces {
|
||||
match chains.last_mut() {
|
||||
Some(ch) if ch.last().is_some_and(|q| near(*q, a)) => ch.push(b),
|
||||
_ => chains.push(vec![a, b]),
|
||||
}
|
||||
}
|
||||
// letzter Zug schliesst an den ersten an
|
||||
if chains.len() >= 2 && near(*chains.last().unwrap().last().unwrap(), chains[0][0]) {
|
||||
let mut last = chains.pop().unwrap();
|
||||
last.extend(chains[0].iter().skip(1).copied());
|
||||
chains[0] = last;
|
||||
}
|
||||
chains
|
||||
}
|
||||
|
||||
/// Länge aller Achsen (m), für die IFC-Basismengen.
|
||||
pub fn axes_length(axes: &[Vec<P>]) -> f64 {
|
||||
axes.iter().map(|a| a.windows(2).map(|w| (w[1][0] - w[0][0]).hypot(w[1][1] - w[0][1])).sum::<f64>()).sum()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn sample() -> Project {
|
||||
serde_json::from_str(include_str!("../tests/fixtures/sample_project.json")).unwrap()
|
||||
}
|
||||
|
||||
/// ST1 (EG) steht bei x 3.2 … 4.2, y 0.4 … 3.6; Loch in C1 (OG-Boden) darüber.
|
||||
fn with_hole() -> Project {
|
||||
let mut p = sample();
|
||||
let hole = vec![Vec2 { x: 3.2, y: 1.6 }, Vec2 { x: 4.2, y: 1.6 }, Vec2 { x: 4.2, y: 3.6 }, Vec2 { x: 3.2, y: 3.6 }];
|
||||
p.ceilings.as_mut().unwrap()[0].openings = Some(vec![hole]);
|
||||
p
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ankommende_treppe_hat_achsen_auf_der_decke() {
|
||||
let p = with_hole();
|
||||
let a = arrivals(&p, "og", &|_| true, &|| vec![]);
|
||||
assert_eq!(a.len(), 1);
|
||||
assert!(!a[0].axes.is_empty() && axes_length(&a[0].axes) > 1.0);
|
||||
// nicht auf dem Loch: jede Achse ausserhalb des Lochrings
|
||||
assert!(a[0].axes.iter().flatten().all(|q| !crate::surface_pattern::point_in(*q, &a[0].rings[0])));
|
||||
// ohne Loch / im Geschoss der Treppe: nichts
|
||||
assert!(arrivals(&sample(), "og", &|_| true, &|| vec![]).is_empty());
|
||||
assert!(arrivals(&p, "eg", &|_| true, &|| vec![]).is_empty());
|
||||
}
|
||||
|
||||
/// 3D: Körper aus Pfosten, Handlauf und Stäben auf der Decke (Boden des OG), nur mit Loch.
|
||||
#[test]
|
||||
fn absturzsicherung_als_3d_koerper() {
|
||||
let p = with_hole();
|
||||
let base = p.floor("og").unwrap().base_elevation.unwrap();
|
||||
let g = crate::model3d::stair_guard_meshes(&p);
|
||||
assert_eq!(g.len(), 1);
|
||||
let m = &g[0].1;
|
||||
let zs: Vec<f64> = m.positions.chunks(3).map(|q| q[2]).collect();
|
||||
let (lo, hi) = zs.iter().fold((f64::MAX, f64::MIN), |(a, b), &z| (a.min(z), b.max(z)));
|
||||
assert!((lo - base).abs() < 1e-6 && (hi - base - crate::stair_rail::RAIL_HEIGHT).abs() < 0.05, "{lo} {hi} {base}");
|
||||
assert!(m.indices.len() > 300, "Pfosten, Handlauf und Stäbe");
|
||||
assert!(crate::model3d::emit_stair_railings(&p).len() > crate::model3d::emit_stair_handrails(&p).len());
|
||||
assert!(crate::model3d::stair_guard_meshes(&sample()).is_empty());
|
||||
assert!(!crate::model3d::pick_stair_railings(&p).is_empty());
|
||||
}
|
||||
|
||||
/// IFC: eigenes Geländer (GUARDRAIL) an der Treppe, mit Länge als Basismenge.
|
||||
#[test]
|
||||
fn absturzsicherung_im_ifc_teil() {
|
||||
let mut p = with_hole();
|
||||
let st = p.stairs.as_ref().unwrap()[0].clone();
|
||||
p.stairs = Some(vec![st.clone()]);
|
||||
let parts = crate::ifc_stairs::stair_parts(&p, &st, 0.0);
|
||||
let g = parts.guard.expect("Absturzsicherung");
|
||||
assert!(g.quantities[0].value > 1.0 && !g.mesh.indices.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -738,6 +738,52 @@ pub fn railings_with(buf: &[f64], half: f64) -> Vec<Mesh> {
|
||||
out
|
||||
}
|
||||
|
||||
/// Stababstand der Füllung der Absturzsicherung (lichtes Mass ≤ 12 cm) und Pfostenabstand.
|
||||
const GUARD_BALUSTER_GAP: f64 = 0.11;
|
||||
const GUARD_POST_GAP: f64 = 1.2;
|
||||
|
||||
/// [155] Körper der Absturzsicherung am Deckenloch über den Achsen aus [`crate::stair_guard`] (Standhöhe `z`):
|
||||
/// Pfosten an den Ecken und im Abstand, Handlauf in [`crate::stair_rail::RAIL_HEIGHT`], Stäbe als Füllung —
|
||||
/// dieselben Rohrquerschnitte wie das Treppengeländer. Ein Netz (Quelle `src`), leer ohne Achsen.
|
||||
pub fn guard_mesh(axes: &[Vec<P>], z: f64, src: usize) -> Option<Mesh> {
|
||||
let h = crate::stair_rail::RAIL_HEIGHT;
|
||||
let half = RAIL_THICK / 2.0;
|
||||
let mut tubes: Vec<(Vec<f64>, Vec<u32>)> = Vec::new();
|
||||
for axis in axes {
|
||||
if axis.len() < 2 || axis.iter().any(|q| !q[0].is_finite() || !q[1].is_finite()) {
|
||||
continue;
|
||||
}
|
||||
let top: Vec<V3> = axis.iter().map(|q| [q[0], q[1], z + h]).collect();
|
||||
tubes.extend(tube_along(&top, half));
|
||||
let post_at = |q: P, r: f64, z1: f64, tubes: &mut Vec<(Vec<f64>, Vec<u32>)>| tubes.extend(tube_along(&[[q[0], q[1], z], [q[0], q[1], z1]], r));
|
||||
for (i, w) in axis.windows(2).enumerate() {
|
||||
let len = hypot2(w[1][0] - w[0][0], w[1][1] - w[0][1]);
|
||||
if len < EPS {
|
||||
continue;
|
||||
}
|
||||
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 / GUARD_POST_GAP).ceil().max(1.0) as usize;
|
||||
for k in 0..n_post + usize::from(i + 2 == axis.len()) {
|
||||
post_at(at(k as f64 / n_post as f64), half * 0.75, z + h, &mut tubes);
|
||||
}
|
||||
let n_bal = (len / GUARD_BALUSTER_GAP).round().max(1.0) as usize;
|
||||
for k in 1..n_bal {
|
||||
let t = k as f64 / n_bal as f64;
|
||||
if (t * n_post as f64).fract().min(1.0 - (t * n_post as f64).fract()) * len / n_post as f64 > 0.04 {
|
||||
post_at(at(t), 0.006, z + h - half, &mut tubes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut positions: Vec<f64> = Vec::new();
|
||||
let mut indices: Vec<u32> = Vec::new();
|
||||
for (p, i) in tubes {
|
||||
let base = (positions.len() / 3) as u32;
|
||||
positions.extend(p);
|
||||
indices.extend(i.into_iter().map(|k| k + base));
|
||||
}
|
||||
(!indices.is_empty()).then_some(Mesh { src, positions, indices })
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
@@ -66,12 +66,12 @@
|
||||
// IfcOpeningElement = Profil-Extrusion entlang z_dir (Position origin/x_dir/z_dir) im Geschoss-
|
||||
// Placement, IfcRelVoidsElement zum Wirt; IfcWindow/IfcDoor mit dem Netz, IfcRelFillsElement.
|
||||
// STAIR = 5, structure, id, predefined (Text), PTS, z_rel, depth (Ersatzkörper, nur ohne Läufe/Podest),
|
||||
// PSETS, n_flights, FLIGHT × n_flights, n_landings, LANDING × n_landings, has_rail, [RAIL],
|
||||
// PSETS, n_flights, FLIGHT × n_flights, n_landings, LANDING × n_landings, n_rails, RAIL × n_rails,
|
||||
// has_column, [COLUMN]
|
||||
// FLIGHT = name, n_risers, n_treads, riser_height, tread_length, predefined (Text, IfcStairFlightTypeEnum),
|
||||
// PSETS, shape (0 = Extrusionen, 1 = Dreiecks-Mesh), 0: n, (PTS, z_rel, depth) × n | 1: MESH
|
||||
// LANDING = name, PTS, z_rel, depth, PSETS (IfcSlab, PredefinedType LANDING)
|
||||
// RAIL = name, predefined (Text, IfcRailingTypeEnum), PSETS, MESH
|
||||
// RAIL = name, predefined (Text, IfcRailingTypeEnum: HANDRAIL, [155] GUARDRAIL), PSETS, MESH
|
||||
// COLUMN = name, PTS, z_rel, depth, PSETS (Mittelsäule/Spindel: IfcColumn, COLUMN)
|
||||
// Mit mindestens einem Lauf/Podest/Geländer ist die IfcStair selbst ohne Darstellung und fasst Läufe,
|
||||
// Podest und Geländer per IfcRelAggregates zusammen (nur die Treppe liegt im Geschoss).
|
||||
@@ -735,12 +735,15 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
|
||||
for _ in 0..r.idx()? {
|
||||
landings.push(r.stair_landing()?);
|
||||
}
|
||||
let rail = if r.flag()? { Some(r.stair_rail()?) } else { None };
|
||||
let mut rails = Vec::new();
|
||||
for _ in 0..r.idx()? {
|
||||
rails.push(r.stair_rail()?);
|
||||
}
|
||||
let column = if r.flag()? { Some(r.stair_landing()?) } else { None };
|
||||
let key = format!("stair/{id}");
|
||||
let parent = w.placement_of(structure);
|
||||
let g = w.gid(&key);
|
||||
let entity = if flights.is_empty() && landings.is_empty() && rail.is_none() && column.is_none() {
|
||||
let entity = if flights.is_empty() && landings.is_empty() && rails.is_empty() && column.is_none() {
|
||||
// Ohne Teile: ein Ersatzkörper (Fussabdruck) wie bisher.
|
||||
let (placement, shape) = w.emit_box_product(&pts, z_rel, depth, parent);
|
||||
w.emit_building_element("IFCSTAIR", g, "Treppe", placement, shape, Some(enum_(&predefined)))
|
||||
@@ -793,9 +796,10 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
|
||||
}
|
||||
parts.push(slab);
|
||||
}
|
||||
if let Some(rl) = &rail {
|
||||
for (k, rl) in rails.iter().enumerate() {
|
||||
let (placement, shape) = w.emit_triangulated_product(&rl.mesh, stair_placement);
|
||||
let rkey = format!("{key}/railing");
|
||||
// erstes Geländer mit dem bisherigen Schlüssel (stabile GlobalId)
|
||||
let rkey = if k == 0 { format!("{key}/railing") } else { format!("{key}/railing/{k}") };
|
||||
let guid = w.gid(&rkey);
|
||||
let railing = w.emit_building_element("IFCRAILING", guid, &rl.name, placement, shape, Some(enum_(&rl.predefined)));
|
||||
for p in &rl.psets {
|
||||
|
||||
@@ -811,11 +811,16 @@ fn stair_with_parts(b: &mut B) {
|
||||
b.pts(&SQUARE);
|
||||
b.n(&[0.0, 1.3]);
|
||||
b.no_psets();
|
||||
b.n(&[1.0]);
|
||||
// zwei Geländer: Handlauf und [155] Absturzsicherung
|
||||
b.n(&[2.0]);
|
||||
b.str("Handlauf");
|
||||
b.str("HANDRAIL");
|
||||
b.no_psets();
|
||||
b.mesh_tetra();
|
||||
b.str("Absturzsicherung");
|
||||
b.str("GUARDRAIL");
|
||||
b.no_psets();
|
||||
b.mesh_tetra();
|
||||
b.n(&[1.0]);
|
||||
b.str("Spindel");
|
||||
b.pts(&SQUARE);
|
||||
@@ -832,7 +837,8 @@ fn treppe_mit_laeufen_podest_und_gelaender() {
|
||||
check_structure(&ifc);
|
||||
assert_eq!(count(&ifc, "IFCSTAIR"), 1);
|
||||
assert_eq!(count(&ifc, "IFCSTAIRFLIGHT"), 2);
|
||||
assert_eq!(count(&ifc, "IFCRAILING"), 1);
|
||||
assert_eq!(count(&ifc, "IFCRAILING"), 2);
|
||||
assert!(ifc.contains(".GUARDRAIL.") && ifc.contains(".HANDRAIL."));
|
||||
assert_eq!(count(&ifc, "IFCSLAB"), 1);
|
||||
assert!(ifc.contains(".LANDING.);"), "Podest als IfcSlab(LANDING)");
|
||||
assert_eq!(count(&ifc, "IFCCOLUMN"), 1, "Spindel als IfcColumn");
|
||||
@@ -845,13 +851,13 @@ fn treppe_mit_laeufen_podest_und_gelaender() {
|
||||
assert_eq!(count(&ifc, "IFCELEMENTQUANTITY"), 4);
|
||||
assert!(ifc.contains("IFCQUANTITYAREA('SoffitArea',$,$,7.5,$)"), "Dossier_Qto_… als Menge");
|
||||
assert_eq!(count(&ifc, "IFCPROPERTYSINGLEVALUE"), 0);
|
||||
let agg = ifc.lines().find(|l| l.contains("IFCRELAGGREGATES(") && l.matches('#').count() == 8).expect("Aggregation der Treppe");
|
||||
let agg = ifc.lines().find(|l| l.contains("IFCRELAGGREGATES(") && l.matches('#').count() == 9).expect("Aggregation der Treppe");
|
||||
assert!(agg.contains(",#"), "{agg}");
|
||||
let contained = first_line(&ifc, "IFCRELCONTAINEDINSPATIALSTRUCTURE");
|
||||
assert_eq!(contained.matches('#').count(), 4, "nur die Treppe (Nummer, Owner, Treppe, Gebäude): {contained}");
|
||||
// Läufe als Prismen, Geländer als Dreiecks-Netz.
|
||||
assert_eq!(count(&ifc, "IFCEXTRUDEDAREASOLID"), 6); // 2 Läufe × 2 Prismen + Podest + Spindel
|
||||
assert_eq!(count(&ifc, "IFCTRIANGULATEDFACESET"), 1);
|
||||
assert_eq!(count(&ifc, "IFCTRIANGULATEDFACESET"), 2);
|
||||
// Ohne Teile: Ersatzkörper (Fussabdruck) wie vorher.
|
||||
let fallback = build(&b).unwrap();
|
||||
assert_eq!(count(&fallback, "IFCSTAIRFLIGHT"), 0);
|
||||
@@ -1125,7 +1131,7 @@ fn ifc2x3_fenster_stil_klassifikation_zone_treppe() {
|
||||
// Treppenlauf: NumberOfRiser… ohne PredefinedType.
|
||||
assert!(first_line(&ifc, "IFCSTAIRFLIGHT").ends_with(",7,7,0.1857,0.28);"), "{}", first_line(&ifc, "IFCSTAIRFLIGHT"));
|
||||
assert_eq!(count(&ifc, "IFCTRIANGULATEDFACESET"), 0);
|
||||
assert_eq!(count(&ifc, "IFCFACETEDBREP"), 2); // Dach + Geländer (Mesh dicht? s. mesh_tetra: closed = 1)
|
||||
assert_eq!(count(&ifc, "IFCFACETEDBREP"), 3); // Dach + zwei Geländer (Handlauf, Absturzsicherung)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
meshes [1954]
|
||||
meshes[].color [3] x1954
|
||||
meshes [1957]
|
||||
meshes[].color [3] x1957
|
||||
meshes[].indices [108] x6
|
||||
meshes[].indices [11376]
|
||||
meshes[].indices [12888]
|
||||
meshes[].indices [144] x55
|
||||
meshes[].indices [156642]
|
||||
meshes[].indices [1584]
|
||||
@@ -12,6 +14,7 @@ meshes[].indices [396]
|
||||
meshes[].indices [564]
|
||||
meshes[].indices [60] x9
|
||||
meshes[].indices [72]
|
||||
meshes[].indices [7632]
|
||||
meshes[].indices [84] x2
|
||||
meshes[].indices [9288]
|
||||
meshes[].indices [96] x6
|
||||
@@ -26,7 +29,10 @@ meshes[].positions [264]
|
||||
meshes[].positions [288] x7
|
||||
meshes[].positions [306] x3
|
||||
meshes[].positions [324] x6
|
||||
meshes[].positions [4128]
|
||||
meshes[].positions [4746]
|
||||
meshes[].positions [6096]
|
||||
meshes[].positions [6972]
|
||||
meshes[].positions [72] x2
|
||||
meshes[].positions [78837]
|
||||
meshes[].positions [78] x55
|
||||
@@ -61,4 +67,4 @@ walls[].start [2] x1489
|
||||
walls[].startCut [4] x1164
|
||||
walls[].topDrop [2] x103
|
||||
walls[].topPlane [3] x259
|
||||
hash e65de53f576b2bf9
|
||||
hash 9acaf7b7c01c66a3
|
||||
Reference in new issue
Block a user