[G1] Merge: Poché für Körper, Abzugskörper beliebiger Form, exakte Treppenuntersicht

This commit is contained in:
Claude committed 2026-11-05 06:01:26 +00:00
commit f0d9bc7aa3
8 files changed
+259 -13

No files matched your search

+15
View File
@@ -1387,6 +1387,21 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
- ◐ **[G1] Ebenenschnitt beliebiger Körper** — `plan/meshSection.ts` (Ringe, Löcher, offene Linienzüge),
im Schnitt für Geländelinie und freie/B-Rep-Körper. Offen: Grundriss-Poché für Körper,
Treppenuntersicht, Abzugskörper beliebiger Form im Schnitt. · L
- (5.11.) **Grundriss-Poché für Körper** (`plan/domains.rs` `body_cut_ring`): Profil-Extrusionen (auch
verjüngt; Ring auf Schnitthöhe zum Ecken-Schwerpunkt gestaucht wie die truck-Verjüngung), die die Schnitthöhe
durchdringen (Ansichtsbereich [36]: Zone „Cut"), bekommen eine Schnittfläche (Füllung/Schraffur wie geschnittene
Körper im Schnitt, Schnitt-Strichstärke 0.18) über dem Umriss; der Umriss bleibt als Projektion. **Abzugskörper
beliebiger Form im Schnitt**: nicht-prismatische Abzugskörper (verjüngt, B-Rep) kommen als truck-Netz mit
(`toSection.ts`), der Kern schneidet sie mit der Ebene und zieht die Flächen (Löcher als Schlüsselloch) von allen
Schnittflächen ab; sie selbst erscheinen weder als Schnittfläche noch in der Projektion. **Treppenuntersicht**:
gerade Betontreppen im Schnitt aus dem Laufplatten-Netz (`model3d::stair_flight_meshes`, vereinigt, Fugen-Ecken
weg) statt 1.5-cm-Scheiben — Untersicht als Gerade (Golden „muster" Schnitt: Treppe quer, UK 1.4 cm höher).
Geprüft: Rust-Tests (Poché Quader/Pyramide/über Schnitt/Abzug, Abzugsprisma dreieckig durch die Wand = Analytik,
Untersicht auf der Geraden), vitest (Kugel-Abzugskörper spart Schnittflächen aus), CLI-Grundriss/-Schnitte als
PNG angesehen (Linux; das SVG des CLI zeichnet keine Schraffuren, im Render-Scene sind sie da). Offen: Poché für
B-Rep-Körper im Grundriss (kein Netz im Kern, nur Umriss), Eckenradius/Fase in der Poché (Rohprofil),
ExtrudedSolid ohne Material-Feld (keine SIA-Schraffur je Material), Abzugskörper beliebiger Form im Grundriss,
Untersicht von Wendel-/Podesttreppen, nicht in der Tauri-App/Metal geprüft.
- ◐ **[G2] Wand an Dach.** 27.10.: schräge Oberkante (`topDrop`) in render3d statt 15-cm-Treppung. Offen:
Schnitt, exakte Lösung über [B6]. · M–L
- (30.10.) **Exakt je Schicht, analytisch** (ohne Booleans, `wall_bands.rs`): Dach-Unterkante als Facetten
+9
View File
@@ -1467,6 +1467,15 @@ pub fn emit_stair_meshes(p: &Project) -> Vec<RMesh> {
}
}
/// [G1] Laufplatten gerader Betontreppen je Treppe (Index in `p.stairs`): Netze mit exakter
/// Untersicht, für den Schnitt (`plan::section`).
pub fn stair_flight_meshes(p: &Project) -> Vec<(usize, crate::mesh3d::Mesh)> {
match stair_input(p, |s, st| st.is_some_and(|t| t.structure == StairTypeStructure::Beton) && matches!(s.shape, StairShape::Straight)) {
Some((stairs, buf)) => crate::stairs3d::slab_meshes(&buf).into_iter().filter_map(|m| stairs.get(m.src).map(|&(si, _)| (si, m))).collect(),
None => vec![],
}
}
/// Handlauf und Pfosten gerader Treppen (`emitStairRailings`); bei Wendeltreppen als Schraubensweep.
pub fn emit_stair_railings(p: &Project) -> Vec<RMesh> {
match stair_input(p, |s, st| matches!(s.shape, StairShape::Straight | StairShape::Spiral) && st.and_then(|t| t.railing).is_some_and(|r| r != StairTypeRailing::Keine)) {
+70
View File
@@ -689,6 +689,12 @@ fn solids(c: &Ctx, out: &mut Vec<Primitive>) {
}
} else {
out.push(polygon(s.points.clone(), "none", EXTRUSION_STROKE, SYMBOL_HAIRLINE_MM, no_hatch(), None, None, Pick::Solid(&s.id)));
// [G1] Schnittfläche auf Schnitthöhe (Poché); der Umriss darunter bleibt als Projektion.
if zone == super::view_range::Zone::Cut {
if let Some(ring) = body_cut_ring(s, zb, range.cut) {
out.push(polygon(ring, super::section::BODY_FILL, POCHE_STROKE, WALL_FALLBACK_MM, super::section::section_hatch(), None, None, Pick::Solid(&s.id)));
}
}
}
if let Some(d) = range.restyle_dash(zone) {
super::view_range::restyle(out, out_start, d);
@@ -696,6 +702,27 @@ fn solids(c: &Ctx, out: &mut Vec<Primitive>) {
}
}
/// [G1] Schnittfläche eines Körpers (Profil-Extrusion, auch verjüngt) auf der Höhe `cut` (UK `zb`):
/// das Profil, linear zum Ecken-Schwerpunkt gestaucht wie die truck-Verjüngung (`extruded_solid_spec`).
/// `None` für B-Rep-Körper (kein Netz im Kern), Abzugskörper, entartete Profile und ausserhalb.
fn body_cut_ring(s: &ExtrudedSolid, zb: f64, cut: f64) -> Option<Vec<Vec2>> {
let n = s.points.len();
if s.brep.is_some() || s.operation.as_deref() == Some("subtract") || n < 3 || !(s.height > 0.0) || !(cut > zb && cut < zb + s.height) {
return None;
}
let t = min(1.0, max(0.0, s.taper.unwrap_or(0.0)));
let k = 1.0 - t * (cut - zb) / s.height;
if !(k > 1e-9) || s.points.iter().any(|q| !q.x.is_finite() || !q.y.is_finite()) {
return None;
}
if t < 1e-6 {
return Some(s.points.clone());
}
let cx = s.points.iter().fold(0.0, |a, q| a + q.x) / n as f64;
let cy = s.points.iter().fold(0.0, |a, q| a + q.y) / n as f64;
Some(s.points.iter().map(|q| Vec2 { x: cx + (q.x - cx) * k, y: cy + (q.y - cy) * k }).collect())
}
/// Abfrage `planDomains`: Domänen als Listen (Tests); die 2D-Zeichnungen in `drawings`.
pub fn plan_domains(p: &Project, a: &PlanArgs) -> Result<DomainPrims, String> {
let c = Ctx::new(p, a);
@@ -1364,4 +1391,47 @@ mod tests {
assert!(arcs >= 2 * 2, "Umriss innen/aussen als Bögen (≤ 90° je Stück): {arcs}");
assert_eq!(polar, 4, "ein polar schraffiertes Band je Schicht");
}
/// [G1] Körper, die die Schnitthöhe durchdringen: Poché (Schnittfläche auf Schnitthöhe, Schraffur,
/// Schnitt-Strichstärke) über dem Umriss; verjüngt ⇒ kleinere Fläche; darüber/Abzug ⇒ keine Poché.
#[test]
fn koerper_poche_auf_schnitthoehe() {
let mut p = sample();
let mk = |id: &str, off: f64, h: f64, taper: Option<f64>, op: Option<&str>| ExtrudedSolid {
id: id.into(),
level_id: "eg".into(),
points: vec![Vec2 { x: 20.0, y: 0.0 }, Vec2 { x: 22.0, y: 0.0 }, Vec2 { x: 22.0, y: 2.0 }, Vec2 { x: 20.0, y: 2.0 }],
height: h,
base_offset: Some(off),
taper,
operation: op.map(Into::into),
..Default::default()
};
p.extruded_solids = Some(vec![mk("block", 0.0, 2.0, None, None), mk("pyr", 0.0, 2.0, Some(1.0), None), mk("hoch", 1.5, 1.0, None, None), mk("void", 0.0, 2.0, None, Some("subtract"))]);
let cut = super::super::extras::cut_z(&p, "eg");
let base = p.floor("eg").and_then(|f| f.base_elevation).unwrap_or(0.0);
assert!(cut > base && cut < base + 1.5, "Schnitthöhe {cut}");
let r = plan_domains(&p, &args("eg", 1.0, &["20", "30", "60"])).unwrap();
let poche: Vec<(&str, Vec<Vec2>, f64)> = r
.solids
.iter()
.filter_map(|q| match q {
Primitive::Polygon { pts, hatch, stroke_width_mm, extruded_solid_id: Some(id), .. } if hatch.pattern != HatchPattern::None => Some((id.as_str(), pts.clone(), *stroke_width_mm)),
_ => None,
})
.collect();
let ids: Vec<&str> = poche.iter().map(|q| q.0).collect();
assert_eq!(ids, vec!["block", "pyr"], "{ids:?}");
let area = |pts: &[Vec2]| (pts.iter().enumerate().fold(0.0, |a, (i, q)| { let n = pts[(i + 1) % pts.len()]; a + q.x * n.y - n.x * q.y }) / 2.0).abs();
assert!((area(&poche[0].1) - 4.0).abs() < 1e-9);
// Pyramide (Spitze bei 2 m): auf Schnitthöhe um (1 − t) gestaucht.
let k = 1.0 - (cut - base) / 2.0;
assert!((area(&poche[1].1) - 4.0 * k * k).abs() < 1e-9, "{}", area(&poche[1].1));
assert!(poche.iter().all(|q| q.2 == WALL_FALLBACK_MM));
// Darunter bleibt der Umriss (Projektion) aller vier.
let s = serde_json::to_string(&r.solids).unwrap();
for id in ["block", "pyr", "hoch", "void"] {
assert!(s.contains(&format!("\"{id}\"")), "{id}");
}
}
}
+135 -10
View File
@@ -36,10 +36,10 @@ const SECTION_SLAB_AXIS_ANGLE_DEG: f64 = 0.0;
/// Seitenrand (m) der Geländelinie um den Inhalt des Schnitts.
const TERRAIN_MARGIN: f64 = 6.0;
/// Neutrale Füllung geschnittener freier Körper.
const BODY_FILL: &str = "#d9dde2";
pub(crate) const BODY_FILL: &str = "#d9dde2";
/// Rückfall-Schraffur der Cut-Flächen ohne auflösbares Bauteil.
fn section_hatch() -> HatchRender {
pub(crate) fn section_hatch() -> HatchRender {
HatchRender { pattern: HatchPattern::Diagonal, scale: 1.0, angle: 45.0, color: HATCH_INK.into(), line_weight: 0.13, ..no_hatch_base() }
}
@@ -1261,7 +1261,7 @@ fn union_rect_outlines(rects: &[[f64; 4]]) -> Vec<Vec<[f64; 2]>> {
}
/// `mergeMonolithCuts`.
fn merge_monolith_cuts(cuts: Vec<Cut>, slabs: &[RSlab]) -> Vec<Cut> {
fn merge_monolith_cuts(cuts: Vec<Cut>, slabs: &[RSlab], exact: &HashMap<String, Vec<Vec<[f64; 2]>>>) -> Vec<Cut> {
let mut order: Vec<String> = Vec::new();
let mut groups: HashMap<String, Vec<Cut>> = HashMap::new();
let mut out = Vec::new();
@@ -1279,6 +1279,13 @@ fn merge_monolith_cuts(cuts: Vec<Cut>, slabs: &[RSlab]) -> Vec<Cut> {
}
for g in order {
let list = groups.remove(&g).unwrap_or_default();
// [G1] Exakte Fläche (gerade Betontreppe: Untersicht als Gerade statt Scheiben-Sägezahn).
if let Some(rings) = exact.get(&g).filter(|r| !r.is_empty() && !list.is_empty()) {
for ring in rings {
out.push(Cut { pts: ring.clone(), nse: None, ..list[0].clone() });
}
continue;
}
if list.len() == 1 {
out.extend(list);
continue;
@@ -1295,6 +1302,41 @@ fn merge_monolith_cuts(cuts: Vec<Cut>, slabs: &[RSlab]) -> Vec<Cut> {
out
}
/// [G1] Schnittflächen der Laufplatten gerader Betontreppen (je Treppen-ID vereinigt, Löcher als
/// Schlüsselloch) aus ihren Netzen mit exakter Untersicht.
fn stair_flight_sections(p: &Project, base: (f64, f64), u: (f64, f64)) -> HashMap<String, Vec<Vec<[f64; 2]>>> {
let stairs = p.stairs.as_deref().unwrap_or(&[]);
let mut polys: HashMap<String, Vec<crate::flat::Polygon>> = HashMap::new();
for (si, m) in model3d::stair_flight_meshes(p) {
let Some(st) = stairs.get(si) else { continue };
let idx: Vec<f64> = m.indices.iter().map(|&i| i as f64).collect();
let (rings, _) = cut_mesh(&m.positions, &idx, base, u);
polys.entry(st.id.clone()).or_default().extend(rings_to_polygons(&rings));
}
polys
.into_iter()
.map(|(id, list)| {
let rings = crate::polygon_bool::union(&list).into_iter().map(|poly| if poly.len() > 1 { keyhole(&poly).0 } else { poly.into_iter().next().unwrap_or_default() }).map(drop_collinear).filter(|r| r.len() >= 3).collect();
(id, rings)
})
.collect()
}
/// Ecken ohne Knick weglassen (Tritt-Fugen auf der Untersicht).
fn drop_collinear(r: Vec<[f64; 2]>) -> Vec<[f64; 2]> {
let n = r.len();
if n < 4 {
return r;
}
let keep = |i: usize| {
let (a, b, c) = (r[(i + n - 1) % n], r[i], r[(i + 1) % n]);
let (ux, uy, vx, vy) = (b[0] - a[0], b[1] - a[1], c[0] - b[0], c[1] - b[1]);
let l = hypot2(ux, uy) * hypot2(vx, vy);
!(l > 0.0) || (ux * vy - uy * vx).abs() > 1e-6 * l || ux * vx + uy * vy < 0.0
};
(0..n).filter(|&i| keep(i)).map(|i| r[i]).collect()
}
fn is_void_solid(s: &ExtrudedSolid) -> bool {
s.operation.as_deref() == Some("subtract") && s.brep.is_none() && s.taper.unwrap_or(0.0) < 1e-6 && s.points.len() >= 3 && s.height > 0.0
}
@@ -1461,7 +1503,34 @@ fn subtract_voids_in_section(cuts: Vec<Cut>, p: &Project, base: (f64, f64), u: (
if !any || rects.is_empty() {
return cuts;
}
let refs: Vec<&[[f64; 2]]> = rects.iter().map(|r| r.as_slice()).collect();
subtract_rings_from_cuts(cuts, &rects)
}
/// [G1] Ob ein Körper-Netz zu einem Abzugskörper gehört.
fn is_subtract_body(p: &Project, b: &BodyMesh) -> bool {
p.extruded_solids.as_deref().and_then(|s| s.get(b.index)).is_some_and(|s| s.operation.as_deref() == Some("subtract"))
}
/// [G1] Abzugskörper beliebiger Form: Netz mit der Ebene schneiden, Flächen (Löcher als Schlüsselloch)
/// von allen bisherigen Schnittflächen abziehen.
fn subtract_body_voids_in_section(cuts: Vec<Cut>, voids: &[&BodyMesh], base: (f64, f64), u: (f64, f64)) -> Vec<Cut> {
let mut rings: Vec<Vec<[f64; 2]>> = Vec::new();
for b in voids {
let (r, _) = cut_mesh(&b.positions, &b.indices, base, u);
for poly in rings_to_polygons(&r) {
rings.push(if poly.len() > 1 { keyhole(&poly).0 } else { poly[0].clone() });
}
}
rings.retain(|r| r.len() >= 3);
if rings.is_empty() {
return cuts;
}
subtract_rings_from_cuts(cuts, &rings)
}
/// Zieht `rings` von jeder Schnittfläche ab (Ränder auf den Schnittkanten ohne Strich); Fehlschlag ⇒ unverändert.
fn subtract_rings_from_cuts(cuts: Vec<Cut>, rings: &[Vec<[f64; 2]>]) -> Vec<Cut> {
let refs: Vec<&[[f64; 2]]> = rings.iter().map(|r| r.as_slice()).collect();
let cutters = encode_rings(&refs);
let mut out = Vec::with_capacity(cuts.len());
for cp in cuts {
@@ -1630,7 +1699,7 @@ fn keyhole(poly: &[Vec<[f64; 2]>]) -> (Vec<[f64; 2]>, Vec<f64>) {
}
/// `appendBodySections` + `attachBodyOwners`: geschnittene freie Körper.
fn append_body_sections(cuts: &mut Vec<Cut>, p: &Project, bodies: &[BodyMesh], base: (f64, f64), u: (f64, f64)) {
fn append_body_sections(cuts: &mut Vec<Cut>, p: &Project, bodies: &[&BodyMesh], base: (f64, f64), u: (f64, f64)) {
let solids = p.extruded_solids.as_deref().unwrap_or(&[]);
for b in bodies {
let (rings, _) = cut_mesh(&b.positions, &b.indices, base, u);
@@ -1845,7 +1914,7 @@ fn quad_of(t: &[[f64; 3]; 3], n: [f64; 3], next: &[u32], vert: &dyn Fn(u32) -> (
/// Dreiecke (Wände samt Gehrung und Löchern wie im 3D-Modell, Platten, Treppen, Dächer, Körper),
/// auf die Seite hinter der Ebene zugeschnitten; die Schnittflächen verdecken in Tiefe 0. Bogenwände,
/// verschnittene Dächer und Körper glätten ihre Facetten (keine Fugen, nur Knicke und Silhouetten).
fn projection_edges(p: &Project, plane: &Plane, walls_r: &[RWall], wi: &[render3d::WallInput], slabs_r: &[RSlab], bodies: &[BodyMesh], cuts: &[Cut], hidden: bool, max_depth: Option<f64>) -> (Vec<Edge>, Vec<Edge>) {
fn projection_edges(p: &Project, plane: &Plane, walls_r: &[RWall], wi: &[render3d::WallInput], slabs_r: &[RSlab], bodies: &[&BodyMesh], cuts: &[Cut], hidden: bool, max_depth: Option<f64>) -> (Vec<Edge>, Vec<Edge>) {
use crate::hlr;
let nl = crate::jsmath::hypot(&plane.normal);
if !(nl > 1e-12) {
@@ -2039,15 +2108,18 @@ pub fn compute_section(p: &Project, level: &LevelSpec, bodies: &[BodyMesh]) -> R
let walls: Vec<Option<&Wall>> = owners.iter().zip(&virt).map(|(o, v)| v.as_ref().or(*o)).collect();
let slabs = slab_owners(p, &slabs_r);
let cuts = attach_cut_styles(cuts, p, &plane, &walls, &slabs)?;
let cuts = merge_monolith_cuts(cuts, &slabs_r);
let cuts = merge_monolith_cuts(cuts, &slabs_r, &stair_flight_sections(p, plane.base(), plane.u_model()));
let base = plane.base();
let u = plane.u_model();
let cuts = subtract_voids_in_section(cuts, p, base, u);
// [G1] Abzugskörper beliebiger Form kommen als Netz mit (wie freie Körper): ausgespart, nicht gezeichnet.
let (void_bodies, bodies): (Vec<&BodyMesh>, Vec<&BodyMesh>) = bodies.iter().partition(|b| is_subtract_body(p, b));
let cuts = subtract_body_voids_in_section(cuts, &void_bodies, base, u);
let cuts = subtract_pockets_in_section(cuts, p, base, u);
let mut cuts = parallel_reveal_cuts(cuts, p, &plane, &walls)?;
append_body_sections(&mut cuts, p, bodies, base, u);
append_body_sections(&mut cuts, p, &bodies, base, u);
// Projektion hinter der Ebene exakt ([G4]); die Schnittflächen verdecken, was hinter ihnen liegt.
let (mut visible, hidden) = projection_edges(p, &plane, &walls_r, &wi, &slabs_r, bodies, &cuts, level.hidden_lines, level.depth);
let (mut visible, hidden) = projection_edges(p, &plane, &walls_r, &wi, &slabs_r, &bodies, &cuts, level.hidden_lines, level.depth);
shaped_projection(&mut visible, p, &walls_r, &plane);
let mut out = Output { cuts, visible, hidden, profiles: Vec::new(), earth: Vec::new() };
append_terrain_profiles(&mut out, p, base, u);
@@ -2746,6 +2818,59 @@ mod tests {
assert!((full - wall_area(&p, 0.5)).abs() < 1e-4);
}
/// [G1] Abzugskörper beliebiger Form (Netz, hier dreieckiges Prisma quer durch die Wand): seine
/// Schnittfläche wird aus der Wand-Poché ausgespart; er selbst erscheint weder als Schnittfläche
/// noch in der Projektion.
#[test]
fn abzugskoerper_beliebiger_form_im_schnitt() {
use crate::plan::walls::tests::pocket_project;
let mut p = pocket_project(DoorTypeKind::Tasche, Some(OpeningHinge::End), 1.0);
// Profil/Verjüngung nur, damit es kein senkrechtes Prisma ist (das ginge über `section_rects`).
let pts = vec![Vec2 { x: 3.2, y: -1.0 }, Vec2 { x: 3.8, y: -1.0 }, Vec2 { x: 3.8, y: 1.0 }, Vec2 { x: 3.2, y: 1.0 }];
p.extruded_solids = Some(vec![ExtrudedSolid { id: "v".into(), level_id: "eg".into(), points: pts, height: 1.0, base_offset: Some(1.0), taper: Some(0.5), operation: Some("subtract".into()), ..Default::default() }]);
// Dreieckiges Prisma längs x: Querschnitt (y, z) = (−1, 1), (1, 1), (0, 2).
let tri = [[-1.0, 1.0], [1.0, 1.0], [0.0, 2.0]];
let mut positions = Vec::new();
for x in [3.2, 3.8] {
for q in tri {
positions.extend([x, q[0], q[1]]);
}
}
let indices: Vec<f64> = [0, 2, 1, 3, 4, 5, 0, 1, 4, 0, 4, 3, 1, 2, 5, 1, 5, 4, 2, 0, 3, 2, 3, 5].iter().map(|&i| i as f64).collect();
let body = BodyMesh { index: 0, positions, indices };
let l = LevelSpec { kind: "section".into(), line: Some([Vec2 { x: 3.5, y: -1.0 }, Vec2 { x: 3.5, y: 1.0 }]), ..Default::default() };
let area = |c: &Cut| {
let n = c.pts.len();
(0..n).map(|i| c.pts[i][0] * c.pts[(i + 1) % n][1] - c.pts[(i + 1) % n][0] * c.pts[i][1]).sum::<f64>().abs() / 2.0
};
let full: f64 = compute_section(&p, &l, &[]).unwrap().unwrap().cuts.iter().filter(|c| c.kind == Kind::Wall).map(area).sum();
let out = compute_section(&p, &l, std::slice::from_ref(&body)).unwrap().unwrap();
let cut: f64 = out.cuts.iter().filter(|c| c.kind == Kind::Wall).map(area).sum();
// Wand 16 cm mittig auf y = 0: ∫ min(0.16, 2·(2 − z)) dz über 1…2 = 0.16·0.92 + 0.08².
assert!((full - cut - (0.16 * 0.92 + 0.0064)).abs() < 1e-5, "{full} {cut}");
assert!(out.cuts.iter().all(|c| c.kind != Kind::Body));
// Keine Kante des Abzugskörpers in der Projektion (Prisma-Enden bei x = 3.8 liegen hinter der Ebene).
let apex = |q: [f64; 2]| (q[0] - 1.0).abs() < 1e-6 && (q[1] - 2.0).abs() < 1e-6;
assert!(!out.visible.iter().chain(&out.hidden).any(|e| apex(e.a) || apex(e.b)));
}
/// [G1] Treppenuntersicht: gerade Betontreppe längs geschnitten — die Laufplatte unten als gerade
/// Linie (exakt, aus dem Laufplatten-Netz), nicht mehr als Sägezahn aus 1.5-cm-Scheiben.
#[test]
fn treppenuntersicht_exakt() {
let p = sample();
let l = LevelSpec { kind: "section".into(), line: Some([Vec2 { x: 3.2, y: -1.0 }, Vec2 { x: 3.2, y: 5.0 }]), ..Default::default() };
let out = compute_section(&p, &l, &[]).unwrap().unwrap();
let st: Vec<&Cut> = out.cuts.iter().filter(|c| c.stair_id.as_deref() == Some("ST1")).collect();
assert_eq!(st.len(), 1, "{:?}", out.cuts.iter().map(|c| (c.kind, c.index, c.stair_id.clone(), c.pts.len())).collect::<Vec<_>>());
let pts = &st[0].pts;
// ST1: Lauf 3.2 m ab y = 0.4, Steigung 2.6 m, 15 Stufen ⇒ Laufplatte 0.208 m senkrecht.
let soffit = |u: f64| (((u - 1.4) / 3.2) * 2.6 - 0.208).max(0.0);
assert!(pts.iter().all(|q| q[1] >= soffit(q[0]) - 1e-6), "{pts:?}");
assert!(pts.iter().filter(|q| q[1] > 0.1 && (q[1] - soffit(q[0])).abs() < 1e-6).count() >= 2, "{pts:?}");
assert!(pts.len() < 2 * 15 + 10, "{pts:?}");
}
/// [95][T2] Schnitt durch die Tasche in der Bogenwand (radial) und unter schräger Oberkante.
#[test]
fn schnitt_durch_die_tasche_bogen_und_dach() {
@@ -3335,7 +3460,7 @@ mod ts_faelle {
let slab = |m: Option<&str>| RSlab { outline: vec![], z_bottom: 0.0, z_top: 1.0, color: [0.0; 3], ceiling_id: String::new(), hatch: None, cut: None, monolith: m.map(String::from), source: SlabSource::None };
let slabs = vec![slab(None), slab(Some("ST1")), slab(Some("ST1"))];
let mk = |i: usize, u0: f64| Cut::new(Kind::Slab, i, vec![[u0, 0.0], [u0 + 1.0, 0.0], [u0 + 1.0, 1.0], [u0, 1.0]]);
let out = merge_monolith_cuts(vec![mk(0, 0.0), mk(1, 0.0), mk(2, 0.5)], &slabs);
let out = merge_monolith_cuts(vec![mk(0, 0.0), mk(1, 0.0), mk(2, 0.5)], &slabs, &HashMap::new());
assert_eq!(out.len(), 2, "nur Bänder derselben Gruppe werden vereint");
}
+1 -1
View File
@@ -31,7 +31,7 @@
<polygon points="3.46,4.54564 5.8425,4.54564 5.8425,4.58564 3.46,4.58564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="1,4.58564 6,4.58564 6,4.78564 1,4.78564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="0.6,0.5 6.4,0.5 6.4,0.73094 0.6,0.73094" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="4.2,6.00809 5.2,6.00809 5.2,5.69897 4.2,5.69897" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="4.2,5.69897 4.2,5.99364 5.2,5.99364 5.2,5.69897" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.035" stroke-linejoin="round"/>
<line x1="5.8275" y1="7.08564" x2="5.4" y2="7.08564" stroke="#2b3039" stroke-width="0.018"/>
<line x1="5.4" y1="6.18564" x2="5.4" y2="4.88564" stroke="#2b3039" stroke-width="0.018"/>
<line x1="5.4" y1="7.08564" x2="4" y2="7.08564" stroke="#2b3039" stroke-width="0.018"/>

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

@@ -4,4 +4,4 @@ line 35
polygon 31
rect 1
svg 1
hash 12af29f2ceb8cdc6
hash 58399ffc23652b9f
+25
View File
@@ -58,4 +58,29 @@ describe("Schnitt: Gelände und freie Körper", () => {
const plan = generateSectionPlan((await computeSection(p, section))!);
expect(plan.primitives.some((q) => q.kind === "polygon" && q.extrudedSolidId === "ball" && q.fill === "#d9dde2")).toBe(true);
}, 30_000);
it("Abzugskörper beliebiger Form (Kugel, B-Rep) spart die Schnittflächen aus, ohne selbst zu erscheinen", async () => {
const floor = sampleProject.drawingLevels.find((l) => l.kind === "floor")!;
const [a, b] = section.linePoints!;
const cx = (a.x + b.x) / 2;
const cy = (a.y + b.y) / 2;
const r = 2;
const ball: ExtrudedSolid = {
id: "void-ball", type: "extrudedSolid", levelId: floor.id, height: 2 * r, operation: "subtract",
points: [{ x: cx - r, y: cy - r }, { x: cx + r, y: cy - r }, { x: cx + r, y: cy + r }, { x: cx - r, y: cy + r }],
brep: { spec: { kind: "sphere", center: [cx, cy, 1], r }, origin: { x: cx - r, y: cy - r } },
};
const cutArea = async (p: Project) => {
const plan = generateSectionPlan((await computeSection(p, section))!);
expect(plan.primitives.some((q) => q.kind === "polygon" && q.extrudedSolidId === "void-ball")).toBe(false);
return plan.primitives.reduce((s, q) => {
if (q.kind !== "polygon" || q.fill === "none") return s;
const n = q.pts.length;
return s + Math.abs(q.pts.reduce((t, v, i) => t + v.x * q.pts[(i + 1) % n].y - q.pts[(i + 1) % n].x * v.y, 0)) / 2;
}, 0);
};
const before = await cutArea(sampleProject);
const after = await cutArea({ ...sampleProject, extrudedSolids: [...(sampleProject.extrudedSolids ?? []), ball] });
expect(after).toBeLessThan(before - 0.1);
}, 30_000);
});
+3 -1
View File
@@ -49,7 +49,9 @@ export async function computeSection(project: Project, level: DrawingLevel): Pro
const solids = project.extrudedSolids ?? [];
for (let index = 0; index < solids.length; index++) {
const solid = solids[index];
if (solid.operation === "subtract" || isVoid(solid)) continue;
// Senkrechte Prismen-Abzugskörper rechnet der Kern selbst; alle übrigen Abzugskörper ([G1]) kommen
// als Netz mit und werden im Kern aus den Schnittflächen ausgespart.
if (isVoid(solid)) continue;
let baseZ = 0;
try {
baseZ = solid.levelId ? (getFloor(project, solid.levelId).baseElevation ?? 0) : 0;