[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
@@ -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");
|
||||
}
|
||||
Reference in new issue
Block a user