Merge branch 'worktree-agent-adfbe9022c5af58a9' into claude/practical-noether-1hb2s1
check / check (push) Has been cancelled
check / licenses (push) Has been cancelled
check / e2e (push) Has been cancelled
macos / native (push) Has been cancelled

This commit is contained in:
Claude committed 2026-11-18 08:37:56 +00:00
commit 11730f7602
11 files changed
+300 -50

No files matched your search

+1 -1
View File
@@ -227,7 +227,7 @@ Punktwolken/BCF-Ausbau, Windows-Paket, [C5]/[C7]/[15] Kern-Umbauten — ausser s
- ◐ **[211]** Rendering mit Blender/Cycles (12.11.; Export-Paket `model.glb` + `scene.json` + `textures/` `export/blenderRender.ts`, Skript `scripts/blender/render_dossier.py`, Dialog, CLI `render`; Mac-Gegenprobe 12.11. lief, Befunde in [227] behoben). Offen: nicht in der Tauri-App/auf dem Mac geprüft (Berechtigungen, Metal-GPU, Ereignisse), nicht mit installiertem Blender 3.6/4.x (Mix-Knoten per Platz, `light_settings.ao_factor` nur in 5.x geprüft); Dialog nicht im Browser geklickt; ambientCG-Web-Texturen lädt die CLI nicht; Dachtyp-Schichten ohne Bildkarte (z. B. Faserzement) nur nach Namen. · M
- ◐ **[B4]** (= [25], zweite Stufe) IFC-Import zu echten Bauteilen (`io/ifcImport*`, `fileio`). Offen: Dächer, Treppen mit 3+ Podesten, Träger, schräge/gekrümmte Wände, Wände mit Profiländerung, Decken aus Netzen mit T-Stössen, Tür-Anschlag, Typen aus IfcDoorType/IfcWindowType, Farbe der Bauteile; LEFT/RIGHT nur gegen den eigenen Export geprüft. · L
- ◐ **[B3]-Rest** IFC-Geometrie-Import. Offen: IfcAdvancedBrep (NURBS), IFC4.3-Ausrichtung, IfcGridPlacement, B-Spline-Kurven, Profil-Kantenradien; CSG bei > 200 000 Dreiecken übersprungen; Farbe von Kontext-Meshes im 3D (`plan/toWalls3d.ts::emitMeshes` setzt fest `IMPORTED_RGB`). · M
- ◐ **[B5]** IFC-Export (Kern `ifc_data.rs`, `ifc_export/`). Offen: Wand/Decke-Felder ohne UI; Reference-Rückimport fehlt; IFC2x3 nicht gesondert geprüft; nicht in Revit/ArchiCAD geöffnet. · M
- ◐ **[B5]** IFC-Export (Kern `ifc_data.rs`, `ifc_export/`). 18.11.: Dach als `IfcRoof`-Aggregat (PredefinedType nach Dachform, Typ/`Pset_RoofCommon`/`Qto_RoofBaseQuantities` am Dach) mit je Dachfläche einem `IfcSlab` ROOF (Netz, `Pset_SlabCommon` inkl. Status Umbau, `Qto_SlabBaseQuantities`, Schichten des Dachtyps als `IfcMaterialLayerSetUsage` AXIS3/NEGATIVE, Dachfenster-Öffnung in der Wirtsfläche, Klassifikation auch an den Flächen), IFC4 und IFC2x3 (ifcopenshell-Schema gültig; Datensatz 9 ROOF neu geordnet, keine neue Nummer). Verschnittene Dächer/Gauben ([G5]) und Attika gehen als EIN Teil bzw. eigenes Teil statt je Fläche; Dachfläche bleibt Netz (kein Profil-Sweep); `IfcRoofType` nur IFC4. Offen: Wand/Decke-Felder ohne UI; Reference-Rückimport fehlt; IFC2x3 nicht gesondert geprüft; nicht in Revit/ArchiCAD geöffnet. · M
- ◐ **[BCF]** BCF (`fileio/src/bcf.rs`). Offen: Kamera im nativen Metal-Fenster; Schnittebene aus dem Live-Schnitt übernehmen; Kamera-Roll; schräge Schnittebenen nur angezeigt; `extensions.xml`, Farbgruppen/Linien, BimSnippet, Dokument-Referenzen und verwandte Themen gehen beim Speichern verloren. · M
- ◐ **[201]** IFC-GlobalId-Rundreise, Normalen in glTF/OBJ (12.11.). Offen: GlobalId von Bäumen und IfcOpeningElement/-Beziehungen (bleiben abgeleitet); Kopieren/Einfügen/Reihe/Spiegeln/Wand teilen setzen sie bewusst nicht mit; OBJ-Normalen/MTL im Tauri-Dialog (zweiter Dialog) und IFC nicht in Revit/ArchiCAD geprüft; keine UVs/Texturen. · S
- ◐ **[C11]** glTF/GLB-Export (`fileio/src/mesh_export.rs`). Offen: keine Texturen/Instanzen; Gelände ohne Vertex-Farben; Abzugskörper-Booleans und truck-Extrusionen nicht wie im 3D. · M
+2 -2
View File
@@ -27,7 +27,7 @@ Legende Dossier: **ja** vorhanden · **teils** teilweise · **fehlt**.
| Flächen SIA 416 / IVHB | Raumflächen-Add-on DIN 277/WoFlV belegt; SIA 416 über Listeneinstellungen (Forum, nicht geprüft) | Spaces + Worksheets (SIA 416 nicht geprüft) | **ja**: Flächentabelle nach SIA 416, GV aus Hülle ([266]), IVHB-Ziffern, Kennzahlenleiste, CSV/PDF/IFC |
| Kostenschätzung | Mengen/Listen; Kostenmodul nicht geprüft | Worksheets (nicht geprüft) | **ja**: Kennwert-Methode eBKP-H B–J, Honorar, Reserve, MwSt ([209]); nur grob |
| Abgabe-Layouts | Layouts, Publisher | Sheet Layers, Batch Publish | **ja**: Layout-Blätter, Plakate A0/A1, Kennwort/anonym mit Prüfung, PDF mit Ebenen, Publikationssätze ([208] ◐) |
| Austausch DXF/IFC | DXF/DWG, IFC (sehr ausgereift), BCF, Teamwork-Hotlinks | DXF/DWG, IFC, BCF (nicht geprüft) | **teils**: DXF/DWG, IFC Import/Export, BCF, STEP/OBJ/glTF; IFC/DXF in keinem Fremdprogramm geöffnet ([259], [C9]); Dächer als Netz im IFC |
| Austausch DXF/IFC | DXF/DWG, IFC (sehr ausgereift), BCF, Teamwork-Hotlinks | DXF/DWG, IFC, BCF (nicht geprüft) | **teils**: DXF/DWG, IFC Import/Export, BCF, STEP/OBJ/glTF; IFC/DXF in keinem Fremdprogramm geöffnet ([259], [C9]); Dächer als IfcRoof-Aggregat mit IfcSlab ROOF je Dachfläche (Netz) ([B5], 18.11.) |
| Wände/Decken/Dächer | alle, Schichtaufbau, Profile | alle | **ja**: mehrschichtig, Bogen, Gehrung/T-Stoss, Dach beliebiger Umriss; **fehlt**: geneigte Decke/Rampe als Element |
| Treppen | parametrisch, Geländer | parametrisch | **ja**: gerade, L, U, Wendel, Deckenloch automatisch |
| Geländer, Balken, Vorhangfassade | eigene Werkzeuge | eigene Werkzeuge | **teils**: Geländer als eigenes Bauteil (Stäbe, Glas, Brüstung, Lochblech; [279]); **fehlt**: Träger/Unterzug, Vorhangfassade |
@@ -64,7 +64,7 @@ Grösse: S ≤ 1 Tag · M ≤ 1 Woche · L ≤ 1 Monat. IDs aus `TODO.md`; **neu
| 9 | **Träger/Unterzug/Fassadenträger**: kein Element (Behelf Körper/Wand), Deckenspiegel mit Unterzügen fehlt. **teilweise erledigt 17.11. ([280]: Träger/Unterzug als Bauteil in Plan, Schnitt, Ansicht, 3D, IFC; Rest: Gruppen, Deckenspiegel, Profilkatalog)**, [100] nennt die Lücke | `columns` als Muster | M |
| 10 | **3D-Entourage** (Möbel, Menschen, Autos 3D) für Bilder: Bibliothek nur 2D; Behelf glTF/OBJ-Import | [253] („3D nach 1.0“), `furniture_lib.rs` | L |
| 11 | **GV: Studienkörper neben Wand-Haus, Bodenplatte unter unterstem Geschoss** | [266] Punkt 1 Rest; `building_volume.rs` | S–M |
| 12 | **IFC: Dächer als Netz, keine 2D/Layouts/Möbel**; IFC-Import zu Bauteilen unvollständig (Dächer, Träger) | [B4], [B5], [259] | M |
| 12 | **IFC: Dachflächen nur als Netz (IfcRoof-Aggregat seit 18.11., keine Profil-Extrusion), keine 2D/Layouts/Möbel**; IFC-Import zu Bauteilen unvollständig (Dächer, Träger) | [B4], [B5], [259] | M |
| 13 | **Gelände weiter bearbeiten** (Modellieren, Schnitt-Gelände geprüft?): Griffe/Profile, Abtrag/Aufschüttung nur über Baugrube | [187], [T6], [68]; Spec-Schritt 1.3 „Gelände nicht im Schnitt“ | M |
| 14 | **Raumprogramm → Modell**: Räume-generieren/ Abgleich ok; Ausbau auf Variantenvergleich (Kennzahlen je Option) nicht geprüft | [272] | nicht geprüft |
+82 -22
View File
@@ -619,6 +619,11 @@ fn stair_footprint(st: &Stair) -> Vec<Vec2> {
vec![Vec2 { x: min_x, y: min_y }, Vec2 { x: max_x, y: min_y }, Vec2 { x: max_x, y: max_y }, Vec2 { x: min_x, y: max_y }]
}
/// Name einer Dachfläche (Teil eines IfcRoof): Typname oder „Dachfläche“.
fn name_of_part(type_name: Option<&str>) -> &str {
type_name.filter(|n| !n.is_empty()).unwrap_or("Dachfläche")
}
fn roof_predefined(s: RoofShape) -> &'static str {
match s {
RoofShape::Flach => "FLAT_ROOF",
@@ -1789,26 +1794,10 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
classified.push((format!("roof/{}", roof.id), Kind::Roof, roof.category_code.clone()));
// Alle Dächer im Projekt lassen (Verschneidung [G5] braucht die Nachbarn), nur dieses ausgeben.
p.roofs = roofs.clone();
let meshes = model3d::emit_roofs(&p, Some(&roof.id))?;
let (mut positions, mut indices) = (Vec::<f64>::new(), Vec::<u32>::new());
for m in &meshes {
let at = (positions.len() / 3) as u32;
for c in m.positions.chunks_exact(3) {
positions.extend_from_slice(&[c[0], c[1], c[2] - base]);
}
indices.extend(m.indices.iter().map(|i| at + i));
}
if indices.is_empty() {
let parts = model3d::emit_roof_parts(&p, &roof.id)?;
if parts.is_empty() {
continue;
}
let mut closed = is_watertight(&positions, &indices, 1e-6);
if !closed {
let flipped: Vec<u32> = indices.chunks_exact(3).flat_map(|t| [t[0], t[2], t[1]]).collect();
if is_watertight(&positions, &flipped, 1e-6) {
indices = flipped;
closed = true;
}
}
let predefined = roof_predefined(roof.shape);
let roof_type = roof.roof_type_id.as_deref().filter(|s| !s.is_empty()).and_then(|id| p.roof_types.as_deref().unwrap_or(&[]).iter().find(|t| t.id == id));
// Ein Dach ist Gebäudehülle: IsExternal folgt aus der Bauteilart.
@@ -1817,7 +1806,8 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
props.push(ident("Reference", &t.name));
}
props.push(Prop::Bool("IsExternal", true));
props.extend(crate::u_value::roof_u_value(&p, roof).and_then(|u| u.u).map(|u| Prop::Thermal("ThermalTransmittance", u)));
let u_value = crate::u_value::roof_u_value(&p, roof).and_then(|u| u.u);
props.extend(u_value.map(|u| Prop::Thermal("ThermalTransmittance", u)));
let mut psets = vec![Pset { name: "Pset_RoofCommon", props }];
renovation_props(&p, &mut psets, "Pset_RoofCommon", roof.renovation.as_ref());
layer_renovation_props(&p, &mut psets, &roof.id);
@@ -1829,7 +1819,63 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
f.nums(&[REC_ROOF, structure, id, name, pre]);
w_type(&mut f, ty.as_ref().map(|t| type_ref(t, 2.0, predefined)).as_ref());
w_psets(&mut f, &psets);
w_mesh(&mut f, &positions, &indices, closed);
// [B5] IfcRoof als Aggregat, je Dachfläche ein IfcSlab ROOF (Pset_SlabCommon, Qto_SlabBaseQuantities).
let ri = p.roofs.as_deref().unwrap_or(&[]).iter().position(|r| r.id == roof.id);
let thickness = ty.as_ref().map_or(0.0, |t| t.2.iter().map(|l| l.2.max(0.0)).sum::<f64>());
let planes = crate::roof::roof_geometry(&roof.params(), p.roof_base_elevation(roof)).planes;
f.num(parts.len() as f64);
for (k, part) in parts.iter().enumerate() {
let (mut positions, mut indices) = (Vec::<f64>::new(), part.indices.clone());
for c in part.positions.chunks_exact(3) {
positions.extend_from_slice(&[c[0], c[1], c[2] - base]);
}
let mut closed = is_watertight(&positions, &indices, 1e-6);
if !closed {
let flipped: Vec<u32> = indices.chunks_exact(3).flat_map(|t| [t[0], t[2], t[1]]).collect();
if is_watertight(&positions, &flipped, 1e-6) {
indices = flipped;
closed = true;
}
}
let plane = part.plane.filter(|&i| i < planes.len());
let mut slab_props: Vec<Prop> = Vec::new();
if let Some(t) = roof_type {
slab_props.push(ident("Reference", &t.name));
}
slab_props.push(Prop::Bool("IsExternal", true));
slab_props.extend(u_value.map(|u| Prop::Thermal("ThermalTransmittance", u)));
let mut slab_psets = vec![Pset { name: "Pset_SlabCommon", props: slab_props }];
renovation_props(&p, &mut slab_psets, "Pset_SlabCommon", roof.renovation.as_ref());
// Mengen: Fläche der Dachfläche (geneigt, Aussenseite) abzüglich Dachfenster, Volumen aus dem Körper.
let volume = signed_volume6(&positions, &indices).abs() / 6.0;
let mut slab_q = match plane {
Some(i) => {
let gross = qty::roof_quantities(std::slice::from_ref(&planes[i])).into_iter().find(|q| q.name == "GrossArea").map_or(0.0, |q| q.value);
let pts = &planes[i];
let perimeter: f64 = (0..pts.len()).map(|j| { let (a, b) = (pts[j], pts[(j + 1) % pts.len()]); ((a[0] - b[0]).powi(2) + (a[1] - b[1]).powi(2) + (a[2] - b[2]).powi(2)).sqrt() }).sum();
let cut: f64 = ri.map_or(0.0, |ri| crate::opening_shape::roof_openings(&p, ri).iter().filter(|(_, fr)| fr.plane == Some(i)).map(|(o, _)| max(0.0, o.width) * max(0.0, o.height)).sum());
vec![
qty::Qty { name: "Width", kind: qty::QtyKind::Length, value: thickness },
qty::Qty { name: "Perimeter", kind: qty::QtyKind::Length, value: perimeter },
qty::Qty { name: "GrossArea", kind: qty::QtyKind::Area, value: gross },
qty::Qty { name: "NetArea", kind: qty::QtyKind::Area, value: max(0.0, gross - cut) },
]
}
None => Vec::new(),
};
slab_q.push(qty::Qty { name: "GrossVolume", kind: qty::QtyKind::Volume, value: volume });
slab_q.push(qty::Qty { name: "NetVolume", kind: qty::QtyKind::Volume, value: volume });
slab_psets.extend(qto("Qto_SlabBaseQuantities", slab_q));
let part_name = match (plane, parts.len()) {
(Some(_), _) => format!("{} {}", name_of_part(roof_type.map(|t| t.name.as_str())), k + 1),
(None, 1) => name_of_part(roof_type.map(|t| t.name.as_str())).to_string(),
(None, _) => "Attika".to_string(),
};
let (pname, plane_n) = (f.str(&part_name), plane.map_or(-1.0, |i| i as f64));
f.nums(&[pname, plane_n]);
w_psets(&mut f, &slab_psets);
w_mesh(&mut f, &positions, &indices, closed);
}
}
p.roofs = roofs;
@@ -1838,7 +1884,8 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
let Some(fr) = crate::opening_shape::host_frame(&p, o) else { continue };
let (host_key, floor_id) = if fr.plane.is_some() || fr.dormer {
let r = &p.roofs.as_deref().unwrap_or(&[])[fr.host];
(format!("roof/{}", r.id), r.floor_id.clone())
// [B5] Wirt = die Dachfläche (IfcSlab ROOF im IfcRoof-Aggregat), s. Datensatz ROOF.
(fr.plane.map_or_else(|| format!("roof/{}", r.id), |i| format!("roof/{}/p{i}", r.id)), r.floor_id.clone())
} else {
let c = &p.ceilings.as_deref().unwrap_or(&[])[fr.host];
(format!("slab/{}", c.id), c.floor_id.clone())
@@ -2310,10 +2357,23 @@ mod tests {
p.openings.as_mut().unwrap().push(Opening { id: "DF".into(), kind: ElementKind::Window, width: 0.78, height: 1.18, host_roof_id: Some("RF1".into()), host_point: Some(Vec2 { x: 2.5, y: 1.0 }), ..Default::default() });
let f = ifc_export_data(&p, &IfcOptions::default()).unwrap();
let s = strings(&f);
assert!(s.iter().any(|x| x == "wall/W1") && s.iter().any(|x| x == "roof/RF1"));
assert!(s.iter().any(|x| x == "wall/W1") && s.iter().any(|x| x.starts_with("roof/RF1")));
assert_eq!(f.nums.iter().filter(|v| **v == REC_OPENING_SOLID).count() >= 2, true);
}
/// [B5] Dach als Aggregat: je Dachfläche ein Teil mit Pset_SlabCommon und Qto_SlabBaseQuantities; Dachfenster am Teil.
#[test]
fn dach_in_dachflaechen() {
let mut p = sample();
p.openings.as_mut().unwrap().push(Opening { id: "DF".into(), kind: ElementKind::Window, width: 0.78, height: 1.18, host_roof_id: Some("RF1".into()), host_point: Some(Vec2 { x: 2.5, y: 1.0 }), ..Default::default() });
let n_planes = crate::roof::roof_geometry(&p.roofs.as_ref().unwrap()[0].params(), p.roof_base_elevation(&p.roofs.as_ref().unwrap()[0])).planes.len();
let parts = model3d::emit_roof_parts(&p, "RF1").unwrap();
assert!(parts.len() >= 2 && parts.iter().filter(|x| x.plane.is_some()).count() <= n_planes, "{}", parts.len());
let s = strings(&ifc_export_data(&p, &IfcOptions::default()).unwrap());
assert_eq!(s.iter().filter(|x| *x == "Qto_SlabBaseQuantities").count() >= 2, true);
assert!(s.iter().any(|x| x == "Pset_SlabCommon") && s.iter().any(|x| x.starts_with("roof/RF1/p")));
}
/// [148] Flachdach auf L-Umriss: IFC-Mengen aus dem echten Umriss (60 m², nicht 66 m² Bounding-Box),
/// Nettofläche ohne Dachfenster.
#[test]
+55
View File
@@ -603,6 +603,61 @@ pub fn emit_roofs(p: &Project, only_roof: Option<&str>) -> Result<Vec<RMesh>, St
Ok(out)
}
/// Ein Körper des IFC-Exports eines Dachs ([B5]): eine Dachfläche mit allen Schichten (Index in `roof_geometry().planes`)
/// oder ein Sonderteil ohne Fläche (Attika; verschnittenes Dach mit Gauben/Nachbarn als Ganzes).
pub struct RoofPart {
pub plane: Option<usize>,
pub positions: Vec<f64>,
pub indices: Vec<u32>,
}
/// Dach in Teilen für den IFC-Export: je Dachfläche ein Körper (alle Schichten, Dachfenster-Löcher wie im 3D), dazu die
/// Attika. Verschnittene Dächer und Gauben ([G5]) liefern ihre Körper nicht je Fläche: ein Teil ohne Fläche.
pub fn emit_roof_parts(p: &Project, roof_id: &str) -> Result<Vec<RoofPart>, String> {
let nb = crate::roof_assembly::neighbors_rc(p);
let Some((ri, roof)) = p.roofs.as_deref().unwrap_or(&[]).iter().enumerate().find(|(_, r)| r.id == roof_id) else { return Ok(Vec::new()) };
if crate::roof_assembly::roof_solids_with(p, ri, &nb).is_some() {
let (mut positions, mut indices) = (Vec::<f64>::new(), Vec::<u32>::new());
for m in emit_roofs(p, Some(roof_id))? {
let at = (positions.len() / 3) as u32;
positions.extend_from_slice(&m.positions);
indices.extend(m.indices.iter().map(|i| at + i));
}
return Ok(if indices.is_empty() { Vec::new() } else { vec![RoofPart { plane: None, positions, indices }] });
}
let g = crate::roof::roof_geometry(&roof.params(), p.roof_base_elevation(roof));
let mitre = Mitre::new(&g.planes);
let holes = roof_holes_by_plane(p, ri, &g.planes);
let layers: Vec<f64> = p.roof_layers(roof).iter().map(|l| l.thickness.max(0.0)).filter(|t| *t > EPS).collect();
let mut out = Vec::new();
for (i, plane) in g.planes.iter().enumerate() {
if plane.len() < 3 {
continue;
}
// Jede Fläche ein eigener, geschlossener Körper: auch entlang der Gratkanten Seitenflächen (Gehrungsebene).
let (mut positions, mut indices) = (Vec::new(), Vec::new());
let mut offset_above = 0.0;
for &t in &layers {
let top = mitre.at(i, offset_above);
let bottom = mitre.at(i, offset_above + t);
if holes[i].is_empty() {
push_roof_slab_between(&mut positions, &mut indices, &top, &bottom, &vec![false; top.len()]);
} else {
push_roof_slab_with_holes(&mut positions, &mut indices, &top, &bottom, &vec![false; top.len()], &holes[i], offset_above, offset_above + t);
}
offset_above += t;
}
if !indices.is_empty() {
out.push(RoofPart { plane: Some(i), positions, indices });
}
}
if let Some(pp) = crate::roof_parapet::parapet(roof, &g) {
let m = crate::roof_parapet::mesh(&pp);
out.push(RoofPart { plane: None, positions: m.positions, indices: m.indices });
}
Ok(out)
}
/// Dachschicht-Eingabe für den 3D-Live-Schnitt (`emitRoofCutLayers`).
pub fn emit_roof_cut_layers(p: &Project) -> Result<Vec<RRoofLayer>, String> {
let mut out = Vec::new();
@@ -68,6 +68,8 @@ pub(super) struct Builder {
pub(super) column_materials: Vec<(String, String, Vec<usize>)>,
/// Bauteil-Schlüssel (wie für die GlobalId, z. B. `wall/<id>`) → Entität; Ziel von Klassifikation/Zone/Attach.
pub(super) elements: HashMap<String, usize>,
/// Wirt für IfcRelVoidsElement, wenn der Schlüssel ein Aggregat ist (Dach → erste Dachfläche).
pub(super) void_alias: HashMap<String, usize>,
/// [201] Übernommene GlobalIds (Schlüssel wie für `gid`), Vorrang vor der abgeleiteten.
pub(super) guid_override: HashMap<String, String>,
/// IFC2x3: Türen/Fenster je (Tür?, Ausführung) → Bauteile; am Ende je ein IfcDoorStyle/IfcWindowStyle.
@@ -590,6 +592,22 @@ impl Builder {
(set != 0).then_some(set)
}
/// Aggregat ohne eigene Darstellung (IfcRoof): Typ, Eingliederung und Psets wie `finish_typed`.
#[allow(clippy::too_many_arguments)]
pub(super) fn finish_aggregate(&mut self, ifc: &str, guid_key: String, name: &str, ty: &Option<TypeRef>, psets: &[Pset], structure: i64, placement: usize, predefined: String) -> usize {
let guid = self.gid(&guid_key);
let entity = self.add(ifc, format!("{guid},#{},{},$,$,#{placement},$,$,{predefined}", self.owner_history, ifc_string(name)));
if let Some(i) = ty.as_ref().map(|t| self.type_for(t)) {
self.types[i].occurrences.push(entity);
}
self.add_to_containment(structure, entity);
for p in psets {
self.add_pset(p, entity, &guid_key);
}
self.elements.insert(guid_key, entity);
entity
}
/// Gemeinsamer Abschluss der Bauteile mit Typ und Psets: Typ (falls vorhanden) anlegen, Entität
/// schreiben, Typ-Exemplar, Eingliederung und Psets vormerken.
#[allow(clippy::too_many_arguments)]
+68 -10
View File
@@ -85,7 +85,12 @@
// ceiling_height (FinishCeilingHeight, mittlere lichte Höhe), PTS, net_area, gross_area,
// sia_category, PSETS
// END_SPACES = 8 (bündelt die Räume je Geschoss zu IfcRelAggregates)
// ROOF = 9, structure, id, name, predefined (Text), TYPEREF, PSETS, MESH
// ROOF = 9 ([B5] Aggregat), structure, id, name, predefined (Text), TYPEREF, PSETS, n_parts,
// (name, plane (Index der Dachfläche, −1 = Sonderteil), PSETS, MESH) × n_parts
// IfcRoof (PredefinedType nach Dachform; Typ, Pset_RoofCommon, Qto_RoofBaseQuantities) ohne Darstellung, per
// IfcRelAggregates je Teil ein IfcSlab ROOF mit Netz, Pset_SlabCommon, Qto_SlabBaseQuantities und den Schichten
// des Dachtyps als IfcMaterialLayerSetUsage (AXIS3, NEGATIVE). Teile: `roof/<id>/p<plane>` bzw. `roof/<id>/part<k>`;
// OPENING_SOLID mit Wirt `roof/<id>` sitzt im ersten Teil, mit `roof/<id>/p<plane>` in dieser Fläche.
// COLUMN = 10, structure, id, label, PTS, z_rel, depth, component_id (−1 = keine), component_name, PSETS
// COLUMN_PIECES = 20, structure, id, label, n, (PTS, z_rel, depth) × n, component_id (−1 = keine),
// component_name, PSETS ([141] Stütze mit Höhenabschnitten, je Abschnitt ein eigenes beschnittenes
@@ -379,6 +384,7 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
spaces: Vec::new(),
column_materials: Vec::new(),
elements: HashMap::new(),
void_alias: HashMap::new(),
fill_styles: Vec::new(),
};
let v2 = schema == Schema::Ifc2x3;
@@ -848,7 +854,13 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
}
let host_entity = match host.strip_prefix("wall/") {
Some(id) => w.walls.get(id).map(|x| x.0),
None => w.elements.get(&host).copied(),
None => w
.elements
.get(&host)
.or_else(|| w.void_alias.get(&host))
// `roof/<id>/p<n>` ohne diese Fläche (verschnittenes Dach): erster Teil des Dachs.
.or_else(|| host.rsplit_once("/p").and_then(|(roof, n)| n.parse::<u32>().ok().and_then(|_| w.void_alias.get(roof))))
.copied(),
};
let Some(host_entity) = host_entity else { continue };
let parent = w.placement_of(structure);
@@ -1169,9 +1181,46 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
let predefined = r.string()?;
let ty = r.type_ref()?;
let psets = r.psets()?;
let mesh = r.mesh()?;
let (placement, shape) = w.emit_triangulated_product(&mesh, w.placement_of(structure));
w.finish_typed("IFCROOF", format!("roof/{id}"), &name, &ty, &psets, structure, placement, shape, Some(enum_(&predefined)), false);
let n_parts = r.idx()?;
// [B5] IfcRoof als Aggregat ohne eigene Darstellung; je Dachfläche (bzw. Sonderteil) ein IfcSlab ROOF mit
// Schichten (IfcMaterialLayerSetUsage), Pset_SlabCommon und Qto_SlabBaseQuantities.
let placement = w.emit_placement(0.0, w.placement_of(structure));
let roof_key = format!("roof/{id}");
let roof_guid = w.gid(&roof_key);
let roof_entity = w.finish_aggregate("IFCROOF", roof_key.clone(), &name, &ty, &psets, structure, placement, enum_(&predefined));
let set = ty.as_ref().and_then(|t| w.layer_set_of(t));
let mut slabs = Vec::new();
for _ in 0..n_parts {
let part_name = r.string()?;
let plane = r.raw()?;
let part_psets = r.psets()?;
let mesh = r.mesh()?;
let (part_placement, shape) = w.emit_triangulated_product(&mesh, placement);
let key = if plane >= 0.0 { format!("{roof_key}/p{}", plane as i64) } else { format!("{roof_key}/part{}", slabs.len()) };
// GlobalId aus der des Dachs (stabil auch nach Import → Export, wo die Dach-id eine andere ist).
let guid = ifc_string(&ifc_guid(&format!("{roof_guid}/{}", key.rsplit('/').next().unwrap_or(""))));
let slab = w.emit_building_element("IFCSLAB", guid, &part_name, part_placement, shape, Some(enum_("ROOF")));
for p in &part_psets {
w.add_pset(p, slab, &key);
}
w.elements.insert(key, slab);
slabs.push(slab);
}
if let Some(&first) = slabs.first() {
// Dachfenster ohne Flächenangabe (verschnittenes Dach) sitzen im ersten Teil.
w.void_alias.insert(roof_key.clone(), first);
let g = w.gid(&format!("aggregates/{roof_key}"));
w.add("IFCRELAGGREGATES", format!("{g},#{},$,$,#{roof_entity},{}", w.owner_history, refs(&slabs)));
if let Some(set) = set {
// Schichten von aussen (oben) nach innen: Dickenrichtung = lokale Z-Achse, abwärts.
let u = w.add(
"IFCMATERIALLAYERSETUSAGE",
format!("#{set},{},{},0.{}", enum_("AXIS3"), enum_("NEGATIVE"), if v2 { "" } else { ",$" }),
);
let g = w.gid(&format!("{roof_key}/material"));
w.add("IFCRELASSOCIATESMATERIAL", format!("{g},#{},$,$,{},#{u}", w.owner_history, refs(&slabs)));
}
}
}
c if c == REC_COLUMN || c == REC_COLUMN_PIECES || c == REC_BEAM => {
let structure = r.structure(n_storeys)?;
@@ -1244,12 +1293,21 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
continue; // ohne Code keine Referenz
}
let Some(&entity) = w.elements.get(&key) else { continue };
if let Some((_, _, v)) = by_code.iter_mut().find(|(c, _, _)| *c == code) {
if !v.contains(&entity) {
v.push(entity);
// [B5] Dach: auch die Dachflächen (Teile des IfcRoof) tragen die Klassifikation (Leser erben nicht).
let mut targets = vec![entity];
if key.starts_with("roof/") {
let mut parts: Vec<(&String, usize)> = w.elements.iter().filter(|(k, _)| k.strip_prefix(&format!("{key}/")).is_some_and(|t| t.starts_with('p'))).map(|(k, v)| (k, *v)).collect();
parts.sort();
targets.extend(parts.into_iter().map(|x| x.1));
}
for entity in targets {
if let Some((_, _, v)) = by_code.iter_mut().find(|(c, _, _)| *c == code) {
if !v.contains(&entity) {
v.push(entity);
}
} else {
by_code.push((code.clone(), ref_name.clone(), vec![entity]));
}
} else {
by_code.push((code, ref_name, vec![entity]));
}
}
if !by_code.is_empty() {
+28 -8
View File
@@ -284,6 +284,11 @@ fn full_house_in(mut b: B, with_geo: bool) -> B {
b.str("Beton");
b.n(&[0.3]);
b.ref_pset("Pset_RoofCommon", "Satteldach");
// [B5] Teile: eine Dachfläche (Index 0) mit Pset_SlabCommon.
b.n(&[1.0]);
b.str("Satteldach 1");
b.n(&[0.0]);
b.ref_pset("Pset_SlabCommon", "Satteldach");
b.mesh_tetra();
// Stütze mit Material.
b.n(&[REC_COLUMN, 0.0]);
@@ -354,7 +359,7 @@ fn volles_haus_ist_wohlgeformt() {
assert!(ifc.is_ascii(), "Datei muss reines ASCII sein");
check_structure(&ifc);
assert_eq!(count(&ifc, "IFCWALL"), 2);
assert_eq!(count(&ifc, "IFCSLAB"), 1);
assert_eq!(count(&ifc, "IFCSLAB"), 2); // Decke + Dachfläche des Dachs
assert_eq!(count(&ifc, "IFCROOF"), 1);
assert_eq!(count(&ifc, "IFCCOLUMN"), 1);
assert_eq!(count(&ifc, "IFCSTAIR"), 1);
@@ -376,11 +381,17 @@ fn volles_haus_ist_wohlgeformt() {
assert_eq!(count(&ifc, "IFCMATERIALLAYERSET"), 2); // Wandtyp + Dachtyp
assert_eq!(count(&ifc, "IFCMATERIAL"), 2); // Beton (geteilt mit Dachtyp und Stütze) + Dämmung
assert_eq!(count(&ifc, "IFCRELDEFINESBYTYPE"), 2);
assert_eq!(count(&ifc, "IFCPROPERTYSET"), 5); // Wall, Space, Roof, Column + CH_Raum (Tür ohne Pset)
assert_eq!(count(&ifc, "IFCPROPERTYSET"), 6); // Wall, Space, Roof, SlabCommon der Dachfläche, Column + CH_Raum (Tür ohne Pset)
// Eingliederung: Geschoss (Wände, Decke, Treppe, Tür, Dach, Stütze) und Gebäude (Extrusion).
assert_eq!(count(&ifc, "IFCRELCONTAINEDINSPATIALSTRUCTURE"), 2);
// Project→Site, Site→Building, Building→Storeys, Geschoss→Räume.
assert_eq!(count(&ifc, "IFCRELAGGREGATES"), 4);
// Project→Site, Site→Building, Building→Storeys, Geschoss→Räume, Dach→Dachfläche.
assert_eq!(count(&ifc, "IFCRELAGGREGATES"), 5);
// [B5] Dach als Aggregat: IfcRoof ohne Darstellung, darunter IfcSlab ROOF mit den Schichten des Dachtyps.
let roof = first_line(&ifc, "IFCROOF");
assert!(roof.ends_with(",$,$,.GABLE_ROOF.);"), "{roof}");
assert!(first_line(&ifc, "IFCRELAGGREGATES").len() > 0);
assert!(ifc.lines().any(|l| l.contains("=IFCSLAB(") && l.ends_with(".ROOF.);")), "IfcSlab ROOF");
assert!(ifc.lines().any(|l| l.contains("=IFCMATERIALLAYERSETUSAGE(") && l.ends_with(".AXIS3.,.NEGATIVE.,0.,$);")));
}
/// Zeile der ersten Entität eines Typs.
@@ -581,7 +592,7 @@ fn wand_mit_achse_und_layer_set_usage() {
let ifc = build(&full_house(false)).unwrap();
check_structure(&ifc);
// Nur W1 hat Wandsystem: eine Usage, eine Axis-Darstellung, ein Axis-Kontext.
assert_eq!(count(&ifc, "IFCMATERIALLAYERSETUSAGE"), 1);
assert_eq!(count(&ifc, "IFCMATERIALLAYERSETUSAGE"), 2); // Wand W1 + Dachflächen
assert_eq!(count(&ifc, "IFCGEOMETRICREPRESENTATIONSUBCONTEXT"), 1);
let usage = first_line(&ifc, "IFCMATERIALLAYERSETUSAGE");
assert!(usage.contains(".AXIS2.,.POSITIVE.,-0.2,$"), "{usage}");
@@ -954,8 +965,9 @@ fn ifc2x3_kopf_und_entitaeten() {
// W1 hat Achse + Usage (StandardCase), W2 nicht (IfcWall).
assert_eq!(count(&ifc, "IFCWALLSTANDARDCASE"), 1);
assert_eq!(count(&ifc, "IFCWALL"), 1);
assert_eq!(count(&ifc, "IFCMATERIALLAYERSETUSAGE"), 1);
assert_eq!(count(&ifc, "IFCMATERIALLAYERSETUSAGE"), 2); // Wand + Dachflächen (IFC2x3: keine ReferenceExtent)
assert!(first_line(&ifc, "IFCMATERIALLAYERSETUSAGE").ends_with(".AXIS2.,.POSITIVE.,-0.2);"));
assert!(ifc.lines().any(|l| l.contains("=IFCMATERIALLAYERSETUSAGE(") && l.ends_with(".AXIS3.,.NEGATIVE.,0.);")));
// Wand ohne PredefinedType (8 Attribute), Stütze ebenso.
assert!(first_line(&ifc, "IFCWALL").ends_with(",$);") && first_line(&ifc, "IFCWALL").matches(',').count() == 7, "{}", first_line(&ifc, "IFCWALL"));
assert!(first_line(&ifc, "IFCCOLUMN").ends_with(",$);"), "{}", first_line(&ifc, "IFCCOLUMN"));
@@ -979,7 +991,7 @@ fn ifc2x3_kopf_und_entitaeten() {
assert_eq!(count(&ifc, "IFCFACE"), 4);
assert_eq!(count(&ifc, "IFCPOLYLOOP"), 4);
assert!(ifc.contains("'Body','Brep'"));
assert_eq!(count(&ifc, "IFCRELASSOCIATESMATERIAL"), 4); // Wandtyp, Usage, Dachschichten, Stütze
assert_eq!(count(&ifc, "IFCRELASSOCIATESMATERIAL"), 5); // Wandtyp, Usage, Dachschichten (am Dach), Usage der Dachflächen, Stütze
// Stile der Teilrollen über IfcPresentationStyleAssignment.
assert_eq!(count(&ifc, "IFCPRESENTATIONSTYLEASSIGNMENT"), 3);
// Mengen ohne Formula.
@@ -1037,6 +1049,10 @@ fn dachfenster_oeffnungskoerper() {
b.str("GABLE_ROOF");
b.no_type();
b.no_psets();
b.n(&[1.0]);
b.str("Dachfläche 1");
b.n(&[0.0]);
b.no_psets();
b.n(&[4.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0]);
b.n(&[2.0, 0.0, 1.0, 2.0, 0.0, 2.0, 3.0]);
b.f.push(0.0);
@@ -1081,6 +1097,10 @@ fn ifc2x3_offenes_netz_ist_shell_based_surface_model() {
b.str("FLAT_ROOF");
b.no_type();
b.no_psets();
b.n(&[1.0]);
b.str("Dachfläche 1");
b.n(&[0.0]);
b.no_psets();
// Zwei Dreiecke (offen) plus ein entartetes (doppelte Ecke).
b.n(&[4.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0]);
b.n(&[3.0, 0.0, 1.0, 2.0, 0.0, 2.0, 3.0, 0.0, 0.0, 1.0]);
@@ -1090,7 +1110,7 @@ fn ifc2x3_offenes_netz_ist_shell_based_surface_model() {
assert_eq!(count(&ifc, "IFCSHELLBASEDSURFACEMODEL"), 1);
assert_eq!(count(&ifc, "IFCOPENSHELL"), 1);
assert_eq!(count(&ifc, "IFCFACE"), 2);
assert_eq!(count(&ifc, "IFCCARTESIANPOINT"), 6); // Ursprung, 4 Ecken (je einmal), Placement
assert_eq!(count(&ifc, "IFCCARTESIANPOINT"), 7); // Ursprung, 4 Ecken (je einmal), 2 Placements (Dach, Dachfläche)
assert!(ifc.contains("'Body','SurfaceModel'"));
assert_eq!(count(&ifc, "IFCFACETEDBREP"), 0);
}
+3 -2
View File
@@ -123,9 +123,10 @@ describe("Rundreise Export → Import", () => {
const ifc = exportIfcSpf(sampleProject, { ebkph: true });
const bytes = new TextEncoder().encode(ifc);
const { products } = await inspectIfc(bytes);
expect(products.find((p) => p.ifcClass === "IfcRoof")?.classifications?.[0]).toMatchObject({ system: "eBKP-H", code: "F" });
// [B5] Das Dach ist ein IfcRoof-Aggregat ohne Körper: die Dachflächen (IfcSlab ROOF) erben die Klassifikation.
expect(products.find((p) => p.ifcClass === "IfcSlab" && p.classifications?.[0]?.code === "F")?.classifications?.[0]).toMatchObject({ system: "eBKP-H", code: "F" });
const r = await importIfcInto(sampleProject, bytes, { group: "product" });
const roof = r.meshes.find((m) => m.source === "IFC IfcRoof")!;
const roof = r.meshes.find((m) => / \[eBKP-H F\]$/.test(m.name))!;
expect(roof.name).toMatch(/ \[eBKP-H F\]$/);
// Ohne Klassifikation kein Zusatz.
expect(r.meshes.find((m) => m.source === "IFC IfcStairFlight")?.name).not.toMatch(/\[/);
+11 -3
View File
@@ -89,7 +89,7 @@ for el in m.by_type("IfcElement"):
g = shape.geometry
v = np.array(g.verts).reshape(-1, 3)
item["zExtent"] = float(v[:, 2].max() - v[:, 2].min())
if el.is_a("IfcSlab"):
if el.is_a("IfcSlab") and el.PredefinedType != "ROOF":
prof = [r for r in el.Representation.Representations if r.RepresentationIdentifier == "Body"][0].Items[0].SweptArea
holes = []
if prof.is_a("IfcArbitraryProfileDefWithVoids"):
@@ -215,11 +215,19 @@ describe.skipIf(!hasIfcOpenShell)("Basismengen gegen ifcopenshell", { timeout: 1
});
it("Dach: Grundrissprojektion und geneigte Fläche = nach oben zeigende Netz-Dreiecke", () => {
// [B5] IfcRoof ist Aggregat ohne Darstellung; die Dachflächen (IfcSlab ROOF) tragen die Netze.
const [roof] = of("IfcRoof");
const parts = of("IfcSlab").filter((s) => s.predefined === "ROOF");
expect(parts.length).toBeGreaterThan(0);
const q = qof(roof, "Qto_RoofBaseQuantities");
close(q.GrossArea, roof.up![0]);
close(q.ProjectedArea, roof.up![1]);
close(q.GrossArea, parts.reduce((a, s) => a + s.up![0], 0));
close(q.ProjectedArea, parts.reduce((a, s) => a + s.up![1], 0));
expect(q.GrossArea).toBeGreaterThan(q.ProjectedArea);
for (const s of parts) {
const qs = qof(s, "Qto_SlabBaseQuantities");
close(qs.NetVolume, s.volume!);
close(qs.GrossArea, s.up![0]);
}
});
it("Stütze: Volumen, Querschnitt × Länge", () => {
+28
View File
@@ -394,4 +394,32 @@ print(json.dumps({"n": len(c), "solids": len(body.Items), "volume": us.get_volum
const glassVol = d.items.filter((i) => i.styles[0] === "Glas").reduce((a, i) => a + i.volume, 0);
expect(glassVol).toBeCloseTo(2 * leafArea * 0.5 * 0.024, 6);
});
it("[B5] Dächer als IfcRoof-Aggregat mit IfcSlab ROOF je Dachfläche (IFC4 und IFC2x3), Schema gültig", () => {
const PY = `
import sys, json, ifcopenshell
m = ifcopenshell.open(sys.argv[1])
out = []
for r in m.by_type("IfcRoof"):
kids = [o for rel in r.IsDecomposedBy for o in rel.RelatedObjects]
out.append({"pre": getattr(r, "PredefinedType", None) or r.ShapeType, "rep": r.Representation is not None,
"kids": [[k.is_a(), k.PredefinedType, k.Representation is not None, any(a.is_a("IfcRelAssociatesMaterial") and a.RelatingMaterial.is_a("IfcMaterialLayerSetUsage") for a in k.HasAssociations)] for k in kids]})
print(json.dumps(out))
`;
const typed = { ...sampleProject, roofs: sampleProject.roofs!.map((r) => ({ ...r, roofTypeId: "roof-warm" })) } as Project;
for (const schema of ["IFC4", "IFC2X3"] as const) {
const ifc = exportIfcSpf(typed, { schema });
const file = writeIfc(`dach-${schema}`, ifc);
const r = spawnSync("python3", ["-c", PY, file], { encoding: "utf8" });
const roofs = JSON.parse(r.stdout) as { pre: string; rep: boolean; kids: [string, string, boolean, boolean][] }[];
expect(roofs.length).toBe(sampleProject.roofs!.length);
for (const roof of roofs) {
expect(roof.rep).toBe(false);
expect(roof.kids.length).toBeGreaterThan(0);
for (const k of roof.kids) expect(k).toEqual(["IfcSlab", "ROOF", true, true]);
}
const v = validate(`dach-${schema}`, ifc);
expect(v.out).toContain("0 Befunde");
expect(v.status).toBe(0);
}
}, 240_000);
});
+4 -2
View File
@@ -43,7 +43,8 @@ function exportedCounts(ifc: string): Map<string, number> {
const m = new Map<string, number>();
for (const cls of ["IFCWALL", "IFCSLAB", "IFCROOF", "IFCDOOR", "IFCWINDOW", "IFCSTAIRFLIGHT", "IFCRAILING", "IFCCOLUMN", "IFCBUILDINGELEMENTPROXY"]) {
const n = (ifc.match(new RegExp(`^#\\d+=${cls}\\(`, "gm")) ?? []).length;
if (n) m.set(cls, n);
// [B5] Das Dach ist ein Aggregat ohne Körper (kein Produkt im Mesh-Import); seine IfcSlab ROOF zählen als Platten.
if (n && cls !== "IFCROOF") m.set(cls, n);
}
return m;
}
@@ -106,7 +107,8 @@ describe("IFC-Import: Rundreise mit dem eigenen Export", () => {
return Math.abs(polygonArea(c.outline)) * Math.max(zTop - zBottom, 0.001);
})
.sort((a, b) => a - b);
const slabsGot = products.filter((p) => p.ifcClass === "IfcSlab").map(vol).sort((a, b) => a - b);
const roofSlabs = new Set((sampleProject.roofs ?? []).length ? products.filter((p) => p.ifcClass === "IfcSlab" && /Dach/.test(p.name ?? "")).map((p) => p.globalId) : []);
const slabsGot = products.filter((p) => p.ifcClass === "IfcSlab" && !roofSlabs.has(p.globalId)).map(vol).sort((a, b) => a - b);
expect(slabsGot.length).toBe(slabsExpected.length);
slabsGot.forEach((v, i) => expect(relClose(v, slabsExpected[i], 1e-6), `${v} ≠ ${slabsExpected[i]}`).toBe(true));
});