Merge branch 'worktree-agent-af84fe98126c5e7dc' into claude/practical-noether-1hb2s1

This commit is contained in:
Claude committed 2026-11-11 07:08:33 +00:00
commit d3b889d243
21 files changed
+506 -67

No files matched your search

+9 -2
View File
@@ -141,6 +141,8 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `*
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`). (11.11.)
Freier Lochring ohne Wand und Austritt: geschlossener Zug mit Gehrung an der Naht (`offset_polyline` erkennt geschlossene
Züge, 3D-Rohr ohne Deckel; Test `freier_ring_ist_geschlossen_mit_gehrung`); offene Enden stehen rechtwinklig. (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:
@@ -378,7 +380,6 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `*
`arc_wall_radius_target`). Bogenlänge per Tab auch über dem Halbkreis: Seite eindeutig aus dem Cursor, Öffnungswinkel
genau l/r (`arc_wall_resize`, `moveGrip` mit `arcLength`); Vorschau mit echtem Bulge. Geprüft: Rust-/vitest-Tests; nicht in der
App geklickt (Shift-Griff, Tab-Feld „Radius", HUD). · M
- ◐ **[T3]** Wendeltreppe. Kein Handlauf-Profil im Modell (rund fest). · S
- ◐ **[T4]** Import-Meshes glätten oder kantig. Metal-Pfad nicht gebaut/gesehen. · S
- ◐ **[T6]** Glattes Gelände aus Höhenlinien (`terrain.rs`). Natural-Neighbour/Clough-Tocher statt Hermite-Teilung;
Erdreich-Band nicht „bis zur Planunterkante“; Glättung ohne Kantenerhalt; Baugrube ist eigene Kategorie und
@@ -439,7 +440,7 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `*
nicht in der Tauri-App geprüft. · S
- ◐ **[108]** Schräge Wandanschlüsse exakt (T/L/X). 3D nur per Rust-Test (kein Metal-Render). · S
- ◐ **[151]** Treppenformen U und gerade mit Podest (`Stair`, `kernel2d`, `stairs3d.rs`). Kein Wendelpodest/Wendelstufen am
Podest; Handlauf-Profil fest rund; Doppellinie ab 1:50 fest (keine Einstellung). · M
Podest; Doppellinie ab 1:50 fest (keine Einstellung). · M
- ◐ **[100]** Standard-Baustoffe/Ansichtsschraffur (SIA 400). Deckenspiegel: Unterzüge (kein Modell-Element), UK unter
Gauben, kein Leuchten-Werkzeug; waagrechte Flächen in Schnitt/Ansicht nicht sichtbar; Decken ohne
`surfacePatternAngle/Offset`. · M
@@ -625,3 +626,9 @@ exakte Durchdringung, [61] Zuordnung per Hand, [63] Profil je Kante, [70] Fläch
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`)
- [T3] Handlauf-Profil im Modell (11.11.): `Stair.railProfile` (rund / rechteck / flach), `railWidth`, `railHeight`, dazu
Pfosten `postProfile`, `postWidth`, `postDepth`; gilt für alle Treppenformen und die Absturzsicherung am Deckenloch
(`stairs3d::RailSpec`, `sweep` statt Rundrohr; Pfostenbreite in Richtung des Handlaufs). Grundriss-Doppellinie nutzt die
halbe Handlaufbreite, IFC-Basismenge `CrossSectionArea`, Objekt-Info (Profil + Masse). Ohne Angabe Rundrohr wie bisher
(Netze bit-gleich). Offen: Profil am Treppentyp (nur am Element), Profil nur für Handlauf/Pfosten, Stäbe der
Absturzsicherung bleiben rund; in der App nicht geklickt
+4 -4
View File
@@ -323,9 +323,9 @@ pub fn flight_quantities(length: f64, volume: f64) -> Vec<Qty> {
vec![len("Length", length), vol("GrossVolume", volume), vol("NetVolume", volume)]
}
/// Geländer: Länge.
pub fn railing_quantities(length: f64) -> Vec<Qty> {
vec![len("Length", length)]
/// Geländer: Länge und [T3] Querschnittsfläche des Handlaufs (Rund-, Rechteck- oder Flachprofil).
pub fn railing_quantities(length: f64, section_area: f64) -> Vec<Qty> {
vec![len("Length", length), area("CrossSectionArea", section_area)]
}
#[cfg(test)]
@@ -483,6 +483,6 @@ mod tests {
assert_eq!(get(&q, "Width"), Some(0.0));
assert!(close(get(&q, "Perimeter"), 4.0));
assert_eq!(flight_quantities(-1.0, 2.0)[0].value, 0.0);
assert_eq!(railing_quantities(3.0)[0].value, 3.0);
assert_eq!(railing_quantities(3.0, 0.001)[0].value, 3.0);
}
}
+4 -2
View File
@@ -379,11 +379,13 @@ pub fn stair_parts(one: &Project, stair: &Stair, base: f64) -> StairParts {
})
.collect();
// [T3] Querschnitt des Handlaufs (Rund-, Rechteck-, Flachprofil) für die Basismengen
let section_area = crate::stairs3d::RailSpec::decode(stair.rail_params()).rail_area();
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) }
Rail { mesh: ifc_mesh(positions, &indices, base), quantities: railing_quantities(walk_length(stair, rise) * sides, section_area) }
});
let guard_meshes = model3d::stair_guard_meshes(one);
let guard = (!guard_meshes.is_empty()).then(|| {
@@ -395,7 +397,7 @@ pub fn stair_parts(one: &Project, stair: &Stair, base: f64) -> StairParts {
}
// 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) }
Rail { mesh: ifc_mesh(positions, &indices, base), quantities: railing_quantities(length, section_area) }
});
StairParts { flights, landings, rail, guard, column }
}
+43
View File
@@ -3845,6 +3845,24 @@ pub enum StairArrowStyle {
Unknown,
}
/// [T3] Querschnittsform von Handlauf bzw. Geländerpfosten.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
pub enum StairRailProfile {
/// Rundrohr (Durchmesser = Breite).
#[default]
#[serde(rename = "rund")]
Rund,
/// Rechteck (Breite × Höhe bzw. Tiefe).
#[serde(rename = "rechteck")]
Rechteck,
/// Flachstahl (Breite × Dicke, Dicke klein).
#[serde(rename = "flach")]
Flach,
#[serde(other)]
#[ts(skip)]
Unknown,
}
/// Eine Treppe (Treppe/Stair) — ein geschossübergreifendes Bauteil, das über die
/// Geschosshöhe (OKFF → OKFF des nächsten Geschosses) steigt. Definiert über eine
/// Grundform (gerade / L / Wendel), eine Basis-Geometrie, die Laufbreite und die
@@ -3997,6 +4015,31 @@ pub struct Stair {
#[serde(rename = "centerColumn", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub center_column: Option<f64>,
/// [T3] Handlauf-Profil (gilt für alle Treppenformen und die Absturzsicherung am Deckenloch);
/// fehlt es, ist der Handlauf ein Rundrohr von 4 cm.
#[serde(rename = "railProfile", default, skip_serializing_if = "Option::is_none")]
#[ts(optional, inline)]
pub rail_profile: Option<StairRailProfile>,
/// [T3] Handlauf-Breite in Metern (rund: Durchmesser; fehlt = 0.04).
#[serde(rename = "railWidth", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub rail_width: Option<f64>,
/// [T3] Handlauf-Höhe in Metern (rechteckig: fehlt = 0.04; Flachstahl: Dicke, fehlt = 0.01; rund: ohne Wirkung).
#[serde(rename = "railHeight", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub rail_height: Option<f64>,
/// [T3] Pfosten-Profil (fehlt = rund).
#[serde(rename = "postProfile", default, skip_serializing_if = "Option::is_none")]
#[ts(optional, inline)]
pub post_profile: Option<StairRailProfile>,
/// [T3] Pfosten-Breite in Metern, in Richtung des Handlaufs (rund: Durchmesser; fehlt = 0.03, Flachstahl 0.04).
#[serde(rename = "postWidth", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub post_width: Option<f64>,
/// [T3] Pfosten-Tiefe in Metern, quer zum Handlauf (rechteckig: fehlt = 0.03; Flachstahl: Dicke, fehlt = 0.01; rund: ohne Wirkung).
#[serde(rename = "postDepth", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub post_depth: Option<f64>,
#[serde(flatten)]
#[ts(skip)]
pub extra: Extra,
+12
View File
@@ -219,6 +219,18 @@ impl Roof {
}
impl Stair {
/// [T3] Handlauf-/Pfosten-Profil als `[profil, breite, höhe, pfostenProfil, pfostenBreite, pfostenTiefe]`
/// (Profil 0 rund, 1 rechteck, 2 flach; fehlend = NaN = Standard), Eingabe von [`crate::stairs3d::RailSpec::decode`].
pub fn rail_params(&self) -> [f64; 6] {
let n = |v: Option<f64>| v.unwrap_or(f64::NAN);
let k = |p: Option<StairRailProfile>| match p {
Some(StairRailProfile::Rechteck) => 1.0,
Some(StairRailProfile::Flach) => 2.0,
_ => 0.0,
};
[k(self.rail_profile), n(self.rail_width), n(self.rail_height), k(self.post_profile), n(self.post_width), n(self.post_depth)]
}
/// Treppen-Parameter als [`crate::stair::PARAMS`] Zahlen (Aufbau: `stair.rs`, `encodeStair` in TS);
/// fehlend = NaN.
pub fn encode(&self) -> [f64; crate::stair::PARAMS] {
+4 -2
View File
@@ -12,7 +12,7 @@ fn rail_rgb() -> Rgb {
hex_to_rgb("#74797f", SLAB_RGB)
}
/// Flache Eingabe der Treppen für `stairs3d` (24 Zahlen je Treppe); `wanted` wählt vor.
/// Flache Eingabe der Treppen für `stairs3d` (36 Zahlen je Treppe); `wanted` wählt vor.
pub(super) fn stair_input<'a>(p: &'a Project, wanted: impl Fn(&Stair, Option<&StairType>) -> bool) -> Option<(Vec<(usize, &'a Stair)>, Vec<f64>)> {
let mut stairs: Vec<(usize, &Stair)> = Vec::new();
let mut types: Vec<Option<&StairType>> = Vec::new();
@@ -48,6 +48,7 @@ pub(super) fn stair_input<'a>(p: &'a Project, wanted: impl Fn(&Stair, Option<&St
_ => 0.0,
});
buf.push(s.center_column.filter(|r| r.is_finite() && *r > 0.0).unwrap_or(0.0));
buf.extend(s.rail_params());
}
Some((stairs, buf))
}
@@ -150,7 +151,8 @@ pub fn stair_guard_meshes_by_floor(p: &Project) -> Vec<(usize, String, crate::me
let mut out: Vec<(usize, String, 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) {
let spec = crate::stairs3d::RailSpec::decode(p.stairs.as_deref().and_then(|v| v.get(a.stair)).map_or([f64::NAN; 6], |s| s.rail_params()));
if let Some(m) = crate::stairs3d::guard_mesh(&a.axes, a.z, a.stair, &spec) {
out.push((a.stair, f.id.clone(), m));
}
}
+4 -2
View File
@@ -333,6 +333,8 @@ pub struct RunOpts {
pub start: f64,
pub end: f64,
pub start_mark: Option<f64>,
/// [T3] Halbe Handlaufbreite (Meter) für die Doppellinie; 0 = Standard ([`crate::stair_rail::RAIL_THICK`] / 2).
pub rail_half: f64,
}
/// [173] Schnittparameter des Strahls `a + t·d` mit der Geraden durch `c`–`e` (`None` = parallel).
@@ -565,7 +567,7 @@ pub fn plan_stair_run(params: &[f64], total_rise: f64, cut_rise: f64, lw_mm: f64
}
// [151] Handlauf: über der Bruchlinie gestrichelt (dieselbe Teilung wie Tritte und Wange).
let r = crate::stair_rail::RAIL_THICK / 2.0;
let r = if run.rail_half.is_finite() && run.rail_half > 0.0 { run.rail_half } else { crate::stair_rail::RAIL_THICK / 2.0 };
for rail in crate::stair_rail::rails(&p, &geo, railing) {
let path = crate::stair_rail::plan_path(&rail);
let mut pieces: Vec<(Vec<P>, bool)> = Vec::new();
@@ -981,7 +983,7 @@ mod tests {
assert!(l(&g.run_line) >= l(&raw.run_line) - 1e-9, "{name}: nicht kürzer als vorher");
assert!(len(sub(g.arrow.head.1, g.run_line[n - 1])) < 1e-9, "{name}: Pfeil am Ende");
let mut h = stair_geometry(&sp, 2.8);
run_line_to_edges(&mut h, spiral, &RunOpts { start: 0.1, end: 0.2, start_mark: None });
run_line_to_edges(&mut h, spiral, &RunOpts { start: 0.1, end: 0.2, start_mark: None, rail_half: 0.0 });
assert!((l(&g.run_line) - l(&h.run_line) - 0.3).abs() < 1e-6, "{name}: Versatz 0.1 + 0.2");
assert!(len(sub(h.arrow.head.1, h.run_line[h.run_line.len() - 1])) < 1e-9);
}
+10 -5
View File
@@ -173,7 +173,7 @@ pub fn plan_stairs(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) {
bounds.acc(q.x, q.y);
}
}
let f = crate::plan::stair_symbol::plan_stair_run(&params, zt - zb, cut_height, lw, s.arrow_style == Some(StairArrowStyle::Filled), s.center_column.unwrap_or(0.0), railing_code(p, s), double, &[], &run_opts(&opts, c.a.scale));
let f = crate::plan::stair_symbol::plan_stair_run(&params, zt - zb, cut_height, lw, s.arrow_style == Some(StairArrowStyle::Filled), s.center_column.unwrap_or(0.0), railing_code(p, s), double, &[], &run_opts(&opts, c.a.scale, s));
emit(out, &f, &stroke, greyed, &s.id, &opts);
if let (true, Some(geo)) = (opts.step_numbers, &geo) {
let avoid = arrow_boxes(&out[out_start..]);
@@ -252,9 +252,14 @@ fn step_numbers(out: &mut Vec<Primitive>, geo: &kernel2d::StairGeometry, cut_hei
/// [173] Lauflinie nach der Modelldarstellung: Versatz (Papier-mm → Meter bei 1:`scale`) und Antrittspunkt
/// (Halbmesser 0.75 mm Papier, nur mit Lauflinie).
fn run_opts(o: &super::model_view::StairOpts, scale: f64) -> crate::plan::stair_symbol::RunOpts {
fn run_opts(o: &super::model_view::StairOpts, scale: f64, s: &Stair) -> crate::plan::stair_symbol::RunOpts {
let m = |mm: f64| if scale.is_finite() && scale > 0.0 { mm * scale / 1000.0 } else { 0.0 };
crate::plan::stair_symbol::RunOpts { start: m(o.run_start_mm), end: m(o.run_end_mm), start_mark: (o.start_mark && o.walk_line).then(|| m(0.75)).filter(|r| *r > 0.0) }
crate::plan::stair_symbol::RunOpts { start: m(o.run_start_mm), end: m(o.run_end_mm), start_mark: (o.start_mark && o.walk_line).then(|| m(0.75)).filter(|r| *r > 0.0), rail_half: rail_half(s) }
}
/// [T3] Halbe Handlaufbreite der Treppe (Meter).
fn rail_half(s: &Stair) -> f64 {
crate::stairs3d::RailSpec::decode(s.rail_params()).rail_half_width()
}
/// [155] Treppen tieferer Geschosse, die auf diesem Geschoss ankommen: durch das Loch der Decke, auf der
@@ -270,10 +275,10 @@ fn arriving(c: &Ctx, out: &mut Vec<Primitive>, double: bool, opts: &super::model
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(&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));
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, s));
emit(out, &f, &stroke, greyed, &s.id, opts);
for axis in &a.axes {
let r = crate::stair_rail::RAIL_THICK / 2.0;
let r = rail_half(s);
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) {
+6
View File
@@ -948,6 +948,12 @@ fn stair_selection(root: &Map<String, Value>, s: &Value) -> Result<J, String> {
.raw("arrowStyle", s, "arrowStyle")
.raw("referenz", s, "referenz")
.raw("centerColumn", s, "centerColumn")
.raw("railProfile", s, "railProfile")
.raw("railWidth", s, "railWidth")
.raw("railHeight", s, "railHeight")
.raw("postProfile", s, "postProfile")
.raw("postWidth", s, "postWidth")
.raw("postDepth", s, "postDepth")
.raw("runLength", s, "runLength")
.raw("run2Length", s, "run2Length")
.raw("turn", s, "turn")
+54
View File
@@ -135,6 +135,14 @@ fn guard_chains(ring: &[[f64; 2]], fps: &[WallFootprint], arrival: ([f64; 2], [f
last.extend(chains[0].iter().skip(1).copied());
chains[0] = last;
}
// [155] Ein freier Lochring ohne Wand und Austritt ist ein einziger geschlossener Zug: Anfang und Ende
// fallen genau zusammen, damit die Achse an der Naht eine Gehrung bekommt statt zweier stumpfer Enden.
if let [ch] = chains.as_mut_slice() {
if ch.len() >= 4 && near(*ch.last().unwrap(), ch[0]) {
let first = ch[0];
*ch.last_mut().unwrap() = first;
}
}
chains
}
@@ -199,4 +207,50 @@ mod tests {
let g = parts.guard.expect("Absturzsicherung");
assert!(g.quantities[0].value > 1.0 && !g.mesh.indices.is_empty());
}
/// [155] Freier Lochring ohne Wand und Austritt: ein geschlossener Zug mit Gehrung an der Naht.
#[test]
fn freier_ring_ist_geschlossen_mit_gehrung() {
let ring: Vec<[f64; 2]> = vec![[0.0, 0.0], [2.0, 0.0], [2.0, 2.0], [0.0, 2.0]];
let chains = guard_chains(&ring, &[], ([9.0, 9.0], [9.5, 9.0]));
assert_eq!(chains.len(), 1);
assert!(crate::stair_rail::is_closed(&chains[0]), "{:?}", chains[0]);
let axis = offset_polyline(&chains[0], GUARD_INSET);
assert!(crate::stair_rail::is_closed(&axis));
// alle Ecken (auch die Naht) um GUARD_INSET innen, mit Gehrung: Quadrat 0.04 … 1.96
for q in &axis {
assert!(((q[0] - 1.0).abs() - (1.0 - GUARD_INSET)).abs() < 1e-9 && ((q[1] - 1.0).abs() - (1.0 - GUARD_INSET)).abs() < 1e-9, "{q:?}");
}
// Ring mit Austritt: offener Zug, rechtwinkliger Abschluss
let open = guard_chains(&ring, &[], ([1.0, 0.0], [1.5, 0.0]));
assert_eq!(open.len(), 1);
assert!(!crate::stair_rail::is_closed(&open[0]));
let a = offset_polyline(&open[0], GUARD_INSET);
assert!((a[0][0] - open[0][0][0]).abs() < 1e-9, "Anfang senkrecht zur Kante: {:?}", a[0]);
}
/// [T3] Profil der Treppe wirkt auf Absturzsicherung (3D) und IFC-Basismengen (Querschnittsfläche); Rundung wie bisher.
#[test]
fn handlaufprofil_in_3d_und_ifc() {
let mut p = with_hole();
let area = |p: &Project| {
let st = p.stairs.as_ref().unwrap()[0].clone();
let g = crate::ifc_stairs::stair_parts(p, &st, 0.0).guard.unwrap();
g.quantities.iter().find(|q| q.name == "CrossSectionArea").unwrap().value
};
let round_mesh = crate::model3d::stair_guard_meshes(&p)[0].1.positions.len();
assert!((area(&p) - std::f64::consts::PI * 0.02 * 0.02).abs() < 1e-9);
let st = &mut p.stairs.as_mut().unwrap()[0];
st.rail_profile = Some(StairRailProfile::Rechteck);
st.rail_width = Some(0.05);
st.rail_height = Some(0.03);
st.post_profile = Some(StairRailProfile::Rechteck);
assert!((area(&p) - 0.0015).abs() < 1e-9);
assert!(crate::model3d::stair_guard_meshes(&p)[0].1.positions.len() < round_mesh);
// JSON-Namen
let j = serde_json::to_value(&p.stairs.as_ref().unwrap()[0]).unwrap();
assert_eq!(j["railProfile"], "rechteck");
assert_eq!(j["railWidth"], 0.05);
assert!(serde_json::to_value(&sample().stairs.unwrap()[0]).unwrap().get("railProfile").is_none());
}
}
+10 -2
View File
@@ -212,10 +212,18 @@ pub fn boundary_arc(poly: &[P], a: P, b: P, avoid: &[P]) -> Vec<P> {
}
}
/// Geschlossener Zug: mindestens drei verschiedene Ecken, letzter Punkt gleich dem ersten.
pub fn is_closed(pts: &[P]) -> bool {
pts.len() >= 4 && near(pts[0], pts[pts.len() - 1])
}
/// Parallele zu einem Polygonzug im Abstand `d` (> 0 links der Laufrichtung), Gehrungen an den Ecken
/// (bei sehr spitzen Ecken auf das Vierfache begrenzt). Aufeinanderfolgende gleiche Punkte sind nicht erlaubt.
/// [155] Ein geschlossener Zug (letzter Punkt = erster, mindestens drei Ecken) bekommt auch an der Naht eine
/// Gehrung; Anfang und Ende bleiben gleich.
pub fn offset_polyline(pts: &[P], d: f64) -> Vec<P> {
let n = pts.len();
let closed = is_closed(pts);
let normals: Vec<Option<P>> = pts
.windows(2)
.map(|w| {
@@ -226,8 +234,8 @@ pub fn offset_polyline(pts: &[P], d: f64) -> Vec<P> {
.collect();
(0..n)
.map(|i| {
let a = i.checked_sub(1).and_then(|k| normals[k]);
let b = normals.get(i).copied().flatten();
let a = i.checked_sub(1).and_then(|k| normals[k]).or_else(|| if closed && i == 0 { normals[n - 2] } else { None });
let b = normals.get(i).copied().flatten().or_else(|| if closed && i == n - 1 { normals[0] } else { None });
let m = match (a, b) {
(Some(a), Some(b)) => {
let s = [a[0] + b[0], a[1] + b[1]];
+249 -36
View File
@@ -3,10 +3,11 @@
//! als Rohre (`railings`). Die Treppengeometrie selbst kommt aus `kernel2d` (`stair_geometry`); TS sammelt aus
//! dem `Project` nur Parameter, Höhen und Tragart und färbt die Ergebnisse ein.
//!
//! Eingabe (je Treppe 30 Zahlen, davor die Anzahl): die 22 Treppen-Parameter (s. [`crate::stair`]),
//! Eingabe (je Treppe 36 Zahlen, davor die Anzahl): die 22 Treppen-Parameter (s. [`crate::stair`]),
//! `zUnten, zOben, tragart (0 massiv, 1 beton, 2 offen: Wange/aufgesattelt/Spindel),
//! trittdicke, nase, geschlosseneSetzstufen (0/1), gelaender (0 keine, 1 links, 2 rechts, 3 beide),
//! saeulenRadius (0 keine; nur Wendel)`.
//! saeulenRadius (0 keine; nur Wendel), [T3] handlaufProfil (0 rund, 1 rechteck, 2 flach), handlaufBreite,
//! handlaufHoehe, pfostenProfil, pfostenBreite, pfostenTiefe (fehlend = NaN = Standard)`.
//!
//! Ausgabe Slabs: `[n, (treppe, monolith 0/1, zUnten, zOben, nPkt, x, y …)…]`; Ausgabe Meshes
//! (Laufplatte, Geländer): `[n, (treppe, nPos, nIdx, positionen…, indizes…)…]`. `treppe` ist der
@@ -43,6 +44,8 @@ struct StairIn {
closed_risers: bool,
railing: u8,
column_radius: f64,
/// [T3] Handlauf- und Pfostenprofil.
rail: RailSpec,
}
impl StairIn {
@@ -66,6 +69,7 @@ fn decode(buf: &[f64]) -> Option<Vec<Option<StairIn>>> {
}
let (z_bottom, z_top, structure, tread_thickness, nosing, closed, railing, column) =
(r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?);
let (rail_profile, rail_w, rail_h, post_profile, post_w, post_d) = (r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?);
// Eine unbrauchbare Treppe fällt einzeln weg (Index bleibt erhalten).
let valid = [z_bottom, z_top, tread_thickness, nosing].iter().all(|v| v.is_finite());
out.push(match (valid, decode_params(&p)) {
@@ -79,6 +83,7 @@ fn decode(buf: &[f64]) -> Option<Vec<Option<StairIn>>> {
closed_risers: closed != 0.0,
railing: railing.clamp(0.0, 3.0) as u8,
column_radius: if column.is_finite() && column > 0.0 { column.min(5.0) } else { 0.0 },
rail: RailSpec::decode([rail_profile, rail_w, rail_h, post_profile, post_w, post_d]),
}),
_ => None,
});
@@ -519,13 +524,131 @@ type V3 = [f64; 3];
/// Ecken des runden Handlauf-Profils.
const TUBE_SEGMENTS: usize = 12;
/// Rohr (Kreisprofil, Radius `radius`) entlang eines Polygonzugs, mit Deckeln; geschlossenes,
/// nach aussen orientiertes Netz. Profil-Ebene je Punkt senkrecht zur gemittelten Tangente; die
/// Profil-Lage wird mitgeführt (Doppelspiegelung, ohne Verdrillen). `None` bei < 2 Punkten oder
/// entarteten (zu kurzen/NaN-) Segmenten.
/// [T3] Querschnitt eines Handlaufs oder Pfostens: Punkte (quer, hoch) gegen den Uhrzeigersinn um die Achse.
type Section = Vec<[f64; 2]>;
fn round_section(radius: f64) -> Section {
(0..TUBE_SEGMENTS)
.map(|k| {
let a = std::f64::consts::TAU * k as f64 / TUBE_SEGMENTS as f64;
[crate::jsnum::cos(a) * radius, crate::jsnum::sin(a) * radius]
})
.collect()
}
fn rect_section(w: f64, h: f64) -> Section {
let (a, b) = (w / 2.0, h / 2.0);
vec![[a, -b], [a, b], [-a, b], [-a, -b]]
}
/// [T3] Profile von Handlauf und Pfosten einer Treppe (Mass in Metern); [`RailSpec::default`] = heutiges Rundrohr.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct RailSpec {
rail: (u8, f64, f64),
post: (u8, f64, f64),
}
impl Default for RailSpec {
fn default() -> Self {
RailSpec { rail: (0, RAIL_THICK, RAIL_THICK), post: (0, RAIL_THICK * 0.75, RAIL_THICK * 0.75) }
}
}
impl RailSpec {
/// Aus `[profil, breite, höhe, pfostenProfil, pfostenBreite, pfostenTiefe]`; fehlend/unsinnig = Standard.
pub fn decode(v: [f64; 6]) -> Self {
let kind = |x: f64| if x == 1.0 { 1 } else if x == 2.0 { 2 } else { 0 };
let dim = |x: f64, d: f64| if x.is_finite() && x > 0.0 { x.clamp(0.002, 0.5) } else { d };
let (rk, pk) = (kind(v[0]), kind(v[3]));
let rw = dim(v[1], RAIL_THICK);
let pw = dim(v[4], if pk == 2 { 0.04 } else { RAIL_THICK * 0.75 });
RailSpec {
rail: (rk, rw, dim(v[2], if rk == 2 { 0.01 } else { RAIL_THICK })),
post: (pk, pw, dim(v[5], if pk == 2 { 0.01 } else { RAIL_THICK * 0.75 })),
}
}
/// Dünne Rundrohre für die Ansichtskanten im Schnitt ([`railings_with`]).
fn thin(half: f64) -> Self {
RailSpec { rail: (0, half * 2.0, half * 2.0), post: (0, half * 1.5, half * 1.5) }
}
fn section((k, w, h): (u8, f64, f64)) -> Section {
if k == 0 { round_section(w / 2.0) } else { rect_section(w, h) }
}
fn rail_section(&self) -> Section {
Self::section(self.rail)
}
fn post_section(&self) -> Section {
Self::section(self.post)
}
fn area((k, w, h): (u8, f64, f64)) -> f64 {
if k == 0 { std::f64::consts::PI * w * w / 4.0 } else { w * h }
}
/// Halbe Handlaufbreite (m): Abstand der Kanten der Doppellinie im Grundriss.
pub fn rail_half_width(&self) -> f64 {
self.rail.1 / 2.0
}
/// Querschnittsfläche des Handlaufs (m²), für die IFC-Basismengen.
pub fn rail_area(&self) -> f64 {
Self::area(self.rail)
}
}
/// Richtung (waagrecht, Einheit) des Handlaufzugs bei `q`: Segment mit dem kleinsten Grundrissabstand.
fn path_dir(path: &[V3], q: P) -> Option<V3> {
let mut best: Option<(f64, V3)> = None;
for w in path.windows(2) {
let d = [w[1][0] - w[0][0], w[1][1] - w[0][1]];
let l2 = d[0] * d[0] + d[1] * d[1];
if !(l2 > 1e-12) {
continue;
}
let t = (((q[0] - w[0][0]) * d[0] + (q[1] - w[0][1]) * d[1]) / l2).clamp(0.0, 1.0);
let dist = hypot2(w[0][0] + d[0] * t - q[0], w[0][1] + d[1] * t - q[1]);
if best.map_or(true, |(b, _)| dist < b) {
let l = l2.sqrt();
best = Some((dist, [d[0] / l, d[1] / l, 0.0]));
}
}
best.map(|b| b.1)
}
/// Querachse eines eckigen Handlaufprofils: waagrecht quer zum ersten Segment (Breite waagrecht, Höhe senkrecht).
/// Rundprofile brauchen keine (und behalten so ihre Netze bit-genau).
fn rail_across(kind: u8, path: &[V3]) -> Option<V3> {
if kind == 0 {
return None;
}
let w = path.windows(2).next()?;
let (dx, dy) = (w[1][0] - w[0][0], w[1][1] - w[0][1]);
let l = hypot2(dx, dy);
(l > 1e-9).then(|| [-dy / l, dx / l, 0.0])
}
/// Rohr mit Kreisprofil: [`sweep`] mit rundem Querschnitt.
#[cfg(test)]
fn tube_along(path: &[V3], radius: f64) -> Option<(Vec<f64>, Vec<u32>)> {
if !(radius > 0.0) {
return None;
}
sweep(path, &round_section(radius), None)
}
/// Körper (beliebiger konvexer Querschnitt `section`) entlang eines Polygonzugs, mit Deckeln; geschlossenes,
/// nach aussen orientiertes Netz. Profil-Ebene je Punkt senkrecht zur gemittelten Tangente; die
/// Profil-Lage wird mitgeführt (Doppelspiegelung, ohne Verdrillen). Die erste Profilachse liegt zu Beginn
/// in `start_normal` (auf die Profil-Ebene projiziert); ohne sie senkrecht (für Rundprofile ohne Belang). `None` bei < 2
/// Punkten oder entarteten (zu kurzen/NaN-) Segmenten.
fn sweep(path: &[V3], section: &Section, start_normal: Option<V3>) -> Option<(Vec<f64>, Vec<u32>)> {
let n = path.len();
if n < 2 || !(radius > 0.0) {
let m = section.len();
if n < 2 || m < 3 {
return None;
}
let sub = |a: V3, b: V3| [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
@@ -544,11 +667,28 @@ fn tube_along(path: &[V3], radius: f64) -> Option<(Vec<f64>, Vec<u32>)> {
(None, None) => [0.0, 0.0, 1.0],
})
.collect();
// [155] Geschlossener Zug (Anfang = Ende): Gehrung an der Naht, keine Deckel.
let closed = n >= 4 && hypot(&sub(path[0], path[n - 1])) < 1e-9;
let mut tangents = tangents;
if closed {
let (a, b) = (seg[n - 2], seg[0]);
if let Some(t) = unit([a[0] + b[0], a[1] + b[1], a[2] + b[2]]) {
tangents[0] = t;
tangents[n - 1] = t;
}
}
// Start-Normale: quer zur Tangente, möglichst waagrecht.
let t0 = tangents[0];
let up: V3 = if t0[2].abs() > 0.98 { [1.0, 0.0, 0.0] } else { [0.0, 0.0, 1.0] };
let mut normal = unit(cross(cross(t0, up), t0))?;
let mut positions = Vec::with_capacity(3 * (n * TUBE_SEGMENTS + 2));
if let Some(sn) = start_normal {
// gewünschte Querachse, senkrecht zur Tangente gestellt
let d = dot(sn, t0);
if let Some(u) = unit(sub(sn, t0.map(|x| x * d))) {
normal = u;
}
}
let mut positions = Vec::with_capacity(3 * (n * m + 2));
for i in 0..n {
if i > 0 {
// Doppelspiegelung (Wang et al. 2008): rotationsminimierende Rahmen.
@@ -562,9 +702,7 @@ fn tube_along(path: &[V3], radius: f64) -> Option<(Vec<f64>, Vec<u32>)> {
normal = unit(normal)?;
}
let bi = cross(tangents[i], normal);
for k in 0..TUBE_SEGMENTS {
let a = std::f64::consts::TAU * k as f64 / TUBE_SEGMENTS as f64;
let (c, s) = (crate::jsnum::cos(a) * radius, crate::jsnum::sin(a) * radius);
for &[c, s] in section {
for d in 0..3 {
positions.push(path[i][d] + normal[d] * c + bi[d] * s);
}
@@ -576,19 +714,21 @@ fn tube_along(path: &[V3], radius: f64) -> Option<(Vec<f64>, Vec<u32>)> {
for d in 0..3 {
positions.push(path[n - 1][d]);
}
let m = TUBE_SEGMENTS as u32;
let m = m as u32;
let ring = |i: usize, k: u32| i as u32 * m + k % m;
let (c0, c1) = ((n * TUBE_SEGMENTS) as u32, (n * TUBE_SEGMENTS) as u32 + 1);
let mut indices = Vec::with_capacity(6 * TUBE_SEGMENTS * n);
let (c0, c1) = ((n * section.len()) as u32, (n * section.len()) as u32 + 1);
let mut indices = Vec::with_capacity(6 * section.len() * n);
for i in 0..n - 1 {
for k in 0..m {
let (a, b, c, d) = (ring(i, k), ring(i, k + 1), ring(i + 1, k + 1), ring(i + 1, k));
indices.extend([a, b, c, a, c, d]);
}
}
for k in 0..m {
indices.extend([c0, ring(0, k + 1), ring(0, k)]);
indices.extend([c1, ring(n - 1, k), ring(n - 1, k + 1)]);
if !closed {
for k in 0..m {
indices.extend([c0, ring(0, k + 1), ring(0, k)]);
indices.extend([c1, ring(n - 1, k), ring(n - 1, k + 1)]);
}
}
Some((positions, indices))
}
@@ -660,18 +800,20 @@ pub fn stringers(buf: &[f64]) -> Vec<Mesh> {
out
}
fn railings_of(s: &StairIn, idx: usize, half: f64, out: &mut Vec<Mesh>) {
fn railings_of(s: &StairIn, idx: usize, thin: Option<f64>, out: &mut Vec<Mesh>) {
if s.railing == 0 {
return;
}
let Some((geo, _)) = geometry_of(s) else { return };
let z0 = s.z_bottom;
let spec = thin.map_or(s.rail, RailSpec::thin);
let (rail_sec, post_sec) = (spec.rail_section(), spec.post_section());
let mut tubes: Vec<(Vec<f64>, Vec<u32>)> = Vec::new();
for rail in crate::stair_rail::rails(&s.params, &geo, s.railing) {
let path: Vec<V3> = rail.path.iter().map(|q| [q[0], q[1], q[2] + z0]).collect();
tubes.extend(tube_along(&path, half));
tubes.extend(sweep(&path, &rail_sec, rail_across(spec.rail.0, &path)));
for (p, z) in &rail.posts {
tubes.extend(tube_along(&[[p[0], p[1], z0 + z], [p[0], p[1], z0 + z + crate::stair_rail::RAIL_HEIGHT]], half * 0.75));
tubes.extend(sweep(&[[p[0], p[1], z0 + z], [p[0], p[1], z0 + z + crate::stair_rail::RAIL_HEIGHT]], &post_sec, path_dir(&path, *p)));
}
}
if s.spiral() {
@@ -722,17 +864,22 @@ pub fn slab_meshes(buf: &[f64]) -> Vec<Mesh> {
}
pub fn railings(buf: &[f64]) -> Vec<Mesh> {
railings_with(buf, RAIL_THICK / 2.0)
railings_in(buf, None)
}
/// [157] Wie [`railings`] mit Rohr-Halbmesser `half` (Schnitt: dünn, damit Handlauf und Pfosten als je eine
/// Linie erscheinen statt als Doppellinie im Rohrabstand).
pub fn railings_with(buf: &[f64], half: f64) -> Vec<Mesh> {
railings_in(buf, Some(half))
}
/// `thin`: Rohr-Halbmesser statt des Profils der Treppe ([`railings_with`]).
fn railings_in(buf: &[f64], thin: Option<f64>) -> Vec<Mesh> {
let mut out = Vec::new();
let Some(stairs) = decode(buf) else { return out };
for (i, s) in stairs.iter().enumerate() {
if let Some(s) = s {
railings_of(s, i, half, &mut out);
railings_of(s, i, thin, &mut out);
}
}
out
@@ -745,32 +892,35 @@ 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> {
pub fn guard_mesh(axes: &[Vec<P>], z: f64, src: usize, spec: &RailSpec) -> Option<Mesh> {
let h = crate::stair_rail::RAIL_HEIGHT;
let half = RAIL_THICK / 2.0;
let (rail_sec, post_sec) = (spec.rail_section(), spec.post_section());
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));
tubes.extend(sweep(&top, &rail_sec, rail_across(spec.rail.0, &top)));
let post_at = |q: P, sec: &Section, dir: Option<V3>, z1: f64, tubes: &mut Vec<(Vec<f64>, Vec<u32>)>| tubes.extend(sweep(&[[q[0], q[1], z], [q[0], q[1], z1]], sec, dir));
let bal_sec = round_section(0.006);
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 dir = Some([(w[1][0] - w[0][0]) / len, (w[1][1] - w[0][1]) / len, 0.0]);
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);
for k in 0..n_post + usize::from(i + 2 == axis.len() && !crate::stair_rail::is_closed(axis)) {
post_at(at(k as f64 / n_post as f64), &post_sec, dir, 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);
post_at(at(t), &bal_sec, None, z + h - half, &mut tubes);
}
}
}
@@ -796,7 +946,7 @@ mod tests {
1.0, // eine Treppe
0.0, 0.0, 0.0, 1.0, 0.0, 3.0, nan, nan, nan, nan, nan, nan, 1.0, 10.0, nan, 0.0, // Parameter
nan, nan, nan, nan, nan, nan,
0.0, 2.8, structure, 0.04, nosing, closed, railing, 0.0,
0.0, 2.8, structure, 0.04, nosing, closed, railing, 0.0, f64::NAN, f64::NAN, f64::NAN, f64::NAN, f64::NAN, f64::NAN,
]
}
@@ -845,7 +995,7 @@ mod tests {
vec![
1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 2.0, 1.5, turn, nan, nan, nan, nan, 1.0, 10.0, nan, 0.0,
nan, nan, nan, nan, nan, nan,
0.0, 2.8, 0.0, 0.04, 0.0, 0.0, railing, 0.0,
0.0, 2.8, 0.0, 0.04, 0.0, 0.0, railing, 0.0, f64::NAN, f64::NAN, f64::NAN, f64::NAN, f64::NAN, f64::NAN,
]
}
@@ -882,7 +1032,7 @@ mod tests {
let s = stairs[0].as_ref().unwrap();
let (geo, _) = geometry_of(s).unwrap();
let mut out = Vec::new();
railings_of(s, 0, RAIL_THICK / 2.0, &mut out);
railings_of(s, 0, None, &mut out);
let rail = &out[0];
// Podesthöhe: Oberkante Podest + 0.9 kommt als Ebene im Handlauf vor
let z_land = geo.treads.iter().find(|t| t.index > 2).unwrap().base_rise + RAIL_HEIGHT;
@@ -948,7 +1098,7 @@ mod tests {
let l = vec![
1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 2.0, 1.5, 1.0, nan, nan, nan, nan, 1.0, 10.0, nan, 0.0, // L
nan, nan, nan, nan, nan, nan,
0.0, 2.8, 0.0, 0.04, 0.0, 0.0, 0.0, 0.0,
0.0, 2.8, 0.0, 0.04, 0.0, 0.0, 0.0, 0.0, f64::NAN, f64::NAN, f64::NAN, f64::NAN, f64::NAN, f64::NAN,
];
let s = slabs(&l, false);
assert!(s.len() >= 10);
@@ -959,7 +1109,7 @@ mod tests {
let w = vec![
1.0, 2.0, 1.0, 0.0, 1.0, 0.0, 1.0, nan, nan, 0.0, 0.0, 1.5, 270.0, 1.0, 12.0, nan, 0.0, // Wendel
nan, nan, nan, nan, nan, nan,
0.0, 2.8, 2.0, 0.04, 0.0, 0.0, 3.0, 0.0,
0.0, 2.8, 2.0, 0.04, 0.0, 0.0, 3.0, 0.0, f64::NAN, f64::NAN, f64::NAN, f64::NAN, f64::NAN, f64::NAN,
];
assert!(!slabs(&w, false).is_empty());
assert!(!railings(&w).is_empty()); // Wendelgeländer = Schraubensweep
@@ -970,7 +1120,7 @@ mod tests {
vec![
1.0, 2.0, 1.0, 0.0, 1.0, 0.0, 1.0, nan, nan, 0.0, 0.0, 1.5, 270.0, 1.0, 12.0, nan, 0.0, // Wendel
nan, nan, nan, nan, nan, nan,
0.0, 2.8, structure, 0.04, 0.0, 0.0, railing, column,
0.0, 2.8, structure, 0.04, 0.0, 0.0, railing, column, f64::NAN, f64::NAN, f64::NAN, f64::NAN, f64::NAN, f64::NAN,
]
}
@@ -1102,7 +1252,7 @@ mod tests {
vec![
1.0, 3.0, 0.0, 0.0, 1.0, 0.0, 2.5, 2.5, 1.0, nan, nan, nan, nan, 1.0, 17.0, nan, 0.0,
0.2, nan, nan, mid, nan, nan,
0.0, 2.89, structure, 0.04, 0.0, 0.0, railing, 0.0,
0.0, 2.89, structure, 0.04, 0.0, 0.0, railing, 0.0, f64::NAN, f64::NAN, f64::NAN, f64::NAN, f64::NAN, f64::NAN,
]
}
@@ -1210,7 +1360,7 @@ mod tests {
vec![
1.0, 4.0, 0.0, 0.0, 1.0, 0.0, 2.0, 2.0, nan, nan, nan, nan, nan, 1.0, 16.0, nan, 0.0,
nan, 1.2, 8.0, nan, nan, nan,
0.0, 2.8, structure, 0.04, 0.0, 0.0, 3.0, 0.0,
0.0, 2.8, structure, 0.04, 0.0, 0.0, 3.0, 0.0, f64::NAN, f64::NAN, f64::NAN, f64::NAN, f64::NAN, f64::NAN,
]
};
let s = slabs(&b(0.0), false);
@@ -1224,4 +1374,67 @@ mod tests {
let c = tube_centers(&r[0]);
assert!((c[c.len() - 1][0] - 5.2).abs() < 1e-9 && (c[c.len() - 1][2] - 3.7).abs() < 1e-9);
}
/// [T3] Ohne Angabe: Standard-Rundrohr; Rechteck/Flachstahl: vier Ecken je Querschnitt, Mass wie angegeben.
#[test]
fn handlauf_profile() {
assert_eq!(RailSpec::decode([f64::NAN; 6]), RailSpec::default());
assert!((RailSpec::default().rail_area() - std::f64::consts::PI * 0.02 * 0.02).abs() < 1e-12);
// Rechteck 6 × 2 cm entlang x: y-Spanne = Breite, z-Spanne = Höhe (Querachse waagrecht).
let path: Vec<V3> = vec![[0.0, 0.0, 1.0], [2.0, 0.0, 1.0]];
let (pos, idx) = sweep(&path, &rect_section(0.06, 0.02), rail_across(1, &path)).unwrap();
assert_eq!(pos.len(), 3 * (2 * 4 + 2));
let span = |d: usize| {
let v: Vec<f64> = pos.chunks(3).take(8).map(|q| q[d]).collect();
v.iter().cloned().fold(f64::MIN, f64::max) - v.iter().cloned().fold(f64::MAX, f64::min)
};
assert!((span(1) - 0.06).abs() < 1e-9 && (span(2) - 0.02).abs() < 1e-9, "{} {}", span(1), span(2));
assert_eq!(idx.len(), 3 * (2 * 4 + 2 * 4)); // vier Seitenflächen (je 2 Dreiecke) + Deckel
// nach aussen orientiert (positives Volumen)
let m = Mesh { src: 0, positions: pos, indices: idx };
assert!(signed_volume(&m) > 0.0);
// Treppe: Rechteck-Handlauf hat weniger Ecken als das Rundrohr, das Profil wirkt auch auf den Pfosten
let mut round = straight(2.0, 1.0, 0.0, 0.0);
let r0 = railings(&round);
let n = round.len();
round[n - 6..].copy_from_slice(&[1.0, 0.06, 0.03, 1.0, 0.05, 0.02]);
let r1 = railings(&round);
assert_eq!(r0.len(), r1.len());
assert!(r1[0].positions.len() < r0[0].positions.len());
assert!(r1.iter().skip(1).all(|m| m.positions.len() == 3 * (2 * 4 + 2)), "Pfosten vierkant");
// Ansichtskanten im Schnitt bleiben dünne Rundrohre
assert_eq!(railings_with(&round, 0.004)[0].positions.len(), railings_with(&straight(2.0, 1.0, 0.0, 0.0), 0.004)[0].positions.len());
}
/// [T3] Absturzsicherung nimmt das Profil der Treppe; Pfosten stehen mit der Breite in Richtung des Handlaufs.
#[test]
fn absturzsicherung_profil() {
let axes = vec![vec![[0.0, 0.0], [2.0, 0.0]]];
let round = guard_mesh(&axes, 0.0, 0, &RailSpec::default()).unwrap();
let spec = RailSpec::decode([1.0, 0.05, 0.03, 2.0, 0.04, 0.01]);
let flat = guard_mesh(&axes, 0.0, 0, &spec).unwrap();
assert!(flat.positions.len() < round.positions.len());
// erster Pfosten (nach dem Handlauf): x-Spanne 4 cm (Breite), y-Spanne 1 cm (Dicke)
let first = &flat.positions[3 * (2 * 4 + 2)..3 * (2 * 4 + 2) + 3 * 8];
let span = |d: usize| {
let v: Vec<f64> = first.chunks(3).map(|q| q[d]).collect();
v.iter().cloned().fold(f64::MIN, f64::max) - v.iter().cloned().fold(f64::MAX, f64::min)
};
assert!((span(0) - 0.04).abs() < 1e-9 && (span(1) - 0.01).abs() < 1e-9, "{} {}", span(0), span(1));
}
/// [155] Geschlossener Zug (freier Lochring): ohne Deckel, Naht ohne Lücke.
#[test]
fn geschlossener_zug_ohne_deckel() {
let path: Vec<V3> = vec![[0.0, 0.0, 1.0], [1.0, 0.0, 1.0], [1.0, 1.0, 1.0], [0.0, 1.0, 1.0], [0.0, 0.0, 1.0]];
let (pos, idx) = sweep(&path, &round_section(0.02), None).unwrap();
assert_eq!(idx.len(), 6 * TUBE_SEGMENTS * 4, "nur Mantel");
// erster und letzter Ring fallen zusammen
let m = TUBE_SEGMENTS * 3;
for k in 0..m {
assert!((pos[k] - pos[4 * m + k]).abs() < 1e-9, "{k}");
}
// offener Zug behält die Deckel
assert_eq!(sweep(&path[..4], &round_section(0.02), None).unwrap().1.len(), 6 * TUBE_SEGMENTS * 3 + 6 * TUBE_SEGMENTS);
}
}
+11
View File
@@ -876,6 +876,17 @@ export const de = {
"objinfo.stair.midOffset": "Versatz Mittellauf",
"objinfo.stair.width": "Laufbreite",
"objinfo.stair.column": "Mittelsäule (Radius)",
"objinfo.stair.railProfile": "Handlauf-Profil",
"objinfo.stair.railDiameter": "Handlauf Durchmesser",
"objinfo.stair.railWidth": "Handlauf Breite",
"objinfo.stair.railHeight": "Handlauf Höhe",
"objinfo.stair.postProfile": "Pfosten-Profil",
"objinfo.stair.postDiameter": "Pfosten Durchmesser",
"objinfo.stair.postWidth": "Pfosten Breite",
"objinfo.stair.postDepth": "Pfosten Tiefe",
"objinfo.stair.profile.rund": "Rund",
"objinfo.stair.profile.rechteck": "Rechteck",
"objinfo.stair.profile.flach": "Flachstahl",
"objinfo.stair.steps": "Stufenanzahl",
"objinfo.stair.rise": "Steighöhe (gesamt)",
"objinfo.stair.riser": "Steigungshöhe",
+11
View File
@@ -860,6 +860,17 @@ export const en: Record<TranslationKey, string> = {
"objinfo.stair.shape.spiral": "Spiral",
"objinfo.stair.width": "Run width",
"objinfo.stair.column": "Centre column (radius)",
"objinfo.stair.railProfile": "Handrail profile",
"objinfo.stair.railDiameter": "Handrail diameter",
"objinfo.stair.railWidth": "Handrail width",
"objinfo.stair.railHeight": "Handrail height",
"objinfo.stair.postProfile": "Post profile",
"objinfo.stair.postDiameter": "Post diameter",
"objinfo.stair.postWidth": "Post width",
"objinfo.stair.postDepth": "Post depth",
"objinfo.stair.profile.rund": "Round",
"objinfo.stair.profile.rechteck": "Rectangular",
"objinfo.stair.profile.flach": "Flat bar",
"objinfo.stair.steps": "Step count",
"objinfo.stair.rise": "Total rise",
"objinfo.stair.riser": "Riser height",
+21
View File
@@ -3516,6 +3516,27 @@ export type Stair = {
* ≤ 0, gibt es keine Säule.
*/
centerColumn?: number;
/**
* [T3] Handlauf-Profil (gilt für alle Treppenformen und die Absturzsicherung am Deckenloch);
* fehlt es, ist der Handlauf ein Rundrohr von 4 cm.
*/
railProfile?: "rund" | "rechteck" | "flach";
/** [T3] Handlauf-Breite in Metern (rund: Durchmesser; fehlt = 0.04). */
railWidth?: number;
/**
* [T3] Handlauf-Höhe in Metern (rechteckig: fehlt = 0.04; Flachstahl: Dicke, fehlt = 0.01; rund: ohne Wirkung).
*/
railHeight?: number;
/** [T3] Pfosten-Profil (fehlt = rund). */
postProfile?: "rund" | "rechteck" | "flach";
/**
* [T3] Pfosten-Breite in Metern, in Richtung des Handlaufs (rund: Durchmesser; fehlt = 0.03, Flachstahl 0.04).
*/
postWidth?: number;
/**
* [T3] Pfosten-Tiefe in Metern, quer zum Handlauf (rechteckig: fehlt = 0.03; Flachstahl: Dicke, fehlt = 0.01; rund: ohne Wirkung).
*/
postDepth?: number;
};
/**
+1 -1
View File
@@ -562,7 +562,7 @@ export interface PanelHostValue {
/** Weist der Treppe einen Treppentyp (Bibliothek) zu; "" löst die Zuweisung. */
onSetStairType: (typeId: string) => void;
/** [151] Lauf-/Podest-Parameter (Lauflängen, Drehsinn, Auge, Podesttiefe, Stufen je Lauf, Versatz). */
onSetStairPatch: (patch: Partial<Pick<Stair, "runLength" | "run2Length" | "turn" | "gap" | "landingLength" | "run1Steps" | "midSteps" | "run2Offset" | "midOffset">>) => void;
onSetStairPatch: (patch: Partial<Pick<Stair, "runLength" | "run2Length" | "turn" | "gap" | "landingLength" | "run1Steps" | "midSteps" | "run2Offset" | "midOffset" | "railProfile" | "railWidth" | "railHeight" | "postProfile" | "postWidth" | "postDepth">>) => void;
// ── Raum-Attribute (Object-Info-Panel; nur der selektierte Raum) ────────
/** Setzt den Raum-Namen. */
+35
View File
@@ -14,6 +14,40 @@ import { DimensionField } from "./fields";
* [151] Läufe und Podest einer Podesttreppe (L, U, gerade mit Podest): Lauflängen, Steigungen im ersten
* Lauf, Drehsinn (L/U), Treppenauge, Mittellauf und Versatz (U), Podesttiefe (U, gerade mit Podest).
*/
type RailProfile = "rund" | "rechteck" | "flach";
/** [T3] Handlauf- und Pfosten-Querschnitt (gilt für alle Treppenformen und die Absturzsicherung). */
function StairRailFields({ stair, host }: { stair: StairInfo; host: ReturnType<typeof usePanelHost> }) {
const profiles = [
{ value: "rund", label: t("objinfo.stair.profile.rund") },
{ value: "rechteck", label: t("objinfo.stair.profile.rechteck") },
{ value: "flach", label: t("objinfo.stair.profile.flach") },
];
const rail = stair.railProfile ?? "rund";
const post = stair.postProfile ?? "rund";
// Standardmasse wie im Kern (`RailSpec::decode`)
const railH = stair.railHeight ?? (rail === "flach" ? 0.01 : 0.04);
const postW = stair.postWidth ?? (post === "flach" ? 0.04 : 0.03);
const postD = stair.postDepth ?? (post === "flach" ? 0.01 : 0.03);
const set = (patch: Parameters<typeof host.onSetStairPatch>[0]) => host.onSetStairPatch(patch);
return (
<>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.stair.railProfile")}</span>
<Dropdown value={rail} onChange={(v) => set({ railProfile: v === "rund" ? undefined : (v as RailProfile) })} options={profiles} title={t("objinfo.stair.railProfile")} width={130} />
</div>
<DimensionField label={rail === "rund" ? t("objinfo.stair.railDiameter") : t("objinfo.stair.railWidth")} value={stair.railWidth ?? 0.04} onCommit={(v) => set({ railWidth: v > 0 ? v : undefined })} />
{rail !== "rund" && <DimensionField label={t("objinfo.stair.railHeight")} value={railH} onCommit={(v) => set({ railHeight: v > 0 ? v : undefined })} />}
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.stair.postProfile")}</span>
<Dropdown value={post} onChange={(v) => set({ postProfile: v === "rund" ? undefined : (v as RailProfile) })} options={profiles} title={t("objinfo.stair.postProfile")} width={130} />
</div>
<DimensionField label={post === "rund" ? t("objinfo.stair.postDiameter") : t("objinfo.stair.postWidth")} value={postW} onCommit={(v) => set({ postWidth: v > 0 ? v : undefined })} />
{post !== "rund" && <DimensionField label={t("objinfo.stair.postDepth")} value={postD} onCommit={(v) => set({ postDepth: v > 0 ? v : undefined })} />}
</>
);
}
function StairFlightFields({ stair, host }: { stair: StairInfo; host: ReturnType<typeof usePanelHost> }) {
const isU = stair.shape === "U";
const turn = stair.turn ?? 1;
@@ -213,6 +247,7 @@ export function StairSection({
onCommit={(v) => host.onSetStairColumn(v)}
/>
)}
<StairRailFields stair={stair} host={host} />
{stair.shape !== "spiral" && stair.shape !== "straight" && <StairFlightFields stair={stair} host={host} />}
<DimensionField
label={t("objinfo.stair.steps")}
@@ -1,12 +1,12 @@
viewBox -13.448 0 38.615 33.813
bytes 20038
bytes 20024
circle 14
g 1
line 63
polygon 29
polyline 14
polygon 30
polyline 13
rect 1
svg 1
text 32
tspan 9
hash dfd484ce590877a4
hash 82cd80b6658fd8f2
@@ -1,12 +1,12 @@
viewBox -12.974 0 37.808 33.406
bytes 318165
bytes 318135
circle 14
g 1
line 3212
polygon 75
polyline 72
polygon 77
polyline 70
rect 1
svg 1
text 32
tspan 9
hash f65e632e02bea427
hash 608c18c089b7cda0
+3 -3
View File
@@ -2,7 +2,7 @@ meshes [1958]
meshes[].color [3] x1958
meshes[].indices [108] x6
meshes[].indices [11376]
meshes[].indices [12888]
meshes[].indices [12960]
meshes[].indices [144] x55
meshes[].indices [156642]
meshes[].indices [1584]
@@ -33,7 +33,7 @@ meshes[].positions [324] x6
meshes[].positions [4128]
meshes[].positions [4746]
meshes[].positions [6096]
meshes[].positions [6972]
meshes[].positions [7050]
meshes[].positions [72] x2
meshes[].positions [78837]
meshes[].positions [78] x55
@@ -68,4 +68,4 @@ walls[].start [2] x1492
walls[].startCut [4] x1107
walls[].topDrop [2] x115
walls[].topPlane [3] x271
hash a7e38b2a054609be
hash 11c141a0fe0852d7
+7
View File
@@ -284,6 +284,13 @@ export interface StairInfo {
referenz?: "links" | "mitte" | "rechts";
/** Nur Wendel: Radius der Mittelsäule (Meter); fehlt → keine Säule. */
centerColumn?: number;
/** [T3] Handlauf-/Pfosten-Profil (rund / rechteck / flach) und Masse in Metern; fehlt → Rundrohr. */
railProfile?: "rund" | "rechteck" | "flach";
railWidth?: number;
railHeight?: number;
postProfile?: "rund" | "rechteck" | "flach";
postWidth?: number;
postDepth?: number;
/** Länge des (ersten) Laufs (Meter). */
runLength?: number;
/** [151] L / U / gerade mit Podest: Länge des zweiten bzw. letzten Laufs; Drehsinn (+1 links, −1 rechts). */