[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
@@ -480,7 +480,6 @@ pub fn terrain_from_contours_with(contours: &[Value], id: &str, o: crate::terrai
|
||||
("id", s(id)),
|
||||
("type", s("terrainMesh")),
|
||||
("name", s("Gelände")),
|
||||
("layer", s("Terrain")),
|
||||
("categoryCode", s("02")),
|
||||
("positions", Value::Array(pos.into_iter().map(js_num).collect())),
|
||||
("indices", Value::Array(idx.into_iter().map(Value::from).collect())),
|
||||
@@ -606,7 +605,6 @@ fn excavation_ops(root: &Map<String, Value>, p: &Project, v: &Value, ctx: &Ctx,
|
||||
("id", s(&ids.next("excavation"))),
|
||||
("type", s("excavation")),
|
||||
("name", s(&format!("Baugrube {}", n + 1))),
|
||||
("layer", s("Terrain")),
|
||||
("categoryCode", s(EXCAVATION_CATEGORY)),
|
||||
("outline", pvs(&pts)),
|
||||
("bottom", js_num(check.bottom)),
|
||||
|
||||
@@ -141,13 +141,24 @@ pub fn color_of(v: Option<&Value>) -> Option<Vec<f64>> {
|
||||
v?.as_array().map(|a| a.iter().map(|x| x.as_f64().unwrap_or(f64::NAN)).collect())
|
||||
}
|
||||
|
||||
fn mesh_value(id: String, name: String, layer: &str, color: Option<String>, extra: Option<(&str, &str)>, positions: Vec<Value>, indices: Vec<Value>) -> Value {
|
||||
/// Netzkörper (`importedMesh`, Klasse „10 Situation") mit Herkunft `source` (nur Auskunft, [181]).
|
||||
fn mesh_value(id: String, name: String, source: &str, color: Option<String>, extra: Option<(&str, &str)>, positions: Vec<Value>, indices: Vec<Value>) -> Value {
|
||||
element_value("importedMesh", GENERIC_IMPORT_CODE, id, name, source, color, extra, positions, indices)
|
||||
}
|
||||
|
||||
/// [181] Klasse der importierten Gelände-Elemente (wie „Gelände erzeugen“).
|
||||
pub const TERRAIN_CODE: &str = "02";
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn element_value(kind: &str, code: &str, id: String, name: String, source: &str, color: Option<String>, extra: Option<(&str, &str)>, positions: Vec<Value>, indices: Vec<Value>) -> Value {
|
||||
let mut o = Map::new();
|
||||
o.insert("id".into(), id.into());
|
||||
o.insert("type".into(), "importedMesh".into());
|
||||
o.insert("type".into(), kind.into());
|
||||
o.insert("name".into(), name.into());
|
||||
o.insert("layer".into(), layer.into());
|
||||
o.insert("categoryCode".into(), GENERIC_IMPORT_CODE.into());
|
||||
o.insert("categoryCode".into(), code.into());
|
||||
if !source.is_empty() {
|
||||
o.insert("source".into(), source.into());
|
||||
}
|
||||
if let Some(c) = color {
|
||||
o.insert("color".into(), c.into());
|
||||
}
|
||||
@@ -289,11 +300,34 @@ pub fn classification_suffix(list: &[Value]) -> String {
|
||||
format!(" [{}]", parts.join(" "))
|
||||
}
|
||||
|
||||
/// Gruppierung: `"product"`, `"class"` oder `"auto"` (nach [`MAX_SINGLE`]).
|
||||
/// [152]/[181] Gelände in einer IFC-Datei: Klasse `IfcSite` oder Name mit „Gelände"/„Terrain" (z. B. ein
|
||||
/// `IfcGeographicElement` „Terrain"). Wird beim Import ein Gelände-Element; danach zählt nur die Elementart.
|
||||
pub fn is_ifc_terrain(class: &str, name: Option<&str>) -> bool {
|
||||
let name = name.unwrap_or("").to_lowercase();
|
||||
class.eq_ignore_ascii_case("IfcSite") || name.contains("ifcsite") || ["gelände", "gelaende", "terrain"].iter().any(|k| name.contains(k))
|
||||
}
|
||||
|
||||
/// Gruppierung: `"product"`, `"class"` oder `"auto"` (nach [`MAX_SINGLE`]). Gelände ([`is_ifc_terrain`]) wird je
|
||||
/// Bauteil ein Gelände-Element (`terrainMesh`, Klasse „02"), alles andere Netzkörper.
|
||||
pub fn ifc_meshes(products: &[IfcProduct], file_name: &str, group: &str, shift: [f64; 2], now: f64) -> Vec<Value> {
|
||||
let base = base_name(file_name, "IFC");
|
||||
let stamp = stamp36(now);
|
||||
let d = [shift[0], shift[1], 0.0];
|
||||
let (terrain, rest): (Vec<&IfcProduct>, Vec<&IfcProduct>) = products.iter().partition(|p| is_ifc_terrain(&p.ifc_class, p.name.as_deref()));
|
||||
let mut out: Vec<Value> = terrain
|
||||
.iter()
|
||||
.map(|p| {
|
||||
let (pos, idx) = arrays(std::iter::once((p.positions, p.indices)), d);
|
||||
let gid = (!p.global_id.is_empty()).then_some(("ifcGlobalId", p.global_id.as_str()));
|
||||
let name = p.name.as_deref().filter(|n| !n.is_empty()).unwrap_or("Gelände").to_string();
|
||||
element_value("terrainMesh", TERRAIN_CODE, format!("imported-ifc-{stamp}-{}", next_seq()), name, &format!("IFC {}", p.ifc_class), None, gid, pos, idx)
|
||||
})
|
||||
.collect();
|
||||
out.extend(ifc_body_meshes(&rest, &base, group, d, &stamp));
|
||||
out
|
||||
}
|
||||
|
||||
fn ifc_body_meshes(products: &[&IfcProduct], base: &str, group: &str, d: [f64; 3], stamp: &str) -> Vec<Value> {
|
||||
let per_product = group == "product" || (group != "class" && products.len() <= MAX_SINGLE);
|
||||
if per_product {
|
||||
return products
|
||||
@@ -310,7 +344,7 @@ pub fn ifc_meshes(products: &[IfcProduct], file_name: &str, group: &str, shift:
|
||||
mesh_value(
|
||||
format!("imported-ifc-{stamp}-{}", next_seq()),
|
||||
label + &classification_suffix(&p.classifications),
|
||||
&p.ifc_class,
|
||||
&format!("IFC {}", p.ifc_class),
|
||||
color_hex(p.color.as_deref()),
|
||||
gid,
|
||||
pos,
|
||||
@@ -327,7 +361,7 @@ pub fn ifc_meshes(products: &[IfcProduct], file_name: &str, group: &str, shift:
|
||||
let color = if colors.len() == 1 { colors.into_iter().next().filter(|c| !c.is_empty()) } else { None };
|
||||
let label = [first.storey.as_deref(), Some(first.ifc_class.as_str())].into_iter().flatten().filter(|s| !s.is_empty()).collect::<Vec<_>>().join(" ");
|
||||
let (pos, idx) = arrays(g.iter().map(|&i| (products[i].positions, products[i].indices)), d);
|
||||
mesh_value(format!("imported-ifc-{stamp}-{}", next_seq()), format!("{base}: {label} ({})", g.len()), &first.ifc_class, color, None, pos, idx)
|
||||
mesh_value(format!("imported-ifc-{stamp}-{}", next_seq()), format!("{base}: {label} ({})", g.len()), &format!("IFC {}", first.ifc_class), color, None, pos, idx)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
@@ -478,7 +512,7 @@ pub fn mesh_shift(objects: &[MeshObject], placement: &str, origin: Option<[f64;
|
||||
}
|
||||
}
|
||||
|
||||
/// Objekte → Kontext-Meshes (`layer` = Gruppe, sonst Dateiname); `group`: `"object"`, `"merge"`, `"auto"`.
|
||||
/// Objekte → Netzkörper (Herkunft `source` = Gruppe, sonst Dateiname); `group`: `"object"`, `"merge"`, `"auto"`.
|
||||
pub fn mesh_objects_to_meshes(objects: &[MeshObject], file_name: &str, placement: &str, origin: Option<[f64; 2]>, group: &str, now: f64) -> Vec<Value> {
|
||||
let base = base_name(file_name, "Mesh");
|
||||
let d = mesh_shift(objects, placement, origin);
|
||||
@@ -553,6 +587,7 @@ pub fn step_meshes(bodies: &[(Vec<f32>, Vec<f64>)], file_name: &str, now: f64) -
|
||||
o.insert("type".into(), "importedMesh".into());
|
||||
o.insert("name".into(), if n > 1 { format!("{base} ({}/{n})", i + 1) } else { base.clone() }.into());
|
||||
o.insert("categoryCode".into(), GENERIC_IMPORT_CODE.into());
|
||||
o.insert("source".into(), format!("STEP {file_name}").into());
|
||||
o.insert("positions".into(), Value::Array(pos.iter().map(|&x| js_num(x.to_string().parse().unwrap_or(f64::from(x)))).collect()));
|
||||
o.insert("indices".into(), Value::Array(idx.iter().map(|&k| js_num(k)).collect()));
|
||||
Value::Object(o)
|
||||
@@ -583,6 +618,7 @@ mod step_tests {
|
||||
assert_eq!(m[1]["name"], "haus (2/2)");
|
||||
assert_eq!(m[0]["categoryCode"], "10");
|
||||
assert!(m[0].get("layer").is_none());
|
||||
assert_eq!(m[0]["source"], "STEP haus.stp");
|
||||
assert_eq!(m[0]["positions"][0], json!(0.1));
|
||||
assert_eq!(m[1]["indices"], json!([0, 1, 2]));
|
||||
assert!(m[0]["id"].as_str().unwrap().starts_with("imported-step-"));
|
||||
|
||||
@@ -586,7 +586,7 @@ pub fn summary_json(d: &DrawingImport) -> Value {
|
||||
Value::Object(m)
|
||||
}
|
||||
|
||||
/// Meshes als Kontext-Objekte (`ImportedMesh`, Kategorie „10 Situation"; Layer „0" ohne `layer`).
|
||||
/// Meshes als Netzkörper (`ImportedMesh`, Klasse „10 Situation"; Herkunft `source` = DXF-Layer ausser „0").
|
||||
pub fn mesh_values(d: &DrawingImport) -> Vec<Value> {
|
||||
d.meshes
|
||||
.iter()
|
||||
@@ -596,8 +596,9 @@ pub fn mesh_values(d: &DrawingImport) -> Vec<Value> {
|
||||
o.insert("type".into(), "importedMesh".into());
|
||||
o.insert("name".into(), m.name.clone().into());
|
||||
o.insert("categoryCode".into(), GENERIC_IMPORT_CODE.into());
|
||||
if m.layer != "0" {
|
||||
o.insert("layer".into(), m.layer.clone().into());
|
||||
// [181] Herkunft nur als Auskunft (DXF-Layer), ohne Wirkung.
|
||||
if m.layer != "0" && !m.layer.is_empty() {
|
||||
o.insert("source".into(), format!("DXF-Layer {}", m.layer).into());
|
||||
}
|
||||
o.insert("positions".into(), Value::Array(m.positions.iter().map(|&x| js_num(x)).collect()));
|
||||
o.insert("indices".into(), Value::Array(m.indices.iter().map(|&x| js_num(x)).collect()));
|
||||
|
||||
@@ -90,6 +90,7 @@ fn ops_neue_zeichnung_mit_layer_kategorien() {
|
||||
assert_eq!(drawings[4]["geom"], json!({"shape": "text", "at": {"x": 5, "y": 6}, "text": "Wohnen", "height": 0.25, "angle": 0}));
|
||||
assert_eq!(ops[2]["collection"], json!("context"));
|
||||
assert!(ops[2]["items"][0].get("layer").is_none());
|
||||
assert_eq!(ops[2]["items"][0]["categoryCode"], json!("10"));
|
||||
// Kategorien: „Import x" mit A, B; dazu „05 Kontext" mit „10 Situation".
|
||||
let layers = &ops[3]["value"];
|
||||
assert_eq!(layers[2]["name"], json!("Import x"));
|
||||
@@ -182,7 +183,9 @@ fn ifc_meshes_farbe_und_globalid() {
|
||||
assert_eq!(m[0]["color"], json!("#ff8000"));
|
||||
assert_eq!(m[0]["ifcGlobalId"], json!("2O2Fr$t4X7Zf8NOew3FLOH"));
|
||||
assert_eq!(m[0]["name"], json!("EG: Wand"));
|
||||
assert_eq!(m[0]["layer"], json!("IfcWall"));
|
||||
assert!(m[0].get("layer").is_none());
|
||||
assert_eq!(m[0]["source"], json!("IFC IfcWall"));
|
||||
assert_eq!(m[0]["type"], json!("importedMesh"));
|
||||
let n = ifc_meshes(&[product(None, "")], "x.ifc", "product", [0.0, 0.0], 0.0);
|
||||
assert!(n[0].get("color").is_none() && n[0].get("ifcGlobalId").is_none());
|
||||
// Zusammengelegt: gemeinsame Farbe nur, wenn alle gleich; Indizes versetzt.
|
||||
@@ -194,6 +197,18 @@ fn ifc_meshes_farbe_und_globalid() {
|
||||
assert_eq!(g[0]["positions"][0], json!(10));
|
||||
let h = ifc_meshes(&[product(red(), "a"), product(Some(vec![0.0, 0.0, 1.0, 1.0]), "b")], "x.ifc", "class", [0.0, 0.0], 0.0);
|
||||
assert!(h[0].get("color").is_none());
|
||||
// [181] Gelände (IfcSite, IfcGeographicElement „Terrain") wird beim Import ein Gelände-Element (Klasse „02"),
|
||||
// unabhängig davon, ob je Bauteil oder je Klasse zusammengelegt wird.
|
||||
let site = |class: &str, name: &str| IfcProduct { ifc_class: class.into(), name: Some(name.into()), ..product(None, "s") };
|
||||
for group in ["product", "class"] {
|
||||
let t = ifc_meshes(&[site("IfcSite", "Site"), site("IfcGeographicElement", "Gelände Süd"), product(None, "w")], "x.ifc", group, [0.0, 0.0], 0.0);
|
||||
let types: Vec<&str> = t.iter().map(|m| m["type"].as_str().unwrap()).collect();
|
||||
assert_eq!(types.iter().filter(|&&k| k == "terrainMesh").count(), 2, "{group}: {types:?}");
|
||||
let g = t.iter().find(|m| m["type"] == "terrainMesh").unwrap();
|
||||
assert_eq!(g["categoryCode"], json!("02"));
|
||||
assert!(g["source"].as_str().unwrap().starts_with("IFC "));
|
||||
assert!(t.iter().any(|m| m["type"] == "importedMesh" && m["categoryCode"] == "10"));
|
||||
}
|
||||
assert_eq!(classification_suffix(&[]), "");
|
||||
assert_eq!(classification_suffix(&[json!({"system": "", "code": "214", "name": null})]), " [214]");
|
||||
}
|
||||
@@ -216,7 +231,8 @@ fn meshes_mitte_und_gruppen() {
|
||||
let obj = |g: &str, x: f64| MeshObject { name: String::new(), group: g.into(), color: Some(vec![1.0, 0.5, 0.0, 1.0]), positions: vec![x, 0.0, 1.0, x + 2.0, 2.0, 3.0], indices: vec![0.0, 1.0, 0.0] };
|
||||
let m = mesh_objects_to_meshes(&[obj("", 0.0), obj("g", 10.0)], "haus.obj", "center", None, "auto", 0.0);
|
||||
assert_eq!(m[0]["name"], json!("haus 1"));
|
||||
assert_eq!(m[0]["layer"], json!("haus"));
|
||||
assert!(m[0].get("layer").is_none());
|
||||
assert_eq!(m[0]["source"], json!("haus"));
|
||||
assert_eq!(m[0]["color"], json!("#ff8000"));
|
||||
assert_eq!(m[0]["positions"], json!([-6, -1, 0, -4, 1, 2]));
|
||||
let m = mesh_objects_to_meshes(&[obj("g", 0.0), obj("g", 10.0)], "haus.obj", "original", None, "merge", 0.0);
|
||||
|
||||
@@ -143,13 +143,13 @@ pub fn info(m: &ImportedMesh) -> Option<Rc<MeshInfo>> {
|
||||
i
|
||||
}
|
||||
|
||||
/// Die gezeichneten Netze: nicht einzeln ausgeblendet ([137]), mit mindestens einem gültigen Dreieck.
|
||||
/// Die gezeichneten Netze: mit mindestens einem gültigen Dreieck.
|
||||
/// Kategorie-Sichtbarkeit prüft der Aufrufer (UI-Zustand).
|
||||
pub fn meshes(p: &Project) -> Vec<MeshRef<'_>> {
|
||||
let mut out = Vec::new();
|
||||
for (index, obj) in p.context.as_deref().unwrap_or(&[]).iter().enumerate() {
|
||||
let ContextObject::ImportedMesh(m) = obj else { continue };
|
||||
if m.hidden == Some(true) || m.positions.len() < 9 || m.indices.len() < 3 {
|
||||
if m.positions.len() < 9 || m.indices.len() < 3 {
|
||||
continue;
|
||||
}
|
||||
if let Some(info) = info(m) {
|
||||
@@ -159,13 +159,6 @@ pub fn meshes(p: &Project) -> Vec<MeshRef<'_>> {
|
||||
out
|
||||
}
|
||||
|
||||
/// [152] Gelände aus einem IFC-Import (Klasse `IfcSite` im Layer bzw. Namen, oder Name mit „Gelände"/„Terrain",
|
||||
/// z. B. ein `IfcGeographicElement` „Terrain"): im Schnitt Geländelinie statt Körper.
|
||||
pub fn is_terrain(m: &ImportedMesh) -> bool {
|
||||
let (name, layer) = (m.name.to_lowercase(), m.layer.as_deref().unwrap_or("").to_lowercase());
|
||||
layer == "ifcsite" || name.contains("ifcsite") || ["gelände", "gelaende", "terrain"].iter().any(|k| name.contains(k))
|
||||
}
|
||||
|
||||
/// Linienzüge ungerichtet aneinanderhängen (Netze mit wechselnder Orientierung): was sich schliesst,
|
||||
/// wird Ring, der Rest bleibt offen. Endpunkte gleich auf 1e-6 (wie `mesh_section`).
|
||||
pub fn close_chains(lines: Vec<Vec<[f64; 2]>>) -> (Vec<Vec<[f64; 2]>>, Vec<Vec<[f64; 2]>>) {
|
||||
|
||||
@@ -5764,9 +5764,9 @@ pub struct Project {
|
||||
pub rooms: Option<Vec<Room>>,
|
||||
/// Freie 2D-Zeichengeometrie (Line/Polyline/Rect/Circle/Arc/Text).
|
||||
pub drawings2d: Vec<Drawing2D>,
|
||||
/// Kontext-Schicht: importierte/abgeleitete „dumme" Geometrie (Meshes,
|
||||
/// Konturen, Gelände-TIN) — NICHT semantisch. Optional, damit bestehende
|
||||
/// Projekte/Tests ohne `context` gültig bleiben (Default: leer behandeln).
|
||||
/// [181] Gelände- und Umgebungs-Elemente (Gelände, Höhenlinien, Netzkörper wie Nachbargebäude, Luftbilder,
|
||||
/// Baugruben): normale Elemente mit Klasse (`categoryCode`), unabhängig von ihrer Herkunft; s.
|
||||
/// {@link ContextObject}. Fehlt das Feld, gilt die Liste als leer.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub context: Option<Vec<ContextObject>>,
|
||||
@@ -6104,17 +6104,15 @@ pub struct SequenceRule {
|
||||
pub struct ImportedMesh {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
/// Ursprünglicher DXF-Layer-Name (für spätere Kategorisierung).
|
||||
/// [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und
|
||||
/// Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`).
|
||||
#[serde(rename = "categoryCode")]
|
||||
pub category_code: String,
|
||||
/// [181] Herkunft (z. B. „swissBUILDINGS3D", „IFC IfcSite", „DXF-Layer Haus") — nur Auskunft in der
|
||||
/// Objekt-Info, ohne jede Wirkung auf Darstellung oder Sichtbarkeit (die steuert allein `categoryCode`).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub layer: Option<String>,
|
||||
/// Grafik-Kategorie-Code (s. {@link LayerCategory}, `model/contextCategories.ts`)
|
||||
/// — steuert Sichtbarkeit/Grau/Sperren wie bei jedem anderen Bauteil (Ebenen-
|
||||
/// Panel). Fehlt er (ältere Importe vor dieser Erweiterung), bleibt das Objekt
|
||||
/// IMMER sichtbar (Rückwärtskompatibilität), s. `plan/context.rs` im Kern.
|
||||
#[serde(rename = "categoryCode", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub category_code: Option<String>,
|
||||
pub source: Option<String>,
|
||||
/// Farbe aus der Quelldatei (`#rrggbb`, z. B. IFC-Oberflächenstil/Material); fehlt sie, gilt die Kontext-Grundfarbe.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
@@ -6131,11 +6129,6 @@ pub struct ImportedMesh {
|
||||
#[serde(rename = "creaseAngle", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub crease_angle: Option<f64>,
|
||||
/// [137] Nur dieses Netz ausblenden (Grundriss, Schnitt, Ansicht, 3D, Pick); die Kategorie bleibt
|
||||
/// davon unberührt. Fehlt/false = sichtbar.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub hidden: Option<bool>,
|
||||
pub positions: Vec<f64>,
|
||||
pub indices: Vec<f64>,
|
||||
#[serde(flatten)]
|
||||
@@ -6204,14 +6197,15 @@ pub struct Contour {
|
||||
pub struct ContourSet {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
/// Ursprünglicher DXF-Layer-Name (für spätere Kategorisierung).
|
||||
/// [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und
|
||||
/// Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`).
|
||||
#[serde(rename = "categoryCode")]
|
||||
pub category_code: String,
|
||||
/// [181] Herkunft (z. B. „swissBUILDINGS3D", „IFC IfcSite", „DXF-Layer Haus") — nur Auskunft in der
|
||||
/// Objekt-Info, ohne jede Wirkung auf Darstellung oder Sichtbarkeit (die steuert allein `categoryCode`).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub layer: Option<String>,
|
||||
/// Grafik-Kategorie-Code, s. {@link ImportedMesh.categoryCode}.
|
||||
#[serde(rename = "categoryCode", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub category_code: Option<String>,
|
||||
pub source: Option<String>,
|
||||
pub contours: Vec<Contour>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
@@ -6220,20 +6214,22 @@ pub struct ContourSet {
|
||||
|
||||
/// Ein TIN-Geländemodell, abgeleitet aus Konturen (Delaunay über (x,y), Z aus der
|
||||
/// jeweiligen Kontur-Höhe). `positions` = flaches (x,y,z…)-Array in Metern,
|
||||
/// `indices` = Dreiecks-Indizes. Gelände ist NICHT semantisch (Kontext-Schicht).
|
||||
/// `indices` = Dreiecks-Indizes. Gelände-Element ([181]): aus Höhenlinien erzeugt oder importiert (swissALTI3D,
|
||||
/// IFC-Gelände), danach unabhängig von der Quelle.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct TerrainMesh {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
/// Ebenen-/Gruppierungsname (SitePanel), z. B. „Terrain". Optional.
|
||||
/// [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und
|
||||
/// Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`).
|
||||
#[serde(rename = "categoryCode")]
|
||||
pub category_code: String,
|
||||
/// [181] Herkunft (z. B. „swissBUILDINGS3D", „IFC IfcSite", „DXF-Layer Haus") — nur Auskunft in der
|
||||
/// Objekt-Info, ohne jede Wirkung auf Darstellung oder Sichtbarkeit (die steuert allein `categoryCode`).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub layer: Option<String>,
|
||||
/// Grafik-Kategorie-Code, s. {@link ImportedMesh.categoryCode}.
|
||||
#[serde(rename = "categoryCode", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub category_code: Option<String>,
|
||||
pub source: Option<String>,
|
||||
pub positions: Vec<f64>,
|
||||
pub indices: Vec<f64>,
|
||||
/// Optionale Pro-Vertex-Albedo (flach `[r,g,b, …]`, 0..1) — ein Wert je
|
||||
@@ -6265,11 +6261,6 @@ pub struct TerrainMesh {
|
||||
#[serde(rename = "sourceId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub source_id: Option<String>,
|
||||
/// [137] Nur dieses Netz ausblenden (Grundriss, Schnitt, Ansicht, 3D, Pick); die Kategorie bleibt
|
||||
/// davon unberührt. Fehlt/false = sichtbar.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub hidden: Option<bool>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -6285,12 +6276,10 @@ pub struct TerrainMesh {
|
||||
pub struct Excavation {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub layer: Option<String>,
|
||||
#[serde(rename = "categoryCode", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub category_code: Option<String>,
|
||||
/// [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und
|
||||
/// Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`).
|
||||
#[serde(rename = "categoryCode")]
|
||||
pub category_code: String,
|
||||
pub outline: Vec<Vec2>,
|
||||
pub bottom: f64,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
@@ -6356,14 +6345,15 @@ pub struct ContextImageFilters {
|
||||
pub struct ContextImage {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
/// Ebenen-/Gruppierungsname (SitePanel), z. B. „Luftbild". Optional.
|
||||
/// [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und
|
||||
/// Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`).
|
||||
#[serde(rename = "categoryCode")]
|
||||
pub category_code: String,
|
||||
/// [181] Herkunft (z. B. „swissBUILDINGS3D", „IFC IfcSite", „DXF-Layer Haus") — nur Auskunft in der
|
||||
/// Objekt-Info, ohne jede Wirkung auf Darstellung oder Sichtbarkeit (die steuert allein `categoryCode`).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub layer: Option<String>,
|
||||
/// Grafik-Kategorie-Code, s. {@link ImportedMesh.categoryCode}.
|
||||
#[serde(rename = "categoryCode", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub category_code: Option<String>,
|
||||
pub source: Option<String>,
|
||||
/// Bildquelle als Data-URL (PNG/JPEG).
|
||||
pub src: String,
|
||||
/// Modell-Meter Bounding-Box (das Bild füllt [min..max] planar von oben).
|
||||
|
||||
@@ -630,7 +630,9 @@ pub enum ParametricRule {
|
||||
Sequence(SequenceRule),
|
||||
}
|
||||
|
||||
/// Kontext-Objekt (Tag `type`).
|
||||
/// Gelände- und Umgebungs-Element (Tag `type`, Sammlung `Project.context`, [181]): Netzkörper (`importedMesh`,
|
||||
/// z. B. Nachbargebäude), Höhenlinien (`contourSet`), Gelände (`terrainMesh`), Luftbild (`image`), Baugrube
|
||||
/// (`excavation`). Normale Elemente mit Klasse (`categoryCode`), unabhängig davon, woher sie kommen.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum ContextObject {
|
||||
@@ -646,6 +648,30 @@ pub enum ContextObject {
|
||||
Excavation(Excavation),
|
||||
}
|
||||
|
||||
impl ContextObject {
|
||||
/// [181] Klasse/Ebene des Elements (Pflichtfeld jeder Art).
|
||||
pub fn category_code(&self) -> &str {
|
||||
match self {
|
||||
ContextObject::ImportedMesh(m) => &m.category_code,
|
||||
ContextObject::ContourSet(s) => &s.category_code,
|
||||
ContextObject::TerrainMesh(t) => &t.category_code,
|
||||
ContextObject::Image(i) => &i.category_code,
|
||||
ContextObject::Excavation(e) => &e.category_code,
|
||||
}
|
||||
}
|
||||
|
||||
/// Element-Id.
|
||||
pub fn id(&self) -> &str {
|
||||
match self {
|
||||
ContextObject::ImportedMesh(m) => &m.id,
|
||||
ContextObject::ContourSet(s) => &s.id,
|
||||
ContextObject::TerrainMesh(t) => &t.id,
|
||||
ContextObject::Image(i) => &i.id,
|
||||
ContextObject::Excavation(e) => &e.id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Drawing2DGeom {
|
||||
fn default() -> Self {
|
||||
Drawing2DGeom::Pointmarker { at: Vec2::default() }
|
||||
|
||||
@@ -45,7 +45,7 @@ mod tests {
|
||||
#[test]
|
||||
fn importiertes_netz_mit_farbe_und_ifc_id() {
|
||||
let raw: Value = serde_json::from_str(
|
||||
r##"{"type":"importedMesh","id":"m","name":"Wand","color":"#aabbcc","ifcGlobalId":"2O2Fr$t4X7Zf8NOew3FLOH",
|
||||
r##"{"type":"importedMesh","id":"m","name":"Wand","categoryCode":"10","source":"IFC IfcWall","color":"#aabbcc","ifcGlobalId":"2O2Fr$t4X7Zf8NOew3FLOH",
|
||||
"positions":[0,0,0],"indices":[0,0,0]}"##,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -32,18 +32,11 @@ pub fn emit_context_meshes(p: &Project) -> Vec<RMesh> {
|
||||
// [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)) {
|
||||
// [181] Sichtbarkeit allein über die Klasse.
|
||||
if hidden.contains(obj.category_code()) {
|
||||
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);
|
||||
|
||||
@@ -189,15 +189,10 @@ pub fn pick_geometry(p: &Project) -> Result<PickGeometry, String> {
|
||||
let stairs = pick_stairs(p);
|
||||
// Kontext-Meshes: rohe Welt-Dreiecke, Modell (x, y, z) → Welt (x, z, −y).
|
||||
let mut context_meshes = Vec::new();
|
||||
// [137] Was im 3D nicht gezeichnet wird (Kategorie aus, Gelände einzeln aus), fängt auch keinen Klick.
|
||||
// [137] Was im 3D nicht gezeichnet wird (Klasse aus), fängt auch keinen Klick.
|
||||
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)) || matches!(obj, ContextObject::TerrainMesh(m) if m.hidden == Some(true)) || matches!(obj, ContextObject::ImportedMesh(m) if m.hidden == Some(true)) {
|
||||
if hidden.contains(obj.category_code()) {
|
||||
continue;
|
||||
}
|
||||
let (pos, idx, id) = match obj {
|
||||
|
||||
@@ -64,7 +64,7 @@ fn near(a: V3, b: V3) -> bool {
|
||||
/// [T6]/[114] Gelände in ausgeblendeter Kategorie kommt nicht ins 3D.
|
||||
#[test]
|
||||
fn gelaende_ausgeblendet_nicht_im_3d() {
|
||||
let t = crate::model::TerrainMesh { id: "t".into(), category_code: Some("02".into()), positions: vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0], indices: vec![0.0, 1.0, 2.0], ..Default::default() };
|
||||
let t = crate::model::TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0], indices: vec![0.0, 1.0, 2.0], ..Default::default() };
|
||||
let cat = |visible| crate::model::LayerCategory { code: "02".into(), name: "Gelände".into(), visible, ..Default::default() };
|
||||
let mk = |visible| Project { context: Some(vec![ContextObject::TerrainMesh(t.clone())]), layers: vec![cat(visible)], ..Default::default() };
|
||||
assert_eq!(emit_context_meshes(&mk(true)).len(), 1);
|
||||
@@ -173,21 +173,19 @@ fn pick_dachfenster_im_3d() {
|
||||
assert!(g.roofs.iter().any(|r| r.roof_id == "RF1" && !r.tris.is_empty()));
|
||||
}
|
||||
|
||||
/// [137] Einzeln ausgeblendetes Gelände (`hidden`) und Gelände einer ausgeblendeten Kategorie fehlen im 3D
|
||||
/// und in der Pick-Geometrie; ein zweites Netz bleibt.
|
||||
/// [137]/[181] Gelände-Elemente verschwinden mit ihrer Klasse aus 3D und Pick-Geometrie; ein Gelände anderer Klasse bleibt.
|
||||
#[test]
|
||||
fn gelaende_einzeln_ausblenden() {
|
||||
let mk = |id: &str, hidden: Option<bool>, code: Option<&str>| {
|
||||
fn gelaende_nach_klasse_ausblenden() {
|
||||
let mk = |id: &str, code: &str| {
|
||||
ContextObject::TerrainMesh(TerrainMesh {
|
||||
id: id.into(),
|
||||
positions: vec![0.0, 0.0, 0.0, 10.0, 0.0, 0.0, 10.0, 10.0, 1.0],
|
||||
indices: vec![0.0, 1.0, 2.0],
|
||||
hidden,
|
||||
category_code: code.map(Into::into),
|
||||
category_code: code.into(),
|
||||
..Default::default()
|
||||
})
|
||||
};
|
||||
let mut p = Project { context: Some(vec![mk("a", Some(true), None), mk("b", None, None), mk("c", Some(false), Some("02"))]), ..Default::default() };
|
||||
let mut p = Project { context: Some(vec![mk("b", "05"), mk("c", "02")]), ..Default::default() };
|
||||
let ids = |p: &Project| pick_geometry(p).unwrap().context_meshes.iter().map(|m| m.context_object_id.clone()).collect::<Vec<_>>();
|
||||
assert_eq!(ids(&p), vec!["b", "c"]);
|
||||
assert_eq!(emit_context_meshes(&p).len(), 2);
|
||||
@@ -583,15 +581,16 @@ fn pick_kreis_bogen_text_im_3d() {
|
||||
assert!(inside(&g.drawing_meshes[2].tris, 21.0, 0.2) && !inside(&g.drawing_meshes[2].tris, 22.0, 0.2));
|
||||
}
|
||||
|
||||
/// [137] Einzeln ausgeblendetes importiertes Netz: weder im 3D noch als Pick-Dreiecke.
|
||||
/// [181] Netzkörper (z. B. Nachbargebäude) in ausgeblendeter Klasse: weder im 3D noch als Pick-Dreiecke.
|
||||
#[test]
|
||||
fn importiertes_netz_einzeln_ausgeblendet() {
|
||||
let mk = |hidden: Option<bool>| Project {
|
||||
context: Some(vec![ContextObject::ImportedMesh(ImportedMesh { id: "m".into(), hidden, positions: vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0], indices: vec![0.0, 1.0, 2.0], ..Default::default() })]),
|
||||
fn netzkoerper_klasse_ausgeblendet() {
|
||||
let mk = |visible: bool| Project {
|
||||
context: Some(vec![ContextObject::ImportedMesh(ImportedMesh { id: "m".into(), category_code: "12".into(), positions: vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0], indices: vec![0.0, 1.0, 2.0], ..Default::default() })]),
|
||||
layers: vec![crate::model::LayerCategory { code: "12".into(), name: "Gebäude".into(), visible, ..Default::default() }],
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(emit_context_meshes(&mk(None)).len(), 1);
|
||||
assert_eq!(pick_geometry(&mk(None)).unwrap().context_meshes.len(), 1);
|
||||
assert!(emit_context_meshes(&mk(Some(true))).is_empty());
|
||||
assert!(pick_geometry(&mk(Some(true))).unwrap().context_meshes.is_empty());
|
||||
assert_eq!(emit_context_meshes(&mk(true)).len(), 1);
|
||||
assert_eq!(pick_geometry(&mk(true)).unwrap().context_meshes.len(), 1);
|
||||
assert!(emit_context_meshes(&mk(false)).is_empty());
|
||||
assert!(pick_geometry(&mk(false)).unwrap().context_meshes.is_empty());
|
||||
}
|
||||
@@ -59,7 +59,7 @@ fn bbox_corners(positions: &[f64]) -> Option<Vec<Vec2>> {
|
||||
(b.len() == 4).then(|| vec![v2(b[0], b[1]), v2(b[2], b[1]), v2(b[2], b[3]), v2(b[0], b[3])])
|
||||
}
|
||||
|
||||
/// Kontext-Schicht (`addContextContours`). Objekte ohne Kategorie bleiben immer sichtbar. Die
|
||||
/// Gelände- und Umgebungs-Elemente (`Project.context`, [181]); sichtbar nach ihrer Klasse. Die
|
||||
/// Höhenlinien-Beschriftungen weichen den Zeichnungen des Geschosses aus (`drawings::stamp_obstacle_prims`).
|
||||
pub fn plan_context(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
plan_context_with(c, out, c.drawn_obstacles());
|
||||
@@ -80,23 +80,14 @@ pub fn plan_context_with(c: &Ctx, out: &mut Vec<Primitive>, drawing_obstacles: &
|
||||
if meshes_done && matches!(obj, ContextObject::ImportedMesh(_)) {
|
||||
continue;
|
||||
}
|
||||
let code = match obj {
|
||||
ContextObject::ImportedMesh(m) => m.category_code.as_deref(),
|
||||
ContextObject::ContourSet(s) => s.category_code.as_deref(),
|
||||
ContextObject::TerrainMesh(t) => t.category_code.as_deref(),
|
||||
ContextObject::Image(i) => i.category_code.as_deref(),
|
||||
ContextObject::Excavation(e) => e.category_code.as_deref(),
|
||||
};
|
||||
if code.is_some_and(|k| !c.shown(k)) {
|
||||
// [181] Sichtbarkeit allein über die Klasse (kein „ohne Kategorie immer sichtbar", kein Einzel-Ausblenden).
|
||||
let code = Some(obj.category_code());
|
||||
if !c.shown(obj.category_code()) {
|
||||
continue;
|
||||
}
|
||||
if matches!(obj, ContextObject::TerrainMesh(_) | ContextObject::ContourSet(_) | ContextObject::Excavation(_)) && !terrain_shown(c) {
|
||||
continue;
|
||||
}
|
||||
// [137] Einzeln ausgeblendetes Gelände bzw. importiertes Netz (Kategorie bleibt sichtbar).
|
||||
if matches!(obj, ContextObject::TerrainMesh(t) if t.hidden == Some(true)) || matches!(obj, ContextObject::ImportedMesh(m) if m.hidden == Some(true)) {
|
||||
continue;
|
||||
}
|
||||
// [33] Gelände und Höhenlinien über Regeln (Bauteilart „Gelände“): Ausblenden, Linie (Farbe, Stärke, Linienstil).
|
||||
let tov = match obj {
|
||||
ContextObject::TerrainMesh(t) => super::overrides::terrain_override(c.p, c.rule_view(), code, &t.name),
|
||||
@@ -171,7 +162,7 @@ pub fn plan_context_with(c: &Ctx, out: &mut Vec<Primitive>, drawing_obstacles: &
|
||||
/// [157] Sohle und Böschungsoberkante der Baugruben, die dieser Grundriss zeigt (Gelände sichtbar, Kategorie
|
||||
/// der Baugrube gezeigt), als Strecken — Hindernisse der Aussenbemassung und der Schnittmarken-Beschriftung.
|
||||
pub(super) fn excavation_segments(c: &Ctx) -> Vec<([f64; 2], [f64; 2])> {
|
||||
let pits: Vec<&Excavation> = crate::excavation::excavations(c.p).into_iter().filter(|e| e.category_code.as_deref().is_none_or(|k| c.shown(k))).collect();
|
||||
let pits: Vec<&Excavation> = crate::excavation::excavations(c.p).into_iter().filter(|e| c.shown(&e.category_code)).collect();
|
||||
if pits.is_empty() || !terrain_shown(c) {
|
||||
return Vec::new();
|
||||
}
|
||||
@@ -977,7 +968,7 @@ pub fn plan_section_lines(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
if !excavation_segments(c).is_empty() {
|
||||
let house = terrain_footprint(c.p, &c.a.floor);
|
||||
let (mut pit, mut bands) = (Vec::new(), Vec::new());
|
||||
for e in crate::excavation::excavations(c.p).into_iter().filter(|e| e.category_code.as_deref().is_none_or(|k| c.shown(k))) {
|
||||
for e in crate::excavation::excavations(c.p).into_iter().filter(|e| c.shown(&e.category_code)) {
|
||||
excavation_lines(c, e, &mut pit, &mut bands, &house);
|
||||
}
|
||||
for q in &pit {
|
||||
@@ -1057,23 +1048,25 @@ mod tests {
|
||||
id: "t".into(),
|
||||
positions: vec![0.0, 0.0, 0.0, 60.0, 0.0, 6.0, 60.0, 40.0, 6.0, 0.0, 40.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 {
|
||||
id: "bg".into(),
|
||||
category_code: "02".into(),
|
||||
outline: vec![v2(20.0, 15.0), v2(30.0, 15.0), v2(30.0, 25.0), v2(20.0, 25.0)],
|
||||
bottom: 1.0,
|
||||
..Default::default()
|
||||
};
|
||||
let cs = ContourSet {
|
||||
id: "hl".into(),
|
||||
category_code: "02".into(),
|
||||
contours: vec![Contour { z: 0.0, pts: vec![v2(-20.0, -5.0), v2(80.0, 50.0)], ..Default::default() }],
|
||||
..Default::default()
|
||||
};
|
||||
// Reihenfolge wie im Musterhaus komplex: Höhenlinien, Baugrube, dann das daraus erzeugte Gelände.
|
||||
let p = Project { context: Some(vec![ContextObject::ContourSet(cs), ContextObject::Excavation(pit), ContextObject::TerrainMesh(t)]), ..Default::default() };
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "scale": 100}"#).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02", "02"], "scale": 100}"#).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_context(&Ctx::new(&p, &a), &mut out);
|
||||
assert_eq!(top_context(&out, 25.0, 20.0).as_deref(), Some("bg"), "Sohle");
|
||||
@@ -1096,7 +1089,7 @@ mod tests {
|
||||
// Pfeil nach unten (Ansicht Nord, oben im Plan) und nach links/rechts.
|
||||
let p = Project { drawing_levels: vec![level("Ansicht Nord", [10.0, 20.0], [0.0, 20.0]), level("Ansicht West", [-5.0, 10.0], [-5.0, 0.0]), level("Ansicht Ost", [15.0, 0.0], [15.0, 10.0]), level("Schnitt A-A", [0.0, 5.0], [60.0, 5.0])], ..Default::default() };
|
||||
let run = |scale: f64| {
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"show": ["90"], "scale": {scale}, "global": true}}"#)).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"show": ["02", "90"], "scale": {scale}, "global": true}}"#)).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_section_lines(&Ctx::new(&p, &a), &mut out);
|
||||
out
|
||||
@@ -1125,7 +1118,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
// Ausmass des Plans umfasst die Beschriftung der Ansicht Nord (über y = 20).
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["90"], "scale": 100, "global": true}"#).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02", "90"], "scale": 100, "global": true}"#).unwrap();
|
||||
let d = super::super::domains::plan_domains(&p, &a).unwrap();
|
||||
let top = out_top(&run(100.0));
|
||||
assert!(d.bounds.is_some_and(|b| b[3] >= top - 1e-9), "{:?} < {top}", d.bounds);
|
||||
@@ -1140,7 +1133,7 @@ mod tests {
|
||||
"linePoints": [{ "x": 0.0, "y": -2.0 }, { "x": 10.0, "y": -2.0 }] })).unwrap()],
|
||||
..Default::default()
|
||||
};
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["90"], "scale": 100, "global": true}"#).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02", "90"], "scale": 100, "global": true}"#).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_section_lines(&Ctx::new(&p, &a), &mut out);
|
||||
assert!(!out.iter().any(|q| matches!(q, Primitive::Line { .. } | Primitive::Arc { .. })), "keine Linie, kein Kreis");
|
||||
@@ -1171,7 +1164,7 @@ mod tests {
|
||||
p
|
||||
};
|
||||
let run = |p: &Project, mv: bool| {
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"show": ["90"], "scale": 100, "global": true{}}}"#, if mv { r#", "modelView": "m""# } else { "" })).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"show": ["02", "90"], "scale": 100, "global": true{}}}"#, if mv { r#", "modelView": "m""# } else { "" })).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_section_lines(&Ctx::new(p, &a), &mut out);
|
||||
out
|
||||
@@ -1200,7 +1193,7 @@ mod tests {
|
||||
}
|
||||
};
|
||||
let run = |p: &Project| {
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["90"], "scale": 100, "global": true}"#).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02", "90"], "scale": 100, "global": true}"#).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_section_lines(&Ctx::new(p, &a), &mut out);
|
||||
out
|
||||
@@ -1236,7 +1229,7 @@ mod tests {
|
||||
.collect()
|
||||
};
|
||||
let run = |p: &Project, scale: f64| {
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"floor": "eg", "show": ["90", "80"], "scale": {scale}}}"#)).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"floor": "eg", "show": ["02", "90", "80"], "scale": {scale}}}"#)).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_section_lines(&Ctx::new(p, &a), &mut out);
|
||||
out
|
||||
@@ -1291,7 +1284,7 @@ mod tests {
|
||||
assert!(outside(v2(4.0, 4.0), v2(5.0, 4.0), &rings).is_empty());
|
||||
assert_eq!(outside(v2(20.0, 4.0), v2(25.0, 4.0), &rings).len(), 1);
|
||||
// Im Plan: Gelände z = x/10, Haus aus vier Wänden 12..18 × 0..10 → keine Höhenlinie bei x = 15 im Haus.
|
||||
let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 30.0, 0.0, 3.0, 30.0, 10.0, 3.0, 0.0, 10.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.5), ..Default::default() };
|
||||
let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 30.0, 0.0, 3.0, 30.0, 10.0, 3.0, 0.0, 10.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.5), ..Default::default() };
|
||||
let mut v: serde_json::Value = serde_json::from_str(include_str!("../../tests/fixtures/sample_project.json")).unwrap();
|
||||
let wall = |id: &str, a: [f64; 2], b: [f64; 2]| serde_json::json!({"id": id, "type": "wall", "floorId": v["drawingLevels"][0]["id"], "categoryCode": "20", "wallTypeId": v["walls"][0]["wallTypeId"], "start": {"x": a[0], "y": a[1]}, "end": {"x": b[0], "y": b[1]}, "height": 3});
|
||||
let walls = serde_json::json!([wall("a", [12.0, -2.0], [18.0, -2.0]), wall("b", [18.0, -2.0], [18.0, 12.0]), wall("c", [18.0, 12.0], [12.0, 12.0]), wall("d", [12.0, 12.0], [12.0, -2.0])]);
|
||||
@@ -1299,7 +1292,7 @@ mod tests {
|
||||
v["openings"] = serde_json::json!([]);
|
||||
let mut p: Project = serde_json::from_value(v).unwrap();
|
||||
p.context = Some(vec![ContextObject::TerrainMesh(t)]);
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"scale": 100}"#).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "scale": 100}"#).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_context(&Ctx::new(&p, &a), &mut out);
|
||||
let lines: Vec<(Vec2, Vec2)> = out.iter().filter_map(|q| match q { Primitive::Line { a, b, color: Some(c), .. } if c == TERRAIN_INK => Some((*a, *b)), _ => None }).collect();
|
||||
@@ -1327,13 +1320,14 @@ mod tests {
|
||||
// x 0..10 flach (z = 0.1 x), x 10..11 steil (z 1 → 11).
|
||||
let t = TerrainMesh {
|
||||
id: "t".into(),
|
||||
category_code: "02".into(),
|
||||
positions: vec![0.0, 0.0, 0.0, 10.0, 0.0, 1.0, 10.0, 10.0, 1.0, 0.0, 10.0, 0.0, 11.0, 0.0, 11.0, 11.0, 10.0, 11.0],
|
||||
indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0, 1.0, 4.0, 5.0, 1.0, 5.0, 2.0],
|
||||
contour_interval: Some(0.1),
|
||||
..Default::default()
|
||||
};
|
||||
let p = Project { context: Some(vec![ContextObject::TerrainMesh(t)]), ..Default::default() };
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"scale": 100}"#).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "scale": 100}"#).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_context(&Ctx::new(&p, &a), &mut out);
|
||||
let xs: Vec<f64> = out.iter().filter_map(|q| match q { Primitive::Line { a, b, color: Some(c), .. } if c == TERRAIN_INK && (a.x - b.x).abs() < 1e-9 => Some(a.x), _ => None }).collect();
|
||||
@@ -1353,18 +1347,19 @@ mod tests {
|
||||
id: "t".into(),
|
||||
positions: vec![0.0, 0.0, 0.0, 60.0, 0.0, 6.0, 60.0, 40.0, 6.0, 0.0, 40.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(),
|
||||
contour_interval: Some(1.0),
|
||||
..Default::default()
|
||||
};
|
||||
let pit = Excavation {
|
||||
id: "bg".into(),
|
||||
category_code: "02".into(),
|
||||
outline: vec![v2(20.0, 15.0), v2(30.0, 15.0), v2(30.0, 25.0), v2(20.0, 25.0)],
|
||||
bottom: 1.0,
|
||||
..Default::default()
|
||||
};
|
||||
let p = Project { context: Some(vec![ContextObject::TerrainMesh(t), ContextObject::Excavation(pit)]), ..Default::default() };
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "scale": 100}"#).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02", "02"], "scale": 100}"#).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_context(&Ctx::new(&p, &a), &mut out);
|
||||
let w = |m: f64| out.iter().filter(|q| matches!(q, Primitive::Line { weight_mm, color: Some(c), .. } if *weight_mm == m && c == TERRAIN_INK)).count();
|
||||
@@ -1418,9 +1413,9 @@ mod tests {
|
||||
["o1", "og", 30.0, 20.0, 38.0, 20.0]
|
||||
]));
|
||||
// Gelände z = y/10 über 40 × 30 m: Höhenlinien waagrecht je 1 m, Zähllinien je 5 m (z = 0.5, 1.0 …).
|
||||
let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 30.0, 3.0, 0.0, 30.0, 3.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() };
|
||||
let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 30.0, 3.0, 0.0, 30.0, 3.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() };
|
||||
p.context = Some(vec![ContextObject::TerrainMesh(t)]);
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "scale": 100}"#).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "floor": "eg", "scale": 100}"#).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_context(&Ctx::new(&p, &a), &mut out);
|
||||
let lines: Vec<(Vec2, Vec2)> = out.iter().filter_map(|q| match q { Primitive::Line { a, b, color: Some(c), .. } if c == TERRAIN_INK => Some((*a, *b)), _ => None }).collect();
|
||||
@@ -1452,9 +1447,9 @@ mod tests {
|
||||
["a1", "eg", 18.5, 8.0, 18.5, 12.0], ["a2", "eg", 18.5, 12.0, 21.5, 12.0], ["a3", "eg", 21.5, 12.0, 21.5, 8.0]
|
||||
]));
|
||||
// Grube mit Arbeitsraum: Nordrand bei y = 10 läuft durch den Anbau.
|
||||
let pit = Excavation { id: "bg".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, ..Default::default() };
|
||||
let pit = Excavation { id: "bg".into(), category_code: "02".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, ..Default::default() };
|
||||
p.context = Some(vec![ContextObject::Excavation(pit)]);
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "scale": 100}"#).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "floor": "eg", "scale": 100}"#).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_context(&Ctx::new(&p, &a), &mut out);
|
||||
let sohle: Vec<(Vec2, Vec2)> = out.iter().filter_map(|q| match q { Primitive::Line { a, b, color: Some(c), weight_mm, .. } if c == EXCAVATION_INK && (*weight_mm - 0.25).abs() < 1e-9 => Some((*a, *b)), _ => None }).collect();
|
||||
@@ -1472,13 +1467,13 @@ mod tests {
|
||||
#[test]
|
||||
fn schnittmarke_nicht_auf_der_boeschung() {
|
||||
let mut p = sample_with_walls(serde_json::json!([["h1", "eg", 14.0, 0.0, 26.0, 0.0]]));
|
||||
let t = TerrainMesh { id: "t".into(), positions: vec![0.0, -10.0, 0.0, 40.0, -10.0, 0.0, 40.0, 30.0, 0.0, 0.0, 30.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], ..Default::default() };
|
||||
let pit = Excavation { id: "bg".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, slope: Some(45.0), ..Default::default() };
|
||||
let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, -10.0, 0.0, 40.0, -10.0, 0.0, 40.0, 30.0, 0.0, 0.0, 30.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], ..Default::default() };
|
||||
let pit = Excavation { id: "bg".into(), category_code: "02".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, slope: Some(45.0), ..Default::default() };
|
||||
p.context = Some(vec![ContextObject::TerrainMesh(t), ContextObject::Excavation(pit)]);
|
||||
// Schnittlinie mit den Enden in der West- und Ostböschung.
|
||||
p.drawing_levels.push(serde_json::from_value(serde_json::json!({ "id": "s", "name": "Schnitt B-B", "kind": "section", "visible": true, "locked": false,
|
||||
"linePoints": [{ "x": 10.5, "y": 4.0 }, { "x": 29.5, "y": 4.0 }] })).unwrap());
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "show": ["90", "80", "02"], "scale": 100}"#).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "show": ["02", "90", "80", "02"], "scale": 100}"#).unwrap();
|
||||
let c = Ctx::new(&p, &a);
|
||||
let mut out = Vec::new();
|
||||
plan_section_lines(&c, &mut out);
|
||||
@@ -1516,15 +1511,15 @@ mod tests {
|
||||
let mut p = sample_with_walls(serde_json::json!([
|
||||
["h1", "eg", 14.0, 0.0, 26.0, 0.0], ["h2", "eg", 26.0, 0.0, 26.0, 8.0], ["h3", "eg", 26.0, 8.0, 14.0, 8.0], ["h4", "eg", 14.0, 8.0, 14.0, 0.0]
|
||||
]));
|
||||
let t = TerrainMesh { id: "t".into(), positions: vec![0.0, -10.0, 0.0, 40.0, -10.0, 0.0, 40.0, 30.0, 0.0, 0.0, 30.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], ..Default::default() };
|
||||
let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, -10.0, 0.0, 40.0, -10.0, 0.0, 40.0, 30.0, 0.0, 0.0, 30.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], ..Default::default() };
|
||||
// Sohle 2 m ausserhalb, 3 m tief, 45°: Böschungsoberkante West bei x ≈ 9.
|
||||
let pit = Excavation { id: "bg".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, slope: Some(45.0), ..Default::default() };
|
||||
let pit = Excavation { id: "bg".into(), category_code: "02".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, slope: Some(45.0), ..Default::default() };
|
||||
p.context = Some(vec![ContextObject::TerrainMesh(t), ContextObject::Excavation(pit)]);
|
||||
let dim = |id: &str, off: f64| serde_json::from_value::<Drawing2D>(serde_json::json!({"id": id, "type": "drawing2d", "levelId": "eg", "categoryCode": "20", "geom": {"shape": "dimension", "pts": [{"x": 13.8, "y": 0}, {"x": 13.8, "y": 8}], "offset": off}})).unwrap();
|
||||
p.drawings2d = vec![dim("autodim-eg-west-openings", 1.0), dim("autodim-eg-west-total", 2.4), dim("eigene", 1.5)];
|
||||
// Masslinien (senkrecht, über die ganze Kette) je Zeichnung.
|
||||
let lines = |p: &Project| -> Vec<(String, f64)> {
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "scale": 100, "show": ["20"]}"#).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "scale": 100, "show": ["02", "20"]}"#).unwrap();
|
||||
let mut out = Vec::new();
|
||||
for q in super::super::drawings::stamp_obstacle_prims(&Ctx::new(p, &a)) {
|
||||
if let Primitive::Line { a, b, drawing_id: Some(id), .. } = q {
|
||||
@@ -1552,12 +1547,12 @@ mod tests {
|
||||
#[test]
|
||||
fn gelaende_nur_im_erdgeschoss() {
|
||||
let mut p = sample_with_walls(serde_json::json!([["h1", "eg", 14.0, 0.0, 26.0, 0.0]]));
|
||||
let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 30.0, 3.0, 0.0, 30.0, 3.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() };
|
||||
let pit = Excavation { id: "bg".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, ..Default::default() };
|
||||
let cs = ContourSet { id: "hl".into(), contours: vec![Contour { pts: vec![v2(0.0, 20.0), v2(40.0, 20.0)], ..Default::default() }], ..Default::default() };
|
||||
let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 30.0, 3.0, 0.0, 30.0, 3.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() };
|
||||
let pit = Excavation { id: "bg".into(), category_code: "02".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, ..Default::default() };
|
||||
let cs = ContourSet { id: "hl".into(), category_code: "02".into(), contours: vec![Contour { pts: vec![v2(0.0, 20.0), v2(40.0, 20.0)], ..Default::default() }], ..Default::default() };
|
||||
p.context = Some(vec![ContextObject::TerrainMesh(t), ContextObject::Excavation(pit), ContextObject::ContourSet(cs)]);
|
||||
let count = |p: &Project, floor: &str, scale: f64| {
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"floor": "{floor}", "scale": {scale}}}"#)).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"show": ["02"], "floor": "{floor}", "scale": {scale}}}"#)).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_context(&Ctx::new(p, &a), &mut out);
|
||||
out.iter().filter(|q| matches!(q, Primitive::Line { color: Some(c), .. } if c == TERRAIN_INK || c == EXCAVATION_INK || c == CONTEXT_LINE_COLOR)).count()
|
||||
@@ -1575,10 +1570,10 @@ mod tests {
|
||||
/// Böschungsoberkante oder Böschungsschraffur (vorher „-2.5“/„-2.2“ in der Böschung, Musterhaus komplex EG).
|
||||
#[test]
|
||||
fn hoehenkoten_nicht_auf_der_baugrube() {
|
||||
let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 60.0, 0.0, 6.0, 60.0, 40.0, 6.0, 0.0, 40.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() };
|
||||
let pit = Excavation { id: "bg".into(), outline: vec![v2(20.0, 5.0), v2(40.0, 5.0), v2(40.0, 35.0), v2(20.0, 35.0)], bottom: 0.5, ..Default::default() };
|
||||
let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 60.0, 0.0, 6.0, 60.0, 40.0, 6.0, 0.0, 40.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() };
|
||||
let pit = Excavation { id: "bg".into(), category_code: "02".into(), outline: vec![v2(20.0, 5.0), v2(40.0, 5.0), v2(40.0, 35.0), v2(20.0, 35.0)], bottom: 0.5, ..Default::default() };
|
||||
let p = Project { context: Some(vec![ContextObject::Excavation(pit), ContextObject::TerrainMesh(t)]), ..Default::default() };
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "scale": 100}"#).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02", "02"], "scale": 100}"#).unwrap();
|
||||
let mut out = Vec::new();
|
||||
plan_context(&Ctx::new(&p, &a), &mut out);
|
||||
let pit_lines: Vec<(Vec2, Vec2)> = out.iter().filter_map(|q| match q { Primitive::Line { a, b, color: Some(c), .. } if c == EXCAVATION_INK => Some((*a, *b)), _ => None }).collect();
|
||||
@@ -1601,10 +1596,10 @@ mod tests {
|
||||
#[test]
|
||||
fn hoehenlinien_beschriftungen_kollisionsfrei() {
|
||||
// Steil: z = 4·y über 40 × 10 m → Zähllinien (z = 0.5 k) alle 0.125 m = 1.25 mm Papier.
|
||||
let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 10.0, 40.0, 0.0, 10.0, 40.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() };
|
||||
let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 10.0, 40.0, 0.0, 10.0, 40.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() };
|
||||
let dim: Drawing2D = serde_json::from_value(serde_json::json!({ "id": "d", "type": "drawing2d", "levelId": "eg", "categoryCode": "80", "geom": { "shape": "dimension", "pts": [{ "x": 2.0, "y": 5.0 }, { "x": 38.0, "y": 5.0 }], "offset": 0.0 } })).unwrap();
|
||||
let p = Project { context: Some(vec![ContextObject::TerrainMesh(t)]), drawings2d: vec![dim], ..Default::default() };
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "show": ["80"], "scale": 100}"#).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "show": ["02", "80"], "scale": 100}"#).unwrap();
|
||||
let c = Ctx::new(&p, &a);
|
||||
let mut out = Vec::new();
|
||||
plan_context(&c, &mut out);
|
||||
@@ -1649,11 +1644,11 @@ mod tests {
|
||||
/// Speicher), nach einem anderen Massstab und ohne Speicher (`contour_prims`).
|
||||
#[test]
|
||||
fn hoehenlinien_aus_dem_zwischenspeicher_wie_neu() {
|
||||
let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 2.0, 40.0, 30.0, 9.0, 0.0, 30.0, 4.0, 20.0, 15.0, 7.5], indices: vec![0.0, 1.0, 4.0, 1.0, 2.0, 4.0, 2.0, 3.0, 4.0, 3.0, 0.0, 4.0], contour_interval: Some(0.1), ..Default::default() };
|
||||
let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 2.0, 40.0, 30.0, 9.0, 0.0, 30.0, 4.0, 20.0, 15.0, 7.5], indices: vec![0.0, 1.0, 4.0, 1.0, 2.0, 4.0, 2.0, 3.0, 4.0, 3.0, 0.0, 4.0], contour_interval: Some(0.1), ..Default::default() };
|
||||
let mut p = sample_with_walls(serde_json::json!([["w1", "eg", 5, 5, 15, 5], ["w2", "eg", 15, 5, 15, 12], ["w3", "eg", 15, 12, 5, 12], ["w4", "eg", 5, 12, 5, 5]]));
|
||||
p.context = Some(vec![ContextObject::TerrainMesh(t.clone())]);
|
||||
let run = |scale: f64| {
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"floor": "eg", "show": ["80"], "scale": {scale}}}"#)).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"floor": "eg", "show": ["02", "80"], "scale": {scale}}}"#)).unwrap();
|
||||
let c = Ctx::new(&p, &a);
|
||||
let mut out = Vec::new();
|
||||
plan_context(&c, &mut out);
|
||||
|
||||
@@ -134,7 +134,7 @@ pub(super) fn face_overrides(p: &Project, faces: &mut [Face], v: RuleView) {
|
||||
Role::Mesh => p.context.as_deref().unwrap_or(&[]).iter().find_map(|c| match c {
|
||||
ContextObject::ImportedMesh(m) if m.id == id => Some(m),
|
||||
_ => None,
|
||||
}).and_then(|m| surf_ov(p, v, super::super::section::MESH_KIND, m.category_code.as_deref().unwrap_or(""), Some(&m.name), &[], None)),
|
||||
}).and_then(|m| surf_ov(p, v, super::super::section::MESH_KIND, &m.category_code, Some(&m.name), &[], None)),
|
||||
};
|
||||
memo.insert(key, o.clone());
|
||||
f.ov = o;
|
||||
|
||||
@@ -224,9 +224,7 @@ 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 {
|
||||
if let Some(code) = m.category_code.as_deref() {
|
||||
mesh_cat.entry(m.id.as_str()).or_insert(code);
|
||||
}
|
||||
mesh_cat.entry(m.id.as_str()).or_insert(m.category_code.as_str());
|
||||
}
|
||||
}
|
||||
let category = |f: &Face| -> Option<&str> {
|
||||
@@ -614,13 +612,13 @@ pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool,
|
||||
let depth_max = faces.iter().map(|f| f.depth_min).fold(f64::INFINITY, f64::min) + 0.3;
|
||||
let mut has_terrain = false;
|
||||
if acc.min_x.is_finite() && depth_max.is_finite() && !crate::excavation::terrains(p).is_empty() {
|
||||
let terrain_shown = |c: Option<&str>| c.is_none_or(|c| vis.visible(c) && vis.render(c));
|
||||
let terrain_shown = |c: &str| vis.visible(c) && vis.render(c);
|
||||
for t in crate::excavation::terrains(p) {
|
||||
if !terrain_shown(t.category_code.as_deref()) || t.hidden == Some(true) {
|
||||
if !terrain_shown(&t.category_code) {
|
||||
continue;
|
||||
}
|
||||
// [33] Gelände über Regeln (Bauteilart „Gelände“): Ausblenden, Füllung der Geländefläche, Linie.
|
||||
let tov = super::overrides::terrain_override(p, rv, t.category_code.as_deref(), &t.name);
|
||||
let tov = super::overrides::terrain_override(p, rv, Some(&t.category_code), &t.name);
|
||||
if tov.as_ref().is_some_and(|(a, _)| a.hidden()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ fn beispiel_ansicht() {
|
||||
#[test]
|
||||
fn importierte_netze_in_der_ansicht() {
|
||||
use crate::mesh_view::tests::cube;
|
||||
let mesh = |id: &str, (positions, indices): (Vec<f64>, Vec<f64>)| ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: id.into(), category_code: Some("10".into()), color: Some("#ff0000".into()), positions, indices, ..Default::default() });
|
||||
let mesh = |id: &str, (positions, indices): (Vec<f64>, Vec<f64>)| ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: id.into(), category_code: "10".into(), color: Some("#ff0000".into()), positions, indices, ..Default::default() });
|
||||
// Ansicht von y = −1 nach +y, u = x + 5.
|
||||
let level = LevelSpec { kind: "elevation".into(), line: Some([Vec2 { x: -5.0, y: -1.0 }, Vec2 { x: 8.0, y: -1.0 }]), direction_sign: Some(1.0), ..Default::default() };
|
||||
let lines = |prims: &[Primitive]| -> Vec<([f64; 2], [f64; 2])> {
|
||||
@@ -77,7 +77,7 @@ fn importierte_netze_in_der_ansicht() {
|
||||
#[test]
|
||||
fn verdeckte_netzflaechen_entfallen() {
|
||||
use crate::mesh_view::tests::cube;
|
||||
let mesh = |id: &str, (positions, indices): (Vec<f64>, Vec<f64>)| ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: id.into(), category_code: Some("10".into()), positions, indices, ..Default::default() });
|
||||
let mesh = |id: &str, (positions, indices): (Vec<f64>, Vec<f64>)| ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: id.into(), category_code: "10".into(), positions, indices, ..Default::default() });
|
||||
let level = LevelSpec { kind: "elevation".into(), line: Some([Vec2 { x: -5.0, y: -1.0 }, Vec2 { x: 8.0, y: -1.0 }]), direction_sign: Some(1.0), ..Default::default() };
|
||||
let count = |prims: &[Primitive], id: &str| prims.iter().filter(|q| matches!(q, Primitive::Polygon { context_object_id: Some(i), .. } if i == id)).count();
|
||||
// Wand x −1…5, 3 m hoch, bei y = 0.5; dahinter „hinten" (ganz verdeckt), „teil" (ragt rechts heraus),
|
||||
|
||||
@@ -603,14 +603,7 @@ pub fn extra_bounds(p: &Project, extra: &[(Primitive, u32)], shown: impl Fn(&str
|
||||
}
|
||||
}
|
||||
for obj in p.context.as_deref().unwrap_or(&[]) {
|
||||
let code = match obj {
|
||||
ContextObject::ImportedMesh(m) => m.category_code.as_deref(),
|
||||
ContextObject::ContourSet(s) => s.category_code.as_deref(),
|
||||
ContextObject::TerrainMesh(t) => t.category_code.as_deref(),
|
||||
ContextObject::Image(i) => i.category_code.as_deref(),
|
||||
ContextObject::Excavation(e) => e.category_code.as_deref(),
|
||||
};
|
||||
if code.is_some_and(|k| !shown(k)) {
|
||||
if !shown(obj.category_code()) {
|
||||
continue;
|
||||
}
|
||||
match obj {
|
||||
|
||||
@@ -62,7 +62,7 @@ fn mesh_ov(c: &Ctx, m: &ImportedMesh) -> Option<MeshOv> {
|
||||
if !super::overrides::has_active(c.p, v) {
|
||||
return None;
|
||||
}
|
||||
let code = m.category_code.as_deref();
|
||||
let code = Some(m.category_code.as_str());
|
||||
let s = super::overrides::Subject { layer_name: code.and_then(|k| c.p.layer_category(k)).map(|k| k.name.as_str()), layer_code: code, object_name: Some(&m.name), element_kind: Some(super::section::MESH_KIND), ..Default::default() };
|
||||
let (el, ly, _) = super::overrides::effective_surface(c.p.override_rules.as_deref(), &s, v);
|
||||
let hatch = match ly.hatch.as_deref() {
|
||||
@@ -181,7 +181,7 @@ pub fn plan_meshes(c: &Ctx, out: &mut Vec<Primitive>) -> bool {
|
||||
let cut = range.cut;
|
||||
let meshes: Vec<(MeshRef, Zone)> = mesh_view::meshes(c.p)
|
||||
.into_iter()
|
||||
.filter(|m| m.mesh.category_code.as_deref().is_none_or(|k| c.shown(k)) && !c.rule_hidden(&m.mesh.id))
|
||||
.filter(|m| c.shown(&m.mesh.category_code) && !c.rule_hidden(&m.mesh.id))
|
||||
.filter_map(|m| {
|
||||
let z = zone_of(&range, band, m.info.bbox[2], m.info.bbox[5])?;
|
||||
Some((m, z))
|
||||
@@ -192,7 +192,7 @@ pub fn plan_meshes(c: &Ctx, out: &mut Vec<Primitive>) -> bool {
|
||||
}
|
||||
let (solid_fill, solid_hatch) = if c.solid_cut() { (HATCH_INK.to_string(), no_hatch()) } else { (super::section::BODY_FILL.to_string(), super::section::section_hatch()) };
|
||||
let ovs: Vec<Option<MeshOv>> = meshes.iter().map(|(m, _)| mesh_ov(c, m.mesh)).collect();
|
||||
let greyed = |m: &MeshRef| m.mesh.category_code.as_deref().is_some_and(|k| c.greyed(k));
|
||||
let greyed = |m: &MeshRef| c.greyed(&m.mesh.category_code);
|
||||
// Schnittflächen (und Verdecker der Aufsicht in Tiefe 0).
|
||||
let mut below: Vec<crate::hlr::Face> = Vec::new();
|
||||
let mut cut_prims: Vec<Primitive> = Vec::new();
|
||||
@@ -287,7 +287,7 @@ mod tests {
|
||||
use crate::plan::domains::PlanArgs;
|
||||
|
||||
fn mesh(id: &str, (positions, indices): (Vec<f64>, Vec<f64>)) -> ContextObject {
|
||||
ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: id.into(), category_code: Some("10".into()), positions, indices, ..Default::default() })
|
||||
ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: id.into(), category_code: "10".into(), positions, indices, ..Default::default() })
|
||||
}
|
||||
|
||||
/// Zwei Geschosse: EG (0, Höhe 2.7, Schnitt 1.0), OG (2.7).
|
||||
|
||||
@@ -358,7 +358,7 @@ pub fn hidden_elements(p: &Project, v: RuleView) -> HashSet<String> {
|
||||
// [152] Importierte Netze (Bauteilart „mesh"); ohne Kategorie nur über Name/Bauteilart.
|
||||
for c in p.context.iter().flatten() {
|
||||
if let ContextObject::ImportedMesh(m) = c {
|
||||
if test(super::section::MESH_KIND, m.category_code.as_deref().unwrap_or(""), Some(&m.name)) {
|
||||
if test(super::section::MESH_KIND, &m.category_code, Some(&m.name)) {
|
||||
out.insert(m.id.clone());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1119,14 +1119,16 @@ fn context_selection(root: &Map<String, Value>, o: &Value) -> J {
|
||||
O::default().n("e", (bb[0] + bb[2]) / 2.0 + oe).n("n", (bb[1] + bb[3]) / 2.0 + on).done()
|
||||
});
|
||||
let image = kind == Some("image");
|
||||
// [181] Normales Element: Klasse (im Kopf der Objekt-Info änderbar) und Farbe/Stärke der Klasse; Herkunft nur als Auskunft.
|
||||
let cat = category(root, field(o, "categoryCode"));
|
||||
O::default()
|
||||
.s("kind", "contextObject")
|
||||
.raw("id", o, "id")
|
||||
.s("categoryCode", "")
|
||||
.s("color", "#888888")
|
||||
.n("weightMm", WALL_FALLBACK_MM)
|
||||
.raw("categoryCode", o, "categoryCode")
|
||||
.v("color", color_of(o, cat, "#888888"))
|
||||
.v("weightMm", lw_or(None, cat, WALL_FALLBACK_MM))
|
||||
.v("bbox", bbox_value(bb))
|
||||
.v("contextObject", O::default().raw("objType", o, "type").o("lv95Center", lv95).done())
|
||||
.v("contextObject", O::default().raw("objType", o, "type").raw("source", o, "source").o("lv95Center", lv95).done())
|
||||
.v("isImage", Value::Bool(image))
|
||||
.o("opacity", image.then(|| nn(field(o, "opacity")).cloned().unwrap_or_else(|| Value::from(1u64))))
|
||||
.o("imageFilters", if image { field(o, "filters").cloned() } else { None })
|
||||
|
||||
@@ -210,11 +210,8 @@ fn candidate_codes(p: &Project) -> HashSet<String> {
|
||||
codes.extend(p.roofs.iter().flatten().map(|e| e.category_code.clone()));
|
||||
codes.extend(p.stairs.iter().flatten().map(|e| e.category_code.clone()));
|
||||
codes.extend(p.openings.iter().flatten().map(|e| e.category_code.clone()));
|
||||
for c in p.context.iter().flatten() {
|
||||
if let crate::model::ContextObject::TerrainMesh(t) = c {
|
||||
codes.extend(t.category_code.clone());
|
||||
}
|
||||
}
|
||||
// [181] Gelände- und Umgebungs-Elemente tragen ihre Klasse wie jedes Bauteil.
|
||||
codes.extend(p.context.iter().flatten().map(|c| c.category_code().to_string()));
|
||||
codes
|
||||
}
|
||||
|
||||
|
||||
@@ -1067,7 +1067,7 @@ fn is_tree_category(p: &Project, code: &str) -> bool {
|
||||
|
||||
/// Gelände für den Schattenwurf: erstes sichtbares Geländenetz des Kontexts (inkl. Baugruben).
|
||||
fn shadow_terrain(p: &Project) -> Option<std::rc::Rc<crate::excavation::SiteTerrain>> {
|
||||
let t = crate::excavation::terrains(p).into_iter().find(|t| t.hidden != Some(true))?;
|
||||
let t = crate::excavation::terrains(p).into_iter().next()?;
|
||||
let st = crate::excavation::site_terrain(p, t);
|
||||
(!st.current().tris.is_empty()).then_some(st)
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ pub fn bases(p: &Project) -> Vec<f64> {
|
||||
if trees.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
let site = crate::excavation::terrains(p).into_iter().find(|t| t.hidden != Some(true)).map(|t| crate::excavation::site_terrain(p, t)).filter(|st| !st.current().tris.is_empty());
|
||||
let site = crate::excavation::terrains(p).into_iter().next().map(|t| crate::excavation::site_terrain(p, t)).filter(|st| !st.current().tris.is_empty());
|
||||
let idx = site.as_ref().map(|st| (st.index_current(), st.datum));
|
||||
trees
|
||||
.iter()
|
||||
|
||||
Reference in new issue
Block a user