Merge branch 'worktree-agent-a916c018860e27cb8' into claude/practical-noether-1hb2s1
This commit is contained in:
17 files changed
+934
-116
No files matched your search
@@ -347,6 +347,23 @@ Kennwort, anonym) als PDF; Austausch mit Fachplanern über DXF/IFC.
|
||||
nicht in der Tauri-App angesehen. · M
|
||||
- Fachplaner-Austausch: DXF/DWG je Geschoss/Schnitt/Ansicht ([200]), IFC mit Räumen/Psets ([201]); Rundreise in Archicad/Revit einmal
|
||||
real prüfen ([C9]).
|
||||
- ◐ **[259]** IFC-Export für Fachplaner (Vorprojekt, 14.11.). Alle drei Beispielprojekte mit ifcopenshell 0.9 geprüft: `validate-ifc.py`
|
||||
0 Befunde, neue inhaltliche Prüfung `scripts/check-ifc-fachplaner.py` (Project → Site → Building → Storey, jedes Bauteil genau einmal
|
||||
eingeordnet, Öffnungen gefüllt und im Geschoss des Wirts, Räume mit Nummer/Name/Psets/Qto/SIA-416, Wandschichten, Mengen ±1 % gegen die
|
||||
Geometrie, Georeferenz) in `src/export/exportIfc.fachplaner.test.ts`. Behoben: (1) Geometrie lag in LV95-Millionen — jetzt lokal,
|
||||
`IfcMapConversion` mit Versatz des Ursprungs und OrthogonalHeight = ±0.00 m ü. M. (`referenceElevationMasl`, = `IfcSite.RefElevation`);
|
||||
(2) Bögen in Decken-/Raumumrissen an der Sehne gespiegelt (Bulge-Vorzeichen Modell ↔ DXF-Sinn) und mit nur kartesischer Trimmung von
|
||||
ifcopenshell als Sehne gelesen — jetzt Punkt + Winkel, PARAMETER (Erker komplex: Raum 51.5 → 57.4 m² = Flächenbilanz); (3) Geschoss-GF
|
||||
war gleich NGF (KGF 0) — jetzt aus der Flächentabelle mit Konstruktionsfläche, dazu GrossHeight/GrossVolume und Gebäudesummen
|
||||
(`Qto_BuildingBaseQuantities`); (4) Wandmengen: Bogenwände (volle Höhe über alle Schichten, +5 bis +23 %) und Formöffnungen (Rechteck statt
|
||||
Umriss) neu; (5) Netz-Wände mit mehreren Bändern bzw. Formöffnungs-Füllkörpern als ein Körper (Manifold), Füllkörper nach aussen gewickelt,
|
||||
Netze verschweisst (kleinere Dateien). Neu: Option „Kontext mitgeben" (Dialog, CLI `--kontext`, Vorgabe aus): Gelände → `IfcGeographicElement`
|
||||
TERRAIN, Netze auf Umgebungsklassen → Proxy „Kontext", am IfcSite. Entscheid: 2D-Objektbibliothek ([253]) wird NICHT exportiert (kein
|
||||
falscher Körper, kein geometrieloses IfcFurniture). Grösse/Zeit (Linux, unter Last): komplex 1.6 MB / 2.5 s, Wettbewerb 0.9 MB / 0.5 s,
|
||||
Stress-Beispiel `sampleProjectBig` 19.8 MB / 5.8 s. **Offen:** nicht in Archicad/Revit/Solibri/BIMcollab geöffnet (Prüfzeile 13.14 in
|
||||
`doc/RELEASE-1.0.md`); Anbauwand OG Ost (komplex, Netz unter dem Pultdach mit Fenster): ifcopenshell scheitert am Abzug der Öffnung
|
||||
(30.4 statt 7.5 m³, als bekannt in der Prüfung); Raumhöhe = Geschosshöhe statt lichter Höhe; keine `IfcPresentationLayerAssignment`
|
||||
(Ebenen nur als Klassifikation); IFC2x3 nur über die bestehenden Tests. · M
|
||||
- ◐ **[255]** Baurecht-Nachweis: Ausnützung gegen Modell als Tabelle (14.11.). Kern `site_proof.rs` (Abfrage `siteProof`) stellt die Vorgaben
|
||||
der Parzelle den Kennzahlen gegenüber: GFZ, AZ, BMZ, ÜZ, GZ (min.), Gesamt-/Fassadenhöhe, Grundfläche ausserhalb Grenzabstand/Baulinie,
|
||||
Gebäudeprofil; je Zeile zulässig · Projekt · Reserve/Überschreitung · erfüllt, fehlende Vorgabe als „—“ (nichts erfunden), dazu Grundlagen
|
||||
|
||||
+13
-8
@@ -47,25 +47,30 @@ Alte `.json`-Projekte bleiben lesbar (Kopf von `src/state/useProjectFileActions.
|
||||
|
||||
## IFC (Export)
|
||||
|
||||
Schema IFC4 (Vorgabe) oder IFC2x3; optional eBKP-H- und Ebenen-Klassifikation. Sammler `ifc_data.rs::ifc_export_data`,
|
||||
Schreiber `fileio/src/ifc_export/mod.rs`, Aufruf `src/export/exportIfc.ts`.
|
||||
Schema IFC4 (Vorgabe) oder IFC2x3; optional eBKP-H- und Ebenen-Klassifikation und Kontext. Sammler `ifc_data.rs::ifc_export_data`,
|
||||
Schreiber `fileio/src/ifc_export/mod.rs`, Aufruf `src/export/exportIfc.ts`. Zielgruppe ([259]): Bauingenieur, HLK-, Kostenplaner —
|
||||
Struktur IfcProject → IfcSite → IfcBuilding → IfcBuildingStorey, jedes Bauteil genau einmal eingeordnet.
|
||||
|
||||
| Modell | Wird zu | Verlust / Vereinfachung | Beleg |
|
||||
|---|---|---|---|
|
||||
| Geschosse (`floor`) | `IfcBuildingStorey`; verwaiste Bauteile am Gebäude | Zeichnungs-Ebenen (`kind: drawing`) fehlen | `ifc_data.rs` (Kopf) |
|
||||
| Geschosse (`floor`) | `IfcBuildingStorey` (Name, Elevation); verwaiste Bauteile am Gebäude. Mengen wie die Flächentabelle: `Qto_BuildingStoreyBaseQuantities` (GF = NGF + Konstruktionsfläche der Wände, NGF, Höhe, GV) und `CH_Qto_SIA416`; Summen am Gebäude (`Qto_BuildingBaseQuantities`) | Zeichnungs-Ebenen (`kind: drawing`) fehlen | `ifc_data.rs` (Kopf), `flaechen::area_table` |
|
||||
| Wände | Extrusion je Schichtband + `IfcOpeningElement`; sonst öffnungsgenaues Netz | Bogenwand: Profil-Extrusion mit Kreisachse, sonst Netz; Wandtyp nur als Materialschichten | `ifc_data.rs::emit_walls`-Abschnitt, Datensätze `WALL_SOLIDS`/`WALL_MESH`/`WALL_ARC_SOLID` |
|
||||
| Decken, Räume | `IfcSlab`, `IfcSpace` (SIA 416, Raumbuch-Psets) | Bögen im Umriss bleiben echte Bögen (`CEILING_ARC`, `SPACE_ARC`) | `ifc_data.rs`, Tests `exportIfc.test.ts` |
|
||||
| Decken, Räume | `IfcSlab` (FLOOR/LANDING), `IfcSpace` (Name = Nummer, LongName = Name, Extrusion über die Geschosshöhe, `Pset_SpaceCommon`, `Qto_SpaceBaseQuantities`, SIA-416-Kategorie in `CH_Raum.SIA416` und als `IfcZone`, Raumbuch-Psets) | Bögen im Umriss bleiben echte Bögen (`CEILING_ARC`, `SPACE_ARC`; vor [259] an der Sehne gespiegelt); Raumhöhe = Geschosshöhe, nicht lichte Höhe | `ifc_data.rs`, Tests `exportIfc.test.ts`, `exportIfc.fachplaner.test.ts` |
|
||||
| Türen, Fenster | `IfcDoor`/`IfcWindow` mit Rahmen, Blatt, Glas als getrennte Körper | nur die im Modell parametrisierten Teile; ohne Teile (Wandöffnung) keine Füllung | `fileio/src/ifc_openings.rs`, Kopf `ifc_export/mod.rs` |
|
||||
| Treppen | `IfcStair` mit Läufen, Podesten, Geländern (`IfcRelAggregates`); Ersatzquader nur ohne Teile | – | `ifc_stairs.rs` |
|
||||
| Dächer | `IfcRoof`, ein Netz je Dach | **Netz statt Parametrik**: Neigung, Typ, Traufe nicht rückholbar | `ifc_data.rs` (Dächer), Datensatz `ROOF` |
|
||||
| Stützen, Bäume, Achsraster, Extrusionskörper | `IfcColumn`, `IfcGeographicElement` (IFC2x3: Proxy), `IfcGrid`, `IfcBuildingElementProxy` | Baum: zwei Netze Stamm + Krone | `ifc_data.rs` |
|
||||
| Psets / Mengen | `Pset_*Common` und `Qto_*BaseQuantities` nur mit **Modellwerten**; `CH_Qto_SIA416`, `Dossier_*` | keine frei definierbaren Eigenschaften | Kopf `ifc_data.rs`, Pset-Namen dort und in `ifc_quantities.rs` |
|
||||
| Georeferenz | ganze Geometrie in LV95, wenn `geoAnchor` gesetzt | – | `geo_rebase`, Kopf `ifc_data.rs` |
|
||||
| Georeferenz | Geometrie **lokal** (Modell-Meter, z 0 = ±0.00); mit `geoAnchor` `IfcMapConversion` auf `IfcProjectedCRS` EPSG:2056 (Eastings/Northings = LV95 des Modell-Ursprungs, OrthogonalHeight = `referenceElevationMasl`, sonst Höhe des Bezugspunkts; = `IfcSite.RefElevation`); IFC2x3: `ePSet_MapConversion` + RefLatitude/-Longitude | keine Drehung (Modell nordausgerichtet). Vor [259] lag die Geometrie in LV95-Millionen (Revit/Archicad warnen) | Kopf `ifc_data.rs`, `ifc_export/mod.rs` |
|
||||
| GUIDs | `ifcGlobalId` des Bauteils, wenn gesetzt (Import, [201]; Wand, Decke, Dach, Stütze, Treppe, Raum, Extrusion, Tür/Fenster); sonst deterministisch aus der Modell-id. Doppelte oder ungültige GlobalIds fallen auf die abgeleitete zurück | Bäume, `IfcOpeningElement` und Beziehungen bleiben abgeleitet | `ifc_data.rs` (Datensatz `GUIDS`), `ifc_export::ifc_guid` |
|
||||
| **Nicht exportiert** | 2D-Zeichnungen (ausser Raster), Texte, Bemassungen, Schraffuren, Layouts/Blätter, Ebenen als Sichtbarkeit, Stifte, Gruppen, Gelände, Netzkörper, Möbel/Blöcke, Ansichtsausschnitte | Im Sammler wird nur über Bauteile iteriert, `context` und `drawings2d` (ausser `Grid`) kommen nicht vor | `ifc_data.rs` (`grep context` leer) |
|
||||
| Kontext (Option „Kontext mitgeben", CLI `--kontext`; Vorgabe aus) | Gelände-Netz → `IfcGeographicElement` TERRAIN, Netze auf Umgebungsklassen (z. B. „12 Gebäude") → `IfcBuildingElementProxy` „Kontext"; am `IfcSite`, Klasse als Description (IFC2x3: beide Proxy) | Höhenlinien, Baugrube, Luftbild nicht; Netze auf Bauteil-Klassen nicht | `ifc_data.rs` (Datensatz `CONTEXT`) |
|
||||
| 2D-Objektbibliothek ([253], `libobj`) | **nicht exportiert** (Entscheid [259]): reine 2D-Symbole ohne Höhe; ein erfundener Körper oder ein `IfcFurniture`/`IfcSanitaryTerminal` ohne Geometrie würde in Revit/Archicad unsichtbar bleiben oder Mengen verfälschen. Kommt mit 3D-Objekten nach 1.0 | – | Test „2D-Objektbibliothek im IFC" |
|
||||
| **Nicht exportiert** | 2D-Zeichnungen (ausser Raster), Texte, Bemassungen, Schraffuren, Layouts/Blätter, Ebenen als Sichtbarkeit (kein `IfcPresentationLayerAssignment`), Stifte, Gruppen, Netzkörper ausserhalb des Kontexts, Möbel/Blöcke, Ansichtsausschnitte | Im Sammler wird nur über Bauteile iteriert, `drawings2d` (ausser `Grid`) kommen nicht vor | `ifc_data.rs` |
|
||||
|
||||
Geprüft mit IfcOpenShell nur, wenn `ifcopenshell` installiert ist (`src/export/exportIfc.validate.test.ts`); ob
|
||||
Revit/ArchiCAD alles wie gewünscht lesen: ungeprüft.
|
||||
Geprüft mit IfcOpenShell nur, wenn `ifcopenshell` installiert ist (`src/export/exportIfc.validate.test.ts`, für alle drei
|
||||
Beispielprojekte zusätzlich `scripts/check-ifc-fachplaner.py` in `exportIfc.fachplaner.test.ts`: Struktur, Eingliederung,
|
||||
Georeferenz, Öffnungen gefüllt und im Geschoss des Wirts, Raum-/Wand-/Deckenmengen ±1 % gegen die Geometrie); ob
|
||||
Revit/Archicad/Solibri/BIMcollab alles wie gewünscht lesen: ungeprüft (Prüfzeile 13.14 in `doc/RELEASE-1.0.md`).
|
||||
|
||||
## IFC (Import)
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ und Befunde in `TODO.md` eintragen.
|
||||
| 13.11 | **Objektbibliothek ([253]):** Panel „Objekte“ → WC, im Plan klicken; vor dem Klick R und M; Esstisch setzen, in der Objekt-Info Anzahl, „Unordnung“, „Neu würfeln“; Detailgrad grob/fein | Symbol am Cursor dreht/spiegelt; Stühle ändern sich, gleicher Wert = gleiche Stühle; Linien folgen dem Detailgrad; Klassen 22/23/24 vorhanden und ausschaltbar; ⌘Z je ein Schritt |
|
||||
| 13.12 | **Objekte im DXF ([253]):** Erdgeschoss mit Objekten als DXF exportieren, in AutoCAD/Archicad öffnen | je Objektart ein Block `DOSSIER_…` mit Einfügungen, lagerichtig |
|
||||
| 13.13 | **Baurecht-Nachweis ([255]):** Panel Gelände → Baurecht: GFZ/AZ/BMZ/ÜZ/GZ/Fassadenhöhe max. eintragen; Panel Flächenbilanz ansehen, CSV und PDF; Blatt → + Tabelle → „Baurecht-Nachweis“ | Tabelle zulässig/Projekt/Reserve/erfüllt, „—“ ohne Vorgabe; PDF und Blatt-Tabelle zeigen dieselben Werte; Überschreitung ist markiert |
|
||||
| 13.14 | **IFC für Fachplaner ([259]):** Vorlage Wettbewerb und Musterhaus komplex → Datei → Exportieren → IFC (IFC4, einmal mit „Kontext mitgeben“, einmal IFC2x3); Dateien in Archicad (IFC-Übersetzer „Allgemein“), Revit (Öffnen/Verknüpfen), Solibri oder BIMcollab Zoom öffnen | Geschosse EG/1.OG/2.OG mit Höhen; Wände mit Schichten und Materialnamen, Fenster/Türen in den Öffnungen, Decken, Dach, Treppen; Räume mit Nummer, Name, Fläche (= Flächenbilanz), SIA-Kategorie; Lage: Projektbasispunkt/Vermessungspunkt in LV95 (E 2 697 450 / N 1 261 800, ±0.00 = 441.30 m ü. M.), Gebäude nicht kilometerweit vom Ursprung; Kontext nur mit Option, am Grundstück; keine Möbel/Sanitär-Symbole. Befunde mit Programm und Version in `TODO.md` [259]/[C9] |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
#!/usr/bin/env python3
|
||||
"""IFC für Fachplaner prüfen ([259]): was Archicad/Revit/Solibri/BIMcollab von einem Architekturmodell erwarten.
|
||||
|
||||
Ergänzt `scripts/validate-ifc.py` (Schema, Express-Regeln, Geometrie) um inhaltliche Prüfungen:
|
||||
• räumliche Struktur: genau ein IfcProject → IfcSite → IfcBuilding → IfcBuildingStorey (Name, Elevation);
|
||||
jedes Bauteil genau einmal räumlich eingeordnet (Teile über IfcRelAggregates, Öffnungen über IfcRelVoidsElement,
|
||||
Kontext am IfcSite, sonst an einem Geschoss);
|
||||
• Georeferenz (mit `--geo`): IfcMapConversion auf IfcProjectedCRS EPSG:2056, Geometrie lokal (nicht in
|
||||
LV95-Millionen: Revit/Archicad warnen ab wenigen Kilometern Abstand zum Ursprung);
|
||||
• Öffnungen: jedes IfcOpeningElement schneidet genau ein Bauteil; jede Tür/jedes Fenster füllt genau eine Öffnung und
|
||||
liegt im Geschoss ihres Wirts;
|
||||
• Räume: Name (Nummer), LongName, Pset_SpaceCommon, Qto_SpaceBaseQuantities (NetFloorArea, GrossFloorArea, Height),
|
||||
SIA-416-Kategorie; Fläche ±1 % gegen die Geometrie (ifcopenshell);
|
||||
• Wände: IfcMaterialLayerSetUsage mit Materialnamen, Schichtsumme = Wanddicke; NetVolume ±1 % gegen die Geometrie;
|
||||
Decken: PredefinedType, NetVolume ±1 %;
|
||||
• Geschoss-Mengen: GrossFloorArea ≥ NetFloorArea;
|
||||
• keine Objekte der 2D-Objektbibliothek als 3D-Körper (IfcFurniture/IfcSanitaryTerminal …).
|
||||
|
||||
Aufruf: python3 scripts/check-ifc-fachplaner.py datei.ifc [--geo] [--context] [--json] [--known=GlobalId,…]
|
||||
--geo die Datei MUSS georeferenziert sein
|
||||
--context Kontext (Gelände/Nachbarn) wird erwartet; ohne: es darf keiner drin sein
|
||||
--json Kennwerte als JSON auf stdout (für Tests)
|
||||
--known bekannte Mengen-Abweichungen dieser Bauteile (GlobalId) als `stats.known` statt als Befund
|
||||
(offene Punkte in TODO.md, z. B. ifcopenshell-Boolean an Netz-Wänden unter dem Dach)
|
||||
Exit 0 = keine Befunde.
|
||||
"""
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.geom
|
||||
import ifcopenshell.util.element as ue
|
||||
import ifcopenshell.util.placement as up
|
||||
import ifcopenshell.util.shape as us
|
||||
|
||||
TOL = 0.01 # ±1 %
|
||||
LOCAL_LIMIT = 5000.0 # m: weiter vom Ursprung = „nicht lokal"
|
||||
LIBRARY_CLASSES = ["IfcFurniture", "IfcFurnishingElement", "IfcSanitaryTerminal", "IfcSystemFurnitureElement"]
|
||||
|
||||
|
||||
def rel_err(a, b):
|
||||
return abs(a - b) / max(abs(b), 1e-9)
|
||||
|
||||
|
||||
def check(path, want_geo, want_context, known=()):
|
||||
m = ifcopenshell.open(path)
|
||||
problems = []
|
||||
stats = {"known": []}
|
||||
|
||||
def volume_problem(e, text):
|
||||
(stats["known"] if e.GlobalId in known else problems).append(text)
|
||||
s = ifcopenshell.geom.settings()
|
||||
|
||||
# ── Räumliche Struktur ──
|
||||
projects, sites, buildings = m.by_type("IfcProject"), m.by_type("IfcSite"), m.by_type("IfcBuilding")
|
||||
if (len(projects), len(sites), len(buildings)) != (1, 1, 1):
|
||||
problems.append(f"Struktur: {len(projects)} Projekt(e), {len(sites)} Site(s), {len(buildings)} Gebäude (erwartet je 1)")
|
||||
return problems, stats
|
||||
site, building = sites[0], buildings[0]
|
||||
if not any(r.RelatingObject == projects[0] for r in site.Decomposes):
|
||||
problems.append("IfcSite hängt nicht am IfcProject")
|
||||
if not any(r.RelatingObject == site for r in building.Decomposes):
|
||||
problems.append("IfcBuilding hängt nicht am IfcSite")
|
||||
storeys = m.by_type("IfcBuildingStorey")
|
||||
stats["storeys"] = [(st.Name, st.Elevation) for st in storeys]
|
||||
for st in storeys:
|
||||
if not st.Name:
|
||||
problems.append(f"Geschoss #{st.id()} ohne Namen")
|
||||
if st.Elevation is None:
|
||||
problems.append(f"Geschoss {st.Name} ohne Elevation")
|
||||
if not any(r.RelatingObject == building for r in st.Decomposes):
|
||||
problems.append(f"Geschoss {st.Name} hängt nicht am Gebäude")
|
||||
|
||||
def container(e):
|
||||
rels = list(e.ContainedInStructure or [])
|
||||
return rels[0].RelatingStructure if len(rels) == 1 else None
|
||||
|
||||
# ── Jedes Element genau einmal eingeordnet ──
|
||||
counts = {}
|
||||
for e in m.by_type("IfcElement"):
|
||||
counts[e.is_a()] = counts.get(e.is_a(), 0) + 1
|
||||
contained = len(e.ContainedInStructure or [])
|
||||
parts = len(e.Decomposes or [])
|
||||
if e.is_a("IfcFeatureElementSubtraction"):
|
||||
if contained or len(e.VoidsElements or []) != 1:
|
||||
problems.append(f"{e.is_a()} #{e.id()}: {len(e.VoidsElements or [])} Wirte, {contained}× eingeordnet (erwartet 1 Wirt, 0)")
|
||||
continue
|
||||
if contained + parts != 1:
|
||||
problems.append(f"{e.is_a()} {e.Name!r}: {contained}× eingeordnet, {parts}× Teil (erwartet genau eins)")
|
||||
continue
|
||||
if contained:
|
||||
c = container(e)
|
||||
ctx = e.is_a("IfcGeographicElement") or (e.ObjectType or "").startswith("Kontext")
|
||||
if ctx and not c.is_a("IfcSite"):
|
||||
problems.append(f"Kontext {e.Name!r} nicht am IfcSite, sondern {c.is_a()}")
|
||||
if not ctx and not c.is_a("IfcBuildingStorey") and not e.is_a("IfcGeographicElement"):
|
||||
problems.append(f"{e.is_a()} {e.Name!r} liegt in {c.is_a()} statt einem Geschoss")
|
||||
stats["counts"] = counts
|
||||
|
||||
# ── Kontext ──
|
||||
context = [e for e in m.by_type("IfcElement") if (container(e) is not None and container(e).is_a("IfcSite"))]
|
||||
stats["context"] = len(context)
|
||||
if want_context and not context:
|
||||
problems.append("Kontext erwartet, aber keiner am IfcSite")
|
||||
if not want_context and context:
|
||||
problems.append(f"{len(context)} Kontext-Objekte, obwohl abgeschaltet")
|
||||
|
||||
# ── Objektbibliothek nicht als 3D ──
|
||||
for cls in LIBRARY_CLASSES:
|
||||
try:
|
||||
n = len(m.by_type(cls))
|
||||
except RuntimeError:
|
||||
n = 0
|
||||
if n:
|
||||
problems.append(f"{n} × {cls} (2D-Objektbibliothek darf nicht als 3D-Körper exportiert werden)")
|
||||
|
||||
# ── Georeferenz ──
|
||||
convs = m.by_type("IfcMapConversion") if m.schema != "IFC2X3" else []
|
||||
if want_geo:
|
||||
if not convs:
|
||||
problems.append("Georeferenz erwartet, aber kein IfcMapConversion")
|
||||
else:
|
||||
c = convs[0]
|
||||
crs = c.TargetCRS
|
||||
if crs.Name != "EPSG:2056":
|
||||
problems.append(f"Zielsystem {crs.Name!r} statt EPSG:2056")
|
||||
if not (2_480_000 < c.Eastings < 2_840_000 and 1_070_000 < c.Northings < 1_300_000):
|
||||
problems.append(f"IfcMapConversion ausserhalb LV95: E {c.Eastings}, N {c.Northings}")
|
||||
stats["map"] = [c.Eastings, c.Northings, c.OrthogonalHeight]
|
||||
if site.RefElevation is not None and abs(site.RefElevation - c.OrthogonalHeight) > 1e-6:
|
||||
problems.append(f"IfcSite.RefElevation {site.RefElevation} ≠ OrthogonalHeight {c.OrthogonalHeight}")
|
||||
far = 0.0
|
||||
for e in m.by_type("IfcProduct"):
|
||||
if e.ObjectPlacement is None:
|
||||
continue
|
||||
mat = up.get_local_placement(e.ObjectPlacement)
|
||||
far = max(far, abs(mat[0][3]), abs(mat[1][3]))
|
||||
for p in m.by_type("IfcCartesianPoint"):
|
||||
far = max(far, *(abs(x) for x in p.Coordinates[:2]))
|
||||
for pl in m.by_type("IfcCartesianPointList3D"):
|
||||
for c in pl.CoordList:
|
||||
far = max(far, abs(c[0]), abs(c[1]))
|
||||
stats["far"] = far
|
||||
if far > LOCAL_LIMIT:
|
||||
problems.append(f"Geometrie {far:.0f} m vom Ursprung (nicht lokal; Revit/Archicad warnen)")
|
||||
|
||||
# ── Öffnungen ──
|
||||
unfilled = 0
|
||||
for o in m.by_type("IfcOpeningElement"):
|
||||
if not o.HasFillings:
|
||||
unfilled += 1
|
||||
stats["openings"] = len(m.by_type("IfcOpeningElement"))
|
||||
stats["unfilled"] = unfilled
|
||||
for f in m.by_type("IfcDoor") + m.by_type("IfcWindow"):
|
||||
if len(f.FillsVoids or []) != 1:
|
||||
problems.append(f"{f.is_a()} {f.Name!r} füllt {len(f.FillsVoids or [])} Öffnungen")
|
||||
continue
|
||||
host = f.FillsVoids[0].RelatingOpeningElement.VoidsElements[0].RelatingBuildingElement
|
||||
hc, fc = container(host), container(f)
|
||||
if hc is not None and fc is not None and hc != fc:
|
||||
problems.append(f"{f.is_a()} {f.Name!r} in {fc.Name}, Wirt in {hc.Name}")
|
||||
|
||||
# ── Räume ──
|
||||
spaces = m.by_type("IfcSpace")
|
||||
stats["spaces"] = len(spaces)
|
||||
for sp in spaces:
|
||||
ps = ue.get_psets(sp)
|
||||
label = f"Raum {sp.Name!r}"
|
||||
if not sp.Name or not sp.LongName:
|
||||
problems.append(f"{label}: Name/LongName fehlt ({sp.Name!r}/{sp.LongName!r})")
|
||||
if not any(r.RelatingObject.is_a("IfcBuildingStorey") for r in sp.Decomposes):
|
||||
problems.append(f"{label}: nicht im Geschoss aggregiert")
|
||||
if "Pset_SpaceCommon" not in ps:
|
||||
problems.append(f"{label}: Pset_SpaceCommon fehlt")
|
||||
q = ps.get("Qto_SpaceBaseQuantities", {})
|
||||
for k in ("NetFloorArea", "GrossFloorArea", "Height"):
|
||||
if k not in q:
|
||||
problems.append(f"{label}: Qto_SpaceBaseQuantities.{k} fehlt")
|
||||
if not any("SIA416" in v for k, v in ps.items() if k != "Qto_SpaceBaseQuantities"):
|
||||
problems.append(f"{label}: SIA-416-Kategorie fehlt")
|
||||
if sp.Representation is None:
|
||||
problems.append(f"{label}: ohne Geometrie")
|
||||
continue
|
||||
sh = ifcopenshell.geom.create_shape(s, sp)
|
||||
area = us.get_footprint_area(sh.geometry)
|
||||
if "NetFloorArea" in q and rel_err(q["NetFloorArea"], area) > TOL:
|
||||
problems.append(f"{label}: NetFloorArea {q['NetFloorArea']:.3f} ≠ Geometrie {area:.3f}")
|
||||
h = us.get_z(sh.geometry)
|
||||
if "Height" in q and abs(q["Height"] - h) > 0.01:
|
||||
problems.append(f"{label}: Height {q['Height']:.3f} ≠ Geometrie {h:.3f}")
|
||||
|
||||
# ── Wände: Schichten und Volumen ──
|
||||
walls = m.by_type("IfcWall")
|
||||
with_usage = 0
|
||||
for w in walls:
|
||||
label = f"Wand {w.Name!r} #{w.id()}"
|
||||
mat = ue.get_material(w, should_skip_usage=False)
|
||||
if mat is not None and mat.is_a("IfcMaterialLayerSetUsage"):
|
||||
with_usage += 1
|
||||
layers = mat.ForLayerSet.MaterialLayers
|
||||
if any(not (ly.Material and ly.Material.Name) for ly in layers):
|
||||
problems.append(f"{label}: Schicht ohne Materialnamen")
|
||||
q = ue.get_psets(w).get("Qto_WallBaseQuantities", {})
|
||||
total = sum(ly.LayerThickness for ly in layers)
|
||||
if "Width" in q and abs(q["Width"] - total) > 1e-4:
|
||||
problems.append(f"{label}: Schichtsumme {total:.4f} ≠ Width {q['Width']:.4f}")
|
||||
elif mat is None:
|
||||
problems.append(f"{label}: ohne Material")
|
||||
q = ue.get_psets(w).get("Qto_WallBaseQuantities", {})
|
||||
if "NetVolume" in q:
|
||||
v = us.get_volume(ifcopenshell.geom.create_shape(s, w).geometry)
|
||||
if rel_err(q["NetVolume"], v) > TOL:
|
||||
volume_problem(w, f"{label}: NetVolume {q['NetVolume']:.4f} ≠ Geometrie {v:.4f}")
|
||||
stats["walls"] = len(walls)
|
||||
stats["wallsWithUsage"] = with_usage
|
||||
|
||||
# ── Decken ──
|
||||
for sl in m.by_type("IfcSlab"):
|
||||
label = f"Decke {sl.Name!r} #{sl.id()}"
|
||||
if sl.PredefinedType not in ("FLOOR", "ROOF", "BASESLAB", "LANDING"):
|
||||
problems.append(f"{label}: PredefinedType {sl.PredefinedType}")
|
||||
q = ue.get_psets(sl).get("Qto_SlabBaseQuantities", {})
|
||||
if "NetVolume" in q and sl.Representation is not None:
|
||||
v = us.get_volume(ifcopenshell.geom.create_shape(s, sl).geometry)
|
||||
if rel_err(q["NetVolume"], v) > TOL:
|
||||
volume_problem(sl, f"{label}: NetVolume {q['NetVolume']:.4f} ≠ Geometrie {v:.4f}")
|
||||
|
||||
# ── Geschoss-Mengen ──
|
||||
for st in storeys:
|
||||
q = ue.get_psets(st).get("Qto_BuildingStoreyBaseQuantities", {})
|
||||
if q and q.get("GrossFloorArea", 0) + 1e-6 < q.get("NetFloorArea", 0):
|
||||
problems.append(f"Geschoss {st.Name}: GrossFloorArea < NetFloorArea")
|
||||
# SIA 416: GF = NGF + KF; mit Wänden im Geschoss ist die Konstruktionsfläche > 0.
|
||||
has_walls = any(e.is_a("IfcWall") for r in st.ContainsElements for e in r.RelatedElements)
|
||||
if q and has_walls and q.get("GrossFloorArea", 0) <= q.get("NetFloorArea", 0) + 1e-6:
|
||||
problems.append(f"Geschoss {st.Name}: GrossFloorArea = NetFloorArea trotz Wänden (Konstruktionsfläche fehlt)")
|
||||
stats.setdefault("storeyQto", {})[st.Name] = {k: v for k, v in q.items() if k != "id"}
|
||||
|
||||
# ── Pset_*Common ──
|
||||
for cls, pset in (("IfcWall", "Pset_WallCommon"), ("IfcSlab", "Pset_SlabCommon"), ("IfcDoor", "Pset_DoorCommon"), ("IfcWindow", "Pset_WindowCommon")):
|
||||
missing = [e for e in m.by_type(cls) if pset not in ue.get_psets(e) and not (cls == "IfcSlab" and e.PredefinedType == "LANDING")]
|
||||
if missing:
|
||||
problems.append(f"{len(missing)} × {cls} ohne {pset}")
|
||||
return problems, stats
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = [a for a in sys.argv[1:] if not a.startswith("--")]
|
||||
if not args:
|
||||
print(__doc__)
|
||||
sys.exit(2)
|
||||
flags = set(a.split("=")[0] for a in sys.argv[1:] if a.startswith("--"))
|
||||
known = [g for a in sys.argv[1:] if a.startswith("--known=") for g in a.split("=", 1)[1].split(",") if g]
|
||||
worst = 0
|
||||
for path in args:
|
||||
problems, stats = check(path, "--geo" in flags, "--context" in flags, known)
|
||||
if "--json" in flags:
|
||||
print(json.dumps({"path": path, "problems": problems, "stats": stats}))
|
||||
else:
|
||||
print(f"{path}: {len(problems)} Befunde")
|
||||
for p in problems[:200]:
|
||||
print(" " + p)
|
||||
for p in stats["known"]:
|
||||
print(" (bekannt) " + p)
|
||||
worst = max(worst, 1 if problems else 0)
|
||||
sys.exit(worst)
|
||||
+312
-59
@@ -1,7 +1,7 @@
|
||||
//! IFC-Export: Sammler im Kern ([K4] S2, [B5]; vorher `src/export/exportIfc.ts`, `ifcOpenings.ts`,
|
||||
//! `ifcClassification.ts`). Liest das Projekt-Dokument und erzeugt den flachen Puffer, den der
|
||||
//! Schreiber in `src-tauri/fileio/src/ifc_export/mod.rs` zur STEP-Datei macht (Kodierung dort im Kopf,
|
||||
//! FLAT_VERSION 4). TS gibt nur noch Optionen (Schema, Klassifikation) und den Zeitstempel weiter und
|
||||
//! FLAT_VERSION 5). TS gibt nur noch Optionen (Schema, Klassifikation) und den Zeitstempel weiter und
|
||||
//! reicht die Bytes an `fileio` (zwei WASM-Module, keine gemischten Crates).
|
||||
//!
|
||||
//! Abbildung (Einzelheiten im Kopf von `ifc_export/mod.rs` und in `TODO.md` [B5]):
|
||||
@@ -17,11 +17,12 @@
|
||||
//! Wand/Decke/Stütze/Treppe = C, Dach = F, Fenster = E, Tür und Raum ohne — nicht geraten) und/oder
|
||||
//! die Ebene des Modells als System „Dossier-Ebenen" (Code = `categoryCode`, Name = Ebenenname).
|
||||
//! Das Modell führt KEINEN eBKP-H-Code; `categoryCode` ist die Grafik-Ebene.
|
||||
//! Georeferenz: mit `geoAnchor` liegt die ganze Geometrie in LV95 (`geo_rebase`).
|
||||
//! Georeferenz ([259]): die Geometrie bleibt lokal; `geoAnchor` ergibt den Versatz des Modell-Ursprungs in LV95
|
||||
//! (IfcMapConversion Eastings/Northings), `referenceElevationMasl` die Höhe von ±0.00 (OrthogonalHeight).
|
||||
//! Zahlsemantik und Reihenfolge wie die frühere TS-Fassung: die Dateien bleiben zeichengleich.
|
||||
|
||||
use crate::export_flat::{js_trim, Flat};
|
||||
use crate::geo_rebase::{lv95_to_wgs84, project_to_world_coords};
|
||||
use crate::geo_rebase::lv95_to_wgs84;
|
||||
use crate::ifc_quantities::{self as qty, Cutout, Qty, QtyKind};
|
||||
use crate::ifc_stairs::{stair_parts, FlightBody, StairParts};
|
||||
use crate::jsmath::hypot2;
|
||||
@@ -31,7 +32,7 @@ use crate::model3d::{self, RWall};
|
||||
use crate::wall_mesh_cut::{is_watertight, wall_cut_mesh_checked, CutWall};
|
||||
use std::collections::HashMap;
|
||||
|
||||
const FLAT_VERSION: f64 = 4.0;
|
||||
const FLAT_VERSION: f64 = 5.0;
|
||||
const REC_WALL_SOLIDS: f64 = 1.0;
|
||||
const REC_WALL_MESH: f64 = 2.0;
|
||||
const REC_CEILING: f64 = 3.0;
|
||||
@@ -55,6 +56,7 @@ const REC_COLUMN_PIECES: f64 = 20.0;
|
||||
const REC_CEILING_ARC: f64 = 21.0;
|
||||
const REC_SPACE_ARC: f64 = 22.0;
|
||||
const REC_GUIDS: f64 = 23.0;
|
||||
const REC_CONTEXT: f64 = 24.0;
|
||||
|
||||
/// Toleranz des Kerns (`wall_bands.rs::EPS`) für „Öffnung trifft Band".
|
||||
const BAND_EPS: f64 = 1e-4;
|
||||
@@ -70,6 +72,9 @@ pub struct IfcOptions {
|
||||
pub ebkph: bool,
|
||||
/// `categoryCode` als System „Dossier-Ebenen".
|
||||
pub layer_codes: bool,
|
||||
/// [259] Kontext mitgeben: Gelände-Netze (IfcGeographicElement TERRAIN) und Netze auf Umgebungsklassen
|
||||
/// (Nachbargebäude → IfcBuildingElementProxy), am IfcSite. Fachplaner wollen oft nur das Gebäude: Vorgabe aus.
|
||||
pub context: bool,
|
||||
/// Zeitstempel (Sekunden seit 1970) und dieselbe Zeit als ISO-Text ohne Sekundenbruchteil.
|
||||
pub now: f64,
|
||||
pub iso: String,
|
||||
@@ -137,11 +142,14 @@ fn w_pts(f: &mut Flat, pts: &[Vec2]) {
|
||||
}
|
||||
}
|
||||
|
||||
/// [191] Ring mit Bögen: `n, (x, y, bulge) × n` (Bulge zur nächsten Ecke; fehlend = gerade).
|
||||
/// [191] Ring mit Bögen: `n, (x, y, bulge) × n` (Bulge zur nächsten Ecke; fehlend = gerade). Der Schreiber liest den
|
||||
/// Bulge im DXF-Sinn (positiv = Gegenuhrzeigersinn, Scheitel rechts der Kante); das Modell zählt umgekehrt
|
||||
/// (`ring_arc`: positiv = Scheitel links, wie bei Wänden) — daher das Vorzeichen ([259]: vorher lagen die Bögen von
|
||||
/// Decken und Räumen gespiegelt an der Sehne, Fläche/Volumen nach ifcopenshell ≠ Mengen).
|
||||
fn w_bpts(f: &mut Flat, pts: &[Vec2], bulge: Option<&[f64]>) {
|
||||
f.num(pts.len() as f64);
|
||||
for (i, p) in pts.iter().enumerate() {
|
||||
f.nums(&[p.x, p.y, crate::ring_arc::bulge_at(bulge, i)]);
|
||||
f.nums(&[p.x, p.y, -crate::ring_arc::bulge_at(bulge, i)]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,8 +406,11 @@ fn reveal_frame_slice(p: &Project, wall: &Wall, o: &Opening) -> Option<(f64, f64
|
||||
|
||||
/// [168] Bänder einer Wand als EIN Körper (Manifold, exakt): je Band der volle Quader (Enden an den
|
||||
/// Schnittlinien wie das 3D) minus die Löcher, dann alle vereinigt — IFC-Koordinaten (x, y, z − `base`).
|
||||
/// `None` bei Bändern mit schräger Oberkante oder wenn Manifold ablehnt (dann bleibt das Schalen-Netz).
|
||||
fn union_bands(bands: &[&RWall], base: f64) -> Option<(Vec<f64>, Vec<u32>)> {
|
||||
/// [259] Auch die Füllkörper von Formöffnungen (`boxes`, Quader wie `push_box`) und jede Wand mit mehreren Bändern:
|
||||
/// sonst lagen mehrere sich berührende Schalen in einem Face-Set (Kanten 4- bis 8-fach), und ifcopenshell rechnete
|
||||
/// beim Abzug der Öffnungen falsch (Füllkörper waren zudem verdreht gewickelt). `None` bei Bändern mit schräger oder
|
||||
/// ebener Dach-Oberkante (`top_drop`, `top_plane`) oder wenn Manifold ablehnt (dann bleibt das Schalen-Netz).
|
||||
fn union_bands(bands: &[&RWall], base: f64, boxes: &[[f64; 24]]) -> Option<(Vec<f64>, Vec<u32>)> {
|
||||
use crate::solid_bool::{Mesh, Solid};
|
||||
let solid = |w: &CutWall, shift: Option<&RWall>| -> Option<Solid> {
|
||||
let mut cut = wall_cut_mesh_checked(w);
|
||||
@@ -411,8 +422,20 @@ fn union_bands(bands: &[&RWall], base: f64) -> Option<(Vec<f64>, Vec<u32>)> {
|
||||
Solid::new(&Mesh { positions, indices: (0..n).collect() }).ok()
|
||||
};
|
||||
let mut acc: Option<Solid> = None;
|
||||
let mut add = |acc: &mut Option<Solid>, m: Solid| -> Option<()> {
|
||||
*acc = Some(match acc.take() {
|
||||
None => m,
|
||||
Some(a) => a.union(&m).ok()?,
|
||||
});
|
||||
Some(())
|
||||
};
|
||||
for b in bands {
|
||||
if b.top_plane.is_some() || b.top_drop.is_some_and(|d| d[0].abs() > 1e-9 || d[1].abs() > 1e-9) {
|
||||
if b.top_drop.is_some_and(|d| d[0].abs() > 1e-9 || d[1].abs() > 1e-9) {
|
||||
return None;
|
||||
}
|
||||
// Ebene Oberkante unter einem Dach: nicht vereinigt (die Prismen berühren die Nachbarbänder nur an Kanten;
|
||||
// der vereinigte Körper war dicht, aber ifcopenshell scheiterte am Abzug der Öffnung — Volumen 0).
|
||||
if b.top_plane.is_some() {
|
||||
return None;
|
||||
}
|
||||
let mut m = solid(&CutWall { start: b.start, end: b.end, thickness: b.thickness, base_elevation: b.base_elevation, height: b.height, holes: vec![] }, Some(b))?;
|
||||
@@ -431,10 +454,12 @@ fn union_bands(bands: &[&RWall], base: f64) -> Option<(Vec<f64>, Vec<u32>)> {
|
||||
let hole = solid(&CutWall { start: at(h.from), end: at(h.to), thickness: b.thickness + 0.1, base_elevation: lo, height: hi - lo, holes: vec![] }, None)?;
|
||||
m = m.difference(&hole).ok()?;
|
||||
}
|
||||
acc = Some(match acc {
|
||||
None => m,
|
||||
Some(a) => a.union(&m).ok()?,
|
||||
});
|
||||
add(&mut acc, m)?;
|
||||
}
|
||||
for b in boxes {
|
||||
let positions: Vec<f64> = b.chunks_exact(3).flat_map(|c| [c[0], c[1], c[2] - base]).collect();
|
||||
let solid = Solid::new(&Mesh { positions, indices: box_tris_outward(b).to_vec() }).ok()?;
|
||||
add(&mut acc, solid)?;
|
||||
}
|
||||
let m = acc?.to_mesh();
|
||||
(!m.indices.is_empty()).then_some((m.positions, m.indices))
|
||||
@@ -687,8 +712,6 @@ struct SolidOpening {
|
||||
depth: f64,
|
||||
}
|
||||
|
||||
/// Dreiecke eines 8-Ecken-Quaders wie `model3d::OPENING_BOX_TRIS`.
|
||||
const BOX_TRIS: [u32; 36] = [0, 1, 3, 0, 3, 2, 4, 5, 7, 4, 7, 6, 0, 1, 5, 0, 5, 4, 2, 3, 7, 2, 7, 6, 0, 2, 6, 0, 6, 4, 1, 3, 7, 1, 7, 5];
|
||||
|
||||
/// Gauben eines Dachs (Index) für die Mengen ([G5]): je Gaube Breite, Stirnhöhe, geneigte Fläche des
|
||||
/// Ausschnitts im Hauptdach, Volumen der Wände (Stirn/Wangen) und des Gaubendachs aus den Körpern.
|
||||
@@ -734,12 +757,74 @@ fn dormer_parts(p: &Project, ri: usize, roof: &Roof) -> Vec<qty::DormerIn> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// [259] Formöffnungen ([G3]) in den Wandmengen: die Rechteck-Rechnung zieht das ganze Rechteck ab, geschnitten wird
|
||||
/// aber der Umriss (Rund-/Spitzbogen, Kreis). Liefert (Fläche, Volumen) zwischen Rechteck und Umriss, die netto
|
||||
/// wieder dazukommen — dann stimmen die Mengen mit dem Körper nach ifcopenshell überein (±1 %).
|
||||
fn shaped_cut_back(p: &Project, wall: &Wall, cutouts: &[(usize, Cutout)], openings: &[Opening]) -> (f64, f64) {
|
||||
let total = p.wall_thickness(wall, 0.2);
|
||||
let mut area = 0.0;
|
||||
for &(k, c) in cutouts {
|
||||
let (w, h) = (c.to - c.from, c.z_top - c.z_bottom);
|
||||
if let Some(poly) = crate::opening_shape::opening_outline(&openings[k], w, h) {
|
||||
let pts: Vec<Vec2> = poly.iter().map(|q| Vec2 { x: q[0], y: q[1] }).collect();
|
||||
area += max(0.0, w * h - qty::ring_area(&pts));
|
||||
}
|
||||
}
|
||||
(area, area * total)
|
||||
}
|
||||
|
||||
/// [259] Formöffnungs-Rückgabe ([`shaped_cut_back`]) auf NetSideArea/NetVolume (Brutto mindestens netto).
|
||||
fn add_back(quantities: &mut [Qty], (area, volume): (f64, f64)) {
|
||||
for q in quantities.iter_mut() {
|
||||
match q.name {
|
||||
"NetSideArea" => q.value += area,
|
||||
"NetVolume" => q.value += volume,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let net = quantities.iter().find(|q| q.name == "NetVolume").map_or(0.0, |q| q.value);
|
||||
if let Some(g) = quantities.iter_mut().find(|q| q.name == "GrossVolume") {
|
||||
g.value = max(g.value, net);
|
||||
}
|
||||
}
|
||||
|
||||
fn push_box(positions: &mut Vec<f64>, indices: &mut Vec<u32>, b: &[f64; 24], base: f64) {
|
||||
let at = (positions.len() / 3) as u32;
|
||||
for c in b.chunks_exact(3) {
|
||||
positions.extend_from_slice(&[c[0], c[1], c[2] - base]);
|
||||
}
|
||||
indices.extend(BOX_TRIS.iter().map(|i| at + i));
|
||||
indices.extend(box_tris_outward(b).iter().map(|i| at + i));
|
||||
}
|
||||
|
||||
/// Sechsfaches Volumen mit Vorzeichen (positiv = nach aussen gewickelt; `mesh_volume` liefert den Betrag).
|
||||
fn signed_volume6(positions: &[f64], indices: &[u32]) -> f64 {
|
||||
let p = |i: u32| [positions[i as usize * 3], positions[i as usize * 3 + 1], positions[i as usize * 3 + 2]];
|
||||
indices
|
||||
.chunks_exact(3)
|
||||
.map(|x| {
|
||||
let (a, c, d) = (p(x[0]), p(x[1]), p(x[2]));
|
||||
a[0] * (c[1] * d[2] - c[2] * d[1]) - a[1] * (c[0] * d[2] - c[2] * d[0]) + a[2] * (c[0] * d[1] - c[1] * d[0])
|
||||
})
|
||||
.sum()
|
||||
}
|
||||
|
||||
/// [259] Dreiecke eines 8-Ecken-Quaders (Ecke i = Bits Achse 0/1/2 wie `model3d::OPENING_BOX_TRIS`) einheitlich nach
|
||||
/// aussen gewickelt. `OPENING_BOX_TRIS` (3D, beidseitig gezeichnet; vorher auch hier) wickelt gegenüberliegende Flächen gleich — als Körper nicht
|
||||
/// geschlossen: Manifold lehnt ab, IFC-Leser sehen eine verdrehte Schale.
|
||||
fn box_tris_outward(b: &[f64; 24]) -> [u32; 36] {
|
||||
// Je Fläche das Viereck im Umlauf; die erste der Paar-Flächen liegt bei Bit = 0 und wird umgedreht.
|
||||
const QUADS: [([u32; 4], bool); 6] = [([0, 1, 3, 2], true), ([4, 5, 7, 6], false), ([0, 1, 5, 4], false), ([2, 3, 7, 6], true), ([0, 2, 6, 4], true), ([1, 3, 7, 5], false)];
|
||||
let mut t = [0u32; 36];
|
||||
for (k, (q, flip)) in QUADS.iter().enumerate() {
|
||||
let tri = if *flip { [q[0], q[2], q[1], q[0], q[3], q[2]] } else { [q[0], q[1], q[2], q[0], q[2], q[3]] };
|
||||
t[k * 6..k * 6 + 6].copy_from_slice(&tri);
|
||||
}
|
||||
if signed_volume6(b, &t) < 0.0 {
|
||||
for tri in t.chunks_exact_mut(3) {
|
||||
tri.swap(1, 2);
|
||||
}
|
||||
}
|
||||
t
|
||||
}
|
||||
|
||||
/// Füllung (Rahmen, Glas/Blatt) einer Formöffnung als Netz, Z relativ zur Geschoss-UK.
|
||||
@@ -820,6 +905,8 @@ enum Kind {
|
||||
Window,
|
||||
Door,
|
||||
Space,
|
||||
/// [259] Kontext (Gelände, Nachbargebäude): keine eBKP-H-Gruppe, nur die Ebene.
|
||||
Context,
|
||||
}
|
||||
|
||||
/// eBKP-H-Hauptgruppe zur Bauteilart, oder `None` (Tür, Raum: nicht eindeutig).
|
||||
@@ -828,7 +915,7 @@ fn ebkph_group(k: Kind) -> Option<(&'static str, &'static str)> {
|
||||
Kind::Wall | Kind::Slab | Kind::Column | Kind::Stair => Some(("C", "Konstruktion Gebäude")),
|
||||
Kind::Roof => Some(("F", "Bedachung Gebäude")),
|
||||
Kind::Window => Some(("E", "Äussere Wandbekleidung Gebäude")),
|
||||
Kind::Door | Kind::Space => None,
|
||||
Kind::Door | Kind::Space | Kind::Context => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -864,8 +951,9 @@ const SIA_CATEGORIES: [SiaCategory; 6] = [SiaCategory::HNF, SiaCategory::NNF, Si
|
||||
|
||||
/// Der flache IFC-Puffer aus dem Projekt (s. Modulkopf).
|
||||
pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String> {
|
||||
// Georeferenziert: die ganze Geometrie auf die echten LV95-Koordinaten (ohne Bezug unverändert).
|
||||
let mut p = project_to_world_coords(src);
|
||||
// [259] Geometrie bleibt lokal (Modell-Meter); die Georeferenz trägt IfcMapConversion (Versatz zu LV95 und
|
||||
// Höhe von ±0.00). LV95-Millionen in der Geometrie lassen Revit/Archicad warnen und kosten Genauigkeit.
|
||||
let mut p = src.clone();
|
||||
let mut f = Flat::new(FLAT_VERSION);
|
||||
|
||||
// Je "floor"-Ebene ein IfcBuildingStorey (Elevation = baseElevation).
|
||||
@@ -879,8 +967,10 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
let base_of = |structure: f64| -> f64 { if structure < 0.0 { 0.0 } else { storey_base[structure as usize] } };
|
||||
|
||||
// Kopf: RefElevation = reale Datumshöhe (informativ), RefLatitude/-Longitude des Bezugspunkts.
|
||||
let anchor = p.geo_anchor.clone();
|
||||
let lat_lon = anchor.as_ref().map(|a| (a.lv95.e, a.lv95.n)).filter(|(e, n)| e.is_finite() && n.is_finite()).map(|(e, n)| lv95_to_wgs84(e, n)).filter(|(la, lo)| la.is_finite() && lo.is_finite());
|
||||
let anchor = p.geo_anchor.clone().filter(|a| a.lv95.e.is_finite() && a.lv95.n.is_finite() && a.model.x.is_finite() && a.model.y.is_finite());
|
||||
// Höhe von Modell-z 0 (±0.00) über Meer: `referenceElevationMasl` ([131]), sonst die Höhe des Bezugspunkts.
|
||||
let ref_elevation = p.reference_elevation_masl.or_else(|| anchor.as_ref().and_then(|a| a.height)).filter(|h| h.is_finite()).unwrap_or(f64::NAN);
|
||||
let lat_lon = anchor.as_ref().map(|a| (a.lv95.e - a.model.x, a.lv95.n - a.model.y)).filter(|(e, n)| e.is_finite() && n.is_finite()).map(|(e, n)| lv95_to_wgs84(e, n)).filter(|(la, lo)| la.is_finite() && lo.is_finite());
|
||||
// Anonyme Abgabe ([208]): Kennwort statt Projektname, fester Zeitstempel; leerer `iso` heisst für den Schreiber
|
||||
// „anonym" (neutrale Erzeuger-/Autorangaben, `fileio/ifc_export`).
|
||||
let anon = crate::competition::anonymous_keyword(&p);
|
||||
@@ -892,9 +982,11 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
now,
|
||||
iso,
|
||||
if anchor.is_some() { 1.0 } else { 0.0 },
|
||||
anchor.as_ref().and_then(|a| a.height).unwrap_or(f64::NAN),
|
||||
ref_elevation,
|
||||
lat_lon.map_or(f64::NAN, |x| x.0),
|
||||
lat_lon.map_or(f64::NAN, |x| x.1),
|
||||
anchor.as_ref().map_or(0.0, |a| a.lv95.e - a.model.x),
|
||||
anchor.as_ref().map_or(0.0, |a| a.lv95.n - a.model.y),
|
||||
if opt.ifc2x3 { 1.0 } else { 0.0 },
|
||||
floors.len() as f64,
|
||||
]);
|
||||
@@ -1020,7 +1112,9 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
continue;
|
||||
}
|
||||
let structure = structure_of(&wall.floor_id);
|
||||
let (name, ty, psets) = wall_ident(&p, wall, qty::wall_quantities(wall.start, wall.end, &bands, &plain, None));
|
||||
let mut quantities = qty::wall_quantities(wall.start, wall.end, &bands, &plain, None);
|
||||
add_back(&mut quantities, shaped_cut_back(&p, wall, cutouts_by_wall.get(&wall.id).map_or(&[][..], |v| v.as_slice()), &openings));
|
||||
let (name, ty, psets) = wall_ident(&p, wall, quantities);
|
||||
// Wandsystem: Placement am Wandanfang, X = Achse, Y = linke Normale; IfcMaterialLayerSetUsage nur,
|
||||
// wenn die Typ-Schichten den Querschnitt der Bänder füllen (sonst wäre der Offset gelogen).
|
||||
let extent = cross_extent(wall, &bands);
|
||||
@@ -1062,7 +1156,29 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
let ro = crate::joins::reference_offset(model3d::wall_reference(wall), total);
|
||||
let (zb, zt) = p.wall_vertical_extent(wall);
|
||||
let plain: Vec<Cutout> = cutouts_by_wall.get(&wall.id).map_or_else(Vec::new, |v| v.iter().map(|x| x.1).collect());
|
||||
let (name, ty, psets) = wall_ident(&p, wall, qty::arc_wall_quantities(&a, ro - total / 2.0, ro + total / 2.0, zb, zt, &plain, None));
|
||||
// [259] Mengen aus den geschriebenen Profilen (Schichten enden an der Decke, Eckstücke): Brutto = Σ
|
||||
// Profilfläche × Höhe (exakt mit Bögen; Profil-Bulge im DXF-Sinn → Modell-Sinn), netto abzüglich der
|
||||
// Öffnungen als Ringsektoren — vorher volle Wandhöhe über alle Schichten (Erker 5 % zu viel).
|
||||
let gross: f64 = profiles
|
||||
.iter()
|
||||
.map(|(ring, _, depth)| {
|
||||
let pts: Vec<Vec2> = ring.iter().map(|v| Vec2 { x: v[0], y: v[1] }).collect();
|
||||
let bulge: Vec<f64> = ring.iter().map(|v| -v[2]).collect();
|
||||
crate::ring_arc::signed_area(&pts, Some(&bulge)).abs() * depth
|
||||
})
|
||||
.sum();
|
||||
let mut quantities = qty::arc_wall_quantities(&a, ro - total / 2.0, ro + total / 2.0, zb, zt, &plain, None);
|
||||
let exact = qty::arc_wall_quantities(&a, ro - total / 2.0, ro + total / 2.0, zb, zt, &[], None);
|
||||
let full = exact.iter().find(|q| q.name == "GrossVolume").map_or(0.0, |q| q.value);
|
||||
let cut = full - quantities.iter().find(|q| q.name == "NetVolume").map_or(full, |q| q.value);
|
||||
for q in quantities.iter_mut() {
|
||||
match q.name {
|
||||
"GrossVolume" => q.value = gross,
|
||||
"NetVolume" => q.value = max(0.0, gross - cut),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
let (name, ty, psets) = wall_ident(&p, wall, quantities);
|
||||
w_head(&mut f, REC_WALL_ARC_SOLID, structure, &wall.id, &name);
|
||||
w_type(&mut f, ty.as_ref().map(|t| type_ref(t, 0.0, "STANDARD")).as_ref());
|
||||
w_psets(&mut f, &psets);
|
||||
@@ -1118,14 +1234,9 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
// [168] Schichteinzug-Stücke (Überdämmung, Leibungsputz) berühren die Bänder nur teilweise: dann die
|
||||
// Bänder zu EINEM Körper vereinigen (Manifold, exakt) — mehrere sich teilweise berührende Schalen
|
||||
// verrechnet ein IFC-Leser beim Abzug der Öffnungskörper (ifcopenshell: Volumen falsch).
|
||||
let pieces = arc.is_none() && openings.iter().any(|o| o.host_wall_id == wall.id && reveal_frame_slice(&p, wall, o).is_some());
|
||||
if pieces {
|
||||
if let Some((up, ui)) = union_bands(bands, base) {
|
||||
(positions, indices) = (up, ui);
|
||||
}
|
||||
}
|
||||
// Formöffnungen ([G3]): Füllkörper zwischen Rechteck-Loch und Umriss gehören zur Wand (nicht bei
|
||||
// Bogenwänden: dort bleibt das Rechteck-Loch).
|
||||
let mut boxes: Vec<[f64; 24]> = Vec::new();
|
||||
for &(k, c) in cutouts_by_wall.get(&wall.id).map_or(&[][..], |v| v.as_slice()).iter().filter(|_| arc.is_none()) {
|
||||
let o = &openings[k];
|
||||
let n = model3d::shaped_fill_count(&p, wall, o, c.to - c.from, c.z_top - c.z_bottom);
|
||||
@@ -1141,7 +1252,17 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
};
|
||||
for m in model3d::shaped_wall_opening_meshes(&p, wall, &wr, o, [c.from, c.to, c.z_bottom, c.z_top]).iter().take(n) {
|
||||
if let Ok(b) = <[f64; 24]>::try_from(m.positions.as_slice()) {
|
||||
push_box(&mut positions, &mut indices, &b, base);
|
||||
boxes.push(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
// [259] Mehrere Schalen (Bänder, Stücke, Füllkörper) zu einem Körper; lehnt Manifold ab, bleiben die Schalen.
|
||||
let shells = bands.len() + boxes.len();
|
||||
match (arc.is_none() && shells > 1).then(|| union_bands(bands, base, &boxes)).flatten() {
|
||||
Some((up, ui)) => (positions, indices) = (up, ui),
|
||||
None => {
|
||||
for b in &boxes {
|
||||
push_box(&mut positions, &mut indices, b, base);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1157,8 +1278,22 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
let mut quantities = match &arc {
|
||||
Some(a) => {
|
||||
let (zb, zt) = p.wall_vertical_extent(wall);
|
||||
// Exakt aus dem Kreis statt aus dem Sehnen-Netz.
|
||||
qty::arc_wall_quantities(a, ro - total / 2.0, ro + total / 2.0, zb, zt, &plain, None)
|
||||
// Längen/Flächen exakt aus dem Kreis. [259] Volumen: dichtes Netz = geschriebener Körper (Schichten enden
|
||||
// an der Decke; vorher volle Höhe über alle Schichten, Erker OG 23 % zu viel), Brutto = netto + Öffnungen.
|
||||
let mut q = qty::arc_wall_quantities(a, ro - total / 2.0, ro + total / 2.0, zb, zt, &plain, None);
|
||||
if let Some(nv) = net {
|
||||
let full = qty::arc_wall_quantities(a, ro - total / 2.0, ro + total / 2.0, zb, zt, &[], None);
|
||||
let gross = full.iter().find(|x| x.name == "GrossVolume").map_or(0.0, |x| x.value);
|
||||
let cut = gross - q.iter().find(|x| x.name == "NetVolume").map_or(gross, |x| x.value);
|
||||
for x in q.iter_mut() {
|
||||
match x.name {
|
||||
"GrossVolume" => x.value = nv + cut,
|
||||
"NetVolume" => x.value = nv,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
q
|
||||
}
|
||||
None => qty::wall_quantities(wall.start, wall.end, bands, &plain, net),
|
||||
};
|
||||
@@ -1168,6 +1303,11 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
nv.value = max(0.0, gross - qty::hole_volume(bands));
|
||||
}
|
||||
}
|
||||
if arc.is_none() {
|
||||
// Geschlossenes Netz: Volumen enthält die Füllkörper der Formöffnung schon, nur die Ansichtsfläche nicht.
|
||||
let (area, volume) = shaped_cut_back(&p, wall, cutouts_by_wall.get(&wall.id).map_or(&[][..], |v| v.as_slice()), &openings);
|
||||
add_back(&mut quantities, (area, if net.is_some() { 0.0 } else { volume }));
|
||||
}
|
||||
let (name, ty, psets) = wall_ident(&p, wall, quantities);
|
||||
w_head(&mut f, if arc.is_some() { REC_WALL_ARC } else { REC_WALL_MESH }, structure, &wall.id, &name);
|
||||
w_type(&mut f, ty.as_ref().map(|t| type_ref(t, 0.0, "STANDARD")).as_ref());
|
||||
@@ -1407,34 +1547,43 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
],
|
||||
);
|
||||
}
|
||||
// Geschoss-Kennwerte: GF/NGF als Basismenge des IfcBuildingStorey, alle SIA-416-Flächen als CH_Qto_SIA416.
|
||||
for fl in &floors {
|
||||
let rooms: Vec<(usize, f64)> = room_areas.iter().filter(|r| r.1 == fl.id).map(|r| (SIA_CATEGORIES.iter().position(|c| *c == r.2).unwrap_or(usize::MAX), r.3)).collect();
|
||||
if rooms.is_empty() {
|
||||
// Geschoss-Kennwerte ([259]: aus der Flächentabelle wie Kennzahlen/Flächenbilanz, GF = NGF + KF mit der
|
||||
// Konstruktionsfläche der Wände): GF/NGF/Höhe/GV als Basismenge des IfcBuildingStorey, alle SIA-416-Flächen als
|
||||
// CH_Qto_SIA416; Summen am IfcBuilding.
|
||||
let table = crate::flaechen::area_table(&p);
|
||||
for row in &table.levels {
|
||||
if row.rooms == 0 && row.kf <= 0.0 {
|
||||
continue;
|
||||
}
|
||||
let b = crate::room_area::balance(&rooms);
|
||||
let by_key = |k: &str| -> f64 {
|
||||
match k {
|
||||
"NF" => b.agg_area[0],
|
||||
"NGF" => b.agg_area[1],
|
||||
"GF" => b.agg_area[2],
|
||||
_ => crate::room_area::CATEGORIES.iter().position(|c| *c == k).map_or(0.0, |i| b.leaf_area[i]),
|
||||
}
|
||||
};
|
||||
let key = f.str(&format!("storey/{}", fl.id));
|
||||
let key = f.str(&format!("storey/{}", row.level_id));
|
||||
f.nums(&[REC_ATTACH, key]);
|
||||
let mut base = vec![Prop::Qty("GrossFloorArea", QtyKind::Area, max(0.0, row.gf)), Prop::Qty("NetFloorArea", QtyKind::Area, max(0.0, row.ngf))];
|
||||
if row.height > 0.0 {
|
||||
base.push(Prop::Qty("GrossHeight", QtyKind::Length, row.height));
|
||||
base.push(Prop::Qty("GrossVolume", QtyKind::Volume, max(0.0, row.gv)));
|
||||
}
|
||||
let sia = [("HNF", row.hnf), ("NNF", row.nnf), ("NF", row.nf), ("VF", row.vf), ("FF", row.ff), ("NGF", row.ngf), ("KGF", row.kf), ("AGF", row.agf), ("GF", row.gf)];
|
||||
w_psets(
|
||||
&mut f,
|
||||
&[
|
||||
Pset { name: "Qto_BuildingStoreyBaseQuantities", props: base },
|
||||
Pset { name: "CH_Qto_SIA416", props: sia.iter().map(|(k, v)| Prop::Qty(k, QtyKind::Area, max(0.0, *v))).collect() },
|
||||
],
|
||||
);
|
||||
}
|
||||
if table.total.gf > 0.0 {
|
||||
let key = f.str("building");
|
||||
f.nums(&[REC_ATTACH, key]);
|
||||
let t = &table.total;
|
||||
let sia = [("HNF", t.hnf), ("NNF", t.nnf), ("NF", t.nf), ("VF", t.vf), ("FF", t.ff), ("NGF", t.ngf), ("KGF", t.kf), ("AGF", t.agf), ("GF", t.gf), ("GV", table.gv)];
|
||||
w_psets(
|
||||
&mut f,
|
||||
&[
|
||||
Pset {
|
||||
name: "Qto_BuildingStoreyBaseQuantities",
|
||||
props: vec![Prop::Qty("GrossFloorArea", QtyKind::Area, max(0.0, by_key("GF"))), Prop::Qty("NetFloorArea", QtyKind::Area, max(0.0, by_key("NGF")))],
|
||||
},
|
||||
Pset {
|
||||
name: "CH_Qto_SIA416",
|
||||
props: ["HNF", "NNF", "NF", "VF", "FF", "NGF", "KGF", "AGF", "GF"].iter().map(|k| Prop::Qty(k, QtyKind::Area, max(0.0, by_key(k)))).collect(),
|
||||
name: "Qto_BuildingBaseQuantities",
|
||||
props: vec![Prop::Qty("GrossFloorArea", QtyKind::Area, max(0.0, t.gf)), Prop::Qty("NetFloorArea", QtyKind::Area, max(0.0, t.ngf)), Prop::Qty("GrossVolume", QtyKind::Volume, max(0.0, table.gv))],
|
||||
},
|
||||
Pset { name: "CH_Qto_SIA416", props: sia.iter().map(|(k, v)| Prop::Qty(k, if *k == "GV" { QtyKind::Volume } else { QtyKind::Area }, max(0.0, *v))).collect() },
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -1612,6 +1761,35 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
w_mesh(&mut f, &positions, &indices, false);
|
||||
}
|
||||
|
||||
// ── [259] Kontext (Option): Gelände und Nachbarn am IfcSite, Höhen absolut (Modell-z, ±0.00 = 0) ──
|
||||
if opt.context {
|
||||
for c in p.context.iter().flatten() {
|
||||
let (kind, id, name, code, positions, indices) = match c {
|
||||
ContextObject::TerrainMesh(m) => (1.0, &m.id, &m.name, &m.category_code, &m.positions, &m.indices),
|
||||
ContextObject::ImportedMesh(m) if crate::import_context::is_context_class(&m.category_code) => (0.0, &m.id, &m.name, &m.category_code, &m.positions, &m.indices),
|
||||
_ => continue,
|
||||
};
|
||||
let n = positions.len() / 3;
|
||||
if n < 3 || indices.len() < 3 || positions.iter().any(|v| !v.is_finite()) {
|
||||
continue;
|
||||
}
|
||||
let tris: Vec<u32> = indices
|
||||
.chunks_exact(3)
|
||||
.filter(|t| t.iter().all(|i| i.is_finite() && *i >= 0.0 && (*i as usize) < n) && t[0] != t[1] && t[1] != t[2] && t[0] != t[2])
|
||||
.flat_map(|t| t.iter().map(|i| *i as u32).collect::<Vec<_>>())
|
||||
.collect();
|
||||
if tris.is_empty() {
|
||||
continue;
|
||||
}
|
||||
classified.push((format!("context/{id}"), Kind::Context, code.clone()));
|
||||
// Klasse als Beschreibung („12 Gebäude"), damit sie im Fremdprogramm ohne Klassifikation lesbar bleibt.
|
||||
let class = layer_classification(&p, code).map(|(c, n)| format!("{c} {n}")).unwrap_or_default();
|
||||
let (a, b, c) = (f.str(id), f.str(if name.is_empty() { id } else { name }), f.str(&class));
|
||||
f.nums(&[REC_CONTEXT, kind, a, b, c]);
|
||||
w_mesh(&mut f, &positions[..n * 3], &tris, false);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Achsraster ([112]) → IfcGrid (U-/V-Achsen als Linienzüge in Welt-XY) ──
|
||||
for d in &p.drawings2d {
|
||||
let Some(spec) = crate::grid::Spec::of(&d.geom) else { continue };
|
||||
@@ -1728,6 +1906,74 @@ mod tests {
|
||||
text.split('\0').map(String::from).collect()
|
||||
}
|
||||
|
||||
/// [259] Kontext nur mit Option: Gelände (jede Klasse) und Netze auf Umgebungsklassen; ein Netz auf einer
|
||||
/// Bauteil-Klasse (z. B. importierte Möblierung) bleibt draussen, ebenso kaputte Dreiecke.
|
||||
#[test]
|
||||
fn kontext_nur_mit_option() {
|
||||
let mut p = sample();
|
||||
let tri = |id: &str, code: &str| ImportedMesh { id: id.into(), name: format!("Netz {id}"), category_code: code.into(), positions: vec![0.0, 0.0, 0.0, 9.0, 0.0, 0.0, 0.0, 9.0, 3.0], indices: vec![0.0, 1.0, 2.0, 0.0, 0.0, 1.0, 0.0, 1.0, 7.0], ..Default::default() };
|
||||
let terrain = TerrainMesh { id: "gel".into(), name: "Gelände".into(), category_code: "02".into(), positions: vec![0.0, 0.0, -1.0, 50.0, 0.0, -1.0, 0.0, 50.0, 0.5], indices: vec![0.0, 1.0, 2.0], ..Default::default() };
|
||||
p.context = Some(vec![ContextObject::ImportedMesh(tri("nb", "12")), ContextObject::ImportedMesh(tri("moebel", "20")), ContextObject::TerrainMesh(terrain)]);
|
||||
let count = |f: &Flat| f.nums.iter().filter(|v| **v == REC_CONTEXT).count();
|
||||
let off = ifc_export_data(&p, &IfcOptions::default()).unwrap();
|
||||
assert!(!strings(&off).iter().any(|s| s == "nb" || s == "gel"));
|
||||
let on = ifc_export_data(&p, &IfcOptions { context: true, ..Default::default() }).unwrap();
|
||||
let s = strings(&on);
|
||||
assert!(count(&on) >= 2);
|
||||
for want in ["nb", "Netz nb", "12 Gebäude", "gel", "Gelände"] {
|
||||
assert!(s.iter().any(|x| x == want), "fehlt: {want}");
|
||||
}
|
||||
assert!(!s.iter().any(|x| x == "moebel"), "Netz auf Bauteil-Klasse ist kein Kontext");
|
||||
// Datei: Nachbar mit einem gültigen Dreieck (die beiden kaputten fallen weg), Gelände am Grundstück.
|
||||
let (nums, text) = from_bytes(&on.to_bytes()).unwrap();
|
||||
let ifc = fileio_like_check(&nums, &text);
|
||||
assert_eq!(ifc, 2);
|
||||
}
|
||||
|
||||
/// Zählt die CONTEXT-Datensätze mit gültigem Dreiecksnetz im Puffer (Kopf: 24, kind, id, name, class, MESH).
|
||||
fn fileio_like_check(nums: &[f64], text: &str) -> usize {
|
||||
let strs: Vec<&str> = text.split('\0').collect();
|
||||
let mut n = 0;
|
||||
for i in 0..nums.len().saturating_sub(6) {
|
||||
if nums[i] == REC_CONTEXT && (nums[i + 1] == 0.0 || nums[i + 1] == 1.0) && strs.get(nums[i + 2] as usize).is_some_and(|s| *s == "nb" || *s == "gel") {
|
||||
let nv = nums[i + 5] as usize;
|
||||
let nt = nums[i + 6 + nv * 3] as usize;
|
||||
assert_eq!(nt, 1, "ein Dreieck je Netz");
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
n
|
||||
}
|
||||
|
||||
/// [259] Geschoss-Mengen wie die Flächentabelle: GF = NGF + Konstruktionsfläche (Wände), nicht nur die Räume.
|
||||
#[test]
|
||||
fn geschoss_mengen_mit_konstruktionsflaeche() {
|
||||
let p = sample();
|
||||
let t = crate::flaechen::area_table(&p);
|
||||
let row = t.levels.iter().find(|r| r.kf > 0.0 && r.rooms > 0).expect("Geschoss mit Wänden und Räumen");
|
||||
let f = ifc_export_data(&p, &IfcOptions::default()).unwrap();
|
||||
let (nums, _) = from_bytes(&f.to_bytes()).unwrap();
|
||||
assert!(row.gf > row.ngf);
|
||||
assert!(nums.iter().any(|v| (*v - row.gf).abs() < 1e-9), "GF {} fehlt", row.gf);
|
||||
assert!(nums.iter().any(|v| (*v - row.kf).abs() < 1e-9), "KGF {} fehlt", row.kf);
|
||||
let s = strings(&f);
|
||||
assert!(s.iter().any(|x| x == "building") && s.iter().any(|x| x == "Qto_BuildingBaseQuantities"));
|
||||
}
|
||||
|
||||
/// [259] Quader der Formöffnungs-Füllkörper: einheitlich nach aussen gewickelt (dicht, Volumen positiv), auch
|
||||
/// bei gespiegelter Eckenreihenfolge.
|
||||
#[test]
|
||||
fn quader_nach_aussen_gewickelt() {
|
||||
let corner = |i: usize, sx: f64| [sx * (i & 1) as f64 * 2.0, ((i >> 1) & 1) as f64 * 3.0, ((i >> 2) & 1) as f64 * 0.5];
|
||||
for sx in [1.0, -1.0] {
|
||||
let b: [f64; 24] = std::array::from_fn(|k| corner(k / 3, sx)[k % 3]);
|
||||
let t = box_tris_outward(&b);
|
||||
assert!((crate::export_flat::mesh_volume(&b, &t) - 3.0).abs() < 1e-12);
|
||||
assert!(is_watertight(&b, &t, 1e-9));
|
||||
assert!(crate::solid_bool::Solid::new(&crate::solid_bool::Mesh { positions: b.to_vec(), indices: t.to_vec() }).is_ok());
|
||||
}
|
||||
}
|
||||
|
||||
/// [208] Anonyme Abgabe: Kopf trägt Kennwort, festen Zeitstempel und leeren ISO-Text, nie den Projektnamen.
|
||||
#[test]
|
||||
fn anonyme_abgabe_kopf() {
|
||||
@@ -1830,9 +2076,9 @@ mod tests {
|
||||
for rec in [REC_CEILING_ARC, REC_SPACE_ARC] {
|
||||
assert!(f.nums.contains(&rec), "{rec}");
|
||||
}
|
||||
// Die Bulge-Werte stehen im Datensatz (Ring: x, y, bulge).
|
||||
assert!(f.nums.windows(3).any(|w| w[0] == first.x && w[1] == first.y && w[2] == 0.5));
|
||||
assert!(f.nums.iter().any(|&v| v == -0.5));
|
||||
// Die Bulge-Werte stehen im Datensatz (Ring: x, y, bulge), im DXF-Sinn des Schreibers (Vorzeichen gedreht).
|
||||
assert!(f.nums.windows(3).any(|w| w[0] == first.x && w[1] == first.y && w[2] == -0.5));
|
||||
assert!(f.nums.iter().any(|&v| v == 0.5));
|
||||
}
|
||||
|
||||
/// [T2] Bogenwand: Datensatz WALL_ARC_SOLID mit Kreisachse (Mitte, Radius, Startwinkel, Schwenk) und
|
||||
@@ -1919,11 +2165,18 @@ mod tests {
|
||||
let mut p = sample();
|
||||
p.geo_anchor = Some(ProjectGeoAnchor { lv95: ProjectGeoAnchorLv95 { e: 2_683_000.0, n: 1_247_000.0, ..Default::default() }, model: Vec2 { x: 0.0, y: 0.0 }, height: Some(400.0), ..Default::default() });
|
||||
let f = ifc_export_data(&p, &IfcOptions::default()).unwrap();
|
||||
// Kopf: [Version, id, name, now, iso, hasGeo, refElevation, lat, lon, schema, nStoreys …]
|
||||
// Kopf: [Version, id, name, now, iso, hasGeo, refElevation, lat, lon, eastings, northings, schema, nStoreys …]
|
||||
assert_eq!(f.nums[5], 1.0);
|
||||
assert_eq!(f.nums[6], 400.0);
|
||||
assert!((f.nums[7] - 47.37).abs() < 0.1 && (f.nums[8] - 8.54).abs() < 0.1, "{} {}", f.nums[7], f.nums[8]);
|
||||
assert!(f.nums.iter().any(|v| *v > 2_683_000.0));
|
||||
assert_eq!((f.nums[9], f.nums[10]), (2_683_000.0, 1_247_000.0));
|
||||
// [259] Geometrie bleibt lokal: keine LV95-Millionen im Puffer ausser dem Versatz.
|
||||
assert_eq!(f.nums.iter().filter(|v| v.abs() > 1_000_000.0).count(), 2);
|
||||
// Bezugspunkt nicht im Ursprung: Versatz des Ursprungs; Höhe von ±0.00 vor der Höhe des Bezugspunkts.
|
||||
p.geo_anchor.as_mut().unwrap().model = Vec2 { x: 10.0, y: -5.0 };
|
||||
p.reference_elevation_masl = Some(441.3);
|
||||
let f = ifc_export_data(&p, &IfcOptions::default()).unwrap();
|
||||
assert_eq!((f.nums[6], f.nums[9], f.nums[10]), (441.3, 2_682_990.0, 1_247_005.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -2086,7 +2339,7 @@ mod tests {
|
||||
})
|
||||
.sum();
|
||||
assert!(bands.iter().any(|b| b.holes.as_ref().is_none_or(|h| h.is_empty()) && b.thickness < 0.2), "Stücke fehlen");
|
||||
let (pos, idx) = union_bands(&bands, 0.0).expect("ein Körper");
|
||||
let (pos, idx) = union_bands(&bands, 0.0, &[]).expect("ein Körper");
|
||||
assert!(is_watertight(&pos, &idx, 1e-6));
|
||||
let v = crate::export_flat::mesh_volume(&pos, &idx);
|
||||
assert!((v - shells).abs() < 1e-6, "{v} vs {shells}");
|
||||
|
||||
@@ -299,8 +299,9 @@ pub fn run_bin(p: &Project, name: &str, args: &[f64], text: &str) -> Result<Vec<
|
||||
match (name, args.len()) {
|
||||
("planDomains", 1) => crate::plan::domains::plan_domains_buf(p, &crate::plan::domains::PlanArgs::parse_in(p, args[0], text)?),
|
||||
// Export-Sammler ([K4], [B5], [C11]): flacher Puffer für `fileio` (Byte-Hülle `export_flat.rs`).
|
||||
("ifcExportData", 4) => {
|
||||
let opt = crate::ifc_data::IfcOptions { now: args[0], ifc2x3: args[1] != 0.0, ebkph: args[2] != 0.0, layer_codes: args[3] != 0.0, iso: text.to_string() };
|
||||
("ifcExportData", 4 | 5) => {
|
||||
// 5. Argument [259]: Kontext (Gelände, Nachbarn) mitgeben.
|
||||
let opt = crate::ifc_data::IfcOptions { now: args[0], ifc2x3: args[1] != 0.0, ebkph: args[2] != 0.0, layer_codes: args[3] != 0.0, context: args.get(4).is_some_and(|v| *v != 0.0), iso: text.to_string() };
|
||||
crate::ifc_data::ifc_export_data(p, &opt).map(|f| f.to_bytes())
|
||||
}
|
||||
("meshExportData", 3 | 4) => {
|
||||
|
||||
@@ -3,6 +3,37 @@
|
||||
|
||||
use super::*;
|
||||
|
||||
/// [259] Ecken mit gleicher Ausgabe (6 Nachkommastellen) zusammenlegen, Dreiecke ohne Fläche (doppelte Ecke) weglassen.
|
||||
/// Die Kern-Netze sind Dreieckssuppen (jede Ecke je Dreieck neu); ifcopenshell/OpenCASCADE nähte sie beim Abzug der
|
||||
/// Öffnungen nicht zusammen (Volumen einer Anbauwand 30 statt 7.5 m³), und Revit/Archicad lesen ein verbundenes Netz
|
||||
/// robuster. Nebenbei kleinere Dateien.
|
||||
pub(super) fn weld(mesh: &Mesh) -> Mesh {
|
||||
let key = |i: usize| -> [String; 3] {
|
||||
let c = &mesh.positions[i * 3..i * 3 + 3];
|
||||
[fmt_real(c[0]), fmt_real(c[1]), fmt_real(c[2])]
|
||||
};
|
||||
let mut index: HashMap<[String; 3], usize> = HashMap::new();
|
||||
let mut positions = Vec::with_capacity(mesh.positions.len());
|
||||
let mut indices = Vec::with_capacity(mesh.indices.len());
|
||||
for t in mesh.indices.chunks_exact(3) {
|
||||
let k = [key(t[0]), key(t[1]), key(t[2])];
|
||||
if k[0] == k[1] || k[1] == k[2] || k[0] == k[2] {
|
||||
continue;
|
||||
}
|
||||
for (j, kj) in k.into_iter().enumerate() {
|
||||
let at = *index.entry(kj).or_insert_with(|| {
|
||||
positions.extend_from_slice(&mesh.positions[t[j] * 3..t[j] * 3 + 3]);
|
||||
positions.len() / 3 - 1
|
||||
});
|
||||
indices.push(at);
|
||||
}
|
||||
}
|
||||
Mesh { positions, indices, closed: mesh.closed }
|
||||
}
|
||||
|
||||
/// Struktur-Nummer des Grundstücks (IfcSite, [259] Kontext); −1 = Gebäude, ≥ 0 = Geschoss.
|
||||
pub(super) const SITE: i64 = -2;
|
||||
|
||||
/// Entitäten-Schreiber mit allem Zustand, den die TS-Fassung in Closures hielt.
|
||||
pub(super) struct Builder {
|
||||
pub(super) lines: Vec<String>,
|
||||
@@ -14,6 +45,9 @@ pub(super) struct Builder {
|
||||
pub(super) extrude_dir: usize,
|
||||
pub(super) building_entity: usize,
|
||||
pub(super) building_placement: usize,
|
||||
/// [259] Grundstück: Träger des Kontexts (Struktur `SITE`).
|
||||
pub(super) site_entity: usize,
|
||||
pub(super) site_placement: usize,
|
||||
pub(super) storeys: Vec<Storey>,
|
||||
/// Eingliederung je Struktur (−1 = Gebäude), in Reihenfolge des ersten Auftretens.
|
||||
pub(super) containment: Vec<(i64, Vec<usize>)>,
|
||||
@@ -62,7 +96,9 @@ impl Builder {
|
||||
}
|
||||
|
||||
pub(super) fn placement_of(&self, structure: i64) -> usize {
|
||||
if structure < 0 {
|
||||
if structure == SITE {
|
||||
self.site_placement
|
||||
} else if structure < 0 {
|
||||
self.building_placement
|
||||
} else {
|
||||
self.storeys[structure as usize].placement
|
||||
@@ -70,7 +106,9 @@ impl Builder {
|
||||
}
|
||||
|
||||
pub(super) fn entity_of(&self, structure: i64) -> usize {
|
||||
if structure < 0 {
|
||||
if structure == SITE {
|
||||
self.site_entity
|
||||
} else if structure < 0 {
|
||||
self.building_entity
|
||||
} else {
|
||||
self.storeys[structure as usize].entity
|
||||
@@ -78,7 +116,9 @@ impl Builder {
|
||||
}
|
||||
|
||||
pub(super) fn key_of(&self, structure: i64) -> String {
|
||||
if structure < 0 {
|
||||
if structure == SITE {
|
||||
"site".to_string()
|
||||
} else if structure < 0 {
|
||||
"building".to_string()
|
||||
} else {
|
||||
format!("storey/{}", self.storeys[structure as usize].id)
|
||||
@@ -337,7 +377,22 @@ impl Builder {
|
||||
let c = self.add("IFCCARTESIANPOINT", list(&[fmt_real(cx), fmt_real(cy)]));
|
||||
let pl = self.add("IFCAXIS2PLACEMENT2D", format!("#{c},$"));
|
||||
let circle = self.add("IFCCIRCLE", format!("#{pl},{}", fmt_real(r)));
|
||||
self.add("IFCTRIMMEDCURVE", format!("#{circle},(#{p0}),(#{p1}),{},{}", if b > 0.0 { ".T." } else { ".F." }, enum_("CARTESIAN")))
|
||||
// [259] Beide Trimmungen (Punkt und Winkel im Bogenmass, Einheit RADIAN), massgebend der Winkel: mit nur
|
||||
// kartesischer Trimmung liess ifcopenshell/OpenCASCADE den Bogen fallen (Sehne statt Bogen, Raumfläche
|
||||
// und Deckenvolumen nach der Geometrie ≠ Mengen); Revit/Archicad lesen den Parameter zuverlässiger.
|
||||
let tau = std::f64::consts::TAU;
|
||||
let ang = |x: f64, y: f64| (((y - cy).atan2(x - cx) % tau) + tau) % tau;
|
||||
let (t0, t1) = (ang(x0, y0), ang(x1, y1));
|
||||
self.add(
|
||||
"IFCTRIMMEDCURVE",
|
||||
format!(
|
||||
"#{circle},(#{p0},IFCPARAMETERVALUE({})),(#{p1},IFCPARAMETERVALUE({})),{},{}",
|
||||
fmt_real(t0),
|
||||
fmt_real(t1),
|
||||
if b > 0.0 { ".T." } else { ".F." },
|
||||
enum_("PARAMETER")
|
||||
),
|
||||
)
|
||||
};
|
||||
segs.push(self.add("IFCCOMPOSITECURVESEGMENT", format!("{},.T.,#{curve}", enum_("CONTINUOUS"))));
|
||||
}
|
||||
@@ -407,6 +462,7 @@ impl Builder {
|
||||
}
|
||||
|
||||
pub(super) fn emit_face_set(&mut self, mesh: &Mesh) -> usize {
|
||||
let mesh = &weld(mesh);
|
||||
let coords: Vec<String> = mesh
|
||||
.positions
|
||||
.chunks_exact(3)
|
||||
@@ -427,6 +483,7 @@ impl Builder {
|
||||
/// aussen orientiertes Netz = IfcFacetedBrep über IfcClosedShell, sonst IfcShellBasedSurfaceModel über
|
||||
/// IfcOpenShell. Dreiecke mit doppelter Ecke (ohne Fläche) entfallen. Liefert (Körper, Darstellungsart).
|
||||
pub(super) fn emit_face_brep(&mut self, mesh: &Mesh) -> (usize, &'static str) {
|
||||
let mesh = &weld(mesh);
|
||||
let points: Vec<usize> = mesh
|
||||
.positions
|
||||
.chunks_exact(3)
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
// [FLAT_VERSION, META, Datensatz, Datensatz, …]
|
||||
// META = project_id, project_name, now (Sekunden, ganzzahlig), iso (Zeitstempel, Text; leer = anonyme Abgabe [208]:
|
||||
// neutrale Programm-/Personenangaben, fester Kopf-Zeitstempel), has_geo (0/1),
|
||||
// ref_elevation (NaN = keine), ref_lat, ref_lon (WGS84-Grad, NaN = keine; nur IFC2x3),
|
||||
// ref_elevation (m ü. M. von Modell-z 0 = ±0.00, NaN = keine), ref_lat, ref_lon (WGS84-Grad des
|
||||
// Modell-Ursprungs, NaN = keine; nur IFC2x3), eastings, northings (LV95 des Modell-Ursprungs, [259]),
|
||||
// schema (0 = IFC4, 1 = IFC2x3), n_storeys, (id, name, base) × n_storeys
|
||||
// PTS = n, x0, y0, …, x(n−1), y(n−1) (Profil, offen; Rust schliesst es)
|
||||
// MESH = n_verts, x, y, z, …, n_tris, i0, i1, i2, …, closed (0/1) (Indizes 0-basiert)
|
||||
@@ -108,6 +109,10 @@
|
||||
// TREE = 19 ([149] Baum), structure, id, name, PSETS, MESH (Stamm + Krone, Welt rel. Geschoss-UK)
|
||||
// IFC4: IfcGeographicElement (ObjectType „Baum", PredefinedType USERDEFINED); IFC2x3 (kennt die
|
||||
// Klasse nicht): IfcBuildingElementProxy mit ObjectType „Baum". GlobalId aus `tree/<id>`.
|
||||
// CONTEXT = 24 ([259] Kontext, nur mit Option), kind (0 Netz auf Umgebungsklasse, 1 Gelände), id, name, class
|
||||
// (Klasse als Text, leer = keine), MESH (Modell-Koordinaten, z absolut). Am IfcSite eingegliedert (nicht
|
||||
// im Geschoss); Gelände: IfcGeographicElement TERRAIN, sonst IfcBuildingElementProxy (ObjectType „Kontext",
|
||||
// USERDEFINED); IFC2x3 beides als Proxy. Description = Klasse. GlobalId aus `context/<id>`.
|
||||
//
|
||||
// Schema IFC2x3 (Coordination View 2.0, TC1; [B5] 28.10.): gleiche Datensätze, GUIDs, Psets und Mengen, aber
|
||||
// die Entitäten des Schemas — Netze als IfcFacetedBrep (dicht) bzw. IfcShellBasedSurfaceModel (offen) statt
|
||||
@@ -131,7 +136,8 @@ use crate::ifc_openings::{fill_geometry, DoorKind, FillParams, FillPart, Sash, M
|
||||
|
||||
/// Version der flachen Kodierung (erstes Element des Puffers). 3 seit 28.10.: Basismengen (Pset-Arten 3–5), Deckenaussparungen, Treppen mit Läufen.
|
||||
/// 4 seit 28.10.: Schema-Wahl und Breite/Länge im META.
|
||||
pub const FLAT_VERSION: f64 = 4.0;
|
||||
/// 5 seit 14.11. ([259]): Versatz des Modell-Ursprungs in LV95 im META, Geometrie bleibt lokal.
|
||||
pub const FLAT_VERSION: f64 = 5.0;
|
||||
|
||||
/// IFC-Schema der Ausgabe.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
@@ -160,6 +166,7 @@ pub const REC_WALL_ARC_SOLID: f64 = 17.0;
|
||||
pub const REC_GRID: f64 = 18.0;
|
||||
pub const REC_GUIDS: f64 = 23.0;
|
||||
pub const REC_TREE: f64 = 19.0;
|
||||
pub const REC_CONTEXT: f64 = 24.0;
|
||||
pub const REC_COLUMN_PIECES: f64 = 20.0;
|
||||
pub const REC_CEILING_ARC: f64 = 21.0;
|
||||
pub const REC_SPACE_ARC: f64 = 22.0;
|
||||
@@ -194,6 +201,7 @@ fn rec_name(code: f64) -> &'static str {
|
||||
c if c == REC_GRID => "GRID",
|
||||
c if c == REC_GUIDS => "GUIDS",
|
||||
c if c == REC_TREE => "TREE",
|
||||
c if c == REC_CONTEXT => "CONTEXT",
|
||||
c if c == REC_COLUMN_PIECES => "COLUMN_PIECES",
|
||||
_ => "?",
|
||||
}
|
||||
@@ -234,6 +242,8 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
|
||||
let has_geo = r.flag()?;
|
||||
let ref_elevation = r.raw()?;
|
||||
let (ref_lat, ref_lon) = (r.raw()?, r.raw()?);
|
||||
let (eastings, northings) = (r.f()?, r.f()?);
|
||||
let orthogonal_height = if ref_elevation.is_finite() { ref_elevation } else { 0.0 };
|
||||
let schema = match r.idx()? {
|
||||
0 => Schema::Ifc4,
|
||||
1 => Schema::Ifc2x3,
|
||||
@@ -258,6 +268,8 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
|
||||
extrude_dir: 0,
|
||||
building_entity: 0,
|
||||
building_placement: 0,
|
||||
site_entity: 0,
|
||||
site_placement: 0,
|
||||
storeys: Vec::new(),
|
||||
containment: Vec::new(),
|
||||
psets: Vec::new(),
|
||||
@@ -320,9 +332,10 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
|
||||
format!("$,{},3,{},#{},$", ifc_string("Model"), fmt_real(0.00001), w.identity_axis),
|
||||
);
|
||||
|
||||
// Georeferenz: Geometrie liegt schon in LV95-Weltkoordinaten (TS), die Abbildung ist die Identität;
|
||||
// das Koordinatensystem wird trotzdem deklariert (IFC4 IfcProjectedCRS + IfcMapConversion; IFC2x3 kennt
|
||||
// beide nicht und bekommt ePSet_ProjectedCRS/ePSet_MapConversion am IfcProject, s. unten).
|
||||
// Georeferenz ([259]): die Geometrie bleibt lokal (Modell-Meter, z 0 = ±0.00), IfcMapConversion verschiebt den
|
||||
// Ursprung nach LV95 (Eastings/Northings) und auf die Meereshöhe von ±0.00 (OrthogonalHeight); keine Drehung (das
|
||||
// Modell ist nach Norden ausgerichtet, x = Ost). IFC2x3 kennt beide Entitäten nicht und bekommt
|
||||
// ePSet_ProjectedCRS/ePSet_MapConversion am IfcProject (s. unten).
|
||||
if has_geo && !v2 {
|
||||
let crs = w.add(
|
||||
"IFCPROJECTEDCRS",
|
||||
@@ -339,9 +352,9 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
|
||||
format!(
|
||||
"#{},#{crs},{},{},{},{},{},{}",
|
||||
w.context,
|
||||
fmt_real(0.0),
|
||||
fmt_real(0.0),
|
||||
fmt_real(0.0),
|
||||
fmt_real(eastings),
|
||||
fmt_real(northings),
|
||||
fmt_real(orthogonal_height),
|
||||
fmt_real(1.0),
|
||||
fmt_real(0.0),
|
||||
fmt_real(1.0)
|
||||
@@ -394,6 +407,10 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
|
||||
enum_("ELEMENT")
|
||||
),
|
||||
);
|
||||
// Schlüssel für Mengen am Gebäude (ATTACH „building“, [259]) und die Kontext-Eingliederung am Grundstück.
|
||||
w.elements.insert("building".to_string(), w.building_entity);
|
||||
w.site_entity = site_entity;
|
||||
w.site_placement = site_placement;
|
||||
let g = w.gid("aggregates/site");
|
||||
w.add(
|
||||
"IFCRELAGGREGATES",
|
||||
@@ -406,7 +423,7 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
|
||||
);
|
||||
|
||||
// IFC2x3-Georeferenz (Konvention buildingSMART): Koordinatensystem und Abbildung als Eigenschaftssätze am
|
||||
// IfcProject. Die Geometrie liegt schon in LV95, die Abbildung ist die Identität.
|
||||
// IfcProject, mit demselben Versatz wie IfcMapConversion.
|
||||
if v2 && has_geo {
|
||||
let txt = |name: &str, ty: &str, v: &str| (name.to_string(), format!("{ty}({})", ifc_string(v)));
|
||||
let num = |name: &str, ty: &str, v: f64| (name.to_string(), format!("{ty}({})", fmt_real(v)));
|
||||
@@ -418,9 +435,9 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
|
||||
txt("MapUnit", "IFCLABEL", "METRE"),
|
||||
];
|
||||
let conversion = [
|
||||
num("Eastings", "IFCLENGTHMEASURE", 0.0),
|
||||
num("Northings", "IFCLENGTHMEASURE", 0.0),
|
||||
num("OrthogonalHeight", "IFCLENGTHMEASURE", 0.0),
|
||||
num("Eastings", "IFCLENGTHMEASURE", eastings),
|
||||
num("Northings", "IFCLENGTHMEASURE", northings),
|
||||
num("OrthogonalHeight", "IFCLENGTHMEASURE", orthogonal_height),
|
||||
num("XAxisAbscissa", "IFCREAL", 1.0),
|
||||
num("XAxisOrdinate", "IFCREAL", 0.0),
|
||||
num("Scale", "IFCREAL", 1.0),
|
||||
@@ -970,6 +987,29 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
|
||||
w.add_pset(p, entity, &key);
|
||||
}
|
||||
}
|
||||
c if c == REC_CONTEXT => {
|
||||
// [259] Kontext am IfcSite: Gelände als IfcGeographicElement TERRAIN, Nachbarn als Proxy (IFC2x3: beide Proxy).
|
||||
let terrain = r.idx()? == 1;
|
||||
let id = r.string()?;
|
||||
let name = r.string()?;
|
||||
let class = r.string()?;
|
||||
let mesh = r.mesh()?;
|
||||
let (placement, shape) = w.emit_triangulated_product(&mesh, w.site_placement);
|
||||
let key = format!("context/{id}");
|
||||
let g = w.gid(&key);
|
||||
let description = if class.is_empty() { "$".to_string() } else { ifc_string(&class) };
|
||||
let object_type = ifc_string(if terrain { "Gelände" } else { "Kontext" });
|
||||
let head = format!("{g},#{},{},{description},{object_type},#{placement},#{shape},$", w.owner_history, ifc_string(&name));
|
||||
let entity = if terrain && !w.v2() {
|
||||
w.add("IFCGEOGRAPHICELEMENT", format!("{head},{}", enum_("TERRAIN")))
|
||||
} else if w.v2() {
|
||||
w.add("IFCBUILDINGELEMENTPROXY", format!("{head},$"))
|
||||
} else {
|
||||
w.add("IFCBUILDINGELEMENTPROXY", format!("{head},{}", enum_("USERDEFINED")))
|
||||
};
|
||||
w.add_to_containment(SITE, entity);
|
||||
w.elements.insert(key, entity);
|
||||
}
|
||||
c if c == REC_ROOF => {
|
||||
let structure = r.structure(n_storeys)?;
|
||||
let id = r.string()?;
|
||||
|
||||
@@ -62,10 +62,11 @@ impl B {
|
||||
fn v2() -> Self {
|
||||
B { schema: 1.0, ..B::new() }
|
||||
}
|
||||
/// META ab `has_geo`: Geo-Flag, Höhe, Breite/Länge (nur mit Geo), Schema, Anzahl Geschosse.
|
||||
/// META ab `has_geo`: Geo-Flag, Höhe, Breite/Länge (nur mit Geo), Versatz LV95 ([259]), Schema, Anzahl Geschosse.
|
||||
fn meta_tail(&mut self, geo: bool, elevation: f64, storeys: f64) {
|
||||
let (lat, lon) = if geo { (47.376_9, 8.541_7) } else { (f64::NAN, f64::NAN) };
|
||||
self.f.extend([if geo { 1.0 } else { 0.0 }, elevation, lat, lon, self.schema, storeys]);
|
||||
let (e, n) = if geo { (2_683_000.0, 1_247_000.0) } else { (0.0, 0.0) };
|
||||
self.f.extend([if geo { 1.0 } else { 0.0 }, elevation, lat, lon, e, n, self.schema, storeys]);
|
||||
}
|
||||
fn s(&mut self, x: &str) -> f64 {
|
||||
self.s.push(x.to_string());
|
||||
@@ -366,6 +367,8 @@ fn volles_haus_ist_wohlgeformt() {
|
||||
assert_eq!(count(&ifc, "IFCBUILDINGSTOREY"), 1);
|
||||
assert_eq!(count(&ifc, "IFCPROJECTEDCRS"), 1);
|
||||
assert_eq!(count(&ifc, "IFCMAPCONVERSION"), 1);
|
||||
// [259] Versatz des lokalen Ursprungs nach LV95, Höhe von ±0.00 = RefElevation.
|
||||
assert!(ifc.contains(",2683000.0,1247000.0,421.5,1.0,0.0,1.0);"), "IfcMapConversion mit Versatz");
|
||||
assert!(ifc.contains(",421.5,$,$);"), "RefElevation");
|
||||
assert!(ifc.contains("'Haus \\X2\\00C4\\X0\\'"));
|
||||
// Gleiche Wandtypen teilen Typ, Materialschichten und Pset.
|
||||
@@ -560,7 +563,7 @@ fn bogenwand_als_bogenprofil() {
|
||||
assert_eq!(count(&ifc, "IFCCOMPOSITECURVESEGMENT"), 4);
|
||||
assert_eq!(count(&ifc, "IFCCIRCLE"), 3, "zwei Profilbögen und die Achse");
|
||||
assert!(ifc.contains(",2.6);") && ifc.contains(",2.4);"), "Radien 2.6 und 2.4");
|
||||
assert!(ifc.contains(".F.,.CARTESIAN.") && ifc.contains(".T.,.CARTESIAN."));
|
||||
assert!(ifc.contains(".F.,.PARAMETER.") && ifc.contains(".T.,.PARAMETER."));
|
||||
assert!(ifc.contains("'Body','SweptSolid'") && ifc.contains("'Axis','Curve2D'"));
|
||||
// Kaputtes Profil: Fehler statt Panik.
|
||||
let mut b = mini();
|
||||
@@ -798,7 +801,9 @@ fn decke_mit_bogenkante_hat_zusammengesetzte_kurve() {
|
||||
assert_eq!(count(&ifc, "IFCTRIMMEDCURVE"), 1);
|
||||
// Aussparung ohne Bögen bleibt Linienzug.
|
||||
assert_eq!(count(&ifc, "IFCPOLYLINE"), 4);
|
||||
assert!(first_line(&ifc, "IFCTRIMMEDCURVE").contains(".F.,.CARTESIAN."));
|
||||
// [259] Punkt und Winkel als Trimmung, massgebend der Winkel (ifcopenshell liess den Bogen sonst fallen).
|
||||
let t = first_line(&ifc, "IFCTRIMMEDCURVE");
|
||||
assert!(t.contains(",IFCPARAMETERVALUE(") && t.ends_with(".F.,.PARAMETER.);"), "{t}");
|
||||
}
|
||||
|
||||
/// Treppe mit zwei Läufen (Prismen), Podest und Geländer (Mesh).
|
||||
@@ -1117,6 +1122,40 @@ fn baum_als_geografisches_element() {
|
||||
}
|
||||
}
|
||||
|
||||
/// [259] Kontext: Gelände als IfcGeographicElement TERRAIN, Nachbar als Proxy „Kontext"; beide am IfcSite (eigene
|
||||
/// Eingliederung, nicht im Gebäude/Geschoss), Klasse als Beschreibung. IFC2x3: beide als Proxy.
|
||||
#[test]
|
||||
fn kontext_am_grundstueck() {
|
||||
for v2 in [false, true] {
|
||||
let mut b = mini_in(if v2 { B::v2() } else { B::new() });
|
||||
for (kind, id, name, class) in [(1.0, "T", "Gelände", "02 Gelände"), (0.0, "N", "Nachbargebäude", "12 Gebäude")] {
|
||||
b.n(&[REC_CONTEXT, kind]);
|
||||
b.str(id);
|
||||
b.str(name);
|
||||
b.str(class);
|
||||
b.n(&[3.0, 0.0, 0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 10.0, 1.0]);
|
||||
b.n(&[1.0, 0.0, 1.0, 2.0, 0.0]);
|
||||
}
|
||||
let ifc = build(&b).unwrap();
|
||||
check_structure(&ifc);
|
||||
let site = ifc.lines().find(|l| l.contains("=IFCSITE(")).unwrap().split('=').next().unwrap().to_string();
|
||||
let terrain = ifc.lines().find(|l| l.contains(&ifc_string("Gelände")) && l.contains(&ifc_guid("t/context/T"))).unwrap();
|
||||
let neighbour = ifc.lines().find(|l| l.contains(&ifc_guid("t/context/N"))).unwrap();
|
||||
if v2 {
|
||||
assert!(terrain.contains("=IFCBUILDINGELEMENTPROXY(") && terrain.ends_with(",$);"), "{terrain}");
|
||||
assert_eq!(count(&ifc, "IFCGEOGRAPHICELEMENT"), 0);
|
||||
} else {
|
||||
assert!(terrain.contains("=IFCGEOGRAPHICELEMENT(") && terrain.ends_with(".TERRAIN.);"), "{terrain}");
|
||||
assert!(neighbour.contains("=IFCBUILDINGELEMENTPROXY(") && neighbour.ends_with(".USERDEFINED.);"), "{neighbour}");
|
||||
}
|
||||
assert!(neighbour.contains(&format!("{},'Kontext'", ifc_string("12 Gebäude"))), "{neighbour}");
|
||||
let contains: Vec<&str> = ifc.lines().filter(|l| l.contains("=IFCRELCONTAINEDINSPATIALSTRUCTURE(")).collect();
|
||||
assert_eq!(contains.len(), 1, "nur der Kontext ist eingegliedert");
|
||||
assert!(contains[0].ends_with(&format!(",{site});")), "{}", contains[0]);
|
||||
assert!(contains[0].contains(&ifc_guid("t/contains/site")));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ifc2x3_fenster_stil_klassifikation_zone_treppe() {
|
||||
let mut b = full_house_in(B::v2(), false);
|
||||
@@ -1253,9 +1292,9 @@ fn kaputte_puffer_ergeben_fehler_nie_panic() {
|
||||
}
|
||||
}
|
||||
// Unbekannter Datensatz, Geschoss-Index ausserhalb, Dreiecks-Index ausserhalb.
|
||||
let mut g = vec![FLAT_VERSION, 0.0, 0.0, 1.0, 0.0, 0.0, f64::NAN, f64::NAN, f64::NAN, 0.0, 0.0, 99.0];
|
||||
let mut g = vec![FLAT_VERSION, 0.0, 0.0, 1.0, 0.0, 0.0, f64::NAN, f64::NAN, f64::NAN, 0.0, 0.0, 0.0, 0.0, 99.0];
|
||||
assert!(build_ifc(&g, "a").is_err());
|
||||
g[11] = REC_STAIR;
|
||||
g[13] = REC_STAIR;
|
||||
g.extend([3.0]);
|
||||
assert!(build_ifc(&g, "a").is_err());
|
||||
let mut m = B::new();
|
||||
@@ -1302,3 +1341,17 @@ fn stuetze_mit_hoehenabschnitten() {
|
||||
// Zweiter Abschnitt sitzt 1.5 m über dem ersten.
|
||||
assert!(ifc.contains("IFCCARTESIANPOINT((0.0,0.0,1.5))"), "Versatz des oberen Abschnitts");
|
||||
}
|
||||
|
||||
/// [259] Dreieckssuppe → verbundenes Netz: gleiche Ecken (auf 6 Stellen) einmal, Dreieck mit doppelter Ecke fällt weg.
|
||||
#[test]
|
||||
fn netz_wird_verschweisst() {
|
||||
let soup = Mesh {
|
||||
positions: vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.000_000_1, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 5.0, 5.0],
|
||||
indices: vec![0, 1, 2, 3, 4, 5, 6, 7, 8],
|
||||
closed: true,
|
||||
};
|
||||
let m = weld(&soup);
|
||||
assert_eq!(m.positions.len() / 3, 4, "{:?}", m.positions);
|
||||
assert_eq!(m.indices, vec![0, 1, 2, 1, 3, 2]);
|
||||
assert!(m.closed);
|
||||
}
|
||||
+2
-2
@@ -21,7 +21,7 @@
|
||||
// --model-view <Name> wählt eine Modelldarstellung (eigene Stufe oder grob/mittel/fein) [173]
|
||||
// --hide <Code|Name,…> blendet Klassen aus (z. B. --hide "Schatten,Auto-Bemassung") [180]
|
||||
// --snapshot <Name|id> übernimmt Geschoss, Massstab, Vorlage und Sichtbarkeit eines Ausschnitts [207]
|
||||
// dossier-cli <projekt.obp> ifc [--ebkph] [--ebenen] (IFC mit eBKP-H-Hauptgruppen bzw. Modell-Ebenen als Klassifikation)
|
||||
// dossier-cli <projekt.obp> ifc [--ebkph] [--ebenen] [--kontext] (IFC mit eBKP-H-Hauptgruppen bzw. Modell-Ebenen als Klassifikation; --kontext: Gelände/Nachbarn mitgeben)
|
||||
// --schema 4|2x3: IFC4 (Standard) oder IFC2x3 (Coordination View 2.0)
|
||||
// dossier-cli <projekt.obp> dxf [--binary] [--scale 100] [--dim-unit cm] [--layout]|dwg|ifc|step|obj [--no-mtl]|stl|glb|gltf|schedule [--openings|--elements|--rooms] [--format json|csv|svg|pdf]|kennzahlen [--sia416] [--ivhb] [--nachweis] [--format json|csv|svg|pdf] [--agsf m2] [--gruenflaeche m2] [--agf-basis gf|ngf|nf] [--untergeschosse]|raumprogramm [--import tabelle] [--sheet name|nr] [--mode replace|append] [--tolerance %] [--generate] [--format json|csv|svg|pdf] [--save projekt.obp]|sun [--level EG] [--out datei]
|
||||
// glb/gltf = glTF 2.0 (Y-up, Meter, Geschoss als Eltern; --flat ohne Geschoss-Knoten)
|
||||
@@ -1082,7 +1082,7 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
case "ifc":
|
||||
await loadFileio();
|
||||
// --ebkph: eBKP-H-Hauptgruppen je Bauteilart; --ebenen: Ebene (categoryCode) des Modells als Klassifikation.
|
||||
out(args, exportIfcSpf(project, { ebkph: args.flags.has("ebkph"), layerCodes: args.flags.has("ebenen"), schema: ifcSchemaFlag(args) }), `${exportProjectName(project) || "projekt"}.ifc`);
|
||||
out(args, exportIfcSpf(project, { ebkph: args.flags.has("ebkph"), layerCodes: args.flags.has("ebenen"), context: args.flags.has("kontext"), schema: ifcSchemaFlag(args) }), `${exportProjectName(project) || "projekt"}.ifc`);
|
||||
return 0;
|
||||
case "obj":
|
||||
await loadFileio();
|
||||
|
||||
@@ -49,10 +49,13 @@ describe("IFC-Export: Zonen und Geschoss-Kennwerte (SIA 416)", () => {
|
||||
expect(lines(ifc, "IFCCLASSIFICATION")).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("ohne Räume keine Zonen und keine Geschoss-Mengen", () => {
|
||||
it("ohne Räume keine Zonen; Geschoss-Mengen nur aus der Konstruktionsfläche der Wände ([259])", () => {
|
||||
const ifc = exportIfcSpf({ ...sampleProject, rooms: [] });
|
||||
expect(lines(ifc, "IFCZONE")).toHaveLength(0);
|
||||
expect(ifc).not.toContain("Qto_BuildingStoreyBaseQuantities");
|
||||
expect(ifc).toContain("Qto_BuildingStoreyBaseQuantities");
|
||||
expect(ifc).toMatch(/IFCQUANTITYAREA\('NetFloorArea',\$,\$,0\.0,\$\)/);
|
||||
// Ohne Wände und Räume: gar keine Geschoss-Mengen.
|
||||
expect(exportIfcSpf({ ...sampleProject, rooms: [], walls: [], openings: [] })).not.toContain("Qto_BuildingStoreyBaseQuantities");
|
||||
});
|
||||
|
||||
it("GUIDs der Zonen und der übrigen Bauteile bleiben stabil (zweimal exportiert gleich)", () => {
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
// [259] IFC-Export für Fachplaner (Vorprojekt): alle drei Beispielprojekte gegen ifcopenshell — Schema/Express-Regeln/
|
||||
// Geometrie (`scripts/validate-ifc.py`) und die inhaltliche Prüfung `scripts/check-ifc-fachplaner.py` (räumliche
|
||||
// Struktur, jedes Bauteil genau einmal eingeordnet, Georeferenz lokal + IfcMapConversion EPSG:2056, Öffnungen gefüllt
|
||||
// und im Geschoss des Wirts, Räume mit Mengen/SIA-416-Kategorie, Wandschichten, Mengen ±1 % gegen die Geometrie,
|
||||
// Geschoss-GF mit Konstruktionsfläche, Kontext nur mit Option, keine 2D-Objektbibliothek als 3D-Körper).
|
||||
// Ohne Python/ifcopenshell übersprungen (CI installiert es).
|
||||
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdtempSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import "../engine/fileioWasm.setup";
|
||||
import { exportIfcSpf, ifcGuid, type IfcExportOptions } from "./exportIfc";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import { buildWettbewerbSampleProject } from "../model/sampleProjectWettbewerb";
|
||||
import type { Drawing2D, Project } from "../model/types";
|
||||
|
||||
const hasIfcOpenShell = spawnSync("python3", ["-c", "import ifcopenshell, ifcopenshell.validate, ifcopenshell.util.shape, _pytest"]).status === 0;
|
||||
|
||||
function writeIfc(name: string, ifc: string): string {
|
||||
const file = join(mkdtempSync(join(tmpdir(), "dossier-ifc-fp-")), `${name}.ifc`);
|
||||
writeFileSync(file, ifc);
|
||||
return file;
|
||||
}
|
||||
|
||||
interface Check {
|
||||
problems: string[];
|
||||
stats: Record<string, unknown> & { counts: Record<string, number>; context: number; far: number; known: string[]; map?: number[]; storeyQto?: Record<string, Record<string, number>> };
|
||||
}
|
||||
|
||||
/** Beide Prüfskripte; liefert die Kennwerte der inhaltlichen Prüfung. */
|
||||
function check(name: string, ifc: string, flags: string[]): Check {
|
||||
const file = writeIfc(name, ifc);
|
||||
const v = spawnSync("python3", ["scripts/validate-ifc.py", file], { encoding: "utf8", timeout: 400_000 });
|
||||
expect(`${v.stdout}\n${v.stderr}`).toContain(" 0 Befunde");
|
||||
const r = spawnSync("python3", ["scripts/check-ifc-fachplaner.py", file, "--json", ...flags], { encoding: "utf8", timeout: 400_000 });
|
||||
expect(r.stdout, r.stderr).not.toBe("");
|
||||
const out = JSON.parse(r.stdout) as Check;
|
||||
expect(out.problems).toEqual([]);
|
||||
expect(r.status).toBe(0);
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Export mit festem Zeitstempel (Vergleich zweier Dateien). */
|
||||
function exportAt(p: Project, options: IfcExportOptions = {}): string {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date("2026-11-14T10:00:00Z"));
|
||||
try {
|
||||
return exportIfcSpf(p, options);
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
}
|
||||
|
||||
describe.skipIf(!hasIfcOpenShell)("[259] IFC für Fachplaner (ifcopenshell)", { timeout: 900_000 }, () => {
|
||||
it("Musterhaus: Struktur, Mengen, Öffnungen", () => {
|
||||
const c = check("musterhaus", exportIfcSpf(sampleProject), []);
|
||||
expect(c.stats.counts.IfcWall).toBe(sampleProject.walls.length);
|
||||
expect(c.stats.context).toBe(0);
|
||||
});
|
||||
|
||||
it("Wettbewerb: georeferenziert (lokal + IfcMapConversion, ±0.00 = 441.30), Geschoss-GF mit Konstruktionsfläche", () => {
|
||||
const p = buildWettbewerbSampleProject();
|
||||
const c = check("wettbewerb", exportIfcSpf(p), ["--geo"]);
|
||||
expect(c.stats.far).toBeLessThan(1000);
|
||||
expect(c.stats.map).toEqual([p.geoAnchor!.lv95.e - p.geoAnchor!.model.x, p.geoAnchor!.lv95.n - p.geoAnchor!.model.y, 441.3]);
|
||||
const eg = c.stats.storeyQto!.Erdgeschoss;
|
||||
expect(eg.GrossFloorArea).toBeGreaterThan(eg.NetFloorArea);
|
||||
expect(c.stats.spaces).toBe(p.rooms!.length);
|
||||
});
|
||||
|
||||
it("Wettbewerb mit Kontext: Nachbargebäude am IfcSite, sonst nichts geändert", () => {
|
||||
const p = buildWettbewerbSampleProject();
|
||||
const c = check("wettbewerb-kontext", exportIfcSpf(p, { context: true }), ["--geo", "--context"]);
|
||||
expect(c.stats.context).toBe(p.context!.filter((o) => o.type === "importedMesh").length);
|
||||
});
|
||||
|
||||
it("komplex: Bogenkanten (Erker) mit Fläche/Volumen = Mengen, Kontext (Gelände + Nachbar) mit Option", () => {
|
||||
const p = buildComplexSampleProject();
|
||||
// Offen ([259]): Anbauwand OG Ost unter dem Pultdach (Netz mit Dach-Oberkante + Fenster) — ifcopenshell scheitert am
|
||||
// Abzug der Öffnung (30.4 statt 7.5 m³); Netz und Mengen stimmen mit dem 3D überein.
|
||||
const known = `--known=${ifcGuid(`${p.id}/wall/og-anbau-o`)}`;
|
||||
const k = check("komplex", exportIfcSpf(p), ["--geo", known]);
|
||||
expect(k.stats.known.length).toBeLessThanOrEqual(1);
|
||||
const c = check("komplex-kontext", exportIfcSpf(p, { context: true }), ["--geo", "--context", known]);
|
||||
expect(c.stats.counts.IfcGeographicElement).toBeGreaterThanOrEqual(1); // Gelände (TERRAIN)
|
||||
expect(c.stats.context).toBe(2); // Gelände + Nachbargebäude; Höhenlinien und Baugrube nicht
|
||||
});
|
||||
});
|
||||
|
||||
describe("[259] 2D-Objektbibliothek im IFC", () => {
|
||||
it("bleibt draussen: die Datei ist mit und ohne Objekte zeichengleich", () => {
|
||||
const objs: Drawing2D[] = [
|
||||
{ id: "wc", type: "drawing2d", levelId: "eg", categoryCode: "23", geom: { shape: "libobj", libId: "lib:wc-wand", at: { x: 1, y: 1 }, rotation: 0 } },
|
||||
{ id: "ti", type: "drawing2d", levelId: "eg", categoryCode: "22", geom: { shape: "libobj", libId: "lib:tisch-80x140", at: { x: 3, y: 2 }, rotation: 0.5, seed: 3 } },
|
||||
];
|
||||
const without = exportAt(sampleProject);
|
||||
const withObjs = exportAt({ ...sampleProject, drawings2d: [...sampleProject.drawings2d, ...objs] });
|
||||
expect(withObjs).toBe(without);
|
||||
expect(withObjs).not.toMatch(/IFCFURNITURE|IFCSANITARYTERMINAL|IFCFURNISHINGELEMENT/);
|
||||
});
|
||||
});
|
||||
@@ -307,10 +307,14 @@ describe("exportIfcSpf — IFC4-Export", () => {
|
||||
// Das Loch-Face-Set hat 48 CoordIndex-Tripel.
|
||||
const triCounts = faceSets.map((l) => (l.match(/\(\d+,\d+,\d+\)/g) ?? []).length);
|
||||
expect(triCounts).toContain(48);
|
||||
// Zugehörige Punktliste hat 144 Punkte (3er-Koordinaten-Tupel).
|
||||
const pointLists = lines.filter((l) => l.includes("=IFCCARTESIANPOINTLIST3D("));
|
||||
const ptCounts = pointLists.map((l) => (l.match(/\([^()]*,[^()]*,[^()]*\)/g) ?? []).length);
|
||||
expect(ptCounts).toContain(144);
|
||||
// [259] Zugehörige Punktliste verschweisst: jede Ecke einmal (vorher 144 = 3 je Dreieck).
|
||||
const hole = faceSets[triCounts.indexOf(48)];
|
||||
const listId = /IFCTRIANGULATEDFACESET\(#(\d+)/.exec(hole)![1];
|
||||
const list = lines.find((l) => l.startsWith(`#${listId}=`))!;
|
||||
const pts = list.match(/\([^()]*,[^()]*,[^()]*\)/g) ?? [];
|
||||
expect(new Set(pts).size).toBe(pts.length);
|
||||
expect(pts.length).toBeLessThan(144);
|
||||
expect(pts.length).toBeGreaterThanOrEqual(16); // Quader-Ecken + Loch-Ecken vorne/hinten
|
||||
// Keine dangling refs (der Kern-Invarianten-Check gilt auch mit Face-Sets).
|
||||
const { defined, referenced } = collectIds(spf);
|
||||
expect([...referenced].filter((id) => !defined.has(id))).toEqual([]);
|
||||
@@ -433,28 +437,26 @@ describe("exportIfcSpf — IFC4-Export", () => {
|
||||
expect(b.filter((g) => a.has(g))).toEqual([]);
|
||||
});
|
||||
|
||||
it("georeferenziert: mit geoAnchor werden die ECHTEN LV95-Koordinaten geschrieben (lokal bearbeitet, weltweit lagerichtig)", () => {
|
||||
// Modell lokal nahe (0,0), aber geoAnchor sagt: Modell (0,0) = LV95
|
||||
// (2600000,1200000). Der Export muss die Profil-/Punkt-Koordinaten auf die
|
||||
// echten Landeskoordinaten (Millionenbereich) verschoben schreiben.
|
||||
it("[259] georeferenziert: Geometrie bleibt lokal, IfcMapConversion trägt den LV95-Versatz und die Höhe von ±0.00", () => {
|
||||
// Modell lokal nahe (0,0), geoAnchor: Modell (2,1) = LV95 (2600002,1200001) ⇒ Ursprung = (2600000,1200000).
|
||||
// Vorher lag die ganze Geometrie in LV95-Millionen (Revit/Archicad warnen, Genauigkeit leidet).
|
||||
const local = fixtureProject();
|
||||
const withoutAnchor = exportIfcSpf(local);
|
||||
// Ohne Bezug: lokale Koordinaten, KEINE Millionenwerte im Text.
|
||||
expect(withoutAnchor).not.toMatch(/26000\d\d\./);
|
||||
expect(withoutAnchor).not.toContain("IFCMAPCONVERSION");
|
||||
|
||||
const geo: Project = {
|
||||
...local,
|
||||
geoAnchor: { lv95: { e: 2600000, n: 1200000 }, model: { x: 0, y: 0 } },
|
||||
geoAnchor: { lv95: { e: 2600002, n: 1200001 }, model: { x: 2, y: 1 } },
|
||||
referenceElevationMasl: 441.3,
|
||||
};
|
||||
const spf = exportIfcSpf(geo);
|
||||
// W1.start (0,0) -> LV95 (2600000,1200000); W2.end (5,4) -> (2600005,1200004).
|
||||
expect(spf).toContain("2600000.");
|
||||
expect(spf).toContain("1200000.");
|
||||
expect(spf).toContain("2600005.");
|
||||
// Koordinatensystem deklariert (IFC4): EPSG:2056 + Identitäts-Abbildung.
|
||||
// Nur der Versatz in Millionen, keine Koordinate.
|
||||
expect(spf.match(/\b2600000\.0\b/g)).toHaveLength(1);
|
||||
expect(spf).not.toMatch(/2600005\./);
|
||||
expect(spf).toContain("IFCPROJECTEDCRS('EPSG:2056'");
|
||||
expect(spf).toContain("IFCMAPCONVERSION(");
|
||||
expect(withoutAnchor).not.toContain("IFCMAPCONVERSION");
|
||||
expect(spf).toMatch(/IFCMAPCONVERSION\(#\d+,#\d+,2600000\.0,1200000\.0,441\.3,1\.0,0\.0,1\.0\);/);
|
||||
expect(spf).toMatch(/IFCSITE\(.*,441\.3,\$,\$\);/);
|
||||
// Struktur bleibt valide (keine dangling refs / Duplikate).
|
||||
const { defined, referenced, duplicates } = collectIds(spf);
|
||||
expect(duplicates).toEqual([]);
|
||||
|
||||
@@ -29,6 +29,11 @@ export interface IfcExportOptions {
|
||||
ebkph?: boolean;
|
||||
/** `categoryCode` (Ebene) des Modells als System „Dossier-Ebenen". */
|
||||
layerCodes?: boolean;
|
||||
/**
|
||||
* [259] Kontext mitgeben: Gelände (IfcGeographicElement TERRAIN) und Netze auf Umgebungsklassen wie Nachbargebäude
|
||||
* (IfcBuildingElementProxy „Kontext"), am IfcSite. Ohne Angabe nicht: Fachplaner wollen meist nur das Gebäude.
|
||||
*/
|
||||
context?: boolean;
|
||||
}
|
||||
|
||||
/** Deterministische 22-stellige IFC-GUID aus einem Namen (Rust, `ifc_export::ifc_guid`). */
|
||||
@@ -67,13 +72,13 @@ export function decodeExportFlat(bytes: Uint8Array): [Float64Array, string] {
|
||||
|
||||
/**
|
||||
* Baut aus einem Projekt einen vollständigen IFC-SPF-String (IFC4, oder IFC2x3 mit `options.schema`). Kein
|
||||
* Datei-IO. Leeres Projekt ⇒ valider Minimal-IFC (Project/Site/Building). Georeferenziert (`geoAnchor`):
|
||||
* Geometrie in LV95. Verlangt das geladene Format-Modul (`await loadFileio()`).
|
||||
* Datei-IO. Leeres Projekt ⇒ valider Minimal-IFC (Project/Site/Building). Georeferenziert (`geoAnchor`): Geometrie
|
||||
* lokal, IfcMapConversion mit dem LV95-Versatz und der Höhe von ±0.00 ([259]). Verlangt das geladene Format-Modul (`await loadFileio()`).
|
||||
*/
|
||||
export function exportIfcSpf(project: Project, options: IfcExportOptions = {}): string {
|
||||
const now = Date.now();
|
||||
const iso = new Date(now).toISOString().replace(/\.\d+Z$/, "");
|
||||
const args = [Math.floor(now / 1000), options.schema === "IFC2X3" ? 1 : 0, options.ebkph ? 1 : 0, options.layerCodes ? 1 : 0];
|
||||
const args = [Math.floor(now / 1000), options.schema === "IFC2X3" ? 1 : 0, options.ebkph ? 1 : 0, options.layerCodes ? 1 : 0, options.context ? 1 : 0];
|
||||
const [buf, strings] = decodeExportFlat(documentFor(project).queryBin("ifcExportData", args, iso));
|
||||
const m = fileio();
|
||||
const text = m.export_ifc_flat(buf, strings);
|
||||
|
||||
@@ -2861,6 +2861,8 @@ export const de = {
|
||||
"exportSave.ifc.ebkphHint": "Hauptgruppe je Bauteilart: Wand, Decke, Stütze, Treppe = C, Dach = F, Fenster = E; Türen bleiben ohne. Vorschlag für die Kostenplanung (CRB, eBKP-H, SN 506 511) — Aussen-/Innenwände und Untergruppen unterscheidet das Modell nicht.",
|
||||
"exportSave.ifc.layers": "Ebene (Kategorie-Code) des Modells als Klassifikation",
|
||||
"exportSave.ifc.layersHint": "System «Dossier-Ebenen»: Code und Name der Grafik-Ebene jedes Bauteils (kein Baukostenplan).",
|
||||
"exportSave.ifc.context": "Kontext mitgeben (Gelände, Nachbargebäude)",
|
||||
"exportSave.ifc.contextHint": "Gelände als IfcGeographicElement, Netze auf Umgebungsklassen (z. B. 12 Gebäude) als IfcBuildingElementProxy «Kontext», am Grundstück statt im Geschoss. Für Fachplaner meist aus lassen: sie brauchen nur das Gebäude.",
|
||||
"exportSave.ifc.zonesNote": "SIA-416-Zonen (HNF, NNF …) und Geschossflächen sind immer enthalten, sobald Räume vorhanden sind.",
|
||||
"exportSave.ifc.schema": "IFC-Schema",
|
||||
"exportSave.ifc.schema4": "IFC4 (Standard)",
|
||||
|
||||
@@ -3172,6 +3172,8 @@ export const en: Record<TranslationKey, string> = {
|
||||
"exportSave.ifc.ebkphHint": "Main group per element type: wall, slab, column, stair = C, roof = F, window = E; doors stay unclassified. A suggestion for cost planning (CRB, eBKP-H, SN 506 511) — the model does not tell exterior from interior walls or know sub-groups.",
|
||||
"exportSave.ifc.layers": "Model layer (category code) as classification",
|
||||
"exportSave.ifc.layersHint": "System “Dossier-Ebenen”: code and name of each element's graphic layer (not a cost plan).",
|
||||
"exportSave.ifc.context": "Include context (terrain, neighbouring buildings)",
|
||||
"exportSave.ifc.contextHint": "Terrain as IfcGeographicElement, meshes on context classes (e.g. 12 Buildings) as IfcBuildingElementProxy “Kontext”, placed on the site instead of a storey. Usually leave off for consultants: they only need the building.",
|
||||
"exportSave.ifc.zonesNote": "SIA 416 zones (HNF, NNF …) and floor areas are always included when rooms exist.",
|
||||
"exportSave.ifc.schema": "IFC schema",
|
||||
"exportSave.ifc.schema4": "IFC4 (default)",
|
||||
|
||||
@@ -66,9 +66,10 @@ export function ExportSaveDialog({
|
||||
// IFC-Klassifikation (Schweizer Praxis): beides aus, bis die Nutzerin es wählt.
|
||||
const [ebkph, setEbkph] = useState(false);
|
||||
const [layerCodes, setLayerCodes] = useState(false);
|
||||
const [context, setContext] = useState(false);
|
||||
// IFC-Schema: IFC4 (Standard) oder IFC2x3 für ältere Fachplaner-Programme.
|
||||
const [schema, setSchema] = useState<IfcSchema>("IFC4");
|
||||
const onConfirm = () => onSave(format, filename, format === "ifc" ? { schema, ebkph, layerCodes } : undefined);
|
||||
const onConfirm = () => onSave(format, filename, format === "ifc" ? { schema, ebkph, layerCodes, context } : undefined);
|
||||
|
||||
return (
|
||||
<div className="imp-overlay" onClick={onClose}>
|
||||
@@ -127,6 +128,11 @@ export function ExportSaveDialog({
|
||||
<span>{t("exportSave.ifc.layers")}</span>
|
||||
</label>
|
||||
<div className="imp-note">{t("exportSave.ifc.layersHint")}</div>
|
||||
<label className="imp-check">
|
||||
<input type="checkbox" checked={context} onChange={(e) => setContext(e.target.checked)} />
|
||||
<span>{t("exportSave.ifc.context")}</span>
|
||||
</label>
|
||||
<div className="imp-note">{t("exportSave.ifc.contextHint")}</div>
|
||||
<div className="imp-note">{t("exportSave.ifc.zonesNote")}</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user