[137] Kern: Baugrube, Höhenlinien, Schatten und Baurecht anwählbar (Grundriss-Pick, 3D-Pick, sitePick)
This commit is contained in:
9 files changed
+256
-5
No files matched your search
@@ -2561,6 +2561,9 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
|
||||
Abweichungs-Abwahl mehr; Fussbereich/Vorlage-Wahl e2e repariert). Sichtbarkeit/Overrides sind Projektdaten: ein Wechsel
|
||||
setzt sie nur bei Abweichung, als ein Undo-Schritt. Kein Modellwechsel (Reiter waren nie im Modell). Tests
|
||||
`viewTabs.test.ts`, e2e `viewTabs.spec.ts`. Offen: Reiter nicht mit dem Projekt gespeichert; nicht in der Tauri-App geprüft. · S
|
||||
- ◐ **[137] Alles Sichtbare anwählbar.** (5.11., Mac-Befund am Musterhaus komplex: „Schatten und gewachsenes Terrain lassen sich
|
||||
nicht anwählen und bearbeiten") In Arbeit: Kern-Picken für Baugrube (Wirkbereich zuoberst), Höhenlinien-Satz, Schatten/Baurecht
|
||||
(`sitePick`), 3D-Picken der Baugrube; `TerrainMesh.smooth`/`sourceId`. · M
|
||||
|
||||
## Priorität 4 — später
|
||||
|
||||
|
||||
@@ -485,6 +485,7 @@ pub fn terrain_from_contours_with(contours: &[Value], id: &str, o: crate::terrai
|
||||
("positions", Value::Array(pos.into_iter().map(js_num).collect())),
|
||||
("indices", Value::Array(idx.into_iter().map(Value::from).collect())),
|
||||
("contourInterval", js_num(iv)),
|
||||
("smooth", Value::from(o.smooth)),
|
||||
])
|
||||
}
|
||||
|
||||
@@ -520,10 +521,14 @@ fn terrain_ops(root: &Map<String, Value>, ids: &mut IdGen) -> Vec<Op> {
|
||||
let Some(set) = arr(root.get("context")).iter().find(|o| field(o, "type").and_then(Value::as_str) == Some("contourSet")) else {
|
||||
return Vec::new();
|
||||
};
|
||||
let t = terrain_from_contours(arr(field(set, "contours")), &ids.next("terrain"));
|
||||
let mut t = terrain_from_contours(arr(field(set, "contours")), &ids.next("terrain"));
|
||||
if arr(field(&t, "indices")).is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
// [137] Quelle merken: die Objekt-Info glättet das Gelände aus diesen Höhenlinien neu.
|
||||
if let (Some(m), Some(src)) = (t.as_object_mut(), field(set, "id").cloned()) {
|
||||
m.insert("sourceId".into(), src);
|
||||
}
|
||||
add_op("context", vec![t])
|
||||
}
|
||||
|
||||
|
||||
@@ -729,6 +729,54 @@ pub fn terrain_before(st: &SiteTerrain, id: &str) -> Option<Tin> {
|
||||
Some(cur)
|
||||
}
|
||||
|
||||
// ── Auswahl ([137]) ──────────────────────────────────────────────────────────
|
||||
|
||||
/// [137] Baugrube, die das Gelände am Punkt (x, y) ändert (Sohle oder Böschung/Schüttung), sonst `None`.
|
||||
/// `idx` = Index des gewachsenen Netzes (`st.orig`); die Baugruben wirken der Reihe nach wie im Netz.
|
||||
pub fn owner_at<'a>(st: &'a SiteTerrain, idx: &TinIndex, x: f64, y: f64) -> Option<&'a str> {
|
||||
let p = [x, y];
|
||||
let mut z = idx.z_at(x, y);
|
||||
for (id, spec, _) in &st.items {
|
||||
if point_in_ring(p, &spec.ring) {
|
||||
return Some(id);
|
||||
}
|
||||
if let Some(t) = z {
|
||||
let n = spec.apply(t, p);
|
||||
if (n - t).abs() > 0.005 {
|
||||
return Some(id);
|
||||
}
|
||||
z = Some(n);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// [137] Wirkbereich einer Baugrube im Grundriss (Pick-Fläche): konvexe Hülle aus Sohle und
|
||||
/// Böschungsoberkante, gegen den Uhrzeigersinn. Leer, wenn sie kein Gelände trifft.
|
||||
pub fn affected_hull(st: &SiteTerrain, id: &str) -> Vec<P2> {
|
||||
let Some((_, spec, daylight)) = st.items.iter().find(|(i, ..)| i == id) else { return Vec::new() };
|
||||
let mut pts: Vec<P2> = spec.ring.iter().chain(daylight.iter().flatten()).copied().filter(|q| q[0].is_finite() && q[1].is_finite()).collect();
|
||||
pts.sort_by(|a, b| a[0].total_cmp(&b[0]).then(a[1].total_cmp(&b[1])));
|
||||
pts.dedup();
|
||||
if pts.len() < 3 {
|
||||
return pts;
|
||||
}
|
||||
let cross = |o: P2, a: P2, b: P2| (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
|
||||
let mut hull: Vec<P2> = Vec::with_capacity(pts.len() + 1);
|
||||
for pass in 0..2 {
|
||||
let start = hull.len();
|
||||
let it: Box<dyn Iterator<Item = &P2>> = if pass == 0 { Box::new(pts.iter()) } else { Box::new(pts.iter().rev()) };
|
||||
for &q in it {
|
||||
while hull.len() >= start + 2 && cross(hull[hull.len() - 2], hull[hull.len() - 1], q) <= 0.0 {
|
||||
hull.pop();
|
||||
}
|
||||
hull.push(q);
|
||||
}
|
||||
hull.pop();
|
||||
}
|
||||
hull
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -5197,6 +5197,15 @@ pub struct TerrainMesh {
|
||||
#[serde(rename = "earthDepth", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub earth_depth: Option<f64>,
|
||||
/// [137] Glättungsstufe, mit der das Netz aus Höhenlinien erzeugt wurde (0 = roh, 1–4 Kantenteilungen).
|
||||
/// Fehlt bei importierten Netzen (swissALTI3D) — dann gibt es nichts neu zu glätten.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub smooth: Option<f64>,
|
||||
/// [137] Quelle: Id des Höhenlinien-Satzes (`contourSet`), aus dem das Netz erzeugt wurde.
|
||||
#[serde(rename = "sourceId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub source_id: Option<String>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
|
||||
@@ -2425,17 +2425,49 @@ pub fn pick_geometry(p: &Project) -> Result<PickGeometry, String> {
|
||||
let (pos, idx) = (&*pos, &*idx);
|
||||
let vcount = pos.len() / 3;
|
||||
let at = |i: usize| -> V3 { [pos[i * 3], pos[i * 3 + 2], -pos[i * 3 + 1]] };
|
||||
// [137] Dreiecke im Wirkbereich einer Baugrube (Sohle, Böschungen) wählen die Baugrube.
|
||||
let site = match obj {
|
||||
ContextObject::TerrainMesh(m) => Some(crate::excavation::site_terrain(p, m)),
|
||||
_ => None,
|
||||
};
|
||||
let site = site.filter(|st| !st.items.is_empty());
|
||||
let orig_idx = site.as_ref().map(|st| crate::terrain::TinIndex::new(&st.orig));
|
||||
let boxes: Vec<[f64; 4]> = site.as_ref().map_or_else(Vec::new, |st| {
|
||||
st.items
|
||||
.iter()
|
||||
.map(|(eid, ..)| crate::excavation::affected_hull(st, eid).iter().fold([f64::INFINITY, f64::INFINITY, f64::NEG_INFINITY, f64::NEG_INFINITY], |b, q| [b[0].min(q[0]), b[1].min(q[1]), b[2].max(q[0]), b[3].max(q[1])]))
|
||||
.collect()
|
||||
});
|
||||
let mut tris: Vec<Tri> = Vec::new();
|
||||
let mut owned: Vec<(String, Vec<Tri>)> = Vec::new();
|
||||
for t in idx.chunks_exact(3) {
|
||||
let ok = |v: f64| v >= 0.0 && v.fract() == 0.0 && (v as usize) < vcount;
|
||||
if !(ok(t[0]) && ok(t[1]) && ok(t[2])) {
|
||||
continue;
|
||||
}
|
||||
tris.push([at(t[0] as usize), at(t[1] as usize), at(t[2] as usize)]);
|
||||
let tri = [at(t[0] as usize), at(t[1] as usize), at(t[2] as usize)];
|
||||
let owner = match (&site, &orig_idx) {
|
||||
(Some(st), Some(oi)) => {
|
||||
let (cx, cy) = ((tri[0][0] + tri[1][0] + tri[2][0]) / 3.0, -(tri[0][2] + tri[1][2] + tri[2][2]) / 3.0);
|
||||
let near = boxes.iter().any(|b| cx >= b[0] - 0.01 && cx <= b[2] + 0.01 && cy >= b[1] - 0.01 && cy <= b[3] + 0.01);
|
||||
if near { crate::excavation::owner_at(st, oi, cx, cy) } else { None }
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
match owner {
|
||||
Some(eid) => match owned.iter_mut().find(|(i, _)| i == eid) {
|
||||
Some((_, l)) => l.push(tri),
|
||||
None => owned.push((eid.to_string(), vec![tri])),
|
||||
},
|
||||
None => tris.push(tri),
|
||||
}
|
||||
}
|
||||
if !tris.is_empty() {
|
||||
context_meshes.push(PickContextMesh { tris, context_object_id: id.clone() });
|
||||
}
|
||||
for (eid, tris) in owned {
|
||||
context_meshes.push(PickContextMesh { tris, context_object_id: eid });
|
||||
}
|
||||
}
|
||||
Ok(PickGeometry {
|
||||
walls: emit_walls(p, true)?,
|
||||
@@ -2500,6 +2532,31 @@ mod tests {
|
||||
assert!(emit_context_meshes(&pp(false)).is_empty());
|
||||
}
|
||||
|
||||
/// [137] 3D-Picken: Dreiecke der Baugrube (Sohle, Böschung) tragen die Id der Baugrube, das übrige
|
||||
/// Gelände die des Netzes.
|
||||
#[test]
|
||||
fn pick_gelaende_und_baugrube_im_3d() {
|
||||
let t = crate::model::TerrainMesh {
|
||||
id: "t".into(),
|
||||
positions: vec![0.0, 0.0, 0.0, 60.0, 0.0, 6.0, 60.0, 40.0, 6.0, 0.0, 40.0, 0.0],
|
||||
indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0],
|
||||
..Default::default()
|
||||
};
|
||||
let v = |x: f64, y: f64| crate::model::Vec2 { x, y };
|
||||
let pit = crate::model::Excavation { id: "bg".into(), outline: vec![v(20.0, 15.0), v(30.0, 15.0), v(30.0, 25.0), v(20.0, 25.0)], bottom: 1.0, ..Default::default() };
|
||||
let p = Project { context: Some(vec![ContextObject::Excavation(pit), ContextObject::TerrainMesh(t)]), ..Default::default() };
|
||||
let g = pick_geometry(&p).unwrap();
|
||||
let of = |id: &str| g.context_meshes.iter().find(|m| m.context_object_id == id).map(|m| m.tris.clone()).unwrap_or_default();
|
||||
let (bg, terr) = (of("bg"), of("t"));
|
||||
assert!(!bg.is_empty() && !terr.is_empty(), "{} {}", bg.len(), terr.len());
|
||||
// Welt (x, z, −y): alle Baugruben-Dreiecke liegen im Wirkbereich (x 18…32, y 13…27), Sohle auf 1 m dabei.
|
||||
for tri in &bg {
|
||||
let (cx, cy) = ((tri[0][0] + tri[1][0] + tri[2][0]) / 3.0, -(tri[0][2] + tri[1][2] + tri[2][2]) / 3.0);
|
||||
assert!((17.0..=33.0).contains(&cx) && (12.0..=28.0).contains(&cy), "{cx} {cy}");
|
||||
}
|
||||
assert!(bg.iter().any(|tri| tri.iter().all(|q| (q[1] - 1.0).abs() < 1e-6)));
|
||||
}
|
||||
|
||||
/// [T4] Import-Mesh glatt: Knickwinkel geht ans 3D (Vorgabe 30°), kantig ohne; JSON `creaseAngle`.
|
||||
#[test]
|
||||
fn import_mesh_glatt_mit_knickwinkel() {
|
||||
|
||||
@@ -59,6 +59,9 @@ fn bbox_corners(positions: &[f64]) -> Option<Vec<Vec2>> {
|
||||
|
||||
/// Kontext-Schicht (`addContextContours`). Objekte ohne Kategorie bleiben immer sichtbar.
|
||||
pub fn plan_context(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
// [137] Pick-Flächen der Baugruben zuletzt (zuoberst): sie liegen im Rahmen des Geländes, das sonst
|
||||
// jeden Klick in der Grube fängt.
|
||||
let mut late: Vec<Primitive> = Vec::new();
|
||||
for obj in c.p.context.as_deref().unwrap_or(&[]) {
|
||||
let code = match obj {
|
||||
ContextObject::ImportedMesh(m) => m.category_code.as_deref(),
|
||||
@@ -72,6 +75,11 @@ pub fn plan_context(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
}
|
||||
match obj {
|
||||
ContextObject::ContourSet(s) => {
|
||||
// [137] Rahmen als Pick-Fläche (unter dem daraus erzeugten Gelände; Cmd+Klick schaltet durch).
|
||||
let all: Vec<f64> = s.contours.iter().flat_map(|k| k.pts.iter().flat_map(|q| [q.x, q.y, 0.0])).collect();
|
||||
if let Some(pts) = bbox_corners(&all) {
|
||||
out.push(pick_band(pts, Some(&s.id), None));
|
||||
}
|
||||
for k in &s.contours {
|
||||
let pts = &k.pts;
|
||||
if pts.len() < 2 {
|
||||
@@ -102,10 +110,11 @@ pub fn plan_context(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
}
|
||||
terrain_contours(c, t, out);
|
||||
}
|
||||
ContextObject::Excavation(e) => excavation_lines(c, e, out),
|
||||
ContextObject::Excavation(e) => excavation_lines(c, e, out, &mut late),
|
||||
ContextObject::Image(_) => {}
|
||||
}
|
||||
}
|
||||
out.append(&mut late);
|
||||
}
|
||||
|
||||
const TERRAIN_INK: &str = "#7a5b3a";
|
||||
@@ -185,7 +194,7 @@ fn terrain_contours(c: &Ctx, t: &TerrainMesh, out: &mut Vec<Primitive>) {
|
||||
}
|
||||
|
||||
/// [68] Baugrube im Grundriss: Sohle (Böschungsfuss) und Böschungsoberkante, Böschungsschraffur.
|
||||
fn excavation_lines(c: &Ctx, e: &Excavation, out: &mut Vec<Primitive>) {
|
||||
fn excavation_lines(c: &Ctx, e: &Excavation, out: &mut Vec<Primitive>, bands: &mut Vec<Primitive>) {
|
||||
let ring: Vec<Vec2> = e.outline.iter().copied().filter(|q| q.x.is_finite() && q.y.is_finite()).collect();
|
||||
if ring.len() < 3 {
|
||||
return;
|
||||
@@ -193,7 +202,10 @@ fn excavation_lines(c: &Ctx, e: &Excavation, out: &mut Vec<Primitive>) {
|
||||
for i in 0..ring.len() {
|
||||
out.push(ink_line(ring[i], ring[(i + 1) % ring.len()], 0.25, EXCAVATION_INK, None));
|
||||
}
|
||||
out.push(pick_band(ring.clone(), Some(&e.id), None));
|
||||
// [137] Pick-Fläche = Wirkbereich (Sohle + Böschungen), ohne Gelände nur die Sohle.
|
||||
let hull = crate::excavation::terrains(c.p).into_iter().map(|t| crate::excavation::affected_hull(&crate::excavation::site_terrain(c.p, t), &e.id)).find(|h| h.len() >= 3);
|
||||
let band = hull.map_or_else(|| ring.clone(), |h| h.iter().map(|q| v2(q[0], q[1])).collect());
|
||||
bands.push(pick_band(band, Some(&e.id), None));
|
||||
let spacing = (0.004 * c.a.scale.max(1.0)).max(0.2);
|
||||
for t in crate::excavation::terrains(c.p) {
|
||||
let st = crate::excavation::site_terrain(c.p, t);
|
||||
@@ -292,6 +304,52 @@ pub fn plan_section_lines(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Oberstes Kontext-Pick-Band unter dem Punkt (wie `PickIndex::polygons_at` mit Maske „Kontext").
|
||||
fn top_context(out: &[Primitive], x: f64, y: f64) -> Option<String> {
|
||||
out.iter().rev().find_map(|q| match q {
|
||||
Primitive::Polygon { pts, context_object_id: Some(id), .. } => {
|
||||
let flat: Vec<f64> = pts.iter().flat_map(|v| [v.x, v.y]).collect();
|
||||
crate::plan::pick::point_in_polygon(x, y, &flat).then(|| id.clone())
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
/// [137] Auswahl im Grundriss: Klick in die Baugrube (Sohle und Böschung) wählt die Baugrube, auch wenn
|
||||
/// das Gelände in der Liste später kommt; daneben das Gelände; ausserhalb des Geländes die Höhenlinien.
|
||||
#[test]
|
||||
fn auswahl_gelaende_baugrube_hoehenlinien() {
|
||||
let t = TerrainMesh {
|
||||
id: "t".into(),
|
||||
positions: vec![0.0, 0.0, 0.0, 60.0, 0.0, 6.0, 60.0, 40.0, 6.0, 0.0, 40.0, 0.0],
|
||||
indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0],
|
||||
category_code: Some("02".into()),
|
||||
..Default::default()
|
||||
};
|
||||
let pit = Excavation {
|
||||
id: "bg".into(),
|
||||
outline: vec![v2(20.0, 15.0), v2(30.0, 15.0), v2(30.0, 25.0), v2(20.0, 25.0)],
|
||||
bottom: 1.0,
|
||||
..Default::default()
|
||||
};
|
||||
let cs = ContourSet {
|
||||
id: "hl".into(),
|
||||
contours: vec![Contour { z: 0.0, pts: vec![v2(-20.0, -5.0), v2(80.0, 50.0)], ..Default::default() }],
|
||||
..Default::default()
|
||||
};
|
||||
// Reihenfolge wie im Musterhaus komplex: Höhenlinien, Baugrube, dann das daraus erzeugte Gelände.
|
||||
let p = Project { context: Some(vec![ContextObject::ContourSet(cs), ContextObject::Excavation(pit), ContextObject::TerrainMesh(t)]), ..Default::default() };
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "scale": 100}"#).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_context(&Ctx::new(&p, &a), &mut out);
|
||||
assert_eq!(top_context(&out, 25.0, 20.0).as_deref(), Some("bg"), "Sohle");
|
||||
// Ostseite: Gelände 3 m bei x = 30, Sohle 1 m → 2 m Böschung (45°) bis x ≈ 32.
|
||||
assert_eq!(top_context(&out, 31.0, 20.0).as_deref(), Some("bg"), "Böschung");
|
||||
assert_eq!(top_context(&out, 50.0, 5.0).as_deref(), Some("t"), "Gelände");
|
||||
assert_eq!(top_context(&out, -10.0, 0.0).as_deref(), Some("hl"), "Höhenlinien");
|
||||
assert_eq!(top_context(&out, -30.0, 0.0), None);
|
||||
}
|
||||
|
||||
/// [T6]/[68] Höhenlinien (Zähllinien dicker + beschriftet) und Baugrube (Sohle, Oberkante, Schraffur).
|
||||
#[test]
|
||||
fn hoehenlinien_und_baugrube() {
|
||||
|
||||
@@ -96,6 +96,37 @@ pub fn sun_shadow(p: &Project, floor: &str, when_ms: Option<f64>, out: &mut Vec<
|
||||
}
|
||||
}
|
||||
|
||||
/// [137] Abgeleitete Lage-Darstellung unter dem Punkt (x, y) im Geschoss `floor` (dieselben Bedingungen
|
||||
/// wie die Zeichnung): `"siteRules"` näher als `tol` (m) an Parzellengrenze oder zulässiger Fläche,
|
||||
/// `"sunStudy"` in einer Schattenfläche zum Zeitpunkt `when_ms`, sonst `""`. Die Auswahl öffnet dann die
|
||||
/// Einstellungen der Quelle (Baurecht bzw. Sonnenstand) — Schatten und Baurechtslinien sind keine Elemente.
|
||||
pub fn site_pick(p: &Project, floor: &str, when_ms: Option<f64>, x: f64, y: f64, tol: f64) -> &'static str {
|
||||
if !(x.is_finite() && y.is_finite()) {
|
||||
return "";
|
||||
}
|
||||
let tol = if tol.is_finite() && tol > 0.0 { tol } else { 0.0 };
|
||||
let near_ring = |r: &[Vec2]| (0..r.len()).any(|i| crate::plan::pick::point_seg_dist(x, y, r[i].x, r[i].y, r[(i + 1) % r.len()].x, r[(i + 1) % r.len()].y) <= tol);
|
||||
if let (Some(check), Some(rules)) = (site_check(p, floor), p.site_rules.as_ref()) {
|
||||
if near_ring(&rules.parcel) || check.allowed.iter().flatten().any(|r| near_ring(r)) {
|
||||
return "siteRules";
|
||||
}
|
||||
}
|
||||
let mut shadow = Vec::new();
|
||||
sun_shadow(p, floor, when_ms, &mut shadow);
|
||||
let inside = shadow.iter().any(|q| match q {
|
||||
Primitive::Polygon { pts, .. } => {
|
||||
let flat: Vec<f64> = pts.iter().flat_map(|v| [v.x, v.y]).collect();
|
||||
crate::plan::pick::point_in_polygon(x, y, &flat)
|
||||
}
|
||||
_ => false,
|
||||
});
|
||||
if inside {
|
||||
"sunStudy"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
/// Baurecht im Geschoss nächst ±0.00 (ohne `show: false`): Prüfung des Modells, `None` ohne
|
||||
/// gültiges Baurecht.
|
||||
fn site_check(p: &Project, floor: &str) -> Option<crate::site_rules::SiteCheckOut> {
|
||||
@@ -536,6 +567,37 @@ mod tests {
|
||||
assert!(n1 > n0, "{n0} {n1}");
|
||||
}
|
||||
|
||||
/// [137] Klick in eine Schattenfläche wählt den Sonnenstand, Klick auf eine Baurechtslinie das Baurecht;
|
||||
/// ohne sichtbare Studie bzw. in einem anderen Geschoss nichts.
|
||||
#[test]
|
||||
fn klick_auf_schatten_und_baurecht() {
|
||||
let mut p = sample();
|
||||
let floor = ground_floor_id(&p).unwrap().to_string();
|
||||
p.sun_study = Some(SunStudy { when: "2026-12-21T09:00:00Z".into(), show: true, ..Default::default() });
|
||||
let when = Some(1_797_843_600_000.0); // 2026-12-21T09:00:00Z
|
||||
let mut shadow = Vec::new();
|
||||
sun_shadow(&p, &floor, when, &mut shadow);
|
||||
assert!(!shadow.is_empty());
|
||||
// Ein Punkt in einer Schattenfläche (Raster über die erste Fläche).
|
||||
let Primitive::Polygon { pts, .. } = &shadow[0] else { panic!() };
|
||||
let flat: Vec<f64> = pts.iter().flat_map(|v| [v.x, v.y]).collect();
|
||||
let (x0, x1) = pts.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |a, v| (a.0.min(v.x), a.1.max(v.x)));
|
||||
let (y0, y1) = pts.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |a, v| (a.0.min(v.y), a.1.max(v.y)));
|
||||
let inside = (0..400).map(|k| (x0 + (x1 - x0) * ((k % 20) as f64 + 0.5) / 20.0, y0 + (y1 - y0) * ((k / 20) as f64 + 0.5) / 20.0)).find(|q| crate::plan::pick::point_in_polygon(q.0, q.1, &flat)).unwrap();
|
||||
assert_eq!(site_pick(&p, &floor, when, inside.0, inside.1, 0.1), "sunStudy");
|
||||
assert_eq!(site_pick(&p, &floor, when, 1e4, 1e4, 0.1), "");
|
||||
assert_eq!(site_pick(&p, "anderes-geschoss", when, inside.0, inside.1, 0.1), "");
|
||||
assert_eq!(site_pick(&p, &floor, None, inside.0, inside.1, 0.1), "");
|
||||
assert_eq!(site_pick(&p, &floor, when, f64::NAN, 0.0, 0.1), "");
|
||||
p.sun_study.as_mut().unwrap().show = false;
|
||||
assert_eq!(site_pick(&p, &floor, when, inside.0, inside.1, 0.1), "");
|
||||
// Baurecht: Parzellengrenze bei x = −30 (weit weg vom Gebäude, kein Schatten dort).
|
||||
p.site_rules = Some(serde_json::from_value(serde_json::json!({"parcel": [{"x": -30, "y": -30}, {"x": 40, "y": -30}, {"x": 40, "y": 40}, {"x": -30, "y": 40}], "defaultSetback": 3.0})).unwrap());
|
||||
assert_eq!(site_pick(&p, &floor, when, -30.05, 5.0, 0.1), "siteRules");
|
||||
assert_eq!(site_pick(&p, &floor, when, -27.0, 5.0, 0.1), "siteRules", "zulässige Fläche 3 m innen");
|
||||
assert_eq!(site_pick(&p, &floor, when, -28.5, 5.0, 0.1), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn strichstaerken_faktor() {
|
||||
let mut on = sample();
|
||||
|
||||
@@ -57,6 +57,8 @@ pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String,
|
||||
("siteCheck", _) => json(&site_rules::check_project(p)),
|
||||
("dormerStatus", _) => json(&crate::dormer::status(p)),
|
||||
("excavationQuantities", _) => json(&crate::excavation::quantities(p)),
|
||||
// [137] Klick auf Schatten/Baurechtslinien: args = [x, y, Toleranz m, Zeitpunkt ms (NaN = keiner)], text = Geschoss.
|
||||
("sitePick", 4) => json(&crate::plan::extras::site_pick(p, text, Some(args[3]).filter(|t| t.is_finite()), args[0], args[1], args[2])),
|
||||
("buildingFootprint", _) => json(&site_rules::building_footprint(p)),
|
||||
("modelTop", _) => json(&site_rules::model_top(p)),
|
||||
("shadows", 2) => json(&site_rules::area_out(&sun::shadow_polygons_project(p, sun::SunPosition { azimuth: args[0], elevation: args[1] }))),
|
||||
|
||||
@@ -3112,6 +3112,13 @@ export type TerrainMesh = {
|
||||
contourIndexEvery?: number;
|
||||
/** [T6] Tiefe des Erdreich-Bands im Schnitt unter dem Gelände in m (Default 1.5). */
|
||||
earthDepth?: number;
|
||||
/**
|
||||
* [137] Glättungsstufe, mit der das Netz aus Höhenlinien erzeugt wurde (0 = roh, 1–4 Kantenteilungen).
|
||||
* Fehlt bei importierten Netzen (swissALTI3D) — dann gibt es nichts neu zu glätten.
|
||||
*/
|
||||
smooth?: number;
|
||||
/** [137] Quelle: Id des Höhenlinien-Satzes (`contourSet`), aus dem das Netz erzeugt wurde. */
|
||||
sourceId?: string;
|
||||
};
|
||||
|
||||
/** Ein zusammenhängender Textabschnitt mit einheitlicher Formatierung. */
|
||||
|
||||
Reference in new issue
Block a user