[162] Grosse Rust-Dateien geteilt: plan/section.rs → plan/section/, model3d.rs → model3d/
Reines Verschieben ohne Logik-Änderung: gleiche Funktionen, gleiche Tests (1194 Kern-Tests vorher und nachher, Namensliste identisch). Jede neue Datei mit Kopf-Kommentar; Sichtbarkeit nur so weit geöffnet, wie die Geschwister brauchen (pub(super)); öffentliche Pfade über Wiederexport in mod.rs unverändert. Schnitt: mod (Typen, compute_section), input, bands, shapes, voids, meshes, projection, primitives, openings, query; Tests in tests, ts_faelle, dach_faelle, abzug_faelle, wand_an_dach, bench, mesh_tests. 3D: mod (Typen, parts), ceilings, columns, walls, openings, stairs, roofs, context, drawings, pick, tests. Doku (ARCHITEKTUR.md, READMEs) und Pfad-Hinweise in Kommentaren nachgeführt.
This commit is contained in:
43 files changed
+8773
-8655
No files matched your search
@@ -0,0 +1,73 @@
|
||||
//! Kontext im 3D: Gelände und importierte Netze als `RMesh`, ausgeblendete Kategorien weggelassen
|
||||
//! (`emit_context_meshes()`). Aufgerufen von `parts()` (`mod.rs`) und der Pick-Geometrie.
|
||||
|
||||
use super::*;
|
||||
|
||||
const TERRAIN_RGB: Rgb = [169.0 / 255.0, 176.0 / 255.0, 162.0 / 255.0];
|
||||
const IMPORTED_RGB: Rgb = [159.0 / 255.0, 166.0 / 255.0, 174.0 / 255.0];
|
||||
|
||||
fn indices_u32(v: &[f64]) -> Vec<u32> {
|
||||
v.iter().map(|&i| i as u32).collect()
|
||||
}
|
||||
|
||||
/// Codes ausgeblendeter Kategorien samt Kindern einer ausgeblendeten Elternebene.
|
||||
pub(super) fn hidden_category_codes(cats: &[crate::model::LayerCategory]) -> std::collections::HashSet<&str> {
|
||||
fn walk<'a>(list: &'a [crate::model::LayerCategory], parent_hidden: bool, out: &mut std::collections::HashSet<&'a str>) {
|
||||
for c in list {
|
||||
let hidden = parent_hidden || !c.visible;
|
||||
if hidden {
|
||||
out.insert(c.code.as_str());
|
||||
}
|
||||
walk(c.children.as_deref().unwrap_or(&[]), hidden, out);
|
||||
}
|
||||
}
|
||||
let mut out = std::collections::HashSet::new();
|
||||
walk(cats, false, &mut out);
|
||||
out
|
||||
}
|
||||
|
||||
/// Rohe Kontext-Meshes: Gelände-TIN und importierte Volumen (`emitMeshes`).
|
||||
pub fn emit_context_meshes(p: &Project) -> Vec<RMesh> {
|
||||
let mut out = Vec::new();
|
||||
// [T6]/[114] Ebenen-Sichtbarkeit: ein ausgeblendetes Gelände (Kategorie „02") verschwindet auch im 3D.
|
||||
let hidden = hidden_category_codes(&p.layers);
|
||||
for obj in p.context.as_deref().unwrap_or(&[]) {
|
||||
let code = match obj {
|
||||
ContextObject::TerrainMesh(m) => m.category_code.as_deref(),
|
||||
ContextObject::ImportedMesh(m) => m.category_code.as_deref(),
|
||||
_ => None,
|
||||
};
|
||||
if code.is_some_and(|c| hidden.contains(c)) {
|
||||
continue;
|
||||
}
|
||||
match obj {
|
||||
// [137] Einzeln ausgeblendetes Gelände.
|
||||
ContextObject::TerrainMesh(m) if m.hidden == Some(true) => {}
|
||||
ContextObject::ImportedMesh(m) if m.hidden == Some(true) => {}
|
||||
ContextObject::TerrainMesh(m) if m.positions.len() >= 9 && m.indices.len() >= 3 => {
|
||||
// [T6] Baugruben schneiden das Gelände; Höhen im Modellbezug (Luftbild-Farben auf das geänderte Netz übertragen).
|
||||
let (pos, idx, _) = crate::excavation::terrain_model_mesh(p, m);
|
||||
out.push(RMesh {
|
||||
crease_angle: None,
|
||||
positions: pos.into_owned(),
|
||||
indices: indices_u32(&idx),
|
||||
kind: "terrain",
|
||||
color: TERRAIN_RGB,
|
||||
vertex_colors: crate::excavation::terrain_vertex_colors(p, m),
|
||||
material_index: None,
|
||||
})
|
||||
}
|
||||
ContextObject::ImportedMesh(m) if m.positions.len() >= 9 && m.indices.len() >= 3 => out.push(RMesh {
|
||||
positions: m.positions.clone(),
|
||||
indices: indices_u32(&m.indices),
|
||||
kind: "imported",
|
||||
color: IMPORTED_RGB,
|
||||
vertex_colors: None,
|
||||
material_index: None,
|
||||
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)),
|
||||
}),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
Reference in new issue
Block a user