[B3] IFC-Import: Öffnungen abziehen, Boolesche Körper und Halbräume, Rotation/Sweeps, Laden im Worker
- csg.rs: BSP-CSG (Verfahren csg.js, MIT, in Rust neu geschrieben: iterativ, Budget, Ursprung verschoben); Vereinigung/Differenz/Schnitt, Unsinn → None statt Panic. NOTICE ergänzt. - ifc_import.rs: IfcRelVoidsElement wird abgezogen (auch Öffnungen am Ganzen, z. B. IfcRoof → Platten); IfcBooleanResult/ClippingResult mit allen drei Operationen, Halbräume (HalfSpace, Boxed, PolygonalBounded auf IfcPlane) als Quader/Prisma um den Wirt; Kurven jetzt räumlich (3D-Bögen, Leitkurven); Ausrundungen bei RoundedRectangle/I/L/U/T; Bericht `voidsApplied`. - ifc_sweep.rs: IfcRevolvedAreaSolid, IfcSweptDiskSolid(+Polygonal), IfcFixedReferenceSweptAreaSolid, IfcSurfaceCurveSweptAreaSolid auf Ebene (Gehrung an Knicken). - ifcImport.ts/.worker.ts: Lesen im Web-Worker (Puffer übertragen), Rückfall im aufrufenden Thread. - Tests: Rust je Fall mit Sollvolumen; Rundreise des [B5]-Exports jetzt mit ausgeschnittenem Volumen für alle Wände; synthetische Testdatei io/testdata/ifc-geometry-cases.ifc, Gegencheck mit ifcopenshell (Skript zieht Öffnungen jetzt ab, stdout-Meldungen umgelenkt); Worker mit Attrappe. Geprüft: npm run check grün, build:cli, CLI import-ifc; gegen ifcopenshell alle 35 buildingSMART-Sample-Test-Files und 39/46 IFC4.3-sample-models (lokal, nicht eingecheckt). Nicht geprüft: Tauri-App/Browser (Worker nur als Attrappe in vitest), macOS. Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
11 files changed
+1639
-194
No files matched your search
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Gegencheck für den IFC-Import ([B3]): Dreiecke und Volumen je Bauteil aus ifcopenshell.geom.
|
||||
|
||||
Aufruf: python3 scripts/ifc-import-compare.py datei.ifc
|
||||
Aufruf: python3 scripts/ifc-import-compare.py datei.ifc [--no-openings]
|
||||
Ausgabe (stdout, JSON): {"<GlobalId>": {"class": "IfcWall", "triangles": 12, "volume": 1.5}, …}
|
||||
Volumen in m³ (Weltkoordinaten, Einheiten der Datei umgerechnet). Ausgelassen wie im Import:
|
||||
IfcOpeningElement, IfcSpace, IfcAnnotation, IfcGrid, IfcVirtualElement, IfcSpatialZone und Bauteile ohne Körper.
|
||||
@@ -9,6 +9,7 @@ Braucht `pip install ifcopenshell` (getestet mit 0.8/0.9).
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
import ifcopenshell
|
||||
@@ -19,11 +20,27 @@ SKIP = {"IfcOpeningElement", "IfcOpeningStandardCase", "IfcSpace", "IfcAnnotatio
|
||||
|
||||
|
||||
def main(path: str) -> int:
|
||||
# ifcopenshell schreibt bei manchen Dateien Meldungen auf stdout (C++): stdout während des Lesens
|
||||
# auf stderr umlenken, damit nur das JSON auf stdout landet.
|
||||
sys.stdout.flush()
|
||||
real_stdout = os.dup(1)
|
||||
os.dup2(2, 1)
|
||||
try:
|
||||
out = shapes(path)
|
||||
finally:
|
||||
sys.stdout.flush()
|
||||
os.dup2(real_stdout, 1)
|
||||
os.close(real_stdout)
|
||||
json.dump(out, sys.stdout)
|
||||
return 0
|
||||
|
||||
|
||||
def shapes(path: str) -> dict:
|
||||
model = ifcopenshell.open(path)
|
||||
settings = ifcopenshell.geom.settings()
|
||||
settings.set("use-world-coords", True)
|
||||
# Öffnungen nicht abziehen — der Mesh-Import [B3] tut es auch nicht.
|
||||
settings.set("disable-opening-subtractions", True)
|
||||
# Öffnungen werden abgezogen (wie im Import); `--no-openings` schaltet das ab.
|
||||
settings.set("disable-opening-subtractions", "--no-openings" in sys.argv)
|
||||
out = {}
|
||||
for product in model.by_type("IfcProduct"):
|
||||
if product.is_a() in SKIP or product.Representation is None:
|
||||
@@ -38,12 +55,12 @@ def main(path: str) -> int:
|
||||
"triangles": len(geom.faces) // 3,
|
||||
"volume": ifcopenshell.util.shape.get_volume(geom),
|
||||
}
|
||||
json.dump(out, sys.stdout)
|
||||
return 0
|
||||
return out
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
files = [a for a in sys.argv[1:] if not a.startswith("--")]
|
||||
if len(files) != 1:
|
||||
print(__doc__)
|
||||
sys.exit(2)
|
||||
sys.exit(main(sys.argv[1]))
|
||||
sys.exit(main(files[0]))
|
||||
Reference in new issue
Block a user