diff --git a/TODO.md b/TODO.md index 20206316..c9c83327 100644 --- a/TODO.md +++ b/TODO.md @@ -53,9 +53,10 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* - ◐ **[141]** Wandecken. 9.11.: Wand und Stütze überlappen nicht mehr — runde Stütze an der Kontur, Wand durch bzw. breiter als die Stütze, Stütze kürzer als die Wand (3D: `model3d::carve_at_columns`, Streifen an den Konturkanten; Grundriss: `wall_columns::carve_walls_under_columns`, Stütze unter der Schnitthöhe als Ansichtskante), - Längsschnitt in einer Wand zeigt die getroffene Schicht (`split_layers_along`). Offen: IFC-Profil je - Höhenabschnitt einer beschnittenen Stütze (Satz `REC_COLUMN` trägt nur eine Extrusion, Änderung in - `fileio/ifc_export.rs` nötig); Längsschnitt ohne Anschlag-Nasen/Schichteinzug; Muster bei ungeraden Maschen; + Längsschnitt in einer Wand zeigt die getroffene Schicht (`split_layers_along`). IFC (9.11.): Stütze mit + mehreren Höhenabschnitten (`column_pieces`) als Satz `COLUMN_PIECES` (20) → EIN IfcColumn mit je einer + Extrusion pro Abschnitt in einer SweptSolid-Darstellung, Menge = Summe (`column_pieces_quantities`); ein + Abschnitt bleibt `COLUMN` (10). Offen: Längsschnitt ohne Anschlag-Nasen/Schichteinzug; Muster bei ungeraden Maschen; Schnitt genau in einer Wand-Stirnfläche: Lücke in der Projektionskante über den Streifen. · M - ◐ **[145]** Texte beim Zoomen synchron. Falls der Mac noch nachläuft: Raumstempel nativ zeichnen (vtext kann nur einzeilig/linksbündig, eine Schrift, kein Fett). 9.11.: `clampInside` nur noch im Kern (`grip_clamp_inside`, diff --git a/doc/ARCHITEKTUR.md b/doc/ARCHITEKTUR.md index 2f7b7b42..3d263f78 100644 --- a/doc/ARCHITEKTUR.md +++ b/doc/ARCHITEKTUR.md @@ -385,7 +385,8 @@ Es gibt drei Schatten, alle aus derselben Sonnenstudie (`Project.sunStudy`, Ort 1. `src/export/exportIfc.ts` fragt `queryBin("ifcExportData", …)`. Im Kern sammelt `ifc_export_data()` (`src-tauri/core/src/ifc_data.rs`) Wand-Bänder, Öffnungen, Treppen (`ifc_stairs.rs`), Dach-Netze, Räume, Basismengen (`ifc_quantities.rs`), Klassifikation und - Georeferenz in einen Export-Puffer (`export_flat.rs`). + Georeferenz in einen Export-Puffer (`export_flat.rs`). Stützen mit mehreren Höhenabschnitten + ([141], `model3d::column_pieces`) gehen als Satz `COLUMN_PIECES` (eine Extrusion je Abschnitt) hinüber. 2. `fileio` schreibt daraus die Datei: `export_ifc_flat()` in `src-tauri/fileio/src/ifc_export/mod.rs` (Entitäten, GUIDs, Typen mit Materialschichten, Psets, Beziehungen), Öffnungs-Geometrie in `ifc_openings.rs`. diff --git a/src-tauri/core/src/ifc_data.rs b/src-tauri/core/src/ifc_data.rs index 3ce992db..ce23faf6 100644 --- a/src-tauri/core/src/ifc_data.rs +++ b/src-tauri/core/src/ifc_data.rs @@ -51,6 +51,7 @@ const REC_WALL_ARC: f64 = 16.0; const REC_WALL_ARC_SOLID: f64 = 17.0; const REC_GRID: f64 = 18.0; const REC_TREE: f64 = 19.0; +const REC_COLUMN_PIECES: f64 = 20.0; /// Toleranz des Kerns (`wall_bands.rs::EPS`) für „Öffnung trifft Band". const BAND_EPS: f64 = 1e-4; @@ -1352,36 +1353,49 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result // ── Stützen → IfcColumn (Profil-Extrusion, Material = Bauteil) ────────── for col in p.columns.as_deref().unwrap_or(&[]) { - // [141] Von einer prioritäreren Wand beschnitten: Querschnitt ohne das Wandband (wie im 3D), wenn - // die Aussparung über die ganze Höhe geht (ein Abschnitt); sonst der volle Querschnitt. - let (footprint, z_bottom, z_top) = match model3d::column_pieces(&p, col).as_slice() { - [one] => one.clone(), - _ => { - let (zb, zt) = p.column_vertical_extent(col); - (model3d::column_footprint(col), zb, zt) - } + // [141] Von einer prioritäreren Wand beschnitten: je Höhenabschnitt ein eigenes Profil (wie im 3D), + // als Datensatz COLUMN_PIECES mit mehreren Extrusionen in einer Darstellung; ein Abschnitt = COLUMN. + let pieces: Vec<(Vec, f64, f64)> = model3d::column_pieces(&p, col).into_iter().filter(|(fp, zb, zt)| fp.len() >= 3 && zt > zb).collect(); + let pieces = if pieces.is_empty() { + let (zb, zt) = p.column_vertical_extent(col); + vec![(model3d::column_footprint(col), zb, zt)] + } else { + pieces }; - if footprint.len() < 3 { - continue; - } - if !(z_top > z_bottom) { + let z_bottom = pieces.iter().fold(f64::INFINITY, |m, q| m.min(q.1)); + let z_top = pieces.iter().fold(f64::NEG_INFINITY, |m, q| m.max(q.2)); + if pieces.iter().any(|(fp, zb, zt)| fp.len() < 3 || !(zt > zb)) { continue; } let structure = structure_of(&col.floor_id); classified.push((format!("column/{}", col.id), Kind::Column, col.category_code.clone())); let label = crate::plan::domains::column_label(col); let mut psets = vec![Pset { name: "Pset_ColumnCommon", props: vec![ident("Reference", &label)] }]; - psets.extend(qto("Qto_ColumnBaseQuantities", qty::column_quantities(&footprint, z_top - z_bottom))); + let quantities = if let [(footprint, zb, zt)] = pieces.as_slice() { + qty::column_quantities(footprint, zt - zb) + } else { + qty::column_pieces_quantities(&pieces) + }; + psets.extend(qto("Qto_ColumnBaseQuantities", quantities)); let (id, lab) = (f.str(&col.id), f.str(&label)); - f.nums(&[REC_COLUMN, structure, id, lab]); - w_pts(&mut f, &footprint); + if let [(footprint, _, _)] = pieces.as_slice() { + f.nums(&[REC_COLUMN, structure, id, lab]); + w_pts(&mut f, footprint); + f.nums(&[z_bottom - base_of(structure), z_top - z_bottom]); + } else { + f.nums(&[REC_COLUMN_PIECES, structure, id, lab, pieces.len() as f64]); + for (footprint, zb, zt) in &pieces { + w_pts(&mut f, footprint); + f.nums(&[zb - base_of(structure), zt - zb]); + } + } let comp = col.component_id.as_deref().filter(|s| !s.is_empty()); let cid = comp.map_or(-1.0, |c| f.str(c)); let cname = comp.map_or(-1.0, |c| { let n = component_name(&p, c); f.str(&n) }); - f.nums(&[z_bottom - base_of(structure), z_top - z_bottom, cid, cname]); + f.nums(&[cid, cname]); w_psets(&mut f, &psets); } f.num(REC_END_COLUMNS); diff --git a/src-tauri/core/src/ifc_quantities.rs b/src-tauri/core/src/ifc_quantities.rs index aabce04b..6a30b17c 100644 --- a/src-tauri/core/src/ifc_quantities.rs +++ b/src-tauri/core/src/ifc_quantities.rs @@ -282,6 +282,35 @@ pub fn column_quantities(footprint: &[Vec2], length: f64) -> Vec { ] } +/// [141] Basismengen einer in Höhenabschnitte geteilten Stütze (`model3d::column_pieces`): Länge = Gesamthöhe, +/// Volumen und Mantel = Summe der Abschnitte, Querschnitt = grösster Abschnitt, Deckel nur an der Unter- und +/// Oberkante der Stütze (die Fugen zwischen den Abschnitten sind innen). +pub fn column_pieces_quantities(pieces: &[(Vec, f64, f64)]) -> Vec { + let z0 = pieces.iter().fold(f64::INFINITY, |m, p| m.min(p.1)); + let z1 = pieces.iter().fold(f64::NEG_INFINITY, |m, p| m.max(p.2)); + let (mut cross, mut outer, mut caps, mut volume) = (0.0f64, 0.0, 0.0, 0.0); + for (ring, b, t) in pieces { + let a = ring_area(ring); + cross = cross.max(a); + outer += ring_perimeter(ring) * (t - b); + volume += a * (t - b); + if (b - z0).abs() < 1e-6 { + caps += a; + } + if (t - z1).abs() < 1e-6 { + caps += a; + } + } + vec![ + len("Length", z1 - z0), + area("CrossSectionArea", cross), + area("OuterSurfaceArea", outer), + area("NetSurfaceArea", outer + caps), + vol("GrossVolume", volume), + vol("NetVolume", volume), + ] +} + /// Tür-/Fenster-Basismengen (lichte Öffnung): Breite, Höhe, Umfang, Fläche. pub fn opening_quantities(width: f64, height: f64) -> Vec { let w = clean(width); diff --git a/src-tauri/core/src/wall_join3d_tests.rs b/src-tauri/core/src/wall_join3d_tests.rs index cc4eb300..ef413c32 100644 --- a/src-tauri/core/src/wall_join3d_tests.rs +++ b/src-tauri/core/src/wall_join3d_tests.rs @@ -429,3 +429,38 @@ fn laengsschnitt_in_der_wand_zeigt_die_getroffene_schicht() { } + +/// [141] Wand (Beton) nur 1.5 m hoch, Backsteinstütze 2.6 m: unten das beschnittene Profil (U-Form), oben der +/// volle Querschnitt. Der IFC-Export schreibt EINEN Datensatz COLUMN_PIECES mit zwei Profilen; die Menge +/// (Volumen) ist die Summe der Abschnitte. +#[test] +fn stuetze_mit_hoehenabschnitten_im_ifc() { + use crate::ifc_data::{ifc_export_data, IfcOptions}; + let mut p = base(); + add_wall(&mut p, "bw", (0.0, 0.0), (3.0, 0.0)); + p.walls[0].height = 1.5; + add_column(&mut p, "C", (3.0, 0.0), ColumnProfile::Rect { width: 0.3, depth: 0.3 }, Some("brick")); + let pieces = model3d::column_pieces(&p, &p.columns.as_ref().unwrap()[0]); + assert_eq!(pieces.len(), 2, "{pieces:?}"); + let vol: f64 = pieces.iter().map(|(fp, z0, z1)| ring_area(&fp.iter().map(|v| [v.x, v.y]).collect::>()) * (z1 - z0)).sum(); + let want = (0.09 - 0.15 * 0.2) * 1.5 + 0.09 * 1.1; + assert!((vol - want).abs() < 1e-6, "{vol} ≠ {want}"); + let f = ifc_export_data(&p, &IfcOptions::default()).unwrap(); + // Datensatz 20 (COLUMN_PIECES) zwischen Wandsätzen: Anzahl Abschnitte steht an Position +4. + let has = f.nums.windows(5).any(|w| w[0] == 20.0 && w[4] == 2.0); + assert!(has, "COLUMN_PIECES mit 2 Abschnitten"); + // Menge im Pset: NetVolume = Summe. + let net = f.nums.iter().any(|v| (v - want).abs() < 1e-6); + assert!(net, "NetVolume = {want}"); +} + +/// Eine nicht geteilte Stütze bleibt beim Datensatz COLUMN (rückwärtskompatibel). +#[test] +fn stuetze_ohne_abschnitte_bleibt_column() { + use crate::ifc_data::{ifc_export_data, IfcOptions}; + let mut p = base(); + add_column(&mut p, "C", (3.0, 0.0), ColumnProfile::Rect { width: 0.3, depth: 0.3 }, Some("brick")); + let f = ifc_export_data(&p, &IfcOptions::default()).unwrap(); + assert!(f.nums.contains(&10.0)); + assert!(!f.nums.windows(5).any(|w| w[0] == 20.0 && w[4] == 2.0)); +} diff --git a/src-tauri/fileio/src/ifc_export/builder.rs b/src-tauri/fileio/src/ifc_export/builder.rs index 72a24cd4..e1f170ea 100644 --- a/src-tauri/fileio/src/ifc_export/builder.rs +++ b/src-tauri/fileio/src/ifc_export/builder.rs @@ -261,6 +261,16 @@ impl Builder { (placement, shape) } + /// [141] Mehrere Extrusionen (je Höhenabschnitt ein Profil `(Profil, z_rel, Tiefe)`) in EINER SweptSolid- + /// Darstellung; das Placement liegt auf dem tiefsten Abschnitt, die übrigen sitzen als Versatz der Extrusion. + pub(super) fn emit_pieces_product(&mut self, pieces: &[(Vec<(f64, f64)>, f64, f64)], relative_to: usize) -> (usize, usize) { + let z0 = pieces.iter().fold(f64::INFINITY, |m, p| m.min(p.1)); + let solids: Vec = pieces.iter().map(|(fp, z, d)| self.emit_extrusion_voids(fp, &[], z - z0, *d)).collect(); + let shape = self.emit_swept_shape(&solids); + let placement = self.emit_placement(z0, relative_to); + (placement, shape) + } + /// Dreiecks-Mesh als IfcTriangulatedFaceSet (IFC2x3: IfcFacetedBrep bzw. IfcShellBasedSurfaceModel) + /// Shape + Placement (Punkte tragen die Geometrie absolut im Rahmen der Trägerstruktur). pub(super) fn emit_triangulated_product(&mut self, mesh: &Mesh, relative_to: usize) -> (usize, usize) { diff --git a/src-tauri/fileio/src/ifc_export/mod.rs b/src-tauri/fileio/src/ifc_export/mod.rs index dad68dd9..ca76acf2 100644 --- a/src-tauri/fileio/src/ifc_export/mod.rs +++ b/src-tauri/fileio/src/ifc_export/mod.rs @@ -81,6 +81,10 @@ // END_SPACES = 8 (bündelt die Räume je Geschoss zu IfcRelAggregates) // ROOF = 9, structure, id, name, predefined (Text), TYPEREF, PSETS, MESH // 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 +// Profil; EIN IfcColumn mit n Extrusionen in einer SweptSolid-Darstellung, Placement auf dem tiefsten +// Abschnitt; Material und Materialzuordnung wie COLUMN; die Mengen stehen fertig in PSETS) // END_COLUMNS = 11 (Materialzuordnung der Stützen) // CLASSIFICATION = 12, name, source, edition (Text, leer = keine), n_refs, (key, code, ref_name) × n_refs // ([B5], 28.10.) Ein Klassifikationssystem (IfcClassification) mit je Code einer @@ -147,6 +151,7 @@ pub const REC_WALL_ARC: f64 = 16.0; pub const REC_WALL_ARC_SOLID: f64 = 17.0; pub const REC_GRID: f64 = 18.0; pub const REC_TREE: f64 = 19.0; +pub const REC_COLUMN_PIECES: f64 = 20.0; mod format; mod reader; @@ -175,6 +180,7 @@ fn rec_name(code: f64) -> &'static str { c if c == REC_ATTACH => "ATTACH", c if c == REC_GRID => "GRID", c if c == REC_TREE => "TREE", + c if c == REC_COLUMN_PIECES => "COLUMN_PIECES", _ => "?", } } @@ -937,17 +943,33 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result { 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); } - c if c == REC_COLUMN => { + c if c == REC_COLUMN || c == REC_COLUMN_PIECES => { let structure = r.structure(n_storeys)?; let id = r.string()?; let label = r.string()?; - let pts = r.pts()?; - let z_rel = r.f()?; - let depth = r.f()?; + let pieces: Vec<(Vec<(f64, f64)>, f64, f64)> = if c == REC_COLUMN { + let pts = r.pts()?; + vec![(pts, r.f()?, r.f()?)] + } else { + let n = r.idx()?; + if n == 0 { + return Err(format!("Stütze ohne Abschnitte bei {}", r.pos - 1)); + } + let mut v = Vec::new(); + for _ in 0..n { + let pts = r.pts()?; + v.push((pts, r.f()?, r.f()?)); + } + v + }; let component = r.opt_string()?; let component_name = r.opt_string()?; let psets = r.psets()?; - let (placement, shape) = w.emit_box_product(&pts, z_rel, depth, w.placement_of(structure)); + let (placement, shape) = if let [(pts, z_rel, depth)] = pieces.as_slice() { + w.emit_box_product(pts, *z_rel, *depth, w.placement_of(structure)) + } else { + w.emit_pieces_product(&pieces, w.placement_of(structure)) + }; let g = w.gid(&format!("column/{id}")); let entity = w.emit_building_element("IFCCOLUMN", g, &label, placement, shape, Some(enum_("COLUMN"))); w.add_to_containment(structure, entity); diff --git a/src-tauri/fileio/src/ifc_export/tests.rs b/src-tauri/fileio/src/ifc_export/tests.rs index 36d7015c..e96b5b1f 100644 --- a/src-tauri/fileio/src/ifc_export/tests.rs +++ b/src-tauri/fileio/src/ifc_export/tests.rs @@ -1224,3 +1224,31 @@ fn kaputte_puffer_ergeben_fehler_nie_panic() { let (f, s) = m.data(); assert!(build_ifc(f, &s).is_err()); } + +/// [141] Stütze mit zwei Höhenabschnitten: EIN IfcColumn, zwei Extrusionen in einer Darstellung; die +/// Mengen (Volumen = Summe) stehen im Qto. +#[test] +fn stuetze_mit_hoehenabschnitten() { + let mut b = mini(); + b.n(&[REC_COLUMN_PIECES, -1.0]); + b.str("C2"); + b.str("Stütze 30"); + b.n(&[2.0]); + b.pts(&SQUARE); + b.n(&[0.0, 1.5]); + b.pts(&SQUARE); + b.n(&[1.5, 1.1]); + b.str("c1"); + b.str("Beton"); + b.qto("Qto_ColumnBaseQuantities", &[("NetVolume", 5.0, 0.27)]); + b.n(&[REC_END_COLUMNS]); + let ifc = build(&b).unwrap(); + check_structure(&ifc); + assert_eq!(count(&ifc, "IFCCOLUMN"), 1); + assert_eq!(count(&ifc, "IFCEXTRUDEDAREASOLID"), 2, "eine Extrusion je Höhenabschnitt"); + assert_eq!(count(&ifc, "IFCSHAPEREPRESENTATION"), 1, "eine Darstellung für beide Extrusionen"); + assert!(ifc.contains("IFCQUANTITYVOLUME('NetVolume'") && ifc.contains("0.27"), "Summenvolumen"); + assert_eq!(count(&ifc, "IFCRELASSOCIATESMATERIAL"), 1); + // Zweiter Abschnitt sitzt 1.5 m über dem ersten. + assert!(ifc.contains("IFCCARTESIANPOINT((0.0,0.0,1.5))"), "Versatz des oberen Abschnitts"); +} diff --git a/src/export/exportIfc.validate.test.ts b/src/export/exportIfc.validate.test.ts index 137f8f38..9fb2c950 100644 --- a/src/export/exportIfc.validate.test.ts +++ b/src/export/exportIfc.validate.test.ts @@ -191,6 +191,35 @@ describe.skipIf(!hasIfcOpenShell)("IFC-Export gegen ifcopenshell", { timeout: 60 expect(r.out).toContain("0 Befunde"); expect(r.status).toBe(0); }); + it("[141] Stütze mit Höhenabschnitten: eine IfcColumn, zwei Extrusionen, Volumen = Summe = Qto", () => { + // Wand (aw, nur 1.5 m hoch) prioritärer als die Putz-Stütze (render-ext): unten beschnittenes Profil, oben voller Querschnitt. + const p = { + ...sampleProject, + walls: [{ id: "W1", type: "wall" as const, floorId: "eg", categoryCode: "20", start: { x: 0, y: 0 }, end: { x: 3, y: 0 }, wallTypeId: "aw", height: 1.5 }], + openings: [], + columns: [{ id: "S1", type: "column" as const, floorId: "eg", categoryCode: "50", position: { x: 3, y: 0 }, profile: { kind: "rect" as const, width: 0.4, depth: 0.4 }, rotation: 0, height: 2.6, componentId: "render-ext" }], + } as unknown as Project; + const ifc = exportIfcSpf(p); + expect(validate("stuetze-abschnitte", ifc).out).toContain("0 Befunde"); + const script = ` +import json, sys +import ifcopenshell, ifcopenshell.geom, ifcopenshell.util.shape as us, ifcopenshell.util.element as ue +m = ifcopenshell.open(sys.argv[1]) +c = m.by_type("IfcColumn") +sh = ifcopenshell.geom.create_shape(ifcopenshell.geom.settings(), c[0]) +body = [r for r in c[0].Representation.Representations if r.RepresentationIdentifier == "Body"][0] +q = ue.get_psets(c[0])["Qto_ColumnBaseQuantities"] +print(json.dumps({"n": len(c), "solids": len(body.Items), "volume": us.get_volume(sh.geometry), "net": q["NetVolume"]})) +`; + const r = spawnSync("python3", ["-c", script, writeIfc("stuetze-abschnitte-q", ifc)], { encoding: "utf8", timeout: 120_000 }); + expect(r.status, r.stderr).toBe(0); + const o = JSON.parse(r.stdout); + expect(o.n).toBe(1); + expect(o.solids).toBeGreaterThanOrEqual(2); + expect(o.volume).toBeCloseTo(o.net, 4); + expect(o.net).toBeLessThan(0.4 * 0.4 * 2.6 - 1e-3); // unten um das Wandband gekürzt + expect(o.net).toBeGreaterThan(0.4 * 0.4 * 1.1); // oben voller Querschnitt + }); it("[B5] Wand als Extrusion mit IfcOpeningElement: Volumen = Wand − Öffnung", () => { const ifc = exportIfcSpf(singleWall(false)); const r = validate("oeffnung", ifc);