[279] Geländer: Lochblech mit Lochmuster (Punktschraffur) in Ansicht und 3D-Dokument, Handlauf über der Schnitthöhe im Grundriss gestrichelt neben der Achse

This commit is contained in:
Claude committed 2026-11-18 15:40:55 +00:00
1 parent f0a33d220a
commit 9abc83edb0
10 files changed
+91 -10

No files matched your search

+3 -1
View File
@@ -705,7 +705,9 @@ pub fn axo_primitives(p: &Project, a: &AxoArgs, mono: bool) -> Result<Option<(Ve
}
let glass = is_glass(*o);
// Ein Hauch Kontur in der Füllfarbe deckt die Haarfugen zwischen Nachbarflächen.
let mut prim = polygon(ring.iter().map(|q| v2(q[0], q[1])).collect(), &fill, &fill, 0.1, no_hatch());
// [279] Lochblech: Lochmuster (Punktschraffur) über der Tafel.
let hatch = if owner(*o).is_some_and(|r| r.perforated) { super::railings::perforation_hatch(super::style::HATCH_INK) } else { no_hatch() };
let mut prim = polygon(ring.iter().map(|q| v2(q[0], q[1])).collect(), &fill, &fill, 0.1, hatch);
if let Primitive::Polygon { opacity, .. } = &mut prim {
if glass {
*opacity = Some(super::elevation::GLASS_OPACITY);
+11 -2
View File
@@ -81,7 +81,7 @@ pub(super) fn project_faces(frame: &[f64; 9], walls: &[RWall], slabs: &[RSlab],
Role::Roof => (roofs[f.src].id.clone(), roofs[f.src].fill),
};
let pts = f.pts.iter().map(|q| [q.0, q.1]).collect();
out.push(Face { pts, pd: f.pd, depth: f.depth, depth_min: f.depth_min, depth_max: f.depth_max, role, id, fill, normal: f.normal, ov: None, two_sided: false, curved_slab: false, see_through: false });
out.push(Face { pts, pd: f.pd, depth: f.depth, depth_min: f.depth_min, depth_max: f.depth_max, role, id, fill, normal: f.normal, ov: None, two_sided: false, curved_slab: false, see_through: false, perforated: false });
}
out
}
@@ -131,8 +131,17 @@ pub(super) fn collect_railing_faces(p: &Project, frame: &[f64; 9]) -> Vec<Face>
// Glastafeln (Glasgeländer, Teil Tafel) getrennt: durchscheinend, in der Ansicht wie Fensterglas hell.
let is_glass = |s: &model3d::RSlab| matches!(s.source, model3d::SlabSource::Railing { index, fill: true } if p.railings.as_deref().and_then(|r| r.get(index)).is_some_and(|r| r.kind == RailingKind::Glass));
let (glass, rest): (Vec<_>, Vec<_>) = slabs.into_iter().partition(is_glass);
// Lochblechtafeln: Lochmuster (Punktschraffur der Schraffur-Bibliothek, `super::super::railings::perforation_hatch`).
let is_perf = |s: &model3d::RSlab| matches!(s.source, model3d::SlabSource::Railing { index, fill: true } if p.railings.as_deref().and_then(|r| r.get(index)).is_some_and(|r| r.kind == RailingKind::Perforated));
let (perf, rest): (Vec<_>, Vec<_>) = rest.into_iter().partition(is_perf);
let mut faces = project_faces(frame, &[], &rest, &[]);
faces.iter_mut().for_each(|f| f.role = Role::Railing);
let mut pf = project_faces(frame, &[], &perf, &[]);
for f in &mut pf {
f.role = Role::Railing;
f.perforated = true;
}
faces.extend(pf);
let mut g = project_faces(frame, &[], &glass, &[]);
for f in &mut g {
f.role = Role::Railing;
@@ -233,7 +242,7 @@ fn mesh_faces(frame: &[f64; 9], pos: &[f64], info: &crate::mesh_view::MeshInfo,
groups.push((key, Vec::new()));
groups.len() - 1
});
groups[k].1.push(Face { pts, pd, depth, depth_min: dmin, depth_max: dmax, role, id: id.to_string(), fill, normal, ov: None, two_sided: !info.closed, curved_slab: false, see_through: false });
groups[k].1.push(Face { pts, pd, depth, depth_min: dmin, depth_max: dmax, role, id: id.to_string(), fill, normal, ov: None, two_sided: !info.closed, curved_slab: false, see_through: false, perforated: false });
}
for (_, tris) in groups {
merge_coplanar(tris, out);
@@ -44,6 +44,8 @@ pub(super) struct Face {
pub(super) curved_slab: bool,
/// [279] Glas des Geländers: durchscheinend gefüllt, verdeckt nichts (weder Füllungen noch Kanten dahinter).
pub(super) see_through: bool,
/// [279] Tafel eines Lochblechgeländers: Lochmuster (Punktschraffur) auf der Fläche.
pub(super) perforated: bool,
}
/// [33] Override einer Ansichtsfläche bzw. Öffnung (`overrides::effective_surface`).
@@ -46,7 +46,7 @@ pub(super) fn merge_coplanar(tris: Vec<Face>, out: &mut Vec<Face>) {
let pd: Vec<f64> = pts.iter().map(depth_at).collect();
let depth = pd.iter().sum::<f64>() / pd.len() as f64;
let (dmin, dmax) = (pd.iter().copied().fold(f64::INFINITY, f64::min), pd.iter().copied().fold(f64::NEG_INFINITY, f64::max));
out.push(Face { pts, pd, depth, depth_min: dmin, depth_max: dmax, role: f0.role, id: f0.id.clone(), fill: f0.fill, normal: f0.normal, ov: None, two_sided: f0.two_sided, curved_slab: false, see_through: false });
out.push(Face { pts, pd, depth, depth_min: dmin, depth_max: dmax, role: f0.role, id: f0.id.clone(), fill: f0.fill, normal: f0.normal, ov: None, two_sided: f0.two_sided, curved_slab: false, see_through: false, perforated: false });
}
}
+3 -3
View File
@@ -433,7 +433,7 @@ pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, m
let rect = |x0: f64, y0: f64, x1: f64, y1: f64| vec![[x0, y0], [x1, y0], [x1, y1], [x0, y1]];
let band = [rect(b[0] - BAND, b[1] - BAND, b[2] + BAND, b[1]), rect(b[0] - BAND, b[3], b[2] + BAND, b[3] + BAND), rect(b[0] - BAND, b[1], b[0], b[3]), rect(b[2], b[1], b[2] + BAND, b[3])];
for q in fills.iter().filter(|q| q.len() >= 3).chain(band.iter()) {
extra.push(Face { pts: q.clone(), pd: vec![host.depth; q.len()], depth: host.depth, depth_min: host.depth_min, depth_max: host.depth_max, role: Role::Wall, id: host.id.clone(), fill: host.fill, normal: host.normal, ov: host.ov.clone(), two_sided: false, curved_slab: false, see_through: false });
extra.push(Face { pts: q.clone(), pd: vec![host.depth; q.len()], depth: host.depth, depth_min: host.depth_min, depth_max: host.depth_max, role: Role::Wall, id: host.id.clone(), fill: host.fill, normal: host.normal, ov: host.ov.clone(), two_sided: false, curved_slab: false, see_through: false, perforated: false });
}
}
if !extra.is_empty() {
@@ -537,7 +537,7 @@ pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, m
let fill = face_fill(f);
// [152] Importierte Netze ebenso (Dreiecke).
let seam = (is_roof && assembled.contains(f.id.as_str())) || f.role.is_mesh();
let hatch = f.ov.as_ref().and_then(|o| o.hatch.clone()).unwrap_or_else(no_hatch);
let hatch = f.ov.as_ref().and_then(|o| o.hatch.clone()).unwrap_or_else(|| if f.perforated { super::railings::perforation_hatch(super::style::HATCH_INK) } else { no_hatch() });
let mut prim = if seam { polygon(pts, &fill, &fill, 0.15, hatch) } else { polygon(pts, &fill, "none", 0.0, hatch) };
// [279] Glasgeländer: helle Füllung wie Fensterglas, durchscheinend (Linien dahinter bleiben lesbar).
if let (true, Primitive::Polygon { opacity, .. }) = (f.see_through, &mut prim) {
@@ -700,7 +700,7 @@ pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, m
}
let pd: Vec<f64> = ring.iter().map(|q| pl[0] + pl[1] * q[0] + pl[2] * q[1]).collect();
let (dmin, dmax) = pd.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |(a, b), d| (a.min(*d), b.max(*d)));
cut.push(Face { pts: ring, pd, depth: f.depth, depth_min: dmin, depth_max: dmax, role: f.role, id: f.id.clone(), fill: f.fill, normal: f.normal, ov: f.ov.clone(), two_sided: f.two_sided, curved_slab: f.curved_slab, see_through: f.see_through });
cut.push(Face { pts: ring, pd, depth: f.depth, depth_min: dmin, depth_max: dmax, role: f.role, id: f.id.clone(), fill: f.fill, normal: f.normal, ov: f.ov.clone(), two_sided: f.two_sided, curved_slab: f.curved_slab, see_through: f.see_through, perforated: f.perforated });
}
}
}
+38 -1
View File
@@ -9,10 +9,13 @@
//! - **Lochblech:** wie Glas, dazu eine gestrichelte Mittellinie.
//! - **Brüstung (massiv):** geschnittene Fläche mit Bauteil-Schraffur (Poché wie die Stützen), Umriss ohne Gehrungsfugen.
//!
//! - **Handlauf über der Schnitthöhe** (Fuss geschnitten, Handlauf darüber): zwei gestrichelte Linien im Abstand der
//! Handlaufbreite neben der Achse (`railing-handrail`, wie die Treppen-Handläufe über dem Schnitt).
//!
//! 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::prim::{HatchRender, Primitive};
use super::style::*;
use super::view_range::{ViewRange, Zone};
use crate::model::*;
@@ -36,6 +39,12 @@ pub fn is_symbol_part(q: &Primitive) -> bool {
}
}
/// [279] Lochmuster der Lochblechtafel in Ansicht und 3D-Dokument: Punktschraffur (`HatchPattern::Dots`, die bestehende
/// Schraffur-Bibliothek, Teilung 5 cm), Punkte in der Tintenfarbe `color`.
pub fn perforation_hatch(color: &str) -> HatchRender {
HatchRender { pattern: HatchPattern::Dots, scale: 1.0, color: color.to_string(), line_weight: 0.18, ..no_hatch() }
}
/// 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)
@@ -136,6 +145,14 @@ pub(super) fn plan_railings(c: &Ctx, out: &mut Vec<Primitive>) {
}
}
}
// Handlauf ganz über der Schnitthöhe (Fuss geschnitten): gestrichelt neben der Achse, Konvention wie bei den Treppen
// (Handlauf über dem Schnitt gestrichelt, Strichmuster „verdeckt“, dünne Linie).
if zone == Zone::Cut && s.has_rail() && range.classify(s.top() - s.rail_h(), s.top()) == Zone::Above {
let (_, l, rt) = railing::strips(&ax, s.rail_w() / 2.0);
for side in [&l, &rt] {
polyline(out, side, "railing-handrail", lw * 0.6, &stroke, Some(&super::line_pattern::HIDDEN), 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) };
@@ -235,6 +252,26 @@ mod tests {
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 handlauf_ueber_schnitthoehe_gestrichelt_neben_der_achse() {
// Höhe 1.2 über Schnitt 1.0: Fuss geschnitten, Handlauf (1.16–1.20) darüber -> zwei gestrichelte Linien im Abstand der Handlaufbreite.
let p = project(rail("glass", serde_json::json!({"height": 1.2, "handrail": true, "handrailSize": 0.06})));
let l = lines(&plan(&p, 50.0), "railing-handrail");
assert_eq!(l.len(), 2, "{l:?}");
assert!(l.iter().all(|(a, b)| (a.x - b.x).abs() > 3.9 && (a.y - b.y).abs() < 1e-9));
assert!(((l[0].0.y - l[1].0.y).abs() - 0.06).abs() < 1e-9);
let dashed = |prims: &[Primitive]| prims.iter().filter_map(|q| match q { Primitive::Line { cls, dash, .. } if cls == "railing-handrail" => Some(dash.clone()), _ => None }).all(|d| matches!(d, Some(Some(_))));
assert!(dashed(&plan(&p, 50.0)));
// Handlauf unter der Schnitthöhe (Höhe 1.0 = Schnitt): ausgezogen wie bisher, keine eigene Linie.
let p = project(rail("glass", serde_json::json!({"height": 1.0, "handrail": true})));
assert!(lines(&plan(&p, 50.0), "railing-handrail").is_empty());
// Ohne Handlauf (Brüstung, keine Angabe) und ganz über dem Schnitt (schon gestrichelt): keine zusätzlichen Linien.
let p = project(rail("solid", serde_json::json!({"height": 1.2})));
assert!(lines(&plan(&p, 50.0), "railing-handrail").is_empty());
let p = project(rail("glass", serde_json::json!({"height": 1.2, "baseOffset": 1.2})));
assert!(lines(&plan(&p, 50.0), "railing-handrail").is_empty());
}
#[test]
fn klasse_aus_blendet_aus_und_unsinn_kein_absturz() {
let p = project(rail("glass", serde_json::json!({})));
@@ -330,6 +330,8 @@ pub(crate) struct OwnerRef {
pub railing: bool,
/// [279] Glastafel eines Glasgeländers: durchscheinend, verdeckt nichts (3D-Dokument).
pub glass: bool,
/// [279] Tafel eines Lochblechgeländers: Lochmuster (3D-Dokument).
pub perforated: bool,
}
/// [266] Alle Flächen des Modells für eine beliebige Ansicht (Vektor-Axonometrie, `plan/axo.rs`): dieselben Körper wie
@@ -373,7 +375,8 @@ pub(crate) fn model_view_faces(p: &Project, vis: &Visibility, view: &dyn Fn([f64
Kind::Mesh => (mrefs.get(i).map(|m| m.mesh.id.clone()), false, false, false),
};
let glass = railing && matches!(kind, Kind::Slab) && matches!(slabs.get(i), Some(SlabOwner::Railing(r, true)) if r.kind == RailingKind::Glass);
OwnerRef { kind, id, stair, column, railing, glass }
let perforated = railing && matches!(kind, Kind::Slab) && matches!(slabs.get(i), Some(SlabOwner::Railing(r, true)) if r.kind == RailingKind::Perforated);
OwnerRef { kind, id, stair, column, railing, glass, perforated }
})
.collect();
Ok((vf, refs))
+28
View File
@@ -180,6 +180,34 @@ fn glas_im_3d_dokument_durchscheinend() {
assert!(o > 0.0 && o < 1.0, "{o}");
}
/// Schraffurmuster der Flächen mit Pick-Id `@railing:g`.
fn rail_hatches(prims: &[Primitive]) -> Vec<crate::model::HatchPattern> {
prims.iter().filter_map(|q| match q {
Primitive::Polygon { hatch, context_object_id: Some(c), fill, .. } if c == "@railing:g" && fill != "none" => Some(hatch.pattern),
_ => None,
}).collect()
}
#[test]
fn lochblech_mit_lochmuster_in_ansicht_und_3d_dokument() {
use crate::model::HatchPattern::{Dots, None as NoHatch};
let vis = crate::plan::section::Visibility::default();
let el = |p: &Project| crate::plan::elevation::elevation_primitives(p, &level(p, "ans"), false, false, &vis, 50.0).unwrap().unwrap().0;
let ax = |p: &Project| {
let a = crate::plan::axo::AxoArgs::parse(p, &json!({"view": "southeast", "scale": 100})).unwrap();
crate::plan::axo::axo_primitives(p, &a, false).unwrap().expect("Bild").0
};
let perf = project("perforated", json!({"handrail": false}));
for (name, h) in [("Ansicht", rail_hatches(&el(&perf))), ("3D-Dokument", rail_hatches(&ax(&perf)))] {
assert!(!h.is_empty() && h.iter().all(|p| *p == Dots), "{name}: Lochmuster fehlt: {h:?}");
}
// Glas und Brüstung bleiben ohne Muster.
for kind in ["glass", "solid"] {
let p = project(kind, json!({"handrail": false}));
assert!(rail_hatches(&el(&p)).iter().chain(rail_hatches(&ax(&p)).iter()).all(|p| *p == NoHatch), "{kind}");
}
}
#[test]
fn dokument_3d_axo() {
let p = project("glass", json!({}));