[68] [T6] [112] [G5] Baugrube: Griffe, Arbeitsraum, Verbau, Überlagerung; Höhenlinien-Lücke, Raster-Glättung, Luftbild-Farben; Achsen-Beschriftung/Blasenseite, IfcGrid; Gauben-Hinweis

TODO.md nachgeführt (30.10.): Offen-Listen der vier Einträge aktualisiert.
This commit is contained in:
Claude committed 2026-10-30 11:22:02 +00:00
1 parent 32810725de
commit 40d86fd5c0
38 files changed
+1074 -78

No files matched your search

+43
View File
@@ -214,6 +214,37 @@ pub fn geometry(p: &Project, roof: &Roof, d: &Dormer) -> Option<DormerGeom> {
Some(g2)
}
/// Zustand einer Gaube für die Hülle ([G5]): am First gekappt (`clamped`, `effective_height` = tatsächliche
/// Stirnhöhe) oder nicht herstellbar (`invalid`).
#[derive(Debug, serde::Serialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct DormerStatus {
pub roof_id: String,
pub dormer_id: String,
pub clamped: bool,
pub invalid: bool,
pub effective_height: f64,
}
/// Zustand aller Gauben des Projekts (nur solche, die gekappt oder ungültig sind, sind für die UI wichtig;
/// hier alle, damit die Hülle auch „wieder in Ordnung" erkennt).
pub fn status(p: &Project) -> Vec<DormerStatus> {
let mut out = Vec::new();
for roof in p.roofs.as_deref().unwrap_or(&[]) {
for d in roof.dormers.as_deref().unwrap_or(&[]) {
let g = geometry(p, roof, d);
out.push(DormerStatus {
roof_id: roof.id.clone(),
dormer_id: d.id.clone(),
clamped: g.as_ref().is_some_and(|g| g.clamped),
invalid: g.is_none(),
effective_height: g.as_ref().map_or(0.0, |g| g.front_height),
});
}
}
out
}
fn geometry_raw(p: &Project, roof: &Roof, d: &Dormer) -> Option<DormerGeom> {
let frame = frame(p, roof, d)?;
if !(finite_pos(d.width) && d.width >= 0.4 && d.width <= 30.0 && finite_pos(d.front_height) && d.front_height <= 10.0) {
@@ -479,6 +510,18 @@ pub(crate) mod tests {
.unwrap()
}
#[test]
fn status_meldet_gekappte_gauben() {
let mut p = gable_project();
let st = status(&p);
assert_eq!(st.len(), 1);
assert!(!st[0].clamped && !st[0].invalid && (st[0].effective_height - 1.6).abs() < 1e-9, "{st:?}");
p.roofs.as_mut().unwrap()[0].dormers.as_mut().unwrap()[0].front_height = 6.0;
let st = status(&p);
assert!(st[0].clamped && !st[0].invalid && st[0].effective_height < 6.0 && st[0].effective_height > 0.3, "{st:?}");
assert_eq!((st[0].roof_id.as_str(), st[0].dormer_id.as_str()), ("R1", "D1"));
}
#[test]
fn zu_hohe_gaube_wird_vor_dem_first_gekappt() {
let mut p = gable_project();
+194 -28
View File
@@ -34,6 +34,8 @@ pub struct ExSpec {
pub ring: Vec<P2>,
pub bottom: f64,
pub cut_tan: Vec<f64>,
/// Kante mit senkrechtem Verbau (Spundwand): keine Böschung, keine Schraffur.
pub shored: Vec<bool>,
pub fill_tan: f64,
pub berm_w: f64,
pub berm_h: f64,
@@ -65,6 +67,30 @@ fn signed_area(r: &[P2]) -> f64 {
(0..n).map(|i| r[i][0] * r[(i + 1) % n][1] - r[(i + 1) % n][0] * r[i][1]).sum::<f64>() / 2.0
}
/// Umriss (gegen den Uhrzeigersinn) um `d` nach aussen versetzt: Gehrung an den Ecken, höchstens 4·d weit.
pub fn offset_ring(ring: &[P2], d: f64) -> Vec<P2> {
let n = ring.len();
let normal = |i: usize| {
let (a, b) = (ring[i], ring[(i + 1) % n]);
let l = (b[0] - a[0]).hypot(b[1] - a[1]).max(1e-12);
[(b[1] - a[1]) / l, -(b[0] - a[0]) / l]
};
(0..n)
.map(|i| {
let (n0, n1) = (normal((i + n - 1) % n), normal(i));
let (mx, my) = (n0[0] + n1[0], n0[1] + n1[1]);
let k = 1.0 + n0[0] * n1[0] + n0[1] * n1[1];
if k < 1e-6 {
return [ring[i][0] + n1[0] * d, ring[i][1] + n1[1] * d];
}
let (sx, sy) = (mx * d / k, my * d / k);
let l = sx.hypot(sy);
let f = if l > 4.0 * d { 4.0 * d / l } else { 1.0 };
[ring[i][0] + sx * f, ring[i][1] + sy * f]
})
.collect()
}
impl ExSpec {
/// Aus dem Modell; `dz` = Höhenbezug des Netzes ([`datum`]). `None` bei kaputtem Umriss.
pub fn of(e: &Excavation, dz: f64) -> Option<ExSpec> {
@@ -78,21 +104,29 @@ impl ExSpec {
}
let n = ring.len();
let slope = e.slope.filter(|s| s.is_finite() && *s > 0.0).unwrap_or(DEFAULT_SLOPE);
let mut cut_tan: Vec<f64> = (0..n).map(|i| tan_deg(e.edge_slopes.as_ref().and_then(|v| v.get(i)).copied().filter(|s| s.is_finite() && *s > 0.0).unwrap_or(slope))).collect();
let mut shored: Vec<bool> = (0..n).map(|i| e.edge_shoring.as_ref().and_then(|v| v.get(i)).copied().unwrap_or(false)).collect();
let mut cut_tan: Vec<f64> = (0..n).map(|i| if shored[i] { tan_deg(89.5) } else { tan_deg(e.edge_slopes.as_ref().and_then(|v| v.get(i)).copied().filter(|s| s.is_finite() && *s > 0.0).unwrap_or(slope)) }).collect();
if signed_area(&ring) < 0.0 {
// Kante i (p_i → p_i+1) wird nach dem Umdrehen Kante n−2−i (mod n).
ring.reverse();
let old = cut_tan.clone();
let (old, old_s) = (cut_tan.clone(), shored.clone());
for i in 0..n {
cut_tan[(2 * n - 2 - i) % n] = old[i];
shored[(2 * n - 2 - i) % n] = old_s[i];
}
}
// Arbeitsraum: Sohle um `workingSpace` nach aussen (Gehrung, höchstens 4× so weit an spitzen Ecken).
let ws = e.working_space.filter(|v| v.is_finite() && *v > 0.0).unwrap_or(0.0);
if ws > 0.0 {
ring = offset_ring(&ring, ws);
}
let bw = e.berm_width.filter(|v| v.is_finite() && *v > 0.0).unwrap_or(0.0);
let bh = e.berm_height.filter(|v| v.is_finite() && *v > 0.0).unwrap_or(0.0);
Some(ExSpec {
ring,
bottom: e.bottom + dz,
cut_tan,
shored,
fill_tan: tan_deg(e.fill_slope.filter(|s| s.is_finite() && *s > 0.0).unwrap_or(DEFAULT_FILL_SLOPE)),
berm_w: if bh > 0.0 { bw } else { 0.0 },
berm_h: if bw > 0.0 { bh } else { 0.0 },
@@ -374,38 +408,68 @@ pub struct Volumes {
pub bottom_area: f64,
}
/// Integriert (t − neu) über ein Raster der Weite ≤ `h` (Mittelpunkte, höchstens ~1.5 Mio. Proben).
/// Mengen mehrerer Baugruben ohne Doppelzählung: die Baugruben wirken der Reihe nach (wie in [`site_terrain`]),
/// je Probe geht der Höhenunterschied einer Baugrube an sie allein — die Summe ist die Vereinigung.
/// Integriert über ein Raster der Weite ≤ `h` (Mittelpunkte, höchstens ~1.5 Mio. Proben).
/// `footprint`: Gebäude-Grundfläche (Ringe); Abtrag darin zählt nicht zur Hinterfüllung.
pub fn volumes(orig: &Tin, ex: &ExSpec, h: f64, footprint: &[Vec<P2>]) -> Volumes {
/// Sohlenfläche = Fläche des Umrisses ohne die der vorherigen Baugruben (Überlappung per Raster).
pub fn volumes_union(orig: &Tin, specs: &[&ExSpec], h: f64, footprint: &[Vec<P2>]) -> Vec<Volumes> {
if specs.is_empty() {
return Vec::new();
}
let idx = TinIndex::new(orig);
let r = ex.reach_in(orig, &idx);
let b = ex.bbox();
let reg = [b[0] - r, b[1] - r, b[2] + r, b[3] + r];
let mut reg = [f64::INFINITY, f64::INFINITY, f64::NEG_INFINITY, f64::NEG_INFINITY];
for ex in specs {
let (b, r) = (ex.bbox(), ex.reach_in(orig, &idx));
reg = [reg[0].min(b[0] - r), reg[1].min(b[1] - r), reg[2].max(b[2] + r), reg[3].max(b[3] + r)];
}
let (w, hh) = (reg[2] - reg[0], reg[3] - reg[1]);
let mut h = h.max(1e-3);
while (w / h).ceil() * (hh / h).ceil() > 1.5e6 {
h *= 1.2;
}
let (nx, ny) = ((w / h).ceil() as usize, (hh / h).ceil() as usize);
let (nx, ny) = (((w / h).ceil() as usize).max(1), ((hh / h).ceil() as usize).max(1));
let (hx, hy) = (w / nx as f64, hh / ny as f64);
let cell = hx * hy;
let mut v = Volumes { bottom_area: signed_area(&ex.ring).abs(), ..Default::default() };
let boxes: Vec<[f64; 4]> = specs.iter().map(|e| e.bbox()).collect();
let overlaps: Vec<bool> = (0..specs.len())
.map(|k| (0..k).any(|j| boxes[j][0] < boxes[k][2] && boxes[k][0] < boxes[j][2] && boxes[j][1] < boxes[k][3] && boxes[k][1] < boxes[j][3]))
.collect();
let mut out: Vec<Volumes> = specs.iter().map(|e| Volumes { bottom_area: signed_area(&e.ring).abs(), ..Default::default() }).collect();
let mut shared = vec![0.0; specs.len()];
for j in 0..ny {
for i in 0..nx {
let p = [reg[0] + (i as f64 + 0.5) * hx, reg[1] + (j as f64 + 0.5) * hy];
let Some(t) = idx.z_at(p[0], p[1]) else { continue };
let dz = t - ex.apply(t, p);
if dz > 0.0 {
v.cut += dz * cell;
if !footprint.iter().any(|f| point_in_ring(p, f)) {
v.backfill += dz * cell;
let mut cur = t;
let outside_fp = !footprint.iter().any(|f| point_in_ring(p, f));
for (k, ex) in specs.iter().enumerate() {
if overlaps[k] && p[0] >= boxes[k][0] && p[0] <= boxes[k][2] && p[1] >= boxes[k][1] && p[1] <= boxes[k][3] && point_in_ring(p, &ex.ring) && (0..k).any(|q| point_in_ring(p, &specs[q].ring)) {
shared[k] += cell;
}
} else {
v.fill -= dz * cell;
let next = ex.apply(cur, p);
let dz = cur - next;
if dz > 0.0 {
out[k].cut += dz * cell;
if outside_fp {
out[k].backfill += dz * cell;
}
} else {
out[k].fill -= dz * cell;
}
cur = next;
}
}
}
v
for (v, s) in out.iter_mut().zip(shared) {
v.bottom_area = (v.bottom_area - s).max(0.0);
}
out
}
/// Mengen einer einzelnen Baugrube (s. [`volumes_union`]).
pub fn volumes(orig: &Tin, ex: &ExSpec, h: f64, footprint: &[Vec<P2>]) -> Volumes {
volumes_union(orig, &[ex], h, footprint).pop().unwrap_or_default()
}
// ── Gelände mit Baugruben, zwischengespeichert ──────────────────────────────
@@ -492,6 +556,40 @@ pub fn terrain_model_mesh<'a>(p: &Project, t: &'a TerrainMesh) -> (std::borrow::
(Cow::Owned(pos), Cow::Owned(idx), st.modified.is_some())
}
/// [T6] Luftbild-Farben (flach r,g,b je Eckpunkt des Original-Netzes) auf das geänderte Gelände übertragen:
/// jeder neue Eckpunkt erhält die in der Grundrissprojektion (x, y) des Originals interpolierte Farbe
/// (Böschungen und Sohle bekommen so die Farbe des Bildes darüber); ausserhalb der nächste Eckpunkt.
pub fn reproject_colors(orig: &Tin, colors: &[f64], new: &Tin) -> Vec<f64> {
let idx = TinIndex::new(orig);
let col = |i: usize| -> [f64; 3] { [colors[3 * i], colors[3 * i + 1], colors[3 * i + 2]] };
let mut out = Vec::with_capacity(new.xy.len() * 3);
for p in &new.xy {
let c = match idx.bary_at(p[0], p[1]) {
Some((t, l)) => {
let (a, b, c) = (col(t[0]), col(t[1]), col(t[2]));
[0, 1, 2].map(|k| l[0] * a[k] + l[1] * b[k] + l[2] * c[k])
}
None => {
let n = orig.xy.iter().enumerate().min_by(|a, b| (a.1[0] - p[0]).hypot(a.1[1] - p[1]).total_cmp(&(b.1[0] - p[0]).hypot(b.1[1] - p[1]))).map_or(0, |x| x.0);
col(n)
}
};
out.extend(c);
}
out
}
/// Vertex-Farben des Geländes im Modell: unverändert, oder auf das Netz mit Baugruben übertragen.
/// `None` ohne (passende) Farben.
pub fn terrain_vertex_colors(p: &Project, t: &TerrainMesh) -> Option<Vec<f64>> {
let c = t.vertex_colors.as_ref().filter(|v| !v.is_empty())?;
let st = site_terrain(p, t);
match &st.modified {
None => Some(c.clone()),
Some(m) => (c.len() == st.orig.xy.len() * 3).then(|| reproject_colors(&st.orig, c, m)),
}
}
/// Mengen je Baugrube (gegen das gewachsene Terrain des ersten Netzes, das sie trifft).
#[derive(Debug, serde::Serialize)]
#[serde(rename_all = "camelCase")]
@@ -507,18 +605,27 @@ pub struct ExQty {
pub fn quantities(p: &Project) -> Vec<ExQty> {
let fp: Vec<Vec<P2>> = crate::site_rules::building_footprint(p).iter().flat_map(|poly| poly.first().map(|r| r.iter().map(|v| [v.x, v.y]).collect::<Vec<P2>>())).collect();
let mut out = Vec::new();
for e in excavations(p) {
for t in terrains(p) {
let st = site_terrain(p, t);
let Some((_, spec, _)) = st.items.iter().find(|(id, ..)| *id == e.id) else { continue };
let h = (spec.ring.iter().map(|q| q[0]).fold(f64::NEG_INFINITY, f64::max) - spec.ring.iter().map(|q| q[0]).fold(f64::INFINITY, f64::min)).max(1.0) / 400.0;
let v = volumes(&st.orig, spec, h.clamp(0.02, 0.5), &fp);
out.push(ExQty { id: e.id.clone(), name: e.name.clone(), bottom: e.bottom, bottom_area: v.bottom_area, cut: v.cut, fill: v.fill, backfill: v.backfill });
break;
let mut done: Vec<ExQty> = Vec::new();
// Je Gelände-Netz alle Baugruben, die es trifft, zusammen (Überlagerungen zählen einmal).
for t in terrains(p) {
let st = site_terrain(p, t);
let hits: Vec<&(String, ExSpec, Vec<Vec<P2>>)> = st.items.iter().filter(|(id, ..)| !done.iter().any(|q| q.id == *id)).collect();
if hits.is_empty() {
continue;
}
let specs: Vec<&ExSpec> = hits.iter().map(|(_, s, _)| s).collect();
let (x0, x1) = specs.iter().flat_map(|s| s.ring.iter().map(|q| q[0])).fold((f64::INFINITY, f64::NEG_INFINITY), |a, x| (a.0.min(x), a.1.max(x)));
let h = ((x1 - x0).max(1.0) / 400.0).clamp(0.02, 0.5);
let vols = volumes_union(&st.orig, &specs, h, &fp);
for ((id, ..), v) in hits.iter().zip(vols) {
let Some(e) = excavations(p).into_iter().find(|e| e.id == *id) else { continue };
done.push(ExQty { id: e.id.clone(), name: e.name.clone(), bottom: e.bottom, bottom_area: v.bottom_area, cut: v.cut, fill: v.fill, backfill: v.backfill });
}
}
out
// Reihenfolge wie im Modell.
let order: Vec<&str> = excavations(p).iter().map(|e| e.id.as_str()).collect();
done.sort_by_key(|q| order.iter().position(|i| *i == q.id).unwrap_or(usize::MAX));
done
}
/// Höhe des gewachsenen (`designed = false`) bzw. gestalteten Terrains im Modellbezug; `None` ohne Gelände.
@@ -568,6 +675,9 @@ pub fn slope_hatch(t: &Tin, ex: &ExSpec, spacing: f64) -> Vec<(P2, P2)> {
let (a, b) = (ex.ring[i], ex.ring[(i + 1) % n]);
let len = (b[0] - a[0]).hypot(b[1] - a[1]);
let nn = normal(i);
if ex.shored[i] {
continue;
}
let k = (len / spacing).floor() as usize;
let off = (len - k as f64 * spacing) / 2.0;
for s in 0..=k {
@@ -580,7 +690,7 @@ pub fn slope_hatch(t: &Tin, ex: &ExSpec, spacing: f64) -> Vec<(P2, P2)> {
// Fächer an der konvexen Ecke b.
let n2 = normal((i + 1) % n);
let cross = nn[0] * n2[1] - nn[1] * n2[0];
if cross > 1e-9 {
if cross > 1e-9 && !ex.shored[(i + 1) % n] {
let a0 = nn[1].atan2(nn[0]);
let mut a1 = n2[1].atan2(n2[0]);
if a1 < a0 {
@@ -671,6 +781,62 @@ mod tests {
}
}
#[test]
fn arbeitsraum_verbau_und_ueberlappung() {
// Arbeitsraum 1 m: Sohle 12 × 12 statt 10 × 10 (Gehrung), Mengen wachsen entsprechend.
let mut e = square(5.0, -3.0);
e.working_space = Some(1.0);
let ws = ExSpec::of(&e, 0.0).unwrap();
assert!((signed_area(&ws.ring) - 144.0).abs() < 1e-9, "{}", signed_area(&ws.ring));
// Senkrechter Verbau auf allen Kanten: Abtrag = Sohle × Tiefe (kaum Böschung), keine Schraffur.
let mut e = square(5.0, -3.0);
e.edge_shoring = Some(vec![true; 4]);
let sh = ExSpec::of(&e, 0.0).unwrap();
let t = flat(0.0, 50.0);
let v = volumes(&t, &sh, 0.05, &[]);
assert!((v.cut - 300.0).abs() < 0.03 * 300.0, "{}", v.cut);
assert!(slope_hatch(&t, &sh, 0.5).is_empty());
// Nur eine Kante verbaut: Hatch an den anderen drei bleibt, Index folgt dem Umlaufsinn (auch im Uhrzeigersinn).
let mut e = square(5.0, -3.0);
e.outline.reverse();
e.edge_shoring = Some(vec![true, false, false, false]);
let one = ExSpec::of(&e, 0.0).unwrap();
assert_eq!(one.shored.iter().filter(|b| **b).count(), 1);
// Überlagerung: zwei sich überdeckende Gruben zählen die gemeinsame Fläche einmal.
let mut a = square(5.0, -3.0);
a.id = "a".into();
let mut b = square(5.0, -3.0);
b.id = "b".into();
let (sa, sb) = (ExSpec::of(&a, 0.0).unwrap(), ExSpec::of(&b, 0.0).unwrap());
let single = volumes(&t, &sa, 0.1, &[]);
let both = volumes_union(&t, &[&sa, &sb], 0.1, &[]);
assert!((both[0].cut + both[1].cut - single.cut).abs() < 1e-6, "{} vs {}", both[0].cut + both[1].cut, single.cut);
assert!(both[1].cut.abs() < 1e-6 && both[1].bottom_area < 1.0, "{:?}", both[1]);
// Teilweise versetzt: Summe < Summe der Einzelmengen, > jede einzelne.
let mut c = square(5.0, -3.0);
for q in &mut c.outline {
q.x += 6.0;
}
let sc = ExSpec::of(&c, 0.0).unwrap();
let sep = volumes(&t, &sc, 0.1, &[]);
let u = volumes_union(&t, &[&sa, &sc], 0.1, &[]);
let sum = u[0].cut + u[1].cut;
assert!(sum < single.cut + sep.cut - 1.0 && sum > single.cut, "{sum}");
}
#[test]
fn luftbildfarben_auf_geaendertem_gelaende() {
// Original-Netz mit Farbverlauf in x; nach der Baugrube behalten alle neuen Punkte die Farbe ihrer (x, y).
let t = flat(0.0, 50.0);
let colors: Vec<f64> = t.xy.iter().flat_map(|p| [(p[0] + 50.0) / 100.0, 0.5, 0.25]).collect();
let r = excavate(&t, &ExSpec::of(&square(5.0, -3.0), 0.0).unwrap()).unwrap();
let c = reproject_colors(&t, &colors, &r.tin);
assert_eq!(c.len(), r.tin.xy.len() * 3);
for (p, q) in r.tin.xy.iter().zip(c.chunks(3)) {
assert!((q[0] - (p[0] + 50.0) / 100.0).abs() < 1e-9 && (q[1] - 0.5).abs() < 1e-9, "{p:?} {q:?}");
}
}
#[test]
fn auftrag_am_hang_und_bermen() {
// Hang 10 %: Plattform auf ±0 schneidet bergseits ein und wird talseits geschüttet.
+38 -9
View File
@@ -84,7 +84,8 @@ impl<'a> Spec<'a> {
/// Alle Achsen (Index: `a` zuerst, dann `b`).
pub fn axes(&self) -> Vec<Axis> {
let want = |start: bool| match self.bubbles {
// Blasenseite: die der Achse, sonst die des Rasters.
let want = |g: &GridAxis, start: bool| match g.bubble.unwrap_or(self.bubbles) {
GridBubbles::Both => true,
GridBubbles::Start => start,
GridBubbles::End => !start,
@@ -101,7 +102,7 @@ impl<'a> Spec<'a> {
index: i as u32,
label: g.label.clone(),
shape: Shape::Line { a: p0, b: p1 },
bubbles: [want(true).then_some((p0, d0)), want(false).then_some((p1, d1))],
bubbles: [want(g, true).then_some((p0, d0)), want(g, false).then_some((p1, d1))],
});
}
for (j, g) in self.b.iter().enumerate() {
@@ -111,7 +112,7 @@ impl<'a> Spec<'a> {
index: (self.a.len() + j) as u32,
label: g.label.clone(),
shape: Shape::Line { a: p0, b: p1 },
bubbles: [want(true).then_some((p0, d0)), want(false).then_some((p1, d1))],
bubbles: [want(g, true).then_some((p0, d0)), want(g, false).then_some((p1, d1))],
});
}
return out;
@@ -126,7 +127,7 @@ impl<'a> Spec<'a> {
index: i as u32,
label: g.label.clone(),
shape: Shape::Line { a: self.origin, b: end },
bubbles: [None, (self.bubbles != GridBubbles::Start).then_some((end, u))],
bubbles: [None, (g.bubble.unwrap_or(self.bubbles) != GridBubbles::Start).then_some((end, u))],
});
}
let (t0, t1) = Self::span(self.a);
@@ -147,8 +148,8 @@ impl<'a> Spec<'a> {
label: g.label.clone(),
shape: Shape::Arc { c: self.origin, r, a0, a1 },
bubbles: [
(!full && want(true)).then(|| (at(a0), tan(a0, -1.0))),
(if full { self.bubbles != GridBubbles::Start } else { want(false) }).then(|| (at(a1), tan(a1, 1.0))),
(!full && want(g, true)).then(|| (at(a0), tan(a0, -1.0))),
(if full { g.bubble.unwrap_or(self.bubbles) != GridBubbles::Start } else { want(g, false) }).then(|| (at(a1), tan(a1, 1.0))),
],
});
}
@@ -270,8 +271,8 @@ pub fn axes_from_bays(radial: bool, xs: &[f64], ys: &[f64]) -> (Vec<GridAxis>, V
}
out
};
let a = cum(xs, true).iter().enumerate().map(|(i, p)| GridAxis { label: (i + 1).to_string(), pos: *p }).collect();
let b = cum(ys, !radial).iter().enumerate().map(|(i, p)| GridAxis { label: letter_label(i), pos: *p }).collect();
let a = cum(xs, true).iter().enumerate().map(|(i, p)| GridAxis { label: (i + 1).to_string(), pos: *p, ..Default::default() }).collect();
let b = cum(ys, !radial).iter().enumerate().map(|(i, p)| GridAxis { label: letter_label(i), pos: *p, ..Default::default() }).collect();
(a, b)
}
@@ -330,13 +331,27 @@ pub fn section_axes(spec: &Spec, origin: P, dir: P, projected: bool) -> Vec<(Str
out
}
/// Verlauf einer Achse als Linienzug (Bögen in Schritten von höchstens 5°), z. B. für den IFC-Export.
pub fn polyline(ax: &Axis) -> Vec<P> {
match ax.shape {
Shape::Line { a, b } => vec![a, b],
Shape::Arc { c, r, a0, a1 } => {
let n = (((a1 - a0).abs() / 5f64.to_radians()).ceil() as usize).max(2);
(0..=n).map(|i| {
let t = a0 + (a1 - a0) * i as f64 / n as f64;
(c.0 + r * t.cos(), c.1 + r * t.sin())
}).collect()
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::model::Vec2;
fn ax(l: &str, p: f64) -> GridAxis {
GridAxis { label: l.into(), pos: p }
GridAxis { label: l.into(), pos: p, ..Default::default() }
}
fn ortho() -> Drawing2DGeom {
@@ -386,6 +401,20 @@ mod tests {
assert!(a.bubbles[0].is_none() && a.bubbles[1].is_some());
}
#[test]
fn blasenseite_je_achse() {
let mut g = ortho();
if let Drawing2DGeom::Grid { a, .. } = &mut g {
a[0].bubble = Some(GridBubbles::Start);
a[1].bubble = Some(GridBubbles::End);
}
let axes = Spec::of(&g).unwrap().axes();
assert!(axes[0].bubbles[0].is_some() && axes[0].bubbles[1].is_none());
assert!(axes[1].bubbles[0].is_none() && axes[1].bubbles[1].is_some());
// Achsen ohne eigene Seite folgen dem Raster (beide Enden).
assert!(axes[2].bubbles[0].is_some() && axes[2].bubbles[1].is_some());
}
#[test]
fn radial_strahlen_ringe() {
let g = Drawing2DGeom::Grid {
+44
View File
@@ -192,6 +192,13 @@ fn find<'a>(root: &'a Map<String, Value>, collection: &str, id: &str) -> Option<
arr(root.get(collection)).iter().find(|e| id_of(e) == Some(id))
}
/// Mittelwert der Ecken eines Umrisses (Griff-Lage der Sohlenhöhe einer Baugruben).
pub fn ring_centroid(ring: &[Value]) -> (f64, f64) {
let n = ring.len().max(1) as f64;
let (sx, sy) = ring.iter().map(xy).fold((0.0, 0.0), |a, p| (a.0 + p.0, a.1 + p.1));
(sx / n, sy / n)
}
fn replace(collection: &str, entity: Value) -> Op {
Op::Replace { collection: collection.into(), entity }
}
@@ -407,6 +414,27 @@ pub fn run(lk: &Lookup, req: &Request) -> Result<GripResult, String> {
let (index, (x, y)) = (r.n("index"), r.p("pt"));
patch(coll, r.s("id"), &|e| Some(with(e, field, replace_at(e.get(field)?.as_array()?, index, &pt(x, y))))).into()
}
// [68] Baugrube: Umriss-Ecke ziehen; der Index hinter der letzten Ecke ist der Sohlen-Griff
// (Lage = Schwerpunkt, y um die Sohlenhöhe versetzt: Ziehen setzt `bottom` = y − Schwerpunkt-y).
"excavationGrip" => {
let (index, (x, y)) = (r.n("index"), r.p("pt"));
patch("context", r.s("id"), &|e| {
let ring = field(e, "outline")?.as_array()?;
if index_in(index, ring.len()).is_some() {
return Some(with(e, "outline", replace_at(ring, index, &pt(x, y))));
}
if index == ring.len() as f64 && y.is_finite() {
let c = ring_centroid(ring);
return Some(with(e, "bottom", js_num(((y - c.1) * 100.0).round() / 100.0)));
}
None
})
.into()
}
"excavationEdge" => {
let (a, b, (dx, dy)) = (r.n("a"), r.n("b"), r.p("delta"));
patch("context", r.s("id"), &|e| Some(with(e, "outline", move_polygon_edge(field(e, "outline")?.as_array()?, a, b, dx, dy, true)?))).into()
}
"ceilingBy" | "roofBy" => {
let coll = if op == "ceilingBy" { "ceilings" } else { "roofs" };
let (dx, dy) = r.p("delta");
@@ -1391,6 +1419,22 @@ mod tests {
assert!(res.ops[0].to_json()["entity"].get("bulge").is_none());
}
/// [68] Baugrube: Ecke, Kante und Sohlen-Griff (Index hinter der letzten Ecke).
#[test]
fn baugrube_griffe() {
let r = root(json!({"context": [{"id": "bg", "type": "excavation", "bottom": -2, "outline": [{"x": 0, "y": 0}, {"x": 4, "y": 0}, {"x": 4, "y": 4}, {"x": 0, "y": 4}]}]}));
let ent = |v: Value| run(&Lookup::plain(&r), &rq(v)).unwrap().ops[0].to_json()["entity"].clone();
let e = ent(json!({"op": "excavationGrip", "id": "bg", "index": 2, "pt": [5, 6]}));
assert_eq!(e["outline"][2], json!({"x": 5, "y": 6}));
// Kante 0–1 um 1 nach unten: beide Ecken wandern.
let e = ent(json!({"op": "excavationEdge", "id": "bg", "a": 0, "b": 1, "delta": [0, -1]}));
assert_eq!((e["outline"][0]["y"].as_f64(), e["outline"][1]["y"].as_f64()), (Some(-1.0), Some(-1.0)));
// Sohlen-Griff: Schwerpunkt-y = 2, Ziel-y = −1 → Sohle −3.
let e = ent(json!({"op": "excavationGrip", "id": "bg", "index": 4, "pt": [2, -1]}));
assert_eq!(e["bottom"], json!(-3));
assert_eq!(e["outline"][2], json!({"x": 4, "y": 4}));
}
#[test]
fn wand_griff_und_sperre() {
let r = root(json!({"walls": [{"id": "w", "start": {"x": 0, "y": 0}, "end": {"x": 1, "y": 0}, "extra": 1}]}));
+52
View File
@@ -49,6 +49,7 @@ const REC_ATTACH: f64 = 14.0;
const REC_OPENING_SOLID: f64 = 15.0;
const REC_WALL_ARC: f64 = 16.0;
const REC_WALL_ARC_SOLID: f64 = 17.0;
const REC_GRID: f64 = 18.0;
/// Toleranz des Kerns (`wall_bands.rs::EPS`) für „Öffnung trifft Band".
const BAND_EPS: f64 = 1e-4;
@@ -1329,6 +1330,30 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
}
f.num(REC_END_COLUMNS);
// ── Achsraster ([112]) → IfcGrid (U-/V-Achsen als Linienzüge in Welt-XY) ──
for d in &p.drawings2d {
let Some(spec) = crate::grid::Spec::of(&d.geom) else { continue };
let Drawing2DGeom::Grid { levels, .. } = &d.geom else { continue };
// Ein Geschoss: dort enthalten; mehrere oder alle: am Gebäude.
let only = match levels.as_deref() {
Some([one]) => Some(one.as_str()),
_ => None,
};
let structure = only.map_or(-1.0, structure_of);
let axes = spec.axes();
if axes.is_empty() {
continue;
}
let (id, name) = (f.str(&d.id), f.str(&format!("Achsraster {}", d.id)));
f.nums(&[REC_GRID, structure, id, name, spec.a.len() as f64, (axes.len() - spec.a.len()) as f64]);
for ax in &axes {
let pts: Vec<Vec2> = crate::grid::polyline(ax).into_iter().map(|(x, y)| Vec2 { x, y }).collect();
let lab = f.str(&ax.label);
f.nums(&[lab]);
w_pts(&mut f, &pts);
}
}
// ── Klassifikation (Optionen), am Ende: alle Bauteile sind geschrieben ──
if opt.ebkph {
let refs: Vec<(String, String, String)> =
@@ -1510,6 +1535,33 @@ mod tests {
assert!(f.nums.iter().any(|v| *v > 2_683_000.0));
}
#[test]
fn achsraster_als_datensatz() {
let mut p = sample();
let a = |l: &str, pos: f64| GridAxis { label: l.into(), pos, ..Default::default() };
let geom = Drawing2DGeom::Grid {
origin: Vec2 { x: 0.0, y: 0.0 },
angle: 0.0,
radial: None,
a: vec![a("1", 0.0), a("2", 5.0)],
b: vec![a("A", 0.0)],
extend: None,
bubbles: None,
bubble_mm: None,
levels: None,
show_3d: None,
};
p.drawings2d.push(Drawing2D { id: "g".into(), r#type: "drawing2d".into(), level_id: p.drawing_levels[0].id.clone(), category_code: "00".into(), geom, ..Default::default() });
let f = ifc_export_data(&p, &IfcOptions::default()).unwrap();
let at = f.nums.windows(2).position(|w| w == [REC_END_COLUMNS, REC_GRID]).map(|i| i + 1);
assert!(at.is_some(), "kein Rasterdatensatz");
// structure, id, name, n_u = 2, n_v = 1
let i = at.unwrap();
assert_eq!((f.nums[i + 4], f.nums[i + 5]), (2.0, 1.0));
// Ohne Raster kein Datensatz.
assert!(!ifc_export_data(&sample(), &IfcOptions::default()).unwrap().nums.windows(2).any(|w| w == [REC_END_COLUMNS, REC_GRID]));
}
#[test]
fn leeres_projekt_und_unbekannter_wandtyp() {
let mut p = Project { id: "leer".into(), ..Default::default() };
+13
View File
@@ -5117,6 +5117,10 @@ pub struct TerrainMesh {
#[serde(rename = "contourIndexEvery", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub contour_index_every: Option<f64>,
/// [T6] Tiefe des Erdreich-Bands im Schnitt unter dem Gelände in m (Default 1.5).
#[serde(rename = "earthDepth", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub earth_depth: Option<f64>,
#[serde(flatten)]
#[ts(skip)]
pub extra: Extra,
@@ -5155,6 +5159,15 @@ pub struct Excavation {
#[serde(rename = "bermHeight", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub berm_height: Option<f64>,
/// [68] Arbeitsraum in m: der Umriss gilt als Gebäude-Grundfläche, die Sohle liegt um dieses Mass
/// weiter aussen (Gehrung an den Ecken). Fehlt = 0 (Umriss = Sohle).
#[serde(rename = "workingSpace", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub working_space: Option<f64>,
/// [68] Senkrechter Verbau (Spundwand) je Kante (wie `edgeSlopes`): keine Böschung, Wand steht senkrecht.
#[serde(rename = "edgeShoring", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub edge_shoring: Option<Vec<bool>>,
#[serde(flatten)]
#[ts(skip)]
pub extra: Extra,
+4
View File
@@ -206,6 +206,10 @@ pub enum SplineMode {
pub struct GridAxis {
pub label: String,
pub pos: f64,
/// Blasenseite nur dieser Achse (überschreibt `Grid.bubbles`); fehlt = wie das Raster.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub bubble: Option<GridBubbles>,
}
/// Welche Achsenden eine Blase tragen.
+3 -3
View File
@@ -1823,15 +1823,15 @@ pub fn emit_context_meshes(p: &Project) -> Vec<RMesh> {
for obj in p.context.as_deref().unwrap_or(&[]) {
match obj {
ContextObject::TerrainMesh(m) if m.positions.len() >= 9 && m.indices.len() >= 3 => {
// [T6] Baugruben schneiden das Gelände; Höhen im Modellbezug (Luftbild-Farben nur ungeändert).
let (pos, idx, changed) = crate::excavation::terrain_model_mesh(p, m);
// [T6] Baugruben schneiden das Gelände; Höhen im Modellbezug (Luftbild-Farben auf das geänderte Netz übertragen).
let (pos, idx, _) = crate::excavation::terrain_model_mesh(p, m);
out.push(RMesh {
crease_angle: None,
positions: pos.into_owned(),
indices: indices_u32(&idx),
kind: "terrain",
color: TERRAIN_RGB,
vertex_colors: if changed { None } else { m.vertex_colors.clone().filter(|v| !v.is_empty()) },
vertex_colors: crate::excavation::terrain_vertex_colors(p, m),
material_index: None,
})
}
+29 -15
View File
@@ -128,22 +128,33 @@ fn terrain_contours(c: &Ctx, t: &TerrainMesh, out: &mut Vec<Primitive>) {
let w = if index { 0.25 } else { 0.1 };
let n = l.pts.len();
let segs = if l.closed { n } else { n - 1 };
for i in 0..segs {
let (a, b) = (l.pts[i], l.pts[(i + 1) % n]);
out.push(ink_line(v2(a[0], a[1]), v2(b[0], b[1]), w, TERRAIN_INK, None));
}
if !index {
continue;
}
// Beschriftung in der Mitte der Linie (nur, wenn sie lang genug ist).
let len: f64 = (0..segs).map(|i| (l.pts[(i + 1) % n][0] - l.pts[i][0]).hypot(l.pts[(i + 1) % n][1] - l.pts[i][1])).sum();
if len < 12.0 * text_h {
continue;
}
let seg_len = |i: usize| (l.pts[(i + 1) % n][0] - l.pts[i][0]).hypot(l.pts[(i + 1) % n][1] - l.pts[i][1]);
let len: f64 = (0..segs).map(seg_len).sum();
// Beschriftung in der Mitte der Zähllinie (nur, wenn sie lang genug ist); die Linie wird dort unterbrochen.
let text = crate::js_fmt::to_fixed(l.level, if iv.fract() == 0.0 { 0 } else { 1 });
let half = 0.3 * text_h * text.chars().count() as f64;
let gap = (index && len >= 12.0 * text_h).then(|| (len / 2.0 - half - 0.4 * text_h, len / 2.0 + half + 0.4 * text_h));
let mut acc = 0.0;
for i in 0..segs {
let (a, b) = (l.pts[i], l.pts[(i + 1) % n]);
let d = (b[0] - a[0]).hypot(b[1] - a[1]);
let d = seg_len(i);
// Anteile (Bruchteile 0..1) des Segments ausserhalb der Lücke.
let mut spans = vec![(0.0, 1.0)];
if let (Some((g0, g1)), true) = (gap, d > 0.0) {
let (f0, f1) = (((g0 - acc) / d).clamp(0.0, 1.0), ((g1 - acc) / d).clamp(0.0, 1.0));
spans = [(0.0, f0), (f1, 1.0)].into_iter().filter(|(x, y)| y - x > 1e-9).collect();
}
for (f0, f1) in spans {
let pt = |f: f64| v2(a[0] + (b[0] - a[0]) * f, a[1] + (b[1] - a[1]) * f);
out.push(ink_line(pt(f0), pt(f1), w, TERRAIN_INK, None));
}
acc += d;
}
let Some(_) = gap else { continue };
let mut acc = 0.0;
for i in 0..segs {
let (a, b) = (l.pts[i], l.pts[(i + 1) % n]);
let d = seg_len(i);
if acc + d >= len / 2.0 && d > 0.0 {
let f = (len / 2.0 - acc) / d;
let mut ang = (b[1] - a[1]).atan2(b[0] - a[0]);
@@ -151,8 +162,6 @@ fn terrain_contours(c: &Ctx, t: &TerrainMesh, out: &mut Vec<Primitive>) {
ang += std::f64::consts::PI;
}
// Text mittig auf die Linie (Breite ≈ 0.6 · Höhe je Zeichen, Grundlinie ≈ −0.35 · Höhe).
let text = crate::js_fmt::to_fixed(l.level, if iv.fract() == 0.0 { 0 } else { 1 });
let half = 0.3 * text_h * text.chars().count() as f64;
let (c, s) = (ang.cos(), ang.sin());
let m = (a[0] + (b[0] - a[0]) * f, a[1] + (b[1] - a[1]) * f);
out.push(Primitive::DrawingText {
@@ -311,6 +320,11 @@ mod tests {
assert!(labels.contains(&"5"), "{labels:?}");
let ex = out.iter().filter(|q| matches!(q, Primitive::Line { color: Some(c), .. } if c == EXCAVATION_INK)).count();
assert!(ex > 20, "{ex}");
// Die Zähllinie ist unter ihrer Beschriftung unterbrochen: keine Linie läuft durch den Textmittelpunkt.
let at = out.iter().find_map(|q| if let Primitive::DrawingText { text, at, .. } = q { (text == "5").then_some(*at) } else { None }).unwrap();
let near = out.iter().filter(|q| matches!(q, Primitive::Line { a, b, weight_mm, color: Some(c), .. }
if *weight_mm == 0.25 && c == TERRAIN_INK && (a.x.min(b.x) - 0.01..=a.x.max(b.x) + 0.01).contains(&at.x) && (a.y.min(b.y) - 0.01..=a.y.max(b.y) + 0.01).contains(&at.y))).count();
assert_eq!(near, 0, "Linie läuft durch das Etikett bei {at:?}");
}
#[test]
+1 -1
View File
@@ -1178,7 +1178,7 @@ pub fn mv_geom(g: &Drawing2DGeom, f: &dyn Fn(Vec2) -> Vec2) -> Drawing2DGeom {
let o = f(*origin);
let ex = f(v(origin.x + angle.cos(), origin.y + angle.sin()));
let flip = reverses_orientation(f);
let neg = |l: &Vec<GridAxis>| l.iter().map(|x| GridAxis { label: x.label.clone(), pos: -x.pos }).collect::<Vec<_>>();
let neg = |l: &Vec<GridAxis>| l.iter().map(|x| GridAxis { label: x.label.clone(), pos: -x.pos, bubble: x.bubble }).collect::<Vec<_>>();
let ang = (ex.y - o.y).atan2(ex.x - o.x);
let (a2, b2) = match (flip, radial == &Some(true)) {
(false, _) => (a.clone(), b.clone()),
+8 -2
View File
@@ -1554,17 +1554,23 @@ fn append_terrain_profiles(out: &mut Output, p: &Project, base: (f64, f64), u: (
append_earth(out, p, base, u);
}
/// Tiefe des Erdreich-Bands unter der Geländelinie (m).
/// Tiefe des Erdreich-Bands unter der Geländelinie (m), wenn das Gelände keine `earthDepth` trägt.
const EARTH_BAND: f64 = 1.5;
/// Tiefe des Erdreich-Bands: `earthDepth` des ersten Geländes, das eine positive Tiefe setzt.
fn earth_band(p: &Project) -> f64 {
crate::excavation::terrains(p).iter().find_map(|t| t.earth_depth.filter(|d| d.is_finite() && *d > 0.0)).unwrap_or(EARTH_BAND)
}
/// [T6]/[109] Erdreich: Band unter dem gestalteten Terrain mit SIA-Erdreich-Schraffur, ohne das
/// Gebäude-Innere (Grundfläche im Schnitt, von der tiefsten Schnittfläche aufwärts); die geschnittenen
/// Bauteile selbst liegen ohnehin darüber.
fn append_earth(out: &mut Output, p: &Project, base: (f64, f64), u: (f64, f64)) {
let depth = earth_band(p);
let mut band: Vec<crate::flat::Polygon> = Vec::new();
for pr in out.profiles.iter().filter(|pr| !pr.natural && pr.pts.len() >= 2) {
let mut ring = pr.pts.clone();
ring.extend(pr.pts.iter().rev().map(|q| [q[0], q[1] - EARTH_BAND]));
ring.extend(pr.pts.iter().rev().map(|q| [q[0], q[1] - depth]));
band.push(vec![ring]);
}
if band.is_empty() {
+1
View File
@@ -23,6 +23,7 @@ pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String,
json(&room_program::layout(p, &opt))
}
("siteCheck", _) => json(&site_rules::check_project(p)),
("dormerStatus", _) => json(&crate::dormer::status(p)),
("excavationQuantities", _) => json(&crate::excavation::quantities(p)),
("buildingFootprint", _) => json(&site_rules::building_footprint(p)),
("modelTop", _) => json(&site_rules::model_top(p)),
+56 -1
View File
@@ -142,6 +142,11 @@ impl<'a> TinIndex<'a> {
/// Höhe am Punkt (x, y); `None` ausserhalb des Netzes.
pub fn z_at(&self, x: f64, y: f64) -> Option<f64> {
self.bary_at(x, y).map(|(t, l)| l[0] * self.tin.z[t[0]] + l[1] * self.tin.z[t[1]] + l[2] * self.tin.z[t[2]])
}
/// Dreieck (Eckindizes) und Schwerpunktkoordinaten am Punkt (x, y); `None` ausserhalb des Netzes.
pub fn bary_at(&self, x: f64, y: f64) -> Option<([usize; 3], [f64; 3])> {
if !(x >= self.b[0] - 1e-9 && x <= self.b[2] + 1e-9 && y >= self.b[1] - 1e-9 && y <= self.b[3] + 1e-9) {
return None;
}
@@ -159,7 +164,7 @@ impl<'a> TinIndex<'a> {
let l0 = 1.0 - l1 - l2;
const E: f64 = -1e-9;
if l0 >= E && l1 >= E && l2 >= E {
return Some(l0 * t.z[a] + l1 * t.z[b] + l2 * t.z[c]);
return Some(([a, b, c], [l0, l1, l2]));
}
}
None
@@ -961,6 +966,43 @@ pub fn datum(reference_masl: Option<f64>, z: &[f64]) -> f64 {
}
}
/// [T6] Glättet ein Höhenraster (`z[j * nx + i]`, NaN = kein Messwert) mit `passes` Durchgängen eines
/// Binomialfilters [1 2 1]/4 je Achse. Fehlende Nachbarn zählen nicht (Gewichte werden renormiert), fehlende
/// Zellen bleiben fehlend. Falsche Grösse → Eingabe unverändert.
pub fn smooth_grid(z: &[f64], nx: usize, ny: usize, passes: u32) -> Vec<f64> {
if nx == 0 || ny == 0 || z.len() != nx * ny {
return z.to_vec();
}
let mut cur = z.to_vec();
for _ in 0..passes.min(20) {
for horizontal in [true, false] {
let src = cur.clone();
for j in 0..ny {
for i in 0..nx {
let c = src[j * nx + i];
if c.is_nan() {
continue;
}
let (a, b) = if horizontal {
(if i > 0 { src[j * nx + i - 1] } else { f64::NAN }, if i + 1 < nx { src[j * nx + i + 1] } else { f64::NAN })
} else {
(if j > 0 { src[(j - 1) * nx + i] } else { f64::NAN }, if j + 1 < ny { src[(j + 1) * nx + i] } else { f64::NAN })
};
let (mut sum, mut w) = (2.0 * c, 2.0);
for v in [a, b] {
if !v.is_nan() {
sum += v;
w += 1.0;
}
}
cur[j * nx + i] = sum / w;
}
}
}
}
cur
}
#[cfg(test)]
mod tests {
use super::*;
@@ -1063,4 +1105,17 @@ mod tests {
assert_eq!(datum(Some(450.0), &[2.0, 5.0]), 0.0);
assert_eq!(datum(None, &[452.0]), 0.0);
}
#[test]
fn raster_glaetten() {
// Spitze in der Mitte wird abgebaut, Summe grob erhalten, NaN bleibt NaN, Ebene bleibt eben.
let mut z = vec![0.0; 25];
z[12] = 8.0;
z[0] = f64::NAN;
let g = smooth_grid(&z, 5, 5, 1);
assert!(g[12] < 8.0 && g[12] > 1.0 && g[11] > 0.0 && g[0].is_nan());
assert!(smooth_grid(&vec![3.0; 25], 5, 5, 3).iter().all(|v| (v - 3.0).abs() < 1e-12));
assert_eq!(smooth_grid(&z[..4], 5, 5, 1).len(), 4);
assert!(smooth_grid(&z, 5, 5, 0)[12] == 8.0);
}
}
+7
View File
@@ -83,3 +83,10 @@ pub fn terrain_from_contours_opts_json(contours_json: &str, id: &str, smooth: f6
};
crate::cmd_solid::terrain_from_contours_with(c.as_array().map(Vec::as_slice).unwrap_or(&[]), id, o).to_string()
}
/// Höhenraster glätten ([T6], `crate::terrain::smooth_grid`): `z` zeilenweise (`nx` Spalten, NaN = kein Wert).
#[wasm_bindgen]
pub fn terrain_smooth_grid(z: &[f64], nx: f64, ny: f64, passes: f64) -> Vec<f64> {
let dim = |v: f64| if v.is_finite() && v >= 0.0 { v as usize } else { 0 };
crate::terrain::smooth_grid(z, dim(nx), dim(ny), if passes.is_finite() && passes > 0.0 { passes as u32 } else { 0 })
}