[63] Merge: Baurecht – Vorsprünge und zulässige Hülle im 3D

This commit is contained in:
Claude committed 2026-11-05 01:59:28 +00:00
commit 6d9cd803a6
16 files changed
+836 -10

No files matched your search

+7 -1
View File
@@ -1717,7 +1717,13 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
- ○ **[42] Varianten.** · L
- ✅ **[63] Baulinien, Grenzabstände, zulässige Hülle.** (27.10.) Parzelle/Baulinien aus Auswahl,
Grenzabstand pauschal und je Kante, Gesamthöhe; zulässige Fläche und Verstösse im Grundriss.
Offen: Vorsprünge (Dachüberstand, Balkone), Hülle im 3D.
5.11.: Vorsprünge — `SiteRules.projectionDepth` (Tiefe in Abstand/über Baulinie) und `projectionShare` (Anteil
der Fassadenlänge je Grenze/Baulinie); geprüft werden Dach-Traufumrisse (nur Tiefe) und als Vorsprung markierte
Decken/Körper (`siteProjection`, im Lage-Panel an der Auswahl; Tiefe + Anteil); ohne Tiefe wie bisher
(`site_rules.rs`, Tests). Zulässige Hülle im 3D (`show3d`, Lage-Panel „Hülle im 3D"): zulässige Fläche vom
massgebenden Terrain bis zur Gesamthöhe durchscheinend, Verstösse rot (`envelope3d` → render3d `set_ghost`,
Alpha-Pipeline). Offen: Hülle im 3D nur im Linux-Container gebaut, nicht angesehen (WebGPU/macOS); Höhenkurven/
Gebäudeprofil (Winkel) fehlen im Modell; Wände eines Erkers nicht markierbar; Anteil grob über Ausdehnung längs der Grenze.
- ◐ **[64]+[59] Sonnenstand und Schatten.** (27.10.) Schatten im Grundriss mit Zeitregler (Lage-Panel),
auch in CLI/PDF. Offen: Schatten im 3D.
- ○ **[88] Nur-Lese-Link fürs Web.** · M
+25
View File
@@ -1984,6 +1984,21 @@ pub struct SiteRules {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub show: Option<bool>,
/// Zulässige Hülle (zulässige Fläche bis zur Gesamthöhe) im 3D durchscheinend zeigen (Default: nein).
#[serde(rename = "show3d", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub show3d: Option<bool>,
/// Vorsprünge ([63]): zulässige Tiefe (m) in den Grenzabstand bzw. über die Baulinie für
/// Dachüberstände und als Vorsprung markierte Bauteile (`siteProjection`). Fehlt ⇒ keine
/// Vorsprungsregel (Dächer und Decken werden nicht geprüft, wie bisher).
#[serde(rename = "projectionDepth", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub projection_depth: Option<f64>,
/// Vorsprünge ([63]): höchster Anteil (0..1) der Fassadenlänge, den markierte Vorsprünge
/// (Balkone, Erker; nicht Dachüberstände) je Grenze/Baulinie einnehmen dürfen. Fehlt ⇒ unbegrenzt.
#[serde(rename = "projectionShare", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub projection_share: Option<f64>,
#[serde(flatten)]
#[ts(skip)]
pub extra: Extra,
@@ -2276,6 +2291,11 @@ pub struct Ceiling {
/// Grafik-Kategorie (Ebene), z. B. "30" für Decken.
#[serde(rename = "categoryCode")]
pub category_code: String,
/// Vorsprung im Baurecht ([63]: Balkon, Erker): darf mit `SiteRules.projectionDepth`/
/// `projectionShare` in den Grenzabstand ragen. Fehlt ⇒ normales Bauteil.
#[serde(rename = "siteProjection", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub site_projection: Option<bool>,
/// Objekt-Sperre, analog `Wall.locked`.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
@@ -3596,6 +3616,11 @@ pub struct ExtrudedSolid {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional, type = "\"subtract\"")]
pub operation: Option<String>,
/// Vorsprung im Baurecht ([63]: Balkon, Erker): darf mit `SiteRules.projectionDepth`/
/// `projectionShare` in den Grenzabstand ragen. Fehlt ⇒ normales Bauteil.
#[serde(rename = "siteProjection", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub site_projection: Option<bool>,
/// Gesetzt, wenn das Profil ein Kreis ist (aus einem `Drawing2D` mit
/// `shape:"circle"`) — `points` bleibt die Tessellierung, `toWalls3d.ts`
/// (emitExtrudedSolids) nutzt `circle` für die runde 3D-Extrusion.
+457 -4
View File
@@ -160,7 +160,7 @@ pub fn check_site_rules(r: &SiteRules, footprint_parts: &[Polygon], max_height:
polygon_bool::difference(&fp, &allowed)
};
// Kleinste Splitter (Rundung an gemeinsamen Kanten) nicht als Verstoss melden.
let real: Vec<Polygon> = violations.into_iter().filter(|p| p.first().is_some_and(|o| signed_area(o).abs() > 1e-4)).collect();
let real = drop_slivers(violations);
Some(SiteCheck {
parcel_area: signed_area(&r.parcel).abs(),
allowed_area: multi_polygon_area(&allowed),
@@ -171,6 +171,158 @@ pub fn check_site_rules(r: &SiteRules, footprint_parts: &[Polygon], max_height:
})
}
/// Splitter (Rundung an gemeinsamen Kanten) weglassen.
fn drop_slivers(v: Vec<Polygon>) -> Vec<Polygon> {
v.into_iter().filter(|p| p.first().is_some_and(|o| signed_area(o).abs() > 1e-4)).collect()
}
// ── Vorsprünge ([63]) ───────────────────────────────────────────────────────
//
// Dachüberstände und als Vorsprung markierte Bauteile (Balkone, Erker) dürfen bis `depth` in den
// Grenzabstand bzw. über die Baulinie ragen; markierte Bauteile zusätzlich höchstens auf `share`
// der Fassadenlänge je Grenze/Baulinie (Ausdehnung längs der Grenze, verglichen mit der
// Ausdehnung der Gebäude-Grundfläche längs derselben Richtung).
/// Vorsprungsregel: Tiefe (m, ≥ 0) und optionaler Höchstanteil der Fassadenlänge.
#[derive(Clone, Copy, Debug)]
pub struct ProjectionRules {
pub depth: f64,
pub share: Option<f64>,
}
/// Ein Vorsprung: Grundriss und ob der Fassadenanteil gilt (Balkon/Erker ja, Dachüberstand nein).
pub struct ProjectionPart {
pub poly: Polygon,
pub share_limited: bool,
}
/// Zulässige Fläche für Vorsprünge: Grenzabstände um `depth` verringert, Baulinien um `depth`
/// nach aussen geschoben.
pub fn projection_area(r: &SiteRules, depth: f64) -> Vec<Polygon> {
if !valid_parcel(&r.parcel) {
return vec![];
}
let d = if depth.is_finite() && depth > 0.0 { depth } else { 0.0 };
let c = centroid(&r.parcel);
let lines = r
.lines
.iter()
.map(|l| {
let (dx, dy) = (l.b[0] - l.a[0], l.b[1] - l.a[1]);
let len = dx.hypot(dy);
if !(len > 1e-9) {
return *l;
}
let (mut nx, mut ny) = (-dy / len, dx / len);
if (c[0] - l.a[0]) * nx + (c[1] - l.a[1]) * ny > 0.0 {
nx = -nx;
ny = -ny;
}
BuildingLine { a: [l.a[0] + nx * d, l.a[1] + ny * d], b: [l.b[0] + nx * d, l.b[1] + ny * d] }
})
.collect();
let setbacks = (0..r.parcel.len()).map(|i| (setback_of(r, i) - d).max(0.0)).collect();
allowed_area(&SiteRules { parcel: r.parcel.clone(), setbacks, lines })
}
fn seg_dist(p: [f64; 2], a: [f64; 2], b: [f64; 2], infinite: bool) -> f64 {
let (dx, dy) = (b[0] - a[0], b[1] - a[1]);
let l2 = dx * dx + dy * dy;
if !(l2 > 1e-18) {
return (p[0] - a[0]).hypot(p[1] - a[1]);
}
let mut t = ((p[0] - a[0]) * dx + (p[1] - a[1]) * dy) / l2;
if !infinite {
t = t.clamp(0.0, 1.0);
}
(p[0] - a[0] - t * dx).hypot(p[1] - a[1] - t * dy)
}
/// Ausdehnung [min, max] der Aussenringe längs der Einheitsrichtung `u`.
fn extent(polys: &[Polygon], u: [f64; 2]) -> Option<(f64, f64)> {
let mut it = polys.iter().filter_map(|p| p.first()).flatten().map(|q| q[0] * u[0] + q[1] * u[1]);
let first = it.next()?;
Some(it.fold((first, first), |(lo, hi), v| (lo.min(v), hi.max(v))))
}
/// Vorsprünge, die die Regel verletzen: Teile ausserhalb der zulässigen Fläche, die tiefer als
/// `depth` hineinragen, und markierte Vorsprünge einer Grenze, deren Länge zusammen den
/// Fassadenanteil übersteigt. `allowed` = zulässige Fläche, `main` = Gebäude-Grundfläche (vereinigt).
pub fn projection_violations(r: &SiteRules, allowed: &[Polygon], main: &[Polygon], parts: &[ProjectionPart], rules: ProjectionRules) -> Vec<Polygon> {
if !valid_parcel(&r.parcel) || parts.is_empty() {
return vec![];
}
let ext = projection_area(r, rules.depth);
let mut out: Vec<Polygon> = vec![];
let mut pieces: Vec<Polygon> = vec![];
for part in parts {
if part.poly.first().is_none_or(|o| o.len() < 3 || o.iter().any(|q| !(q[0].is_finite() && q[1].is_finite()))) {
continue;
}
let one = std::slice::from_ref(&part.poly);
let outside = drop_slivers(if allowed.is_empty() { one.to_vec() } else { polygon_bool::difference(one, allowed) });
if outside.is_empty() {
continue;
}
out.extend(drop_slivers(if ext.is_empty() { outside.clone() } else { polygon_bool::difference(&outside, &ext) }));
if part.share_limited && rules.share.is_some() && !ext.is_empty() {
pieces.extend(drop_slivers(polygon_bool::intersection(&outside, &ext)));
}
}
let Some(share) = rules.share else { return out };
// Grenzen: Parzellenkanten mit Abstand (Strecke) und Baulinien (Gerade).
let n = r.parcel.len();
let mut bounds: Vec<([f64; 2], [f64; 2], bool)> = (0..n).filter(|&i| setback_of(r, i) > 0.0).map(|i| (r.parcel[i], r.parcel[(i + 1) % n], false)).collect();
bounds.extend(r.lines.iter().map(|l| (l.a, l.b, true)));
let mut groups: Vec<Vec<Polygon>> = vec![vec![]; bounds.len()];
for piece in pieces {
let ring = &piece[0];
let c = centroid(ring);
let best = bounds
.iter()
.enumerate()
.map(|(k, &(a, b, inf))| (k, seg_dist(c, a, b, inf)))
.min_by(|x, y| x.1.total_cmp(&y.1));
if let Some((k, _)) = best {
groups[k].push(piece);
}
}
for (k, group) in groups.into_iter().enumerate() {
if group.is_empty() {
continue;
}
let (a, b, _) = bounds[k];
let len = (b[0] - a[0]).hypot(b[1] - a[1]);
if !(len > 1e-9) {
continue;
}
let u = [(b[0] - a[0]) / len, (b[1] - a[1]) / len];
let facade = extent(main, u).map_or(0.0, |(lo, hi)| hi - lo);
let mut iv: Vec<(f64, f64)> = group.iter().filter_map(|p| extent(std::slice::from_ref(p), u)).collect();
iv.sort_by(|x, y| x.0.total_cmp(&y.0));
let mut total = 0.0;
let mut cur: Option<(f64, f64)> = None;
for (lo, hi) in iv {
match cur {
Some((cl, ch)) if lo <= ch => cur = Some((cl, ch.max(hi))),
_ => {
if let Some((cl, ch)) = cur {
total += ch - cl;
}
cur = Some((lo, hi));
}
}
}
if let Some((cl, ch)) = cur {
total += ch - cl;
}
if total > share * facade + 1e-6 {
out.extend(group);
}
}
out
}
#[cfg(test)]
mod tests {
use super::*;
@@ -240,6 +392,70 @@ mod tests {
assert_eq!(multi_polygon_area(&[]), 0.0);
}
fn part(poly: Ring, share_limited: bool) -> ProjectionPart {
ProjectionPart { poly: vec![poly], share_limited }
}
fn area_of(v: &[Polygon]) -> f64 {
multi_polygon_area(v)
}
#[test]
fn vorsprung_flaeche_verringert_abstand_und_schiebt_baulinie() {
let mut r = rules(rect(0.0, 0.0, 30.0, 20.0), SB4.to_vec());
assert!(close(area_of(&projection_area(&r, 1.5)), 25.0 * 15.0));
assert!(close(area_of(&projection_area(&r, 0.0)), 22.0 * 12.0));
// Tiefe grösser als der Abstand: bis zur Grenze, nicht darüber.
assert!(close(area_of(&projection_area(&r, 9.0)), 600.0));
r.lines.push(BuildingLine { a: [30.0, 14.0], b: [0.0, 14.0] });
// Baulinie 1 m nach aussen (weg vom Schwerpunkt): y ≤ 15.
assert!(close(area_of(&projection_area(&r, 1.0)), 24.0 * 12.0));
assert!(projection_area(&rules(vec![], vec![]), 1.0).is_empty());
}
#[test]
fn vorsprung_tiefe() {
let r = rules(rect(0.0, 0.0, 30.0, 20.0), SB4.to_vec());
let allowed = allowed_area(&r);
let main = vec![vec![rect(6.0, 6.0, 24.0, 16.0)]];
let pr = ProjectionRules { depth: 1.5, share: None };
// Balkon 1.5 m tief: erlaubt.
assert!(projection_violations(&r, &allowed, &main, &[part(rect(10.0, 16.0, 14.0, 17.5), true)], pr).is_empty());
// Balkon 2 m tief: die letzten 0.5 m verletzen.
let v = projection_violations(&r, &allowed, &main, &[part(rect(10.0, 16.0, 14.0, 18.0), true)], pr);
assert!(close(area_of(&v), 2.0), "{}", area_of(&v));
// Dachüberstand ringsum 1 m: erlaubt; 2 m nach Norden: 0.5 m Streifen verletzt.
assert!(projection_violations(&r, &allowed, &main, &[part(rect(5.0, 5.0, 25.0, 17.0), false)], pr).is_empty());
let v = projection_violations(&r, &allowed, &main, &[part(rect(3.0, 3.0, 27.0, 18.0), false)], pr);
assert!(close(area_of(&v), 24.0 * 0.5), "{}", area_of(&v));
// Ganz innerhalb: nichts.
assert!(projection_violations(&r, &allowed, &main, &[part(rect(8.0, 8.0, 9.0, 9.0), true)], pr).is_empty());
// Unsinn: kein Panic, nichts gemeldet.
assert!(projection_violations(&r, &allowed, &main, &[part(vec![[f64::NAN, 0.0], [1.0, 0.0], [0.0, 1.0]], true)], pr).is_empty());
let nan = ProjectionRules { depth: f64::NAN, share: None };
let v = projection_violations(&r, &allowed, &main, &[part(rect(10.0, 16.0, 14.0, 17.0), true)], nan);
assert!(close(area_of(&v), 4.0));
}
#[test]
fn vorsprung_fassadenanteil() {
let r = rules(rect(0.0, 0.0, 30.0, 20.0), SB4.to_vec());
let allowed = allowed_area(&r);
// Fassade längs der Nordgrenze: 18 m.
let main = vec![vec![rect(6.0, 6.0, 24.0, 16.0)]];
let balkone = [part(rect(7.0, 16.0, 11.0, 17.0), true), part(rect(15.0, 16.0, 19.0, 17.0), true)];
let mit = |share| projection_violations(&r, &allowed, &main, &balkone, ProjectionRules { depth: 1.5, share: Some(share) });
// 8 m von 18 m = 0.44.
assert!(mit(0.5).is_empty());
assert!(close(area_of(&mit(0.4)), 8.0));
// Überlappende Vorsprünge zählen ihre Länge nur einmal.
let ueber = [part(rect(7.0, 16.0, 11.0, 17.0), true), part(rect(9.0, 16.0, 13.0, 17.0), true)];
let v = projection_violations(&r, &allowed, &main, &ueber, ProjectionRules { depth: 1.5, share: Some(6.0 / 18.0) });
assert!(v.is_empty());
// Dachüberstände zählen nicht zum Anteil.
let dach = [part(rect(5.0, 5.0, 25.0, 17.0), false)];
assert!(projection_violations(&r, &allowed, &main, &dach, ProjectionRules { depth: 1.5, share: Some(0.1) }).is_empty());
}
#[test]
fn pruefung() {
let r = rules(rect(0.0, 0.0, 30.0, 20.0), SB4.to_vec());
@@ -279,8 +495,13 @@ pub(crate) fn wall_corners(start: Vec2, end: Vec2, thickness: f64) -> Vec<[f64;
]
}
/// Teile der Gebäude-Grundfläche (Wände aller Geschosse, freie Körper ohne Abzugskörper).
/// Teile der Gebäude-Grundfläche (Wände aller Geschosse, freie Körper ohne Abzugskörper). Mit
/// `skip_projections` fehlen die als Vorsprung markierten Körper (sie prüft die Vorsprungsregel).
fn footprint_parts(p: &Project) -> Vec<Polygon> {
footprint_parts_with(p, false)
}
fn footprint_parts_with(p: &Project, skip_projections: bool) -> Vec<Polygon> {
let mut parts: Vec<Polygon> = Vec::new();
for w in &p.walls {
if hypot2(w.end.x - w.start.x, w.end.y - w.start.y) < 1e-9 {
@@ -293,7 +514,7 @@ fn footprint_parts(p: &Project) -> Vec<Polygon> {
}
}
for s in p.extruded_solids.as_deref().unwrap_or(&[]) {
if s.operation.as_deref() == Some("subtract") || s.points.len() < 3 {
if s.operation.as_deref() == Some("subtract") || s.points.len() < 3 || (skip_projections && s.site_projection == Some(true)) {
continue;
}
parts.push(vec![s.points.iter().map(|v| [v.x, v.y]).collect()]);
@@ -301,6 +522,37 @@ fn footprint_parts(p: &Project) -> Vec<Polygon> {
parts
}
/// Vorsprünge ([63]): Dach-Traufumrisse (mit Überstand; ohne Fassadenanteil), als Vorsprung
/// markierte Decken und Körper (mit Fassadenanteil).
fn projection_parts(p: &Project) -> Vec<ProjectionPart> {
let mut out = Vec::new();
for r in p.roofs.as_deref().unwrap_or(&[]) {
let g = crate::roof::roof_geometry(&r.params(), p.roof_base_elevation(r));
if g.eaves.len() >= 3 {
let mut poly = vec![g.eaves.clone()];
poly.extend(g.eaves_holes.iter().cloned());
out.push(ProjectionPart { poly, share_limited: false });
}
}
for c in p.ceilings.as_deref().unwrap_or(&[]) {
if c.site_projection == Some(true) && c.outline.len() >= 3 {
out.push(ProjectionPart { poly: vec![c.outline.iter().map(|v| [v.x, v.y]).collect()], share_limited: true });
}
}
for s in p.extruded_solids.as_deref().unwrap_or(&[]) {
if s.site_projection == Some(true) && s.operation.as_deref() != Some("subtract") && s.points.len() >= 3 {
out.push(ProjectionPart { poly: vec![s.points.iter().map(|v| [v.x, v.y]).collect()], share_limited: true });
}
}
out
}
/// Vorsprungsregel des Projekts; `None` ohne (gültige) Tiefe = altes Verhalten.
fn projection_rules(r: &crate::model::SiteRules) -> Option<ProjectionRules> {
let depth = r.projection_depth.filter(|d| d.is_finite())?;
Some(ProjectionRules { depth: depth.max(0.0), share: r.projection_share.filter(|v| v.is_finite()).map(|v| v.max(0.0)) })
}
/// Grundfläche des Gebäudes (vereinigt).
pub fn building_footprint(p: &Project) -> AreaOut {
let parts = footprint_parts(p);
@@ -393,7 +645,19 @@ pub fn check_project(p: &Project) -> Option<SiteCheckOut> {
let height_above_terrain = max_top.zip(terrain_min).map(|(t, g)| t - g);
// Mit Gelände zählt die Höhe über dem massgebenden Terrain, sonst über ±0.00.
let top_for_check = height_above_terrain.or(max_top);
let c = check_site_rules(&rules, &footprint_parts(p), r.max_height.unwrap_or(f64::NAN), top_for_check.unwrap_or(f64::NAN))?;
let proj = projection_rules(r);
let parts = footprint_parts_with(p, proj.is_some());
let mut c = check_site_rules(&rules, &parts, r.max_height.unwrap_or(f64::NAN), top_for_check.unwrap_or(f64::NAN))?;
if let Some(pr) = proj {
let main = if parts.is_empty() { vec![] } else { polygon_bool::union(&parts) };
let pv = projection_violations(&rules, &c.allowed, &main, &projection_parts(p), pr);
if !pv.is_empty() {
let mut all = std::mem::take(&mut c.violations);
all.extend(pv);
c.violations = drop_slivers(polygon_bool::union(&all));
c.violation_area = multi_polygon_area(&c.violations);
}
}
Some(SiteCheckOut {
parcel_area: c.parcel_area,
allowed: area_out(&c.allowed),
@@ -407,3 +671,192 @@ pub fn check_project(p: &Project) -> Option<SiteCheckOut> {
height_above_terrain,
})
}
// ── Zulässige Hülle im 3D ([63]) ───────────────────────────────────────────
/// Farbe der Hülle (RGBA, durchscheinend), ihrer Kanten und der Verstösse.
pub const ENVELOPE_RGBA: [f32; 4] = [0.25, 0.55, 0.95, 0.16];
pub const ENVELOPE_EDGE: [f32; 3] = [0.15, 0.4, 0.8];
pub const VIOLATION_RGBA: [f32; 4] = [0.9, 0.12, 0.08, 0.4];
/// Durchscheinende Körper für render3d (`set_ghost`): Dreiecke `[x y z r g b a]` und Kanten
/// `[x y z r g b]` (LineList), Welt = (x, Höhe, y) wie `drawing_line_verts`.
#[derive(Debug, Default)]
pub struct Envelope3d {
pub tris: Vec<f32>,
pub lines: Vec<f32>,
}
fn polys_in(a: &AreaOut) -> Vec<Polygon> {
a.iter().map(|p| p.iter().map(|r| r.iter().map(|q| [q.x, q.y]).collect()).collect()).collect()
}
/// Prismen der Mehrfach-Fläche von `z0` bis `z1`; `edge` = Kantenfarbe (None: keine Kanten).
fn push_prisms(out: &mut Envelope3d, polys: &[Polygon], z0: f64, z1: f64, rgba: [f32; 4], edge: Option<[f32; 3]>) {
if !(z0.is_finite() && z1.is_finite() && z1 > z0) {
return;
}
let (b, t) = (z0 as f32, z1 as f32);
let tris = &mut out.tris;
let mut tri = |p: [f64; 2], z: f32| tris.extend([p[0] as f32, z, p[1] as f32, rgba[0], rgba[1], rgba[2], rgba[3]]);
for poly in polys {
let Some(outer) = poly.first() else { continue };
if outer.len() < 3 {
continue;
}
let ring = crate::polygon_holes::merge_holes(outer, &poly[1..], 1e-4).ring;
let pts: Vec<_> = ring.iter().map(|q| crate::hatch::v2(q[0], q[1])).collect();
for k in crate::gpu_compile::triangulate(&pts).chunks_exact(3) {
for z in [b, t] {
for &i in k {
tri(ring[i as usize], z);
}
}
}
for r in poly {
let n = r.len();
if n < 3 {
continue;
}
for i in 0..n {
let (p, q) = (r[i], r[(i + 1) % n]);
for (v, z) in [(p, b), (q, b), (q, t), (p, b), (q, t), (p, t)] {
tri(v, z);
}
}
}
}
let Some(e) = edge else { return };
let mut line = |p: [f64; 2], z: f32| out.lines.extend([p[0] as f32, z, p[1] as f32, e[0], e[1], e[2]]);
for poly in polys {
for ring in poly {
let n = ring.len();
if n < 3 {
continue;
}
for i in 0..n {
let (o, p, q) = (ring[(i + n - 1) % n], ring[i], ring[(i + 1) % n]);
for z in [b, t] {
line(p, z);
line(q, z);
}
// Senkrechte Kante nur an echten Ecken (nicht in gerundeten Bögen).
let (ax, ay, bx, by) = (p[0] - o[0], p[1] - o[1], q[0] - p[0], q[1] - p[1]);
let turn = crate::jsnum::atan2(ax * by - ay * bx, ax * bx + ay * by).abs();
if turn > 0.2 {
line(p, b);
line(p, t);
}
}
}
}
}
/// Zulässige Hülle (zulässige Fläche vom massgebenden Terrain bzw. ±0.00 bis zur Gesamthöhe;
/// ohne Gesamthöhe bis zur Modellhöhe, mind. 3 m) und rote Verstösse (Grundfläche ausserhalb bis
/// zur Modellhöhe, Teil über der Gesamthöhe). Leer ohne Baurecht oder mit `show3d` ≠ true.
pub fn envelope3d(p: &Project) -> Envelope3d {
let mut out = Envelope3d::default();
let Some(r) = p.site_rules.as_ref().filter(|r| r.show3d == Some(true)) else { return out };
let Some(c) = check_project(p) else { return out };
let base = c.terrain_min.unwrap_or(0.0);
let top = match r.max_height {
Some(h) if h.is_finite() && h > 0.0 => base + h,
_ => c.max_top.map_or(base + 10.0, |t| t.max(base + 3.0)),
};
push_prisms(&mut out, &polys_in(&c.allowed), base, top, ENVELOPE_RGBA, Some(ENVELOPE_EDGE));
let model_top = c.max_top.unwrap_or(top);
push_prisms(&mut out, &polys_in(&c.violations), base, model_top.max(base + 0.1), VIOLATION_RGBA, None);
if c.height_exceeded {
// Teil über der Hülle (die Hülle steht auf `base`, die Höhe ist gegen das Terrain geprüft).
push_prisms(&mut out, &polys_in(&building_footprint(p)), top, model_top, VIOLATION_RGBA, None);
}
out
}
#[cfg(test)]
mod project_tests {
use super::*;
use serde_json::json;
fn project(extra: serde_json::Value) -> Project {
let mut v = json!({
"id": "p", "name": "P", "lineStyles": [], "hatches": [], "components": [], "wallTypes": [],
"drawingLevels": [{"id": "eg", "name": "EG", "kind": "floor", "visible": true, "locked": false, "floorHeight": 3.0, "cutHeight": 1.0, "baseElevation": 0}],
"layers": [], "walls": [], "openings": [], "ceilings": [], "stairs": [], "rooms": [], "drawings2d": [], "context": [],
"siteRules": {"parcel": [{"x": 0, "y": 0}, {"x": 30, "y": 0}, {"x": 30, "y": 20}, {"x": 0, "y": 20}], "defaultSetback": 4.0}
});
for (k, val) in extra.as_object().unwrap() {
if k == "siteRules" {
for (k2, v2) in val.as_object().unwrap() {
v["siteRules"][k2] = v2.clone();
}
} else {
v[k] = val.clone();
}
}
serde_json::from_value(v).unwrap()
}
fn rect(x0: f64, y0: f64, x1: f64, y1: f64) -> serde_json::Value {
json!([{"x": x0, "y": y0}, {"x": x1, "y": y0}, {"x": x1, "y": y1}, {"x": x0, "y": y1}])
}
fn solid(id: &str, pts: serde_json::Value, projection: bool) -> serde_json::Value {
let mut s = json!({"id": id, "type": "extrudedSolid", "levelId": "eg", "points": pts, "height": 3.0});
if projection {
s["siteProjection"] = json!(true);
}
s
}
fn roof(overhang: f64) -> serde_json::Value {
json!({"id": "r", "type": "roof", "floorId": "eg", "categoryCode": "35", "outline": rect(6.0, 6.0, 24.0, 16.0), "shape": "flach",
"pitchDeg": 0, "overhang": overhang, "ridgeAxis": "x", "thickness": 0.3})
}
#[test]
fn ohne_vorsprungsregel_wie_bisher() {
// Markierter Körper und Dachüberstand im Abstand: ohne Regel zählt der Körper als Grundfläche, das Dach nicht.
let p = project(json!({"extrudedSolids": [solid("h", rect(6.0, 6.0, 24.0, 16.0), false), solid("b", rect(10.0, 16.0, 14.0, 17.0), true)], "roofs": [roof(2.0)]}));
let c = check_project(&p).unwrap();
assert!((c.violation_area - 4.0).abs() < 1e-6, "{}", c.violation_area);
}
#[test]
fn vorsprungsregel_im_projekt() {
let solids = json!([solid("h", rect(6.0, 6.0, 24.0, 16.0), false), solid("b", rect(10.0, 16.0, 14.0, 17.0), true)]);
// Balkon 1 m und Dachüberstand 1 m bei zulässigen 1.5 m: keine Verstösse.
let p = project(json!({"extrudedSolids": solids, "roofs": [roof(1.0)], "siteRules": {"projectionDepth": 1.5}}));
let c = check_project(&p).unwrap();
assert!(c.violations.is_empty(), "{}", c.violation_area);
// Dachüberstand 2 m: nur nach Norden (Gebäude 6 m vor der Grenze, Abstand 4 m) ragt er
// 2 m in den Abstand, 0.5 m davon zu tief, auf 18 + 2·2 = 22 m Länge.
let p = project(json!({"extrudedSolids": solids, "roofs": [roof(2.0)], "siteRules": {"projectionDepth": 1.5}}));
let c = check_project(&p).unwrap();
assert!((c.violation_area - 22.0 * 0.5).abs() < 1e-3, "{}", c.violation_area);
// Anteil 0.2 der 18 m langen Fassade: Balkon 4 m ist zu lang.
let p = project(json!({"extrudedSolids": solids, "siteRules": {"projectionDepth": 1.5, "projectionShare": 0.2}}));
let c = check_project(&p).unwrap();
assert!((c.violation_area - 4.0).abs() < 1e-6, "{}", c.violation_area);
}
#[test]
fn huelle_3d() {
let solids = json!([solid("h", rect(6.0, 6.0, 24.0, 16.0), false)]);
// Ohne show3d: leer.
let p = project(json!({"extrudedSolids": solids, "siteRules": {"maxHeight": 12.0}}));
assert!(envelope3d(&p).tris.is_empty());
let p = project(json!({"extrudedSolids": solids, "siteRules": {"maxHeight": 12.0, "show3d": true}}));
let e = envelope3d(&p);
// Quader 22 × 12: 2 Deckel à 2 Dreiecke + 4 Seiten à 2 Dreiecke = 12 Dreiecke à 3 Ecken à 7 Werte.
assert_eq!(e.tris.len(), 12 * 3 * 7);
assert!(e.tris.chunks_exact(7).all(|v| v[1] == 0.0 || v[1] == 12.0));
assert!((e.tris[6] - ENVELOPE_RGBA[3]).abs() < 1e-6);
// Kanten: 4 Kanten × 2 Höhen + 4 Senkrechte = 12 Linien à 2 Ecken à 6 Werte.
assert_eq!(e.lines.len(), 12 * 2 * 6);
// Höhe überschritten und Grundfläche ausserhalb: rote Körper kommen dazu.
let solids = json!([solid("h", rect(2.0, 6.0, 24.0, 16.0), false)]);
let p = project(json!({"extrudedSolids": solids, "siteRules": {"maxHeight": 2.0, "show3d": true}}));
let e = envelope3d(&p);
assert!(e.tris.chunks_exact(7).any(|v| (v[6] - VIOLATION_RGBA[3]).abs() < 1e-6 && v[1] == 3.0));
assert!(e.tris.iter().all(|v| v.is_finite()));
}
}
+16
View File
@@ -31,3 +31,19 @@ pub fn site_multi_polygon_area(polys: &[f64]) -> f64 {
pub fn site_allowed_area(rules: &[f64]) -> Vec<f64> {
encode(&read_rules(rules).map(|r| site_rules::allowed_area(&r)).unwrap_or_default())
}
/// Zulässige Hülle im 3D ([63], `site_rules::envelope3d`) für render3d `set_ghost`:
/// `[nDreieckWerte, Dreiecke (x y z r g b a)…, Kanten (x y z r g b)…]` (Float32); leer bei Fehler.
#[wasm_bindgen]
pub fn doc_site_envelope(h: u32) -> Vec<f32> {
super::document::with_doc(h, |d| d.project().ok().map(|p| site_rules::envelope3d(&p)))
.flatten()
.map(|e| {
let mut out = Vec::with_capacity(1 + e.tris.len() + e.lines.len());
out.push(e.tris.len() as f32);
out.extend(e.tris);
out.extend(e.lines);
out
})
.unwrap_or_default()
}
+103 -1
View File
@@ -27,7 +27,7 @@ use crate::section::SectionPlane;
use crate::section_fill::{
build_cut_cap_lines, build_cut_caps, CAP_FLOATS_PER_VERTEX, CUT_LINE_FLOATS_PER_VERTEX,
};
use crate::shaders::{CAP_WGSL, GRID_WGSL, MESH_AERIAL_WGSL, MESH_TEXTURED_WGSL, MESH_WGSL};
use crate::shaders::{CAP_WGSL, GHOST_WGSL, GRID_WGSL, MESH_AERIAL_WGSL, MESH_TEXTURED_WGSL, MESH_WGSL};
use crate::types::{
Camera, Mesh, MeshInput, RoofLayerInput, SlabInput, TexturedMesh, WallInput,
FLOATS_PER_VERTEX, TEXTURED_FLOATS_PER_VERTEX,
@@ -282,6 +282,13 @@ pub struct Renderer {
/// (`depth_compare: Always`, kein Depth-Write): die Auswahl-Highlight-Linien
/// liegen immer sichtbar obenauf und scheinen auch hinter Waenden durch.
highlight_pipeline: wgpu::RenderPipeline,
/// Durchscheinende Koerper ([63] zulaessige Huelle): TriangleList, GHOST_WGSL, Vertex
/// `[pos vec3, rgba vec4]`, Alpha-Blending, Tiefentest ohne Tiefen-Write, kein Culling.
ghost_pipeline: wgpu::RenderPipeline,
/// Dreiecke (`GHOST_FLOATS_PER_VERTEX`) und Kanten (LineList wie das Gitter) der
/// durchscheinenden Koerper; None = nichts. Ueber `set_ghost`, gezeichnet nach allem Opaken.
ghost: Option<LineBuffers>,
ghost_lines: Option<LineBuffers>,
/// Schnittflaechen-Kappen (TriangleList, CAP_WGSL, eigenes Vertex-Layout
/// [pos vec3, uv vec2]). Teilt sich die `Globals`-Bind-Group; leichter
/// Depth-Bias zur Kamera hin gegen Z-Fighting mit den an der Ebene
@@ -408,6 +415,9 @@ pub struct Renderer {
pub clear_color: wgpu::Color,
}
/// Floats je Ecke der durchscheinenden Koerper: `[px,py,pz, r,g,b,a]`.
pub const GHOST_FLOATS_PER_VERTEX: usize = 7;
/// Tiefen-Textur samt View, an eine bestimmte Groesse gebunden.
struct DepthTarget {
view: wgpu::TextureView,
@@ -600,6 +610,56 @@ impl Renderer {
},
);
// Durchscheinende Koerper ([63]): nach dem Opaken gezeichnet, testen die Tiefe (Modell
// verdeckt), schreiben sie aber nicht (die Huelle verdeckt nichts), Alpha-Blending.
let ghost_module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
label: Some("ghost.wgsl"),
source: wgpu::ShaderSource::Wgsl(GHOST_WGSL.into()),
});
let ghost_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("ghost.pipeline"),
layout: Some(&pipeline_layout),
vertex: wgpu::VertexState {
module: &ghost_module,
entry_point: Some("vs_main"),
buffers: &[wgpu::VertexBufferLayout {
array_stride: (GHOST_FLOATS_PER_VERTEX * 4) as u64,
step_mode: wgpu::VertexStepMode::Vertex,
attributes: &wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x4],
}],
compilation_options: Default::default(),
},
fragment: Some(wgpu::FragmentState {
module: &ghost_module,
entry_point: Some("fs_main"),
targets: &[Some(wgpu::ColorTargetState {
format: color_format,
blend: Some(wgpu::BlendState::ALPHA_BLENDING),
write_mask: wgpu::ColorWrites::ALL,
})],
compilation_options: Default::default(),
}),
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
cull_mode: None,
..Default::default()
},
depth_stencil: Some(wgpu::DepthStencilState {
format: DEPTH_FORMAT,
depth_write_enabled: Some(false),
depth_compare: Some(wgpu::CompareFunction::Less),
stencil: wgpu::StencilState::default(),
bias: wgpu::DepthBiasState::default(),
}),
multisample: wgpu::MultisampleState {
count: SAMPLE_COUNT,
mask: !0,
alpha_to_coverage_enabled: false,
},
multiview_mask: None,
cache: None,
});
// Schnitt-Umrisslinien-Pipeline (Cut-Cap-Kanten, P2): dasselbe schlanke
// LineList-Vertex-Layout [pos vec3, color vec3] und `grid_module` (GRID_WGSL)
// wie Grid/Highlight, aber als TriangleList (die Kanten sind Ribbon-Quads,
@@ -998,6 +1058,9 @@ impl Renderer {
hidden_face_pipeline,
grid_pipeline,
highlight_pipeline,
ghost_pipeline,
ghost: None,
ghost_lines: None,
cap_pipeline,
cut_line_pipeline,
textured_pipeline,
@@ -1307,6 +1370,30 @@ impl Renderer {
});
}
/// Setzt/loescht die durchscheinenden Koerper ([63] zulaessige Huelle): `tris` = TriangleList
/// `[px,py,pz, r,g,b,a, ...]` (world, `GHOST_FLOATS_PER_VERTEX`), `lines` = LineList wie
/// `set_highlight_lines`. Leere Slices loeschen; unvollstaendige Ecken am Ende fallen weg.
pub fn set_ghost(&mut self, device: &wgpu::Device, tris: &[f32], lines: &[f32]) {
let buf = |label: &str, v: &[f32], stride: usize, per: usize| {
let n = v.len() / stride / per * per;
(n > 0).then(|| LineBuffers {
vbo: device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some(label),
contents: bytemuck::cast_slice(&v[..n * stride]),
usage: wgpu::BufferUsages::VERTEX,
}),
vertex_count: n as u32,
})
};
self.ghost = buf("ghost.vbo", tris, GHOST_FLOATS_PER_VERTEX, 3);
self.ghost_lines = buf("ghost.lines.vbo", lines, GRID_FLOATS_PER_VERTEX, 2);
}
/// Ob durchscheinende Koerper gesetzt sind (Test/Diagnose).
pub fn has_ghost(&self) -> bool {
self.ghost.is_some() || self.ghost_lines.is_some()
}
/// Setzt die Ansichtsschraffur-Linien (`pattern_lines::PATTERN_STRIDE` Floats je Linie); leer löscht.
/// Die Auswahl nach Abstand passiert im nächsten `render`.
pub fn set_pattern_lines(&mut self, data: &[f32]) {
@@ -2015,6 +2102,21 @@ impl Renderer {
}
}
// 3b) Durchscheinende Koerper ([63] zulaessige Huelle): Kanten tiefengetestet wie das
// Gitter, dann die Flaechen mit Alpha-Blending (ohne Tiefen-Write) nach allem Opaken.
if let Some(gl) = &self.ghost_lines {
pass.set_pipeline(&self.grid_pipeline);
pass.set_bind_group(0, &self.bind_group, &[]);
pass.set_vertex_buffer(0, gl.vbo.slice(..));
pass.draw(0..gl.vertex_count, 0..1);
}
if let Some(g) = &self.ghost {
pass.set_pipeline(&self.ghost_pipeline);
pass.set_bind_group(0, &self.bind_group, &[]);
pass.set_vertex_buffer(0, g.vbo.slice(..));
pass.draw(0..g.vertex_count, 0..1);
}
// 4) Auswahl-Highlight-Linien als ALLERLETZTES — ohne Tiefentest
// (`highlight_pipeline`: depth_compare Always, kein Depth-Write),
// damit die Auswahl immer sichtbar obenauf liegt und auch hinter
+7
View File
@@ -1380,5 +1380,12 @@ mod tests {
Validator::new(ValidationFlags::all(), Capabilities::all())
.validate(&aerial_module)
.unwrap_or_else(|e| panic!("aerial: WGSL-Validierung fehlgeschlagen: {e:?}"));
// Durchscheinende Koerper ([63] zulaessige Huelle).
let ghost_module = naga::front::wgsl::parse_str(super::shaders::GHOST_WGSL)
.unwrap_or_else(|e| panic!("ghost: WGSL-Parse-Fehler: {e:?}"));
Validator::new(ValidationFlags::all(), Capabilities::all())
.validate(&ghost_module)
.unwrap_or_else(|e| panic!("ghost: WGSL-Validierung fehlgeschlagen: {e:?}"));
}
}
+46
View File
@@ -507,3 +507,49 @@ mod uniformity_tests {
}
}
}
/// WGSL der durchscheinenden Körper ([63] zulässige Hülle, `gpu::ghost_pipeline`): TriangleList,
/// Vertex `[pos vec3, rgba vec4]` (world), unbeleuchtet, Alpha-Blending; Kappung an der
/// Schnittebene wie die übrigen Pfade.
pub const GHOST_WGSL: &str = r#"
struct Globals {
view_proj : mat4x4<f32>,
light_dir : vec4<f32>,
sky_color : vec4<f32>,
ground_color : vec4<f32>,
sun_color : vec4<f32>,
mode : vec4<f32>,
section_plane : vec4<f32>,
};
@group(0) @binding(0) var<uniform> globals : Globals;
struct VsIn {
@location(0) position : vec3<f32>,
@location(1) color : vec4<f32>,
};
struct VsOut {
@builtin(position) clip_pos : vec4<f32>,
@location(0) color : vec4<f32>,
@location(1) world_pos : vec3<f32>,
};
@vertex
fn vs_main(in : VsIn) -> VsOut {
var out : VsOut;
out.clip_pos = globals.view_proj * vec4<f32>(in.position, 1.0);
out.color = in.color;
out.world_pos = in.position;
return out;
}
@fragment
fn fs_main(in : VsOut) -> @location(0) vec4<f32> {
if (globals.mode.y > 0.5) {
if (dot(in.world_pos, globals.section_plane.xyz) + globals.section_plane.w > 0.0) {
discard;
}
}
return in.color;
}
"#;
+10
View File
@@ -531,6 +531,16 @@ impl WebModelRenderer {
Ok(())
}
/// Durchscheinende Koerper ([63] zulaessige Huelle, Kern `doc_site_envelope`): `data` =
/// `[nDreieckWerte, Dreiecke (x y z r g b a)…, Kanten (x y z r g b)…]` (world-Meter). Leer
/// oder ungueltig loescht. Wirkt erst beim naechsten `render`.
pub fn set_ghost(&mut self, data: &[f32]) -> Result<(), JsValue> {
let (head, rest) = data.split_first().map_or((0.0, &[][..]), |(h, r)| (*h, r));
let n = if head.is_finite() && head >= 0.0 { (head as usize).min(rest.len()) } else { 0 };
self.renderer.set_ghost(&self.device, &rest[..n], &rest[n..]);
Ok(())
}
/// Ansichtsschraffur auf den Flaechen ([100]): je Linie `ax ay az bx by bz r g b maske`
/// (`pattern_lines::PATTERN_STRIDE`), Auswahl nach Abstand je Kamera; leer loescht.
pub fn set_pattern_lines(&mut self, data: &[f32]) -> Result<(), JsValue> {
+14 -2
View File
@@ -4,8 +4,11 @@
// • Grenzabstand: gesperrt ist alles, was näher als d_i an Kante i liegt (Puffer der Kante mit
// gerundeten Enden) — so stimmen auch konkave Parzellen und einspringende Ecken.
// • Baulinie: Halbebene auf der Seite des Parzellen-Schwerpunkts.
// • Gebäude-Grundfläche: Wände aller Geschosse und freie Körper (ohne Abzugskörper). Vorsprünge
// (Dachüberstand, Balkone) und ihre Sonderregeln zählen nicht.
// • Gebäude-Grundfläche: Wände aller Geschosse und freie Körper (ohne Abzugskörper).
// • Vorsprünge (nur mit `projectionDepth`): Dachüberstände und als Vorsprung markierte Decken/Körper
// (`siteProjection`) dürfen bis zur Tiefe in den Abstand ragen, markierte zusätzlich höchstens
// auf `projectionShare` der Fassadenlänge je Grenze.
// • Zulässige Hülle im 3D (`siteEnvelope3d`, mit `show3d`): durchscheinend in render3d.
// Gerechnet wird im Rust-Kern (`src-tauri/core/src/site_rules.rs`), die Prüfung des Modells auf dem
// Projekt-Dokument; die Flächen-Hilfen (`allowedArea`, `multiPolygonArea`) nehmen flache Daten.
@@ -70,3 +73,12 @@ export function checkSiteRules(project: Project): SiteCheck | null {
if (!project.siteRules) return null;
return documentFor(project).query<SiteCheck | null>("siteCheck");
}
/**
* Zulässige Hülle im 3D ([63], Kern `site_rules::envelope3d`) für render3d `set_ghost`:
* `[nDreieckWerte, Dreiecke (x y z r g b a)…, Kanten (x y z r g b)…]`; leer ohne Baurecht oder `show3d`.
*/
export function siteEnvelope3d(project: Project): Float32Array {
if (project.siteRules?.show3d !== true) return new Float32Array(0);
return documentFor(project).siteEnvelope();
}
+5
View File
@@ -224,6 +224,11 @@ export class ProjectDocument {
return this.handle ? core().doc_drawing_line_verts(this.handle, explode) : new Float32Array(0);
}
/** Zulässige Hülle im 3D ([63]) für render3d `set_ghost`; leer ohne Baurecht oder `siteRules.show3d`. */
siteEnvelope(): Float32Array {
return this.handle ? core().doc_site_envelope(this.handle) : new Float32Array(0);
}
/** Ansichtsschraffur auf den Flächen (Wände, Decken, Dächer) für render3d `set_pattern_lines`. */
surfacePatternLines(explode = 0): Float32Array {
return this.handle ? core().doc_surface_pattern_lines(this.handle, explode) : new Float32Array(0);
+1
View File
@@ -44,6 +44,7 @@ export type { AreaReport, AreaReportOptions } from "../export/areaReport";
export { sunPosition, shadowPolygons, shadowOfPrism, projectLatLon } from "../analysis/sun";
export type { SunPosition } from "../analysis/sun";
export { checkSiteRules, allowedArea, multiPolygonArea, buildingFootprint, modelTop } from "../analysis/siteRules";
export { siteEnvelope3d } from "../analysis/siteRules";
export { excavationQuantities, type ExcavationQuantity } from "../analysis/excavation";
export type { SiteCheck } from "../analysis/siteRules";
export { sampleProject } from "../model/sampleProject";
+8
View File
@@ -2531,6 +2531,14 @@ export const de = {
"siteRules.addLine": "Baulinie aus Auswahl",
"siteRules.addLine.hint": "Eine Linie wählen; das Gebäude bleibt auf der Seite der Parzelle.",
"siteRules.clearLines": "Alle Baulinien entfernen",
"siteRules.show3d": "Hülle im 3D",
"siteRules.show3d.hint": "Zulässige Hülle (zulässige Fläche bis zur Gesamthöhe) im 3D durchscheinend zeigen, Verstösse rot.",
"siteRules.projectionDepth": "Vorsprünge bis",
"siteRules.projectionDepth.hint": "Dachüberstände und markierte Vorsprünge (Balkone, Erker) dürfen so weit in den Grenzabstand bzw. über die Baulinie ragen. Leer = keine Vorsprungsregel.",
"siteRules.projectionShare": "Vorsprünge max. Anteil Fassade",
"siteRules.projectionShare.hint": "Höchstens dieser Anteil der Fassadenlänge je Grenze darf von markierten Vorsprüngen belegt sein (Dachüberstände zählen nicht). Leer = unbegrenzt.",
"siteRules.markProjection": "Auswahl ist Vorsprung (Balkon, Erker)",
"siteRules.markProjection.hint": "Gewählte Decke oder gewählten Körper als Vorsprung nach der Vorsprungsregel prüfen.",
"clash.none": "Keine Kollisionen gefunden.",
"clash.run": "Prüfung starten",
"clash.running": "Prüfung läuft …",
+8
View File
@@ -2481,6 +2481,14 @@ export const en: Record<TranslationKey, string> = {
"siteRules.addLine": "Building line from selection",
"siteRules.addLine.hint": "Select a line; the building stays on the parcel side.",
"siteRules.clearLines": "Remove all building lines",
"siteRules.show3d": "Envelope in 3D",
"siteRules.show3d.hint": "Show the permissible envelope (permissible area up to the total height) translucent in 3D, violations in red.",
"siteRules.projectionDepth": "Projections up to",
"siteRules.projectionDepth.hint": "Roof overhangs and marked projections (balconies, bay windows) may extend this far into the setback or beyond the building line. Empty = no projection rule.",
"siteRules.projectionShare": "Projections max. share of façade",
"siteRules.projectionShare.hint": "At most this share of the façade length per boundary may be taken by marked projections (roof overhangs do not count). Empty = unlimited.",
"siteRules.markProjection": "Selection is a projection (balcony, bay window)",
"siteRules.markProjection.hint": "Check the selected slab or solid as a projection under the projection rule.",
"clash.run": "Run check",
"clash.running": "Checking …",
"clash.clear": "Clear",
+25
View File
@@ -70,6 +70,11 @@ export type Ceiling = {
floorId: string;
/** Grafik-Kategorie (Ebene), z. B. "30" für Decken. */
categoryCode: string;
/**
* Vorsprung im Baurecht ([63]: Balkon, Erker): darf mit `SiteRules.projectionDepth`/
* `projectionShare` in den Grenzabstand ragen. Fehlt ⇒ normales Bauteil.
*/
siteProjection?: boolean;
/** Objekt-Sperre, analog `Wall.locked`. */
locked?: boolean;
/** Aussen (true) / innen (false); fehlt = nicht angegeben (IFC `IsExternal`). */
@@ -1230,6 +1235,11 @@ export type ExtrudedSolid = {
* Fehlt = normaler Körper.
*/
operation?: "subtract";
/**
* Vorsprung im Baurecht ([63]: Balkon, Erker): darf mit `SiteRules.projectionDepth`/
* `projectionShare` in den Grenzabstand ragen. Fehlt ⇒ normales Bauteil.
*/
siteProjection?: boolean;
/**
* Gesetzt, wenn das Profil ein Kreis ist (aus einem `Drawing2D` mit
* `shape:"circle"`) — `points` bleibt die Tessellierung, `toWalls3d.ts`
@@ -2849,6 +2859,21 @@ export type SiteRules = {
maxHeight?: number;
/** Parzelle, zulässige Fläche und Verstösse im Grundriss zeigen (Default: ja). */
show?: boolean;
/**
* Zulässige Hülle (zulässige Fläche bis zur Gesamthöhe) im 3D durchscheinend zeigen (Default: nein).
*/
show3d?: boolean;
/**
* Vorsprünge ([63]): zulässige Tiefe (m) in den Grenzabstand bzw. über die Baulinie für
* Dachüberstände und als Vorsprung markierte Bauteile (`siteProjection`). Fehlt ⇒ keine
* Vorsprungsregel (Dächer und Decken werden nicht geprüft, wie bisher).
*/
projectionDepth?: number;
/**
* Vorsprünge ([63]): höchster Anteil (0..1) der Fassadenlänge, den markierte Vorsprünge
* (Balkone, Erker; nicht Dachüberstände) je Grenze/Baulinie einnehmen dürfen. Fehlt ⇒ unbegrenzt.
*/
projectionShare?: number;
};
/** Terminierungs-Regel einer Wand am Deckenanschluss (siehe {@link Wall.sliceTermination}). */
+94 -1
View File
@@ -5,7 +5,7 @@
import { t } from "../i18n";
import { usePanelHost } from "./host";
import { useStore } from "../state/appStore";
import { checkSiteRules, setField } from "../core";
import { checkSiteRules, patchItem, setField } from "../core";
import type { Project, SiteRules } from "../model/types";
import { lineFromDrawing, parcelFromDrawing } from "./siteRulesInput";
@@ -18,6 +18,28 @@ function parseLen(text: string): number | undefined | null {
return Number.isFinite(v) && v >= 0 ? v : null;
}
/** Gewählte Decke/Körper, der als Vorsprung markiert werden kann, samt aktuellem Stand. */
function projectionTarget(
p: Project,
sel: { kind: string; id: string } | null | undefined,
): { kind: "ceiling" | "extrudedSolid"; id: string; flag: boolean } | null {
if (sel?.kind === "ceiling") {
const c = p.ceilings?.find((x) => x.id === sel.id);
return c ? { kind: "ceiling", id: c.id, flag: c.siteProjection === true } : null;
}
if (sel?.kind === "extrudedSolid") {
const x = p.extrudedSolids?.find((e) => e.id === sel.id);
return x && x.operation !== "subtract" ? { kind: "extrudedSolid", id: x.id, flag: x.siteProjection === true } : null;
}
return null;
}
/** Vorsprung-Markierung setzen (true) oder entfernen (Feld fehlt = normales Bauteil). */
function withProjection<T extends { siteProjection?: boolean }>(e: T, on: boolean): T {
const { siteProjection: _old, ...rest } = e;
return (on ? { ...rest, siteProjection: true } : rest) as T;
}
export function SiteRulesSection() {
const host = usePanelHost();
const applyChange = useStore((s) => s.applyChange);
@@ -26,6 +48,8 @@ export function SiteRulesSection() {
const selDrawing = sel?.kind === "drawing2d" ? host.project.drawings2d.find((d) => d.id === sel.id) : undefined;
const selParcel = parcelFromDrawing(selDrawing);
const selLine = lineFromDrawing(selDrawing);
// Vorsprung markieren: gewählte Decke (Balkon) oder freier Körper (Erker).
const selProjection = projectionTarget(host.project, sel);
const write = (fn: (r: SiteRules) => SiteRules | undefined, key?: string) =>
applyChange((p: Project) => {
@@ -71,6 +95,14 @@ export function SiteRulesSection() {
/>
<span>{t("siteRules.show")}</span>
</label>
<label className="sun-row" title={t("siteRules.show3d.hint")}>
<input
type="checkbox"
checked={rules.show3d === true}
onChange={(e) => write((r) => ({ ...r, show3d: e.target.checked }))}
/>
<span>{t("siteRules.show3d")}</span>
</label>
</div>
{check && (
@@ -131,6 +163,67 @@ export function SiteRulesSection() {
<span>m</span>
</label>
<label className="kz-parcel" title={t("siteRules.projectionDepth.hint")}>
<span>{t("siteRules.projectionDepth")}</span>
<input
type="number"
min={0}
step={0.1}
className="kz-input kz-num"
value={rules.projectionDepth ?? ""}
placeholder="–"
onChange={(e) => {
const v = parseLen(e.target.value);
if (v === null) return;
write((r) => {
const { projectionDepth: _old, ...rest } = r;
return v === undefined ? rest : { ...rest, projectionDepth: v };
}, "siteRules:projectionDepth");
}}
/>
<span>m</span>
</label>
{rules.projectionDepth !== undefined && (
<label className="kz-parcel" title={t("siteRules.projectionShare.hint")}>
<span>{t("siteRules.projectionShare")}</span>
<input
type="number"
min={0}
max={100}
step={5}
className="kz-input kz-num"
value={rules.projectionShare === undefined ? "" : Math.round(rules.projectionShare * 1000) / 10}
placeholder="–"
onChange={(e) => {
const v = parseLen(e.target.value);
if (v === null) return;
write((r) => {
const { projectionShare: _old, ...rest } = r;
return v === undefined ? rest : { ...rest, projectionShare: v / 100 };
}, "siteRules:projectionShare");
}}
/>
<span>%</span>
</label>
)}
{rules.projectionDepth !== undefined && selProjection && (
<label className="sun-row" title={t("siteRules.markProjection.hint")}>
<input
type="checkbox"
checked={selProjection.flag}
onChange={(e) => {
const v = e.target.checked;
applyChange((p: Project) =>
selProjection.kind === "ceiling"
? patchItem(p, "ceilings", selProjection.id, (c) => withProjection(c, v))
: patchItem(p, "extrudedSolids", selProjection.id, (x) => withProjection(x, v)),
);
}}
/>
<span>{t("siteRules.markProjection")}</span>
</label>
)}
<details className="site-rules-edges">
<summary>{t("siteRules.edges", { n })}</summary>
{rules.parcel.map((p, i) => {
+10 -1
View File
@@ -18,7 +18,7 @@
import { useCallback, useEffect, useRef, useState } from "react";
import type { ContextImage, Project } from "../model/types";
import { emitDrawingLineVerts, emitSurfacePatternLines, projectToModel3d } from "../core";
import { emitDrawingLineVerts, emitSurfacePatternLines, projectToModel3d, siteEnvelope3d } from "../core";
import type { DetailLevel } from "../model/viewTypes";
import { loadEngine3d } from "../engine/engine3d";
import { decodeMaterialTextures } from "./materialTextures";
@@ -96,6 +96,8 @@ interface WebModelRendererLike {
set_drawing_lines?(vertices: Float32Array): void;
/** Ansichtsschraffur auf den Flächen (`web::set_pattern_lines`), in den Kanten-Stilen gezeichnet. */
set_pattern_lines?(data: Float32Array): void;
/** Durchscheinende Körper ([63] zulässige Hülle, `web::set_ghost`): Format von `siteEnvelope3d`; leer löscht. */
set_ghost?(data: Float32Array): void;
/** Material-Farbkarten (Stil „textured") als Textur-Array hochladen
* (`web::set_material_textures`). `rgba` = gepackte RGBA8-Bytes von
* `layerCount` 256×256-Ebenen; Ebene 0 bleibt intern das Fallback-Schachbrett,
@@ -251,6 +253,13 @@ export function useWasm3dRenderer(
console.warn("render3d set_drawing_lines fehlgeschlagen:", e);
}
}
if (typeof r.set_ghost === "function") {
try {
r.set_ghost(siteEnvelope3d(project));
} catch (e) {
console.warn("render3d set_ghost fehlgeschlagen:", e);
}
}
if (typeof r.set_pattern_lines === "function") {
try {
r.set_pattern_lines(emitSurfacePatternLines(project, explode));