[68] Verbau im 3D und in der Ansicht, Einbindetiefe als Feld, Erdreich-Band ohne Loch bei ausgeblendeter Klasse

This commit is contained in:
Claude committed 2026-11-11 19:49:01 +00:00
1 parent c76025f997
commit 6771fee2d2
17 files changed
+277 -24

No files matched your search

@@ -130,6 +130,18 @@ pub(super) fn collect_mesh_faces(p: &Project, frame: &[f64; 9]) -> Vec<Face> {
out
}
/// [68] Verbauwände der Baugruben als Netz-Flächen (Role::Mesh, id = Baugrube): Farbe der Verbauart wie im 3D,
/// Verdeckung wie jedes Netz über die exakte Sichtbarkeit.
pub(super) fn collect_shoring_faces(p: &Project, frame: &[f64; 9]) -> Vec<Face> {
let mut out = Vec::new();
for s in crate::excavation::shoring_solids(p) {
let idx: Vec<f64> = s.idx.iter().map(|&i| i as f64).collect();
let Some(info) = crate::mesh_view::analyze(&s.pos, &idx) else { continue };
mesh_faces(frame, &s.pos, &info, Role::Mesh, &s.excavation_id, model3d::shoring_rgb(s.kind), &mut out);
}
out
}
/// [115] Freie Körper (`extrudedSolids`, Netze aus dem Kern, `solid_mesh.rs`) wie importierte Netze; Abzugskörper
/// sind kein Material und fehlen.
pub(super) fn collect_body_faces(p: &Project, frame: &[f64; 9]) -> Vec<Face> {
+10 -2
View File
@@ -226,6 +226,7 @@ pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool,
faces.extend(collect_column_faces(p, &frame));
faces.extend(collect_mesh_faces(p, &frame));
faces.extend(collect_body_faces(p, &frame));
faces.extend(collect_shoring_faces(p, &frame));
// Ansichtsbereich ([36]): Bauteile, deren nächster Punkt weiter als `depth` hinter der Ansichtsebene
// liegt, entfallen ganz (samt ihren Öffnungen, s. unten).
let far = level.depth.filter(|d| *d > 0.0).map(|d| (d, drop_far_faces(&mut faces, d)));
@@ -253,8 +254,15 @@ pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool,
}
let mut mesh_cat: HashMap<&str, &str> = HashMap::new();
for c in p.context.as_deref().unwrap_or(&[]) {
if let ContextObject::ImportedMesh(m) = c {
mesh_cat.entry(m.id.as_str()).or_insert(m.category_code.as_str());
match c {
ContextObject::ImportedMesh(m) => {
mesh_cat.entry(m.id.as_str()).or_insert(m.category_code.as_str());
}
// [68] Verbauwand der Baugrube: Klasse der Baugrube.
ContextObject::Excavation(e) => {
mesh_cat.entry(e.id.as_str()).or_insert(e.category_code.as_str());
}
_ => {}
}
}
// [180] Freie Körper mit ihrer Klasse.
+2 -6
View File
@@ -277,7 +277,7 @@ fn append_shoring(out: &mut Output, p: &Project, base: (f64, f64), u: (f64, f64)
let hatch_id = crate::excavation::shoring_hatch_id(spec.shore_kind);
let hatch = crate::plan::style::resolve_hatch(p, hatch_id, None, None, None)
.unwrap_or(HatchRender { pattern: HatchPattern::Diagonal, scale: 1.0, angle: 45.0, color: HATCH_INK.into(), line_weight: 0.1, ..no_hatch_base() });
let z_bottom = e.bottom - crate::excavation::SHORING_EMBED;
let z_bottom = e.bottom - crate::excavation::shoring_embed(e);
for (_, quad) in quads {
// Schnitt der Geraden base + s·u mit dem Viereck: erster und letzter Durchgang.
let mut ss: Vec<f64> = Vec::new();
@@ -360,11 +360,7 @@ fn append_earth(out: &mut Output, p: &Project, base: (f64, f64), u: (f64, f64))
return;
}
let mut band = crate::polygon_bool::union(&band);
// [68] Verbauwände stehen im Erdreich: das Band lässt sie aus.
if !out.shoring.is_empty() {
let walls: Vec<crate::flat::Polygon> = out.shoring.iter().map(|w| vec![w.ring.clone()]).collect();
band = crate::polygon_bool::difference(&band, &walls);
}
// [68] Die Verbauwände lässt erst `section_primitives` aus, und nur die sichtbaren (ausgeblendete Klasse = kein Loch).
// Gebäude-Inneres: Abschnitte der Schnittlinie in der Grundfläche.
let mut holes: Vec<crate::flat::Polygon> = Vec::new();
for poly in crate::site_rules::building_footprint(p) {
+12 -1
View File
@@ -432,7 +432,18 @@ pub fn section_primitives_mv(out: &Output, mono: bool, hidden_lines: bool, vis:
let tov = rules.terrain.as_ref();
let terrain_shown = out.profiles.iter().all(|pr| pr.category.as_deref().is_none_or(shown)) && !tov.is_some_and(|(a, _)| a.hidden());
if terrain_shown {
for (ring, hatch) in &out.earth {
// [68] Sichtbare Verbauwände stehen im Erdreich: das Band lässt sie aus.
let walls: Vec<crate::flat::Polygon> = out.shoring.iter().filter(|w| shown(&w.category)).map(|w| vec![w.ring.clone()]).collect();
let earth: Vec<(Vec<[f64; 2]>, &HatchRender)> = if walls.is_empty() {
out.earth.iter().map(|(r, h)| (r.clone(), h)).collect()
} else {
out.earth
.iter()
.flat_map(|(r, h)| crate::polygon_bool::difference(&[vec![r.clone()]], &walls).into_iter().filter_map(move |poly| poly.into_iter().next().filter(|o| o.len() >= 3).map(|o| (o, h))))
.collect()
};
for (ring, hatch) in &earth {
let hatch: &HatchRender = hatch;
let hatch = match tov.and_then(|(_, l)| l.hatch.as_deref()) {
Some("none") => no_hatch(),
Some("material") | None => hatch.clone(),
+73 -2
View File
@@ -900,8 +900,79 @@ fn verbauwand_im_schnitt() {
assert!(wall_area > 1.0);
// Klasse aus: keine Wand.
let vis = Visibility { has_vis: true, invisible: ["07".to_string()].into_iter().collect(), ..Default::default() };
let (prims, _) = section_primitives(&out, false, false, &vis);
assert!(!prims.iter().any(|q| matches!(q, Primitive::Polygon { context_object_id: Some(id), .. } if id == "bg")));
let (prims2, _) = section_primitives(&out, false, false, &vis);
assert!(!prims2.iter().any(|q| matches!(q, Primitive::Polygon { context_object_id: Some(id), .. } if id == "bg")));
// Ohne die Wand kein Loch im Erdreich-Band: die Fläche wächst um (mindestens) die Wandfläche.
let earth_area = |pr: &[Primitive]| -> f64 {
pr.iter()
.filter_map(|q| match q {
Primitive::Polygon { pts, hatch, .. } if hatch.pattern == HatchPattern::Earth => Some((0..pts.len()).map(|i| pts[i].x * pts[(i + 1) % pts.len()].y - pts[(i + 1) % pts.len()].x * pts[i].y).sum::<f64>().abs() / 2.0),
_ => None,
})
.sum()
};
assert!(earth_area(&prims2) > earth_area(&prims) + 0.5, "{} {} {wall_area}", earth_area(&prims2), earth_area(&prims));
}
/// [68] Verbau in der Ansicht: Wandflächen der Baugrube (Pick = Baugrube), Klasse steuert sie.
#[test]
fn verbauwand_in_der_ansicht() {
let (p, _) = shoring_site();
let lv = level(&p, "ansicht-sued");
let run = |vis: &Visibility| super::super::elevation::elevation_primitives(&p, &lv, false, false, vis, 100.0).unwrap().unwrap().0;
let has = |ep: &[Primitive]| ep.iter().any(|q| matches!(q, Primitive::Polygon { context_object_id: Some(id), .. } if id == "bg"));
assert!(has(&run(&Visibility::default())), "Verbau in der Ansicht");
let vis = Visibility { has_vis: true, invisible: ["07".to_string()].into_iter().collect(), ..Default::default() };
assert!(!has(&run(&vis)), "Klasse aus: kein Verbau");
}
fn shoring_site() -> (Project, Excavation) {
let mut p = sample();
let flat = TerrainMesh {
id: "t".into(),
positions: vec![-50.0, -50.0, 0.0, 50.0, -50.0, 0.0, 50.0, 50.0, 0.0, -50.0, 50.0, 0.0],
indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0],
category_code: "02".into(),
..Default::default()
};
let pit = Excavation {
id: "bg".into(),
category_code: "07".into(),
outline: vec![Vec2 { x: -1.0, y: -1.0 }, Vec2 { x: 6.0, y: -1.0 }, Vec2 { x: 6.0, y: 5.0 }, Vec2 { x: -1.0, y: 5.0 }],
bottom: -2.0,
edge_shoring: Some(vec![true; 4]),
..Default::default()
};
p.context = Some(vec![ContextObject::TerrainMesh(flat), ContextObject::Excavation(pit.clone())]);
(p, pit)
}
/// [68] Einbindetiefe als Feld: `shoringEmbed` ersetzt die Vorgabe von 1 m.
#[test]
fn verbauwand_einbindetiefe_feld() {
let mut p = sample();
let flat = TerrainMesh {
id: "t".into(),
positions: vec![-50.0, -50.0, 0.0, 50.0, -50.0, 0.0, 50.0, 50.0, 0.0, -50.0, 50.0, 0.0],
indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0],
category_code: "02".into(),
..Default::default()
};
let pit = Excavation {
id: "bg".into(),
outline: vec![Vec2 { x: -1.0, y: -1.0 }, Vec2 { x: 6.0, y: -1.0 }, Vec2 { x: 6.0, y: 5.0 }, Vec2 { x: -1.0, y: 5.0 }],
bottom: -2.0,
edge_shoring: Some(vec![true; 4]),
shoring_embed: Some(2.5),
..Default::default()
};
p.context = Some(vec![ContextObject::TerrainMesh(flat), ContextObject::Excavation(pit)]);
let out = compute_section(&p, &level(&p, "schnitt-a"), &[]).unwrap().unwrap();
assert!(!out.shoring.is_empty());
for w in &out.shoring {
let lo = w.ring.iter().map(|q| q[1]).fold(f64::INFINITY, f64::min);
assert!((lo + 4.5).abs() < 1e-6, "{lo}");
}
}
fn ov_rule(conds: serde_json::Value, actions: serde_json::Value) -> OverrideRule {