[68] Verbau im 3D und in der Ansicht, Einbindetiefe als Feld, Erdreich-Band ohne Loch bei ausgeblendeter Klasse
This commit is contained in:
17 files changed
+277
-24
No files matched your search
@@ -234,6 +234,11 @@ impl ExSpec {
|
||||
/// Einbindetiefe der Verbauwand unter die Sohle (m).
|
||||
pub const SHORING_EMBED: f64 = 1.0;
|
||||
|
||||
/// Einbindetiefe der Baugrube (Feld `shoringEmbed`, Vorgabe [`SHORING_EMBED`]).
|
||||
pub fn shoring_embed(e: &Excavation) -> f64 {
|
||||
e.shoring_embed.filter(|v| v.is_finite() && *v >= 0.0).unwrap_or(SHORING_EMBED)
|
||||
}
|
||||
|
||||
/// Art des Verbaus und ihre Vorgabe-Dicke (m); Unbekanntes = Spundwand.
|
||||
pub fn shoring_kind(k: Option<&str>) -> (&'static str, f64) {
|
||||
match k {
|
||||
@@ -265,6 +270,67 @@ impl ExSpec {
|
||||
}
|
||||
}
|
||||
|
||||
/// [68] Verbauwand einer Baugrube als geschlossene Prismen (Modellbezug, Höhen = Gelände − Höhenbezug) für 3D, Ansicht
|
||||
/// und Pick: je verbauter Kante ein Körper von Sohle − Einbindetiefe bis zum gewachsenen Gelände.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ShoringSolid {
|
||||
pub excavation_id: String,
|
||||
pub kind: &'static str,
|
||||
/// x, y, z je Ecke.
|
||||
pub pos: Vec<f64>,
|
||||
pub idx: Vec<u32>,
|
||||
}
|
||||
|
||||
/// Verbauwände aller Baugruben des Projekts, ein [`ShoringSolid`] je Baugrube mit Verbau.
|
||||
pub fn shoring_solids(p: &Project) -> Vec<ShoringSolid> {
|
||||
let mut out: Vec<ShoringSolid> = Vec::new();
|
||||
for t in terrains(p) {
|
||||
if t.positions.len() < 9 {
|
||||
continue;
|
||||
}
|
||||
let st = site_terrain(p, t);
|
||||
let idx = st.index_orig();
|
||||
for (id, spec, _) in &st.items {
|
||||
if out.iter().any(|s| &s.excavation_id == id) {
|
||||
continue;
|
||||
}
|
||||
let Some(e) = excavations(p).into_iter().find(|e| e.id == *id) else { continue };
|
||||
let quads = spec.shoring_quads();
|
||||
if quads.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let z_bottom = e.bottom - shoring_embed(e);
|
||||
let mut s = ShoringSolid { excavation_id: id.clone(), kind: spec.shore_kind, pos: Vec::new(), idx: Vec::new() };
|
||||
for (_, mut quad) in quads {
|
||||
if signed_area(&quad) < 0.0 {
|
||||
quad.reverse();
|
||||
}
|
||||
let tops: Vec<Option<f64>> = quad.iter().map(|q| idx.z_at(q[0], q[1]).map(|z| (z - st.datum).max(e.bottom))).collect();
|
||||
if tops.iter().any(Option::is_none) || tops.iter().flatten().all(|z| *z <= e.bottom + 1e-3) {
|
||||
continue;
|
||||
}
|
||||
let b = s.pos.len() as u32 / 3;
|
||||
for q in &quad {
|
||||
s.pos.extend([q[0], q[1], z_bottom]);
|
||||
}
|
||||
for (q, z) in quad.iter().zip(&tops) {
|
||||
s.pos.extend([q[0], q[1], z.unwrap_or(e.bottom)]);
|
||||
}
|
||||
// Unterseite, Oberseite, vier Seiten (aussen, gegen den Uhrzeigersinn).
|
||||
s.idx.extend([b, b + 2, b + 1, b, b + 3, b + 2, b + 4, b + 5, b + 6, b + 4, b + 6, b + 7]);
|
||||
for i in 0..4u32 {
|
||||
let j = (i + 1) % 4;
|
||||
s.idx.extend([b + i, b + j, b + 4 + j, b + i, b + 4 + j, b + 4 + i]);
|
||||
}
|
||||
}
|
||||
if !s.idx.is_empty() {
|
||||
out.push(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Prüfung des Arbeitsraums an den Ecken des Umrisses ([68]).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct WsCheck {
|
||||
|
||||
@@ -6379,6 +6379,10 @@ pub struct Excavation {
|
||||
#[serde(rename = "shoringThickness", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub shoring_thickness: Option<f64>,
|
||||
/// [68] Einbindetiefe der Verbauwand unter die Sohle in m; fehlt = 1 m.
|
||||
#[serde(rename = "shoringEmbed", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub shoring_embed: Option<f64>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
|
||||
@@ -61,8 +61,32 @@ pub fn emit_context_meshes(p: &Project) -> Vec<RMesh> {
|
||||
owner: Owner::Context(ci),
|
||||
crease_angle: (m.smooth_shading == Some(true)).then(|| m.crease_angle.filter(|a| a.is_finite() && *a > 0.0).unwrap_or(DEFAULT_CREASE_DEG).min(180.0)),
|
||||
}),
|
||||
// [68] Verbauwand der Baugrube: Körper in der Farbe der Verbauart, Klasse und Pick der Baugrube.
|
||||
ContextObject::Excavation(e) => {
|
||||
if let Some(s) = crate::excavation::shoring_solids(p).into_iter().find(|s| s.excavation_id == e.id) {
|
||||
out.push(RMesh {
|
||||
positions: s.pos,
|
||||
indices: s.idx,
|
||||
kind: "imported",
|
||||
color: shoring_rgb(s.kind),
|
||||
vertex_colors: None,
|
||||
material_index: None,
|
||||
owner: Owner::Context(ci),
|
||||
crease_angle: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// [68] Bauteilfarbe der Verbauart: Stahl (Spundwand), Holz (Rühlwand), Beton (Bohrpfahlwand).
|
||||
pub fn shoring_rgb(kind: &str) -> Rgb {
|
||||
match kind {
|
||||
"soldierPile" => [0.62, 0.47, 0.30],
|
||||
"borePile" => [0.72, 0.72, 0.70],
|
||||
_ => [0.52, 0.56, 0.60],
|
||||
}
|
||||
}
|
||||
@@ -201,6 +201,17 @@ pub fn pick_geometry(p: &Project) -> Result<PickGeometry, String> {
|
||||
(pos, idx, &m.id)
|
||||
}
|
||||
ContextObject::ImportedMesh(m) => (std::borrow::Cow::Borrowed(m.positions.as_slice()), std::borrow::Cow::Borrowed(m.indices.as_slice()), &m.id),
|
||||
// [68] Verbauwand: Körper der Baugrube (Positionen im Modell, Welt wie die übrigen Kontext-Meshes).
|
||||
ContextObject::Excavation(e) => {
|
||||
if let Some(s) = crate::excavation::shoring_solids(p).into_iter().find(|s| s.excavation_id == e.id) {
|
||||
let at = |i: u32| -> V3 { [s.pos[i as usize * 3], s.pos[i as usize * 3 + 2], -s.pos[i as usize * 3 + 1]] };
|
||||
let tris: Vec<Tri> = s.idx.chunks_exact(3).map(|t| [at(t[0]), at(t[1]), at(t[2])]).collect();
|
||||
if !tris.is_empty() {
|
||||
context_meshes.push(PickContextMesh { tris, context_object_id: e.id.clone() });
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
_ => continue,
|
||||
};
|
||||
let (pos, idx) = (&*pos, &*idx);
|
||||
|
||||
@@ -594,3 +594,44 @@ fn netzkoerper_klasse_ausgeblendet() {
|
||||
assert!(emit_context_meshes(&mk(false)).is_empty());
|
||||
assert!(pick_geometry(&mk(false)).unwrap().context_meshes.is_empty());
|
||||
}
|
||||
|
||||
/// [68] Verbau im 3D: Körper in der Farbe der Verbauart, Klasse der Baugrube, Pick wählt die Baugrube.
|
||||
#[test]
|
||||
fn verbau_im_3d_klasse_und_pick() {
|
||||
let t = crate::model::TerrainMesh {
|
||||
id: "t".into(),
|
||||
category_code: "02".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],
|
||||
..Default::default()
|
||||
};
|
||||
let v = |x: f64, y: f64| crate::model::Vec2 { x, y };
|
||||
let pit = crate::model::Excavation {
|
||||
id: "bg".into(),
|
||||
category_code: "07".into(),
|
||||
outline: vec![v(0.0, 0.0), v(8.0, 0.0), v(8.0, 6.0), v(0.0, 6.0)],
|
||||
bottom: -3.0,
|
||||
edge_shoring: Some(vec![true, false, true, false]),
|
||||
shoring_kind: Some("soldierPile".into()),
|
||||
shoring_embed: Some(0.5),
|
||||
..Default::default()
|
||||
};
|
||||
let cat = |visible| crate::model::LayerCategory { code: "07".into(), name: "Baugrube".into(), visible, ..Default::default() };
|
||||
let mk = |visible| Project { context: Some(vec![ContextObject::TerrainMesh(t.clone()), ContextObject::Excavation(pit.clone())]), layers: vec![cat(visible)], ..Default::default() };
|
||||
let meshes = emit_context_meshes(&mk(true));
|
||||
assert_eq!(meshes.len(), 2, "Gelände + Verbau");
|
||||
let m = meshes.iter().find(|m| matches!(m.owner, Owner::Context(1))).unwrap();
|
||||
assert_eq!(m.color, shoring_rgb("soldierPile"));
|
||||
// Zwei Wände: unten Sohle - 0.5, oben Gelände (0).
|
||||
let zs: Vec<f64> = m.positions.chunks_exact(3).map(|q| q[2]).collect();
|
||||
assert!((zs.iter().cloned().fold(f64::INFINITY, f64::min) + 3.5).abs() < 1e-6 && zs.iter().cloned().fold(f64::NEG_INFINITY, f64::max).abs() < 1e-6);
|
||||
assert_eq!(m.indices.len(), 2 * 12 * 3);
|
||||
// Klasse aus: Verbau weg, Gelände bleibt.
|
||||
let off = emit_context_meshes(&mk(false));
|
||||
assert_eq!(off.len(), 1);
|
||||
assert!(off.iter().all(|m| matches!(m.owner, Owner::Context(0))));
|
||||
// Pick.
|
||||
let g = pick_geometry(&mk(true)).unwrap();
|
||||
assert!(g.context_meshes.iter().any(|m| m.context_object_id == "bg" && m.tris.len() == 24));
|
||||
assert!(pick_geometry(&mk(false)).unwrap().context_meshes.iter().all(|m| m.context_object_id != "bg" || m.tris.len() != 24), "Klasse aus: kein Verbau-Pick");
|
||||
}
|
||||
@@ -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> {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user