[181] [152] Importe als eigenständige Elemente: Klasse Pflicht, Herkunft nur Auskunft, keine Import-Liste
Gelände, Höhenlinien, Netzkörper (Nachbargebäude, IFC/OBJ/STEP/DXF-Netze), Luftbilder und Baugruben (`Project.context`) sind normale Elemente: - Modell: `categoryCode` Pflicht (String) an allen fünf Arten; `layer` (Gruppierung) und `hidden` (Einzel-Ausblenden) entfallen; neu `source` (Herkunft, ohne Wirkung). `ContextObject::category_code()`. - Kern: Plan, Schnitt, Ansicht, 3D, Pick fragen nur die Klasse ab (kein „ohne Kategorie immer sichtbar"). IFC-Gelände (IfcSite bzw. Name Gelände/Terrain) wird beim Import ein Gelände-Element (`import_context::ifc_meshes`); `mesh_view::is_terrain` entfällt, geschlossene Gelände-Netze schneidet der Schnitt als Oberkante. Importe setzen `source` statt `layer` (IFC-Klasse, DXF-Layer, STEP-Datei). - Objekt-Info: Klasse im Kopf änderbar und Farbe der Klasse auch für Gelände-/Umgebungs-Elemente, Herkunft als Auskunft; Einzel-Ausblenden-Schalter entfernt. - Panel „Gelände": Import-Liste entfernt (nur Aktionen); Elemente-Panel mit Knoten „Gelände & Umgebung". - swissBUILDINGS3D/OSM/swissALTI3D/SWISSIMAGE setzen Klasse und `source`; Dach-Trennung über den DXF-Layer beim Import. - Musterhaus komplex nachgeführt (ohne `layer`); Doku: ARCHITEKTUR Abschnitt 8 (Entwurf), Glossar, READMEs. Geprüft: cargo test im Kern (bis auf den Zeit-Wächter ansicht_gross_schnell unter Last), vitest (alle), tsc, Plan-/CLI-Goldens unverändert, e2e siteSelect/excavation/terrainHide angepasst und grün. Musterhaus komplex mit zwei Nachbarnetzen: Grundriss EG/UG 1:200, Schnitt A-A, Ansicht Süd per CLI vor/nach byte-gleich (angesehen). Nicht in der Tauri-App/auf dem Mac geprüft.
This commit is contained in:
70 files changed
+616
-710
No files matched your search
@@ -4,7 +4,7 @@ use super::*;
|
||||
use crate::mesh_view::tests::{barrel, cube, prism};
|
||||
|
||||
fn mesh(id: &str, (positions, indices): (Vec<f64>, Vec<f64>)) -> ContextObject {
|
||||
ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: format!("Netz {id}"), category_code: Some("10".into()), positions, indices, ..Default::default() })
|
||||
ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: format!("Netz {id}"), category_code: "10".into(), positions, indices, ..Default::default() })
|
||||
}
|
||||
|
||||
/// Schnitt längs x bei y = 0 ab x = −5 (u = x + 5), Blick nach +y (hinter der Ebene: y > 0).
|
||||
@@ -38,12 +38,6 @@ fn wuerfel_netz_geschnitten() {
|
||||
let vis = Visibility { has_vis: true, invisible: ["10".to_string()].into(), ..Default::default() };
|
||||
let (prims, _) = section_primitives_at(&o, false, false, &vis, 100.0, Detail::Mittel, false, &CutRules::default());
|
||||
assert!(!prims.iter().any(|q| matches!(q, Primitive::Polygon { context_object_id: Some(_), .. })));
|
||||
// Einzeln ausgeblendet ([137]): weg.
|
||||
let mut q = p.clone();
|
||||
if let Some(ContextObject::ImportedMesh(m)) = q.context.as_mut().and_then(|c| c.first_mut()) {
|
||||
m.hidden = Some(true);
|
||||
}
|
||||
assert!(mesh_cuts(&compute_section(&q, &lv(false), &[]).unwrap().unwrap()).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -168,21 +162,18 @@ fn netz_override_fuellung_und_ausblenden() {
|
||||
assert!(mesh_cuts(&compute_section(&q, &lv(false), &[]).unwrap().unwrap()).is_empty());
|
||||
}
|
||||
|
||||
/// [152] IFC-Gelände (Netz „Gelaende" der Klasse IfcSite, 1 m dicke Platte) als Geländelinie mit Erdreich statt als
|
||||
/// geschnittener Körper; ein Netz ohne Gelände-Merkmal bleibt Körper.
|
||||
/// [152]/[181] Geschlossenes Gelände-Netz (z. B. IFC-Gelände als 1 m dicke Platte, beim Import zum Gelände-Element
|
||||
/// geworden): im Schnitt Geländelinie (nur Oberkante) mit Erdreich statt geschnittener Körper; ein Netzkörper gleicher
|
||||
/// Form bleibt Körper — entscheidend ist die Elementart, nicht Name oder Herkunft.
|
||||
#[test]
|
||||
fn ifc_gelaende_als_gelaendelinie() {
|
||||
let terrain = |name: &str, layer: Option<&str>| {
|
||||
let (positions, indices) = cube(-4.0, 7.0, -3.0, 3.0, -1.0, 0.0);
|
||||
ContextObject::ImportedMesh(ImportedMesh { id: "g".into(), name: name.into(), layer: layer.map(String::from), category_code: Some("10".into()), positions, indices, ..Default::default() })
|
||||
};
|
||||
for (name, layer) in [("Gelaende", Some("IfcSite")), ("Terrain", None), ("Site (3)", Some("IfcSite")), ("Gelände 1", Some("IfcGeographicElement"))] {
|
||||
let p = with(vec![terrain(name, layer), mesh("w", cube(1.0, 3.0, -1.0, 2.0, 0.0, 2.5))]);
|
||||
let ContextObject::ImportedMesh(g) = &p.context.as_ref().unwrap()[0] else { unreachable!() };
|
||||
assert!(crate::mesh_view::is_terrain(g), "{name}");
|
||||
fn geschlossenes_gelaende_als_gelaendelinie() {
|
||||
let (positions, indices) = cube(-4.0, 7.0, -3.0, 3.0, -1.0, 0.0);
|
||||
let terrain = ContextObject::TerrainMesh(TerrainMesh { id: "g".into(), name: "Site".into(), category_code: "02".into(), positions: positions.clone(), indices: indices.clone(), ..Default::default() });
|
||||
{
|
||||
let p = with(vec![terrain, mesh("w", cube(1.0, 3.0, -1.0, 2.0, 0.0, 2.5))]);
|
||||
let o = compute_section(&p, &lv(false), &[]).unwrap().unwrap();
|
||||
let c = mesh_cuts(&o);
|
||||
assert_eq!(c.len(), 1, "nur der Würfel als Schnittfläche ({name})");
|
||||
assert_eq!(c.len(), 1, "nur der Würfel als Schnittfläche");
|
||||
assert_eq!(c[0].source_id.as_deref(), Some("w"));
|
||||
// Geländelinie = Oberkante z = 0 über die ganze Breite (u 1 … 12), kein Unterrand.
|
||||
let len: f64 = o.profiles.iter().flat_map(|pr| pr.pts.windows(2)).map(|w| (w[1][0] - w[0][0]).hypot(w[1][1] - w[0][1])).sum();
|
||||
@@ -195,8 +186,8 @@ fn ifc_gelaende_als_gelaendelinie() {
|
||||
let (prims, _) = section_primitives_at(&o, false, false, &Visibility::default(), 100.0, Detail::Mittel, false, &CutRules::default());
|
||||
assert!(prims.iter().any(|q| matches!(q, Primitive::Line { cls, .. } if cls == "section-terrain")));
|
||||
}
|
||||
// Gewöhnliches Netz gleicher Form: Körper.
|
||||
let p = with(vec![terrain("Bodenplatte", Some("IfcSlab"))]);
|
||||
// Netzkörper gleicher Form (auch mit Namen „Gelände"): Körper.
|
||||
let p = with(vec![ContextObject::ImportedMesh(ImportedMesh { id: "g".into(), name: "Gelände".into(), category_code: "10".into(), positions, indices, ..Default::default() })]);
|
||||
let o = compute_section(&p, &lv(false), &[]).unwrap().unwrap();
|
||||
assert_eq!(mesh_cuts(&o).len(), 1);
|
||||
assert!(o.profiles.is_empty());
|
||||
|
||||
@@ -110,7 +110,7 @@ pub(super) fn append_mesh_sections(cuts: &mut Vec<Cut>, lines: &mut Vec<(usize,
|
||||
c.fill = Some(BODY_FILL.into());
|
||||
c.nse = nse;
|
||||
c.source_id = Some(m.mesh.id.clone());
|
||||
c.category = m.mesh.category_code.clone();
|
||||
c.category = Some(m.mesh.category_code.clone());
|
||||
cuts.push(c);
|
||||
}
|
||||
lines.extend(open.into_iter().map(|l| (k, l)));
|
||||
@@ -190,10 +190,10 @@ pub(super) fn clip_line_to_u(pts: &[[f64; 2]], lo: f64, hi: f64) -> Vec<Vec<[f64
|
||||
}
|
||||
|
||||
/// `appendTerrainProfiles`.
|
||||
/// [152] Dazu IFC-Gelände-Netze (`mesh_view::is_terrain`): Oberkante ihres Ebenenschnitts (offene Züge ganz).
|
||||
pub(super) fn append_terrain_profiles(out: &mut Output, p: &Project, base: (f64, f64), u: (f64, f64), terrain_meshes: &[crate::mesh_view::MeshRef]) {
|
||||
/// [152]/[181] Geschlossene Gelände-Netze (z. B. IFC-Gelände als Platte): von ihren Schnittringen nur die Oberkante.
|
||||
pub(super) fn append_terrain_profiles(out: &mut Output, p: &Project, base: (f64, f64), u: (f64, f64)) {
|
||||
let terrains: Vec<&TerrainMesh> = p.context.as_deref().unwrap_or(&[]).iter().filter_map(|c| if let ContextObject::TerrainMesh(t) = c { Some(t) } else { None }).collect();
|
||||
if terrains.is_empty() && terrain_meshes.is_empty() {
|
||||
if terrains.is_empty() {
|
||||
return;
|
||||
}
|
||||
let (mut lo, mut hi) = (f64::INFINITY, f64::NEG_INFINITY);
|
||||
@@ -209,55 +209,54 @@ pub(super) fn append_terrain_profiles(out: &mut Output, p: &Project, base: (f64,
|
||||
}
|
||||
let range = lo.is_finite().then_some((lo, hi));
|
||||
for t in terrains {
|
||||
// [137] Einzeln ausgeblendetes Gelände.
|
||||
if t.positions.len() < 9 || t.hidden == Some(true) {
|
||||
if t.positions.len() < 9 {
|
||||
continue;
|
||||
}
|
||||
out.terrain_id.get_or_insert_with(|| t.id.clone());
|
||||
// [T6] Gelände samt Baugruben, Höhen im Modellbezug; das gewachsene Terrain gestrichelt dazu.
|
||||
let st = crate::excavation::site_terrain(p, t);
|
||||
let mut meshes = vec![(st.current().to_flat(-st.datum), false)];
|
||||
let mut meshes: Vec<((Vec<f64>, Vec<f64>), bool)> = vec![(st.current().to_flat(-st.datum), false)];
|
||||
if st.modified.is_some() {
|
||||
meshes.push((st.orig.to_flat(-st.datum), true));
|
||||
}
|
||||
// [152]/[181] Geschlossenes Gelände-Netz (z. B. IFC-Gelände als Platte): das rohe Netz schneiden und von den
|
||||
// Schnittringen nur die Oberkante nehmen (die Fläche als TIN gelesen hätte Ober- und Unterseite).
|
||||
if st.modified.is_none() && is_closed(&t.indices) {
|
||||
meshes = vec![((t.positions.chunks(3).flat_map(|q| [q[0], q[1], q[2] - st.datum]).collect(), t.indices.clone()), false)];
|
||||
}
|
||||
for ((pos, idx), natural) in meshes {
|
||||
let (_, lines) = cut_mesh(&pos, &idx, base, u);
|
||||
let (rings, mut lines) = cut_mesh(&pos, &idx, base, u);
|
||||
for poly in rings_to_polygons(&rings) {
|
||||
lines.extend(upper_edge(&poly[0]));
|
||||
}
|
||||
for line in lines {
|
||||
let parts = match range {
|
||||
Some((lo, hi)) => clip_line_to_u(&line, lo - TERRAIN_MARGIN, hi + TERRAIN_MARGIN),
|
||||
None => vec![line],
|
||||
};
|
||||
for pts in parts {
|
||||
out.profiles.push(Profile { category: t.category_code.clone(), pts, natural });
|
||||
out.profiles.push(Profile { category: Some(t.category_code.clone()), pts, natural });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for m in terrain_meshes {
|
||||
let (lo, hi) = mesh_depth_range(m, base, u);
|
||||
if !(lo < 0.0 && hi > 0.0) {
|
||||
continue;
|
||||
}
|
||||
let (rings, open) = crate::mesh_view::cut(m, &[0.0, base.0, base.1, u.0, u.1]);
|
||||
let mut lines = open;
|
||||
for poly in rings_to_polygons(&rings) {
|
||||
lines.extend(upper_edge(&poly[0]));
|
||||
}
|
||||
if lines.is_empty() {
|
||||
continue;
|
||||
}
|
||||
out.terrain_id.get_or_insert_with(|| m.mesh.id.clone());
|
||||
for line in lines {
|
||||
let parts = match range {
|
||||
Some((lo, hi)) => clip_line_to_u(&line, lo - TERRAIN_MARGIN, hi + TERRAIN_MARGIN),
|
||||
None => vec![line],
|
||||
};
|
||||
for pts in parts {
|
||||
out.profiles.push(Profile { category: m.mesh.category_code.clone(), pts, natural: false });
|
||||
}
|
||||
append_earth(out, p, base, u);
|
||||
}
|
||||
|
||||
/// Geschlossenes Dreiecksnetz: jede Kante gehört zu genau zwei Dreiecken.
|
||||
fn is_closed(indices: &[f64]) -> bool {
|
||||
if indices.len() < 12 {
|
||||
return false;
|
||||
}
|
||||
let mut edges: std::collections::HashMap<(u32, u32), u32> = std::collections::HashMap::new();
|
||||
for t in indices.chunks_exact(3) {
|
||||
let v = [t[0] as u32, t[1] as u32, t[2] as u32];
|
||||
for k in 0..3 {
|
||||
let (a, b) = (v[k], v[(k + 1) % 3]);
|
||||
*edges.entry((a.min(b), a.max(b))).or_default() += 1;
|
||||
}
|
||||
}
|
||||
append_earth(out, p, base, u);
|
||||
edges.values().all(|&n| n == 2)
|
||||
}
|
||||
|
||||
/// Tiefe des Erdreich-Bands unter der Geländelinie (m), wenn das Gelände keine `earthDepth` trägt.
|
||||
|
||||
@@ -289,7 +289,7 @@ impl CutRules {
|
||||
pub fn of(p: &Project, out: &Output, v: RuleView) -> CutRules {
|
||||
let ts = crate::excavation::terrains(p);
|
||||
let t = out.terrain_id.as_deref().and_then(|id| ts.iter().find(|t| t.id == id)).or(ts.first());
|
||||
let terrain = if out.profiles.is_empty() && out.earth.is_empty() { None } else { t.and_then(|t| super::overrides::terrain_override(p, v, t.category_code.as_deref(), &t.name)) };
|
||||
let terrain = if out.profiles.is_empty() && out.earth.is_empty() { None } else { t.and_then(|t| super::overrides::terrain_override(p, v, Some(&t.category_code), &t.name)) };
|
||||
let terrain_dash = terrain.as_ref().and_then(|(a, _)| super::overrides::linetype_dash(p, a.linetype_id.as_deref()));
|
||||
let terrain_hatch = terrain.as_ref().and_then(|(_, l)| l.hatch.as_deref()).filter(|h| !matches!(*h, "none" | "material")).and_then(|id| resolve_hatch(p, id, None, None, None));
|
||||
let mut ov = cut_overrides(p, &out.cuts, v);
|
||||
@@ -588,9 +588,9 @@ fn compute_plane(p: &Project, level: &LevelSpec, bodies: &[BodyMesh], strip: Opt
|
||||
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);
|
||||
// [152] Importierte Netze: geschnitten (Flächen bzw. offene Linien) und in der Projektion.
|
||||
// IFC-Gelände ([152]) wird Geländelinie (`append_terrain_profiles`), kein Körper.
|
||||
let (terrain_meshes, meshes): (Vec<_>, Vec<_>) = crate::mesh_view::meshes(p).into_iter().partition(|m| crate::mesh_view::is_terrain(m.mesh));
|
||||
// [152] Netzkörper: geschnitten (Flächen bzw. offene Linien) und in der Projektion. Gelände ist ein eigenes
|
||||
// Element (`terrainMesh`, auch IFC-Gelände seit dem Import, [181]) und wird Geländelinie (`append_terrain_profiles`).
|
||||
let meshes = crate::mesh_view::meshes(p);
|
||||
let mut mesh_lines = Vec::new();
|
||||
append_mesh_sections(&mut cuts, &mut mesh_lines, &meshes, base, u);
|
||||
// [176] Segment eines geknickten Schnitts: Schnittflächen auf den Streifen (sie verdecken nur dort).
|
||||
@@ -602,9 +602,9 @@ fn compute_plane(p: &Project, level: &LevelSpec, bodies: &[BodyMesh], strip: Opt
|
||||
// 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, &meshes, &cuts, level.hidden_lines, level.depth, strip.map_or(&[][..], |s| &s.half[..]));
|
||||
shaped_projection(&mut visible, p, &walls_r, &plane);
|
||||
let meshes = meshes.iter().map(|m| MeshMeta { id: m.mesh.id.clone(), name: m.mesh.name.clone(), category: m.mesh.category_code.clone() }).collect();
|
||||
let meshes = meshes.iter().map(|m| MeshMeta { id: m.mesh.id.clone(), name: m.mesh.name.clone(), category: Some(m.mesh.category_code.clone()) }).collect();
|
||||
let mut out = Output { cuts, visible, hidden, profiles: Vec::new(), earth: Vec::new(), terrain_id: None, meshes, mesh_lines };
|
||||
append_terrain_profiles(&mut out, p, base, u, &terrain_meshes);
|
||||
append_terrain_profiles(&mut out, p, base, u);
|
||||
if let Some(s) = strip {
|
||||
unfold::clip_output(&mut out, s);
|
||||
}
|
||||
|
||||
@@ -810,7 +810,7 @@ fn gelaende_mit_baugrube_im_schnitt() {
|
||||
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: Some("02".into()),
|
||||
category_code: "02".into(),
|
||||
..Default::default()
|
||||
};
|
||||
let pit = Excavation {
|
||||
|
||||
Reference in new issue
Block a user