[148] Flachdach: Attika (parapetHeight/Width/ComponentId) in 3D, Schnitt, Ansicht, Grundriss, Objekt-Info
Neues Modul roof_parapet.rs: Ringkörper auf dem Traufumriss des Flachdachs (kurze Kanten werden zusammengezogen, damit der Innenring nicht umklappt). 3D über emit_roofs, Schnitt mit Schraffur des Bauteils, Ansicht über die Dach-Sichtflächen, Grundriss-Innenkante auf der Dach-Ebene. Musterhaus komplex: Erker mit Betonattika. Gefälle der Dachhaut bleibt offen (TODO).
This commit is contained in:
21 files changed
+350
-21
No files matched your search
@@ -52,7 +52,7 @@ Neues Modul: `<modul>.rs` und `mod` in `lib.rs`, Bindungen in `web/<modul>.rs` u
|
||||
|---|---|
|
||||
| `joins.rs` | Wandknoten: Gehrung, T-Stoss, Kreuzung, je Schicht nach Priorität (`compute_joins()`) |
|
||||
| `wall_arc.rs` | Bogenwände |
|
||||
| `roof.rs`, `roof_skeleton.rs`, `skeleton.rs`, `roof_assembly.rs`, `dormer.rs` | Dächer (Straight Skeleton), Dach an Dach, Gauben |
|
||||
| `roof.rs`, `roof_skeleton.rs`, `skeleton.rs`, `roof_assembly.rs`, `roof_parapet.rs`, `dormer.rs` | Dächer (Straight Skeleton), Dach an Dach, Attika (Flachdach-Brüstung), Gauben |
|
||||
| `stair.rs`, `stair_rail.rs`, `stair_guard.rs` | Treppen-Geometrie, Handlauf, Absturzsicherung am Deckenloch (Grundriss, 3D, IFC) |
|
||||
| `opening_geom.rs`, `opening_shape.rs`, `opening_detail.rs`, `opening_presets.rs`, `opening_preview.rs`, `opening_slide.rs` | Öffnungen: Symbol, Formen, Rahmen, Vorlagen, Vorschau, Verschieben in der Wand |
|
||||
| `room_area.rs`, `room_boundary.rs` | Raumflächen nach SIA 416; Raum-Erkennung aus Wänden |
|
||||
|
||||
@@ -16,6 +16,7 @@ pub mod flat_write;
|
||||
pub mod polygon_bool;
|
||||
pub mod roof;
|
||||
pub mod roof_skeleton;
|
||||
pub mod roof_parapet;
|
||||
pub mod flat_read;
|
||||
pub mod sun;
|
||||
pub mod tree;
|
||||
|
||||
@@ -3308,6 +3308,19 @@ pub struct Roof {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub dormers: Option<Vec<Dormer>>,
|
||||
/// Attika ([148]): Höhe über der Dachhaut (Meter) am Rand eines Flachdachs, umlaufend auf dem Dachumriss
|
||||
/// (mit Überstand). Fehlt oder 0 ⇒ keine Attika. Wirkt nur bei Flachdach.
|
||||
#[serde(rename = "parapetHeight", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub parapet_height: Option<f64>,
|
||||
/// Attika: Breite (Meter, nach innen vom Dachrand); fehlt ⇒ 0.2.
|
||||
#[serde(rename = "parapetWidth", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub parapet_width: Option<f64>,
|
||||
/// Attika: Bauteil/Material (Farbe, Schnittschraffur); fehlt ⇒ Wandfarbe ohne Schraffur.
|
||||
#[serde(rename = "parapetComponentId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub parapet_component_id: Option<String>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
|
||||
@@ -541,6 +541,14 @@ pub fn emit_roofs(p: &Project, only_roof: Option<&str>) -> Result<Vec<RMesh>, St
|
||||
let nb = crate::roof_assembly::neighbors_rc(p);
|
||||
for (ri, roof) in p.roofs.as_deref().unwrap_or(&[]).iter().enumerate().filter(|(_, r)| only_roof.is_none_or(|id| r.id == id)) {
|
||||
let override_color = roof.color.as_deref().filter(|c| !c.is_empty()).map(|c| hex_to_rgb(c, ROOF_RGB));
|
||||
// Attika ([148]): Ringkörper auf dem Dachrand eines Flachdachs.
|
||||
if let Some(pp) = crate::roof_parapet::parapet(roof, &crate::roof::roof_geometry(&roof.params(), p.roof_base_elevation(roof))) {
|
||||
let comp_id = roof.parapet_component_id.as_deref().unwrap_or("");
|
||||
let color = override_color.unwrap_or_else(|| p.component(comp_id).map_or(WALL_RGB, |c| hex_to_rgb(&c.color, WALL_RGB)));
|
||||
let material_index = if override_color.is_none() && !comp_id.is_empty() { material_layer(p, &maps, comp_id) } else { None };
|
||||
let m = crate::roof_parapet::mesh(&pp);
|
||||
out.push(RMesh { crease_angle: None, positions: m.positions, indices: m.indices, kind: "extrusion", color, vertex_colors: None, material_index });
|
||||
}
|
||||
// Verschnittene Dächer und Gauben ([G5]): Körper aus `roof_assembly`.
|
||||
if let Some(solids) = crate::roof_assembly::roof_solids_with(p, ri, &nb) {
|
||||
for part in &solids.parts {
|
||||
|
||||
@@ -823,6 +823,13 @@ fn roofs(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) {
|
||||
out.push(line(pts[i], pts[(i + 1) % n], "roof-eaves", ROOF_EAVES_MM, overhead.clone(), stroke, greyed));
|
||||
}
|
||||
}
|
||||
// Attika ([148]): Innenkante des Ringkörpers (Aussenkante = Traufe).
|
||||
if let Some(pp) = crate::roof_parapet::parapet(roof, &geo) {
|
||||
let n = pp.inner.len();
|
||||
for i in 0..n {
|
||||
out.push(line(pv(pp.inner[i]), pv(pp.inner[(i + 1) % n]), "roof-parapet", ROOF_EAVES_MM, overhead.clone(), stroke, greyed));
|
||||
}
|
||||
}
|
||||
for l in &geo.ridges {
|
||||
out.push(line(pv(l[0]), pv(l[1]), "roof-ridge", ROOF_RIDGE_MM, overhead.clone(), stroke, greyed));
|
||||
}
|
||||
|
||||
@@ -253,7 +253,8 @@ pub(super) fn collect_roof_faces(p: &Project, frame: &[f64; 9], walls: &[RWall])
|
||||
})
|
||||
.map(|q| q.to_vec());
|
||||
// Ohne Wände bis ans Dach zusätzlich die Giebeldreiecke ([132]: Stirnen immer).
|
||||
if floors.contains(roof.floor_id.as_str()) { fascia.collect() } else { g.gables.iter().cloned().chain(fascia).collect::<Vec<_>>() }
|
||||
let parapet = crate::roof_parapet::parapet(roof, &g).map(|pp| crate::roof_parapet::view_faces(&pp)).unwrap_or_default();
|
||||
if floors.contains(roof.floor_id.as_str()) { fascia.chain(parapet).collect() } else { g.gables.iter().cloned().chain(fascia).chain(parapet).collect::<Vec<_>>() }
|
||||
};
|
||||
roofs.push(RoofIn { id: roof.id.clone(), fill, planes: crate::roof_assembly::planar_faces(&solids.top, &front(&solids.top)), gables });
|
||||
let wall_comp = solids.parts.iter().find(|pt| pt.role == crate::roof_assembly::Role::DormerWall && pt.layer == 0).and_then(|pt| p.component(&pt.component_id));
|
||||
@@ -269,7 +270,8 @@ pub(super) fn collect_roof_faces(p: &Project, frame: &[f64; 9], walls: &[RWall])
|
||||
// in der Ansicht auf der Kante).
|
||||
let total: f64 = p.roof_layers(roof).iter().map(|l| l.thickness.max(0.0)).sum();
|
||||
let fascia = fascia_quads(&g.planes, total).into_iter().map(|q| q.to_vec());
|
||||
let gables = if floors.contains(roof.floor_id.as_str()) { fascia.collect() } else { g.gables.iter().cloned().chain(fascia).collect() };
|
||||
let parapet = crate::roof_parapet::parapet(roof, &g).map(|pp| crate::roof_parapet::view_faces(&pp)).unwrap_or_default();
|
||||
let gables = if floors.contains(roof.floor_id.as_str()) { fascia.chain(parapet).collect() } else { g.gables.iter().cloned().chain(fascia).chain(parapet).collect() };
|
||||
roofs.push(RoofIn { id: roof.id.clone(), fill, planes: g.planes.clone(), gables });
|
||||
}
|
||||
Ok(project_faces(frame, &[], &[], &roofs))
|
||||
|
||||
@@ -190,7 +190,8 @@ pub(super) fn projection_edges(p: &Project, plane: &Plane, walls_r: &[RWall], wi
|
||||
// Stirnflächen der Ränder ([132]): Flachdächer zeigen sonst hinter dem Schnitt nur eine Linie.
|
||||
let total: f64 = p.roof_layers(roof).iter().map(|l| l.thickness.max(0.0)).sum();
|
||||
let fascia: Vec<Vec<[f64; 3]>> = crate::plan::elevation::fascia_quads(&g.planes, total).into_iter().map(|q| q.to_vec()).collect();
|
||||
for poly in g.planes.iter().chain(&g.gables).chain(&fascia) {
|
||||
let parapet = crate::roof_parapet::parapet(roof, &g).map(|pp| crate::roof_parapet::view_faces(&pp)).unwrap_or_default();
|
||||
for poly in g.planes.iter().chain(&g.gables).chain(&fascia).chain(¶pet) {
|
||||
let w: Vec<[f64; 3]> = poly.iter().map(|q| [q[0], q[2], q[1]]).collect();
|
||||
if w.len() >= 3 {
|
||||
push(&mut faces, &w, [0.0; 3], owner, 0, true);
|
||||
|
||||
@@ -148,6 +148,18 @@ pub(super) fn append_roof_sections(cuts: &mut Vec<Cut>, p: &Project, plane: &Pla
|
||||
let (ux, uy) = plane.u_model();
|
||||
let nb = crate::roof_assembly::neighbors_rc(p);
|
||||
for (index, roof) in roofs.iter().enumerate() {
|
||||
// Attika ([148]): geschnittener Ringkörper, Schraffur des Bauteils.
|
||||
if let Some(pp) = crate::roof_parapet::parapet(roof, &crate::roof::roof_geometry(&roof.params(), p.roof_base_elevation(roof))) {
|
||||
let hatch = roof.parapet_component_id.as_deref().and_then(|id| p.component(id)).and_then(|comp| resolve_hatch(p, &comp.hatch_id, None, None, None));
|
||||
for pts in crate::roof_assembly::section_rings(&crate::roof_parapet::mesh(&pp), (bx, by), (ux, uy)) {
|
||||
let mut c = Cut::new(Kind::Roof, index, pts);
|
||||
if let Some(h) = &hatch {
|
||||
c.fill = Some(poche_fill(h.pattern).to_string());
|
||||
c.hatch = Some(h.clone());
|
||||
}
|
||||
cuts.push(c);
|
||||
}
|
||||
}
|
||||
// Verschnittene Dächer und Gauben ([G5]): Schnitt durch die Körper je Schicht.
|
||||
if let Some(solids) = crate::roof_assembly::roof_solids_with(p, index, &nb) {
|
||||
let rl = p.roof_layers(roof);
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
//! Attika ([148]): umlaufende Brüstung am Rand eines Flachdachs. Aus dem Traufumriss der Dachgeometrie
|
||||
//! (`roof::roof_geometry`) und den Dachfeldern `parapetHeight` / `parapetWidth` / `parapetComponentId`
|
||||
//! entsteht ein Ringkörper (aussen bündig mit dem Dachrand, nach innen `parapetWidth` breit), den 3D
|
||||
//! (`model3d::emit_roofs`), Schnitt (Schnittspur), Ansicht (Aussenflächen) und Grundriss (Innenkante) teilen.
|
||||
|
||||
use crate::model::Roof;
|
||||
use crate::model::RoofShape;
|
||||
use crate::roof::RoofGeometry;
|
||||
use crate::roof_skeleton::{clean_ring, is_simple_ring, offset_ring, point_in_ring, rings_cross, signed_area, Offset, P2, P3};
|
||||
use crate::solid_bool::Mesh;
|
||||
|
||||
/// Standardbreite der Attika (Meter).
|
||||
pub const DEFAULT_WIDTH: f64 = 0.2;
|
||||
|
||||
/// Ringkörper der Attika: Aussen- und Innenring (beide gegen den Uhrzeigersinn, Ecke i des Innenrings
|
||||
/// gehört zu Ecke i des Aussenrings), Unterkante `z0` (Dachhaut), Oberkante `z1`.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Parapet {
|
||||
pub outer: Vec<P2>,
|
||||
pub inner: Vec<P2>,
|
||||
pub z0: f64,
|
||||
pub z1: f64,
|
||||
}
|
||||
|
||||
/// Attika des Dachs, falls eine gesetzt ist (Flachdach, Höhe > 0) und der Innenring gültig ausfällt.
|
||||
/// `z0` ist die Höhe der ersten Dachfläche in `geo` (Dachhaut); ohne Fläche 0.
|
||||
pub fn parapet(roof: &Roof, geo: &RoofGeometry) -> Option<Parapet> {
|
||||
let h = roof.parapet_height.filter(|h| h.is_finite() && *h > 1e-6)?;
|
||||
if roof.shape != RoofShape::Flach {
|
||||
return None;
|
||||
}
|
||||
let w = roof.parapet_width.filter(|w| w.is_finite()).unwrap_or(DEFAULT_WIDTH).max(0.02);
|
||||
let mut outer = clean_ring(&geo.eaves);
|
||||
if outer.len() < 3 || !is_simple_ring(&outer) {
|
||||
return None;
|
||||
}
|
||||
if signed_area(&outer) < 0.0 {
|
||||
outer.reverse();
|
||||
}
|
||||
// Kurze Kanten (Spitzen, Bogenansätze) würden beim Versatz umklappen: sie werden zu einem Punkt
|
||||
// zusammengezogen, bis der Innenring gültig ist (Abweichung höchstens die Kantenlänge).
|
||||
let (outer, inner) = loop {
|
||||
if let Some(inner) = inner_ring(&outer, w) {
|
||||
break (outer, inner);
|
||||
}
|
||||
let n = outer.len();
|
||||
let len = |i: usize| (outer[(i + 1) % n][0] - outer[i][0]).hypot(outer[(i + 1) % n][1] - outer[i][1]);
|
||||
let k = (0..n).min_by(|&a, &b| len(a).total_cmp(&len(b)))?;
|
||||
if n <= 3 || len(k) >= 3.0 * w {
|
||||
return None;
|
||||
}
|
||||
let (a, b) = (outer[k], outer[(k + 1) % n]);
|
||||
outer[k] = [(a[0] + b[0]) / 2.0, (a[1] + b[1]) / 2.0];
|
||||
outer.remove((k + 1) % n);
|
||||
outer = clean_ring(&outer);
|
||||
if outer.len() < 3 {
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let z0 = geo.planes.first().and_then(|p| p.first()).map_or(0.0, |q| q[2]);
|
||||
Some(Parapet { outer, inner, z0, z1: z0 + h })
|
||||
}
|
||||
|
||||
/// Um `w` nach innen versetzter Ring (gegen den Uhrzeigersinn, Ecke i gehört zu Ecke i von `outer`);
|
||||
/// `None`, wenn das Ergebnis kein einfacher Ring innerhalb von `outer` ist.
|
||||
fn inner_ring(outer: &[P2], w: f64) -> Option<Vec<P2>> {
|
||||
// Nach innen versetzen = nach aussen am umgekehrten (Uhrzeigersinn-)Ring; danach wieder umkehren.
|
||||
let cw: Vec<P2> = outer.iter().rev().copied().collect();
|
||||
let mut inner = offset_ring(&cw, Offset::Const(w));
|
||||
inner.reverse();
|
||||
let ok = inner.len() == outer.len()
|
||||
&& inner.iter().all(|q| q[0].is_finite() && q[1].is_finite() && point_in_ring(*q, outer))
|
||||
&& is_simple_ring(&inner)
|
||||
&& signed_area(&inner) > 1e-6
|
||||
&& !rings_cross(outer, &inner);
|
||||
ok.then_some(inner)
|
||||
}
|
||||
|
||||
/// Geschlossenes Dreiecksnetz des Ringkörpers (Normalen nach aussen).
|
||||
pub fn mesh(pp: &Parapet) -> Mesh {
|
||||
let n = pp.outer.len();
|
||||
let mut positions = Vec::with_capacity(4 * n * 3);
|
||||
for (ring, z) in [(&pp.outer, pp.z0), (&pp.outer, pp.z1), (&pp.inner, pp.z0), (&pp.inner, pp.z1)] {
|
||||
for q in ring.iter() {
|
||||
positions.extend([q[0], q[1], z]);
|
||||
}
|
||||
}
|
||||
let (ob, ot, ib, it) = (0u32, n as u32, 2 * n as u32, 3 * n as u32);
|
||||
let mut indices = Vec::with_capacity(n * 24);
|
||||
for i in 0..n as u32 {
|
||||
let j = (i + 1) % n as u32;
|
||||
// Aussenwand, Oberseite, Unterseite, Innenwand.
|
||||
indices.extend([ob + i, ob + j, ot + j, ob + i, ot + j, ot + i]);
|
||||
indices.extend([ot + i, ot + j, it + j, ot + i, it + j, it + i]);
|
||||
indices.extend([ob + i, ib + j, ob + j, ob + i, ib + i, ib + j]);
|
||||
indices.extend([ib + i, it + j, ib + j, ib + i, it + i, it + j]);
|
||||
}
|
||||
Mesh { positions, indices }
|
||||
}
|
||||
|
||||
/// Sichtflächen für die Ansicht (Modellkoordinaten): Aussenwand je Kante und Oberseite je Kante.
|
||||
pub fn view_faces(pp: &Parapet) -> Vec<Vec<P3>> {
|
||||
let n = pp.outer.len();
|
||||
let mut out = Vec::with_capacity(2 * n);
|
||||
for i in 0..n {
|
||||
let j = (i + 1) % n;
|
||||
let (a, b, c, d) = (pp.outer[i], pp.outer[j], pp.inner[j], pp.inner[i]);
|
||||
out.push(vec![[a[0], a[1], pp.z0], [b[0], b[1], pp.z0], [b[0], b[1], pp.z1], [a[0], a[1], pp.z1]]);
|
||||
out.push(vec![[a[0], a[1], pp.z1], [b[0], b[1], pp.z1], [c[0], c[1], pp.z1], [d[0], d[1], pp.z1]]);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::model::Project;
|
||||
|
||||
fn project(extra: &str) -> Project {
|
||||
let roof: serde_json::Value = serde_json::from_str(&format!(
|
||||
r#"{{"id":"r1","type":"roof","floorId":"eg","categoryCode":"31","outline":[{{"x":0,"y":0}},{{"x":6,"y":0}},{{"x":6,"y":4}},{{"x":0,"y":4}}],
|
||||
"shape":"flach","pitchDeg":0,"overhang":0,"ridgeAxis":"x","thickness":0.3,"baseElevation":3 {extra}}}"#
|
||||
))
|
||||
.unwrap();
|
||||
serde_json::from_value(serde_json::json!({
|
||||
"id": "p", "name": "t", "lineStyles": [], "hatches": [], "components": [], "wallTypes": [],
|
||||
"drawingLevels": [], "layers": [], "walls": [], "drawings2d": [], "roofs": [roof]
|
||||
}))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn of(p: &Project) -> Option<Parapet> {
|
||||
let r = &p.roofs.as_ref().unwrap()[0];
|
||||
parapet(r, &crate::roof::roof_geometry(&r.params(), 3.0))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kurze_kante_am_bogenansatz_klappt_nicht_um() {
|
||||
// Wie der Erker im Musterhaus: Bogen mit kurzem Ansatzstück (0.137 m) neben der geraden Kante.
|
||||
let mut p = project(r#","parapetHeight":0.5,"parapetWidth":0.2"#);
|
||||
let r = &mut p.roofs.as_mut().unwrap()[0];
|
||||
r.outline = [[0.0, 0.0], [0.016, -0.136], [0.5, -0.04], [1.5, 0.2], [2.0, 1.0], [1.5, 1.8], [0.5, 2.04], [0.016, 2.136], [0.0, 2.0]]
|
||||
.iter()
|
||||
.map(|q| crate::model::Vec2 { x: q[0], y: q[1] })
|
||||
.collect();
|
||||
let pp = of(&p).expect("Attika trotz kurzer Kante");
|
||||
assert!(pp.inner.len() >= 6 && signed_area(&pp.inner) > 0.5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ohne_hoehe_keine_attika() {
|
||||
assert!(of(&project("")).is_none());
|
||||
assert!(of(&project(r#","parapetHeight":0"#)).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rechteck_ring() {
|
||||
let pp = of(&project(r#","parapetHeight":0.5,"parapetWidth":0.25"#)).unwrap();
|
||||
assert_eq!((pp.z0, pp.z1), (3.0, 3.5));
|
||||
let b = |r: &[P2]| r.iter().fold([f64::MAX, f64::MAX, f64::MIN, f64::MIN], |m, q| [m[0].min(q[0]), m[1].min(q[1]), m[2].max(q[0]), m[3].max(q[1])]);
|
||||
assert_eq!(b(&pp.outer), [0.0, 0.0, 6.0, 4.0]);
|
||||
let i = b(&pp.inner);
|
||||
assert!((i[0] - 0.25).abs() < 1e-9 && (i[1] - 0.25).abs() < 1e-9 && (i[2] - 5.75).abs() < 1e-9 && (i[3] - 3.75).abs() < 1e-9, "{i:?}");
|
||||
assert!(signed_area(&pp.outer) > 0.0 && signed_area(&pp.inner) > 0.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pultdach_hat_keine_attika() {
|
||||
let p = project(r#","parapetHeight":0.5"#);
|
||||
let mut r = p.roofs.as_ref().unwrap()[0].clone();
|
||||
r.shape = RoofShape::Pult;
|
||||
assert!(parapet(&r, &crate::roof::roof_geometry(&r.params(), 3.0)).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zu_breit_gibt_keine_attika() {
|
||||
assert!(of(&project(r#","parapetHeight":0.5,"parapetWidth":3"#)).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn netz_ist_geschlossen_mit_richtigem_volumen() {
|
||||
let pp = of(&project(r#","parapetHeight":0.5,"parapetWidth":0.25"#)).unwrap();
|
||||
let m = mesh(&pp);
|
||||
// Volumen über Tetraeder zum Ursprung: (6*4 - 5.5*3.5) * 0.5.
|
||||
let v: f64 = m
|
||||
.indices
|
||||
.chunks(3)
|
||||
.map(|t| {
|
||||
let q = |i: u32| [m.positions[3 * i as usize], m.positions[3 * i as usize + 1], m.positions[3 * i as usize + 2]];
|
||||
let (a, b, c) = (q(t[0]), q(t[1]), q(t[2]));
|
||||
(a[0] * (b[1] * c[2] - b[2] * c[1]) - a[1] * (b[0] * c[2] - b[2] * c[0]) + a[2] * (b[0] * c[1] - b[1] * c[0])) / 6.0
|
||||
})
|
||||
.sum();
|
||||
assert!((v - (24.0 - 5.5 * 3.5) * 0.5).abs() < 1e-9, "{v}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schnitt_durch_die_attika() {
|
||||
let pp = of(&project(r#","parapetHeight":0.5,"parapetWidth":0.25"#)).unwrap();
|
||||
// Schnitt längs x bei y = 2: zwei Streifen (links, rechts).
|
||||
let rings = crate::roof_assembly::section_rings(&mesh(&pp), (0.0, 2.0), (1.0, 0.0));
|
||||
assert_eq!(rings.len(), 2, "{rings:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn emit_roofs_und_schnitt_enthalten_die_attika() {
|
||||
use crate::plan::section::{compute_section, Kind, LevelSpec};
|
||||
let mut v = serde_json::to_value(project(r#","parapetHeight":0.5,"parapetWidth":0.25"#)).unwrap();
|
||||
v["drawingLevels"] = serde_json::json!([
|
||||
{"id": "eg", "name": "EG", "kind": "floor", "visible": true, "locked": false, "floorHeight": 3.0, "baseElevation": 0},
|
||||
{"id": "s", "name": "S", "kind": "section", "visible": true, "locked": false, "linePoints": [{"x": -2, "y": 2}, {"x": 8, "y": 2}], "directionSign": 1}
|
||||
]);
|
||||
let p: Project = serde_json::from_value(v).unwrap();
|
||||
let mut q = p.clone();
|
||||
q.roofs.as_mut().unwrap()[0].parapet_height = None;
|
||||
assert_eq!(crate::model3d::emit_roofs(&p, None).unwrap().len(), crate::model3d::emit_roofs(&q, None).unwrap().len() + 1);
|
||||
let sect = |p: &Project| {
|
||||
let l = p.drawing_levels.iter().find(|l| l.id == "s").unwrap();
|
||||
compute_section(p, &LevelSpec::from_json(&serde_json::to_value(l).unwrap()), &[]).unwrap().unwrap()
|
||||
};
|
||||
let n = |p: &Project| sect(p).cuts.iter().filter(|c| c.kind == Kind::Roof).count();
|
||||
// Zwei Streifen links und rechts zusätzlich zur Dachscheibe.
|
||||
assert_eq!(n(&p), n(&q) + 2);
|
||||
}
|
||||
}
|
||||
@@ -652,6 +652,9 @@ fn roof_selection(root: &Map<String, Value>, r: &Value) -> Result<J, String> {
|
||||
.raw("halfHipRatio", r, "halfHipRatio")
|
||||
.raw("overhang", r, "overhang")
|
||||
.raw("overhangGable", r, "overhangGable")
|
||||
.raw("parapetHeight", r, "parapetHeight")
|
||||
.raw("parapetWidth", r, "parapetWidth")
|
||||
.raw("parapetComponentId", r, "parapetComponentId")
|
||||
.raw("ridgeAxis", r, "ridgeAxis")
|
||||
.raw("thickness", r, "thickness")
|
||||
.v("baseElevation", eaves_out)
|
||||
|
||||
Reference in new issue
Block a user