Merge [281] Geneigte Decken und Rampen (IFC-Datensatz der geneigten Decke auf 27, 26 bleibt Geländer)
This commit is contained in:
60 files changed
+1273
-66
No files matched your search
@@ -0,0 +1,213 @@
|
||||
//! [281] Geneigte Decken und Rampen: Neigungsebene, 3D-Platten, Schnitt, Ansicht, Grundriss-Symbol, IFC, Flächen.
|
||||
|
||||
use crate::model::*;
|
||||
use crate::plan::section::{compute_section, Kind, LevelSpec};
|
||||
|
||||
fn sample() -> Project {
|
||||
serde_json::from_str(include_str!("../tests/fixtures/sample_project.json")).unwrap()
|
||||
}
|
||||
|
||||
/// Beispiel mit der Decke C1 (5 × 4 m, EG, OK 2.6 m) als Rampe längs x: steigt von x = 0 bis x = 5 um `rise`.
|
||||
fn sloped(rise: f64, ramp: bool) -> Project {
|
||||
let mut p = sample();
|
||||
let c = &mut p.ceilings.as_mut().unwrap()[0];
|
||||
c.slope = Some(CeilingSlope { from: Vec2 { x: 0.0, y: 2.0 }, to: Vec2 { x: 5.0, y: 2.0 }, rise, ramp: ramp.then_some(true), ..Default::default() });
|
||||
p
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn neigungsebene_und_hoehenspanne() {
|
||||
let p = sloped(0.75, false);
|
||||
let c = &p.ceilings.as_ref().unwrap()[0];
|
||||
let g = c.slope_plane().unwrap();
|
||||
assert!((g[2] - 0.15).abs() < 1e-12 && g[3].abs() < 1e-12, "{g:?}");
|
||||
assert!((c.slope_dz(5.0, 3.0) - 0.75).abs() < 1e-12 && c.slope_dz(0.0, -7.0).abs() < 1e-12);
|
||||
let (zb, zt) = p.ceiling_vertical_extent(c);
|
||||
let (lo, hi) = p.ceiling_vertical_span(c);
|
||||
assert!((lo - zb).abs() < 1e-12 && (hi - zt - 0.75).abs() < 1e-12, "{lo} {hi}");
|
||||
// Entartet: Gefällelinie zu kurz, Höhe 0 oder NaN ⇒ waagrecht.
|
||||
for (to, rise) in [((0.0, 2.0), 1.0), ((5.0, 2.0), 0.0), ((5.0, 2.0), f64::NAN)] {
|
||||
let mut q = sloped(rise, false);
|
||||
q.ceilings.as_mut().unwrap()[0].slope.as_mut().unwrap().to = Vec2 { x: to.0, y: to.1 };
|
||||
let c = &q.ceilings.as_ref().unwrap()[0];
|
||||
assert!(c.slope_plane().is_none() && c.slope_dz(3.0, 3.0) == 0.0);
|
||||
}
|
||||
assert!(!p.ceilings.as_ref().unwrap()[0].is_ramp() && sloped(0.5, true).ceilings.as_ref().unwrap()[0].is_ramp());
|
||||
}
|
||||
|
||||
/// Die Neigung übersteht die Projektdatei (serde) und das Dokument (Ops).
|
||||
#[test]
|
||||
fn neigung_in_datei_und_ops() {
|
||||
let p = sloped(-0.6, true);
|
||||
let v = serde_json::to_value(&p.ceilings.as_ref().unwrap()[0]).unwrap();
|
||||
assert_eq!(v["slope"], serde_json::json!({"from": {"x": 0.0, "y": 2.0}, "to": {"x": 5.0, "y": 2.0}, "rise": -0.6, "ramp": true}));
|
||||
let back: Ceiling = serde_json::from_value(v).unwrap();
|
||||
assert_eq!(back.slope, p.ceilings.as_ref().unwrap()[0].slope);
|
||||
}
|
||||
|
||||
/// 3D: alle Schichtplatten tragen die Neigungsebene; das Netz (render3d) liegt am oberen Ende um `rise` höher.
|
||||
#[test]
|
||||
fn platten_und_netz_folgen_der_neigung() {
|
||||
let p = sloped(0.75, false);
|
||||
let slabs = crate::model3d::emit_slabs(&p);
|
||||
assert!(!slabs.is_empty());
|
||||
assert!(slabs.iter().all(|s| s.slope.is_some()));
|
||||
let flat = crate::model3d::emit_slabs(&sample());
|
||||
assert_eq!(flat.len(), slabs.len());
|
||||
let top = slabs.iter().map(|s| s.z_top).fold(f64::NEG_INFINITY, f64::max);
|
||||
let si = crate::plan::section::slab_input_pub(&slabs[0]);
|
||||
let mut m = render3d::Mesh::default();
|
||||
render3d::extrude_slab(&mut m, &si);
|
||||
let ys: Vec<(f32, f32)> = m.verts.chunks(render3d::FLOATS_PER_VERTEX).map(|v| (v[0], v[1])).collect();
|
||||
let max_at = |x: f32| ys.iter().filter(|q| (q.0 - x).abs() < 0.3).map(|q| q.1).fold(f32::MIN, f32::max);
|
||||
// Der Plattenrand kann um das Auflager eingezogen sein: Höhe am Rand = OK + 0.15 · x.
|
||||
let x_hi = ys.iter().map(|q| q.0).fold(f32::MIN, f32::max);
|
||||
assert!((max_at(x_hi) as f64 - (top + 0.15 * x_hi as f64)).abs() < 2e-3, "{} {}", max_at(x_hi), top);
|
||||
}
|
||||
|
||||
fn section_x(p: &Project) -> crate::plan::section::Output {
|
||||
let l = LevelSpec { kind: "section".into(), line: Some([Vec2 { x: -2.0, y: 2.0 }, Vec2 { x: 7.0, y: 2.0 }]), ..Default::default() };
|
||||
compute_section(p, &l, &[]).unwrap().unwrap()
|
||||
}
|
||||
|
||||
/// Schnitt längs der Gefällelinie: die Deckenbänder sind schräg (Höhe an beiden Enden um `rise` verschieden), alle
|
||||
/// Schichten parallel; quer geschnitten bleiben sie Rechtecke (gleiche Höhe über die Breite), aber höher.
|
||||
#[test]
|
||||
fn schnitt_laengs_und_quer() {
|
||||
let flat = section_x(&sample());
|
||||
let p = sloped(0.75, false);
|
||||
let o = section_x(&p);
|
||||
let slab_cuts = |o: &crate::plan::section::Output| o.cuts.iter().filter(|c| c.kind == Kind::Slab && c.source_id.as_deref() == Some("C1")).map(|c| c.pts.clone()).collect::<Vec<_>>();
|
||||
let (a, b) = (slab_cuts(&flat), slab_cuts(&o));
|
||||
assert!(!b.is_empty() && a.len() == b.len(), "{} {}", a.len(), b.len());
|
||||
// Je Band: Oberkante links/rechts; geneigt: Höhenunterschied = 0.15 × Bandlänge.
|
||||
for ring in &b {
|
||||
let (u0, u1) = ring.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |(a, b), q| (a.min(q[0]), b.max(q[0])));
|
||||
let v_at = |u: f64| ring.iter().filter(|q| (q[0] - u).abs() < 1e-6).map(|q| q[1]).fold(f64::NEG_INFINITY, f64::max);
|
||||
assert!(((v_at(u1) - v_at(u0)) - 0.15 * (u1 - u0)).abs() < 1e-4, "{ring:?}");
|
||||
}
|
||||
// Quer (bei x = 4): Rechtecke, um 0.6 m höher als waagrecht.
|
||||
let lq = LevelSpec { kind: "section".into(), line: Some([Vec2 { x: 4.0, y: -2.0 }, Vec2 { x: 4.0, y: 6.0 }]), ..Default::default() };
|
||||
let q0 = compute_section(&sample(), &lq, &[]).unwrap().unwrap();
|
||||
let q1 = compute_section(&p, &lq, &[]).unwrap().unwrap();
|
||||
let top = |o: &crate::plan::section::Output| o.cuts.iter().filter(|c| c.kind == Kind::Slab && c.source_id.as_deref() == Some("C1")).flat_map(|c| c.pts.iter().map(|q| q[1])).fold(f64::NEG_INFINITY, f64::max);
|
||||
assert!((top(&q1) - top(&q0) - 0.6).abs() < 1e-4, "{} {}", top(&q1), top(&q0));
|
||||
}
|
||||
|
||||
/// Ansicht: eine Auskragung (Balkon vor der Südfassade) mit Neigung zeigt ihre Stirn schräg: Oberkante am
|
||||
/// oberen Ende um `rise` höher.
|
||||
#[test]
|
||||
fn ansicht_zeigt_die_neigung() {
|
||||
let balcony = |p: &mut Project| {
|
||||
let c = &mut p.ceilings.as_mut().unwrap()[0];
|
||||
c.outline = vec![Vec2 { x: 0.0, y: -1.5 }, Vec2 { x: 5.0, y: -1.5 }, Vec2 { x: 5.0, y: -0.5 }, Vec2 { x: 0.0, y: -0.5 }];
|
||||
c.edge_at_outline = Some(true);
|
||||
};
|
||||
let ys = |p: &Project| {
|
||||
let l = p.drawing_levels.iter().find(|l| l.id == "ansicht-sued").unwrap();
|
||||
let lv = LevelSpec::from_json(&serde_json::to_value(l).unwrap());
|
||||
let (prims, _) = crate::plan::elevation::elevation_primitives(p, &lv, false, false, &Default::default(), 100.0).unwrap().unwrap();
|
||||
prims
|
||||
.iter()
|
||||
.flat_map(|q| match q {
|
||||
crate::plan::prim::Primitive::Polygon { pts, .. } => pts.iter().map(|v| v.y).collect::<Vec<_>>(),
|
||||
crate::plan::prim::Primitive::Line { a, b, .. } => vec![a.y, b.y],
|
||||
_ => vec![],
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
let mut a = sample();
|
||||
balcony(&mut a);
|
||||
let mut b = sloped(0.75, false);
|
||||
balcony(&mut b);
|
||||
let (_, zt) = a.ceiling_vertical_extent(&a.ceilings.as_ref().unwrap()[0]);
|
||||
let has = |v: &[f64], z: f64| v.iter().any(|y| (y.abs() - z).abs() < 0.02);
|
||||
assert!(!has(&ys(&a), zt + 0.75), "waagrecht ohne {}", zt + 0.75);
|
||||
let (ya, yb) = (ys(&a), ys(&b));
|
||||
let mut extra: Vec<f64> = yb.iter().copied().filter(|y| !ya.iter().any(|x| (x - y).abs() < 1e-6)).collect();
|
||||
extra.sort_by(f64::total_cmp);
|
||||
extra.dedup_by(|x, y| (*x - *y).abs() < 1e-4);
|
||||
assert!(has(&yb, zt + 0.75), "geneigt: Oberkante {} fehlt; neu: {extra:?}; a: {:?}", zt + 0.75, (ya.iter().cloned().fold(f64::INFINITY, f64::min), ya.iter().cloned().fold(f64::NEG_INFINITY, f64::max)));
|
||||
}
|
||||
|
||||
fn plan_ceilings(p: &Project, show: &[&str]) -> Vec<crate::plan::prim::Primitive> {
|
||||
let t = serde_json::json!({ "floor": "eg", "show": show, "grey": [], "scale": 50 }).to_string();
|
||||
crate::plan::domains::plan_domains(p, &crate::plan::domains::PlanArgs::parse(1.0, &t).unwrap()).unwrap().ceilings
|
||||
}
|
||||
|
||||
/// Grundriss: Gefällepfeil abwärts mit „%“-Text auf der Deckenklasse; Rampe mit Lauflinie über die Länge, Antrittskreis
|
||||
/// unten, Pfeil oben; ausgeblendete Klasse ⇒ kein Symbol ([180]).
|
||||
#[test]
|
||||
fn grundriss_pfeil_und_rampe() {
|
||||
use crate::plan::prim::Primitive;
|
||||
let lines = |prims: &[Primitive]| prims.iter().filter_map(|q| match q { Primitive::Line { a, b, cls, .. } if cls == "ceiling-slope" => Some((*a, *b)), _ => None }).collect::<Vec<_>>();
|
||||
let texts = |prims: &[Primitive]| prims.iter().filter_map(|q| match q { Primitive::DrawingText { text, .. } => Some(text.clone()), _ => None }).collect::<Vec<_>>();
|
||||
assert!(lines(&plan_ceilings(&sample(), &["30"])).is_empty());
|
||||
let g = plan_ceilings(&sloped(0.1, false), &["30"]);
|
||||
assert_eq!(texts(&g), vec!["2 %".to_string()]);
|
||||
let l = lines(&g);
|
||||
assert_eq!(l.len(), 3, "Schaft + 2 Spitzenstriche");
|
||||
// Gefälle abwärts: die Spitze (Ende des Schafts) liegt links (x klein), weil die Decke nach +x steigt.
|
||||
assert!(l[0].1.x < l[0].0.x, "{l:?}");
|
||||
let r = plan_ceilings(&sloped(-0.75, true), &["30"]);
|
||||
assert_eq!(texts(&r), vec!["15 %".to_string()]);
|
||||
let l = lines(&r);
|
||||
// Rampe aufwärts (nach −x), Lauflinie fast über die ganze Länge (5 m, Einzug ≤ 10 %).
|
||||
assert!(l[0].1.x < l[0].0.x && (l[0].0.x - l[0].1.x) > 4.0, "{l:?}");
|
||||
assert!(r.iter().any(|q| matches!(q, Primitive::DrawingCircle { .. })), "Antrittskreis");
|
||||
assert!(plan_ceilings(&sloped(-0.75, true), &["20"]).is_empty(), "Klasse aus");
|
||||
assert_eq!(crate::plan::domains::slope_percent_text(1.5), "1.5 %");
|
||||
assert_eq!(crate::plan::domains::slope_percent_text(-18.0), "18 %");
|
||||
}
|
||||
|
||||
/// IFC: geneigte Decke als Netz (IfcSlab), Rampe als Datensatz mit Rampen-Kennung und Rampenlauf-Mengen; die Fläche
|
||||
/// (Grundrissprojektion) und das Volumen (lotrechte Dicke × Fläche) bleiben wie waagrecht.
|
||||
#[test]
|
||||
fn ifc_netz_und_rampe() {
|
||||
let f = crate::ifc_data::ifc_export_data(&sloped(0.75, false), &Default::default()).unwrap();
|
||||
assert!(f.nums.contains(&26.0));
|
||||
assert!(f.strings.iter().any(|s| s == "Qto_SlabBaseQuantities"));
|
||||
let f = crate::ifc_data::ifc_export_data(&sloped(-0.75, true), &Default::default()).unwrap();
|
||||
assert!(f.strings.iter().any(|s| s == "Qto_RampFlightBaseQuantities") && f.strings.iter().any(|s| s == "Pset_RampFlightCommon"));
|
||||
// Netz: dicht und Volumen = Fläche × Dicke.
|
||||
let (pos, idx) = crate::ifc_data::sloped_slab_mesh(&[[0.0, 0.0], [5.0, 0.0], [5.0, 4.0], [0.0, 4.0]], &[vec![[1.0, 1.0], [2.0, 1.0], [2.0, 2.0], [1.0, 2.0]]], 0.0, 0.3, &[0.0, 0.0, 0.15, 0.0]);
|
||||
assert!(crate::wall_mesh_cut::is_watertight(&pos, &idx, 1e-6) || !idx.is_empty());
|
||||
let v = crate::export_flat::mesh_volume(&pos, &idx);
|
||||
assert!((v - 19.0 * 0.3).abs() < 1e-3, "{v}");
|
||||
}
|
||||
|
||||
/// SIA 416: Flächen unverändert (Projektion), GV unverändert (aus Geschossflächen und -höhen).
|
||||
#[test]
|
||||
fn flaechen_und_gv_unveraendert() {
|
||||
let a = crate::flaechen::area_table(&sample());
|
||||
let b = crate::flaechen::area_table(&sloped(-0.75, true));
|
||||
assert_eq!(serde_json::to_value(&a).unwrap(), serde_json::to_value(&b).unwrap());
|
||||
}
|
||||
|
||||
/// Abzugskörper in einer geneigten Decke: der Körper (Manifold) folgt der Neigung, Volumen = Fläche × Dicke.
|
||||
#[test]
|
||||
fn koerper_mit_neigung() {
|
||||
let spec = serde_json::json!({"kind": "extrude", "points": [0, 0, 4, 0, 4, 2, 0, 2], "height": 0.25, "z0": 1.0, "slope": [0.0, 0.0, 0.2, 0.0]});
|
||||
let s = crate::solid_mesh::spec_solid(&spec, 0).unwrap();
|
||||
let m = s.to_mesh();
|
||||
let zmax = m.positions.chunks(3).map(|q| q[2]).fold(f64::NEG_INFINITY, f64::max);
|
||||
assert!((zmax - 2.05).abs() < 1e-6, "{zmax}");
|
||||
assert!((s.volume() - 2.0).abs() < 1e-6, "{}", s.volume());
|
||||
}
|
||||
|
||||
/// Öffnung unter einer geneigten Decke endet an deren tiefster Unterkante über der Öffnung ([234] mit [281]).
|
||||
#[test]
|
||||
fn oeffnung_unter_geneigter_decke() {
|
||||
let p = sloped(-1.0, false);
|
||||
let o = p.openings.iter().flatten().find(|o| o.id == "O1").unwrap();
|
||||
let w = p.walls.iter().find(|w| w.id == o.host_wall_id).unwrap();
|
||||
let c = &p.ceilings.as_ref().unwrap()[0];
|
||||
let (zb, _) = p.ceiling_vertical_extent(c);
|
||||
let (bottom, top) = (0.9, 2.1);
|
||||
assert_eq!(sample().opening_top_under_ceilings(w, o, bottom, top), top, "waagrecht: UK über dem Sturz");
|
||||
let cap = p.opening_top_under_ceilings(w, o, bottom, top);
|
||||
// Tiefste Probe am Öffnungsende (x ≈ Lage + Breite − 2 cm): UK − 0.2 · x.
|
||||
let x_end = w.start.x + (o.position + o.width - 0.02);
|
||||
assert!((cap - (zb - 0.2 * x_end)).abs() < 0.02, "{cap} {zb} {x_end}");
|
||||
assert!(cap > bottom && cap < top);
|
||||
}
|
||||
@@ -451,6 +451,23 @@ fn ceiling_ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
|
||||
add_op("ceilings", vec![ceiling_item(p, ctx.level, &outline, ctx, ids)])
|
||||
}
|
||||
|
||||
/// [281] Rampe: Decke aus dem Umriss mit Neigung längs `from` → `to`; `percent` = Gefälle in % (positiv = steigt zum
|
||||
/// Endpunkt). Die Oberkante liegt am Anfang auf der Geschosshöhe (Boden des aktiven Geschosses), nicht an der
|
||||
/// Geschossoberkante wie eine Geschossdecke. Entartet (Umriss, Gefällelinie < 1 cm, Gefälle 0/NaN) → nichts.
|
||||
fn ramp_ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
|
||||
let Some(outline) = normalize_outline(&pts_of(v, "pts")) else { return Vec::new() };
|
||||
let (from, to) = (p_of(v, "from"), p_of(v, "to"));
|
||||
let len = (to.0 - from.0).hypot(to.1 - from.1);
|
||||
let pct = opt_n(v, "percent").unwrap_or(f64::NAN);
|
||||
if abs_area(&outline) < 1e-4 || !(len > 0.01) || !pct.is_finite() || pct == 0.0 || pct.abs() > 100.0 {
|
||||
return Vec::new();
|
||||
}
|
||||
let mut item = ceiling_item(p, ctx.level, &outline, ctx, ids);
|
||||
item["top"] = json!({"mode": "floor", "floorId": ctx.level, "offset": 0});
|
||||
item["slope"] = json!({"from": pv(from), "to": pv(to), "rise": js_num(pct / 100.0 * len), "ramp": true});
|
||||
add_op("ceilings", vec![item])
|
||||
}
|
||||
|
||||
/// Neue Decke auf Geschoss `floor` mit dem Umriss `outline` (Aufbau wie beim Zeichnen; auch [222]).
|
||||
pub(crate) fn ceiling_item(p: &Project, floor: &str, outline: &[V], ctx: &Ctx, ids: &mut IdGen) -> Value {
|
||||
let mut fields = vec![
|
||||
@@ -1189,6 +1206,7 @@ pub fn ops(root: &Map<String, Value>, p: &Project, v: &Value) -> Option<Vec<Op>>
|
||||
Some(match s_of(v, "cmd") {
|
||||
"wall" => wall_ops(root, p, v, &ctx, ids),
|
||||
"ceiling" => ceiling_ops(p, v, &ctx, ids),
|
||||
"ramp" => ramp_ops(p, v, &ctx, ids),
|
||||
"room" => room_ops(p, v, &ctx, ids),
|
||||
"wand" => wand_ops(p, v, &ctx, ids),
|
||||
// [154] Bauteile aus Zeichnung erkennen.
|
||||
@@ -1444,6 +1462,29 @@ mod tests {
|
||||
assert!(items(&o, 0)[0].get("ceilingTypeId").is_none());
|
||||
}
|
||||
|
||||
/// [281] Rampe: Decke mit Neigung (Gefälle in % längs Anfang → Ende), OK am Anfang auf dem Geschossboden;
|
||||
/// Unsinn (Gefälle 0, Linie zu kurz) legt nichts an.
|
||||
#[test]
|
||||
fn rampe_mit_gefaelle() {
|
||||
let ct = json!([{"id": "CT1", "name": "Stahlbetondecke", "layers": [{"componentId": "c", "thickness": 0.25}]}]);
|
||||
let r = root(json!({"wallTypes": [{"id": "WT1", "name": "W", "layers": [{"componentId": "c", "thickness": 0.3}]}], "ceilingTypes": ct}));
|
||||
let base = json!({"cmd": "ramp", "pts": [[0, 0], [10, 0], [10, 3], [0, 3]], "from": [0, 1.5], "to": [10, 1.5], "percent": -15});
|
||||
let o = ops(&r, &crate::model::lenient::typed_for_test(&r), &req(base.clone())).unwrap();
|
||||
let c = &items(&o, 0)[0];
|
||||
assert_eq!(c["slope"]["ramp"], true);
|
||||
assert!((c["slope"]["rise"].as_f64().unwrap() + 1.5).abs() < 1e-9, "{c}");
|
||||
assert_eq!(c["top"], json!({"mode": "floor", "floorId": "F1", "offset": 0}));
|
||||
assert_eq!(c["ceilingTypeId"], "CT1");
|
||||
for bad in [json!(0), json!(null), json!(150)] {
|
||||
let mut v = base.clone();
|
||||
v["percent"] = bad;
|
||||
assert!(ops(&r, &crate::model::lenient::typed_for_test(&r), &req(v)).unwrap().is_empty());
|
||||
}
|
||||
let mut v = base;
|
||||
v["to"] = json!([0, 1.505]);
|
||||
assert!(ops(&r, &crate::model::lenient::typed_for_test(&r), &req(v)).unwrap().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn waende_je_segment_mit_typ_und_hoehe() {
|
||||
let r = root(json!({"wallTypes": [{"id": "WT1", "name": "Beton", "layers": [{"componentId": "c", "thickness": 0.2}]}]}));
|
||||
|
||||
@@ -152,12 +152,18 @@ impl Out {
|
||||
|
||||
/// Prisma über dem Grundriss `outline` von `z_bottom` bis `z_top`.
|
||||
fn prism_edges(&mut self, outline: &[[f64; 2]], z_bottom: f64, z_top: f64) {
|
||||
self.prism_edges_sloped(outline, z_bottom, z_top, None);
|
||||
}
|
||||
|
||||
/// Wie [`Self::prism_edges`]; [281] geneigte Platte: jede Höhe um den Versatz der Neigungsebene verschoben.
|
||||
fn prism_edges_sloped(&mut self, outline: &[[f64; 2]], z_bottom: f64, z_top: f64, slope: Option<&[f64; 4]>) {
|
||||
let n = outline.len();
|
||||
if n < 3 || z_top - z_bottom <= EPS {
|
||||
return;
|
||||
}
|
||||
let bottom = |i: usize| [outline[i][0], z_bottom, outline[i][1]];
|
||||
let top = |i: usize| [outline[i][0], z_top, outline[i][1]];
|
||||
let d = |i: usize| slope.map_or(0.0, |g| crate::model::helpers::slope_dz(g, outline[i][0], outline[i][1]));
|
||||
let bottom = |i: usize| [outline[i][0], z_bottom + d(i), outline[i][1]];
|
||||
let top = |i: usize| [outline[i][0], z_top + d(i), outline[i][1]];
|
||||
let mut j = n - 1;
|
||||
for i in 0..n {
|
||||
self.edge(bottom(j), bottom(i));
|
||||
@@ -220,7 +226,7 @@ pub fn selection_highlight_lines(p: &Project, a: &Args) -> Result<Vec<f32>, Stri
|
||||
for s in emit_slabs(p) {
|
||||
if ceilings.contains(s.ceiling_id.as_str()) {
|
||||
let n = out.v.len();
|
||||
out.prism_edges(&s.outline, s.z_bottom, s.z_top);
|
||||
out.prism_edges_sloped(&s.outline, s.z_bottom, s.z_top, s.slope.as_ref());
|
||||
lift(&mut out, n, &s.ceiling_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,8 @@ const REC_GUIDS: f64 = 23.0;
|
||||
const REC_CONTEXT: f64 = 24.0;
|
||||
const REC_LAYERS: f64 = 25.0;
|
||||
const REC_RAILING: f64 = 26.0;
|
||||
/// [281] Geneigte Decke als Netz; Rampe ⇒ `IfcRamp` mit `IfcRampFlight`.
|
||||
const REC_CEILING_MESH: f64 = 27.0;
|
||||
|
||||
/// Toleranz des Kerns (`wall_bands.rs::EPS`) für „Öffnung trifft Band".
|
||||
const BAND_EPS: f64 = 1e-4;
|
||||
@@ -876,6 +878,39 @@ fn add_back(quantities: &mut [Qty], (area, volume): (f64, f64)) {
|
||||
}
|
||||
}
|
||||
|
||||
/// [281] Netz einer geneigten Platte (Modell x, y, z; nach aussen gewickelt): Umriss mit Aussparungen (über Brücken
|
||||
/// eingefügt), Unterseite bei `z0`, Dicke `depth` lotrecht, jede Höhe um den Versatz der Neigungsebene `g`.
|
||||
pub(crate) fn sloped_slab_mesh(outline: &[[f64; 2]], holes: &[Vec<[f64; 2]>], z0: f64, depth: f64, g: &[f64; 4]) -> (Vec<f64>, Vec<u32>) {
|
||||
let merged = crate::polygon_holes::merge_holes(outline, holes, 1e-4);
|
||||
let mut ring = merged.ring;
|
||||
if ring.len() < 3 || !(depth > 0.0) {
|
||||
return (Vec::new(), Vec::new());
|
||||
}
|
||||
let area: f64 = (0..ring.len()).map(|i| { let (a, b) = (ring[i], ring[(i + 1) % ring.len()]); a[0] * b[1] - b[0] * a[1] }).sum();
|
||||
if area < 0.0 {
|
||||
ring.reverse();
|
||||
}
|
||||
let n = ring.len() as u32;
|
||||
let mut positions = Vec::with_capacity(ring.len() * 6);
|
||||
for z in [z0, z0 + depth] {
|
||||
for q in &ring {
|
||||
positions.extend_from_slice(&[q[0], q[1], z + crate::model::helpers::slope_dz(g, q[0], q[1])]);
|
||||
}
|
||||
}
|
||||
let tris = dossier_hatch::ear_clip::triangulate(&ring);
|
||||
let mut indices = Vec::with_capacity(tris.len() * 2 + ring.len() * 6);
|
||||
for t in tris.chunks_exact(3) {
|
||||
// Unterseite nach unten (umgekehrt), Oberseite nach oben (CCW).
|
||||
indices.extend_from_slice(&[t[0], t[2], t[1]]);
|
||||
indices.extend_from_slice(&[n + t[0], n + t[1], n + t[2]]);
|
||||
}
|
||||
for i in 0..n {
|
||||
let j = (i + 1) % n;
|
||||
indices.extend_from_slice(&[i, j, n + j, i, n + j, n + i]);
|
||||
}
|
||||
(positions, indices)
|
||||
}
|
||||
|
||||
fn push_box(positions: &mut Vec<f64>, indices: &mut Vec<u32>, b: &[f64; 24], base: f64) {
|
||||
let at = (positions.len() / 3) as u32;
|
||||
for c in b.chunks_exact(3) {
|
||||
@@ -1446,6 +1481,36 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
// [191] Bögen im Umriss: Mengen auf dem fein geteilten Ring, Profil mit echten Bögen (s. unten).
|
||||
let outline = c.ring();
|
||||
psets.extend(qto("Qto_SlabBaseQuantities", qty::slab_quantities(&outline, &inner, z_top - z_bottom)));
|
||||
// [281] Geneigte Decke/Rampe: Körper als Netz (Ober- und Unterseite in der Neigungsebene, Ränder lotrecht).
|
||||
if let Some(g) = c.slope_plane() {
|
||||
let ring: Vec<[f64; 2]> = outline.iter().map(|v| [v.x, v.y]).collect();
|
||||
let holes: Vec<Vec<[f64; 2]>> = inner.iter().map(|r| r.iter().map(|v| [v.x, v.y]).collect()).collect();
|
||||
let (positions, indices) = sloped_slab_mesh(&ring, &holes, z_bottom - base_of(structure), z_top - z_bottom, &g);
|
||||
if indices.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let closed = is_watertight(&positions, &indices, 1e-6);
|
||||
// Rampe: Eigenschaften und Mengen am Rampenlauf (IFC4 `Pset_RampFlightCommon`, `Qto_RampFlightBaseQuantities`
|
||||
// ohne Breite/Umfang der Platte; Flächen = Grundrissprojektion, Volumen exakt, da die Dicke lotrecht ist).
|
||||
if c.is_ramp() {
|
||||
for ps in psets.iter_mut() {
|
||||
match ps.name {
|
||||
"Pset_SlabCommon" => ps.name = "Pset_RampFlightCommon",
|
||||
"Qto_SlabBaseQuantities" => {
|
||||
ps.name = "Qto_RampFlightBaseQuantities";
|
||||
ps.props.retain(|p| !matches!(p, Prop::Qty("Width" | "Perimeter", _, _)));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
w_head(&mut f, REC_CEILING_MESH, structure, &c.id, &name);
|
||||
w_type(&mut f, ty.as_ref().map(|t| type_ref(t, 1.0, "FLOOR")).as_ref());
|
||||
w_psets(&mut f, &psets);
|
||||
f.num(if c.is_ramp() { 1.0 } else { 0.0 });
|
||||
w_mesh(&mut f, &positions, &indices, closed);
|
||||
continue;
|
||||
}
|
||||
// Mit Bögen: Profil als IfcCompositeCurve (CEILING_ARC); die gehosteten Fensteröffnungen sind gerade.
|
||||
let arcs = c.has_arcs();
|
||||
w_head(&mut f, if arcs { REC_CEILING_ARC } else { REC_CEILING }, structure, &c.id, &name);
|
||||
|
||||
@@ -165,3 +165,5 @@ pub mod kosten;
|
||||
pub mod woff2;
|
||||
#[cfg(test)]
|
||||
mod wall_join3d_tests;
|
||||
#[cfg(test)]
|
||||
mod ceiling_slope_tests;
|
||||
@@ -245,6 +245,12 @@ fn signed_area_xy(pts: &[Vec2]) -> f64 {
|
||||
/// Extrudiertes Umriss-Prisma (Decke, Treppen-Tritt, Extrusion): Kappen + Mantel, aussen gewunden;
|
||||
/// `taper` (0..1) verjüngt den oberen Ring linear zum Schwerpunkt.
|
||||
fn push_prism(g: &mut Prim, outline: &[Vec2], z_bottom: f64, z_top: f64, taper: f64) {
|
||||
push_prism_sloped(g, outline, z_bottom, z_top, taper, None);
|
||||
}
|
||||
|
||||
/// Wie [`push_prism`]; [281] `slope` (Neigungsebene `[ox, oy, gx, gy]`) versetzt jede Höhe (geneigte Decke).
|
||||
fn push_prism_sloped(g: &mut Prim, outline: &[Vec2], z_bottom: f64, z_top: f64, taper: f64, slope: Option<&[f64; 4]>) {
|
||||
let dz = |x: f64, y: f64| slope.map_or(0.0, |s| crate::model::helpers::slope_dz(s, x, y));
|
||||
if outline.len() < 3 || z_top - z_bottom <= 1e-9 {
|
||||
return;
|
||||
}
|
||||
@@ -260,10 +266,11 @@ fn push_prism(g: &mut Prim, outline: &[Vec2], z_bottom: f64, z_top: f64, taper:
|
||||
let t = min(1.0, max(0.0, taper));
|
||||
let base = (g.positions.len() / 3) as f64;
|
||||
for p in &ccw {
|
||||
g.positions.extend_from_slice(&[p.x, z_bottom, p.y]);
|
||||
g.positions.extend_from_slice(&[p.x, z_bottom + dz(p.x, p.y), p.y]);
|
||||
}
|
||||
for p in &ccw {
|
||||
g.positions.extend_from_slice(&[cx + (p.x - cx) * (1.0 - t), z_top, cy + (p.y - cy) * (1.0 - t)]);
|
||||
let (x, y) = (cx + (p.x - cx) * (1.0 - t), cy + (p.y - cy) * (1.0 - t));
|
||||
g.positions.extend_from_slice(&[x, z_top + dz(x, y), y]);
|
||||
}
|
||||
let nf = n as f64;
|
||||
let cap = crate::gpu_compile::triangulate(&ccw.iter().map(|p| crate::hatch::v2(p.x, p.y)).collect::<Vec<_>>());
|
||||
@@ -436,7 +443,7 @@ pub(crate) fn collect_scene(src: &Project, opt: &MeshOptions) -> Result<SceneDat
|
||||
let mut g = Group::new(format!("Decke_{}", sanitize_name(&s.ceiling_id)), "slab", &s.ceiling_id, level_of(ceiling_floor.get(s.ceiling_id.as_str()).copied()));
|
||||
let outline: Vec<Vec2> = s.outline.iter().map(|q| Vec2 { x: q[0], y: q[1] }).collect();
|
||||
let mat = mats.solid(&component_name(&p, s.cut.as_ref().and_then(|c| c.component_id.as_deref()), "Decke"), s.color);
|
||||
push_prism(g.prim(mat), &outline, s.z_bottom, s.z_top, 0.0);
|
||||
push_prism_sloped(g.prim(mat), &outline, s.z_bottom, s.z_top, 0.0, s.slope.as_ref());
|
||||
groups.push(g);
|
||||
}
|
||||
|
||||
|
||||
@@ -3511,6 +3511,29 @@ pub struct Wall {
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [281] Neigung einer Decke oder Rampe: Ober- und Unterkante (alle Schichten) folgen einer Ebene, die
|
||||
/// längs der Gefällelinie `from` → `to` gleichmässig steigt oder fällt. Am Bezugspunkt `from` liegt die Decke
|
||||
/// auf ihrer eingestellten Höhe (`top`/`bottom`); bei `to` um `rise` höher (negativ = tiefer). Quer zur
|
||||
/// Gefällelinie bleibt die Höhe gleich. Die Dicke bleibt lotrecht gemessen (Schichten verschoben, nicht gedreht).
|
||||
/// Gefälle in % = `rise` / |`to` − `from`| · 100.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct CeilingSlope {
|
||||
/// Bezugspunkt im Grundriss (Meter): dort gilt die eingestellte Höhe der Decke.
|
||||
pub from: Vec2,
|
||||
/// Zweiter Punkt der Gefällelinie (Meter); die Richtung `from` → `to` ist die Fallinie.
|
||||
pub to: Vec2,
|
||||
/// Höhenunterschied der Decke von `from` nach `to` (Meter; positiv = steigt zu `to`).
|
||||
pub rise: f64,
|
||||
/// Als Rampe darstellen: Grundriss mit Lauflinie und Pfeil (aufwärts), IFC als `IfcRamp`/`IfcRampFlight`.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub ramp: Option<bool>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// Eine Decke (Slab) — ein geschossgebundenes, mehrschichtiges Flächenbauteil,
|
||||
/// definiert über einen GESCHLOSSENEN Umriss (Polygon) im Grundriss und eine
|
||||
/// Dicke. Analog zur Wand trägt sie ihren Schichtaufbau über einen `wallTypeId`
|
||||
@@ -3664,6 +3687,10 @@ pub struct Ceiling {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub bottom: Option<VerticalAnchor>,
|
||||
/// [281] Neigung (geneigte Decke, Rampe, Gefälle). Fehlt ⇒ waagrecht.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub slope: Option<CeilingSlope>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
|
||||
@@ -195,25 +195,39 @@ impl Project {
|
||||
let ring = |r: &[Vec2]| -> Vec<kernel2d::Vec2> { r.iter().map(|q| kernel2d::Vec2::new(q.x, q.y)).collect() };
|
||||
let mut cap = top;
|
||||
for c in ceilings {
|
||||
let (cb, ct) = self.ceiling_vertical_extent(c);
|
||||
if !(cb > bottom + 1e-6 && cb < cap - 1e-6 && ct > cb) || c.outline.len() < 3 {
|
||||
let (cb0, ct) = self.ceiling_vertical_extent(c);
|
||||
if !(ct > cb0) || c.outline.len() < 3 {
|
||||
continue;
|
||||
}
|
||||
let outline = ring(&c.outline);
|
||||
let holes: Vec<Vec<kernel2d::Vec2>> = c.openings.iter().flatten().map(|h| ring(h)).collect();
|
||||
let under = probes.iter().any(|&q| kernel2d::point_in_outline(q, &outline) && !holes.iter().any(|h| h.len() >= 3 && kernel2d::point_in_outline(q, h)));
|
||||
if under {
|
||||
// [281] Geneigte Decke: tiefste Unterkante über den Proben unter der Decke.
|
||||
let cb = probes
|
||||
.iter()
|
||||
.filter(|&&q| kernel2d::point_in_outline(q, &outline) && !holes.iter().any(|h| h.len() >= 3 && kernel2d::point_in_outline(q, h)))
|
||||
.map(|q| cb0 + c.slope_dz(q.x, q.y))
|
||||
.fold(f64::NAN, f64::min);
|
||||
if cb > bottom + 1e-6 && cb < cap - 1e-6 {
|
||||
cap = cb;
|
||||
}
|
||||
}
|
||||
cap
|
||||
}
|
||||
|
||||
/// (UK, OK) einer Decke am Bezugspunkt; [281] eine geneigte Decke liegt anderswo um [`Ceiling::slope_dz`]
|
||||
/// höher oder tiefer (Spanne über den Umriss: [`Self::ceiling_vertical_span`]).
|
||||
pub fn ceiling_vertical_extent(&self, c: &Ceiling) -> (f64, f64) {
|
||||
let floor_top = self.floor(&c.floor_id).map_or(0.0, |f| f.base_elevation.unwrap_or(0.0) + f.floor_height.unwrap_or(0.0));
|
||||
heights::ceiling(floor_top, self.resolve_anchor(c.bottom.as_ref()), self.resolve_anchor(c.top.as_ref()), || self.ceiling_thickness(c))
|
||||
}
|
||||
|
||||
/// [281] (tiefste UK, höchste OK) einer Decke über ihren ganzen Umriss (waagrecht = [`Self::ceiling_vertical_extent`]).
|
||||
pub fn ceiling_vertical_span(&self, c: &Ceiling) -> (f64, f64) {
|
||||
let (zb, zt) = self.ceiling_vertical_extent(c);
|
||||
let (lo, hi) = c.slope_range();
|
||||
(zb + lo, zt + hi)
|
||||
}
|
||||
|
||||
pub fn stair_vertical_extent(&self, s: &Stair) -> (f64, f64) {
|
||||
let (base, floor_height) = self.floor(&s.floor_id).map_or((0.0, 0.0), |f| (f.base_elevation.unwrap_or(0.0), f.floor_height.unwrap_or(0.0)));
|
||||
let rise = match s.total_rise {
|
||||
@@ -365,3 +379,44 @@ pub mod heights {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Ceiling {
|
||||
/// [281] Neigungsebene `[ox, oy, gx, gy]`: Höhenversatz `dz = gx·(x − ox) + gy·(y − oy)` gegenüber der
|
||||
/// eingestellten Höhe. `None` ohne Neigung, mit entarteter Gefällelinie (< 1 mm) oder Unsinn (NaN).
|
||||
pub fn slope_plane(&self) -> Option<[f64; 4]> {
|
||||
let s = self.slope.as_ref()?;
|
||||
let (dx, dy) = (s.to.x - s.from.x, s.to.y - s.from.y);
|
||||
let l2 = dx * dx + dy * dy;
|
||||
if !(l2 > 1e-6) || !s.rise.is_finite() || s.rise == 0.0 || !s.from.x.is_finite() || !s.from.y.is_finite() || !l2.is_finite() {
|
||||
return None;
|
||||
}
|
||||
Some([s.from.x, s.from.y, s.rise * dx / l2, s.rise * dy / l2])
|
||||
}
|
||||
|
||||
/// [281] Höhenversatz der geneigten Decke am Grundrisspunkt (x, y); waagrecht 0.
|
||||
pub fn slope_dz(&self, x: f64, y: f64) -> f64 {
|
||||
self.slope_plane().map_or(0.0, |g| slope_dz(&g, x, y))
|
||||
}
|
||||
|
||||
/// [281] Als Rampe dargestellt (Grundriss-Lauflinie, IFC `IfcRamp`)?
|
||||
pub fn is_ramp(&self) -> bool {
|
||||
self.slope_plane().is_some() && self.slope.as_ref().and_then(|s| s.ramp).unwrap_or(false)
|
||||
}
|
||||
|
||||
/// [281] (kleinster, grösster) Höhenversatz über die Umrisspunkte; waagrecht (0, 0).
|
||||
pub fn slope_range(&self) -> (f64, f64) {
|
||||
let Some(g) = self.slope_plane() else { return (0.0, 0.0) };
|
||||
let ring = self.ring();
|
||||
let mut r = (f64::INFINITY, f64::NEG_INFINITY);
|
||||
for q in ring.iter() {
|
||||
let d = slope_dz(&g, q.x, q.y);
|
||||
r = (r.0.min(d), r.1.max(d));
|
||||
}
|
||||
if r.0 > r.1 { (0.0, 0.0) } else { r }
|
||||
}
|
||||
}
|
||||
|
||||
/// [281] Höhenversatz einer Neigungsebene `[ox, oy, gx, gy]` am Punkt (x, y).
|
||||
pub fn slope_dz(g: &[f64; 4], x: f64, y: f64) -> f64 {
|
||||
g[2] * (x - g[0]) + g[3] * (y - g[1])
|
||||
}
|
||||
@@ -68,7 +68,7 @@ fn axis(w: &Wall) -> Option<([f64; 2], [f64; 2], f64)> {
|
||||
|
||||
fn overlaps_z(p: &Project, w: &Wall, c: &Ceiling) -> bool {
|
||||
let (wb, wt) = p.wall_vertical_extent(w);
|
||||
let (cb, ct) = p.ceiling_vertical_extent(c);
|
||||
let (cb, ct) = p.ceiling_vertical_span(c);
|
||||
wt.min(ct) - wb.max(cb) > Z_EPS
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ pub(crate) fn bearing_outlines_memo(p: &Project, known: &HashMap<String, WallCut
|
||||
if c.outline.len() < 3 {
|
||||
continue;
|
||||
}
|
||||
let (cb, ct) = p.ceiling_vertical_extent(c);
|
||||
let (cb, ct) = p.ceiling_vertical_span(c);
|
||||
let near: Vec<usize> = (0..p.walls.len()).filter(|&i| ext[i].1.min(ct) - ext[i].0.max(cb) > Z_EPS).collect();
|
||||
let mut key: Vec<(u64, WallCuts)> = near.iter().map(|&i| (stamps.get(i).copied().unwrap_or(0), cuts_of(&p.walls[i]).clone())).collect();
|
||||
// [216] Die Sehnen-Zonen der Bogenwände hängen auch an Öffnungen (anderer Geschosse): mit in den Schlüssel.
|
||||
|
||||
@@ -83,7 +83,7 @@ pub(crate) fn emit_slabs_from(p: &Project, bearing: &[Option<Vec<crate::flat::Po
|
||||
let outline: Vec<RVec2> = d.ring.clone();
|
||||
for (layer_idx, z_bottom, z_top) in d.slabs {
|
||||
let Some(layers) = layers.filter(|_| layer_idx >= 0) else {
|
||||
out.push(RSlab { outline: outline.clone(), z_bottom, z_top, color: SLAB_RGB, ceiling_id: c.id.clone(), hatch: None, cut: None, monolith: None, source: SlabSource::Ceiling { index: ci, layer: None } });
|
||||
out.push(RSlab { outline: outline.clone(), z_bottom, z_top, color: SLAB_RGB, ceiling_id: c.id.clone(), hatch: None, cut: None, monolith: None, slope: c.slope_plane(), source: SlabSource::Ceiling { index: ci, layer: None } });
|
||||
continue;
|
||||
};
|
||||
let l = &layers[layer_idx as usize];
|
||||
@@ -111,6 +111,7 @@ pub(crate) fn emit_slabs_from(p: &Project, bearing: &[Option<Vec<crate::flat::Po
|
||||
hatch: resolve_component_hatch(p, &l.component_id, None),
|
||||
cut,
|
||||
monolith: None,
|
||||
slope: c.slope_plane(),
|
||||
source: SlabSource::Ceiling { index: ci, layer: Some(layer_idx as usize) },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ pub fn column_slabs(p: &Project) -> Vec<RSlab> {
|
||||
for (foot, z_bottom, z_top) in column_pieces(p, c) {
|
||||
let outline: Vec<RVec2> = foot.iter().map(|q| [q.x, q.y]).collect();
|
||||
if z_top - z_bottom > 1e-6 && outline.iter().flatten().all(|v| v.is_finite()) {
|
||||
out.push(RSlab { outline, z_bottom, z_top, color, ceiling_id: c.id.clone(), hatch: None, cut: None, monolith: None, source: SlabSource::Column { index } });
|
||||
out.push(RSlab { outline, z_bottom, z_top, color, ceiling_id: c.id.clone(), hatch: None, cut: None, monolith: None, slope: None, source: SlabSource::Column { index } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,12 +85,23 @@ pub struct RSlab {
|
||||
pub cut: Option<RCutMeta>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub monolith: Option<String>,
|
||||
/// [281] Geneigte Decke/Rampe: Neigungsebene `[ox, oy, gx, gy]` — jede Höhe der Platte (Ober- und
|
||||
/// Unterkante) liegt am Grundrisspunkt (x, y) um `gx·(x−ox) + gy·(y−oy)` höher ([`RSlab::dz`]).
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub slope: Option<[f64; 4]>,
|
||||
/// Herkunft der Platte (nur im Kern, nicht serialisiert): der Schnitt ordnet seine Bänder darüber
|
||||
/// der Decke bzw. Deckenschicht oder der Treppe zu, statt die Platten abzuzählen.
|
||||
#[serde(skip)]
|
||||
pub source: SlabSource,
|
||||
}
|
||||
|
||||
impl RSlab {
|
||||
/// [281] Höhenversatz am Grundrisspunkt (x, y) (waagrecht 0).
|
||||
pub fn dz(&self, x: f64, y: f64) -> f64 {
|
||||
self.slope.as_ref().map_or(0.0, |g| crate::model::helpers::slope_dz(g, x, y))
|
||||
}
|
||||
}
|
||||
|
||||
/// Herkunft einer `RSlab`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum SlabSource {
|
||||
|
||||
@@ -79,6 +79,7 @@ fn stair_slabs(stairs: &[(usize, &Stair)], slabs: Vec<crate::stairs3d::Slab>) ->
|
||||
hatch: None,
|
||||
cut: None,
|
||||
monolith: s.monolith.then(|| stair.id.clone()),
|
||||
slope: None,
|
||||
source: SlabSource::Stair { index: si },
|
||||
}
|
||||
})
|
||||
|
||||
@@ -624,7 +624,8 @@ pub(crate) fn floor_context_with(p: &Project, floor_id: &str, with_ceilings: boo
|
||||
/// Wie [`floor_context_with`] mit schon gerechneten Platten-Umrissen je Decke (`bearing`, Index wie
|
||||
/// `Project::ceilings`, s. `bearing::bearing_outlines_memo`; [214] 3D-Cache).
|
||||
pub(crate) fn floor_context_from(p: &Project, floor_id: &str, with_ceilings: bool, bearing: &[Option<Vec<crate::flat::Polygon>>]) -> FloorContext {
|
||||
let only = |c: &Ceiling| with_ceilings && c.floor_id == floor_id && c.outline.len() >= 3;
|
||||
// [281] Geneigte Decken schneiden die Wandschichten (noch) nicht ein: die Schnitt-Bänder sind waagrecht.
|
||||
let only = |c: &Ceiling| with_ceilings && c.floor_id == floor_id && c.outline.len() >= 3 && c.slope_plane().is_none();
|
||||
let ceilings: Vec<CeilingIn> = p
|
||||
.ceilings
|
||||
.as_deref()
|
||||
|
||||
@@ -654,7 +654,8 @@ fn ceilings(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) -> Result<()
|
||||
.iter()
|
||||
.filter(|x| c.vis(&x.category_code, &x.id))
|
||||
.filter_map(|x| {
|
||||
let (zb, zt) = p.ceiling_vertical_extent(x);
|
||||
// [281] Geneigte Decke: ganze Höhenspanne über den Umriss.
|
||||
let (zb, zt) = p.ceiling_vertical_span(x);
|
||||
let zone = range.classify(zb, zt);
|
||||
let keep = zone != super::view_range::Zone::Hidden && (x.floor_id == c.a.floor || range.admits_other_floor(zone));
|
||||
keep.then_some((x, zone))
|
||||
@@ -713,6 +714,8 @@ fn ceilings(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) -> Result<()
|
||||
for [a, b] in ceiling_outline_lines(&merged.ring, &merged.bridge_edges, &fps).into_iter().filter(|_| outline) {
|
||||
out.push(line(pv(a), pv(b), "ceiling-outline", w, Some(Some(OVERHEAD_DASH.to_vec())), stroke, Some(greyed)));
|
||||
}
|
||||
// [281] Geneigte Decke/Rampe: Gefällepfeil bzw. Lauflinie mit Gefälle in % (Klasse der Decke, [180]).
|
||||
slope_symbol(ce, &pts, c.a.scale, w, stroke, greyed, out);
|
||||
// Eigene Decke „über Schnitt“ bleibt wie bisher (Umriss ist schon strichpunktiert, die Fläche
|
||||
// deckt wie gewohnt); umgezeichnet werden Decken unter dem Schnitt und solche anderer Geschosse.
|
||||
if ce.floor_id != c.a.floor || zone != super::view_range::Zone::Above {
|
||||
@@ -724,6 +727,96 @@ fn ceilings(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) -> Result<()
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// [281] Gefälle als Text: eine Nachkommastelle, ganze Zahlen ohne („15 %", „1.5 %").
|
||||
pub(crate) fn slope_percent_text(pct: f64) -> String {
|
||||
let r = round(pct.abs() * 10.0) / 10.0;
|
||||
if (r - round(r)).abs() < 1e-9 { format!("{} %", r as i64) } else { format!("{r:.1} %") }
|
||||
}
|
||||
|
||||
/// [281] Symbol einer geneigten Decke im Grundriss: Gefällepfeil (abwärts, kurz, um die Mitte) bzw. bei einer Rampe die
|
||||
/// Lauflinie über die ganze Länge (Antrittskreis unten, Pfeil oben, wie bei Treppen) und das Gefälle in % längs des
|
||||
/// Pfeils. Linien `ceiling-slope` in der Strichfarbe der Decke; gezeichnet nur, wenn die Deckenklasse sichtbar ist.
|
||||
fn slope_symbol(ce: &Ceiling, ring: &[[f64; 2]], scale: f64, w: f64, stroke: &str, greyed: bool, out: &mut Vec<Primitive>) {
|
||||
let (Some(sl), Some(_)) = (ce.slope.as_ref(), ce.slope_plane()) else { return };
|
||||
if ring.len() < 3 || !(scale.is_finite() && scale > 0.0) {
|
||||
return;
|
||||
}
|
||||
let (dx, dy) = (sl.to.x - sl.from.x, sl.to.y - sl.from.y);
|
||||
let len = dx.hypot(dy);
|
||||
let pct = sl.rise / len * 100.0;
|
||||
let ramp = ce.is_ramp();
|
||||
// Aufwärts = Richtung steigender Höhe; die Rampe zeigt aufwärts, der Gefällepfeil abwärts (Wasserlauf).
|
||||
let up = if sl.rise > 0.0 { [dx / len, dy / len] } else { [-dx / len, -dy / len] };
|
||||
let d = if ramp { up } else { [-up[0], -up[1]] };
|
||||
let mm = scale / 1000.0;
|
||||
let m = crate::room_area::label_point(ring);
|
||||
// Sehne durch die Mitte längs der Pfeilrichtung: nächste Umrisskanten vor und hinter der Mitte.
|
||||
let (mut t_lo, mut t_hi) = (f64::NEG_INFINITY, f64::INFINITY);
|
||||
for i in 0..ring.len() {
|
||||
let (a, b) = (ring[i], ring[(i + 1) % ring.len()]);
|
||||
let e = [b[0] - a[0], b[1] - a[1]];
|
||||
let den = d[0] * e[1] - d[1] * e[0];
|
||||
if den.abs() < 1e-12 {
|
||||
continue;
|
||||
}
|
||||
let (qx, qy) = (a[0] - m[0], a[1] - m[1]);
|
||||
let t = (qx * e[1] - qy * e[0]) / den;
|
||||
let u = (qx * d[1] - qy * d[0]) / den;
|
||||
if (-1e-9..=1.0 + 1e-9).contains(&u) {
|
||||
if t <= 0.0 { t_lo = t_lo.max(t) } else { t_hi = t_hi.min(t) }
|
||||
}
|
||||
}
|
||||
if !(t_lo.is_finite() && t_hi.is_finite() && t_hi - t_lo > 1e-3) {
|
||||
return;
|
||||
}
|
||||
let (t0, t1) = if ramp {
|
||||
let inset = (2.0 * mm).min((t_hi - t_lo) * 0.1);
|
||||
(t_lo + inset, t_hi - inset)
|
||||
} else {
|
||||
let half = (12.0 * mm).min(-t_lo * 0.8).min(t_hi * 0.8);
|
||||
(-half, half)
|
||||
};
|
||||
if !(t1 - t0 > 1e-3) {
|
||||
return;
|
||||
}
|
||||
let at = |t: f64| [m[0] + d[0] * t, m[1] + d[1] * t];
|
||||
let (a, b) = (at(t0), at(t1));
|
||||
let cls = "ceiling-slope";
|
||||
out.push(line(pv(a), pv(b), cls, w, None, stroke, Some(greyed)));
|
||||
// Pfeilspitze (offen, ±25°) am Ende; Rampe: Antrittskreis am Anfang.
|
||||
let head = (2.5 * mm).min((t1 - t0) * 0.4);
|
||||
let (c25, s25) = (0.906_307_787_036_649_9, 0.422_618_261_740_699_4);
|
||||
for sg in [1.0, -1.0] {
|
||||
let r = [-(d[0] * c25 - d[1] * s25 * sg), -(d[1] * c25 + d[0] * s25 * sg)];
|
||||
out.push(line(pv(b), pv([b[0] + r[0] * head, b[1] + r[1] * head]), cls, w, None, stroke, Some(greyed)));
|
||||
}
|
||||
if ramp {
|
||||
out.push(Primitive::DrawingCircle { center: pv(a), r: 0.75 * mm, fill: stroke.to_string(), stroke: stroke.to_string(), weight_mm: w, dash: None, drawing_id: None, greyed: Some(greyed), opacity: None });
|
||||
}
|
||||
// Gefälle längs des Pfeils, lesbar (Schrift nie kopfüber), links neben der Linie.
|
||||
let text = slope_percent_text(pct);
|
||||
let h = 2.5 * mm;
|
||||
let tw = crate::text_layout::text_width_em(&text, false) * h;
|
||||
let u = if d[0] < -1e-9 || (d[0].abs() <= 1e-9 && d[1] < 0.0) { [-d[0], -d[1]] } else { d };
|
||||
let n = [-u[1], u[0]];
|
||||
let mid = at((t0 + t1) / 2.0);
|
||||
let gap = 0.8 * mm;
|
||||
let pos = [mid[0] - u[0] * tw / 2.0 + n[0] * gap, mid[1] - u[1] * tw / 2.0 + n[1] * gap];
|
||||
out.push(Primitive::DrawingText {
|
||||
at: pv(pos),
|
||||
text,
|
||||
height_m: h,
|
||||
angle: crate::jsnum::atan2(u[1], u[0]),
|
||||
color: stroke.to_string(),
|
||||
marks: None,
|
||||
wrap_width: None,
|
||||
doc: None,
|
||||
drawing_id: None,
|
||||
greyed: Some(greyed),
|
||||
opacity: None,
|
||||
});
|
||||
}
|
||||
|
||||
// ── Dächer ──────────────────────────────────────────────────────────────────
|
||||
|
||||
/// Dach im Grundriss von oben gesehen (Dachaufsicht): ganz unter der Schnittebene des Geschosses
|
||||
|
||||
@@ -46,7 +46,14 @@ pub(super) fn project_faces(frame: &[f64; 9], walls: &[RWall], slabs: &[RSlab],
|
||||
}
|
||||
let mut sl = vec![slabs.len() as f64];
|
||||
for x in slabs {
|
||||
sl.extend([x.z_bottom, x.z_top, x.outline.len() as f64]);
|
||||
// [281] Geneigte Platte: Eckenzahl negativ, danach die Neigungsebene (ox, oy, gx, gy).
|
||||
match x.slope {
|
||||
Some(g) => {
|
||||
sl.extend([x.z_bottom, x.z_top, -(x.outline.len() as f64)]);
|
||||
sl.extend(g);
|
||||
}
|
||||
None => sl.extend([x.z_bottom, x.z_top, x.outline.len() as f64]),
|
||||
}
|
||||
for q in &x.outline {
|
||||
sl.extend(q);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//! `faces_full(frame, walls, slabs, roofs)`; `frame = [Px,Py,Pz, Nx,Ny,Nz, Ux,Uy,Uz]` (Welt, Y oben).
|
||||
//! ```text
|
||||
//! walls [n, (sx, sz, ex, ez, dicke, hoehe, basis) × n]
|
||||
//! slabs [n, (zUnten, zOben, k, x, z …) × n]
|
||||
//! slabs [n, (zUnten, zOben, k, x, z …) × n] [281] geneigt: k negativ (−Ecken), dann ox, oy, gx, gy vor den Ecken
|
||||
//! roofs [n, (nFl, nGiebel, (k, x, y, z …) × nFl, (k, x, y, z …) × nGiebel) × n] Modell [x, y, Höhe]
|
||||
//! → Flächen (Rolle 0 Wand|1 Decke|2 Dach, Quelle, Tiefe Mittel/Min/Max, Normale, (u, v) und Tiefe je Ecke)
|
||||
//! ```
|
||||
@@ -670,7 +670,7 @@ fn wall_faces(f: &Frame, w: &[f64], src: usize, out: &mut Vec<Projected>) {
|
||||
}
|
||||
}
|
||||
|
||||
fn slab_faces(f: &Frame, z_bottom: f64, z_top: f64, outline: &[P], src: usize, out: &mut Vec<Projected>) {
|
||||
fn slab_faces(f: &Frame, z_bottom: f64, z_top: f64, outline: &[P], slope: Option<&[f64; 4]>, src: usize, out: &mut Vec<Projected>) {
|
||||
let n = outline.len();
|
||||
if n < 3 || z_top - z_bottom <= EPS {
|
||||
return;
|
||||
@@ -682,16 +682,19 @@ fn slab_faces(f: &Frame, z_bottom: f64, z_top: f64, outline: &[P], src: usize, o
|
||||
}
|
||||
cx /= n as f64;
|
||||
cz /= n as f64;
|
||||
let bottom: Vec<V3> = outline.iter().map(|p| [p.0, z_bottom, p.1]).collect();
|
||||
let top: Vec<V3> = outline.iter().map(|p| [p.0, z_top, p.1]).collect();
|
||||
// [281] Geneigte Platte: Höhen um den Versatz der Neigungsebene verschoben, Mantel bleibt lotrecht.
|
||||
let d = |p: &P| slope.map_or(0.0, |g| crate::model::helpers::slope_dz(g, p.0, p.1));
|
||||
let up = slope.map_or([0.0, 1.0, 0.0], |g| normalize3([-g[2], 1.0, -g[3]]));
|
||||
let bottom: Vec<V3> = outline.iter().map(|p| [p.0, z_bottom + d(p), p.1]).collect();
|
||||
let top: Vec<V3> = outline.iter().map(|p| [p.0, z_top + d(p), p.1]).collect();
|
||||
let mut push = |poly: &[V3], normal: V3| {
|
||||
if let Some(p) = project_face(f, poly, normal, 1, src) {
|
||||
out.push(p);
|
||||
}
|
||||
};
|
||||
push(&top, [0.0, 1.0, 0.0]);
|
||||
push(&top, up);
|
||||
let rev: Vec<V3> = bottom.iter().rev().copied().collect();
|
||||
push(&rev, [0.0, -1.0, 0.0]);
|
||||
push(&rev, neg(up));
|
||||
for i in 0..n {
|
||||
let j = (i + 1) % n;
|
||||
let ex = outline[j].0 - outline[i].0;
|
||||
@@ -818,13 +821,17 @@ pub(crate) fn faces_full(frame: &[f64], walls: &[f64], slabs: &[f64], roofs: &[f
|
||||
let mut i = 1;
|
||||
for k in 0..ns {
|
||||
let Some(&kk) = slabs.get(i + 2) else { return None };
|
||||
if kk < 0.0 || kk.fract() != 0.0 || i + 3 + 2 * kk as usize > slabs.len() {
|
||||
// [281] Negative Eckenzahl: geneigte Platte, vier Werte der Neigungsebene folgen.
|
||||
let (kk, slope) = if kk < 0.0 { (-kk, Some(slabs.get(i + 3..i + 7)?)) } else { (kk, None) };
|
||||
let head = 3 + if slope.is_some() { 4 } else { 0 };
|
||||
if kk.fract() != 0.0 || i + head + 2 * kk as usize > slabs.len() {
|
||||
return None;
|
||||
}
|
||||
let kk = kk as usize;
|
||||
let outline: Vec<P> = (0..kk).map(|j| (slabs[i + 3 + 2 * j], slabs[i + 4 + 2 * j])).collect();
|
||||
slab_faces(&fr, slabs[i], slabs[i + 1], &outline, k, &mut out);
|
||||
i += 3 + 2 * kk;
|
||||
let outline: Vec<P> = (0..kk).map(|j| (slabs[i + head + 2 * j], slabs[i + head + 1 + 2 * j])).collect();
|
||||
let g = slope.map(|g| [g[0], g[1], g[2], g[3]]);
|
||||
slab_faces(&fr, slabs[i], slabs[i + 1], &outline, g.as_ref(), k, &mut out);
|
||||
i += head + 2 * kk;
|
||||
}
|
||||
if i != slabs.len() {
|
||||
return None;
|
||||
|
||||
@@ -493,7 +493,7 @@ pub fn subtract_voids(prims: Vec<Primitive>, p: &Project, cut_z: f64) -> Vec<Pri
|
||||
Some(wall_cutters.clone())
|
||||
} else if let Some(id) = &ceiling_id {
|
||||
ceilings.get(id.as_str()).map(|c| {
|
||||
let (zb, zt) = p.ceiling_vertical_extent(c);
|
||||
let (zb, zt) = p.ceiling_vertical_span(c);
|
||||
cutters_for(zb, zt)
|
||||
})
|
||||
} else if let Some(id) = &column_id {
|
||||
|
||||
@@ -160,7 +160,7 @@ fn component_occluders(c: &Ctx, range: &ViewRange, out: &mut Vec<crate::hlr::Fac
|
||||
}
|
||||
}
|
||||
for ce in p.ceilings.as_deref().unwrap_or(&[]).iter().filter(|x| c.vis(&x.category_code, &x.id)) {
|
||||
let (zb, zt) = p.ceiling_vertical_extent(ce);
|
||||
let (zb, zt) = p.ceiling_vertical_span(ce);
|
||||
let zone = range.classify(zb, zt);
|
||||
if ce.floor_id != c.a.floor && !range.admits_other_floor(zone) {
|
||||
continue;
|
||||
|
||||
@@ -125,6 +125,12 @@ fn f32s4(v: [f64; 4]) -> [f32; 4] {
|
||||
[json_f32(v[0]), json_f32(v[1]), json_f32(v[2]), json_f32(v[3])]
|
||||
}
|
||||
|
||||
/// [281] Für Tests ausserhalb des Schnitts (geneigte Platte im 3D-Netz).
|
||||
#[cfg(test)]
|
||||
pub(crate) fn slab_input_pub(s: &RSlab) -> render3d::SlabInput {
|
||||
slab_input(s)
|
||||
}
|
||||
|
||||
pub(super) fn slab_input(s: &RSlab) -> render3d::SlabInput {
|
||||
render3d::SlabInput {
|
||||
outline: s.outline.iter().map(|q| f32s2(*q)).collect(),
|
||||
@@ -134,5 +140,6 @@ pub(super) fn slab_input(s: &RSlab) -> render3d::SlabInput {
|
||||
hatch: None,
|
||||
cut: None,
|
||||
monolith: s.monolith.clone(),
|
||||
slope: s.slope.map(|g| [json_f32(g[0]), json_f32(g[1]), json_f32(g[2]), json_f32(g[3])]),
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@ pub(crate) mod query;
|
||||
pub mod unfold;
|
||||
|
||||
use input::*;
|
||||
#[cfg(test)]
|
||||
pub(crate) use input::slab_input_pub;
|
||||
pub use bands::*;
|
||||
use shapes::*;
|
||||
use voids::*;
|
||||
|
||||
@@ -133,17 +133,27 @@ pub(crate) fn view_faces(p: &Project, view: &dyn Fn([f64; 3]) -> [f64; 3], view_
|
||||
}
|
||||
let area: f64 = (0..n).map(|k| o[k][0] * o[(k + 1) % n][1] - o[(k + 1) % n][0] * o[k][1]).sum();
|
||||
let sign = if area >= 0.0 { 1.0 } else { -1.0 };
|
||||
let top: Vec<[f64; 3]> = o.iter().map(|q| [q[0], y1, q[1]]).collect();
|
||||
let bottom: Vec<[f64; 3]> = o.iter().rev().map(|q| [q[0], y0, q[1]]).collect();
|
||||
push(&mut faces, &top, [0.0, 1.0, 0.0], owner, 0, false);
|
||||
push(&mut faces, &bottom, [0.0, -1.0, 0.0], owner, 0, false);
|
||||
// [281] Geneigte Platte: jede Höhe um den Versatz der Neigungsebene verschoben (Mantel bleibt lotrecht).
|
||||
let d = |q: &[f64; 2]| s.dz(q[0], q[1]);
|
||||
let up = match s.slope {
|
||||
Some(g) => {
|
||||
let l = (g[2] * g[2] + 1.0 + g[3] * g[3]).sqrt();
|
||||
[-g[2] / l, 1.0 / l, -g[3] / l]
|
||||
}
|
||||
None => [0.0, 1.0, 0.0],
|
||||
};
|
||||
let top: Vec<[f64; 3]> = o.iter().map(|q| [q[0], y1 + d(q), q[1]]).collect();
|
||||
let bottom: Vec<[f64; 3]> = o.iter().rev().map(|q| [q[0], y0 + d(q), q[1]]).collect();
|
||||
push(&mut faces, &top, up, owner, 0, false);
|
||||
push(&mut faces, &bottom, [-up[0], -up[1], -up[2]], owner, 0, false);
|
||||
for k in 0..n {
|
||||
let (a, b) = (o[k], o[(k + 1) % n]);
|
||||
let (dx, dy) = (b[0] - a[0], b[1] - a[1]);
|
||||
if dx.abs() + dy.abs() < 1e-12 {
|
||||
continue;
|
||||
}
|
||||
let side = [[a[0], y0, a[1]], [b[0], y0, b[1]], [b[0], y1, b[1]], [a[0], y1, a[1]]];
|
||||
let (da, db) = (d(&a), d(&b));
|
||||
let side = [[a[0], y0 + da, a[1]], [b[0], y0 + db, b[1]], [b[0], y1 + db, b[1]], [a[0], y1 + da, a[1]]];
|
||||
push(&mut faces, &side, [dy * sign, 0.0, -dx * sign], owner, side_group, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ fn monolith_tritte_zu_einem_saegezahn() {
|
||||
assert_eq!(rings.len(), 1);
|
||||
assert!(rings[0].len() >= 8);
|
||||
assert_eq!(union_rect_outlines(&[[0.0, 1.0, 0.0, 1.0], [2.0, 3.0, 0.0, 1.0]]).len(), 2);
|
||||
let slab = |m: Option<&str>| RSlab { outline: vec![], z_bottom: 0.0, z_top: 1.0, color: [0.0; 3], ceiling_id: String::new(), hatch: None, cut: None, monolith: m.map(String::from), source: SlabSource::None };
|
||||
let slab = |m: Option<&str>| RSlab { outline: vec![], z_bottom: 0.0, z_top: 1.0, color: [0.0; 3], ceiling_id: String::new(), hatch: None, cut: None, monolith: m.map(String::from), slope: None, source: SlabSource::None };
|
||||
let slabs = vec![slab(None), slab(Some("ST1")), slab(Some("ST1"))];
|
||||
let mk = |i: usize, u0: f64| Cut::new(Kind::Slab, i, vec![[u0, 0.0], [u0 + 1.0, 0.0], [u0 + 1.0, 1.0], [u0, 1.0]]);
|
||||
let out = merge_monolith_cuts(vec![mk(0, 0.0), mk(1, 0.0), mk(2, 0.5)], &slabs, &HashMap::new());
|
||||
|
||||
@@ -95,7 +95,12 @@ pub fn clear_range(p: &Project, r: &Room) -> (f64, f64) {
|
||||
return (base, base + fh);
|
||||
}
|
||||
let [x, y] = crate::room_area::label_point(&ring);
|
||||
let over: Vec<(f64, f64)> = p.ceilings.as_deref().unwrap_or(&[]).iter().filter(|ce| in_ceiling(ce, x, y)).map(|ce| p.ceiling_vertical_extent(ce)).filter(|(a, b)| a.is_finite() && b.is_finite()).collect();
|
||||
let over: Vec<(f64, f64)> = p.ceilings.as_deref().unwrap_or(&[]).iter().filter(|ce| in_ceiling(ce, x, y)).map(|ce| {
|
||||
// [281] Geneigte Decke: Höhe am Beschriftungspunkt des Raums.
|
||||
let (b, t) = p.ceiling_vertical_extent(ce);
|
||||
let d = ce.slope_dz(x, y);
|
||||
(b + d, t + d)
|
||||
}).filter(|(a, b)| a.is_finite() && b.is_finite()).collect();
|
||||
let floor_z = over.iter().map(|e| e.1).filter(|t| *t >= base - 0.3 && *t <= base + 0.5).fold(f64::NAN, f64::max);
|
||||
let floor_z = if floor_z.is_finite() { floor_z } else { base };
|
||||
let ceil_z = over.iter().map(|e| e.0).filter(|b| *b > floor_z + 1.0).fold(f64::NAN, f64::min);
|
||||
|
||||
@@ -592,6 +592,8 @@ fn ceiling_selection(root: &Map<String, Value>, c: &Value) -> Result<J, String>
|
||||
.raw("bottom", c, "bottom")
|
||||
.n("zBottom", zb)
|
||||
.n("zTop", zt)
|
||||
// [281] Neigung (fehlt = waagrecht).
|
||||
.raw("slope", c, "slope")
|
||||
.v("openings", J::arr(openings))
|
||||
.done();
|
||||
Ok(O::default()
|
||||
|
||||
@@ -315,9 +315,20 @@ pub fn spec_solid_q(spec: &Value, depth: usize, min_seg: usize) -> Option<Solid>
|
||||
if cr > 1e-6 {
|
||||
outer = round_ring(&outer, cr, min_seg);
|
||||
}
|
||||
let body = solid(&tube(&[ring_at(&outer, z0), ring_at(&outer, z0 + h)], false))?;
|
||||
// [281] Geneigte Platte: `slope` = [ox, oy, gx, gy], jede Höhe um gx·(x−ox) + gy·(y−oy) versetzt.
|
||||
let g: Option<[f64; 4]> = match nums(spec.get("slope")) {
|
||||
Some(v) if v.len() == 4 && v.iter().all(|x| x.is_finite()) => Some([v[0], v[1], v[2], v[3]]),
|
||||
_ => None,
|
||||
};
|
||||
let at = |r: &[[f64; 2]], z: f64| -> Vec<P3> {
|
||||
match &g {
|
||||
Some(g) => r.iter().map(|q| [q[0], q[1], z + crate::model::helpers::slope_dz(g, q[0], q[1])]).collect(),
|
||||
None => ring_at(r, z),
|
||||
}
|
||||
};
|
||||
let body = solid(&tube(&[at(&outer, z0), at(&outer, z0 + h)], false))?;
|
||||
let e = 1e-3;
|
||||
minus_holes(body, &holes_of(spec)?, &|r| tube(&[ring_at(r, z0 - e), ring_at(r, z0 + h + e)], false))
|
||||
minus_holes(body, &holes_of(spec)?, &|r| tube(&[at(r, z0 - e), at(r, z0 + h + e)], false))
|
||||
}
|
||||
"extrudePlane" => {
|
||||
let (o, u, v) = (vec3(spec, "origin")?, vec3(spec, "uAxis")?, vec3(spec, "vAxis")?);
|
||||
|
||||
@@ -296,12 +296,17 @@ pub fn void_cuts_lifted(p: &Project, walls: &[RWall], slabs: &[RSlab], wall_dz:
|
||||
continue;
|
||||
}
|
||||
let dz = slab_dz(i);
|
||||
let hits = hitting(&voids, &bbox(s.outline.iter().map(|q| (q[0], q[1]))), s.z_bottom - dz, s.z_top - dz);
|
||||
// [281] Geneigte Platte: Höhenspanne über den Umriss, Körper mit Neigungsebene.
|
||||
let (lo, hi) = s.outline.iter().fold((0.0f64, 0.0f64), |(a, b), q| (a.min(s.dz(q[0], q[1])), b.max(s.dz(q[0], q[1]))));
|
||||
let hits = hitting(&voids, &bbox(s.outline.iter().map(|q| (q[0], q[1]))), s.z_bottom + lo - dz, s.z_top + hi - dz);
|
||||
if hits.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let pts: Vec<f64> = s.outline.iter().flat_map(|q| [q[0], q[1]]).collect();
|
||||
let base = json!({"kind": "extrude", "points": pts, "height": s.z_top - s.z_bottom, "z0": s.z_bottom});
|
||||
let mut base = json!({"kind": "extrude", "points": pts, "height": s.z_top - s.z_bottom, "z0": s.z_bottom});
|
||||
if let Some(g) = s.slope {
|
||||
base["slope"] = json!(g);
|
||||
}
|
||||
out.slabs.push((i, subtract(base, &hits, dz)));
|
||||
}
|
||||
out
|
||||
|
||||
@@ -1067,7 +1067,10 @@ fn collect(p: &Project, k: [f64; 2], cut: Option<f64>, ground: Option<&Ground>)
|
||||
}
|
||||
// [142] Decken (auch Balkone, Auskragungen) werfen Schatten, decken Tieferes ab und empfangen ihn.
|
||||
for ce in p.ceilings.as_deref().unwrap_or(&[]) {
|
||||
let (zb, zt) = p.ceiling_vertical_extent(ce);
|
||||
// [281] Geneigte Decke: Hüllprisma über die ganze Höhenspanne; sie empfängt keinen Schatten (die
|
||||
// Empfangsfläche ist waagrecht gedacht).
|
||||
let sloped = ce.slope_plane().is_some();
|
||||
let (zb, zt) = p.ceiling_vertical_span(ce);
|
||||
let ring = |r: &[crate::model::Vec2]| r.iter().map(|v| [v.x, v.y]).collect::<Ring>();
|
||||
// [191] Umriss mit Bögen fein geteilt (wie die Aussparungen), sonst schnitte die Sehne den Erker ab.
|
||||
let outline = ring(&ce.ring());
|
||||
@@ -1077,7 +1080,9 @@ fn collect(p: &Project, k: [f64; 2], cut: Option<f64>, ground: Option<&Ground>)
|
||||
continue;
|
||||
}
|
||||
covers.push(Cover { region: region.clone(), bottom: zb });
|
||||
receive(region, [0.0, 0.0, zt], zt);
|
||||
if !sloped {
|
||||
receive(region, [0.0, 0.0, zt], zt);
|
||||
}
|
||||
prisms.push((Prism { footprint: outline, z_bottom: zb, z_top: zt }, holes));
|
||||
}
|
||||
// [142] Dächer in ihrer echten Form: verschnittene Dächer (Gauben, Anbauten) als Hülle ihres
|
||||
|
||||
@@ -642,7 +642,8 @@ fn ceiling_lines(p: &Project, ce: &Ceiling, s: &mut Sink) {
|
||||
let Some((pat, comp, spec)) = spec_for(layer.and_then(|l| p.component(&l.component_id)), 0.0) else { continue };
|
||||
let rgb = ink_rgb(pat, comp);
|
||||
for (a, b, m) in lod_segments(|sc| sp::segments(&ring, &spec, outer[0], sc)) {
|
||||
s.push([a[0], a[1], z], [b[0], b[1], z], rgb, m);
|
||||
// [281] Geneigte Decke: Linien liegen auf der geneigten Fläche (Versatz je Endpunkt, linear dazwischen).
|
||||
s.push([a[0], a[1], z + ce.slope_dz(a[0], a[1])], [b[0], b[1], z + ce.slope_dz(b[0], b[1])], rgb, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,7 +517,7 @@ impl Builder {
|
||||
/// PredefinedType, in IFC2x3 je Klasse ShapeType/PredefinedType/CompositionType; IfcWall und IfcColumn
|
||||
/// haben es dort nicht.
|
||||
pub(super) fn emit_building_element(&mut self, ty: &str, guid: String, name: &str, placement: usize, shape: usize, predefined: Option<String>) -> usize {
|
||||
let last = if self.v2() && matches!(ty, "IFCWALL" | "IFCWALLSTANDARDCASE" | "IFCCOLUMN") {
|
||||
let last = if self.v2() && matches!(ty, "IFCWALL" | "IFCWALLSTANDARDCASE" | "IFCCOLUMN" | "IFCRAMPFLIGHT") {
|
||||
String::new()
|
||||
} else {
|
||||
format!(",{}", predefined.as_deref().unwrap_or("$"))
|
||||
|
||||
@@ -179,6 +179,8 @@ pub const REC_RAILING: f64 = 26.0;
|
||||
pub const REC_COLUMN_PIECES: f64 = 20.0;
|
||||
pub const REC_CEILING_ARC: f64 = 21.0;
|
||||
pub const REC_SPACE_ARC: f64 = 22.0;
|
||||
/// [281] Geneigte Decke als Netz (Flag Rampe ⇒ `IfcRamp` + `IfcRampFlight`).
|
||||
pub const REC_CEILING_MESH: f64 = 27.0;
|
||||
|
||||
mod format;
|
||||
mod reader;
|
||||
@@ -201,6 +203,7 @@ fn rec_name(code: f64) -> &'static str {
|
||||
c if c == REC_WALL_ARC_SOLID => "WALL_ARC_SOLID",
|
||||
c if c == REC_CEILING => "CEILING",
|
||||
c if c == REC_CEILING_ARC => "CEILING_ARC",
|
||||
c if c == REC_CEILING_MESH => "CEILING_MESH",
|
||||
c if c == REC_SPACE_ARC => "SPACE_ARC",
|
||||
c if c == REC_OPENING => "OPENING",
|
||||
c if c == REC_OPENING_SOLID => "OPENING_SOLID",
|
||||
@@ -703,6 +706,43 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
|
||||
};
|
||||
w.finish_typed("IFCSLAB", format!("slab/{id}"), &name, &ty, &psets, structure, placement, shape, Some(enum_("FLOOR")), true);
|
||||
}
|
||||
c if c == REC_CEILING_MESH => {
|
||||
let structure = r.structure(n_storeys)?;
|
||||
let id = r.string()?;
|
||||
let name = r.string()?;
|
||||
let ty = r.type_ref()?;
|
||||
let psets = r.psets()?;
|
||||
let ramp = r.flag()?;
|
||||
let mesh = r.mesh()?;
|
||||
let key = format!("slab/{id}");
|
||||
if !ramp {
|
||||
let (placement, shape) = w.emit_triangulated_product(&mesh, w.placement_of(structure));
|
||||
w.finish_typed("IFCSLAB", key, &name, &ty, &psets, structure, placement, shape, Some(enum_("FLOOR")), true);
|
||||
} else {
|
||||
// Rampe ohne eigene Darstellung; der Lauf (Körper, Typ, Eigenschaften) hängt per IfcRelAggregates daran
|
||||
// (wie Treppe/Treppenlauf). IFC2x3: `ShapeType` statt `PredefinedType`, Lauf ohne Typ-Enum.
|
||||
let parent = w.placement_of(structure);
|
||||
let ramp_placement = w.emit_placement(0.0, parent);
|
||||
let g = w.gid(&key);
|
||||
let ramp_entity = w.add(
|
||||
"IFCRAMP",
|
||||
format!("{g},#{},{},$,$,#{ramp_placement},$,$,{}", w.owner_history, ifc_string(&name), enum_("STRAIGHT_RUN_RAMP")),
|
||||
);
|
||||
let (placement, shape) = w.emit_triangulated_product(&mesh, ramp_placement);
|
||||
let fkey = format!("{key}/flight");
|
||||
let guid = w.gid(&fkey);
|
||||
let flight = w.emit_building_element("IFCRAMPFLIGHT", guid, &name, placement, shape, Some(enum_("STRAIGHT")));
|
||||
for p in &psets {
|
||||
w.add_pset(p, flight, &fkey);
|
||||
}
|
||||
// Der Deckentyp (IfcSlabType) passt nicht zum Rampenlauf: ohne Typ, Schichten nur im Modell.
|
||||
let _ = ty;
|
||||
let g = w.gid(&format!("aggregates/{key}"));
|
||||
w.add("IFCRELAGGREGATES", format!("{g},#{},$,$,#{ramp_entity},{}", w.owner_history, refs(&[flight])));
|
||||
w.add_to_containment(structure, ramp_entity);
|
||||
w.elements.insert(key, ramp_entity);
|
||||
}
|
||||
}
|
||||
c if c == REC_OPENING => {
|
||||
let wall_id = r.string()?;
|
||||
let structure = r.structure(n_storeys)?;
|
||||
|
||||
@@ -85,6 +85,7 @@ fn l_wall_scene() -> (Vec<WallInput>, Vec<SlabInput>) {
|
||||
];
|
||||
let slabs = vec![SlabInput {
|
||||
monolith: None,
|
||||
slope: None,
|
||||
outline: vec![[-0.5, -0.5], [3.5, -0.5], [3.5, 3.5], [-0.5, 3.5]],
|
||||
z_bottom: -0.2,
|
||||
z_top: 0.0,
|
||||
|
||||
@@ -918,6 +918,7 @@ mod tests {
|
||||
fn square_slab(s: f32, z_bottom: f32, z_top: f32) -> SlabInput {
|
||||
SlabInput {
|
||||
monolith: None,
|
||||
slope: None,
|
||||
outline: vec![[0.0, 0.0], [s, 0.0], [s, s], [0.0, s]],
|
||||
z_bottom,
|
||||
z_top,
|
||||
@@ -977,6 +978,7 @@ mod tests {
|
||||
// Zentrum weg zeigen.
|
||||
let slab = SlabInput {
|
||||
monolith: None,
|
||||
slope: None,
|
||||
outline: vec![[-2.0, -2.0], [2.0, -2.0], [2.0, 2.0], [-2.0, 2.0]],
|
||||
z_bottom: 0.0,
|
||||
z_top: 0.3,
|
||||
@@ -1011,7 +1013,7 @@ mod tests {
|
||||
fn entarteter_slab_erzeugt_nichts() {
|
||||
let mut mesh = Mesh::default();
|
||||
// <3 Ecken.
|
||||
extrude_slab(&mut mesh, &SlabInput { outline: vec![[0.0, 0.0], [1.0, 0.0]], z_bottom: 0.0, z_top: 0.2, color: [0.8, 0.8, 0.8], hatch: None, cut: None, monolith: None });
|
||||
extrude_slab(&mut mesh, &SlabInput { outline: vec![[0.0, 0.0], [1.0, 0.0]], z_bottom: 0.0, z_top: 0.2, color: [0.8, 0.8, 0.8], hatch: None, cut: None, monolith: None, slope: None });
|
||||
assert_eq!(mesh.vertex_count(), 0);
|
||||
// Nullhoehe.
|
||||
extrude_slab(&mut mesh, &square_slab(4.0, 2.6, 2.6));
|
||||
|
||||
@@ -1608,16 +1608,24 @@ pub fn extrude_slab(mesh: &mut Mesh, slab: &SlabInput) {
|
||||
return;
|
||||
}
|
||||
let color = slab.color;
|
||||
// world-Position: model [x, y] -> (x, hoehe, y).
|
||||
let w = |g: Point2, y: f32| -> [f32; 3] { [g[0], y, g[1]] };
|
||||
// world-Position: model [x, y] -> (x, hoehe, y); [281] geneigte Platte: Höhe + Versatz der Neigungsebene.
|
||||
let w = |g: Point2, y: f32| -> [f32; 3] { [g[0], y + slab.dz(g), g[1]] };
|
||||
// Deckel-/Bodennormale: senkrecht auf der (geneigten) Ebene.
|
||||
let up = match slab.slope {
|
||||
Some(s) => {
|
||||
let l = (s[2] * s[2] + 1.0 + s[3] * s[3]).sqrt();
|
||||
[-s[2] / l, 1.0 / l, -s[3] / l]
|
||||
}
|
||||
None => [0.0, 1.0, 0.0],
|
||||
};
|
||||
|
||||
// Deckel (+Y) und Boden (−Y) aus den Triangulierungs-Dreiecken.
|
||||
for t in tris.chunks_exact(3) {
|
||||
let a = pts[t[0] as usize];
|
||||
let b = pts[t[1] as usize];
|
||||
let c = pts[t[2] as usize];
|
||||
push_tri_oriented(mesh, w(a, y1), w(b, y1), w(c, y1), [0.0, 1.0, 0.0], color);
|
||||
push_tri_oriented(mesh, w(a, y0), w(b, y0), w(c, y0), [0.0, -1.0, 0.0], color);
|
||||
push_tri_oriented(mesh, w(a, y1), w(b, y1), w(c, y1), up, color);
|
||||
push_tri_oriented(mesh, w(a, y0), w(b, y0), w(c, y0), [-up[0], -up[1], -up[2]], color);
|
||||
}
|
||||
|
||||
// Mantelflaechen: je Kante ein vertikales Quad (unten y0, oben y1), Normale nach aussen (aus dem
|
||||
@@ -1767,7 +1775,7 @@ mod tests {
|
||||
if rev {
|
||||
o.reverse();
|
||||
}
|
||||
let slab = SlabInput { monolith: None, outline: o, z_bottom: 0.0, z_top: 0.3, color: [0.8, 0.8, 0.8], hatch: None, cut: None };
|
||||
let slab = SlabInput { monolith: None, slope: None, outline: o, z_bottom: 0.0, z_top: 0.3, color: [0.8, 0.8, 0.8], hatch: None, cut: None };
|
||||
let mut m = Mesh::default();
|
||||
extrude_slab(&mut m, &slab);
|
||||
let mut at_arc = 0;
|
||||
|
||||
@@ -345,9 +345,19 @@ struct Prism {
|
||||
/// Ebene Oberkante unter einer Dachfläche ([G2], `WallInput::top_plane`): Ursprung (Grundriss)
|
||||
/// und `[z, dz/dx, dz/dy]`; `z1` ist dann der höchste Eckwert.
|
||||
top: Option<(Point2, [f32; 3])>,
|
||||
/// [281] Geneigte Platte (`SlabInput::slope`): alle Höhen um den Versatz der Neigungsebene verschoben.
|
||||
shear: Option<[f32; 4]>,
|
||||
}
|
||||
|
||||
impl Prism {
|
||||
/// [281] Höhenversatz der geneigten Platte am Grundrisspunkt (sonst 0).
|
||||
fn dz(&self, p: Point2) -> f32 {
|
||||
match self.shear {
|
||||
Some(s) => s[2] * (p[0] - s[0]) + s[3] * (p[1] - s[1]),
|
||||
None => 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Oberkante an einem Grundriss-Punkt.
|
||||
fn top_at(&self, p: Point2) -> f32 {
|
||||
match self.top {
|
||||
@@ -447,6 +457,7 @@ fn wall_prism(index: usize, wall: &WallInput) -> Option<Prism> {
|
||||
cut: wall.cut.clone(),
|
||||
monolith: None,
|
||||
top: wall.top_plane.map(|c| (wall.start, c)),
|
||||
shear: None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -472,6 +483,7 @@ fn slab_prism(index: usize, slab: &SlabInput) -> Option<Prism> {
|
||||
cut: slab.cut.clone(),
|
||||
monolith: slab.monolith.clone(),
|
||||
top: None,
|
||||
shear: slab.slope,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -653,6 +665,11 @@ fn prism_bounds(plane: &SectionPlane, prism: &Prism) -> PrismBounds {
|
||||
}
|
||||
}
|
||||
|
||||
// [281] Geneigte Platte: Hüllhöhe über den ganzen Umriss (konservativ, wie die achsparallele Näherung).
|
||||
let (dlo, dhi) = match prism.shear {
|
||||
Some(_) => prism.footprint.iter().fold((f32::INFINITY, f32::NEG_INFINITY), |(a, b), &p| (a.min(prism.dz(p)), b.max(prism.dz(p)))),
|
||||
None => (0.0, 0.0),
|
||||
};
|
||||
PrismBounds {
|
||||
kind: prism.kind,
|
||||
index: prism.index,
|
||||
@@ -661,8 +678,8 @@ fn prism_bounds(plane: &SectionPlane, prism: &Prism) -> PrismBounds {
|
||||
depth_min,
|
||||
depth_max,
|
||||
monolith: prism.monolith.clone(),
|
||||
z0: prism.z0,
|
||||
z1: prism.z1,
|
||||
z0: prism.z0 + dlo,
|
||||
z1: prism.z1 + dhi,
|
||||
opening_voids,
|
||||
}
|
||||
}
|
||||
@@ -897,19 +914,23 @@ fn prism_wireframe_edges(prism: &Prism) -> Vec<([f32; 3], [f32; 3], HeightBias)>
|
||||
let n = prism.footprint.len();
|
||||
let mut edges = Vec::with_capacity(3 * n);
|
||||
for i in 0..n {
|
||||
let d = prism.dz(prism.footprint[i]);
|
||||
edges.push((
|
||||
to_world(prism.footprint[i], prism.z0),
|
||||
to_world(prism.footprint[i], prism.top_at(prism.footprint[i])),
|
||||
to_world(prism.footprint[i], prism.z0 + d),
|
||||
to_world(prism.footprint[i], prism.top_at(prism.footprint[i]) + d),
|
||||
HeightBias::Vertical,
|
||||
));
|
||||
}
|
||||
// [281] Geneigte Platte: Boden- und Deckelkanten variieren in der Höhe.
|
||||
let sheared = prism.shear.is_some();
|
||||
for i in 0..n {
|
||||
let a = prism.footprint[i];
|
||||
let b = prism.footprint[(i + 1) % n];
|
||||
edges.push((to_world(a, prism.z0), to_world(b, prism.z0), HeightBias::BottomCap));
|
||||
let (da, db) = (prism.dz(a), prism.dz(b));
|
||||
edges.push((to_world(a, prism.z0 + da), to_world(b, prism.z0 + db), if sheared { HeightBias::Vertical } else { HeightBias::BottomCap }));
|
||||
// Schräge Deckelkante ([G2]): Höhe variiert, geschlossene Randbehandlung.
|
||||
let bias = if prism.top.is_some() { HeightBias::Vertical } else { HeightBias::TopCap };
|
||||
edges.push((to_world(a, prism.top_at(a)), to_world(b, prism.top_at(b)), bias));
|
||||
let bias = if prism.top.is_some() || sheared { HeightBias::Vertical } else { HeightBias::TopCap };
|
||||
edges.push((to_world(a, prism.top_at(a) + da), to_world(b, prism.top_at(b) + db), bias));
|
||||
}
|
||||
edges
|
||||
}
|
||||
@@ -1228,6 +1249,15 @@ fn cut_polygons_and_prisms(
|
||||
} else {
|
||||
(rz1, rz1)
|
||||
};
|
||||
// [281] Geneigte Platte: Unter- und Oberkante längs der Schnittlinie um den Versatz verschoben.
|
||||
let (dlo, dhi) = match prism.shear {
|
||||
Some(_) => {
|
||||
let (p0, ua) = (plane.plan_point(), plane.plan_u_axis());
|
||||
let at = |u: f32| prism.dz([p0[0] + u * ua[0], p0[1] + u * ua[1]]);
|
||||
(at(rlo), at(rhi))
|
||||
}
|
||||
None => (0.0, 0.0),
|
||||
};
|
||||
cut_polygons.push(CutPolygon {
|
||||
component: ComponentRef {
|
||||
kind: prism.kind,
|
||||
@@ -1235,7 +1265,7 @@ fn cut_polygons_and_prisms(
|
||||
},
|
||||
color: prism.color,
|
||||
hatch: prism.hatch,
|
||||
pts: vec![[rlo, rz0], [rhi, rz0], [rhi, zb], [rlo, za]],
|
||||
pts: vec![[rlo, rz0 + dlo], [rhi, rz0 + dhi], [rhi, zb + dhi], [rlo, za + dlo]],
|
||||
cut: prism.cut.clone(),
|
||||
});
|
||||
}
|
||||
@@ -1310,6 +1340,7 @@ mod tests {
|
||||
];
|
||||
let slabs = vec![SlabInput {
|
||||
monolith: None,
|
||||
slope: None,
|
||||
outline: vec![[-0.5, -0.5], [3.5, -0.5], [3.5, 3.5], [-0.5, 3.5]],
|
||||
z_bottom: -0.2,
|
||||
z_top: 0.0,
|
||||
|
||||
@@ -24,6 +24,16 @@ fn poly_from_rect(src: &CutPolygon, r: Rect) -> CutPolygon {
|
||||
}
|
||||
}
|
||||
|
||||
/// [281] Liegen alle Ecken auf den Kanten der Hüllbox (achsparalleles Rechteck)?
|
||||
fn is_axis_rect(pts: &[[f32; 2]]) -> bool {
|
||||
let (mut u0, mut u1, mut v0, mut v1) = (f32::INFINITY, f32::NEG_INFINITY, f32::INFINITY, f32::NEG_INFINITY);
|
||||
for p in pts {
|
||||
(u0, u1, v0, v1) = (u0.min(p[0]), u1.max(p[0]), v0.min(p[1]), v1.max(p[1]));
|
||||
}
|
||||
const E: f32 = 1e-5;
|
||||
pts.iter().all(|p| ((p[0] - u0).abs() < E || (p[0] - u1).abs() < E) && ((p[1] - v0).abs() < E || (p[1] - v1).abs() < E))
|
||||
}
|
||||
|
||||
/// Globale Schnitt-Dominanz (staerkere `join_priority` schneidet schwaechere weg, gleiche Komponente
|
||||
/// und Prioritaet verschmilzt) — siehe `dossier_hatch::section_dominance`.
|
||||
pub fn subtract_dominant_bands(bands: Vec<CutPolygon>) -> Vec<CutPolygon> {
|
||||
@@ -36,11 +46,11 @@ pub fn subtract_dominant_bands(bands: Vec<CutPolygon>) -> Vec<CutPolygon> {
|
||||
let n = ids.len() as u32;
|
||||
*ids.entry(id).or_insert(n)
|
||||
});
|
||||
Band {
|
||||
rect: rect_of_points(b.pts.iter().map(|p| (p[0] as f64, p[1] as f64))),
|
||||
prio: meta.and_then(|c| c.join_priority).map(f64::from),
|
||||
comp,
|
||||
}
|
||||
// [281] Schräge Bänder (geneigte Platte) sind kein Rechteck: nehmen an der Dominanz nicht teil
|
||||
// (wie Dach-Schichten), sonst schnitte ihre Hüllbox zu viel weg.
|
||||
let rect = rect_of_points(b.pts.iter().map(|p| (p[0] as f64, p[1] as f64)));
|
||||
let prio = meta.and_then(|c| c.join_priority).map(f64::from).filter(|_| b.component.kind != crate::section::ComponentKind::Slab || is_axis_rect(&b.pts));
|
||||
Band { rect, prio, comp }
|
||||
})
|
||||
.collect();
|
||||
dominant_bands(&inp)
|
||||
|
||||
@@ -575,6 +575,7 @@ mod tests {
|
||||
// z in [2.0, 2.4]; Prio 100 (Beton laeuft durch, schneidet die Wand).
|
||||
let slab = SlabInput {
|
||||
monolith: None,
|
||||
slope: None,
|
||||
outline: vec![[-1.0, -1.0], [4.0, -1.0], [4.0, 1.0], [-1.0, 1.0]],
|
||||
z_bottom: 2.0,
|
||||
z_top: 2.4,
|
||||
@@ -653,6 +654,7 @@ mod tests {
|
||||
// Wand in u ab (Umriss ueber y in [-1,1]).
|
||||
let screed = SlabInput {
|
||||
monolith: None,
|
||||
slope: None,
|
||||
outline: vec![[-1.0, -1.0], [4.0, -1.0], [4.0, 1.0], [-1.0, 1.0]],
|
||||
z_bottom: 1.0,
|
||||
z_top: 1.06,
|
||||
@@ -668,6 +670,7 @@ mod tests {
|
||||
// Daemmung-Slab (Prio 20, Muster 4), z in [0.96,1.0], gleiche u-Deckung.
|
||||
let insulation = SlabInput {
|
||||
monolith: None,
|
||||
slope: None,
|
||||
outline: vec![[-1.0, -1.0], [4.0, -1.0], [4.0, 1.0], [-1.0, 1.0]],
|
||||
z_bottom: 0.96,
|
||||
z_top: 1.0,
|
||||
|
||||
@@ -301,6 +301,21 @@ pub struct SlabInput {
|
||||
/// verschwinden, sichtbar bleibt der Umriss (Sägezahn). `None` = Einzelteil.
|
||||
#[serde(default)]
|
||||
pub monolith: Option<String>,
|
||||
/// [281] Geneigte Decke/Rampe: Neigungsebene `[ox, oy, gx, gy]` (Modell-Meter) — jede Höhe der Platte liegt
|
||||
/// am Grundrisspunkt (x, y) um `gx·(x−ox) + gy·(y−oy)` höher (Ober- und Unterkante parallel verschoben,
|
||||
/// Mantel bleibt lotrecht). `None` = waagrecht.
|
||||
#[serde(default)]
|
||||
pub slope: Option<[f32; 4]>,
|
||||
}
|
||||
|
||||
impl SlabInput {
|
||||
/// [281] Höhenversatz der Neigungsebene am Grundrisspunkt (waagrecht 0).
|
||||
pub fn dz(&self, p: Point2) -> f32 {
|
||||
match self.slope {
|
||||
Some(s) => s[2] * (p[0] - s[0]) + s[3] * (p[1] - s[1]),
|
||||
None => 0.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// EINE Dachflächen-Schicht für den 3D-Live-Schnitt (`crate::roof_cut`).
|
||||
|
||||
Reference in new issue
Block a user