[105][103][G3][106][97] Merge: Fenster/Türen-Restpunkte (Rahmendetail in der Ansicht, Türblatt im Falz, Pfostenbreite, Dachfenster-Griffe/Info/Liste, Formöffnung in der Projektion, Schnitt parallel durch die Leibung)
Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
34 files changed
+1229
-72
No files matched your search
@@ -517,7 +517,7 @@ fn shaped_fill_mesh(p: &Project, wall: &Wall, o: &Opening, c: &Cutout, base: f64
|
||||
let wall_rgb = model3d::shaped_wall_opening_meshes(p, wall, &wr, o, [c.from, c.to, c.z_bottom, c.z_top]);
|
||||
let (mut positions, mut indices) = (Vec::new(), Vec::new());
|
||||
// Die Füllkörper (Wandfarbe) gehören zur Wand, nicht zur Füllung: die Öffnung schneidet sie ohnehin nicht.
|
||||
let fills = crate::opening_shape::opening_outline(o, c.to - c.from, c.z_top - c.z_bottom).map_or(0, |poly| crate::opening_shape::fill_quads(&poly, c.to - c.from, c.z_top - c.z_bottom).len());
|
||||
let fills = model3d::shaped_fill_count(p, wall, o, c.to - c.from, c.z_top - c.z_bottom);
|
||||
for m in wall_rgb.iter().skip(fills) {
|
||||
if let Ok(b) = <[f64; 24]>::try_from(m.positions.as_slice()) {
|
||||
push_box(&mut positions, &mut indices, &b, base);
|
||||
@@ -789,8 +789,10 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
// Bogenwänden: dort bleibt das Rechteck-Loch).
|
||||
for &(k, c) in cutouts_by_wall.get(&wall.id).map_or(&[][..], |v| v.as_slice()).iter().filter(|_| arc.is_none()) {
|
||||
let o = &openings[k];
|
||||
let Some(poly) = crate::opening_shape::opening_outline(o, c.to - c.from, c.z_top - c.z_bottom) else { continue };
|
||||
let n = crate::opening_shape::fill_quads(&poly, c.to - c.from, c.z_top - c.z_bottom).len();
|
||||
let n = model3d::shaped_fill_count(&p, wall, o, c.to - c.from, c.z_top - c.z_bottom);
|
||||
if n == 0 {
|
||||
continue;
|
||||
}
|
||||
let total = p.wall_thickness(wall, 0.2);
|
||||
let wr = crate::opening_geom::WallRef {
|
||||
start: crate::opening_geom::v(wall.start.x, wall.start.y),
|
||||
|
||||
@@ -862,6 +862,7 @@ fn emit_opening_meshes_plain(p: &Project, detail: f64) -> Vec<RMesh> {
|
||||
details.extend(s4(f.ext));
|
||||
details.extend(s4(f.rebate));
|
||||
details.extend([f.sash_width, f.sash_depth, f.sash_overlap, f.mullion_width, f.transom_width, f.sill_profile, f.shading_profile, flag(dframe.is_some())]);
|
||||
details.extend(dframe.as_ref().map_or([f64::NAN; 4], |df| door_leaf_in_falz(&wr, op, df)));
|
||||
n_details += 1.0;
|
||||
}
|
||||
if let (Some(df), true) = (dframe.as_ref(), detail > 0.0) {
|
||||
@@ -913,6 +914,25 @@ fn box_mesh(positions: [f64; 24], color: Rgb) -> RMesh {
|
||||
/// Rechteck-Loch und dem Umriss, Rahmen-Ring und Glas (bzw. Türblatt) entlang des Umrisses. Rahmenlage
|
||||
/// quer zur Wand wie bei den Rechteck-Öffnungen (`openings3d::frame_normal_range`). Nicht für Formen:
|
||||
/// Anschlag, Fensterbank, Storenkasten, Flügel-/Sprossenteilung (bleiben beim Rechteck).
|
||||
/// Schichten einer Wand für die Füllkörper einer Formöffnung ([G3]): Dicke (auf `total` skaliert)
|
||||
/// und Farbe, aussen zuerst; ohne Aufbau eine Schicht in Wandfarbe.
|
||||
fn shaped_fill_bands(p: &Project, wall: &Wall, total: f64) -> Vec<(f64, Rgb)> {
|
||||
let (bands, _) = resolve_wall_bands(p, &wall_material_color_maps(p), wall, true);
|
||||
let sum: f64 = bands.iter().map(|b| b.thickness.max(0.0)).sum();
|
||||
let list: Vec<(f64, Rgb)> = bands.iter().filter(|b| b.thickness > 1e-9).map(|b| (b.thickness * total / sum, b.color)).collect();
|
||||
if list.is_empty() || !(sum > 1e-9) {
|
||||
return vec![(total, WALL_RGB)];
|
||||
}
|
||||
list
|
||||
}
|
||||
|
||||
/// Anzahl der Füllkörper (je Schicht) einer Formöffnung — sie stehen in
|
||||
/// [`shaped_wall_opening_meshes`] vor Rahmen und Glas.
|
||||
pub(crate) fn shaped_fill_count(p: &Project, wall: &Wall, op: &Opening, w: f64, h: f64) -> usize {
|
||||
let total = p.wall_thickness(wall, 0.2);
|
||||
crate::opening_shape::opening_outline(op, w, h).map_or(0, |poly| crate::opening_shape::fill_quads(&poly, w, h).len() * shaped_fill_bands(p, wall, total).len())
|
||||
}
|
||||
|
||||
pub(crate) fn shaped_wall_opening_meshes(p: &Project, wall: &Wall, wr: &WallRef, op: &Opening, [from, to, zb, zt]: [f64; 4]) -> Vec<RMesh> {
|
||||
use crate::opening_shape as os;
|
||||
let (w, h) = (to - from, zt - zb);
|
||||
@@ -931,9 +951,14 @@ pub(crate) fn shaped_wall_opening_meshes(p: &Project, wall: &Wall, wr: &WallRef,
|
||||
};
|
||||
let half = wr.total / 2.0;
|
||||
let mut out = Vec::new();
|
||||
let wall_rgb = resolve_wall_bands(p, &wall_material_color_maps(p), wall, false).0.first().map_or(WALL_RGB, |b| b.color);
|
||||
// Füllkörper je Wandschicht (aussen = +half) in deren Farbe.
|
||||
let bands = shaped_fill_bands(p, wall, wr.total);
|
||||
for q in os::fill_quads(&poly, w, h) {
|
||||
out.push(box_mesh(os::quad_box(&q, -half, half, &map), wall_rgb));
|
||||
let mut n_hi = half;
|
||||
for &(t, rgb) in &bands {
|
||||
out.push(box_mesh(os::quad_box(&q, n_hi - t, n_hi, &map), rgb));
|
||||
n_hi -= t;
|
||||
}
|
||||
}
|
||||
let door = op.kind == ElementKind::Door;
|
||||
let ty = if door {
|
||||
@@ -979,6 +1004,19 @@ pub(crate) fn shaped_wall_opening_meshes(p: &Project, wall: &Wall, wr: &WallRef,
|
||||
|
||||
/// Türzarge als Quader ([105]): Profil (Grundriss = Schnitt) an beiden Leibungen über die Höhe und
|
||||
/// am Sturz über die Breite; Ecken ohne Überlappung (Leibungsstück endet unter dem Sturzstück).
|
||||
/// Türblatt im Falz ([105]): Einzug ab Rohbaukante (seitlich, oben) und Lage quer zur Wand in der
|
||||
/// Normalen von `openings3d` (rechts der Achse, `t = −Versatz`).
|
||||
fn door_leaf_in_falz(wr: &WallRef, op: &Opening, df: &crate::opening_detail::DoorFrame) -> [f64; 4] {
|
||||
use crate::opening_detail as od;
|
||||
let innen = od::aufschlag_innen(op);
|
||||
let clear = od::profile_clear_x(&od::door_frame_profile(df, wr.total, innen));
|
||||
let x = (clear - df.falz_width).max(0.0);
|
||||
let (d0, d1) = od::leaf_band(df, wr.total, innen);
|
||||
let face = wr.ref_off - wr.total / 2.0;
|
||||
let off_of = |d: f64| face + if innen { wr.total - d } else { d };
|
||||
[x, x, -off_of(d0), -off_of(d1)]
|
||||
}
|
||||
|
||||
fn door_frame_boxes(out: &mut Vec<RMesh>, wall: &Wall, wr: &WallRef, op: &Opening, df: &crate::opening_detail::DoorFrame, (from, to, zb, zt): (f64, f64, f64, f64)) {
|
||||
use crate::opening_detail as od;
|
||||
let (u, n) = wr.frame();
|
||||
|
||||
@@ -836,4 +836,71 @@ mod tests {
|
||||
let area: f64 = r.iter().map(|q| (q[1] - q[0]) * (q[3] - q[2])).sum();
|
||||
assert!((area - 4.0).abs() < 1e-12);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tuerblatt_im_falz_der_zarge() {
|
||||
// Aufschlag innen (Vorgabe links/innen): Blatt bündig an der Innenfläche, im Falz (Einzug > 0).
|
||||
let p = wand_mit(None, Some(DoorType { id: "t".into(), frame_kind: Some(DoorTypeFrameKind::Umfassungszarge), frame_width: Some(0.06), ..Default::default() }));
|
||||
let leaf_rgb = |p: &Project| {
|
||||
let m = crate::model3d::emit_opening_meshes(p, 1.0);
|
||||
let rgb = m.iter().map(|m| m.color).collect::<Vec<_>>();
|
||||
(m, rgb)
|
||||
};
|
||||
let (m, _) = leaf_rgb(&p);
|
||||
let total = 0.345;
|
||||
let ys: Vec<f64> = m.iter().flat_map(|m| m.positions.chunks(3).map(|q| q[1]).collect::<Vec<_>>()).collect();
|
||||
// Ein Quader (das Blatt) reicht genau an eine Wandfläche (±total/2), Dicke = Falztiefe 4 cm.
|
||||
let leaf = m.iter().find(|m| {
|
||||
let y: Vec<f64> = m.positions.chunks(3).map(|q| q[1]).collect();
|
||||
let (lo, hi) = (y.iter().cloned().fold(f64::INFINITY, f64::min), y.iter().cloned().fold(f64::NEG_INFINITY, f64::max));
|
||||
((hi - total / 2.0).abs() < 1e-9 || (lo + total / 2.0).abs() < 1e-9) && ((hi - lo) - 0.04).abs() < 1e-9
|
||||
});
|
||||
assert!(leaf.is_some(), "{:?}", ys.iter().cloned().fold(f64::NEG_INFINITY, f64::max));
|
||||
let x: Vec<f64> = leaf.unwrap().positions.chunks(3).map(|q| q[0]).collect();
|
||||
let x0 = x.iter().cloned().fold(f64::INFINITY, f64::min);
|
||||
// Einbaufuge 1 cm + Blech 2 mm: Blatt ab 1.012 (Öffnung ab 1.0).
|
||||
assert!((x0 - 1.012).abs() < 1e-9, "{x0}");
|
||||
}
|
||||
|
||||
/// [G3] Füllkörper einer Formöffnung je Wandschicht (vier Schichten ⇒ viermal so viele Körper).
|
||||
#[test]
|
||||
fn formoeffnung_fuellkoerper_je_schicht() {
|
||||
let mut p = wand_mit(Some(WindowType { id: "t".into(), ..Default::default() }), None);
|
||||
for (i, c) in p.components.iter_mut().enumerate() {
|
||||
c.color = ["#ff0000", "#00ff00", "#0000ff", "#ffffff"][i].into();
|
||||
}
|
||||
p.openings.as_mut().unwrap()[0].shape = Some(OpeningShape::Rund);
|
||||
let o = p.openings.as_ref().unwrap()[0].clone();
|
||||
let poly = crate::opening_shape::opening_outline(&o, 1.2, 1.4).unwrap();
|
||||
let quads = crate::opening_shape::fill_quads(&poly, 1.2, 1.4).len();
|
||||
assert!(quads > 0);
|
||||
assert_eq!(crate::model3d::shaped_fill_count(&p, &p.walls[0], &o, 1.2, 1.4), quads * 4);
|
||||
let wr = crate::opening_geom::WallRef { start: crate::opening_geom::v(0.0, 0.0), end: crate::opening_geom::v(5.0, 0.0), total: 0.345, ref_off: 0.0 };
|
||||
let m = crate::model3d::shaped_wall_opening_meshes(&p, &p.walls[0], &wr, &o, [1.0, 2.2, 0.9, 2.3]);
|
||||
let mut colors: Vec<String> = m.iter().take(quads * 4).map(|m| format!("{:?}", m.color)).collect();
|
||||
colors.sort();
|
||||
colors.dedup();
|
||||
assert_eq!(colors.len(), 4);
|
||||
}
|
||||
|
||||
/// [106] Schnitt parallel zur Wand durch den Innenputz: Rücksprung 5 cm weitet das Loch je Seite,
|
||||
/// die Schnittfläche wird um (2 × 1.5 + 2 × 1.2) × 0.05 m² kleiner (mit Ecken) (links, rechts, oben, unten).
|
||||
#[test]
|
||||
fn schnitt_parallel_durch_die_leibung() {
|
||||
use crate::plan::section::{compute_section, Kind, LevelSpec};
|
||||
let area = |p: &Project| -> f64 {
|
||||
let l = LevelSpec { kind: "section".into(), line: Some([Vec2 { x: -1.0, y: 0.165 }, Vec2 { x: 6.0, y: 0.165 }]), ..Default::default() };
|
||||
let out = compute_section(p, &l, &[]).unwrap().unwrap();
|
||||
out.cuts.iter().filter(|c| c.kind == Kind::Wall).map(|c| {
|
||||
let n = c.pts.len();
|
||||
(0..n).map(|i| c.pts[i][0] * c.pts[(i + 1) % n][1] - c.pts[(i + 1) % n][0] * c.pts[i][1]).sum::<f64>().abs() / 2.0
|
||||
}).sum()
|
||||
};
|
||||
let plain = wand_mit(Some(WindowType { id: "t".into(), ..Default::default() }), None);
|
||||
let reveals = vec![LayerReveal { layer: -1.0, mode: RevealMode::Zurueck, amount: Some(0.05), ..Default::default() }];
|
||||
let recessed = wand_mit(Some(WindowType { id: "t".into(), layer_reveals: Some(reveals), ..Default::default() }), None);
|
||||
let (a0, a1) = (area(&plain), area(&recessed));
|
||||
assert!(a0 > 1.0, "{a0}");
|
||||
assert!((a0 - a1 - (2.0 * 1.5 + 2.0 * 1.2) * 0.05).abs() < 1e-3, "{a0} {a1}");
|
||||
}
|
||||
}
|
||||
@@ -266,8 +266,17 @@ pub fn window_symbol(
|
||||
sym.jamb_marks.push(frame_block(fw / 2.0, fw / 2.0));
|
||||
let fwe = if spec.frame_width_end.is_nan() { fw } else { max(0.01, spec.frame_width_end) };
|
||||
sym.jamb_marks.push(frame_block(axis_width - fwe / 2.0, fwe / 2.0));
|
||||
for &(si, from, to) in &segs {
|
||||
// Pfosten (fest, [105] Pfostenbreite): eigener Rahmenblock über seine Breite.
|
||||
if spec.sashes[si].post && to - from > 1e-6 {
|
||||
sym.meeting_marks.push(frame_block((from + to) / 2.0, (to - from) / 2.0));
|
||||
}
|
||||
}
|
||||
for i in 0..segs.len().saturating_sub(1) {
|
||||
let u_pos = segs[i].2;
|
||||
if spec.sashes[segs[i].0].post || spec.sashes[segs[i + 1].0].post {
|
||||
continue;
|
||||
}
|
||||
if fein {
|
||||
sym.meeting_marks.push(frame_block(u_pos - fw / 2.0, fw / 2.0));
|
||||
sym.meeting_marks.push(frame_block(u_pos + fw / 2.0, fw / 2.0));
|
||||
|
||||
@@ -15,7 +15,10 @@ pub struct OpeningScheduleRow {
|
||||
/// "door" oder "window".
|
||||
pub kind: &'static str,
|
||||
pub id: String,
|
||||
/// Wirt: Wand, bzw. Dach/Decke bei Dach-/Deckenfenstern ([103], dann `host_kind`).
|
||||
pub wall_id: String,
|
||||
/// "wall", "roof" oder "ceiling".
|
||||
pub host_kind: &'static str,
|
||||
/// Nummer: eingetragene oder automatische.
|
||||
pub mark: String,
|
||||
pub mark_auto: bool,
|
||||
@@ -112,11 +115,60 @@ fn nz(s: &Option<String>) -> String {
|
||||
s.as_deref().map(str::trim).unwrap_or("").to_string()
|
||||
}
|
||||
|
||||
/// Dach-/Deckenfenster ([103]): Geschoss und Raum vom Wirt (Raum unter dem Mittelpunkt), Dach = aussen.
|
||||
fn surface_row(p: &Project, o: &Opening) -> Option<OpeningScheduleRow> {
|
||||
if !crate::opening_shape::is_surface_hosted(o) {
|
||||
return None;
|
||||
}
|
||||
let hp = o.host_point?;
|
||||
let (host_kind, host_id, floor_id, external) = if let Some(id) = o.host_roof_id.as_deref().filter(|s| !s.is_empty()) {
|
||||
let r = p.roofs.as_deref()?.iter().find(|r| r.id == id)?;
|
||||
("roof", r.id.clone(), r.floor_id.clone(), Some(true))
|
||||
} else {
|
||||
let id = o.host_ceiling_id.as_deref()?;
|
||||
let c = p.ceilings.as_deref()?.iter().find(|c| c.id == id)?;
|
||||
("ceiling", c.id.clone(), c.floor_id.clone(), c.is_external)
|
||||
};
|
||||
let is_door = o.kind != ElementKind::Window;
|
||||
let type_name = if is_door { p.door_type(o).map(|t| t.name.clone()) } else { p.window_type(o).map(|t| t.name.clone()) }.unwrap_or_default();
|
||||
Some(OpeningScheduleRow {
|
||||
kind: if is_door { "door" } else { "window" },
|
||||
id: o.id.clone(),
|
||||
wall_id: host_id,
|
||||
host_kind,
|
||||
mark: nz(&o.mark),
|
||||
mark_auto: false,
|
||||
type_name,
|
||||
floor: p.floor(&floor_id).map_or(floor_id.clone(), |f| f.name.clone()),
|
||||
room_left: room_at(p, &floor_id, hp.x, hp.y),
|
||||
room_right: None,
|
||||
floor_id,
|
||||
width: o.width,
|
||||
height: o.height,
|
||||
clear_width: o.width,
|
||||
clear_height: o.height,
|
||||
sill: 0.0,
|
||||
hinge: None,
|
||||
swing: None,
|
||||
dir: None,
|
||||
fire_rating: nz(&o.fire_rating),
|
||||
sound_class: nz(&o.sound_class),
|
||||
u_value: o.u_value.filter(|u| *u > 0.0),
|
||||
burglary_class: nz(&o.burglary_class),
|
||||
external: o.is_external.or(external),
|
||||
notes: nz(&o.notes),
|
||||
})
|
||||
}
|
||||
|
||||
/// Alle Fenster und Türen als Tabelle: je Geschoss (Reihenfolge der Ebenen), Fenster vor Türen, dann
|
||||
/// Dokumentreihenfolge. Öffnungen ohne Wirtswand fehlen.
|
||||
pub fn opening_schedule(p: &Project) -> Vec<OpeningScheduleRow> {
|
||||
let mut rows = Vec::new();
|
||||
for o in p.openings.as_deref().unwrap_or(&[]) {
|
||||
if let Some(r) = surface_row(p, o) {
|
||||
rows.push(r);
|
||||
continue;
|
||||
}
|
||||
let Some(w) = p.walls.iter().find(|w| w.id == o.host_wall_id) else { continue };
|
||||
let is_door = o.kind != ElementKind::Window;
|
||||
let rooms = rooms_beside(p, w, o.position + o.width / 2.0);
|
||||
@@ -141,6 +193,7 @@ pub fn opening_schedule(p: &Project) -> Vec<OpeningScheduleRow> {
|
||||
kind: if is_door { "door" } else { "window" },
|
||||
id: o.id.clone(),
|
||||
wall_id: w.id.clone(),
|
||||
host_kind: "wall",
|
||||
mark: nz(&o.mark),
|
||||
mark_auto: false,
|
||||
type_name,
|
||||
@@ -173,8 +226,8 @@ pub fn opening_schedule(p: &Project) -> Vec<OpeningScheduleRow> {
|
||||
let n = count.entry((r.floor_id.clone(), r.kind)).or_insert(0);
|
||||
*n += 1;
|
||||
if r.mark.is_empty() {
|
||||
let lv = level_index(&r.floor_id);
|
||||
let lv = if lv == usize::MAX { 0 } else { lv + 1 };
|
||||
// Geschoss-Nummer unter den Geschossen (Schnitte/Ansichten zählen nicht).
|
||||
let lv = p.drawing_levels.iter().filter(|l| l.kind == DrawingLevelKind::Floor).position(|l| l.id == r.floor_id).map_or(0, |i| i + 1);
|
||||
r.mark = format!("{}{}.{:02}", if r.kind == "door" { "T" } else { "F" }, lv, n);
|
||||
r.mark_auto = true;
|
||||
}
|
||||
@@ -253,4 +306,17 @@ mod tests {
|
||||
fn leeres_projekt() {
|
||||
assert!(opening_schedule(&Project::default()).is_empty());
|
||||
}
|
||||
|
||||
/// [103] Dachfenster in der Liste: Wirt Dach, Geschoss des Dachs, aussen.
|
||||
#[test]
|
||||
fn dachfenster_in_der_liste() {
|
||||
let mut p = Project::default();
|
||||
p.drawing_levels.push(DrawingLevel { id: "dg".into(), name: "DG".into(), kind: DrawingLevelKind::Floor, ..Default::default() });
|
||||
p.roofs = Some(vec![Roof { id: "r".into(), floor_id: "dg".into(), ..Default::default() }]);
|
||||
p.openings = Some(vec![Opening { id: "df".into(), kind: ElementKind::Window, width: 0.78, height: 1.18, host_roof_id: Some("r".into()), host_point: Some(v(1.0, 1.0)), ..Default::default() }]);
|
||||
let rows = opening_schedule(&p);
|
||||
assert_eq!(rows.len(), 1);
|
||||
let r = &rows[0];
|
||||
assert_eq!((r.host_kind, r.wall_id.as_str(), r.floor.as_str(), r.external, r.mark.as_str()), ("roof", "r", "DG", Some(true), "F1.01"));
|
||||
}
|
||||
}
|
||||
@@ -467,6 +467,58 @@ pub fn surface_hole_box(o: &Opening, f: &HostFrame) -> [f64; 24] {
|
||||
quad_box(&[[0.0, 0.0], [w, 0.0], [w, h], [0.0, h]], -0.5, f.thickness + 0.5, &|u, v, n| f.at(u - w / 2.0, v - h / 2.0, n))
|
||||
}
|
||||
|
||||
/// Lage einer Dach-/Deckenöffnung für Griffe und Objekt-Info ([103], Abfrage `surfaceOpening`):
|
||||
/// Mittelpunkt, Achsen (Breite waagrecht, Höhe das Gefälle hinauf), Grundriss-Rechteck, UK/OK der
|
||||
/// Öffnung in der Fläche und der Wirt (Art, Name, Geschoss). `None` ohne Wirt.
|
||||
#[derive(Debug, Clone, serde::Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SurfaceOpeningInfo {
|
||||
pub host_kind: &'static str,
|
||||
pub host_id: String,
|
||||
pub host_name: String,
|
||||
pub floor_id: String,
|
||||
pub center: V3,
|
||||
pub ew: V3,
|
||||
pub eh: V3,
|
||||
pub corners: Vec<[f64; 2]>,
|
||||
pub z_bottom: f64,
|
||||
pub z_top: f64,
|
||||
/// Neigung der Fläche in Grad (0 = waagrecht).
|
||||
pub slope_deg: f64,
|
||||
}
|
||||
|
||||
pub fn surface_opening_info(p: &Project, id: &str) -> Option<SurfaceOpeningInfo> {
|
||||
let o = p.openings.as_deref()?.iter().find(|o| o.id == id)?;
|
||||
let f = host_frame(p, o)?;
|
||||
let (host_kind, host_id, floor_id) = match f.plane {
|
||||
Some(_) => {
|
||||
let r = p.roofs.as_deref()?.get(f.host)?;
|
||||
("roof", r.id.clone(), r.floor_id.clone())
|
||||
}
|
||||
None => {
|
||||
let c = p.ceilings.as_deref()?.get(f.host)?;
|
||||
("ceiling", c.id.clone(), c.floor_id.clone())
|
||||
}
|
||||
};
|
||||
let host_name = p.floor(&floor_id).map_or(floor_id.clone(), |l| l.name.clone());
|
||||
let rect = host_rect_plan(&f, o.width, o.height);
|
||||
let zs = rect.iter().map(|q| q[2]);
|
||||
let (z_bottom, z_top) = zs.fold((f64::INFINITY, f64::NEG_INFINITY), |(a, b), z| (a.min(z), b.max(z)));
|
||||
Some(SurfaceOpeningInfo {
|
||||
host_kind,
|
||||
host_id,
|
||||
host_name,
|
||||
floor_id,
|
||||
center: f.c,
|
||||
ew: f.ew,
|
||||
eh: f.eh,
|
||||
corners: rect.iter().map(|q| [q[0], q[1]]).collect(),
|
||||
z_bottom,
|
||||
z_top,
|
||||
slope_deg: f.n[2].clamp(-1.0, 1.0).acos().to_degrees(),
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -584,6 +636,20 @@ mod tests {
|
||||
p
|
||||
}
|
||||
|
||||
/// Abfrage `surfaceOpening`: Wirt, Neigung, Grundriss-Rechteck (Höhe projiziert = cos 45°).
|
||||
#[test]
|
||||
fn lage_fuer_griffe_und_objekt_info() {
|
||||
let p = roof_project();
|
||||
let i = surface_opening_info(&p, "D").unwrap();
|
||||
assert_eq!((i.host_kind, i.host_id.as_str()), ("roof", "R"));
|
||||
assert!((i.slope_deg - 45.0).abs() < 1e-6, "{}", i.slope_deg);
|
||||
assert!((i.z_top - i.z_bottom - 1.2 * 45f64.to_radians().sin()).abs() < 1e-9);
|
||||
let ys: Vec<f64> = i.corners.iter().map(|c| c[1]).collect();
|
||||
let span = ys.iter().cloned().fold(f64::NEG_INFINITY, f64::max) - ys.iter().cloned().fold(f64::INFINITY, f64::min);
|
||||
assert!((span - 1.2 * 45f64.to_radians().cos()).abs() < 1e-9);
|
||||
assert!(surface_opening_info(&p, "x").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dachfenster_liegt_in_der_dachflaeche() {
|
||||
let p = roof_project();
|
||||
|
||||
@@ -208,10 +208,13 @@ pub struct FrameDetailIn {
|
||||
pub shading_profile: f64,
|
||||
/// Türzarge mit eigener Zeichnung: Blendrahmen-Ring und Zargen-Umgriff entfallen.
|
||||
pub skip_frame: bool,
|
||||
/// Türblatt im Falz der Zarge: Einzug ab Rohbaukante seitlich/oben, Lage quer (`t0..t1` in der
|
||||
/// Normalen dieser Achse); NaN = bisherige Lage.
|
||||
pub leaf: [f64; 4],
|
||||
}
|
||||
|
||||
/// Anzahl Zahlen eines Anhang-Eintrags nach (Wand, Öffnung).
|
||||
pub const DETAIL_LEN: usize = 20;
|
||||
pub const DETAIL_LEN: usize = 24;
|
||||
|
||||
impl FrameDetailIn {
|
||||
fn read(r: &mut Reader) -> Option<FrameDetailIn> {
|
||||
@@ -231,6 +234,7 @@ impl FrameDetailIn {
|
||||
sill_profile: v[17],
|
||||
shading_profile: v[18],
|
||||
skip_frame: v[19] != 0.0,
|
||||
leaf: [v[20], v[21], v[22], v[23]],
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -743,12 +747,12 @@ fn frame_meshes(em: &mut Emitter, o: &OpeningIn, p: &FrameParams, detail: Detail
|
||||
while i < p.mullion_rows.min(MAX_COUNT) {
|
||||
let center = sash_bottom + i * cell;
|
||||
let mut from = sash_from;
|
||||
for post in posts.iter().copied().chain(std::iter::once(sash_to + fw / 2.0)) {
|
||||
let to = jmin(sash_to, post - fw / 2.0);
|
||||
for post in posts.iter().copied().chain(std::iter::once(sash_to + mw / 2.0)) {
|
||||
let to = jmin(sash_to, post - mw / 2.0);
|
||||
if to - from > EPS {
|
||||
em.axis_box(from, to, center - fw / 2.0, center + fw / 2.0, p.n_min, p.n_max, Part::Frame);
|
||||
em.axis_box(from, to, center - mw / 2.0, center + mw / 2.0, p.n_min, p.n_max, Part::Frame);
|
||||
}
|
||||
from = post + fw / 2.0;
|
||||
from = post + mw / 2.0;
|
||||
}
|
||||
i += 1.0;
|
||||
}
|
||||
@@ -896,10 +900,13 @@ fn glass_panes(em: &mut Emitter, o: &OpeningIn, p: &FrameParams) {
|
||||
/// Türblatt im Hauptfeld (Vollblatt bzw. blinder Rest unter der Teilverglasung, `doorLeafPanels`).
|
||||
fn door_leaf(em: &mut Emitter, o: &OpeningIn, p: &FrameParams) {
|
||||
let fw = p.frame_width;
|
||||
let leaf_from = o.from + fw;
|
||||
let leaf_to = o.to - fw;
|
||||
// [105] Blatt im Falz der Zarge (Dreh-/Pendeltür).
|
||||
let falz = o.ty.as_ref().and_then(|t| t.detail.as_deref()).map(|d| d.leaf).filter(|l| l.iter().all(|v| v.is_finite()) && (p.door_kind == 0.0 || p.door_kind == 3.0));
|
||||
let (lx, ltop) = falz.map_or((fw, fw), |l| (l[0], l[1]));
|
||||
let leaf_from = o.from + lx;
|
||||
let leaf_to = o.to - lx;
|
||||
let leaf_bottom = o.z_bottom + if p.has_sill { fw } else { 0.0 };
|
||||
let mut field_top = o.z_top - fw;
|
||||
let mut field_top = o.z_top - ltop;
|
||||
if p.transom_height > EPS {
|
||||
let split_z = clamp_range(o.z_top - p.transom_height, leaf_bottom, field_top);
|
||||
field_top = split_z - fw / 2.0;
|
||||
@@ -920,8 +927,13 @@ fn door_leaf(em: &mut Emitter, o: &OpeningIn, p: &FrameParams) {
|
||||
em.axis_box(o.from - 0.05, o.to + 0.05, o.z_bottom, leaf_top, jmin(a, b), jmax(a, b), Part::DoorLeaf);
|
||||
return;
|
||||
}
|
||||
let n1 = p.n_max - 0.02 + DOOR_LEAF_THICK / 2.0;
|
||||
let n0 = jmax(p.n_min, n1 - DOOR_LEAF_THICK);
|
||||
let (n0, n1) = match falz {
|
||||
Some(l) => (jmin(l[2], l[3]), jmax(l[2], l[3])),
|
||||
None => {
|
||||
let n1 = p.n_max - 0.02 + DOOR_LEAF_THICK / 2.0;
|
||||
(jmax(p.n_min, n1 - DOOR_LEAF_THICK), n1)
|
||||
}
|
||||
};
|
||||
if p.panelled {
|
||||
kassette(em, leaf_from, leaf_to, leaf_bottom, leaf_top, n0, n1, p);
|
||||
return;
|
||||
|
||||
@@ -257,6 +257,37 @@ struct ProjOpening {
|
||||
id: String,
|
||||
/// Formöffnung ([G3]): Rahmen-Umriss und Glas entlang des Umrisses statt der Rechtecke.
|
||||
shape: Option<(Vec<Pt>, Vec<Pt>, Vec<Vec<Pt>>, String)>,
|
||||
/// [105] Rahmen-Umriss, wenn er über die Rohbauöffnung hinausgeht (Zargenspiegel, Bekleidung).
|
||||
frame: Option<[Pt; 4]>,
|
||||
}
|
||||
|
||||
/// Türzarge in der Ansicht ([105]) von der sichtbaren Seite: `outer` = über die Rohbaukante hinaus
|
||||
/// (Spiegel, Bekleidung, Blendrahmen), `clear` = lichte Kante der Zarge, `leaf` = Blatt-Einzug.
|
||||
struct DoorBand {
|
||||
outer: f64,
|
||||
clear: f64,
|
||||
leaf: f64,
|
||||
}
|
||||
|
||||
/// Sichtbare Wandseite: +1 = rechts der Achse (Aussenseite, `layers[0]`), −1 = innen.
|
||||
fn view_side(frame: &[f64; 9], wall: &Wall) -> f64 {
|
||||
let (ax, az) = (wall.end.x - wall.start.x, wall.end.y - wall.start.y);
|
||||
let len = hypot2(ax, az).max(1e-12);
|
||||
if frame[3] * az / len - frame[5] * ax / len < 0.0 { 1.0 } else { -1.0 }
|
||||
}
|
||||
|
||||
fn door_band(df: &crate::opening_detail::DoorFrame, total: f64, o: &Opening, side: f64) -> DoorBand {
|
||||
use crate::opening_detail as od;
|
||||
let innen = od::aufschlag_innen(o);
|
||||
let prof = od::door_frame_profile(df, total, innen);
|
||||
// Aufschlagfläche sichtbar? (Aufschlag innen ⇔ Innenseite −1).
|
||||
let aufschlag = (side < 0.0) == innen;
|
||||
let touches = |poly: &[[f64; 2]]| poly.iter().any(|q| if aufschlag { q[1] <= 1e-6 } else { q[1] >= total - 1e-6 });
|
||||
let outer = prof.iter().filter(|(_, p)| touches(p)).flat_map(|(_, p)| p.iter().map(|q| -q[0])).fold(0.0, f64::max);
|
||||
let clear = od::profile_clear_x(&prof);
|
||||
// Von der Aufschlagseite liegt das Blatt vor dem Falz.
|
||||
let leaf = if aufschlag { (clear - df.falz_width).max(0.0) } else { clear };
|
||||
DoorBand { outer, clear, leaf }
|
||||
}
|
||||
|
||||
/// Umriss einer Formöffnung in Anteilen (0…1) und das um die Rahmenbreite eingerückte Glas.
|
||||
@@ -282,6 +313,7 @@ fn collect_openings(p: &Project, frame: &[f64; 9]) -> Vec<ProjOpening> {
|
||||
let mut b = vec![0.0];
|
||||
let mut ids: Vec<&str> = Vec::new();
|
||||
let mut shapes: Vec<Option<ShapeNorm>> = Vec::new();
|
||||
let mut bands: Vec<Option<DoorBand>> = Vec::new();
|
||||
let by_wall = p.openings_by_wall();
|
||||
for wall in &p.walls {
|
||||
let thickness = p.wall_type(wall).map_or(0.2, |t| t.layers.iter().fold(0.0, |s, l| s + l.thickness));
|
||||
@@ -340,6 +372,34 @@ fn collect_openings(p: &Project, frame: &[f64; 9]) -> Vec<ProjOpening> {
|
||||
_ => 0.0,
|
||||
},
|
||||
]);
|
||||
// [105] Rahmen-Detail je Seite, Anschlag je Seite, Profile, Türblatt-Einzug der Zarge.
|
||||
let det = crate::opening_detail::frame_of(p, op).filter(|f| f.detailed);
|
||||
let dframe = crate::opening_detail::door_frame_of(p, op);
|
||||
let side = view_side(frame, wall);
|
||||
let band = dframe.as_ref().map(|df| door_band(df, thickness, op, side));
|
||||
let nan = f64::NAN;
|
||||
match det.as_ref() {
|
||||
Some(f) if !door => b.extend([f.sides.left, f.sides.right, f.sides.top, f.sides.bottom]),
|
||||
_ => b.extend([nan; 4]),
|
||||
}
|
||||
match det.as_ref() {
|
||||
Some(f) => b.extend([f.rebate.left, f.rebate.right, f.rebate.top]),
|
||||
None => b.extend([nan; 3]),
|
||||
}
|
||||
match det.as_ref() {
|
||||
Some(f) if !door => b.extend([f.ext.left, f.ext.right, f.sill_profile, f.shading_profile]),
|
||||
_ => b.extend([nan; 4]),
|
||||
}
|
||||
match &band {
|
||||
Some(bd) => b.extend([bd.leaf, bd.leaf]),
|
||||
None => b.extend([nan; 2]),
|
||||
}
|
||||
if band.is_some() {
|
||||
// Zargen ohne Wandnase: der Anschlag gehört zur Zarge.
|
||||
let k = b.len() - 13 - 3;
|
||||
b[k] = 0.0;
|
||||
}
|
||||
let mullion = det.as_ref().map_or(f64::NAN, |f| f.mullion_width);
|
||||
// Flügel: (pfosten, postWidth, autoWidth, width, opening, hingeLeft).
|
||||
let mut sashes: Vec<[f64; 6]> = Vec::new();
|
||||
if !door {
|
||||
@@ -349,7 +409,7 @@ fn collect_openings(p: &Project, frame: &[f64; 9]) -> Vec<ProjOpening> {
|
||||
for s in list {
|
||||
sashes.push([
|
||||
if s.kind == SashDefKind::Pfosten { 1.0 } else { 0.0 },
|
||||
s.post_width.unwrap_or(f64::NAN),
|
||||
s.post_width.unwrap_or(mullion),
|
||||
if s.auto_width == Some(false) { 0.0 } else { 1.0 },
|
||||
s.width.unwrap_or(f64::NAN),
|
||||
s.opening.map_or(-1.0, sash_kind),
|
||||
@@ -361,6 +421,10 @@ fn collect_openings(p: &Project, frame: &[f64; 9]) -> Vec<ProjOpening> {
|
||||
let wc = if t.wing_count == 0.0 || t.wing_count.is_nan() { 1.0 } else { t.wing_count };
|
||||
let n = max(1.0, round(wc)) as usize;
|
||||
for i in 0..n {
|
||||
// [105] Pfostenbreite gesetzt: Pfosten zwischen den Flügeln.
|
||||
if i > 0 && mullion.is_finite() && mullion > 1e-4 {
|
||||
sashes.push([1.0, mullion, 1.0, f64::NAN, 0.0, 1.0]);
|
||||
}
|
||||
sashes.push([0.0, f64::NAN, 1.0, f64::NAN, sash_kind(t.kind), if i % 2 == 0 { 1.0 } else { 0.0 }]);
|
||||
}
|
||||
}
|
||||
@@ -386,6 +450,7 @@ fn collect_openings(p: &Project, frame: &[f64; 9]) -> Vec<ProjOpening> {
|
||||
]);
|
||||
}
|
||||
ids.push(&op.id);
|
||||
bands.push(band);
|
||||
shapes.push(crate::opening_shape::opening_outline(op, to - from, ot - ob).map(|poly| {
|
||||
let (w, h) = (to - from, ot - ob);
|
||||
let fw = if door { dt.and_then(|t| t.frame_width) } else { wt.and_then(|t| t.frame_width) }.unwrap_or(0.06).min(w.min(h) / 3.0);
|
||||
@@ -442,10 +507,25 @@ fn collect_openings(p: &Project, frame: &[f64; 9]) -> Vec<ProjOpening> {
|
||||
if shape.is_some() {
|
||||
// Formöffnung ([G3]): ohne Flügel-/Sprossenteilung, Türblatt und Symbole (Rechteck-Raster).
|
||||
let round = p.openings.as_deref().unwrap_or(&[]).iter().any(|o| o.id == ids[k] && !crate::opening_shape::has_flat_bottom(o));
|
||||
out.push(ProjOpening { pts, depth, glass: Vec::new(), door_leaf: Vec::new(), divisions: Vec::new(), sash_rects: Vec::new(), sill: if round { Vec::new() } else { sill }, symbol: Vec::new(), id: ids[k].to_string(), shape });
|
||||
out.push(ProjOpening { pts, depth, glass: Vec::new(), door_leaf: Vec::new(), divisions: Vec::new(), sash_rects: Vec::new(), sill: if round { Vec::new() } else { sill }, symbol: Vec::new(), id: ids[k].to_string(), shape, frame: None });
|
||||
continue;
|
||||
}
|
||||
out.push(ProjOpening { pts, depth, glass, door_leaf, divisions, sash_rects, sill, symbol, id: ids[k].to_string(), shape });
|
||||
let mut sash_rects = sash_rects;
|
||||
let mut pts_frame = None;
|
||||
if let Some(bd) = &bands[k] {
|
||||
// Zarge von dieser Seite: Spiegel/Bekleidung über die Rohbaukante hinaus, lichte Kante.
|
||||
let (w, h) = (hypot2(pts[1][0] - pts[0][0], pts[1][1] - pts[0][1]).max(1e-6), hypot2(pts[3][0] - pts[0][0], pts[3][1] - pts[0][1]).max(1e-6));
|
||||
let r = |a0: f64, a1: f64, z1: f64| [map_quad(&pts, a0, 0.0), map_quad(&pts, a1, 0.0), map_quad(&pts, a1, z1), map_quad(&pts, a0, z1)];
|
||||
if bd.outer > 1e-4 {
|
||||
pts_frame = Some(r(-bd.outer / w, 1.0 + bd.outer / w, 1.0 + bd.outer / h));
|
||||
// Rohbaukante unter dem Spiegel/der Bekleidung.
|
||||
sash_rects.push(r(0.0, 1.0, 1.0));
|
||||
}
|
||||
if bd.clear > 1e-4 && bd.clear < bd.leaf - 1e-4 {
|
||||
sash_rects.push(r(bd.clear / w, 1.0 - bd.clear / w, 1.0 - bd.clear / h));
|
||||
}
|
||||
}
|
||||
out.push(ProjOpening { pts, depth, glass, door_leaf, divisions, sash_rects, sill, symbol, id: ids[k].to_string(), shape, frame: pts_frame });
|
||||
}
|
||||
surface_openings(p, frame, &mut out);
|
||||
out
|
||||
@@ -484,7 +564,7 @@ fn surface_openings(p: &Project, frame: &[f64; 9], out: &mut Vec<ProjOpening>) {
|
||||
});
|
||||
let depth = plane_depth.map_or(own, |d| d.min(own));
|
||||
let glass = if o.kind == ElementKind::Window { vec![quad(fw).0] } else { Vec::new() };
|
||||
out.push(ProjOpening { pts, depth, glass, door_leaf: Vec::new(), divisions: Vec::new(), sash_rects: Vec::new(), sill: Vec::new(), symbol: Vec::new(), id: o.id.clone(), shape: None });
|
||||
out.push(ProjOpening { pts, depth, glass, door_leaf: Vec::new(), divisions: Vec::new(), sash_rects: Vec::new(), sill: Vec::new(), symbol: Vec::new(), id: o.id.clone(), shape: None, frame: None });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,7 +919,7 @@ pub fn elevation_primitives(p: &Project, level: &LevelSpec, shadows: bool, mono:
|
||||
items.push(Item { depth: d, seq, rank: None, prim });
|
||||
seq += 1;
|
||||
};
|
||||
let frame_pts = op.shape.as_ref().map_or(&op.pts[..], |(o, _, _, _)| &o[..]);
|
||||
let frame_pts = op.shape.as_ref().map_or(op.frame.as_ref().map_or(&op.pts[..], |f| &f[..]), |(o, _, _, _)| &o[..]);
|
||||
push(poly_prim(to_vec(frame_pts), if mono { "#ffffff" } else { FRAME_FILL_COLOR }, EDGE_INK, FRAME_MM, id));
|
||||
if let Some((_, g, _, _)) = &op.shape {
|
||||
push(poly_prim(to_vec(g), if mono { GLASS_FILL_MONO } else { GLASS_FILL_COLOR }, EDGE_INK, EDGE_MM, id));
|
||||
@@ -1169,4 +1249,35 @@ mod tests {
|
||||
let last_roof = prims.iter().rposition(|pr| matches!(pr, Primitive::Polygon { roof_id: Some(_), .. })).unwrap();
|
||||
assert!(first_df > last_roof, "Dachfenster vor der Dachfläche gezeichnet");
|
||||
}
|
||||
|
||||
/// [105] Umfassungszarge in der Ansicht: Spiegel über die Rohbaukante hinaus (Rahmen breiter als
|
||||
/// die Öffnung), Blatt um die Zarge eingerückt.
|
||||
#[test]
|
||||
fn zargenspiegel_in_der_ansicht() {
|
||||
let mut p = sample();
|
||||
let o1 = p.openings.iter().flatten().find(|o| o.id == "O1").unwrap().clone();
|
||||
let frame_w = |p: &Project| -> f64 {
|
||||
let l = p.drawing_levels.iter().find(|l| l.id == "ansicht-sued").unwrap();
|
||||
let level = LevelSpec::from_json(&serde_json::to_value(l).unwrap());
|
||||
let (prims, _) = elevation_primitives(p, &level, false, false, &Visibility::default(), 100.0).unwrap().unwrap();
|
||||
let pr = prims.iter().find(|pr| matches!(pr, Primitive::Polygon { opening_id: Some(o), .. } if o == "O1")).unwrap();
|
||||
let Primitive::Polygon { pts, .. } = pr else { unreachable!() };
|
||||
pts.iter().map(|q| q.x).fold(f64::NEG_INFINITY, f64::max) - pts.iter().map(|q| q.x).fold(f64::INFINITY, f64::min)
|
||||
};
|
||||
let door = |kind: Option<DoorTypeFrameKind>| {
|
||||
let mut q = p.clone();
|
||||
q.door_types = Some(vec![DoorType { id: "dt".into(), frame_kind: kind, ..Default::default() }]);
|
||||
for o in q.openings.iter_mut().flatten().filter(|o| o.id == "O1") {
|
||||
o.kind = ElementKind::Door;
|
||||
o.type_id = Some("dt".into());
|
||||
o.sill_height = 0.0;
|
||||
}
|
||||
q
|
||||
};
|
||||
let plain = frame_w(&door(None));
|
||||
assert!((plain - o1.width).abs() < 1e-6, "{plain}");
|
||||
let zarge = frame_w(&door(Some(DoorTypeFrameKind::Umfassungszarge)));
|
||||
assert!((zarge - o1.width - 0.1).abs() < 1e-6, "{zarge}");
|
||||
p.openings = None;
|
||||
}
|
||||
}
|
||||
@@ -940,6 +940,68 @@ fn shaped_wall_cuts(cuts: &mut [Cut], p: &Project, walls_r: &[RWall], base: (f64
|
||||
}
|
||||
}
|
||||
|
||||
/// Formöffnungen ([G3]) hinter der Schnittebene: die Wand trägt im Modell das Rechteck-Loch, die
|
||||
/// Projektion zeigt aber den Umriss — Kanten der Wand im Loch-Rechteck fallen weg, der Umriss auf der
|
||||
/// zugewandten Wandfläche kommt dazu.
|
||||
fn shaped_projection(visible: &mut Vec<Edge>, p: &Project, walls_r: &[RWall], plane: &Plane) {
|
||||
let (base, u) = (plane.base(), plane.u_model());
|
||||
let ul = hypot2(u.0, u.1);
|
||||
if !(ul > 1e-12) {
|
||||
return;
|
||||
}
|
||||
let u = (u.0 / ul, u.1 / ul);
|
||||
let nrm = (plane.normal[0], plane.normal[2]);
|
||||
for o in p.openings.as_deref().unwrap_or(&[]).iter().filter(|o| crate::opening_shape::is_shaped(o)) {
|
||||
let Some(wall) = p.walls.iter().find(|w| w.id == o.host_wall_id) else { continue };
|
||||
let owners: Vec<usize> = walls_r.iter().enumerate().filter(|(_, w)| w.wall_id == wall.id).map(|(i, _)| i).collect();
|
||||
if owners.is_empty() || !visible.iter().any(|e| e.kind == Kind::Wall && owners.contains(&e.index)) {
|
||||
continue;
|
||||
}
|
||||
let Some((from, to)) = opening_interval(wall, o) else { continue };
|
||||
let (a, n) = axis_frame(wall);
|
||||
if (a.0 * u.0 + a.1 * u.1).abs() < 0.05 {
|
||||
continue;
|
||||
}
|
||||
let (zb, zt) = opening_extent(p, wall, o);
|
||||
let Some(poly) = crate::opening_shape::opening_outline(o, to - from, zt - zb) else { continue };
|
||||
let total = sum_thickness(&p.wall_type_or_fallback(wall).layers);
|
||||
let ref_off = crate::joins::reference_offset(model3d::wall_reference(wall), total);
|
||||
let at = |s: f64, off: f64| (wall.start.x + a.0 * s + n.0 * off, wall.start.y + a.1 * s + n.1 * off);
|
||||
let uu = |q: (f64, f64)| (q.0 - base.0) * u.0 + (q.1 - base.1) * u.1;
|
||||
let depth = |q: (f64, f64)| (q.0 - base.0) * nrm.0 + (q.1 - base.1) * nrm.1;
|
||||
let faces = [ref_off - total / 2.0, ref_off + total / 2.0];
|
||||
let us: Vec<f64> = faces.iter().flat_map(|&f| [uu(at(from, f)), uu(at(to, f))]).collect();
|
||||
let (u_lo, u_hi) = us.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |(l, h), &x| (l.min(x), h.max(x)));
|
||||
const TOL: f64 = 1e-3;
|
||||
let inside = |q: [f64; 2]| q[0] >= u_lo - TOL && q[0] <= u_hi + TOL && q[1] >= zb - TOL && q[1] <= zt + TOL;
|
||||
visible.retain(|e| !(e.kind == Kind::Wall && owners.contains(&e.index) && inside(e.a) && inside(e.b)));
|
||||
// Senkrechte Stösse der Wandstücke neben dem Loch: der Teil auf Öffnungshöhe entfällt (dort
|
||||
// liegt der Umriss bzw. die durchgehende Wand).
|
||||
let mut split: Vec<Edge> = Vec::new();
|
||||
for e in visible.iter_mut().filter(|e| e.kind == Kind::Wall && owners.contains(&e.index) && (e.a[0] - e.b[0]).abs() < TOL && e.a[0] >= u_lo - TOL && e.a[0] <= u_hi + TOL) {
|
||||
let (lo, hi) = (e.a[1].min(e.b[1]), e.a[1].max(e.b[1]));
|
||||
if hi <= zb + TOL || lo >= zt - TOL {
|
||||
continue;
|
||||
}
|
||||
let x = e.a[0];
|
||||
if hi > zt + TOL {
|
||||
split.push(Edge { kind: e.kind, index: e.index, a: [x, zt], b: [x, hi] });
|
||||
}
|
||||
// Rest unten (oder leer: Länge 0 wird unten entfernt).
|
||||
(e.a, e.b) = ([x, lo], [x, lo.max(zb.min(hi))]);
|
||||
}
|
||||
visible.retain(|e| (e.a[0] - e.b[0]).abs() + (e.a[1] - e.b[1]).abs() > 1e-9);
|
||||
visible.extend(split);
|
||||
// Zugewandte Fläche: kleinere Tiefe hinter der Ebene.
|
||||
let mid = (from + to) / 2.0;
|
||||
let near = if depth(at(mid, faces[0])) <= depth(at(mid, faces[1])) { faces[0] } else { faces[1] };
|
||||
let pts: Vec<[f64; 2]> = poly.iter().map(|q| [uu(at(from + q[0], near)), zb + q[1]]).collect();
|
||||
for i in 0..pts.len() {
|
||||
visible.push(Edge { kind: Kind::Wall, index: owners[0], a: pts[i], b: pts[(i + 1) % pts.len()] });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn append_roof_sections(cuts: &mut Vec<Cut>, p: &Project, plane: &Plane) {
|
||||
let roofs = p.roofs.as_deref().unwrap_or(&[]);
|
||||
if roofs.is_empty() {
|
||||
@@ -1061,6 +1123,129 @@ fn is_void_solid(s: &ExtrudedSolid) -> bool {
|
||||
s.operation.as_deref() == Some("subtract") && s.brep.is_none() && s.taper.unwrap_or(0.0) < 1e-6 && s.points.len() >= 3 && s.height > 0.0
|
||||
}
|
||||
|
||||
/// [106] Schnitt parallel zur Wand durch die Leibungen: Die geschnittene Schicht springt an den
|
||||
/// Öffnungen um ihren Rücksprung zurück (Loch geweitet), ihre Zusatzstücke (Leibungsdämmung, Putz,
|
||||
/// Überdämmung), die die Schnittebene quert, kommen als Schnittfläche im Stil der Schicht dazu.
|
||||
fn parallel_reveal_cuts(mut cuts: Vec<Cut>, p: &Project, plane: &Plane, walls: &[Option<&Wall>]) -> Result<Vec<Cut>, String> {
|
||||
use crate::opening_detail::SIDES;
|
||||
let (base, u_raw) = (plane.base(), plane.u_model());
|
||||
let l = hypot2(u_raw.0, u_raw.1);
|
||||
if !(l > 1e-12) {
|
||||
return Ok(cuts);
|
||||
}
|
||||
let u = (u_raw.0 / l, u_raw.1 / l);
|
||||
let mut seen: Vec<&str> = Vec::new();
|
||||
for w in walls.iter().flatten() {
|
||||
if seen.contains(&w.id.as_str()) {
|
||||
continue;
|
||||
}
|
||||
seen.push(&w.id);
|
||||
let (a, n) = axis_frame(w);
|
||||
let (un, ua) = (u.0 * n.0 + u.1 * n.1, u.0 * a.0 + u.1 * a.1);
|
||||
if un.abs() > 0.05 || ua.abs() < 0.5 {
|
||||
continue;
|
||||
}
|
||||
let Some(wt) = p.wall_type(w) else { continue };
|
||||
let total = sum_thickness(&wt.layers);
|
||||
let ref_off = crate::joins::reference_offset(model3d::wall_reference(w), total);
|
||||
let rel = (base.0 - w.start.x, base.1 - w.start.y);
|
||||
let d = rel.0 * n.0 + rel.1 * n.1 - (ref_off - total / 2.0);
|
||||
if d <= 1e-6 || d >= total - 1e-6 {
|
||||
continue;
|
||||
}
|
||||
let mut acc = 0.0;
|
||||
let Some(li) = wt.layers.iter().position(|ly| {
|
||||
acc += ly.thickness;
|
||||
d < acc
|
||||
}) else {
|
||||
continue;
|
||||
};
|
||||
let a0 = rel.0 * a.0 + rel.1 * a.1;
|
||||
let u_of = |s: f64| (s - a0) / ua;
|
||||
let owners: Vec<usize> = walls.iter().enumerate().filter(|(_, x)| x.is_some_and(|x| x.id == w.id)).map(|(i, _)| i).collect();
|
||||
let mut voids: Vec<Vec<[f64; 2]>> = Vec::new();
|
||||
let mut pieces: Vec<Vec<[f64; 2]>> = Vec::new();
|
||||
let rect = |s0: f64, s1: f64, z0: f64, z1: f64| {
|
||||
let (ua, ub) = (u_of(s0).min(u_of(s1)), u_of(s0).max(u_of(s1)));
|
||||
vec![[ua, z0], [ub, z0], [ub, z1], [ua, z1]]
|
||||
};
|
||||
for o in p.openings_of_wall(&w.id) {
|
||||
let Some(r) = crate::opening_detail::opening_reveal(p, w, o) else { continue };
|
||||
let (zb, zt) = opening_extent(p, w, o);
|
||||
// Rücksprung je Seite dieser Schicht; die seitlichen reichen in die Ecken oben/unten.
|
||||
let sh: Vec<f64> = (0..4).map(|k| r.sides[k].iter().filter(|x| x.layer == li).map(|x| x.shift).fold(0.0, f64::max)).collect();
|
||||
for (k, side) in SIDES.iter().enumerate() {
|
||||
for adj in r.sides[k].iter().filter(|x| x.layer == li) {
|
||||
let s = adj.shift;
|
||||
if s > 1e-6 {
|
||||
voids.push(match side {
|
||||
crate::opening_detail::Side::Left => rect(r.from - s, r.from, zb - sh[3], zt + sh[2]),
|
||||
crate::opening_detail::Side::Right => rect(r.to, r.to + s, zb - sh[3], zt + sh[2]),
|
||||
crate::opening_detail::Side::Top => rect(r.from, r.to, zt, zt + s),
|
||||
crate::opening_detail::Side::Bottom => rect(r.from, r.to, zb - s, zb),
|
||||
});
|
||||
}
|
||||
for pc in adj.pieces.iter().filter(|pc| d >= pc[2] - 1e-9 && d <= pc[3] + 1e-9 && pc[1] - pc[0] > 1e-6) {
|
||||
pieces.push(match side {
|
||||
crate::opening_detail::Side::Left => rect(r.from + pc[0], r.from + pc[1], zb, zt),
|
||||
crate::opening_detail::Side::Right => rect(r.to - pc[1], r.to - pc[0], zb, zt),
|
||||
crate::opening_detail::Side::Top => rect(r.from, r.to, zt - pc[1], zt - pc[0]),
|
||||
crate::opening_detail::Side::Bottom => rect(r.from, r.to, zb + pc[0], zb + pc[1]),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if voids.is_empty() && pieces.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if !voids.is_empty() {
|
||||
let refs: Vec<&[[f64; 2]]> = voids.iter().map(|r| r.as_slice()).collect();
|
||||
let cutters = encode_rings(&refs);
|
||||
let mut out = Vec::with_capacity(cuts.len());
|
||||
for cp in cuts {
|
||||
if cp.kind != Kind::Wall || !owners.contains(&cp.index) || cp.pts.len() < 3 {
|
||||
out.push(cp);
|
||||
continue;
|
||||
}
|
||||
let ring = &encode_rings(&[cp.pts.as_slice()])[1..];
|
||||
let f = crate::voids::subtract_rings_flat(ring, &cutters, &[0.0]);
|
||||
if f.is_empty() || f[0] < 0.0 {
|
||||
out.push(cp);
|
||||
continue;
|
||||
}
|
||||
let mut i = 1;
|
||||
for _ in 0..f[0] as usize {
|
||||
let k = f[i] as usize;
|
||||
i += 1;
|
||||
let pts: Vec<[f64; 2]> = (0..k).map(|j| [f[i + 2 * j], f[i + 2 * j + 1]]).collect();
|
||||
i += 2 * k;
|
||||
let m = f[i] as usize;
|
||||
i += 1 + m;
|
||||
out.push(Cut { pts, nse: None, ..cp.clone() });
|
||||
}
|
||||
}
|
||||
cuts = out;
|
||||
}
|
||||
let Some(&idx) = owners.first() else { continue };
|
||||
let layer = &wt.layers[li];
|
||||
let comp = p.component_or_fallback(&layer.component_id);
|
||||
let category = p.layer_category(&w.category_code);
|
||||
let (fill, hatch) = layer_style(p, comp, w.hatch_id.as_deref(), w.hatch_source, w.foreground.as_deref(), w.foreground_source, w.background.as_deref(), w.background_source, category, SECTION_WALL_AXIS_ANGLE_DEG)?;
|
||||
for pts in pieces {
|
||||
let mut c = Cut::new(Kind::Wall, idx, pts);
|
||||
c.fill = Some(fill.clone());
|
||||
c.hatch = Some(hatch.clone());
|
||||
c.join_priority = Some(comp.join_priority);
|
||||
c.component_id = Some(comp.id.clone());
|
||||
c.source_id = Some(w.id.clone());
|
||||
c.category = Some(w.category_code.clone());
|
||||
cuts.push(c);
|
||||
}
|
||||
}
|
||||
Ok(cuts)
|
||||
}
|
||||
|
||||
fn encode_rings(rings: &[&[[f64; 2]]]) -> Vec<f64> {
|
||||
let mut b = vec![rings.len() as f64];
|
||||
for r in rings {
|
||||
@@ -1365,6 +1550,8 @@ pub fn compute_section(p: &Project, level: &LevelSpec, bodies: &[BodyMesh]) -> R
|
||||
|
||||
shaped_wall_cuts(&mut cuts, p, &walls_r, plane.base(), plane.u_model());
|
||||
let mut cuts = merge_arc_wall_cuts(cuts, p, &walls_r);
|
||||
let mut visible = visible;
|
||||
shaped_projection(&mut visible, p, &walls_r, &plane);
|
||||
append_roof_sections(&mut cuts, p, &plane);
|
||||
let owners = wall_owners(p, &walls_r);
|
||||
// Bogenwand ([T2]): Schichtfolge quer zum Schnitt aus der Richtung des Sehnen-Teilkörpers.
|
||||
@@ -1381,7 +1568,8 @@ pub fn compute_section(p: &Project, level: &LevelSpec, bodies: &[BodyMesh]) -> R
|
||||
let cuts = merge_monolith_cuts(cuts, &slabs_r);
|
||||
let base = plane.base();
|
||||
let u = plane.u_model();
|
||||
let mut cuts = subtract_voids_in_section(cuts, p, base, u);
|
||||
let cuts = subtract_voids_in_section(cuts, p, base, u);
|
||||
let mut cuts = parallel_reveal_cuts(cuts, p, &plane, &walls)?;
|
||||
append_body_sections(&mut cuts, p, bodies, base, u);
|
||||
let mut out = Output { cuts, visible, hidden, profiles: Vec::new() };
|
||||
append_terrain_profiles(&mut out, p, base, u);
|
||||
@@ -1722,6 +1910,28 @@ fn window_cut(p: &Project, wall: &Wall, o: &Opening, c: &CrossSection) -> Result
|
||||
}
|
||||
out.push(l);
|
||||
}
|
||||
// [105] Kämpfer (Oberlicht) und waagrechte Sprossen-Riegel geschnitten, in ihrer Breite.
|
||||
if let Some(t) = wt.filter(|_| !crate::opening_shape::is_shaped(o)) {
|
||||
let (lo, hi) = (zb0 + fwb, zt0 - fwt);
|
||||
let tw = det.as_ref().map(|f| f.transom_width).filter(|v| v.is_finite()).unwrap_or(fw);
|
||||
let mw = det.as_ref().map(|f| f.mullion_width).filter(|v| v.is_finite()).unwrap_or(fw);
|
||||
let mut bars: Vec<(f64, f64)> = Vec::new();
|
||||
let mut top = hi;
|
||||
let tr = t.transom_height.unwrap_or(0.0);
|
||||
if tr > 1e-4 && c.z_top - tr > lo + tw && c.z_top - tr < hi - tw / 2.0 {
|
||||
let z = c.z_top - tr;
|
||||
bars.push((z - tw / 2.0, z + tw / 2.0));
|
||||
top = z - tw / 2.0;
|
||||
}
|
||||
let rows = t.mullion_rows.unwrap_or(1.0).round().clamp(1.0, 20.0) as usize;
|
||||
for r in 1..rows {
|
||||
let z = lo + (top - lo) * r as f64 / rows as f64;
|
||||
bars.push((z - mw / 2.0, z + mw / 2.0));
|
||||
}
|
||||
for (z0, z1) in bars {
|
||||
out.push(opening_poly(rect(u0, u1, z0, z1), true, &o.id));
|
||||
}
|
||||
}
|
||||
if let Some(t) = wt {
|
||||
// Formöffnung ([G3]): kein Sturz-Querschnitt, kein Storenkasten (Bogen/Schräge statt Sturz).
|
||||
let shaped = crate::opening_shape::is_shaped(o);
|
||||
@@ -2129,6 +2339,32 @@ mod tests {
|
||||
assert!(!ys.is_empty() && ys.iter().all(|y| *y < want + 5e-3), "kein Sturz/Kasten über dem Bogen: {ys:?}");
|
||||
}
|
||||
|
||||
/// [G3] Projektion hinter der Schnittebene: Rundfenster zeigt den Umriss statt des Rechteck-Lochs.
|
||||
#[test]
|
||||
fn formoeffnung_in_der_projektion() {
|
||||
let mut p = sample();
|
||||
let o1 = p.openings.as_deref().unwrap().iter().find(|o| o.id == "O1").unwrap().clone();
|
||||
let w1 = p.walls.iter().find(|w| w.id == o1.host_wall_id).unwrap().clone();
|
||||
let (u, n) = axis_frame(&w1);
|
||||
let edges_of = |p: &Project, sign: f64| -> usize {
|
||||
let (a, b) = ((w1.start.x + n.0 * sign * 1.5, w1.start.y + n.1 * sign * 1.5), (w1.end.x + n.0 * sign * 1.5, w1.end.y + n.1 * sign * 1.5));
|
||||
let mut best = 0;
|
||||
for (s, e) in [(a, b), (b, a)] {
|
||||
let l = LevelSpec { kind: "section".into(), line: Some([Vec2 { x: s.0 - u.0, y: s.1 - u.1 }, Vec2 { x: e.0 + u.0, y: e.1 + u.1 }]), ..Default::default() };
|
||||
let out = compute_section(p, &l, &[]).unwrap().unwrap();
|
||||
let (zb, zt) = opening_extent(p, &w1, &o1);
|
||||
best = best.max(out.visible.iter().filter(|e| e.kind == Kind::Wall && e.a[1] > zb + 0.01 && e.a[1] < zt - 0.01 && e.b[1] > zb + 0.01 && e.b[1] < zt - 0.01).count());
|
||||
}
|
||||
best
|
||||
};
|
||||
let rect = edges_of(&p, 1.0).max(edges_of(&p, -1.0));
|
||||
for o in p.openings.iter_mut().flatten().filter(|o| o.id == "O1") {
|
||||
o.shape = Some(OpeningShape::Rund);
|
||||
}
|
||||
let round = edges_of(&p, 1.0).max(edges_of(&p, -1.0));
|
||||
assert!(round >= rect + 20, "Umriss als Kantenzug: {rect} → {round}");
|
||||
}
|
||||
|
||||
/// [103] Dachfenster: Lücke in allen Dachschichten, Rahmen/Glas geschnitten.
|
||||
#[test]
|
||||
fn dachfenster_im_schnitt() {
|
||||
|
||||
@@ -301,7 +301,7 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
|
||||
let wt = if door { None } else { window_type(p, o) };
|
||||
// Rahmenband nur bei Türen mit Typ (Fenster zeichnen es selbst).
|
||||
let dt = if door { door_type(p, o) } else { None };
|
||||
let sash_list = wt.map(sashes).unwrap_or_default();
|
||||
let mut sash_list = wt.map(sashes).unwrap_or_default();
|
||||
let stroke = color.unwrap_or(POCHE_STROKE);
|
||||
let frame_color = o.frame_line.as_ref().and_then(|l| l.color.as_deref()).unwrap_or(stroke);
|
||||
let frame_weight = o.frame_line.as_ref().and_then(|l| l.weight).unwrap_or(lw);
|
||||
@@ -325,6 +325,32 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
|
||||
let dframe = crate::opening_detail::door_frame_of(p, o);
|
||||
// Verbreiterungsprofile: das Fenster-Element sitzt um sie eingerückt in der Rohbauöffnung.
|
||||
let (ext_l, ext_r) = det.as_ref().filter(|_| !door).map_or((0.0, 0.0), |f| (f.ext.left, f.ext.right));
|
||||
// [105] Pfostenbreite: Pfosten ohne eigene Breite und (bei Flügeln aus der Flügelzahl) Pfosten
|
||||
// zwischen den Flügeln wie im 3D.
|
||||
let mullion = det.as_ref().map_or(f64::NAN, |f| f.mullion_width);
|
||||
if mullion.is_finite() && mullion > 1e-4 {
|
||||
let from_count = wt.is_some_and(|t| t.sashes.as_ref().is_none_or(|s| s.is_empty()));
|
||||
let mut list = Vec::with_capacity(sash_list.len() * 2);
|
||||
for (i, mut s) in sash_list.into_iter().enumerate() {
|
||||
if s.kind == SashDefKind::Pfosten && s.post_width.is_none() {
|
||||
s.post_width = Some(mullion);
|
||||
}
|
||||
if from_count && i > 0 {
|
||||
list.push(SashDef { kind: SashDefKind::Pfosten, post_width: Some(mullion), ..Default::default() });
|
||||
}
|
||||
list.push(s);
|
||||
}
|
||||
sash_list = list;
|
||||
}
|
||||
// [105] Türblatt im Falz der Zarge: Drehpunkt an der Falzkante, auf der Aufschlagfläche des Blatts.
|
||||
let hinge = dframe.as_ref().filter(|_| dt.is_some_and(|t| matches!(t.kind, DoorTypeKind::Dreh | DoorTypeKind::Pendel | DoorTypeKind::Unknown))).map(|df| {
|
||||
use crate::opening_detail as od;
|
||||
let innen = od::aufschlag_innen(o);
|
||||
let clear = od::profile_clear_x(&od::door_frame_profile(df, total, innen));
|
||||
let (d0, _) = od::leaf_band(df, total, innen);
|
||||
let off = ref_off - total / 2.0 + if innen { total - d0 } else { d0 };
|
||||
((clear - df.falz_width).max(0.0), off)
|
||||
});
|
||||
let (o_pos, o_wid) = if ext_l + ext_r > 1e-6 && o.width - ext_l - ext_r > 0.05 { (o.position + ext_l, o.width - ext_l - ext_r) } else { (o.position, o.width) };
|
||||
let mut b: Vec<f64> = vec![w.start.x, w.start.y, w.end.x, w.end.y, total, ref_off, o_pos, o_wid, b01(door), detail_code];
|
||||
// Tür
|
||||
@@ -439,10 +465,9 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
|
||||
b01(s.opening.is_some_and(|k| k != OpeningKind::Fest)),
|
||||
]);
|
||||
}
|
||||
// [105] Anhang: Rahmenbreite rechts (Fenster).
|
||||
if let Some(f) = det.as_ref().filter(|f| wt.is_some() && (f.sides.right - f.sides.left).abs() > 1e-9) {
|
||||
b.push(f.sides.right);
|
||||
}
|
||||
// [105] Anhang: Rahmenbreite rechts (Fenster), Drehpunkt des Türblatts im Falz (Einzug, Versatz).
|
||||
b.push(det.as_ref().filter(|f| wt.is_some() && (f.sides.right - f.sides.left).abs() > 1e-9).map_or(f64::NAN, |f| f.sides.right));
|
||||
b.extend(hinge.map_or([f64::NAN; 2], |(x, off)| [x, off]));
|
||||
let f = crate::plan_openings::plan_opening(&b);
|
||||
if f.is_empty() {
|
||||
return Ok(());
|
||||
|
||||
@@ -856,8 +856,11 @@ fn rect(q: &Quad, fa0: f64, fa1: f64, fz0: f64, fz1: f64) -> Quad {
|
||||
[quad_at(q, fa0, fz0), quad_at(q, fa1, fz0), quad_at(q, fa1, fz1), quad_at(q, fa0, fz1)]
|
||||
}
|
||||
|
||||
/// Feste Werte je Öffnung vor der Flügelliste (der letzte = Flügelzahl).
|
||||
const REC: usize = 22;
|
||||
/// Feste Werte je Öffnung vor der Flügelliste (der letzte = Flügelzahl). Ab Index 21 ([105], NaN =
|
||||
/// Vorgabe): Rahmenbreite links/rechts/oben/unten (sonst `o[12]`), Anschlag links/rechts/oben (sonst
|
||||
/// `o[18]`), Verbreiterungsprofil links/rechts, Fensterbank-/Storen-Anschlussprofil (0 = keins),
|
||||
/// Türblatt-Einzug ab Rohbaukante seitlich/oben (sonst 4 % der Breite bzw. 3 % der Höhe).
|
||||
const REC: usize = 35;
|
||||
|
||||
/// Projiziert die zum Betrachter zeigende Wand-Langseite der Öffnung; `None` ohne sichtbare Seite.
|
||||
fn project_opening_rect(f: &Frame, o: &[f64]) -> Option<(Quad, f64)> {
|
||||
@@ -905,8 +908,8 @@ fn project_opening_side(f: &Frame, o: &[f64]) -> Option<(Quad, f64, f64)> {
|
||||
|
||||
/// Flügel/Pfosten eines Feldbands `fz..field_top` (Anteile der Öffnungshöhe) über die lichte Breite.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn sash_band(out: &mut OpeningOut, o: &[f64], sashes: &[f64], pts: &Quad, w: f64, h: f64, fa: f64, fw: f64, fz: f64, field_top: f64, rows_in: f64, cols_in: f64) {
|
||||
let inner_w = max(1e-6, w * (1.0 - 2.0 * fa));
|
||||
fn sash_band(out: &mut OpeningOut, o: &[f64], sashes: &[f64], pts: &Quad, w: f64, h: f64, (fa, fa_end): (f64, f64), fw: f64, fz: f64, field_top: f64, rows_in: f64, cols_in: f64) {
|
||||
let inner_w = max(1e-6, w * (fa_end - fa));
|
||||
let n_sashes = sashes.len() / 6;
|
||||
let sash = |k: usize| &sashes[6 * k..6 * k + 6];
|
||||
let (mut fixed_sum, mut auto_count) = (0.0, 0usize);
|
||||
@@ -977,7 +980,7 @@ fn sash_band(out: &mut OpeningOut, o: &[f64], sashes: &[f64], pts: &Quad, w: f64
|
||||
out.divisions.push((quad_at(pts, ca, gz0), quad_at(pts, ca, gz1)));
|
||||
}
|
||||
}
|
||||
if fa1 < 1.0 - fa - 1e-6 {
|
||||
if fa1 < fa_end - 1e-6 {
|
||||
out.divisions.push((quad_at(pts, fa1, fz), quad_at(pts, fa1, field_top)));
|
||||
}
|
||||
let kind = if sd[4] >= 0.0 { sd[4] as i64 } else { o[17] as i64 };
|
||||
@@ -1013,6 +1016,24 @@ fn layout_opening(o: &[f64], sashes: &[f64], transom_sashes: &[f64], pts: &Quad)
|
||||
let w = to - from;
|
||||
let h = z_top - z_bottom;
|
||||
if o[9] != 0.0 {
|
||||
// [105] Türzarge: Blatt ab der lichten Kante (bzw. dem Falz von der Aufschlagseite).
|
||||
let (la, lt) = (o[32], o[33]);
|
||||
if la.is_finite() && lt.is_finite() && (o[20] == 0.0 || o[20] == 3.0) && !(o[13] > EPS) {
|
||||
let fa = min(0.45, max(0.0, la) / max(w, 1e-6));
|
||||
let top = 1.0 - min(0.45, max(0.0, lt) / max(h, 1e-6));
|
||||
if o[10] != 0.0 {
|
||||
let ratio = max(0.05, min(1.0, if o[11].is_nan() { 1.0 } else { o[11] }));
|
||||
let split_z = top * (1.0 - ratio);
|
||||
out.glass.push(rect(pts, fa, 1.0 - fa, split_z, top));
|
||||
if ratio < 1.0 - EPS {
|
||||
out.door_leaf.push(rect(pts, fa, 1.0 - fa, 0.0, split_z));
|
||||
out.divisions.push((quad_at(pts, fa, split_z), quad_at(pts, 1.0 - fa, split_z)));
|
||||
}
|
||||
} else {
|
||||
out.door_leaf.push(rect(pts, fa, 1.0 - fa, 0.0, top));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
// Oberlicht über dem Kämpfer ([95]): festes Glasfeld, das Blatt endet darunter.
|
||||
let transom = if o[13].is_nan() { 0.0 } else { o[13] };
|
||||
let top = if transom > EPS && transom < h * 0.8 {
|
||||
@@ -1052,12 +1073,30 @@ fn layout_opening(o: &[f64], sashes: &[f64], transom_sashes: &[f64], pts: &Quad)
|
||||
return out;
|
||||
}
|
||||
let fw = o[12];
|
||||
let fa = min(0.45, fw / max(w, 1e-6));
|
||||
let fz = min(0.45, fw / max(h, 1e-6));
|
||||
// [105] Rahmen je Seite und Anschlussprofile (Anteile der Breite/Höhe).
|
||||
let side_w = |k: usize| if o[k].is_finite() { max(0.0, o[k]) } else { fw };
|
||||
let prof = |k: usize| if o[k].is_finite() { max(0.0, o[k]) } else { 0.0 };
|
||||
let (pl, pr) = (min(0.3, prof(28) / max(w, 1e-6)), min(0.3, prof(29) / max(w, 1e-6)));
|
||||
let (pb, pt) = (min(0.3, prof(30) / max(h, 1e-6)), min(0.3, prof(31) / max(h, 1e-6)));
|
||||
let a0 = pl + min(0.45, side_w(21) / max(w, 1e-6));
|
||||
let a1 = 1.0 - pr - min(0.45, side_w(22) / max(w, 1e-6));
|
||||
let fz_t = min(0.45, side_w(23) / max(h, 1e-6));
|
||||
let fz = pb + min(0.45, side_w(24) / max(h, 1e-6));
|
||||
let top = 1.0 - pt;
|
||||
for (fa, on) in [(pl, pl > 0.0), (1.0 - pr, pr > 0.0)] {
|
||||
if on {
|
||||
out.divisions.push((quad_at(pts, fa, 0.0), quad_at(pts, fa, 1.0)));
|
||||
}
|
||||
}
|
||||
for (fzz, on) in [(pb, pb > 0.0), (top, pt > 0.0)] {
|
||||
if on {
|
||||
out.divisions.push((quad_at(pts, pl, fzz), quad_at(pts, 1.0 - pr, fzz)));
|
||||
}
|
||||
}
|
||||
let transom = max(0.0, o[13]);
|
||||
let f_tr = if transom > EPS && transom < h - fw { 1.0 - transom / h } else { 0.0 };
|
||||
let field_top = if f_tr > 0.0 { f_tr - fz / 2.0 } else { 1.0 - fz };
|
||||
sash_band(&mut out, o, sashes, pts, w, h, fa, fw, fz, field_top, o[14], o[15]);
|
||||
let field_top = if f_tr > 0.0 { f_tr - fz_t / 2.0 } else { top - fz_t };
|
||||
sash_band(&mut out, o, sashes, pts, w, h, (a0, a1), fw, fz, field_top, o[14], o[15]);
|
||||
if o[16] != 0.0 {
|
||||
let ov1 = 0.02 / max(w, 1e-6);
|
||||
let ov2 = 0.05 / max(w, 1e-6);
|
||||
@@ -1068,12 +1107,12 @@ fn layout_opening(o: &[f64], sashes: &[f64], transom_sashes: &[f64], pts: &Quad)
|
||||
}
|
||||
if f_tr > 0.0 {
|
||||
if transom_sashes.is_empty() {
|
||||
out.glass.push(rect(pts, fa, 1.0 - fa, f_tr + fz / 2.0, 1.0 - fz));
|
||||
out.glass.push(rect(pts, a0, a1, f_tr + fz_t / 2.0, top - fz_t));
|
||||
} else {
|
||||
// Oberlicht mit Einteilung (Pfosten/Riegel, [95]).
|
||||
sash_band(&mut out, o, transom_sashes, pts, w, h, fa, fw, f_tr + fz / 2.0, 1.0 - fz, f64::NAN, f64::NAN);
|
||||
sash_band(&mut out, o, transom_sashes, pts, w, h, (a0, a1), fw, f_tr + fz_t / 2.0, top - fz_t, f64::NAN, f64::NAN);
|
||||
}
|
||||
out.divisions.push((quad_at(pts, 0.0, f_tr), quad_at(pts, 1.0, f_tr)));
|
||||
out.divisions.push((quad_at(pts, pl, f_tr), quad_at(pts, 1.0 - pr, f_tr)));
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -1142,13 +1181,19 @@ pub fn openings(frame: &[f64], inp: &[f64]) -> Vec<f64> {
|
||||
return Vec::new();
|
||||
}
|
||||
// Anschlag ([94]): von der Anschlag-Seite aus deckt die Wandnase Rahmen links, rechts und oben ab.
|
||||
// [105] Anschlag je Seite (links, rechts, oben; NaN = einheitlich `o[18]`).
|
||||
let mut oo = o.to_vec();
|
||||
if let Some((_, _, side)) = project_opening_side(&fr, o) {
|
||||
let rd = min(if o[18].is_nan() { 0.0 } else { o[18] }, (o[6] - o[5]) / 2.0 - 0.01);
|
||||
if rd > 1e-4 && side * o[19] > 0.0 && o[8] - o[7] > 2.0 * rd {
|
||||
oo[5] += rd;
|
||||
oo[6] -= rd;
|
||||
oo[8] -= rd;
|
||||
let uni = if o[18].is_nan() { 0.0 } else { o[18] };
|
||||
let cap = (o[6] - o[5]) / 2.0 - 0.01;
|
||||
let rd = |k: usize| min(if o[k].is_nan() { uni } else { max(0.0, o[k]) }, cap);
|
||||
let (rl, rr, rt) = (rd(25), rd(26), rd(27));
|
||||
if side * o[19] > 0.0 && o[8] - o[7] > 2.0 * rt {
|
||||
for (k, v) in [(5, rl), (6, -rr), (8, -rt)] {
|
||||
if v.abs() > 1e-4 {
|
||||
oo[k] += v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let o = &oo[..];
|
||||
@@ -1268,7 +1313,10 @@ mod tests_ts {
|
||||
fn anschlag_verkleinert_die_ansicht_nur_von_seiner_seite() {
|
||||
let frame = [0.0, 0.0, -3.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0];
|
||||
let rec = |rebate: f64, side: f64| {
|
||||
vec![1.0, 0.0, 0.0, 5.0, 0.0, 0.3, 1.0, 2.2, 0.9, 2.3, 0.0, 0.0, f64::NAN, 0.06, 0.0, f64::NAN, f64::NAN, 1.0, 1.0, rebate, side, 0.0, 0.0, 0.0]
|
||||
let mut b = vec![1.0, 0.0, 0.0, 5.0, 0.0, 0.3, 1.0, 2.2, 0.9, 2.3, 0.0, 0.0, f64::NAN, 0.06, 0.0, f64::NAN, f64::NAN, 1.0, 1.0, rebate, side, 0.0];
|
||||
b.extend([f64::NAN; 13]);
|
||||
b.extend([0.0, 0.0]);
|
||||
b
|
||||
};
|
||||
let width = |f: &[f64]| {
|
||||
assert_eq!(f[1], 1.0);
|
||||
@@ -1288,6 +1336,7 @@ mod tests_ts {
|
||||
let frame = [0.0, 0.0, -3.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0];
|
||||
let rec = |door: f64, transom: f64, kind: f64, transom_sashes: &[[f64; 6]]| {
|
||||
let mut b = vec![1.0, 0.0, 0.0, 5.0, 0.0, 0.3, 1.0, 2.2, 0.0, 2.3, door, 0.0, f64::NAN, 0.06, transom, f64::NAN, f64::NAN, 1.0, 1.0, 0.0, 1.0, kind];
|
||||
b.extend([f64::NAN; 13]);
|
||||
if door == 0.0 {
|
||||
b.extend([1.0, 0.0, f64::NAN, 1.0, f64::NAN, 3.0, 1.0]);
|
||||
} else {
|
||||
@@ -1320,4 +1369,58 @@ mod tests_ts {
|
||||
assert_eq!(split[3], plain[3] + 2, "zwei Oberlicht-Felder");
|
||||
assert!(split[5] >= plain[5] + 2, "Kipp-Symbol im Oberlicht");
|
||||
}
|
||||
|
||||
/// Fenster-Datensatz für die [105]-Tests: `extra` = Werte ab Index 21 (13 Stück).
|
||||
fn rec105(door: f64, extra: [f64; 13]) -> Vec<f64> {
|
||||
let mut b = vec![1.0, 0.0, 0.0, 5.0, 0.0, 0.3, 1.0, 2.2, 0.9, 2.3, door, 0.0, f64::NAN, 0.06, 0.0, f64::NAN, f64::NAN, 1.0, 1.0, 0.0, 1.0, 0.0];
|
||||
b.extend(extra);
|
||||
if door == 0.0 {
|
||||
b.extend([1.0, 0.0, f64::NAN, 1.0, f64::NAN, 3.0, 1.0]);
|
||||
} else {
|
||||
b.push(0.0);
|
||||
}
|
||||
b.push(0.0);
|
||||
b
|
||||
}
|
||||
|
||||
/// Erstes Glasfeld (u0, u1, v0, v1) einer Öffnung; Listen ab Index 12.
|
||||
fn first_glass(f: &[f64]) -> [f64; 4] {
|
||||
assert!(f[12] >= 1.0);
|
||||
let q = &f[13..21];
|
||||
let us = [q[0], q[2], q[4], q[6]];
|
||||
let vs = [q[1], q[3], q[5], q[7]];
|
||||
let mn = |a: [f64; 4]| a.iter().cloned().fold(f64::INFINITY, f64::min);
|
||||
let mx = |a: [f64; 4]| a.iter().cloned().fold(f64::NEG_INFINITY, f64::max);
|
||||
[mn(us), mx(us), mn(vs), mx(vs)]
|
||||
}
|
||||
|
||||
/// [105] Rahmen je Seite und Anschlussprofile rücken das Glas je Seite verschieden ein.
|
||||
#[test]
|
||||
fn rahmen_je_seite_und_profile_in_der_ansicht() {
|
||||
let frame = [0.0, 0.0, -3.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0];
|
||||
let n = f64::NAN;
|
||||
let g0 = first_glass(&openings(&frame, &rec105(0.0, [n; 13])));
|
||||
let g1 = first_glass(&openings(&frame, &rec105(0.0, [0.06, 0.12, 0.06, 0.10, n, n, n, 0.0, 0.0, 0.03, 0.0, n, n])));
|
||||
// Rechts 6 cm mehr Rahmen, unten 4 cm mehr Rahmen + 3 cm Bankprofil, links/oben gleich.
|
||||
assert!((g1[0] - g0[0]).abs() < 1e-9 && (g0[1] - g1[1] - 0.06).abs() < 1e-9, "{g0:?} {g1:?}");
|
||||
assert!((g1[2] - g0[2] - 0.07).abs() < 1e-9 && (g1[3] - g0[3]).abs() < 1e-9, "{g0:?} {g1:?}");
|
||||
// Anschlag nur rechts (von der Anschlag-Seite): Öffnung rechts schmaler.
|
||||
let w = |f: &[f64]| f[6] - f[4];
|
||||
let r = openings(&frame, &rec105(0.0, [n, n, n, n, 0.0, 0.05, 0.0, n, n, n, n, n, n]));
|
||||
let r0 = openings(&frame, &rec105(0.0, [n; 13]));
|
||||
assert!((w(&r0) - w(&r) - 0.05).abs() < 1e-9);
|
||||
}
|
||||
|
||||
/// [105] Türzarge: Blatt um den Einzug von der Rohbaukante eingerückt.
|
||||
#[test]
|
||||
fn tuerblatt_mit_zargen_einzug() {
|
||||
let frame = [0.0, 0.0, -3.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0];
|
||||
let n = f64::NAN;
|
||||
let f = openings(&frame, &rec105(1.0, [n, n, n, n, n, n, n, n, n, n, n, 0.1, 0.05]));
|
||||
// Listen: Glas 0, Türblatt 1.
|
||||
assert_eq!((f[12], f[13]), (0.0, 1.0));
|
||||
let q = &f[14..22];
|
||||
let u0 = [q[0], q[2], q[4], q[6]].iter().cloned().fold(f64::INFINITY, f64::min);
|
||||
assert!((u0 - (f[4] + 0.1)).abs() < 1e-9, "{u0}");
|
||||
}
|
||||
}
|
||||
@@ -130,8 +130,10 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
|
||||
operable: r.num()? != 0.0,
|
||||
});
|
||||
}
|
||||
// [105] Anhang (optional): Rahmenbreite rechts.
|
||||
// [105] Anhang (optional): Rahmenbreite rechts, Drehpunkt des Türblatts (Einzug ab Rohbaukante,
|
||||
// Versatz quer zur Achse; NaN = an der Wandachse).
|
||||
let frame_width_end = r.num().unwrap_or(f64::NAN);
|
||||
let (hinge_x, hinge_off) = (r.num().unwrap_or(f64::NAN), r.num().unwrap_or(f64::NAN));
|
||||
if ![sx, sy, ex, ey, total, ref_off, position, width].iter().all(|x| x.is_finite()) {
|
||||
return None;
|
||||
}
|
||||
@@ -166,7 +168,19 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
|
||||
};
|
||||
lift_slide(&mut o, jamb_start, jamb_end, wn, lo, hi, door.hinge_end, hair);
|
||||
} else {
|
||||
for leaf in door_leaves(&w, position, width, &door, count) {
|
||||
// [105] Blatt im Falz: Drehpunkt um den Einzug in die Öffnung und auf die Blattfläche versetzt.
|
||||
let falz = hinge_x.is_finite() && hinge_off.is_finite() && width - 2.0 * hinge_x > 0.05;
|
||||
let leaves = |p: &DoorParams| -> Vec<DoorLeaf> {
|
||||
if !falz {
|
||||
return door_leaves(&w, position, width, p, count);
|
||||
}
|
||||
let sh = scale(wn, hinge_off);
|
||||
door_leaves(&w, position + hinge_x, width - 2.0 * hinge_x, p, count)
|
||||
.into_iter()
|
||||
.map(|l| DoorLeaf { hinge: add(l.hinge, sh), open_end: add(l.open_end, sh), closed_end: add(l.closed_end, sh), radius: l.radius })
|
||||
.collect()
|
||||
};
|
||||
for leaf in leaves(&door) {
|
||||
o.line(C_LEAF, hair, 0.0, 0.0, leaf.hinge, leaf.open_end);
|
||||
if detail != Detail::Grob {
|
||||
o.arc(hair, leaf.hinge, leaf.closed_end, leaf.open_end, leaf.radius);
|
||||
@@ -175,7 +189,7 @@ fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
|
||||
if door_kind == 3 {
|
||||
// Pendeltür: schlägt auch zur Gegenseite auf (Blatt gepunktet, Bogen).
|
||||
let other = DoorParams { swing_right: !door.swing_right, ..door };
|
||||
for leaf in door_leaves(&w, position, width, &other, count) {
|
||||
for leaf in leaves(&other) {
|
||||
o.line(C_LEAF, hair, 0.0, 3.0, leaf.hinge, leaf.open_end);
|
||||
if detail != Detail::Grob {
|
||||
// Bögen laufen gegen den Uhrzeigersinn von `from` nach `to`: kurzen Bogen wählen.
|
||||
@@ -708,4 +722,58 @@ mod tests {
|
||||
assert_eq!(arcs(&f), 0);
|
||||
assert_eq!(count_cls(&f, C_LEAF), 2);
|
||||
}
|
||||
|
||||
/// [105] Türblatt im Falz: Drehpunkt um den Einzug in der Öffnung und quer versetzt; Bogenradius
|
||||
/// = lichte Breite zwischen den Falzen.
|
||||
#[test]
|
||||
fn tuerblatt_dreht_im_falz() {
|
||||
let mut b = input(true, 1.0, false, &[]);
|
||||
let arc = |f: &[f64]| {
|
||||
let (mut i, mut out) = (1, None);
|
||||
for _ in 0..f[0] as usize {
|
||||
match f[i] as i64 {
|
||||
1 => i += 5 + 2 * f[i + 4] as usize,
|
||||
3 => {
|
||||
out = Some((f[i + 2], f[i + 3], f[i + 8]));
|
||||
i += 9;
|
||||
}
|
||||
_ => i += 9,
|
||||
}
|
||||
}
|
||||
out.unwrap()
|
||||
};
|
||||
let (cx, cy, r) = arc(&plan_opening(&b));
|
||||
assert!((cx - 1.0).abs() < 1e-9 && cy.abs() < 1e-9 && (r - 0.9).abs() < 1e-9);
|
||||
b.extend([NAN, 0.012, 0.15]);
|
||||
let (cx, cy, r) = arc(&plan_opening(&b));
|
||||
assert!((cx - 1.012).abs() < 1e-9 && (cy.abs() - 0.15).abs() < 1e-9 && (r - 0.876).abs() < 1e-9, "{cx} {cy} {r}");
|
||||
}
|
||||
|
||||
/// [105] Pfosten mit eigener Breite: ein Rahmenblock über die Pfostenbreite (statt zwei Anschläge).
|
||||
#[test]
|
||||
fn pfosten_mit_breite_im_grundriss() {
|
||||
let wing = [0.0, 1.0, NAN, NAN, 1.0];
|
||||
let a = plan_opening(&input(false, 1.0, true, &[wing, wing]));
|
||||
let b = plan_opening(&input(false, 1.0, true, &[wing, [1.0, 1.0, NAN, 0.1, 0.0], wing]));
|
||||
// Längste waagrechte Rahmenblock-Kante (Stulp-Ring) in der Mitte.
|
||||
let widest = |f: &[f64]| {
|
||||
let (mut i, mut best) = (1, 0.0f64);
|
||||
for _ in 0..f[0] as usize {
|
||||
match f[i] as i64 {
|
||||
1 => i += 5 + 2 * f[i + 4] as usize,
|
||||
2 => {
|
||||
let (ax, ay, bx, by) = (f[i + 5], f[i + 6], f[i + 7], f[i + 8]);
|
||||
if f[i + 1] == C_STULP && (ay - by).abs() < 1e-9 && (ax + bx) / 2.0 > 1.3 && (ax + bx) / 2.0 < 1.6 {
|
||||
best = best.max((ax - bx).abs());
|
||||
}
|
||||
i += 9;
|
||||
}
|
||||
_ => i += 9,
|
||||
}
|
||||
}
|
||||
best
|
||||
};
|
||||
assert!((widest(&b) - 0.1).abs() < 1e-9, "{}", widest(&b));
|
||||
assert!(widest(&a) < 0.1);
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String,
|
||||
("roofCutLayers", _) => json(&model3d::emit_roof_cut_layers(p)?),
|
||||
("scheduleRows", _) => json(&export_schedule::schedule_rows(p)),
|
||||
("openingSchedule", _) => json(&crate::opening_schedule::opening_schedule(p)),
|
||||
("surfaceOpening", _) => json(&crate::opening_shape::surface_opening_info(p, text)),
|
||||
("openingPreview", _) => json(&crate::opening_preview::opening_preview(p, text)),
|
||||
("scheduleCsv", 1) => Ok(export_schedule::export_schedule_csv(p, text, args[0] != 0.0)),
|
||||
("pickGeometry", _) => json(&model3d::pick_geometry(p)?),
|
||||
|
||||
@@ -825,6 +825,10 @@ fn opening_selection(lk: &Lookup, o: &Value) -> Result<J, String> {
|
||||
.raw("id", o, "id")
|
||||
.raw("kind", o, "kind")
|
||||
.raw("hostWallId", o, "hostWallId")
|
||||
.raw("hostRoofId", o, "hostRoofId")
|
||||
.raw("hostCeilingId", o, "hostCeilingId")
|
||||
.raw("hostPoint", o, "hostPoint")
|
||||
.raw("hostAngle", o, "hostAngle")
|
||||
.o("hostWallName", floor.map_or_else(|| field(o, "hostWallId").cloned(), |f| Some(Value::from(field(f, "name").map_or("undefined".into(), js_text)))))
|
||||
.raw("position", o, "position")
|
||||
.raw("width", o, "width")
|
||||
|
||||
Reference in new issue
Block a user