Merge [25][B3][B4][B5] IFC: Advanced Brep/NURBS, Rasterplatzierung, Sweep-Parameter; Tueranschlag beim Import; Tuer-/Fenstergeometrie in Rust

Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-10-28 14:03:07 +00:00
commit 02b5be72cf
18 files changed
+3452 -602

No files matched your search

+8
View File
@@ -12,6 +12,14 @@ i_overlay (https://github.com/iShape-Rust/iOverlay), MIT OR Apache-2.0
earcutr (https://github.com/frewsxcv/earcutr), ISC License — Rust-Port von mapbox/earcut (ISC)
Abhängigkeit von src-tauri/fileio (IFC-Import: Dreieckszerlegung von Profilen und Flächen), unverändert.
spade (https://github.com/Stoeoef/spade), MIT OR Apache-2.0
Abhängigkeit von src-tauri/fileio (IFC-Import: eingeschränkte Delaunay-Triangulierung getrimmter
Freiformflächen), unverändert.
truck (https://github.com/ricosjp/truck, truck-meshalgo src/tessellation/triangulation.rs), Apache-2.0
Nur das Verfahren (Rand in den Parameterraum projizieren, Rasterpunkte, eingeschränkte Delaunay-
Triangulierung, Auswahl innen) als Vorbild; eigener Code in src-tauri/fileio/src/ifc_nurbs.rs.
csg.js (https://github.com/evanw/csg.js, Datei csg.js), Copyright (c) 2011 Evan Wallace, MIT License
Verfahren (BSP-Bäume, Ebenen-Teilung, clipTo/invert, Vereinigung/Differenz/Schnitt) in Rust neu
geschrieben und angepasst: src-tauri/fileio/src/csg.rs (IFC-Import: Öffnungen, Boolesche Körper).
+31
View File
@@ -336,6 +336,22 @@ Ganzes nicht WASM-tauglich (rayon, tempfile, SystemTime) — nur einzelne Module
`plan/toWalls3d.ts::emitMeshes` setzt für Kontext-Meshes fest `IMPORTED_RGB`; Vorschlag: dort
`obj.color` (über `hexToRgb`/255) nehmen, falls gesetzt (der Plan zeichnet nur Umrisse in der
Ebenenfarbe). · M
(28.10., 4. Schritt, Freiform) IfcAdvancedBrep(+WithVoids)/IfcFaceSurface: Seiten auf Ebene, Zylinder,
Kegel, Kugel, Torus, (rationaler) B-Spline-Fläche mit Kanten aus IfcEdgeLoop/IfcEdgeCurve (Linie,
Polylinie, Kreis, B-Spline …, Kanten je Brep einmal zerlegt → dicht), getrimmt über den Parameterraum
(`fileio/src/ifc_nurbs.rs`: Projektion, Naht/Pol schliessen, eingeschränkte Delaunay-Triangulierung mit
crate spade, Raster nach Krümmung/Verdrillung, Nachverfeinern; Verfahren wie truck-meshalgo, eigener
Code, kein truck im fileio); IfcBSplineCurveWithKnots(+Rational) als Kurve (Profile, Leitkurven,
IfcTrimmedCurve); IfcGridPlacement (IFC2x3/4 und 4.3-Form); StartParam/EndParam der Sweeps
(Parameter der Leitkurve, IFC4.3 IfcLengthMeasure = Länge; ausserhalb des Bereichs → ganze Kurve).
Lesen in `fileio/src/ifc_brep.rs`. Gegencheck ifcopenshell: buildingSMART basin-/cube-advanced-brep
gleich (≤ 0.3 %), jetzt 77 von 81 Dateien (Sample-Test-Files 35/35, IFC4.3 42/46); grid-placement:
Stützen liegen auf den Rasterschnitten (ifcopenshell 0.9 liefert sie gar nicht). Neue synthetische
Fälle `io/testdata/ifc-freeform-cases.ifc` (Formelvolumen, ifcopenshell wo es sie kann; es übergeht
StartParam/EndParam absichtlich und scheitert an der nahtlosen Halbkugel). Offen: IFC4.3-Trassierung
(IfcAlignment/IfcGradientCurve/IfcLinearPlacement/IfcSectionedSolidHorizontal, 3 Dateien), Flächen
aus Kurven-Extrusion/-Rotation, IfcRectangularTrimmedSurface/IfcCurveBoundedPlane, komplexe
STEP-Instanzen (IFC2x3-NURBS); nur Linux-Container, nicht in der Tauri-App angesehen.
- ◐ **[B4] IFC-Import zu echten Bauteilen** (zweite Stufe von [25]). · L · nach [B3]. Stand 28.10.:
Wahl im Import-Dialog (`ui/IfcImportDialog.tsx`: Kontext-Meshes = Standard | Bauteile), CLI
`import-ifc … --elements`. Erkennung in Rust (`fileio/src/ifc_semantic.rs`, `import_ifc_elements`),
@@ -357,6 +373,15 @@ Ganzes nicht WASM-tauglich (rayon, tempfile, SystemTime) — nur einzelne Module
Profiländerung, Decken aus Dreiecksnetzen mit T-Stössen (zwei Teilflächen → Mesh), Tür-Anschlag/
Öffnungsrichtung, Tür-/Fenstertyp aus IfcDoorType/IfcWindowType, Farbe der Bauteile; nur Linux-
Container/vitest, nicht in der Tauri-App geprüft (Dialog nur per tsc).
(28.10., Tür-Ausführung) Tür: OperationType (IfcDoor, sonst IfcDoorType/IfcDoorStyle) → Scharnierseite
(LEFT = Scharnier auf +X der Tür-Platzierung, von der Aufschlagseite +Y gesehen, wie unser Export) und
Aufschlagseite (+Y gegen die Wandachse), Türtyp nach Dreh/Schiebe und Blattzahl; Fenster:
PartitioningType (IfcWindow, sonst IfcWindowType/IfcWindowStyle) → Fenstertyp mit gleicher Flügelzahl,
sonst `wingCount` an der Öffnung. Erkennung in Rust (`ifc_semantic.rs::operation`), TS ordnet zu.
Rundreise: alle 8 Kombinationen Scharnier/Aufschlag/Richtung landen räumlich gleich (Scharnierpunkt,
Aufschlagrichtung; `openingDir` kommt als „in“ mit gespiegeltem `swing` zurück), 2-flügliges Fenster →
Typ „Fenster 2-flügl.“. Offen: LEFT/RIGHT nur gegen den eigenen Export geprüft (nicht Revit/ArchiCAD);
Türen ohne Ausführung bleiben beim Standard (kein Raten aus der Platzierung).
- ◐ **[B5] IFC-Export nachziehen** (`exportIfc.ts`). Stand 28.10.:
- ✅ Nicht-ASCII nach ISO 10303-21 (`\X2\`/`\X4\`).
- ✅ Materialschichten: Wand-/Decken-/Dachtypen als IfcWallType/IfcSlabType/IfcRoofType mit
@@ -397,6 +422,12 @@ Ganzes nicht WASM-tauglich (rayon, tempfile, SystemTime) — nur einzelne Module
in `ifcOpenings.test.ts`. Offen: LEFT/RIGHT der Tür nach IFC-Konvention (Blick von der Aufschlagseite)
gelesen, nicht in Revit/ArchiCAD gegengeprüft; ohne Sprossen, Fensterbank, Rollladenkasten, Schwelle,
Flügelrahmen.
- ✅ Tür/Fenster-Geometrie nach Rust (Regel „Kern in Rust“, 28.10.): `fileio/src/ifc_openings.rs` rechnet
Rahmen/Zarge, Blatt, Glas, Füllungs-Placement und OperationType/PartitioningType; `export/ifcOpenings.ts`
sammelt nur die Parameter (Typ-/Öffnungswerte, fehlende als „keine“), flache Kodierung FILL (Version 2).
TS-Rechnung gelöscht, ihre Fälle als Rust-Tests. Golden-Vergleich: 419 verschiedene IFC-Ausgaben (Tests in
`export/*ifc*`, `io/ifcImport`, `io/ifcElements` und 780 Tür-/Fenster-Varianten: Glas-/Schiebe-/Wandöffnung,
Oberlicht, Flügeltabellen, Einzug innen, Klemmungen) vorher/nachher zeichengleich bis auf Zeitstempel.
- ○ Offen: Bogenwände als echte Kurve. · M
- ✅ Eigener IFC-Import ([B3]) zieht Öffnungen ab (28.10.): Rundreise vergleicht alle Wände mit dem
ausgeschnittenen Volumen (`ifcImport.test.ts`).
+43 -1
View File
@@ -32,6 +32,12 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "allocator-api2"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]]
name = "anyhow"
version = "1.0.103"
@@ -122,6 +128,7 @@ dependencies = [
"getrandom",
"serde",
"serde_json",
"spade",
"wasm-bindgen",
]
@@ -210,6 +217,17 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "hashbrown"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
dependencies = [
"allocator-api2",
"equivalent",
"foldhash",
]
[[package]]
name = "hashbrown"
version = "0.17.1"
@@ -223,7 +241,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
dependencies = [
"equivalent",
"hashbrown",
"hashbrown 0.17.1",
]
[[package]]
@@ -391,6 +409,12 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "robust"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e27ee8bb91ca0adcf0ecb116293afa12d393f9c2b9b9cd54d33e8078fe19839"
[[package]]
name = "rustversion"
version = "1.0.22"
@@ -464,6 +488,24 @@ version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
[[package]]
name = "smallvec"
version = "1.16.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8"
[[package]]
name = "spade"
version = "2.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9699399fd9349b00b184f5635b074f9ec93afffef30c853f8c875b32c0f8c7fa"
dependencies = [
"hashbrown 0.16.1",
"num-traits",
"robust",
"smallvec",
]
[[package]]
name = "syn"
version = "2.0.118"
+2
View File
@@ -43,3 +43,5 @@ console_error_panic_hook = { version = "0.1", optional = true }
# IFC-Import ([B3]): Dreieckszerlegung von Profilen und Flächen mit Löchern (ISC, Port von mapbox/earcut).
earcutr = "0.5"
# IFC-Import: eingeschränkte Delaunay-Triangulierung getrimmter Freiformflächen (MIT OR Apache-2.0).
spade = "2.15"
+477
View File
@@ -0,0 +1,477 @@
// IFC-Import ([B3]/[25]): Lesen von Freiform-Geometrie für `ifc_import` (Untermodul des Lesers):
// IfcBSplineCurveWithKnots/IfcRationalBSplineCurveWithKnots, IfcBSplineSurfaceWithKnots/
// IfcRationalBSplineSurfaceWithKnots, Kanten-Topologie (IfcEdgeLoop/IfcOrientedEdge/IfcEdgeCurve/
// IfcVertexPoint) der IfcAdvancedFace/IfcFaceSurface mit Trägerfläche Ebene, Zylinder, Kegel, Kugel, Torus
// oder B-Spline (Zerlegung in `ifc_nurbs`), StartParam/EndParam der Sweeps und IfcGridPlacement.
// Eigener Code.
use std::collections::HashMap;
use super::{dot, len, norm, sub, Mesh, Reader, Xf, MAX_CURVE_DEPTH, MAX_LOOP_POINTS, V3};
use crate::ifc_nurbs::{expand_knots, BSplineCurve, BSplineSurface, Surface};
use crate::ifc_step::{Entity, Value};
/// Parameter des Punkts von `pts` (Parameter, Punkt), der `p` am nächsten liegt (linear zwischen
/// Nachbarpunkten).
pub(super) fn nearest_param(pts: &[(f64, V3)], p: V3) -> Option<f64> {
let mut best: Option<(f64, f64)> = None;
for w in pts.windows(2) {
let (a, b) = (w[0].1, w[1].1);
let ab = sub(b, a);
let l2 = dot(ab, ab);
let f = if l2 > 0.0 { (dot(sub(p, a), ab) / l2).clamp(0.0, 1.0) } else { 0.0 };
let q = [a[0] + ab[0] * f, a[1] + ab[1] * f, a[2] + ab[2] * f];
let d = len(sub(p, q));
if best.is_none_or(|bst| d < bst.0) {
best = Some((d, w[0].0 + (w[1].0 - w[0].0) * f));
}
}
if pts.len() == 1 {
return Some(pts[0].0);
}
best.map(|b| b.1)
}
/// Lage von `p` auf der Punktfolge als (Segment, Anteil, Abstand).
fn locate(pts: &[V3], p: V3) -> Option<(usize, f64, f64)> {
let mut best: Option<(usize, f64, f64)> = None;
for i in 0..pts.len().saturating_sub(1) {
let (a, b) = (pts[i], pts[i + 1]);
let ab = sub(b, a);
let l2 = dot(ab, ab);
let f = if l2 > 0.0 { (dot(sub(p, a), ab) / l2).clamp(0.0, 1.0) } else { 0.0 };
let q = [a[0] + ab[0] * f, a[1] + ab[1] * f, a[2] + ab[2] * f];
let d = len(sub(p, q));
if best.is_none_or(|bst| d < bst.2) {
best = Some((i, f, d));
}
}
best
}
/// Teil der Kurve `pts` (in Kurvenrichtung) von `a` nach `b`; bei geschlossener Kurve auch über den
/// Anfang hinweg, bei `a` = `b` die ganze Schleife ab `a`.
fn trim_polyline(pts: &[V3], a: V3, b: V3, whole: bool) -> Vec<V3> {
let n = pts.len();
if n < 2 {
return vec![a, b];
}
let closed = len(sub(pts[0], pts[n - 1])) < 1e-9;
let (Some((ia, fa, _)), Some((ib, fb, _))) = (locate(pts, a), locate(pts, b)) else { return vec![a, b] };
let (sa, sb) = (ia as f64 + fa, ib as f64 + fb);
let mut out = vec![a];
if whole || (closed && sb <= sa) {
if !closed {
// Offene Kurve mit gleichem Anfangs- und Endpunkt der Kante: ganze Kurve.
out.extend_from_slice(&pts[1..n - 1]);
out.push(b);
return out;
}
if whole {
// Ganze Schleife ab `a`.
out.extend_from_slice(&pts[ia + 1..n - 1]);
out.extend_from_slice(&pts[..=ia]);
} else {
out.extend_from_slice(&pts[ia + 1..n - 1]);
out.extend_from_slice(&pts[..=ib]);
}
} else if sb >= sa {
out.extend_from_slice(&pts[ia + 1..=ib]);
} else {
// Offene Kurve, Endpunkt vor dem Anfang: rückwärts.
for k in (ib + 1..=ia).rev() {
out.push(pts[k]);
}
}
out.push(b);
out.dedup_by(|x, y| len(sub(*x, *y)) < 1e-12);
out
}
/// Zieht `pts` (Schlüssel `keys` aufsteigend) auf den Bereich [k0, k1] zusammen (linear zwischen
/// Punkten); Schlüssel nicht aufsteigend → unverändert.
fn trim_by_keys(pts: &[V3], keys: &[f64], k0: f64, k1: f64) -> Vec<V3> {
if pts.len() < 2 || keys.windows(2).any(|w| !(w[1] >= w[0])) {
return pts.to_vec();
}
let (k0, k1) = if k0 <= k1 { (k0, k1) } else { (k1, k0) };
let at = |k: f64| -> V3 {
let k = k.clamp(keys[0], keys[keys.len() - 1]);
let i = keys.partition_point(|x| *x <= k).clamp(1, keys.len() - 1);
let (ka, kb) = (keys[i - 1], keys[i]);
let f = if kb > ka { (k - ka) / (kb - ka) } else { 0.0 };
let (a, b) = (pts[i - 1], pts[i]);
[a[0] + (b[0] - a[0]) * f, a[1] + (b[1] - a[1]) * f, a[2] + (b[2] - a[2]) * f]
};
let mut out = vec![at(k0)];
for (k, p) in keys.iter().zip(pts) {
if *k > k0 && *k < k1 {
out.push(*p);
}
}
out.push(at(k1));
out.dedup_by(|x, y| len(sub(*x, *y)) < 1e-12);
out
}
/// Trägerfläche einer Seite.
pub(super) enum FaceSurface {
Plane,
Curved(Surface),
}
impl<'a> Reader<'a> {
fn f64_list(v: Option<&Value>) -> Option<Vec<f64>> {
v?.as_list()?.iter().map(|x| x.as_f64()).collect()
}
fn i64_list(v: Option<&Value>) -> Option<Vec<i64>> {
v?.as_list()?.iter().map(|x| x.as_i64()).collect()
}
fn degree(v: Option<&Value>) -> Option<usize> {
usize::try_from(v?.as_i64()?).ok()
}
/// IfcBSplineCurveWithKnots / IfcRationalBSplineCurveWithKnots.
pub(super) fn bspline_curve(&self, e: &Entity) -> Option<BSplineCurve> {
let p = Self::degree(e.arg(0))?;
let ctrl: Vec<V3> = e.arg(1)?.as_list()?.iter().take(MAX_LOOP_POINTS).map(|v| self.point(Some(v))).collect::<Option<_>>()?;
let knots = expand_knots(&Self::i64_list(e.arg(5))?, &Self::f64_list(e.arg(6))?)?;
let weights = if e.ty == "IFCRATIONALBSPLINECURVEWITHKNOTS" { Some(Self::f64_list(e.arg(8))?) } else { None };
BSplineCurve::new(p, ctrl, weights, knots)
}
/// IfcBSplineSurfaceWithKnots / IfcRationalBSplineSurfaceWithKnots.
fn bspline_surface(&self, e: &Entity) -> Option<BSplineSurface> {
let (pu, pv) = (Self::degree(e.arg(0))?, Self::degree(e.arg(1))?);
let rows: Vec<Vec<V3>> = e
.arg(2)?
.as_list()?
.iter()
.map(|r| r.as_list().and_then(|r| r.iter().map(|v| self.point(Some(v))).collect::<Option<Vec<V3>>>()))
.collect::<Option<_>>()?;
let uk = expand_knots(&Self::i64_list(e.arg(7))?, &Self::f64_list(e.arg(9))?)?;
let vk = expand_knots(&Self::i64_list(e.arg(8))?, &Self::f64_list(e.arg(10))?)?;
let weights = if e.ty == "IFCRATIONALBSPLINESURFACEWITHKNOTS" {
Some(e.arg(12)?.as_list()?.iter().map(|r| Self::f64_list(Some(r))).collect::<Option<Vec<_>>>()?)
} else {
None
};
BSplineSurface::new(pu, pv, rows, weights, uk, vk)
}
/// Trägerfläche einer Seite; nicht unterstützt → `None` (gezählt).
pub(super) fn face_surface(&mut self, v: Option<&Value>) -> Option<FaceSurface> {
let (_, e) = self.ent_v(v)?;
let s = match e.ty.as_str() {
"IFCPLANE" => return Some(FaceSurface::Plane),
"IFCCYLINDRICALSURFACE" => Surface::Cylinder(self.axis_placement(e.arg(0)), self.length(e.arg(1)).filter(|r| *r > 0.0)?),
"IFCCONICALSURFACE" => {
let a = e.arg(2)?.as_f64()? * self.angle_scale;
if !(a.abs() < std::f64::consts::FRAC_PI_2 - 1e-6) {
return None;
}
Surface::Cone(self.axis_placement(e.arg(0)), self.length(e.arg(1)).filter(|r| *r >= 0.0)?, a)
}
"IFCSPHERICALSURFACE" => Surface::Sphere(self.axis_placement(e.arg(0)), self.length(e.arg(1)).filter(|r| *r > 0.0)?),
"IFCTOROIDALSURFACE" => {
let big = self.length(e.arg(1)).filter(|r| *r > 0.0)?;
let r = self.length(e.arg(2)).filter(|r| *r > 0.0)?;
Surface::Torus(self.axis_placement(e.arg(0)), big, r)
}
"IFCBSPLINESURFACEWITHKNOTS" | "IFCRATIONALBSPLINESURFACEWITHKNOTS" => Surface::BSpline(self.bspline_surface(e)?),
other => {
let ty = format!("Fläche {other}");
self.skip(&ty);
return None;
}
};
Some(FaceSurface::Curved(s))
}
fn vertex_point(&self, v: Option<&Value>) -> Option<V3> {
let (_, e) = self.ent_v(v)?;
if e.ty != "IFCVERTEXPOINT" {
return None;
}
self.point(e.arg(0))
}
/// Punkte einer IfcEdgeCurve vom Anfangs- zum Endpunkt (zwischengespeichert, damit Nachbarseiten
/// dieselben Punkte teilen).
fn edge_points(&mut self, id: u64) -> Option<Vec<V3>> {
if let Some(p) = self.edge_cache.get(&id) {
return Some(p.clone());
}
let e = self.ent(id)?;
if e.ty != "IFCEDGECURVE" {
let ty = e.ty.clone();
self.skip(&ty);
return None;
}
let a = self.vertex_point(e.arg(0))?;
let b = self.vertex_point(e.arg(1))?;
let same = e.arg(3).and_then(|v| v.as_enum()) != Some("F");
let whole = e.arg(0).and_then(|v| v.as_ref_id()) == e.arg(1).and_then(|v| v.as_ref_id()) || len(sub(a, b)) < 1e-9;
let geom = self.ent_v(e.arg(2)).map(|(_, g)| g.ty.clone());
let pts = match geom.as_deref() {
// Gerade: nur die Endpunkte (die Linie ist unbegrenzt).
Some("IFCLINE") => vec![a, b],
_ => {
let mut c = self.curve(e.arg(2), 0)?;
// Ganze Schleife (Kreis ohne doppelten Schlusspunkt): ausdrücklich schliessen.
if whole && c.len() > 2 && len(sub(c[0], c[c.len() - 1])) >= 1e-9 {
c.push(c[0]);
}
if same {
trim_polyline(&c, a, b, whole)
} else {
let mut t = trim_polyline(&c, b, a, whole);
t.reverse();
t
}
}
};
if pts.len() > MAX_LOOP_POINTS || !pts.iter().all(|p| p.iter().all(|v| v.is_finite())) {
return None;
}
self.edge_cache.insert(id, pts.clone());
Some(pts)
}
/// IfcEdgeLoop → Punktfolge ohne doppelten Schlusspunkt.
pub(super) fn edge_loop(&mut self, lp: &Entity) -> Option<Vec<V3>> {
let mut out: Vec<V3> = Vec::new();
for oe in lp.arg(0)?.as_list()? {
let (oid, o) = self.ent_v(Some(oe))?;
let mut pts = match o.ty.as_str() {
"IFCORIENTEDEDGE" => {
let mut p = self.edge_points(o.arg(2)?.as_ref_id()?)?;
if o.arg(3).and_then(|v| v.as_enum()) == Some("F") {
p.reverse();
}
p
}
"IFCEDGECURVE" => self.edge_points(oid)?,
_ => return None,
};
if let (Some(l), Some(f)) = (out.last(), pts.first()) {
if len(sub(*l, *f)) < 1e-9 {
pts.remove(0);
}
}
out.extend(pts);
if out.len() > MAX_LOOP_POINTS {
return None;
}
}
while out.len() > 1 && len(sub(out[0], out[out.len() - 1])) < 1e-9 {
out.pop();
}
Some(out)
}
/// Seite mit gekrümmter Trägerfläche → Dreiecke an `out`; `false`, wenn nicht gelungen.
pub(super) fn curved_face(&mut self, s: &Surface, rings: &[Vec<V3>], same_sense: bool, out: &mut Mesh) -> bool {
match crate::ifc_nurbs::tessellate_face(s, rings, same_sense) {
Some(m) => {
out.append(&m, &Xf::IDENTITY);
true
}
None => {
self.skip("IFCADVANCEDFACE (Parameterraum, eben zerlegt)");
false
}
}
}
/// Leitkurve eines Sweeps mit StartParam/EndParam (`start`/`end` = Argumentnummern). Werte als
/// IfcLengthMeasure (IFC4.3) = Länge ab Kurvenanfang, sonst Parameter der Kurve (`curve_t`).
pub(super) fn sweep_path(&mut self, e: &Entity, path: usize, start: usize, end: usize) -> Option<Vec<V3>> {
let pts = self.curve_t(e.arg(path), 0)?;
let read = |v: Option<&Value>| -> Option<(f64, bool)> {
match v? {
Value::Typed(n, a) if n == "IFCLENGTHMEASURE" || n == "IFCNONNEGATIVELENGTHMEASURE" || n == "IFCPOSITIVELENGTHMEASURE" => {
Some((a.first()?.as_f64()? * self.len_scale, true))
}
other => other.as_f64().map(|x| (x, false)),
}
};
let (s, t) = (read(e.arg(start)), read(e.arg(end)));
let points: Vec<V3> = pts.iter().map(|x| x.1).collect();
if s.is_none() && t.is_none() {
return Some(points);
}
let params: Vec<f64> = pts.iter().map(|x| x.0).collect();
let mut lengths = Vec::with_capacity(points.len());
let mut acc = 0.0;
for (i, p) in points.iter().enumerate() {
if i > 0 {
acc += len(sub(*p, points[i - 1]));
}
lengths.push(acc);
}
// Beide Grenzen als Länge ausdrücken (Parameter → Länge über die Punktfolge).
let to_len = |x: Option<(f64, bool)>, dflt: f64| -> f64 {
match x {
None => dflt,
Some((v, true)) => v,
Some((v, false)) => {
if params.windows(2).any(|w| !(w[1] >= w[0])) {
return dflt;
}
let v = v.clamp(params[0], params[params.len() - 1]);
let i = params.partition_point(|p| *p <= v).clamp(1, params.len().max(2) - 1);
let (pa, pb) = (params[i - 1], params[i]);
let f = if pb > pa { (v - pa) / (pb - pa) } else { 0.0 };
lengths[i - 1] + (lengths[i] - lengths[i - 1]) * f
}
}
};
if points.len() < 2 {
return Some(points);
}
let k0 = to_len(s, 0.0);
let k1 = to_len(t, acc);
Some(trim_by_keys(&points, &lengths, k0, k1))
}
/// IfcGridPlacement: Schnittpunkt zweier (versetzter) Rasterachsen im System des Rasters, Richtung aus
/// PlacementRefDirection (Richtung oder zweiter Schnittpunkt), sonst die des Rasters.
pub(super) fn grid_placement(&mut self, e: &Entity, depth: usize) -> Option<Xf> {
// IFC4.3: (PlacementRelTo, PlacementLocation, PlacementRefDirection); früher ohne PlacementRelTo.
let off = if e.args.len() >= 3 { 1 } else { 0 };
let (grid_xf, o) = self.grid_intersection(e.arg(off), depth)?;
let x = match self.ent_v(e.arg(off + 1)) {
Some((_, d)) if d.ty == "IFCDIRECTION" => {
let d = self.direction(e.arg(off + 1))?;
[d[0], d[1], 0.0]
}
Some((_, d)) if d.ty == "IFCVIRTUALGRIDINTERSECTION" => {
let (_, q) = self.grid_intersection(e.arg(off + 1), depth)?;
sub(q, o)
}
_ => [1.0, 0.0, 0.0],
};
let x = norm([x[0], x[1], 0.0]).unwrap_or([1.0, 0.0, 0.0]);
let local = Xf::from_axes(x, [-x[1], x[0], 0.0], [0.0, 0.0, 1.0], o);
Some(grid_xf.then_after(&local))
}
/// IfcVirtualGridIntersection → (Platzierung des Rasters, Punkt im Raster-System).
fn grid_intersection(&mut self, v: Option<&Value>, depth: usize) -> Option<(Xf, V3)> {
let (_, vi) = self.ent_v(v)?;
if vi.ty != "IFCVIRTUALGRIDINTERSECTION" {
return None;
}
let axes: Vec<u64> = vi.arg(0)?.as_list()?.iter().filter_map(|x| x.as_ref_id()).collect();
if axes.len() != 2 {
return None;
}
let offs: Vec<f64> = vi.arg(1).and_then(|v| v.as_list()).unwrap_or(&[]).iter().map(|x| x.as_f64().unwrap_or(0.0) * self.len_scale).collect();
let off = |i: usize| offs.get(i).copied().filter(|x| x.is_finite()).unwrap_or(0.0);
let mut lines = Vec::new();
for (k, a) in axes.iter().enumerate() {
let ax = self.ent(*a)?;
if ax.ty != "IFCGRIDAXIS" {
return None;
}
let mut c = self.curve2d(ax.arg(1), MAX_CURVE_DEPTH - 2)?;
if ax.arg(2).and_then(|v| v.as_enum()) == Some("F") {
c.reverse();
}
// Versatz nach links (positiv) je Segment.
let segs: Vec<([f64; 2], [f64; 2])> = c
.windows(2)
.filter_map(|w| {
let d = [w[1][0] - w[0][0], w[1][1] - w[0][1]];
let l = (d[0] * d[0] + d[1] * d[1]).sqrt();
(l > 1e-12).then(|| {
let n = [-d[1] / l * off(k), d[0] / l * off(k)];
([w[0][0] + n[0], w[0][1] + n[1]], [w[1][0] + n[0], w[1][1] + n[1]])
})
})
.collect();
if segs.is_empty() {
return None;
}
lines.push(segs);
}
// Schnittpunkt: zuerst innerhalb beider Segmente, sonst der Geraden mit dem kleinsten Überstand.
let mut best: Option<(f64, [f64; 2])> = None;
for a in &lines[0] {
for b in &lines[1] {
let (p, r) = (a.0, [a.1[0] - a.0[0], a.1[1] - a.0[1]]);
let (q, s) = (b.0, [b.1[0] - b.0[0], b.1[1] - b.0[1]]);
let den = r[0] * s[1] - r[1] * s[0];
if den.abs() < 1e-15 {
continue;
}
let qp = [q[0] - p[0], q[1] - p[1]];
let t = (qp[0] * s[1] - qp[1] * s[0]) / den;
let u = (qp[0] * r[1] - qp[1] * r[0]) / den;
let over = (-t).max(t - 1.0).max(0.0) + (-u).max(u - 1.0).max(0.0);
if best.is_none_or(|bst| over < bst.0) {
best = Some((over, [p[0] + r[0] * t, p[1] + r[1] * t]));
}
}
}
let (_, pt) = best?;
// Raster, zu dem die erste Achse gehört (UAxes/VAxes/WAxes).
let grid = self.grid_of_axis(axes[0])?;
let gp = self.ent(grid)?.arg(5).and_then(|v| v.as_ref_id());
let xf = match gp {
Some(p) if depth < super::MAX_PLACEMENT_DEPTH => self.object_placement(p, depth + 1),
_ => Xf::IDENTITY,
};
Some((xf, [pt[0], pt[1], off(2)]))
}
fn grid_of_axis(&mut self, axis: u64) -> Option<u64> {
if self.grid_axes.is_none() {
let mut m: HashMap<u64, u64> = HashMap::new();
for (id, e) in &self.f.entities {
if e.ty != "IFCGRID" {
continue;
}
for k in 7..=9 {
for a in e.arg(k).and_then(|v| v.as_list()).unwrap_or(&[]) {
if let Some(a) = a.as_ref_id() {
m.entry(a).or_insert(*id);
}
}
}
}
self.grid_axes = Some(m);
}
self.grid_axes.as_ref()?.get(&axis).copied()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn trim_polyline_open_closed_and_whole() {
let sq = vec![[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]];
// Von (1, 0.5) über die Ecken nach (0.5, 0): über den Anfang hinweg.
let t = trim_polyline(&sq, [1.0, 0.5, 0.0], [0.5, 0.0, 0.0], false);
assert_eq!(t, vec![[1.0, 0.5, 0.0], [1.0, 1.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.5, 0.0, 0.0]]);
// Ganze Schleife ab (0.5, 0).
let w = trim_polyline(&sq, [0.5, 0.0, 0.0], [0.5, 0.0, 0.0], true);
assert_eq!(w.len(), 6);
assert_eq!(w[0], w[5]);
// Offen, vorwärts.
let open = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [2.0, 0.0, 0.0]];
assert_eq!(trim_polyline(&open, [0.5, 0.0, 0.0], [1.5, 0.0, 0.0], false), vec![[0.5, 0.0, 0.0], [1.0, 0.0, 0.0], [1.5, 0.0, 0.0]]);
}
#[test]
fn trim_by_keys_interpolates() {
let p = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [2.0, 0.0, 0.0]];
let k = [0.0, 1.0, 2.0];
assert_eq!(trim_by_keys(&p, &k, 0.5, 1.5), vec![[0.5, 0.0, 0.0], [1.0, 0.0, 0.0], [1.5, 0.0, 0.0]]);
assert_eq!(trim_by_keys(&p, &k, -1.0, 5.0), p.to_vec());
assert_eq!(trim_by_keys(&p, &[0.0, 2.0, 1.0], 0.5, 1.0), p.to_vec());
}
}
+177 -109
View File
@@ -30,12 +30,18 @@
// WALL_MESH = 2, structure, id, name, TYPEREF, PSETS, MESH
// CEILING = 3, structure, id, name, TYPEREF, PSETS, PTS, z_rel, depth
// OPENING = 4, wall_id, structure, opening_id, is_door (0/1), fill_name, PTS (Öffnungskörper), z_rel,
// depth, width, kind_text (Text oder −1 = keine: Tür OperationType, Fenster PartitioningType,
// IFC-Enum-Name), FILL_FRAME, n_parts, (role, PTS, z_rel, depth) × n_parts, PSETS
// FILL_FRAME = ox, oy, ux, uy (Welt-XY): Placement der Füllung (X = u, Y = linke Normale von u). Die
// Teile-PTS bleiben Welt-XY, z_rel zählt ab Öffnungs-Unterkante. n_parts = 0: kein Körper.
// role: 0 Rahmen/Zarge, 1 Türblatt, 2 Glas. Alle Teile eines Bauteils sind getrennte Körper in EINER
// Darstellung, je mit eigenem IfcStyledItem (Farbe/Transparenz je Rolle).
// depth, width, FILL, PSETS
// FILL (Parameter aus dem Modell; Körper, Placement und OperationType/PartitioningType rechnet
// `ifc_openings.rs`, Version 2 seit 28.10.; OPT = has (0/1), value):
// wall_sx, wall_sy, wall_ex, wall_ey, from, to, z_bottom, z_top, n_lo, n_hi,
// frame_depth OPT, inset OPT, inset_outside (0/1), frame_width OPT,
// wing_count, panes (1–3), n_sashes, (post, post_width OPT, fixed, width OPT) × n_sashes,
// door_kind (0 Dreh, 1 Schiebe, 2 Wandöffnung), leaf_count, swing_sign (±1), dir_sign (±1),
// hinge_at_start (0/1), transom_height, glazed (0/1), glazing_ratio OPT
// Die Füllung bekommt ein eigenes Placement (Ursprung = Öffnungsmitte auf der Achse, X = u, Y = linke
// Normale von u; Tür: Y = Aufschlagrichtung); ohne Teile (Wandöffnung) kein Körper. Alle Teile
// (0 Rahmen/Zarge, 1 Türblatt, 2 Glas) sind getrennte Körper in EINER Darstellung, je mit eigenem
// IfcStyledItem (Farbe/Transparenz je Rolle).
// STAIR = 5, structure, id, predefined (Text), PTS, z_rel, depth
// EXTRUSION = 6, structure, id, PTS, z_rel, depth
// SPACE = 7, structure, id, name, long_name, external (0/1), height, PTS, net_area, gross_area,
@@ -56,8 +62,10 @@
use std::collections::HashMap;
use crate::ifc_openings::{fill_geometry, DoorKind, FillParams, FillPart, Sash, MAX_SASHES};
/// Version der flachen Kodierung (erstes Element des Puffers).
pub const FLAT_VERSION: f64 = 1.0;
pub const FLAT_VERSION: f64 = 2.0;
pub const REC_WALL_SOLIDS: f64 = 1.0;
pub const REC_WALL_MESH: f64 = 2.0;
@@ -378,23 +386,78 @@ impl<'a> Reader<'a> {
let s = self.take(n.checked_mul(2).ok_or("Überlauf")?)?;
Ok(s.chunks_exact(2).map(|c| (c[0], c[1])).collect())
}
/// Teile einer Füllung: n, (Rolle 0 Rahmen / 1 Blatt / 2 Glas, PTS, z_rel, depth) × n.
fn parts(&mut self) -> Result<Vec<Part>, String> {
/// Optionaler Wert: has (0/1), value.
fn opt_f(&mut self) -> Result<Option<f64>, String> {
let has = self.flag()?;
let v = self.f()?;
Ok(has.then_some(v))
}
/// FILL-Parameter einer Tür/eines Fensters (s. Kopf; Geometrie in `ifc_openings.rs`).
fn fill_params(&mut self, is_door: bool) -> Result<FillParams, String> {
let (sx, sy, ex, ey) = (self.f()?, self.f()?, self.f()?, self.f()?);
let (from, to, z_bottom, z_top) = (self.f()?, self.f()?, self.f()?, self.f()?);
let (n_lo, n_hi) = (self.f()?, self.f()?);
let (frame_depth, inset) = (self.opt_f()?, self.opt_f()?);
let inset_outside = self.flag()?;
let frame_width = self.opt_f()?;
let wing_count = self.f()?;
let panes = self.idx()?;
if !(1..=3).contains(&panes) {
return Err(format!("Scheibenzahl {panes} bei {}", self.pos - 1));
}
let n = self.idx()?;
if n > MAX_PARTS {
return Err(format!("zu viele Teile ({n}) bei {}", self.pos - 1));
if n > MAX_SASHES {
return Err(format!("zu viele Flügel ({n}) bei {}", self.pos - 1));
}
let mut out = Vec::with_capacity(n);
let mut sashes = Vec::with_capacity(n);
for _ in 0..n {
let role = self.idx()?;
if role > 2 {
return Err(format!("unbekannte Teilrolle {role} bei {}", self.pos - 1));
}
let pts = self.pts()?;
let (z_rel, depth) = (self.f()?, self.f()?);
out.push(Part { role, pts, z_rel, depth });
let post = self.flag()?;
let post_width = self.opt_f()?;
let fixed = self.flag()?;
let width = self.opt_f()?;
sashes.push(Sash { post, post_width, fixed, width });
}
Ok(out)
let door_kind = match self.idx()? {
0 => DoorKind::Swing,
1 => DoorKind::Sliding,
2 => DoorKind::WallOpening,
k => return Err(format!("unbekannte Türart {k} bei {}", self.pos - 1)),
};
let leaf_count = self.f()?;
let (swing_sign, dir_sign) = (self.f()?, self.f()?);
if swing_sign.abs() != 1.0 || dir_sign.abs() != 1.0 {
return Err(format!("Aufschlag nicht ±1 bei {}", self.pos - 1));
}
let hinge_at_start = self.flag()?;
let transom_height = self.f()?;
let glazed = self.flag()?;
let glazing_ratio = self.opt_f()?;
Ok(FillParams {
wall_start: (sx, sy),
wall_end: (ex, ey),
from,
to,
z_bottom,
z_top,
n_lo,
n_hi,
is_door,
frame_depth,
inset,
inset_outside,
frame_width,
wing_count,
panes,
sashes,
door_kind,
leaf_count,
swing_sign,
dir_sign,
hinge_at_start,
transom_height,
glazed,
glazing_ratio,
})
}
fn mesh(&mut self) -> Result<Mesh, String> {
let nv = self.idx()?;
@@ -458,29 +521,8 @@ impl<'a> Reader<'a> {
}
}
/// Obergrenze der Körper je Tür/Fenster (Rahmenteile, Scheiben, Pfosten).
const MAX_PARTS: usize = 256;
/// Ein Körper einer Tür/eines Fensters (Welt-XY-Profil, Unterkante ab Öffnungs-UK).
struct Part {
/// 0 Rahmen/Zarge, 1 Türblatt, 2 Glas.
role: usize,
pts: Vec<(f64, f64)>,
z_rel: f64,
depth: f64,
}
/// IfcDoorTypeOperationEnum / IfcWindowTypePartitioningEnum (IFC4): nur gültige Namen kommen durch.
const DOOR_OPERATIONS: &[&str] = &[
"SINGLE_SWING_LEFT", "SINGLE_SWING_RIGHT", "DOUBLE_DOOR_SINGLE_SWING", "DOUBLE_DOOR_SINGLE_SWING_OPPOSITE_LEFT",
"DOUBLE_DOOR_SINGLE_SWING_OPPOSITE_RIGHT", "DOUBLE_SWING_LEFT", "DOUBLE_SWING_RIGHT", "DOUBLE_DOOR_DOUBLE_SWING",
"SWING_FIXED_LEFT", "SWING_FIXED_RIGHT", "SLIDING_TO_LEFT", "SLIDING_TO_RIGHT", "DOUBLE_DOOR_SLIDING",
"FOLDING_TO_LEFT", "FOLDING_TO_RIGHT", "DOUBLE_DOOR_FOLDING", "REVOLVING", "ROLLINGUP", "NOTDEFINED",
];
const WINDOW_PARTITIONINGS: &[&str] = &[
"SINGLE_PANEL", "DOUBLE_PANEL_VERTICAL", "DOUBLE_PANEL_HORIZONTAL", "TRIPLE_PANEL_VERTICAL", "TRIPLE_PANEL_BOTTOM",
"TRIPLE_PANEL_TOP", "TRIPLE_PANEL_LEFT", "TRIPLE_PANEL_RIGHT", "TRIPLE_PANEL_HORIZONTAL", "NOTDEFINED",
];
/// Ein Körper einer Tür/eines Fensters (Welt-XY-Profil, Unterkante ab Öffnungs-UK; `ifc_openings.rs`).
type Part = FillPart;
/// Farbe und Durchsichtigkeit je Teilrolle (wie `PART_RGB` im 3D: Rahmen hellgrau, Blatt warm, Glas bläulich).
const PART_STYLES: [(&str, [f64; 3], f64); 3] = [
@@ -1222,20 +1264,17 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
let void_z = r.f()?;
let depth = r.f()?;
let width = r.f()?;
let kind = r.opt_string()?;
let (fox, foy, fux, fuy) = (r.f()?, r.f()?, r.f()?, r.f()?);
if ((fux * fux + fuy * fuy) - 1.0).abs() > 1e-6 {
let fill = fill_geometry(&r.fill_params(is_door)?);
let (kind, parts) = (fill.kind, fill.parts);
let ((fox, foy), (fux, fuy)) = (fill.origin, fill.u);
if ((fux * fux + fuy * fuy) - 1.0).abs() > 1e-6 || !(fox.is_finite() && foy.is_finite()) {
return Err(format!("Füllungsrichtung nicht normiert bei {}", r.pos - 1));
}
let fill_frame = Frame { ox: fox, oy: foy, ux: fux, uy: fuy };
let parts = r.parts()?;
let psets = r.psets()?;
let allowed = if is_door { DOOR_OPERATIONS } else { WINDOW_PARTITIONINGS };
if let Some(k) = &kind {
if !allowed.contains(&k.as_str()) {
return Err(format!("unbekannte Ausführung {k:?} bei {}", r.pos - 1));
}
if parts.iter().any(|p| !(p.z_rel.is_finite() && p.depth.is_finite() && p.pts.iter().all(|q| q.0.is_finite() && q.1.is_finite()))) {
return Err(format!("Füllung mit NaN/∞ bei {}", r.pos - 1));
}
let fill_frame = Frame { ox: fox, oy: foy, ux: fux, uy: fuy };
let psets = r.psets()?;
let Some(&(host_entity, host_placement, host_frame)) = w.walls.get(&wall_id) else {
continue; // Wirtswand nicht geschrieben (degeneriert)
};
@@ -1262,7 +1301,7 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
let fill_placement = w.emit_placement_frame(&fill_frame.relative_to(&host_frame), opening_placement);
let fill_shape = if parts.is_empty() { "$".to_string() } else { format!("#{}", w.emit_parts_shape(&parts, &fill_frame)) };
let g = w.gid(&format!("fill/{opening_id}"));
let operation = kind.as_deref().map(enum_).unwrap_or_else(|| "$".to_string());
let operation = kind.map(enum_).unwrap_or_else(|| "$".to_string());
let fill_entity = w.add(
if is_door { "IFCDOOR" } else { "IFCWINDOW" },
format!(
@@ -1616,22 +1655,9 @@ mod tests {
fn no_type(&mut self) {
self.f.push(0.0);
}
/// OPENING-Datensatz im neuen Format (Gegenstück zu `FlatIfc.opening`).
/// OPENING-Datensatz (Gegenstück zu `FlatIfc.opening`), Füllung als Parameter.
#[allow(clippy::too_many_arguments)]
fn opening(
&mut self,
wall: &str,
id: &str,
is_door: bool,
name: &str,
void_pts: &[(f64, f64)],
void_z: f64,
depth: f64,
width: f64,
kind: Option<&str>,
frame: [f64; 4],
parts: &[(f64, &[(f64, f64)], f64, f64)],
) {
fn opening(&mut self, wall: &str, id: &str, is_door: bool, name: &str, void_pts: &[(f64, f64)], void_z: f64, depth: f64, width: f64, fill: &FillParams) {
self.n(&[REC_OPENING]);
self.str(wall);
self.n(&[-1.0]);
@@ -1640,19 +1666,34 @@ mod tests {
self.str(name);
self.pts(void_pts);
self.n(&[void_z, depth, width]);
match kind {
Some(k) => self.str(k),
None => self.f.push(-1.0),
}
self.n(&frame);
self.f.push(parts.len() as f64);
for (role, pts, z, d) in parts {
self.f.push(*role);
self.pts(pts);
self.n(&[*z, *d]);
}
self.fill(fill);
self.no_psets();
}
fn opt(&mut self, v: Option<f64>) {
self.n(&[if v.is_some() { 1.0 } else { 0.0 }, v.unwrap_or(0.0)]);
}
fn fill(&mut self, p: &FillParams) {
self.n(&[p.wall_start.0, p.wall_start.1, p.wall_end.0, p.wall_end.1, p.from, p.to, p.z_bottom, p.z_top, p.n_lo, p.n_hi]);
self.opt(p.frame_depth);
self.opt(p.inset);
self.n(&[if p.inset_outside { 1.0 } else { 0.0 }]);
self.opt(p.frame_width);
self.n(&[p.wing_count, p.panes as f64, p.sashes.len() as f64]);
for s in &p.sashes {
self.n(&[if s.post { 1.0 } else { 0.0 }]);
self.opt(s.post_width);
self.n(&[if s.fixed { 1.0 } else { 0.0 }]);
self.opt(s.width);
}
let k = match p.door_kind {
DoorKind::Swing => 0.0,
DoorKind::Sliding => 1.0,
DoorKind::WallOpening => 2.0,
};
self.n(&[k, p.leaf_count, p.swing_sign, p.dir_sign, if p.hinge_at_start { 1.0 } else { 0.0 }, p.transom_height]);
self.n(&[if p.glazed { 1.0 } else { 0.0 }]);
self.opt(p.glazing_ratio);
}
fn wall_type(&mut self) {
self.n(&[1.0, 0.0]);
self.str("T1");
@@ -1689,6 +1730,29 @@ mod tests {
const SQUARE: [(f64, f64); 4] = [(0.0, 0.0), (5.0, 0.0), (5.0, 0.4), (0.0, 0.4)];
/// Ein Projekt mit je einem Bauteil jeder Art; zwei Wände gleichen Typs (Pset/Typ müssen sich teilen).
/// Füllungs-Parameter: Wand (sx, sy) → (ex, ey), Achs-Intervall, Höhen, Dicke ±0.2.
fn fill(is_door: bool, wall: [f64; 4], from: f64, to: f64, z0: f64, z1: f64) -> FillParams {
FillParams {
wall_start: (wall[0], wall[1]),
wall_end: (wall[2], wall[3]),
from,
to,
z_bottom: z0,
z_top: z1,
n_lo: -0.2,
n_hi: 0.2,
is_door,
inset_outside: true,
wing_count: 1.0,
panes: 2,
leaf_count: 1.0,
swing_sign: 1.0,
dir_sign: 1.0,
hinge_at_start: true,
..Default::default()
}
}
fn full_house(with_geo: bool) -> B {
let mut b = B::new();
b.str("t");
@@ -1716,15 +1780,11 @@ mod tests {
b.n(&[0.0, 2.6]);
}
// Öffnung in W1: Tür mit Zarge, Blatt und Glas.
// Scharnier am Ende, Aufschlag nach +Y: LEFT; Oberlicht gibt Glas.
b.opening(
"W1", "T1", true, "Haustür",
&[(1.0, -0.02), (1.9, -0.02), (1.9, 0.42), (1.0, 0.42)], 0.0, 2.1, 0.9,
Some("SINGLE_SWING_LEFT"), [1.45, 0.0, 0.0, 1.0],
&[
(0.0, &[(1.0, 0.0), (1.06, 0.0), (1.06, 0.07), (1.0, 0.07)], 0.0, 2.1),
(1.0, &[(1.06, 0.015), (1.84, 0.015), (1.84, 0.055), (1.06, 0.055)], 0.0, 2.04),
(2.0, &[(1.2, 0.02), (1.6, 0.02), (1.6, 0.05), (1.2, 0.05)], 0.5, 1.0),
],
&FillParams { hinge_at_start: false, transom_height: 0.4, ..fill(true, [0.0, 0.0, 5.0, 0.0], 1.0, 1.9, 0.0, 2.1) },
);
// Decke, Treppe, Extrusion.
b.n(&[REC_CEILING, 0.0]);
@@ -1923,8 +1983,7 @@ mod tests {
b.opening(
"W", "O", false, "Fenster",
&[(10.3, 21.0), (10.3, 22.0), (9.7, 22.0), (9.7, 21.0)], 0.9, 1.2, 1.0,
Some("SINGLE_PANEL"), [10.0, 21.5, 0.0, 1.0],
&[(0.0, &[(10.2, 21.0), (10.2, 22.0), (9.8, 22.0), (9.8, 21.0)], 0.0, 1.2)],
&fill(false, [10.0, 20.0, 10.0, 25.0], 1.0, 2.0, 0.9, 2.1),
);
let ifc = build(&b).unwrap();
check_structure(&ifc);
@@ -1946,14 +2005,15 @@ mod tests {
check_structure(&ifc);
let door = first_line(&ifc, "IFCDOOR");
assert!(door.contains(".DOOR.,.SINGLE_SWING_LEFT.,$);"), "{door}");
// Drei Körper (Zarge, Blatt, Glas) in EINER Darstellung, je ein IfcStyledItem, drei Stile.
assert_eq!(count(&ifc, "IFCSTYLEDITEM"), 3);
// Sechs Körper (Zarge 3, Kämpfer, Oberlicht-Glas, Blatt) in EINER Darstellung, je ein
// IfcStyledItem, drei Stile (Rahmen, Blatt, Glas).
assert_eq!(count(&ifc, "IFCSTYLEDITEM"), 6);
assert_eq!(count(&ifc, "IFCSURFACESTYLE"), 3);
assert_eq!(count(&ifc, "IFCSURFACESTYLERENDERING"), 3);
assert!(ifc.contains("IFCSURFACESTYLE('Glas',.BOTH.,"));
assert!(ifc.contains("IFCSURFACESTYLERENDERING(#"));
let shapes = ifc.lines().filter(|l| l.contains("IFCSHAPEREPRESENTATION") && l.contains("'SweptSolid'") && l.matches('#').count() == 5).count();
assert!(shapes >= 1, "Darstellung mit 3 Körpern fehlt");
let shapes = ifc.lines().filter(|l| l.contains("IFCSHAPEREPRESENTATION") && l.contains("'SweptSolid'") && l.matches('#').count() == 8).count();
assert!(shapes >= 1, "Darstellung mit 6 Körpern fehlt");
// Füllungs-Placement mit Richtung (0,1,0) relativ zur Öffnung; Ursprung lokal.
assert!(ifc.contains("IFCCARTESIANPOINT((1.45,0.0,0.0))"));
}
@@ -1961,26 +2021,34 @@ mod tests {
#[test]
fn fenster_ohne_teile_hat_keine_darstellung_und_enum_ist_geprueft() {
let mut b = full_house(false);
b.opening("W1", "F1", false, "Fenster", &SQUARE, 0.9, 1.2, 1.2, Some("DOUBLE_PANEL_VERTICAL"), [2.0, 0.0, 1.0, 0.0], &[]);
b.opening("W1", "T2", true, "Wandöffnung", &SQUARE, 0.0, 2.1, 1.0, None, [3.0, 0.0, 1.0, 0.0], &[]);
let w1 = [0.0, 0.0, 5.0, 0.0];
b.opening("W1", "F1", false, "Fenster", &SQUARE, 0.9, 1.2, 1.2, &FillParams { wing_count: 2.0, ..fill(false, w1, 2.0, 3.2, 0.9, 2.1) });
b.opening("W1", "T2", true, "Wandöffnung", &SQUARE, 0.0, 2.1, 1.0, &FillParams { door_kind: DoorKind::WallOpening, ..fill(true, w1, 3.0, 4.0, 0.0, 2.1) });
let ifc = build(&b).unwrap();
check_structure(&ifc);
let win = first_line(&ifc, "IFCWINDOW");
assert!(win.contains(".WINDOW.,.DOUBLE_PANEL_VERTICAL.,$);"), "{win}");
assert!(win.contains(",$,$,1.2,1.2,.WINDOW."), "ohne Teile keine Darstellung: {win}");
// Ungültige Ausführung (Fenster-Wert an der Tür und umgekehrt) ist ein Fehler, nie Panic.
let hole = ifc.lines().filter(|l| l.contains("IFCDOOR(")).find(|l| l.contains(",$,$,2.1,1.0,.DOOR.,$,$);"));
assert!(hole.is_some(), "Wandöffnung ohne Darstellung und Ausführung");
// Kaputte Parameter: Fehler, nie Panic.
let bad_params = [
FillParams { panes: 0, ..fill(false, w1, 1.0, 2.0, 0.9, 2.1) },
FillParams { swing_sign: 0.0, ..fill(true, w1, 1.0, 2.0, 0.0, 2.1) },
FillParams { wing_count: f64::NAN, ..fill(false, w1, 1.0, 2.0, 0.9, 2.1) },
FillParams { sashes: vec![Sash::default(); MAX_SASHES + 1], ..fill(false, w1, 1.0, 2.0, 0.9, 2.1) },
// Wand ohne Länge: keine Richtung.
fill(false, [1.0, 1.0, 1.0, 1.0], 0.0, 1.0, 0.0, 1.0),
];
for p in bad_params {
let mut bad = full_house(false);
bad.opening("W1", "F9", false, "Fenster", &SQUARE, 0.9, 1.2, 1.2, &p);
assert!(build(&bad).is_err(), "{p:?}");
}
// Unbekannte Türart.
let mut bad = full_house(false);
bad.opening("W1", "T3", true, "Tür", &SQUARE, 0.0, 2.1, 1.0, Some("SINGLE_PANEL"), [1.0, 0.0, 1.0, 0.0], &[]);
assert!(build(&bad).is_err());
let mut bad = full_house(false);
bad.opening("W1", "F3", false, "Fenster", &SQUARE, 0.9, 1.2, 1.2, Some("SINGLE_SWING_LEFT"), [1.0, 0.0, 1.0, 0.0], &[]);
assert!(build(&bad).is_err());
// Unbekannte Teilrolle, schiefe Richtung: Fehler.
let mut bad = full_house(false);
bad.opening("W1", "F4", false, "Fenster", &SQUARE, 0.9, 1.2, 1.2, None, [1.0, 0.0, 1.0, 0.0], &[(3.0, &SQUARE, 0.0, 1.0)]);
assert!(build(&bad).is_err());
let mut bad = full_house(false);
bad.opening("W1", "F5", false, "Fenster", &SQUARE, 0.9, 1.2, 1.2, None, [1.0, 0.0, 3.0, 0.0], &[]);
bad.opening("W1", "T9", true, "Tür", &SQUARE, 0.0, 2.1, 1.0, &fill(true, w1, 1.0, 2.0, 0.0, 2.1));
let at = bad.f.len() - 1 /* psets */ - 3 /* glazed, ratio-opt */ - 6;
bad.f[at] = 7.0;
assert!(build(&bad).is_err());
}
@@ -2041,7 +2109,7 @@ mod tests {
b.n(&[1.0]);
b.str("iso");
b.n(&[0.0, f64::NAN, 0.0]);
b.opening("gibt-es-nicht", "O1", false, "Fenster", &SQUARE, 0.0, 1.0, 1.0, None, [0.0, 0.0, 1.0, 0.0], &[]);
b.opening("gibt-es-nicht", "O1", false, "Fenster", &SQUARE, 0.0, 1.0, 1.0, &fill(false, [0.0, 0.0, 5.0, 0.0], 0.0, 1.0, 0.0, 1.0));
let ifc = build(&b).unwrap();
check_structure(&ifc);
assert_eq!(count(&ifc, "IFCOPENINGELEMENT"), 0);
+247 -51
View File
@@ -7,25 +7,31 @@
// Eigener Code (nichts aus BIMCraft `import.rs` übernommen; BIMCraft rechnet in mm, hier Meter).
//
// Unterstützt:
// - Platzierung: IfcLocalPlacement-Ketten mit IfcAxis2Placement3D/2D.
// - Platzierung: IfcLocalPlacement-Ketten mit IfcAxis2Placement3D/2D, IfcGridPlacement (Schnittpunkt
// der versetzten Rasterachsen, `ifc_brep.rs`).
// - Körper: IfcExtrudedAreaSolid, IfcFacetedBrep(+WithVoids), IfcShellBasedSurfaceModel,
// IfcFaceBasedSurfaceModel, IfcTriangulatedFaceSet, IfcPolygonalFaceSet, IfcMappedItem
// (IfcCartesianTransformationOperator3D, auch ungleichmässig), IfcBlock, IfcCsgSolid,
// IfcBooleanResult/IfcBooleanClippingResult (alle drei Operationen über BSP-CSG `csg.rs`; zweiter
// Operand auch IfcHalfSpaceSolid/IfcBoxedHalfSpace/IfcPolygonalBoundedHalfSpace auf IfcPlane),
// IfcRevolvedAreaSolid, IfcSweptDiskSolid(+Polygonal), IfcFixedReferenceSweptAreaSolid,
// IfcSurfaceCurveSweptAreaSolid auf Ebene (`ifc_sweep.rs`; StartParam/EndParam nicht ausgewertet).
// IfcSurfaceCurveSweptAreaSolid auf Ebene (`ifc_sweep.rs`; StartParam/EndParam als Parameter der
// Leitkurve bzw. IFC4.3-Länge), IfcAdvancedBrep(+WithVoids) und IfcFaceSurface mit Ebene, Zylinder,
// Kegel, Kugel, Torus und (rationaler) B-Spline-Fläche, getrimmt über den Parameterraum
// (`ifc_brep.rs` liest, `ifc_nurbs.rs` zerlegt).
// - Öffnungen: IfcRelVoidsElement — der Körper der IfcOpeningElement wird vom Wirt abgezogen (auch
// vom Teil eines Ganzen, z. B. Platten eines IfcRoof). Scheitert der Boolean → Öffnung gezählt
// und ausgelassen, Wirt bleibt ganz.
// - Profile: Arbitrary(+WithVoids), Rectangle(+Hollow, Rounded), Circle(+Hollow),
// I/L/U/T-Profil (mit Ausrundung, ohne Kantenradien/Neigungen), Derived, Composite.
// - Kurven (2D und räumlich): IfcPolyline, IfcIndexedPolyCurve (Linien + Bögen),
// IfcCompositeCurve, IfcTrimmedCurve auf Kreis/Ellipse/Linie, IfcCircle, IfcEllipse.
// IfcCompositeCurve, IfcTrimmedCurve auf Kreis/Ellipse/Linie/B-Spline, IfcCircle, IfcEllipse,
// IfcBSplineCurveWithKnots(+Rational).
// - Einheiten: IfcSIUnit mit Präfix, IfcConversionBasedUnit (Fuss, Zoll, Grad).
// - Farbe: IfcStyledItem (IfcSurfaceStyleRendering/Shading) am Körper, sonst am Material.
// - Geschoss: IfcRelContainedInSpatialStructure, aufwärts über IfcRelAggregates.
// Übersprungen und gezählt: alles andere (z. B. IfcAdvancedBrep, B-Spline-Kurven, IfcSectionedSpine);
// Übersprungen und gezählt: alles andere (z. B. IfcSectionedSpine, IFC4.3-Trassierung, Flächen aus
// Extrusion/Rotation einer Kurve);
// IfcOpeningElement/IfcSpace/IfcAnnotation/IfcGrid als Bauteile.
//
// Grenzen: Dateigrösse/Instanzen (`ifc_step`), Dreiecke gesamt, Verschachtelung von Mapped Items und
@@ -37,6 +43,10 @@ use crate::csg;
use crate::ifc_step::{self, Entity, StepFile, Value};
use crate::ifc_sweep::{self, Frame};
#[path = "ifc_brep.rs"]
mod brep;
use brep::nearest_param;
/// Höchstzahl Dreiecke über alle Bauteile; darüber wird abgebrochen (`truncated`).
pub const MAX_TRIANGLES: usize = 15_000_000;
const MAX_MAP_DEPTH: usize = 8;
@@ -114,7 +124,7 @@ impl Xf {
Xf { r, t: add(t0, self.t) }
}
/// Umkehrabbildung; nicht umkehrbar → `None`.
fn inverse(&self) -> Option<Xf> {
pub(crate) fn inverse(&self) -> Option<Xf> {
let d = self.det();
if !(d.is_finite() && d.abs() > 1e-15) {
return None;
@@ -520,6 +530,10 @@ pub(crate) struct Reader<'a> {
active: HashSet<u64>,
/// Restbudget an Element-Auswertungen (schützt vor exponentiellen DAGs).
budget: usize,
/// Zerlegte Kanten (IfcEdgeCurve-id → Punkte vom Anfang zum Ende), von Nachbarseiten geteilt.
edge_cache: HashMap<u64, Vec<V3>>,
/// Rasterachse → IfcGrid (für IfcGridPlacement), beim ersten Bedarf gesammelt.
grid_axes: Option<HashMap<u64, u64>>,
}
impl<'a> Reader<'a> {
@@ -615,6 +629,16 @@ impl<'a> Reader<'a> {
Some(parent) if parent != id => self.object_placement(parent, depth + 1).then_after(&local),
_ => local,
}
} else if e.ty == "IFCGRIDPLACEMENT" && depth < MAX_PLACEMENT_DEPTH {
// Vorläufig eintragen: Zyklen über das Raster enden bei der Identität.
self.placements.insert(id, Xf::IDENTITY);
match self.grid_placement(e, depth) {
Some(x) => x,
None => {
self.skip("IFCGRIDPLACEMENT (unlesbar)");
Xf::IDENTITY
}
}
} else {
if e.ty != "IFCLOCALPLACEMENT" {
let ty = e.ty.clone();
@@ -691,15 +715,27 @@ impl<'a> Reader<'a> {
/// Kurve → Punktfolge (offen; Schlusspunkt kann dem Start entsprechen); 2D-Kurven mit z = 0.
fn curve(&mut self, v: Option<&Value>, depth: usize) -> Option<Vec<V3>> {
Some(self.curve_t(v, depth)?.into_iter().map(|(_, p)| p).collect())
}
/// Kurve → (Parameter, Punkt)-Folge in der Parametrisierung der Kurve (für StartParam/EndParam):
/// Polylinie Punktnummer ab 0, Kreis/Ellipse Winkel in der Winkeleinheit der Datei, Linie t (Punkt
/// = Ort + t·Vektor), B-Spline Knotenparameter, IfcIndexedPolyCurve je Segment 1, zusammengesetzte
/// Kurven Segmente aneinander (je Länge ihres Parameterbereichs). Parameter steigen (Gegensinn: ab
/// Start gezählt).
fn curve_t(&mut self, v: Option<&Value>, depth: usize) -> Option<Vec<(f64, V3)>> {
let (_, e) = self.ent_v(v)?;
if depth > MAX_CURVE_DEPTH {
return None;
}
match e.ty.as_str() {
"IFCPOLYLINE" => Some(e.arg(0)?.as_list()?.iter().filter_map(|v| self.point(Some(v))).take(MAX_LOOP_POINTS).collect()),
"IFCPOLYLINE" => Some(
e.arg(0)?.as_list()?.iter().filter_map(|v| self.point(Some(v))).take(MAX_LOOP_POINTS).enumerate().map(|(i, p)| (i as f64, p)).collect(),
),
"IFCINDEXEDPOLYCURVE" => self.indexed_poly_curve(e),
"IFCCOMPOSITECURVE" => {
let mut out: Vec<V3> = Vec::new();
let mut out: Vec<(f64, V3)> = Vec::new();
let mut offset = 0.0;
for seg in e.arg(0)?.as_list()? {
let (_, s) = self.ent_v(Some(seg))?;
if !s.ty.ends_with("COMPOSITECURVESEGMENT") {
@@ -707,13 +743,18 @@ impl<'a> Reader<'a> {
return None;
}
let same = s.arg(1).and_then(|v| v.as_enum()) != Some("F");
let mut pts = self.curve(s.arg(2), depth + 1)?;
let mut pts = self.curve_t(s.arg(2), depth + 1)?;
if !same {
pts.reverse();
}
if let (Some(l), Some(f)) = (out.last(), pts.first()) {
if len(sub(*l, *f)) < 1e-9 {
pts.remove(0);
let (Some(f), Some(l)) = (pts.first().map(|x| x.0), pts.last().map(|x| x.0)) else { continue };
let sign = if l >= f { 1.0 } else { -1.0 };
let pts: Vec<(f64, V3)> = pts.into_iter().map(|(t, p)| (offset + (t - f) * sign, p)).collect();
offset += (l - f).abs();
let mut pts = pts.into_iter();
if let (Some(last), Some(first)) = (out.last(), pts.as_slice().first()) {
if len(sub(last.1, first.1)) < 1e-9 {
pts.next();
}
}
out.extend(pts);
@@ -727,11 +768,18 @@ impl<'a> Reader<'a> {
"IFCCIRCLE" | "IFCELLIPSE" => {
let (pl, rx, ry) = self.conic(e)?;
let n = arc_segments(std::f64::consts::TAU, rx.max(ry)).max(12);
let a = self.angle_scale;
Some((0..n).map(|i| {
let t = std::f64::consts::TAU * i as f64 / n as f64;
pl.apply([rx * t.cos(), ry * t.sin(), 0.0])
(t / a, pl.apply([rx * t.cos(), ry * t.sin(), 0.0]))
}).collect())
}
"IFCBSPLINECURVEWITHKNOTS" | "IFCRATIONALBSPLINECURVEWITHKNOTS" => {
let c = self.bspline_curve(e)?;
let (a, b) = c.domain();
let pts = c.sample(a, b);
(pts.len() >= 2).then_some(pts)
}
other => {
let other = other.to_string();
self.skip(&other);
@@ -748,7 +796,7 @@ impl<'a> Reader<'a> {
(rx > 0.0 && ry > 0.0).then_some((pl, rx, ry))
}
fn indexed_poly_curve(&self, e: &Entity) -> Option<Vec<V3>> {
fn indexed_poly_curve(&self, e: &Entity) -> Option<Vec<(f64, V3)>> {
let (_, pl) = self.ent_v(e.arg(0))?;
if pl.ty != "IFCCARTESIANPOINTLIST2D" && pl.ty != "IFCCARTESIANPOINTLIST3D" {
return None;
@@ -773,28 +821,37 @@ impl<'a> Reader<'a> {
};
let segs = match e.arg(1) {
Some(Value::List(s)) => s,
_ => return Some(coords.clone()),
_ => return Some(coords.iter().enumerate().map(|(i, p)| (i as f64, *p)).collect()),
};
let mut out: Vec<V3> = Vec::new();
let push = |out: &mut Vec<V3>, p: V3| {
if !out.last().is_some_and(|q| len(sub(*q, p)) < 1e-12) {
out.push(p);
let mut out: Vec<(f64, V3)> = Vec::new();
let push = |out: &mut Vec<(f64, V3)>, t: f64, p: V3| {
if !out.last().is_some_and(|q| len(sub(q.1, p)) < 1e-12) {
out.push((t, p));
}
};
// Parameter: je Liniensegment bzw. Bogen eine Einheit.
let mut t0 = 0.0;
for s in segs {
let Value::Typed(name, a) = s else { return None };
let idx = a.first()?.as_list()?;
match name.as_str() {
"IFCLINEINDEX" => {
for i in idx {
push(&mut out, at(i)?);
for (k, i) in idx.iter().enumerate() {
let t = if k == 0 { t0 } else { t0 + 1.0 };
if k > 0 {
t0 += 1.0;
}
push(&mut out, t, at(i)?);
}
}
"IFCARCINDEX" if idx.len() == 3 => {
let (p1, p2, p3) = (at(&idx[0])?, at(&idx[1])?, at(&idx[2])?);
for p in arc3(p1, p2, p3) {
push(&mut out, p);
let arc = arc3(p1, p2, p3);
let n = (arc.len() - 1).max(1) as f64;
for (k, p) in arc.into_iter().enumerate() {
push(&mut out, t0 + k as f64 / n, p);
}
t0 += 1.0;
}
_ => return None,
}
@@ -805,7 +862,7 @@ impl<'a> Reader<'a> {
Some(out)
}
fn trimmed_curve(&mut self, e: &Entity) -> Option<Vec<V3>> {
fn trimmed_curve(&mut self, e: &Entity) -> Option<Vec<(f64, V3)>> {
let (_, basis) = self.ent_v(e.arg(0))?;
let sense = e.arg(3).and_then(|v| v.as_enum()) != Some("F");
let master_param = e.arg(4).and_then(|v| v.as_enum()) == Some("PARAMETER");
@@ -842,9 +899,10 @@ impl<'a> Reader<'a> {
let span = if sense { (a2 - a1).rem_euclid(tau) } else { -((a1 - a2).rem_euclid(tau)) };
let span = if span.abs() < 1e-12 { if sense { tau } else { -tau } } else { span };
let n = arc_segments(span, rx.max(ry));
let a = self.angle_scale;
Some((0..=n).map(|i| {
let t = a1 + span * i as f64 / n as f64;
pl.apply([rx * t.cos(), ry * t.sin(), 0.0])
(t / a, pl.apply([rx * t.cos(), ry * t.sin(), 0.0]))
}).collect())
}
"IFCLINE" => {
@@ -853,19 +911,36 @@ impl<'a> Reader<'a> {
let d = norm(self.direction(vec.arg(0))?)?;
let m = self.length(vec.arg(1)).unwrap_or(1.0);
let at = |t: f64| add(pnt, scale(d, m * t));
let par_of = |p: V3| if m.abs() > 1e-300 { dot(sub(p, pnt), d) / m } else { 0.0 };
let a = if master_param { p1.map(at).or(c1) } else { c1.or(p1.map(at)) }?;
let b = if master_param { p2.map(at).or(c2) } else { c2.or(p2.map(at)) }?;
Some(if sense { vec![a, b] } else { vec![b, a] })
let (ta, tb) = (par_of(a), par_of(b));
Some(if sense { vec![(ta, a), (tb, b)] } else { vec![(tb, b), (ta, a)] })
}
"IFCBSPLINECURVEWITHKNOTS" | "IFCRATIONALBSPLINECURVEWITHKNOTS" => {
let c = self.bspline_curve(basis)?;
let full = c.sample(c.domain().0, c.domain().1);
let t_of = |par: Option<f64>, pt: Option<V3>| -> Option<f64> {
let from_pt = pt.and_then(|p| nearest_param(&full, p));
if master_param { par.or(from_pt) } else { from_pt.or(par) }
};
let (t1, t2) = (t_of(p1, c1)?, t_of(p2, c2)?);
let (lo, hi) = if t1 <= t2 { (t1, t2) } else { (t2, t1) };
let mut pts = c.sample(lo, hi);
// Gegensinn bzw. vertauschte Grenzen: rückwärts.
if sense != (t1 <= t2) {
pts.reverse();
}
(pts.len() >= 2).then_some(pts)
}
_ => {
// Andere Basiskurven (B-Splines, Klothoiden …) nicht unterstützt.
// Andere Basiskurven (Klothoiden …) nicht unterstützt.
let ty = basis.ty.clone();
self.skip(&ty);
None
}
}
}
// ---- Profile ---------------------------------------------------------------------------
/// Profil → Flächen (je Fläche Ring 0 aussen, weitere Löcher) in Profil-Koordinaten.
@@ -1035,6 +1110,21 @@ impl<'a> Reader<'a> {
self.shell(v, out);
}
}
"IFCADVANCEDBREP" | "IFCADVANCEDBREPWITHVOIDS" => {
// Freiform-Brep: Seiten auf Ebenen, Zylindern, Kegeln, Kugeln, Tori, B-Spline-Flächen.
let mut local = Mesh::default();
if let Some(v) = e.arg(0) {
self.shell(v, &mut local);
}
for v in e.arg(1).and_then(|v| v.as_list()).unwrap_or(&[]) {
self.shell(v, &mut local);
}
// Aussen- und Hohlräume sind in sich richtig orientiert; das Ganze nach aussen.
if signed_volume(&local.positions, &local.indices) < 0.0 {
local.flip_all();
}
out.append(&local, &Xf::IDENTITY);
}
"IFCSHELLBASEDSURFACEMODEL" | "IFCFACEBASEDSURFACEMODEL" => {
for v in e.arg(0).and_then(|v| v.as_list()).unwrap_or(&[]) {
self.shell(v, out);
@@ -1107,8 +1197,8 @@ impl<'a> Reader<'a> {
}
}
"IFCSWEPTDISKSOLID" | "IFCSWEPTDISKSOLIDPOLYGONAL" => {
// StartParam/EndParam und Ausrundungen (Polygonal) werden nicht ausgewertet.
let Some(path) = self.curve(e.arg(0), 0) else { return };
// Ausrundungen (Polygonal) werden nicht ausgewertet.
let Some(path) = self.sweep_path(e, 0, 3, 4) else { return };
let Some(r) = self.length(e.arg(1)).filter(|r| *r > 0.0) else { return };
let n = arc_segments(std::f64::consts::TAU, r).max(24);
let circle = |r: f64| -> Vec<V2> {
@@ -1127,10 +1217,10 @@ impl<'a> Reader<'a> {
out.append(&m, &Xf::IDENTITY);
}
"IFCFIXEDREFERENCESWEPTAREASOLID" | "IFCSURFACECURVESWEPTAREASOLID" => {
// Leitkurve im System von Position; StartParam/EndParam werden nicht ausgewertet.
// Leitkurve im System von Position, begrenzt durch StartParam/EndParam.
let Some(areas) = self.profile(e.arg(0), 0) else { return };
let pos = self.axis_placement(e.arg(1));
let Some(path) = self.curve(e.arg(2), 0) else { return };
let Some(path) = self.sweep_path(e, 2, 3, 4) else { return };
let frame = if e.ty == "IFCFIXEDREFERENCESWEPTAREASOLID" {
Frame::FixedX(self.direction(e.arg(5)).unwrap_or([1.0, 0.0, 0.0]))
} else {
@@ -1241,7 +1331,7 @@ impl<'a> Reader<'a> {
let faces = sh.arg(0).and_then(|v| v.as_list()).unwrap_or(&[]);
for f in faces {
let Some((_, face)) = self.ent_v(Some(f)) else { continue };
if face.ty != "IFCFACE" && face.ty != "IFCFACESURFACE" {
if face.ty != "IFCFACE" && face.ty != "IFCFACESURFACE" && face.ty != "IFCADVANCEDFACE" {
continue;
}
let mut outer: Option<Vec<V3>> = None;
@@ -1249,23 +1339,35 @@ impl<'a> Reader<'a> {
for b in face.arg(0).and_then(|v| v.as_list()).unwrap_or(&[]) {
let Some((_, bound)) = self.ent_v(Some(b)) else { continue };
let Some((_, lp)) = self.ent_v(bound.arg(0)) else { continue };
if lp.ty != "IFCPOLYLOOP" {
let ty = lp.ty.clone();
self.skip(&ty);
continue;
}
let mut pts: Vec<V3> = lp
.arg(0)
.and_then(|v| v.as_list())
.unwrap_or(&[])
.iter()
.take(MAX_LOOP_POINTS)
.filter_map(|p| self.point(Some(p)))
.collect();
pts.dedup_by(|a, b| len(sub(*a, *b)) < 1e-12);
if pts.len() > 1 && len(sub(pts[0], pts[pts.len() - 1])) < 1e-12 {
pts.pop();
}
let mut pts: Vec<V3> = match lp.ty.as_str() {
"IFCPOLYLOOP" => {
let mut pts: Vec<V3> = lp
.arg(0)
.and_then(|v| v.as_list())
.unwrap_or(&[])
.iter()
.take(MAX_LOOP_POINTS)
.filter_map(|p| self.point(Some(p)))
.collect();
pts.dedup_by(|a, b| len(sub(*a, *b)) < 1e-12);
if pts.len() > 1 && len(sub(pts[0], pts[pts.len() - 1])) < 1e-12 {
pts.pop();
}
pts
}
"IFCEDGELOOP" => match self.edge_loop(lp) {
Some(p) => p,
None => {
self.skip("IFCEDGELOOP (unlesbar)");
continue;
}
},
_ => {
let ty = lp.ty.clone();
self.skip(&ty);
continue;
}
};
if bound.arg(1).and_then(|v| v.as_enum()) == Some("F") {
pts.reverse();
}
@@ -1286,6 +1388,15 @@ impl<'a> Reader<'a> {
};
let mut rings = vec![outer];
rings.extend(inner);
// Gekrümmte Trägerfläche (IfcAdvancedFace/IfcFaceSurface): über den Parameterraum.
if face.ty != "IFCFACE" {
if let Some(brep::FaceSurface::Curved(s)) = self.face_surface(face.arg(1)) {
let same = face.arg(2).and_then(|v| v.as_enum()) != Some("F");
if self.curved_face(&s, &rings, same, out) {
continue;
}
}
}
triangulate3d(&rings, out);
}
}
@@ -1689,6 +1800,8 @@ pub fn import_ifc_opts(bytes: &[u8], elements: bool) -> Result<IfcImport, String
simplified: 0,
active: HashSet::new(),
budget: MAX_ITEM_EVALS,
edge_cache: HashMap::new(),
grid_axes: None,
};
let mut result = IfcImport { schema: f.schema.clone(), length_scale: len_scale, parse_errors: f.errors, ..Default::default() };
@@ -2370,9 +2483,9 @@ ENDSEC;\nEND-ISO-10303-21;\n"
#[test]
fn unknown_items_are_counted() {
let body = "#44=IFCADVANCEDBREP(#45);#45=IFCCLOSEDSHELL(());";
let body = "#44=IFCSECTIONEDSPINE(#45,(),());";
let r = import_ifc(file(METRE, body, "#44", "IFCWALL").as_bytes()).unwrap();
assert_eq!(r.skipped_items.get("IFCADVANCEDBREP"), Some(&1));
assert_eq!(r.skipped_items.get("IFCSECTIONEDSPINE"), Some(&1));
assert_eq!(r.products_without_geometry, 1);
}
@@ -2430,6 +2543,75 @@ ENDSEC;\nEND-ISO-10303-21;\n"
}
}
/// Synthetische Freiform-Fälle (`src/io/testdata/ifc-freeform-cases.ifc`, erzeugt von Hand):
/// Volumen gegen Formel, Breps ohne Löcher zwischen den Seiten.
#[test]
fn freeform_cases_volumes_and_closed_breps() {
let src = include_str!("../../../src/io/testdata/ifc-freeform-cases.ifc");
let r = import_ifc(src.as_bytes()).unwrap();
assert!(r.skipped_items.is_empty(), "{:?}", r.skipped_items);
let pi = std::f64::consts::PI;
let want = [
("1cyl", pi * 0.25 * 2.0, 0.01),
("2dome", 2.0 / 3.0 * pi, 0.01),
("3bspprofile", pi * 0.25, 0.005),
("4twist", 2.0 / 3.0, 0.005),
("5nurbscyl", pi * 0.25, 0.005),
// StartParam 0.5 … EndParam 1.5 der Polylinie: 2 m + 1.5 m.
("6pipeparams", pi * 0.01 * 3.5, 0.02),
// Viertelkreis R = 2.
("7pipearc", pi * 0.01 * pi, 0.02),
("8pipenurbs", pi * 0.01 * 2.0 * pi, 0.02),
];
assert_eq!(r.products.len(), want.len());
for (p, (name, v, rel)) in r.products.iter().zip(want) {
assert!(p.global_id.starts_with(name), "{}", p.global_id);
let got = vol(p);
assert!((got - v).abs() / v < rel, "{name}: {got} ≠ {v}");
}
// Geschlossen (auch mit T-Stössen, wo gerade Kanten fein geteilt sind): die Flächenvektoren
// aller Dreiecke heben sich auf.
for p in r.products.iter().filter(|p| ["1cyl", "2dome", "4twist", "5nurbscyl"].iter().any(|n| p.global_id.starts_with(n))) {
let at = |i: u32| {
let k = i as usize * 3;
[p.mesh.positions[k], p.mesh.positions[k + 1], p.mesh.positions[k + 2]]
};
let mut sum = [0.0; 3];
let mut total = 0.0;
for t in p.mesh.indices.chunks_exact(3) {
let n = cross(sub(at(t[1]), at(t[0])), sub(at(t[2]), at(t[0])));
sum = add(sum, n);
total += len(n);
}
assert!(len(sum) < 1e-9 * total, "{}: {sum:?}", p.global_id);
}
}
#[test]
fn grid_placement_at_axis_intersection() {
// Raster in (10, 0, 0) des Geschosses; U-Achse y = 2 (Gegensinn), V-Achse x = 3; Versatz 0.5
// (links der umgedrehten U-Achse = −y) und 0.25 (links der V-Achse = −x), z 1.
let body = "#40=IFCRECTANGLEPROFILEDEF(.AREA.,$,$,0.2,0.2);#41=IFCEXTRUDEDAREASOLID(#40,#13,#11,1.);\
#50=IFCCARTESIANPOINT((0.,2.));#51=IFCCARTESIANPOINT((8.,2.));#52=IFCPOLYLINE((#50,#51));#53=IFCGRIDAXIS('1',#52,.F.);\
#54=IFCCARTESIANPOINT((3.,-5.));#55=IFCCARTESIANPOINT((3.,5.));#56=IFCPOLYLINE((#54,#55));#57=IFCGRIDAXIS('A',#56,.T.);\
#58=IFCCARTESIANPOINT((10.,0.,0.));#59=IFCAXIS2PLACEMENT3D(#58,$,$);#60=IFCLOCALPLACEMENT(#23,#59);\
#61=IFCGRID('0grid',$,$,$,$,#60,$,(#53),(#57),$,$);\
#62=IFCVIRTUALGRIDINTERSECTION((#53,#57),(0.5,0.25,1.));#63=IFCDIRECTION((0.,1.,0.));#64=IFCGRIDPLACEMENT(#62,#63);";
let src = file(METRE, body, "#41", "IFCCOLUMN").replace("$,'Teil',$,$,#30,", "$,'Teil',$,$,#64,");
let (r, p) = one(&src);
assert!(r.skipped_items.is_empty(), "{:?}", r.skipped_items);
let (lo, hi) = bbox(&p);
let c = [(lo[0] + hi[0]) / 2.0, (lo[1] + hi[1]) / 2.0];
// x = 10 + 3 − 0.25, y = 2 − 0.5, z = 3 (Geschoss) + 1.
assert!(close(c[0], 12.75, 1e-9) && close(c[1], 1.5, 1e-9), "{c:?}");
assert!(close(lo[2], 4.0, 1e-9) && close(hi[2], 5.0, 1e-9));
assert!(close(vol(&p), 0.04, 1e-9));
// IFC4.3-Form (PlacementRelTo vorne) gibt dasselbe.
let src43 = src.replace("IFCGRIDPLACEMENT(#62,#63)", "IFCGRIDPLACEMENT(#60,#62,#63)");
let (_, q) = one(&src43);
assert_eq!(bbox(&q), (lo, hi));
}
#[test]
fn nonsense_never_panics() {
assert!(import_ifc(b"").is_err());
@@ -2455,10 +2637,24 @@ ENDSEC;\nEND-ISO-10303-21;\n"
"#41=IFCEXTRUDEDAREASOLID(#40,#13,#11,1.);#40=IFCARBITRARYCLOSEDPROFILEDEF(.AREA.,$,#42);#42=IFCINDEXEDPOLYCURVE(#43,(IFCARCINDEX((1,1,1)),IFCLINEINDEX((9))),$);#43=IFCCARTESIANPOINTLIST2D(((0.,0.)));",
"#41=IFCEXTRUDEDAREASOLID(#40,#13,#11,1.E308);#40=IFCCIRCLEPROFILEDEF(.AREA.,$,$,1.E308);",
"#41=IFCEXTRUDEDAREASOLID(#40,#13,#11,1.);#40=IFCCIRCLEPROFILEDEF(.AREA.,$,$,1.E-300);",
// Freiform ([25]): kaputte B-Splines, Kanten, Flächen, Zyklen.
"#41=IFCEXTRUDEDAREASOLID(#40,#13,#11,1.);#40=IFCARBITRARYCLOSEDPROFILEDEF(.AREA.,$,#42);#42=IFCBSPLINECURVEWITHKNOTS(3,(#10,#21),.UNSPECIFIED.,.F.,.F.,(4,4),(0.,1.),.UNSPECIFIED.);",
"#41=IFCEXTRUDEDAREASOLID(#40,#13,#11,1.);#40=IFCARBITRARYCLOSEDPROFILEDEF(.AREA.,$,#42);#42=IFCRATIONALBSPLINECURVEWITHKNOTS(1,(#10,#21),.UNSPECIFIED.,.F.,.F.,(2,2),(0.,1.),.UNSPECIFIED.,(1.,-1.));",
"#41=IFCEXTRUDEDAREASOLID(#40,#13,#11,1.);#40=IFCARBITRARYCLOSEDPROFILEDEF(.AREA.,$,#42);#42=IFCBSPLINECURVEWITHKNOTS(99999,(#10,#21),.UNSPECIFIED.,.F.,.F.,(1,1),(1.,0.),.UNSPECIFIED.);",
"#41=IFCADVANCEDBREP(#42);#42=IFCCLOSEDSHELL((#43));#43=IFCADVANCEDFACE((#44),#47,.T.);#44=IFCFACEOUTERBOUND(#45,.T.);#45=IFCEDGELOOP((#46));#46=IFCORIENTEDEDGE(*,*,#46,.T.);#47=IFCCYLINDRICALSURFACE(#13,1.);",
"#41=IFCADVANCEDBREP(#42);#42=IFCCLOSEDSHELL((#43));#43=IFCADVANCEDFACE((#44),#47,.T.);#44=IFCFACEOUTERBOUND(#45,.T.);#45=IFCEDGELOOP((#46));#46=IFCORIENTEDEDGE(*,*,#48,.T.);#48=IFCEDGECURVE(#49,#49,#50,.T.);#49=IFCVERTEXPOINT(#10);#50=IFCCIRCLE(#13,0.);#47=IFCSPHERICALSURFACE(#13,-1.);",
"#41=IFCADVANCEDBREP(#42);#42=IFCCLOSEDSHELL((#43));#43=IFCADVANCEDFACE((#44),#47,.T.);#44=IFCFACEOUTERBOUND(#45,.T.);#45=IFCEDGELOOP((#46));#46=IFCORIENTEDEDGE(*,*,#48,.T.);#48=IFCEDGECURVE(#49,#49,#50,.T.);#49=IFCVERTEXPOINT(#21);#50=IFCCIRCLE(#13,3.);#47=IFCBSPLINESURFACEWITHKNOTS(1,1,((#10,#21),(#21,#10)),.UNSPECIFIED.,.F.,.F.,.F.,(2,2),(2,2),(0.,0.),(0.,1.),.UNSPECIFIED.);",
"#41=IFCADVANCEDBREP(#42);#42=IFCCLOSEDSHELL((#43));#43=IFCADVANCEDFACE((#44),#47,.T.);#44=IFCFACEOUTERBOUND(#45,.T.);#45=IFCEDGELOOP((#46));#46=IFCORIENTEDEDGE(*,*,#48,.T.);#48=IFCEDGECURVE(#49,#49,#50,.T.);#49=IFCVERTEXPOINT(#21);#50=IFCCIRCLE(#13,1.E300);#47=IFCTOROIDALSURFACE(#13,1.,1.E300);",
"#41=IFCSWEPTDISKSOLID(#92,0.1,$,IFCLENGTHMEASURE(1.E300),-5.);",
"#41=IFCSWEPTDISKSOLID(#42,0.1,$,0.5,0.7);#42=IFCTRIMMEDCURVE(#43,(IFCPARAMETERVALUE(0.)),(#10),.F.,.PARAMETER.);#43=IFCBSPLINECURVEWITHKNOTS(1,(#10,#21),.UNSPECIFIED.,.F.,.F.,(2,2),(0.,1.),.UNSPECIFIED.);",
];
for b in bad {
let _ = import_ifc(file(METRE, b, "#41", "IFCWALL").as_bytes());
}
// Raster-Platzierung mit Zyklus und kaputten Achsen.
let grid = file(METRE, "#40=IFCRECTANGLEPROFILEDEF(.AREA.,$,$,1.,1.);#41=IFCEXTRUDEDAREASOLID(#40,#13,#11,1.);#60=IFCGRIDPLACEMENT(#61,$);#61=IFCVIRTUALGRIDINTERSECTION((#62,#62),(1.,2.));#62=IFCGRIDAXIS('A',#92,.T.);#63=IFCGRID('g',$,$,$,$,#60,$,(#62),(#62),$,$);", "#41", "IFCWALL")
.replace("#94=IFCWALL('3aBcDeFgHiJkLmNoPqRsTu',$,'Teil',$,$,#30,", "#94=IFCWALL('3aBcDeFgHiJkLmNoPqRsTu',$,'Teil',$,$,#60,");
assert_eq!(import_ifc(grid.as_bytes()).unwrap().products.len(), 1);
// Platzierungs-Zyklus.
let cyc = file(METRE, "#40=IFCRECTANGLEPROFILEDEF(.AREA.,$,$,1.,1.);#41=IFCEXTRUDEDAREASOLID(#40,#13,#11,1.);", "#41", "IFCWALL")
.replace("#14=IFCLOCALPLACEMENT($,#13);", "#14=IFCLOCALPLACEMENT(#30,#13);");
File diff suppressed because it is too large. Load diff
+572
View File
@@ -0,0 +1,572 @@
// Geometrie der Türen und Fenster für den IFC-Export ([B5], Port von `src/export/ifcOpenings.ts`, 28.10.):
// statt einer Box getrennte Körper im selben Bauteil — Rahmen/Zarge, Türblatt bzw. Glas — plus
// OperationType (Tür) und PartitioningType (Fenster). Alles sind vertikale Extrusionen von Grundriss-
// Rechtecken (wie die Wände), Profile in Welt-XY, Höhen ab Öffnungs-Unterkante; `ifc_export.rs` rechnet sie
// ins Füllungssystem. TS sammelt nur die Parameter aus dem Modell (`FillParams`, Kodierung im Kopf von
// `ifc_export.rs`).
//
// Masse kommen aus dem Modell, soweit es sie hergibt (Rahmenbreite/-tiefe, Schichteinzug, Flügelzahl und
// -tabelle, Verglasung, Blattzahl, Glasanteil, Oberlicht). Fehlendes füllen dieselben Konstanten wie das 3D
// (`src-tauri/core/src/openings3d.rs`), damit IFC und Ansicht dasselbe zeigen:
// - Rahmenbreite 6 cm, Rahmentiefe 7 cm (reale Rahmen sind 70–90 mm tief, nicht so dick wie die Wand),
// Türblatt 4 cm.
// - Glaspaket: nur im IFC nötig, das 3D zeichnet Einzelscheiben. 1 Scheibe 6 mm, 2 Scheiben 24 mm
// (4-16-4, übliches Isolierglas), 3 Scheiben 36 mm (4-12-4-12-4 ≈ 36 mm).
// Nicht abgebildet (bewusst einfach): Sprossen, Fensterbank/Rollladenkasten, Schwelle, Flügelrahmen im
// Blendrahmen, Kassettenfelder, Schiebe-Laufschiene — die Körper stehen im geschlossenen Zustand.
//
// Bitgleich zur TS-Fassung (Golden-Vergleich der IFC-Ausgabe): JS-Zahlsemantik für Math.min/max/round und
// Math.hypot (Kopien aus `src-tauri/core/src/jsnum.rs`/`jsmath.rs`, fileio hängt nicht vom Kern ab),
// Rechenreihenfolge wie in TS.
pub const DEFAULT_FRAME_WIDTH: f64 = 0.06;
pub const DEFAULT_FRAME_DEPTH: f64 = 0.07;
pub const DOOR_LEAF_THICK: f64 = 0.04;
/// Glaspaket-Dicke je Scheibenzahl (1, 2, 3).
pub const GLASS_PACKAGE_THICKNESS: [f64; 3] = [0.006, 0.024, 0.036];
/// Glasanteil des Türblatts, wenn der Typ keinen angibt.
const DEFAULT_GLAZING_RATIO: f64 = 0.5;
/// Kleinste Teilabmessung, damit nie ein flaches Profil entsteht (Meter).
const MIN_DIM: f64 = 0.005;
/// Pfostenbreite einer Flügeltabelle ohne Angabe.
const DEFAULT_POST_WIDTH: f64 = 0.06;
/// Höchstzahl Flügel (Unsinn-Schutz; TS kennt 1–4).
pub const MAX_SASHES: usize = 64;
/// `Math.min(a, b)` (NaN gewinnt; −0 < +0).
fn js_min(a: f64, b: f64) -> f64 {
if a.is_nan() || b.is_nan() {
f64::NAN
} else if a < b || (a == b && a.is_sign_negative()) {
a
} else {
b
}
}
/// `Math.max(a, b)` (NaN gewinnt; +0 > −0).
fn js_max(a: f64, b: f64) -> f64 {
if a.is_nan() || b.is_nan() {
f64::NAN
} else if a > b || (a == b && a.is_sign_positive()) {
a
} else {
b
}
}
/// `Math.round(x)`.
fn js_round(x: f64) -> f64 {
if !x.is_finite() || x == 0.0 {
return x;
}
if x > 0.0 && x < 0.5 {
return 0.0;
}
if x < 0.0 && x >= -0.5 {
return -0.0;
}
let r = x.ceil();
if r - 0.5 > x { r - 1.0 } else { r }
}
/// `Math.hypot(a, b)` wie V8.
fn js_hypot2(a: f64, b: f64) -> f64 {
let v = [a, b];
let mut max = 0.0f64;
let mut nan = false;
for &x in &v {
let a = x.abs();
if a.is_infinite() {
return f64::INFINITY;
}
if a.is_nan() {
nan = true;
} else if a > max {
max = a;
}
}
if nan {
return f64::NAN;
}
if max == 0.0 {
return 0.0;
}
let (mut sum, mut comp) = (0.0f64, 0.0f64);
for &x in &v {
let n = x.abs() / max;
let summand = n * n - comp;
let prelim = sum + summand;
comp = (prelim - sum) - summand;
sum = prelim;
}
sum.sqrt() * max
}
type V2 = (f64, f64);
/// Ein Eintrag der Flügeltabelle (`SashDef`), wie im Modell.
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Sash {
/// `kind === "pfosten"`.
pub post: bool,
/// `postWidth` (None = nicht gesetzt).
pub post_width: Option<f64>,
/// `autoWidth === false`.
pub fixed: bool,
/// `width` (None = nicht gesetzt).
pub width: Option<f64>,
}
/// Art einer Tür (`DoorType.kind`, Inline `doorType: "wandoeffnung"`).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum DoorKind {
#[default]
Swing,
Sliding,
WallOpening,
}
/// Parameter einer Füllung aus dem Modell (TS `fillParams`); fehlende Typwerte als `None`.
#[derive(Clone, Debug, Default)]
pub struct FillParams {
pub wall_start: V2,
pub wall_end: V2,
/// Achs-Intervall (Abstand ab `wall_start`) und absolute Höhen der Öffnung.
pub from: f64,
pub to: f64,
pub z_bottom: f64,
pub z_top: f64,
/// Querausdehnung der Wand entlang der linken Normalen ab `wall_start` (`n_lo` = Aussenseite).
pub n_lo: f64,
pub n_hi: f64,
pub is_door: bool,
/// Typ: `frameDepth`, `insetFromFace`, `insetFace === "aussen"` (Standard), `frameWidth`.
pub frame_depth: Option<f64>,
pub inset: Option<f64>,
pub inset_outside: bool,
pub frame_width: Option<f64>,
/// Fenster: Flügelzahl (`opening.wingCount ?? type.wingCount ?? 1`), Scheiben (1–3), Flügeltabelle.
pub wing_count: f64,
pub panes: usize,
pub sashes: Vec<Sash>,
/// Tür: Art, Blattzahl, Aufschlagseite (+1 links der Achse / −1), Richtung (+1 innen / −1 aussen),
/// Scharnier am Anfang, Oberlichthöhe, Glasblatt, Glasanteil.
pub door_kind: DoorKind,
pub leaf_count: f64,
pub swing_sign: f64,
pub dir_sign: f64,
pub hinge_at_start: bool,
pub transom_height: f64,
pub glazed: bool,
pub glazing_ratio: Option<f64>,
}
/// Rolle eines Körpers: 0 Rahmen/Zarge, 1 Türblatt, 2 Glas.
#[derive(Clone, Debug, PartialEq)]
pub struct FillPart {
pub role: usize,
/// Profil in Welt-XY (Rechteck, gegen den Uhrzeigersinn in Achs-/Normalenrichtung).
pub pts: Vec<V2>,
/// Unterkante ab Öffnungs-Unterkante (m).
pub z_rel: f64,
/// Höhe des Körpers (m).
pub depth: f64,
}
#[derive(Clone, Debug, PartialEq)]
pub struct FillGeometry {
/// Ursprung des Füllungssystems (Welt-XY): Öffnungsmitte auf der Wandachse.
pub origin: V2,
/// X-Richtung des Füllungssystems (Einheitsvektor); Y = linke Normale davon.
pub u: V2,
/// IfcDoorTypeOperationEnum bzw. IfcWindowTypePartitioningEnum; None = Modell gibt nichts her.
pub kind: Option<&'static str>,
pub parts: Vec<FillPart>,
}
/// Flügeleinteilung, auf die Achsbreite aufgelöst: (von, bis, Pfosten?) ab Laibungsanfang.
struct SashSpan {
from: f64,
to: f64,
post: bool,
}
/// Löst Flügel und Pfosten zu Intervallen auf: Pfosten und Flügel mit fester Breite behalten sie, die
/// übrigen teilen den Rest gleichmässig (gleiche Regel wie `sashSegments` im 2D). Ohne Tabelle:
/// `wing_count` gleiche Flügel.
fn sash_spans(sashes: &[Sash], wing_count: f64, total: f64) -> Vec<SashSpan> {
let list: Vec<Sash> = if !sashes.is_empty() {
sashes.to_vec()
} else {
// Array.from({ length: Math.max(1, Math.round(wingCount)) }) — NaN ergibt eine leere Liste.
let n = js_max(1.0, js_round(wing_count));
let n = if n.is_nan() { 0 } else { (n as usize).min(MAX_SASHES) };
vec![Sash::default(); n]
};
let post_w = |s: &Sash| js_max(0.0, s.post_width.unwrap_or(DEFAULT_POST_WIDTH));
let fixed_w = |s: &Sash| -> Option<f64> {
if s.post {
Some(post_w(s))
} else if s.fixed {
Some(js_max(0.0, s.width.unwrap_or(0.0)))
} else {
None
}
};
let mut fixed = 0.0;
let mut auto = 0usize;
for s in &list {
match fixed_w(s) {
None => auto += 1,
Some(w) => fixed += w,
}
}
let auto_w = if auto > 0 { js_max(0.0, total - fixed) / auto as f64 } else { 0.0 };
let mut out = Vec::with_capacity(list.len());
let mut at = 0.0;
for s in &list {
let w = fixed_w(s).unwrap_or(auto_w);
out.push(SashSpan { from: at, to: at + w, post: s.post });
at += w;
}
out
}
/// Körper und Ausführung der Füllung einer Öffnung (Gegenstück der früheren TS-Funktion `fillGeometry`).
pub fn fill_geometry(p: &FillParams) -> FillGeometry {
let (dx, dy) = (p.wall_end.0 - p.wall_start.0, p.wall_end.1 - p.wall_start.1);
let len = js_hypot2(dx, dy);
let len = if len == 0.0 || len.is_nan() { 1.0 } else { len };
let u = (dx / len, dy / len);
let n = (-u.1, u.0);
let w = p.to - p.from;
let h = p.z_top - p.z_bottom;
let at = |a: f64, b: f64| -> V2 { (p.wall_start.0 + u.0 * a + n.0 * b, p.wall_start.1 + u.1 * a + n.1 * b) };
let rect = |a0: f64, a1: f64, b0: f64, b1: f64| vec![at(a0, b0), at(a1, b0), at(a1, b1), at(a0, b1)];
let center = p.from + w / 2.0;
let origin = at(center, 0.0);
let mut parts: Vec<FillPart> = Vec::new();
let mut add = |role: usize, a0: f64, a1: f64, b0: f64, b1: f64, z0: f64, z1: f64| {
if a1 - a0 < 1e-6 || b1 - b0 < 1e-6 || z1 - z0 < 1e-6 {
return;
}
parts.push(FillPart { role, pts: rect(a0, a1, b0, b1), z_rel: z0, depth: z1 - z0 });
};
// Querlage des Rahmens: Tiefe (Typ oder 7 cm), Schichteinzug von der gewählten Wandfläche, auf die
// Wanddicke geklemmt — dieselbe Rechnung wie `windowSymbol` (2D) und `resolveFrameNormalRange` (3D).
let total = p.n_hi - p.n_lo;
let fd = match p.frame_depth {
Some(d) if d > 1e-9 => d,
_ => DEFAULT_FRAME_DEPTH,
};
let frame_depth = js_min(total, fd);
let inset = js_max(0.0, p.inset.unwrap_or(0.0));
let front = if p.inset_outside { p.n_lo + inset } else { p.n_hi - inset };
let back = if p.inset_outside { front + frame_depth } else { front - frame_depth };
let mut b0 = js_max(p.n_lo, js_min(p.n_hi, js_min(front, back)));
let mut b1 = js_max(p.n_lo, js_min(p.n_hi, js_max(front, back)));
if b1 - b0 < MIN_DIM {
b0 = p.n_lo;
b1 = p.n_hi;
}
let b_mid = (b0 + b1) / 2.0;
// Sichtbare Rahmenbreite: höchstens ein Viertel der kleineren Öffnungsabmessung, sonst bliebe nichts offen.
let fw_t = match p.frame_width {
Some(x) if x > 1e-9 => x,
_ => DEFAULT_FRAME_WIDTH,
};
let fw = js_max(MIN_DIM, js_min(fw_t, js_min(w, h) / 4.0));
let a_in0 = p.from + fw;
let a_in1 = p.to - fw;
if !p.is_door {
// ── Fenster: Blendrahmen (Pfosten links/rechts, Sturz, Sohlbank), Mittelpfosten, Glas je Flügel ──
add(0, p.from, a_in0, b0, b1, 0.0, h);
add(0, a_in1, p.to, b0, b1, 0.0, h);
add(0, a_in0, a_in1, b0, b1, h - fw, h);
add(0, a_in0, a_in1, b0, b1, 0.0, fw);
let pane = GLASS_PACKAGE_THICKNESS[p.panes.clamp(1, 3) - 1];
let gt = js_min(pane, b1 - b0);
let g0 = b_mid - gt / 2.0;
let g1 = b_mid + gt / 2.0;
let spans = sash_spans(&p.sashes, p.wing_count, a_in1 - a_in0);
let mut glass_count = 0;
for (i, s) in spans.iter().enumerate() {
let x0 = a_in0 + s.from;
let x1 = a_in0 + s.to;
if s.post {
add(0, x0, x1, b0, b1, fw, h - fw);
continue;
}
// Zwischen zwei Flügeln ohne Pfosten steht ein Mittelpfosten (Breite = Rahmenbreite) auf der Grenze.
let gx0 = if i == 0 || spans[i - 1].post { x0 } else { x0 + fw / 2.0 };
let gx1 = if i == spans.len() - 1 || spans[i + 1].post { x1 } else { x1 - fw / 2.0 };
if spans.get(i + 1).is_some_and(|nx| !nx.post) {
add(0, x1 - fw / 2.0, x1 + fw / 2.0, b0, b1, fw, h - fw);
}
add(2, gx0, gx1, g0, g1, fw, h - fw);
glass_count += 1;
}
// Teilung nach IFC: nur die senkrechten Standardfälle sind benannt (sonst NOTDEFINED, das Modell
// kennt Sprossen und Seitenverhältnisse, die IFC nicht als Enum führt).
let kind = match glass_count {
1 => "SINGLE_PANEL",
2 => "DOUBLE_PANEL_VERTICAL",
3 => "TRIPLE_PANEL_VERTICAL",
_ => "NOTDEFINED",
};
return FillGeometry { origin, u, kind: Some(kind), parts };
}
// ── Tür ──
// Aufschlagrichtung wie `doorSymbol`: linke Achsnormale, Richtung „aussen“ spiegelt sie.
let swing_dir = (n.0 * p.swing_sign * p.dir_sign, n.1 * p.swing_sign * p.dir_sign);
// Füllungssystem der Tür: Y = Aufschlagrichtung (IFC: die Tür schlägt nach +Y auf), X = Y × Z.
let door_u = (swing_dir.1, -swing_dir.0);
if p.door_kind == DoorKind::WallOpening {
return FillGeometry { origin, u: door_u, kind: None, parts: Vec::new() };
}
// Zarge: Pfosten links/rechts über die ganze Höhe und Sturz (keine Schwelle).
add(0, p.from, a_in0, b0, b1, 0.0, h);
add(0, a_in1, p.to, b0, b1, 0.0, h);
add(0, a_in0, a_in1, b0, b1, h - fw, h);
// Oberlicht: fester Glasstreifen über einem Kämpfer (Riegel in Rahmenbreite) innerhalb der Öffnungshöhe.
let th = p.transom_height;
let has_transom = th > MIN_DIM && th < h - fw - 0.5;
let leaf_top = if has_transom { h - fw - th - fw } else { h - fw };
if has_transom {
add(0, a_in0, a_in1, b0, b1, leaf_top, leaf_top + fw);
let gt = js_min(GLASS_PACKAGE_THICKNESS[1], b1 - b0);
add(2, a_in0, a_in1, b_mid - gt / 2.0, b_mid + gt / 2.0, leaf_top + fw, h - fw);
}
// Türblatt/-blätter im lichten Mass der Zarge, mittig in der Rahmentiefe.
let lt = js_min(DOOR_LEAF_THICK, b1 - b0);
let l0 = b_mid - lt / 2.0;
let l1 = b_mid + lt / 2.0;
let leaf_spans: Vec<(f64, f64)> = if p.leaf_count >= 2.0 {
vec![(a_in0, (a_in0 + a_in1) / 2.0), ((a_in0 + a_in1) / 2.0, a_in1)]
} else {
vec![(a_in0, a_in1)]
};
let ratio = js_min(0.9, js_max(0.05, p.glazing_ratio.unwrap_or(DEFAULT_GLAZING_RATIO)));
for (x0, x1) in leaf_spans {
if !p.glazed {
add(1, x0, x1, l0, l1, 0.0, leaf_top);
continue;
}
// Glastür: Glasfläche = Glasanteil des Blatts (gleichmässig verkleinert um die Blattmitte), das Blatt
// als umlaufender Rahmen darum; das Glas füllt die Blattdicke zu 60 % (4–24 mm, mittig).
let s = ratio.sqrt();
let cx = (x0 + x1) / 2.0;
let cz = leaf_top / 2.0;
let gw = (x1 - x0) * s;
let gh = leaf_top * s;
let (px0, px1, pz0, pz1) = (cx - gw / 2.0, cx + gw / 2.0, cz - gh / 2.0, cz + gh / 2.0);
add(1, x0, x1, l0, l1, 0.0, pz0);
add(1, x0, x1, l0, l1, pz1, leaf_top);
add(1, x0, px0, l0, l1, pz0, pz1);
add(1, px1, x1, l0, l1, pz0, pz1);
let gt = js_min(GLASS_PACKAGE_THICKNESS[1], lt * 0.6);
add(2, px0, px1, b_mid - gt / 2.0, b_mid + gt / 2.0, pz0, pz1);
}
// OperationType: Blattzahl und Scharnierseite. IFC blickt von der Aufschlagseite (+Y des Füllungssystems)
// auf die Tür; "links" = Scharnier auf der +X-Seite des Systems (X = Y × Z, von +Y aus gesehen links).
let hinge_axis = if p.hinge_at_start { p.from } else { p.to };
let ha = at(hinge_axis, 0.0);
let hinge_local_x = (ha.0 - origin.0) * door_u.0 + (ha.1 - origin.1) * door_u.1;
let left = hinge_local_x > 0.0;
let op = if p.door_kind == DoorKind::Sliding {
if p.leaf_count >= 2.0 {
"DOUBLE_DOOR_SLIDING"
} else if left {
"SLIDING_TO_LEFT"
} else {
"SLIDING_TO_RIGHT"
}
} else if p.leaf_count >= 2.0 {
"DOUBLE_DOOR_SINGLE_SWING"
} else if left {
"SINGLE_SWING_LEFT"
} else {
"SINGLE_SWING_RIGHT"
};
FillGeometry { origin, u: door_u, kind: Some(op), parts }
}
// Tests: die früheren TS-Fälle (`ifcOpenings.test.ts`), Wand entlang +X von (0,0) nach (5,0), 0.4 dick.
#[cfg(test)]
mod tests {
use super::*;
fn base(is_door: bool, from: f64, width: f64, z0: f64, height: f64) -> FillParams {
FillParams {
wall_start: (0.0, 0.0),
wall_end: (5.0, 0.0),
from,
to: from + width,
z_bottom: z0,
z_top: z0 + height,
n_lo: -0.2,
n_hi: 0.2,
is_door,
inset_outside: true,
wing_count: 1.0,
panes: 2,
leaf_count: 1.0,
swing_sign: 1.0,
dir_sign: 1.0,
hinge_at_start: true,
..Default::default()
}
}
fn win() -> FillParams {
base(false, 1.0, 1.2, 0.9, 1.2)
}
fn door() -> FillParams {
base(true, 1.0, 1.0, 0.0, 2.1)
}
struct B {
x0: f64,
x1: f64,
y0: f64,
y1: f64,
}
fn bbox(p: &[V2]) -> B {
let f = |g: fn(&V2) -> f64, init: f64, m: fn(f64, f64) -> f64| p.iter().map(g).fold(init, m);
B { x0: f(|q| q.0, f64::MAX, f64::min), x1: f(|q| q.0, f64::MIN, f64::max), y0: f(|q| q.1, f64::MAX, f64::min), y1: f(|q| q.1, f64::MIN, f64::max) }
}
fn volume(parts: &[&FillPart]) -> f64 {
parts.iter().map(|p| {
let b = bbox(&p.pts);
(b.x1 - b.x0) * (b.y1 - b.y0) * p.depth
}).sum()
}
fn role(g: &FillGeometry, r: usize) -> Vec<&FillPart> {
g.parts.iter().filter(|p| p.role == r).collect()
}
fn close(a: f64, b: f64) -> bool {
(a - b).abs() < 1e-9
}
#[test]
fn fenster_rahmen_glas_konstanten() {
let g = fill_geometry(&win());
let (frame, glass) = (role(&g, 0), role(&g, 2));
assert_eq!((frame.len(), glass.len(), g.kind), (4, 1, Some("SINGLE_PANEL")));
let fw = DEFAULT_FRAME_WIDTH;
assert!(close(volume(&frame), (1.2 * 1.2 - (1.2 - 2.0 * fw) * (1.2 - 2.0 * fw)) * DEFAULT_FRAME_DEPTH));
let gb = bbox(&glass[0].pts);
assert!(close(gb.x1 - gb.x0, 1.2 - 2.0 * fw) && close(gb.y1 - gb.y0, 0.024));
assert!(close((gb.y0 + gb.y1) / 2.0, -0.2 + DEFAULT_FRAME_DEPTH / 2.0));
assert!(close(glass[0].z_rel, fw) && close(glass[0].depth, 1.2 - 2.0 * fw));
}
#[test]
fn fenster_masse_aus_typ_einzug_innen() {
let p = FillParams { frame_width: Some(0.09), frame_depth: Some(0.1), inset: Some(0.05), inset_outside: false, panes: 3, ..win() };
let g = fill_geometry(&p);
let frame = role(&g, 0);
let b = bbox(&frame[0].pts);
assert!(close(b.y0, 0.05) && close(b.y1, 0.15));
let gl = bbox(&role(&g, 2)[0].pts);
assert!(close(gl.y1 - gl.y0, 0.036) && close(gl.x1 - gl.x0, 1.2 - 0.18));
// Rahmentiefe auf die Wanddicke geklemmt.
let g = fill_geometry(&FillParams { frame_depth: Some(1.0), ..win() });
let b = bbox(&g.parts[0].pts);
assert!(close(b.y0, -0.2) && close(b.y1, 0.2));
}
#[test]
fn fenster_fluegel_und_tabelle() {
for (wing, kind) in [(2.0, "DOUBLE_PANEL_VERTICAL"), (3.0, "TRIPLE_PANEL_VERTICAL"), (4.0, "NOTDEFINED")] {
let g = fill_geometry(&FillParams { wing_count: wing, ..win() });
assert_eq!(role(&g, 2).len(), wing as usize);
assert_eq!(role(&g, 0).len(), 4 + wing as usize - 1);
assert_eq!(g.kind, Some(kind));
}
let sashes = vec![
Sash { fixed: true, width: Some(0.5), ..Default::default() },
Sash { post: true, post_width: Some(0.1), ..Default::default() },
Sash::default(),
];
let g = fill_geometry(&FillParams { sashes, ..win() });
let glass: Vec<B> = role(&g, 2).iter().map(|p| bbox(&p.pts)).collect();
assert_eq!(glass.len(), 2);
assert!(close(glass[0].x1 - glass[0].x0, 0.5));
let clear = 1.2 - 2.0 * 0.06;
assert!(close(glass[1].x1 - glass[1].x0, clear - 0.6) && close(glass[1].x0, glass[0].x1 + 0.1));
assert_eq!(g.kind, Some("DOUBLE_PANEL_VERTICAL"));
// Alles innerhalb der Öffnung und der Wand.
for p in &fill_geometry(&FillParams { wing_count: 2.0, ..win() }).parts {
let b = bbox(&p.pts);
assert!(b.x0 >= 1.0 - 1e-9 && b.x1 <= 2.2 + 1e-9 && b.y0 >= -0.2 - 1e-9 && b.y1 <= 0.2 + 1e-9);
assert!(p.z_rel >= -1e-9 && p.z_rel + p.depth <= 1.2 + 1e-9);
}
// Unsinnige Flügelzahl: keine Scheibe, kein Panic.
assert!(role(&fill_geometry(&FillParams { wing_count: f64::NAN, ..win() }), 2).is_empty());
assert!(fill_geometry(&FillParams { wing_count: 1e300, ..win() }).parts.len() <= 4 + 2 * MAX_SASHES);
}
#[test]
fn tuer_zarge_blatt_glas_oberlicht() {
let g = fill_geometry(&door());
assert_eq!(role(&g, 0).len(), 3);
let leaf = role(&g, 1);
assert_eq!(leaf.len(), 1);
let lb = bbox(&leaf[0].pts);
assert!(close(lb.y1 - lb.y0, DOOR_LEAF_THICK) && close(lb.x1 - lb.x0, 1.0 - 2.0 * DEFAULT_FRAME_WIDTH));
assert!(leaf[0].z_rel == 0.0 && close(leaf[0].depth, 2.1 - DEFAULT_FRAME_WIDTH));
assert!(role(&g, 2).is_empty());
// Zweiflügelig.
let g = fill_geometry(&FillParams { leaf_count: 2.0, ..door() });
assert_eq!((role(&g, 1).len(), g.kind), (2, Some("DOUBLE_DOOR_SINGLE_SWING")));
// Glastür.
let g = fill_geometry(&FillParams { glazed: true, glazing_ratio: Some(0.36), ..door() });
let glass = role(&g, 2);
assert_eq!(glass.len(), 1);
let gb = bbox(&glass[0].pts);
let (lw, lh) = (1.0 - 2.0 * DEFAULT_FRAME_WIDTH, 2.1 - DEFAULT_FRAME_WIDTH);
assert!(close((gb.x1 - gb.x0) * glass[0].depth / (lw * lh), 0.36));
let leaf = role(&g, 1);
assert_eq!(leaf.len(), 4);
assert!(close(volume(&leaf), (lw * lh - (gb.x1 - gb.x0) * glass[0].depth) * DOOR_LEAF_THICK));
// Oberlicht.
let g = fill_geometry(&FillParams { transom_height: 0.4, ..door() });
let glass = role(&g, 2);
assert!(close(glass[0].depth, 0.4) && close(glass[0].z_rel + glass[0].depth, 2.1 - DEFAULT_FRAME_WIDTH));
let leaf = role(&g, 1)[0];
assert!(close(leaf.z_rel + leaf.depth, 2.1 - DEFAULT_FRAME_WIDTH - 0.4 - DEFAULT_FRAME_WIDTH));
// Reine Wandöffnung.
let g = fill_geometry(&FillParams { door_kind: DoorKind::WallOpening, ..door() });
assert!(g.kind.is_none() && g.parts.is_empty());
}
#[test]
fn tuer_anschlag_und_system() {
// Wand entlang +X, linke Normale +Y. Standard: Aufschlag nach +Y, Scharnier am Anfang (x klein):
// von +Y nach −Y gesehen liegt x klein rechts → RIGHT.
let kind = |p: FillParams| fill_geometry(&p).kind;
assert_eq!(kind(door()), Some("SINGLE_SWING_RIGHT"));
assert_eq!(kind(FillParams { hinge_at_start: false, ..door() }), Some("SINGLE_SWING_LEFT"));
assert_eq!(kind(FillParams { dir_sign: -1.0, ..door() }), Some("SINGLE_SWING_LEFT"));
assert_eq!(kind(FillParams { swing_sign: -1.0, ..door() }), Some("SINGLE_SWING_LEFT"));
assert_eq!(kind(FillParams { door_kind: DoorKind::Sliding, ..door() }), Some("SLIDING_TO_RIGHT"));
assert_eq!(kind(FillParams { door_kind: DoorKind::Sliding, leaf_count: 2.0, ..door() }), Some("DOUBLE_DOOR_SLIDING"));
let g = fill_geometry(&door());
assert_eq!(g.origin, (1.5, 0.0));
assert!(close(g.u.0, 1.0) && close(g.u.1, 0.0));
assert!(close(fill_geometry(&FillParams { dir_sign: -1.0, ..door() }).u.0, -1.0));
}
#[test]
fn js_zahlen() {
assert_eq!(js_round(2.5), 3.0);
assert_eq!(js_round(-2.5), -2.0);
assert!(js_min(0.0, -0.0).is_sign_negative() && js_max(-0.0, 0.0).is_sign_positive());
assert_eq!(js_hypot2(3.0, 4.0), 5.0);
}
}
+98 -3
View File
@@ -107,6 +107,15 @@ pub struct Opening {
/// Brüstung über Wand-Unterkante.
pub sill: f64,
pub height: f64,
/// Ausführung: IfcDoorTypeOperationEnum (Tür) bzw. IfcWindowTypePartitioningEnum (Fenster) vom
/// Bauteil, sonst vom Typ (IfcDoorType/IfcWindowType, IFC2x3 IfcDoorStyle/IfcWindowStyle);
/// NOTDEFINED/USERDEFINED → `None`.
pub operation: Option<String>,
/// Tür: Aufschlag (+Y der Tür-Platzierung, IFC) links (+1) bzw. rechts (−1) der Wandachse; 0 = unbekannt.
pub swing: i8,
/// Tür: Scharnier am Wandanfang (+1) bzw. -ende (−1) nach LEFT/RIGHT der Ausführung (IFC: von der
/// Aufschlagseite gesehen; LEFT = Scharnier auf +X der Tür-Platzierung); 0 = unbekannt.
pub hinge: i8,
}
#[derive(Clone, Debug, Default)]
@@ -488,6 +497,44 @@ struct Ctx<'r, 'a> {
}
impl Ctx<'_, '_> {
/// Ausführung, Aufschlagseite und Scharnier einer Tür/eines Fensters (s. [`Opening`]); `d` =
/// Richtung der (endgültigen) Wandachse.
fn operation(&mut self, id: u64, d: V2) -> (Option<String>, i8, i8) {
let f = self.r.f;
let Some(e) = f.get(id) else { return (None, 0, 0) };
let pick = |v: Option<&Value>| v.and_then(|v| v.as_enum()).filter(|x| *x != "NOTDEFINED" && *x != "USERDEFINED").map(str::to_string);
// IFC4: IfcDoor.OperationType / IfcWindow.PartitioningType (12. Attribut).
let own = if e.ty.starts_with("IFCDOOR") || e.ty.starts_with("IFCWINDOW") { pick(e.arg(11)) } else { None };
let op = own.or_else(|| {
let t = f.get(*self.type_of.get(&id)?)?;
match t.ty.as_str() {
"IFCDOORTYPE" | "IFCWINDOWTYPE" => pick(t.arg(10)),
"IFCDOORSTYLE" => pick(t.arg(8)),
"IFCWINDOWSTYLE" => pick(t.arg(9)),
_ => None,
}
});
// Seite nur mit bekannter Ausführung (ohne sie ist die Platzierung oft einfach die der Wand).
if !e.ty.starts_with("IFCDOOR") || op.is_none() {
return (op, 0, 0);
}
let Some(place) = e.arg(5).and_then(|v| v.as_ref_id()) else { return (op, 0, 0) };
let xf = self.r.object_placement(place, 0);
let x = xf.apply_dir([1.0, 0.0, 0.0]);
let y = xf.apply_dir([0.0, 1.0, 0.0]);
let (Some(x), Some(y)) = (unit2([x[0], x[1]]), unit2([y[0], y[1]])) else { return (op, 0, 0) };
let side = |v: f64| if v > 0.5 { 1 } else if v < -0.5 { -1 } else { 0 };
let swing = side(dot2(y, left(d)));
let hinge = match op.as_deref() {
Some(o) if !o.starts_with("DOUBLE_DOOR") && (o.ends_with("LEFT") || o.ends_with("RIGHT")) => {
let h = if o.ends_with("LEFT") { x } else { [-x[0], -x[1]] };
-side(dot2(h, d))
}
_ => 0,
};
(op, swing, hinge)
}
fn info(&self, id: u64, color: Option<[f64; 4]>) -> Info {
let f = self.r.f;
let Some(e) = f.get(id) else { return Info::default() };
@@ -954,10 +1001,25 @@ pub(crate) fn analyze(r: &mut Reader, rels: &Rels, ids: &[u64]) -> Semantic {
let z0 = b[4].max(w.z0);
let z1 = b[5].min(w.z1);
let info = cx.info(filling.unwrap_or(*o), None);
let (operation, swing, hinge) = match filling {
Some(x) => cx.operation(*x, d),
None => (None, 0, 0),
};
if let Some(x) = filling {
out.converted.insert(*x);
}
out.openings.push(Opening { info, host, kind: *kind, position: u0, width: u1 - u0, sill: z0 - w.z0, height: z1 - z0 });
out.openings.push(Opening {
info,
host,
kind: *kind,
position: u0,
width: u1 - u0,
sill: z0 - w.z0,
height: z1 - z0,
operation,
swing,
hinge,
});
}
out.walls.push(Wall { info: w.info, start, end, z0: w.z0, z1: w.z1, thickness: w.thickness });
}
@@ -967,7 +1029,7 @@ pub(crate) fn analyze(r: &mut Reader, rels: &Rels, ids: &[u64]) -> Semantic {
// ---------------------------------------------------------------------------
// Flache Kodierung für JS: Texte/Verweise als JSON, Zahlen in einem Float64Array.
// wall: sx, sy, ex, ey, z0, z1, thickness
// opening: position, width, sill, height
// opening: position, width, sill, height, swing (±1/0), hinge (±1/0)
// slab: z0, z1, nRings, (nPts, x, y, …)* (erster Ring = Umriss)
// column: cx, cy, rotation, z0, z1, a, b (rect: Breite, Tiefe; round: Radius, 0)
// space: z0, z1, nPts, x, y, …
@@ -1018,7 +1080,13 @@ pub(crate) fn encode(s: &Semantic) -> (serde_json::Value, Vec<f64>) {
OpeningKind::Window => "window",
OpeningKind::Hole => "hole",
};
push("opening", &o.info, json!({ "host": o.host, "openingKind": kind }), vec![o.position, o.width, o.sill, o.height], &mut data);
push(
"opening",
&o.info,
json!({ "host": o.host, "openingKind": kind, "operation": o.operation }),
vec![o.position, o.width, o.sill, o.height, o.swing as f64, o.hinge as f64],
&mut data,
);
}
for sl in &s.slabs {
let mut nums = vec![sl.z0, sl.z1, (1 + sl.holes.len()) as f64];
@@ -1221,6 +1289,33 @@ ENDSEC;\nEND-ISO-10303-21;\n"
let w = &s.walls[0];
assert!(close2(w.start, [6.0, 0.0]) && close2(w.end, [0.0, 0.0]), "{w:?}");
assert!(close(s.openings[0].position, 6.0 - 1.9));
// Ohne Ausführung und Platzierung: nichts abgeleitet.
assert_eq!((s.openings[0].operation.as_deref(), s.openings[0].swing, s.openings[0].hinge), (None, 0, 0));
// Tür-Ausführung ([B4]): OperationType am Bauteil, eigene Platzierung in der Öffnungsmitte mit
// X = −x (Y = Z × X = −y = Aufschlag nach rechts der Wandachse +x). LEFT = Scharnier auf +X der
// Tür = −x-Seite = Wandanfang. Fenster: PartitioningType am Typ (IfcRelDefinesByType).
let door = "#800=IFCDOOR('f800',$,'F800',$,$,#820,$,$,2100.,900.,.DOOR.,.SINGLE_SWING_LEFT.,$);\
#821=IFCCARTESIANPOINT((1450.,0.,0.));#822=IFCDIRECTION((-1.,0.,0.));#823=IFCAXIS2PLACEMENT3D(#821,#11,#822);#820=IFCLOCALPLACEMENT(#1004,#823);";
let window = "#830=IFCWINDOWTYPE('wt',$,'Fenster 2',$,$,$,$,$,$,.WINDOW.,.DOUBLE_PANEL_VERTICAL.,$,$);\
#831=IFCRELDEFINESBYTYPE('dt',$,$,$,(#810),#830);";
let src2 = src.replace("#800=IFCDOOR('f800',$,'F800',$,$,#1004,$,$,$,$,$,$,$);", door) + "";
let src2 = src2.replace("#906=IFCRELASSOCIATESMATERIAL", &format!("{window}#906=IFCRELASSOCIATESMATERIAL"));
let (_, s) = sem(&src2);
let d = &s.openings[0];
assert_eq!((d.operation.as_deref(), d.swing, d.hinge), (Some("SINGLE_SWING_LEFT"), -1, 1), "{d:?}");
assert_eq!(s.openings[1].operation.as_deref(), Some("DOUBLE_PANEL_VERTICAL"));
// Umgekehrte Wand: Scharnier am Ende, Aufschlag links der neuen Richtung.
let (_, s) = sem(&src2.replace(".POSITIVE.", ".NEGATIVE."));
assert_eq!((s.openings[0].swing, s.openings[0].hinge), (1, -1));
// RIGHT: Scharnier auf −X der Tür = +x-Seite = Wandende.
let (_, s) = sem(&src2.replace(".SINGLE_SWING_LEFT.", ".SINGLE_SWING_RIGHT."));
assert_eq!((s.openings[0].swing, s.openings[0].hinge), (-1, -1));
// Zweiflüglig: Seite ohne Scharnier-Angabe; NOTDEFINED zählt nicht.
let (_, s) = sem(&src2.replace(".SINGLE_SWING_LEFT.", ".DOUBLE_DOOR_SINGLE_SWING."));
assert_eq!((s.openings[0].operation.as_deref(), s.openings[0].swing, s.openings[0].hinge), (Some("DOUBLE_DOOR_SINGLE_SWING"), -1, 0));
let (_, s) = sem(&src2.replace(".SINGLE_SWING_LEFT.", ".NOTDEFINED."));
assert_eq!(s.openings[0].operation, None);
}
#[test]
+2
View File
@@ -22,8 +22,10 @@ pub mod ifc_step;
pub mod ifc_import;
pub mod ifc_semantic;
pub mod ifc_export;
pub mod ifc_openings;
pub mod csg;
mod ifc_sweep;
mod ifc_nurbs;
use std::collections::HashMap;
use std::io::Cursor;
+23 -12
View File
@@ -32,7 +32,7 @@
// • Decke → IfcSlab (outline-Polygon, PredefinedType FLOOR).
// • Öffnung → IfcOpeningElement (Quader über die ganze Wanddicke, etwas vorstehend) in der
// Wand (IfcRelVoidsElement), darin IfcDoor/IfcWindow (IfcRelFillsElement) aus getrennten Körpern
// ([B5], 28.10., `ifcOpenings.ts`): Rahmen/Zarge + Türblatt bzw. Glas je Flügel, mit Farbe/
// ([B5], 28.10., Parameter `ifcOpenings.ts`, Rechnung `ifc_openings.rs`): Rahmen/Zarge + Türblatt bzw. Glas je Flügel, mit Farbe/
// Transparenz je Rolle; OperationType (Tür: Blattzahl, Scharnierseite, Schiebe) und
// PartitioningType (Fenster: Flügelzahl). Masse aus dem Modell (Rahmenbreite/-tiefe, Einzug,
// Verglasung, Glasanteil, Oberlicht), sonst die Konstanten des 3D. Ohne Sprossen, Fensterbank,
@@ -87,7 +87,7 @@ import { columnFootprint } from "../geometry/column";
import { openingInterval, openingVerticalExtent } from "../geometry/opening";
import { emitRoofs } from "../plan/toWalls3d/roofs";
import { fileio } from "../engine/fileioWasm";
import { fillGeometry, type FillGeometry } from "./ifcOpenings";
import { fillParams, type FillParams } from "./ifcOpenings";
/** Deterministische 22-stellige IFC-GUID aus einem Namen (Rust, `ifc_export.rs::ifc_guid`). */
export function ifcGuid(name: string): string {
@@ -101,7 +101,7 @@ export function ifcString(s: string): string {
// ── Flacher Puffer (Gegenstück zu src-tauri/fileio/src/ifc_export.rs, dort die Kodierung) ─────
const FLAT_VERSION = 1;
const FLAT_VERSION = 2;
const REC_WALL_SOLIDS = 1;
const REC_WALL_MESH = 2;
const REC_CEILING = 3;
@@ -246,18 +246,29 @@ class FlatIfc {
voidZRel: number;
depth: number;
width: number;
fill: FillGeometry;
fill: FillParams;
psets: PsetIn[];
}): void {
this.nums.push(REC_OPENING, this.str(o.wallId), o.structure, this.str(o.openingId), o.isDoor ? 1 : 0, this.str(o.fillName));
this.pts(o.voidRect);
this.nums.push(o.voidZRel, o.depth, o.width, o.fill.kind === null ? -1 : this.str(o.fill.kind));
this.nums.push(o.fill.origin.x, o.fill.origin.y, o.fill.u.x, o.fill.u.y, o.fill.parts.length);
for (const p of o.fill.parts) {
this.nums.push(p.role);
this.pts(p.pts);
this.nums.push(p.zRel, p.depth);
this.nums.push(o.voidZRel, o.depth, o.width);
// FILL (Kopf von `ifc_export.rs`): Parameter, die Rust zu Körpern und Ausführung rechnet.
const f = o.fill;
const opt = (v: number | null | undefined) => this.nums.push(v == null ? 0 : 1, v ?? 0);
this.nums.push(f.wallStart.x, f.wallStart.y, f.wallEnd.x, f.wallEnd.y, f.from, f.to, f.zBottom, f.zTop, f.nLo, f.nHi);
opt(f.frameDepth);
opt(f.inset);
this.nums.push(f.insetOutside ? 1 : 0);
opt(f.frameWidth);
this.nums.push(f.wingCount, f.panes, f.sashes.length);
for (const s of f.sashes) {
this.nums.push(s.post ? 1 : 0);
opt(s.postWidth);
this.nums.push(s.fixed ? 1 : 0);
opt(s.width);
}
this.nums.push(f.doorKind, f.leafCount, f.swingSign, f.dirSign, f.hingeAtStart ? 1 : 0, f.transomHeight, f.glazed ? 1 : 0);
opt(f.glazingRatio);
this.psets(o.psets);
}
@@ -680,7 +691,7 @@ export function exportIfcSpf(projectIn: Project): string {
// Der Öffnungskörper ist ein Quader über das Achs-Intervall und die Höhe, wie sie das 3D
// stanzt (`openingInterval`/`openingVerticalExtent`), quer über alle Bänder der Wand plus
// OPENING_OVERSHOOT. Die Füllung (Tür/Fenster) hat ein eigenes Placement
// (Öffnungsmitte, Achse bzw. Aufschlagrichtung) und liegt in der Rahmentiefe (`ifcOpenings.ts`).
// (Öffnungsmitte, Achse bzw. Aufschlagrichtung) und liegt in der Rahmentiefe (`ifc_openings.rs`).
for (const wall of project.walls ?? []) {
const host = hostExtent.get(wall.id);
if (!host) continue; // Wirtswand übersprungen (degeneriert)
@@ -715,7 +726,7 @@ export function exportIfcSpf(projectIn: Project): string {
voidZRel: c.zBottom - baseOf(structure),
depth,
width: c.to - c.from,
fill: fillGeometry(project, wall, opening, c, host),
fill: fillParams(project, wall, opening, c, host),
psets: [{ name: psetName, props }],
});
}
+56 -185
View File
@@ -1,204 +1,75 @@
// Geometrie der Türen/Fenster im IFC-Export ([B5]): Rahmen, Blatt, Glas, Ausführung. Reine Rechnung,
// kein WASM nötig.
// Türen/Fenster im IFC-Export ([B5]): TS sammelt nur die Parameter aus Typ und Öffnung; die Geometrie
// rechnet Rust (`src-tauri/fileio/src/ifc_openings.rs`, dort die Fälle Rahmen/Blatt/Glas/Ausführung).
import { describe, expect, it } from "vitest";
import { fillGeometry, DEFAULT_FRAME_WIDTH, DEFAULT_FRAME_DEPTH, DOOR_LEAF_THICK } from "./ifcOpenings";
import { fillParams } from "./ifcOpenings";
import type { DoorType, Opening, Project, Wall, WindowType } from "../model/types";
const wall = { id: "W", start: { x: 0, y: 0 }, end: { x: 5, y: 0 } } as Wall;
const host = { nLo: -0.2, nHi: 0.2 };
function proj(over: { doorTypes?: DoorType[]; windowTypes?: WindowType[] }): Project {
return { doorTypes: over.doorTypes ?? [], windowTypes: over.windowTypes ?? [] } as unknown as Project;
}
function door(over: Partial<Opening> = {}): Opening {
return { id: "D", type: "opening", hostWallId: "W", categoryCode: "21", kind: "door", position: 1, width: 1, height: 2.1, sillHeight: 0, ...over } as Opening;
}
function win(over: Partial<Opening> = {}): Opening {
return { id: "F", type: "opening", hostWallId: "W", categoryCode: "21", kind: "window", position: 1, width: 1.2, height: 1.2, sillHeight: 0.9, ...over } as Opening;
}
const proj = (over: { doorTypes?: DoorType[]; windowTypes?: WindowType[] }) =>
({ doorTypes: over.doorTypes ?? [], windowTypes: over.windowTypes ?? [] }) as unknown as Project;
const door = (over: Partial<Opening> = {}) =>
({ id: "D", type: "opening", hostWallId: "W", categoryCode: "21", kind: "door", position: 1, width: 1, height: 2.1, sillHeight: 0, ...over }) as Opening;
const win = (over: Partial<Opening> = {}) =>
({ id: "F", type: "opening", hostWallId: "W", categoryCode: "21", kind: "window", position: 1, width: 1.2, height: 1.2, sillHeight: 0.9, ...over }) as Opening;
const cut = (o: Opening) => ({ from: o.position, to: o.position + o.width, zBottom: o.sillHeight, zTop: o.sillHeight + o.height });
const wt = (over: Partial<WindowType> = {}): WindowType =>
({ id: "wt", name: "Fenster", kind: "dreh", wingCount: 1, glazing: "zweifach", frameThickness: 0.08, defaultSillHeight: 0.9, defaultWidth: 1.2, defaultHeight: 1.2, ...over }) as WindowType;
({ id: "wt", name: "Fenster", kind: "dreh", wingCount: 1, glazing: "dreifach", frameThickness: 0.08, defaultSillHeight: 0.9, defaultWidth: 1.2, defaultHeight: 1.2, ...over }) as WindowType;
const dtp = (over: Partial<DoorType> = {}): DoorType =>
({ id: "dt", name: "Tür", kind: "dreh", leafCount: 1, leafStyle: "glatt", frameThickness: 0.06, defaultWidth: 1, defaultHeight: 2.1, ...over }) as DoorType;
const bbox = (pts: { x: number; y: number }[]) => ({
x0: Math.min(...pts.map((p) => p.x)),
x1: Math.max(...pts.map((p) => p.x)),
y0: Math.min(...pts.map((p) => p.y)),
y1: Math.max(...pts.map((p) => p.y)),
});
const volume = (parts: { pts: { x: number; y: number }[]; depth: number }[]) =>
parts.reduce((a, p) => {
const b = bbox(p.pts);
return a + (b.x1 - b.x0) * (b.y1 - b.y0) * p.depth;
}, 0);
describe("fillGeometry — Fenster", () => {
it("Blendrahmen aus 4 Teilen + eine Glasscheibe, Masse aus Konstanten, Glas = Paketdicke", () => {
const o = win({ typeId: "wt" });
const g = fillGeometry(proj({ windowTypes: [wt()] }), wall, o, cut(o), host);
const frame = g.parts.filter((p) => p.role === 0);
const glass = g.parts.filter((p) => p.role === 2);
expect(frame.length).toBe(4);
expect(glass.length).toBe(1);
expect(g.kind).toBe("SINGLE_PANEL");
// Rahmenvolumen = (W·H − lichtes Mass) · Tiefe
const fw = DEFAULT_FRAME_WIDTH;
expect(volume(frame)).toBeCloseTo((1.2 * 1.2 - (1.2 - 2 * fw) * (1.2 - 2 * fw)) * DEFAULT_FRAME_DEPTH, 9);
// Glas füllt das lichte Mass, 24 mm (zweifach), mittig in der Rahmentiefe (aussen = nLo).
const gb = bbox(glass[0].pts);
expect(gb.x1 - gb.x0).toBeCloseTo(1.2 - 2 * fw, 9);
expect(gb.y1 - gb.y0).toBeCloseTo(0.024, 9);
expect((gb.y0 + gb.y1) / 2).toBeCloseTo(-0.2 + DEFAULT_FRAME_DEPTH / 2, 9);
expect(glass[0].zRel).toBeCloseTo(fw, 9);
expect(glass[0].depth).toBeCloseTo(1.2 - 2 * fw, 9);
});
it("Rahmenbreite/-tiefe/Einzug/Verglasung aus dem Typ; Einzug von innen", () => {
const o = win({ typeId: "wt" });
const t = wt({ frameWidth: 0.09, frameDepth: 0.1, insetFromFace: 0.05, insetFace: "innen", glazing: "dreifach" });
const g = fillGeometry(proj({ windowTypes: [t] }), wall, o, cut(o), host);
const frame = g.parts.filter((p) => p.role === 0);
const b = bbox(frame[0].pts);
// innen = nHi: Vorderkante 5 cm eingezogen → Rahmen von 0.05 bis 0.15 (Tiefe 10 cm nach aussen)
expect(b.y0).toBeCloseTo(0.05, 9);
expect(b.y1).toBeCloseTo(0.15, 9);
expect(bbox(frame[2].pts).y1 - bbox(frame[2].pts).y0).toBeCloseTo(0.1, 9);
const gl = bbox(g.parts.find((p) => p.role === 2)!.pts);
expect(gl.y1 - gl.y0).toBeCloseTo(0.036, 9);
expect(gl.x1 - gl.x0).toBeCloseTo(1.2 - 0.18, 9);
});
it("Rahmentiefe wird auf die Wanddicke geklemmt", () => {
const o = win({ typeId: "wt" });
const g = fillGeometry(proj({ windowTypes: [wt({ frameDepth: 1 })] }), wall, o, cut(o), host);
const b = bbox(g.parts[0].pts);
expect(b.y0).toBeCloseTo(-0.2, 9);
expect(b.y1).toBeCloseTo(0.2, 9);
});
it("Flügelzahl → Mittelpfosten + eine Scheibe je Flügel, PartitioningType", () => {
for (const [wing, kind] of [
[2, "DOUBLE_PANEL_VERTICAL"],
[3, "TRIPLE_PANEL_VERTICAL"],
[4, "NOTDEFINED"],
] as const) {
const o = win({ typeId: "wt", wingCount: wing });
const g = fillGeometry(proj({ windowTypes: [wt()] }), wall, o, cut(o), host);
expect(g.parts.filter((p) => p.role === 2).length, `${wing}`).toBe(wing);
expect(g.parts.filter((p) => p.role === 0).length, `${wing}`).toBe(4 + (wing - 1));
expect(g.kind).toBe(kind);
}
});
it("Flügeltabelle mit Pfosten und fester Breite: Gläser abgrenzend, keine Überlappung", () => {
const o = win({ typeId: "wt" });
describe("fillParams", () => {
it("Fenster: Typwerte, Flügeltabelle, Flügelzahl der Öffnung vor dem Typ", () => {
const t = wt({
frameWidth: 0.09,
frameDepth: 0.1,
insetFromFace: 0.05,
insetFace: "innen",
wingCount: 3,
sashes: [{ kind: "fluegel", autoWidth: false, width: 0.5 }, { kind: "pfosten", postWidth: 0.1 }, { kind: "fluegel" }],
});
const o = win({ typeId: "wt", wingCount: 2 });
expect(fillParams(proj({ windowTypes: [t] }), wall, o, cut(o), host)).toMatchObject({
from: 1,
to: 2.2,
zBottom: 0.9,
zTop: 2.1,
nLo: -0.2,
nHi: 0.2,
frameDepth: 0.1,
frameWidth: 0.09,
inset: 0.05,
insetOutside: false,
wingCount: 2,
panes: 3,
sashes: [
{ kind: "fluegel", autoWidth: false, width: 0.5 },
{ kind: "pfosten", postWidth: 0.1 },
{ kind: "fluegel" },
{ post: false, fixed: true, width: 0.5 },
{ post: true, postWidth: 0.1, fixed: false },
{ post: false, fixed: false },
],
});
const g = fillGeometry(proj({ windowTypes: [t] }), wall, o, cut(o), host);
const glass = g.parts.filter((p) => p.role === 2).map((p) => bbox(p.pts));
expect(glass.length).toBe(2);
expect(glass[0].x1 - glass[0].x0).toBeCloseTo(0.5, 9);
const clear = 1.2 - 2 * 0.06;
expect(glass[1].x1 - glass[1].x0).toBeCloseTo(clear - 0.6, 9);
expect(glass[1].x0).toBeCloseTo(glass[0].x1 + 0.1, 9);
expect(g.kind).toBe("DOUBLE_PANEL_VERTICAL");
// Ohne Typ: nichts vom Typ, zwei Scheiben, eine Flügel.
const p = fillParams(proj({}), wall, win(), cut(win()), host);
expect(p).toMatchObject({ frameDepth: undefined, frameWidth: undefined, insetOutside: true, wingCount: 1, panes: 2, sashes: [] });
});
it("ohne Typ: Standardmasse, zweifach, Flügelzahl der Öffnung", () => {
const o = win({ wingCount: 2 });
const g = fillGeometry(proj({}), wall, o, cut(o), host);
const glass = g.parts.filter((p) => p.role === 2);
expect(glass.length).toBe(2);
const b = bbox(glass[0].pts);
expect(b.y1 - b.y0).toBeCloseTo(0.024, 9);
});
it("alle Teile liegen innerhalb der Öffnung und der Wand", () => {
const o = win({ typeId: "wt", wingCount: 2 });
const g = fillGeometry(proj({ windowTypes: [wt()] }), wall, o, cut(o), host);
for (const p of g.parts) {
const b = bbox(p.pts);
expect(b.x0).toBeGreaterThanOrEqual(1 - 1e-9);
expect(b.x1).toBeLessThanOrEqual(2.2 + 1e-9);
expect(b.y0).toBeGreaterThanOrEqual(-0.2 - 1e-9);
expect(b.y1).toBeLessThanOrEqual(0.2 + 1e-9);
expect(p.zRel).toBeGreaterThanOrEqual(-1e-9);
expect(p.zRel + p.depth).toBeLessThanOrEqual(1.2 + 1e-9);
}
});
});
describe("fillGeometry — Tür", () => {
it("Zarge (3 Teile) + Blatt, Blatt 4 cm mittig, Höhe bis unter den Sturz", () => {
const o = door({ typeId: "dt" });
const g = fillGeometry(proj({ doorTypes: [dtp()] }), wall, o, cut(o), host);
expect(g.parts.filter((p) => p.role === 0).length).toBe(3);
const leaf = g.parts.filter((p) => p.role === 1);
expect(leaf.length).toBe(1);
const lb = bbox(leaf[0].pts);
expect(lb.y1 - lb.y0).toBeCloseTo(DOOR_LEAF_THICK, 9);
expect(lb.x1 - lb.x0).toBeCloseTo(1 - 2 * DEFAULT_FRAME_WIDTH, 9);
expect(leaf[0].zRel).toBe(0);
expect(leaf[0].depth).toBeCloseTo(2.1 - DEFAULT_FRAME_WIDTH, 9);
expect(g.parts.some((p) => p.role === 2)).toBe(false);
});
it("zweiflügelig: zwei Blätter, DOUBLE_DOOR_SINGLE_SWING", () => {
const o = door({ typeId: "dt" });
const g = fillGeometry(proj({ doorTypes: [dtp({ leafCount: 2 })] }), wall, o, cut(o), host);
expect(g.parts.filter((p) => p.role === 1).length).toBe(2);
expect(g.kind).toBe("DOUBLE_DOOR_SINGLE_SWING");
});
it("Glastür: Glasfläche = glazingRatio des Blatts, Blatt als Rahmen darum, ohne Überlappung", () => {
const o = door({ typeId: "dt" });
const g = fillGeometry(proj({ doorTypes: [dtp({ leafStyle: "glas", glazingRatio: 0.36 })] }), wall, o, cut(o), host);
const glass = g.parts.filter((p) => p.role === 2);
expect(glass.length).toBe(1);
const gb = bbox(glass[0].pts);
const leafW = 1 - 2 * DEFAULT_FRAME_WIDTH;
const leafH = 2.1 - DEFAULT_FRAME_WIDTH;
expect(((gb.x1 - gb.x0) * glass[0].depth) / (leafW * leafH)).toBeCloseTo(0.36, 9);
const leaf = g.parts.filter((p) => p.role === 1);
expect(leaf.length).toBe(4);
// Blatt ohne Glasfläche = volle Blattfläche − Glasfläche, über 4 cm
expect(volume(leaf)).toBeCloseTo((leafW * leafH - (gb.x1 - gb.x0) * glass[0].depth) * DOOR_LEAF_THICK, 9);
});
it("Oberlicht: Riegel + Glasstreifen, Blatt entsprechend kürzer", () => {
const o = door({ typeId: "dt" });
const g = fillGeometry(proj({ doorTypes: [dtp({ transomHeight: 0.4 })] }), wall, o, cut(o), host);
const glass = g.parts.filter((p) => p.role === 2);
expect(glass.length).toBe(1);
expect(glass[0].depth).toBeCloseTo(0.4, 9);
expect(glass[0].zRel + glass[0].depth).toBeCloseTo(2.1 - DEFAULT_FRAME_WIDTH, 9);
const leaf = g.parts.find((p) => p.role === 1)!;
expect(leaf.zRel + leaf.depth).toBeCloseTo(2.1 - DEFAULT_FRAME_WIDTH - 0.4 - DEFAULT_FRAME_WIDTH, 9);
});
it("reine Wandöffnung (Typ oder Inline): kein Körper, keine Ausführung", () => {
const o = door({ typeId: "dt" });
expect(fillGeometry(proj({ doorTypes: [dtp({ kind: "wandoeffnung" })] }), wall, o, cut(o), host)).toMatchObject({ kind: null, parts: [] });
const o2 = door({ doorType: "wandoeffnung" });
expect(fillGeometry(proj({}), wall, o2, cut(o2), host)).toMatchObject({ kind: null, parts: [] });
});
it("Scharnierseite und Aufschlag → LEFT/RIGHT (von der Aufschlagseite gesehen), Schiebetür", () => {
// Wand entlang +X, linke Normale +Y. Standard: Aufschlag nach +Y, Scharnier am Anfang (x klein):
// von +Y nach −Y gesehen liegt x klein rechts → RIGHT.
const kind = (o: Opening, t: DoorType = dtp()) => fillGeometry(proj({ doorTypes: [t] }), wall, o, cut(o), host).kind;
expect(kind(door({ typeId: "dt" }))).toBe("SINGLE_SWING_RIGHT");
expect(kind(door({ typeId: "dt", hinge: "end" }))).toBe("SINGLE_SWING_LEFT");
// Aufschlag nach aussen (−Y): Blickrichtung dreht → Seiten tauschen.
expect(kind(door({ typeId: "dt", openingDir: "out" }))).toBe("SINGLE_SWING_LEFT");
expect(kind(door({ typeId: "dt", swing: "right" }))).toBe("SINGLE_SWING_LEFT");
expect(kind(door({ typeId: "dt" }), dtp({ kind: "schiebe" }))).toBe("SLIDING_TO_RIGHT");
expect(kind(door({ typeId: "dt" }), dtp({ kind: "schiebe", leafCount: 2 }))).toBe("DOUBLE_DOOR_SLIDING");
});
it("Füllungssystem: Y = Aufschlagrichtung, Ursprung = Öffnungsmitte auf der Achse", () => {
const o = door({ typeId: "dt" });
const g = fillGeometry(proj({ doorTypes: [dtp()] }), wall, o, cut(o), host);
expect(g.origin).toEqual({ x: 1.5, y: 0 });
expect(g.u.x).toBeCloseTo(1, 12); // Aufschlag +Y → X = (swing.y, −swing.x) = (1, 0)
expect(g.u.y).toBeCloseTo(0, 12);
const out = fillGeometry(proj({ doorTypes: [dtp()] }), wall, door({ typeId: "dt", openingDir: "out" }), cut(o), host);
expect(out.u.x).toBeCloseTo(-1, 12);
it("Tür: Art, Blätter, Aufschlag, Scharnier, Oberlicht, Glas", () => {
const o = door({ typeId: "dt", hinge: "end", swing: "right", openingDir: "out" });
const t = dtp({ kind: "schiebe", leafCount: 2, transomHeight: 0.4, leafStyle: "glas", glazingRatio: 0.36 });
expect(fillParams(proj({ doorTypes: [t] }), wall, o, cut(o), host)).toMatchObject({
doorKind: 1,
leafCount: 2,
swingSign: -1,
dirSign: -1,
hingeAtStart: false,
transomHeight: 0.4,
glazed: true,
glazingRatio: 0.36,
});
const plain = fillParams(proj({}), wall, door(), cut(door()), host);
expect(plain).toMatchObject({ doorKind: 0, leafCount: 1, swingSign: 1, dirSign: 1, hingeAtStart: true, transomHeight: 0, glazed: false });
expect(fillParams(proj({}), wall, door({ doorType: "wandoeffnung" }), cut(door()), host).doorKind).toBe(2);
expect(fillParams(proj({ doorTypes: [dtp({ kind: "wandoeffnung" })] }), wall, door({ typeId: "dt" }), cut(door()), host).doorKind).toBe(2);
});
});
+69 -238
View File
@@ -1,260 +1,91 @@
// Geometrie der Türen und Fenster für den IFC-Export ([B5], 28.10.): statt einer Box getrennte Körper im
// selben Bauteil — Rahmen/Zarge, Türblatt bzw. Glas — plus OperationType (Tür) und PartitioningType
// (Fenster). Alles sind vertikale Extrusionen von Grundriss-Rechtecken (wie die Wände), Profile in
// Welt-XY, Höhen ab Öffnungs-Unterkante; Rust (`ifc_export.rs`) rechnet sie ins Füllungssystem.
//
// Masse kommen aus dem Modell, soweit es sie hergibt (Rahmenbreite/-tiefe, Schichteinzug, Flügelzahl und
// -tabelle, Verglasung, Blattzahl, Glasanteil, Oberlicht). Fehlendes füllen dieselben Konstanten wie das
// 3D (`src-tauri/core/src/openings3d.rs`), damit IFC und Ansicht dasselbe zeigen:
// - Rahmenbreite 6 cm (`DEFAULT_FRAME_WIDTH`), Rahmentiefe 7 cm (`DEFAULT_FRAME_DEPTH`: reale Rahmen
// sind 70–90 mm tief, nicht so dick wie die Wand), Türblatt 4 cm (`DOOR_LEAF_THICK`).
// - Glaspaket: nur im IFC nötig, das 3D zeichnet Einzelscheiben. 1 Scheibe 6 mm, 2 Scheiben 24 mm
// (4-16-4, übliches Isolierglas), 3 Scheiben 36 mm (4-12-4-12-4 ≈ 36 mm).
// Nicht abgebildet (bewusst einfach): Sprossen, Fensterbank/Rollladenkasten, Schwelle, Flügelrahmen im
// Blendrahmen, Kassettenfelder, Schiebe-Laufschiene — die Körper stehen im geschlossenen Zustand.
// Türen und Fenster im IFC-Export ([B5]): sammelt die Parameter einer Füllung aus dem Modell (Typ und
// Öffnung) für den Rust-Schreiber. Körper (Rahmen/Zarge, Türblatt, Glas), Füllungs-Placement und
// OperationType/PartitioningType rechnet `src-tauri/fileio/src/ifc_openings.rs` (Port der früheren
// TS-Rechnung, 28.10.; Kodierung FILL im Kopf von `ifc_export.rs`). Fehlende Typwerte bleiben `undefined`,
// die Standardmasse (Rahmen 6 × 7 cm, Blatt 4 cm, Glaspakete) kennt nur Rust.
import type { Opening, Project, SashDef, Vec2, Wall } from "../model/types";
import type { Opening, Project, Vec2, Wall } from "../model/types";
import { getDoorType, getWindowType, glazingPanesOf } from "../model/types";
/** Rolle eines Körpers: 0 Rahmen/Zarge, 1 Türblatt, 2 Glas (Kodierung `ifc_export.rs`). */
export type FillRole = 0 | 1 | 2;
export interface FillPart {
role: FillRole;
/** Profil in Welt-XY (Rechteck, gegen den Uhrzeigersinn in Achs-/Normalenrichtung). */
pts: Vec2[];
/** Unterkante ab Öffnungs-Unterkante (m). */
zRel: number;
/** Höhe des Körpers (m). */
depth: number;
/** Ein Eintrag der Flügeltabelle, wie im Modell (`SashDef`). */
export interface FillSash {
post: boolean;
postWidth?: number;
fixed: boolean;
width?: number;
}
export interface FillGeometry {
/** Ursprung des Füllungssystems (Welt-XY): Öffnungsmitte auf der Wandachse. */
origin: Vec2;
/** X-Richtung des Füllungssystems (Einheitsvektor); Y = linke Normale davon. */
u: Vec2;
/** IfcDoorTypeOperationEnum bzw. IfcWindowTypePartitioningEnum; null = Modell gibt nichts her. */
kind: string | null;
parts: FillPart[];
}
export const DEFAULT_FRAME_WIDTH = 0.06;
export const DEFAULT_FRAME_DEPTH = 0.07;
export const DOOR_LEAF_THICK = 0.04;
/** Glaspaket-Dicke je Scheibenzahl (1, 2, 3). */
export const GLASS_PACKAGE_THICKNESS = [0.006, 0.024, 0.036] as const;
/** Glasanteil des Türblatts, wenn der Typ keinen angibt (`glas` ohne `glazingRatio`). */
const DEFAULT_GLAZING_RATIO = 0.5;
/** Kleinste Teilabmessung, damit nie ein flaches Profil entsteht (Meter). */
const MIN_DIM = 0.005;
const sub = (a: Vec2, b: Vec2): Vec2 => ({ x: a.x - b.x, y: a.y - b.y });
const norm = (v: Vec2): Vec2 => {
const len = Math.hypot(v.x, v.y) || 1;
return { x: v.x / len, y: v.y / len };
};
const leftOf = (u: Vec2): Vec2 => ({ x: -u.y, y: u.x });
const dotv = (a: Vec2, b: Vec2): number => a.x * b.x + a.y * b.y;
/** Flügeleinteilung eines Fensters, auf die Achsbreite aufgelöst: (von, bis, Pfosten?) ab Laibungsanfang. */
interface SashSpan {
/** Parameter einer Füllung (Reihenfolge der Kodierung: `FlatIfc.opening` in `exportIfc.ts`). */
export interface FillParams {
wallStart: Vec2;
wallEnd: Vec2;
/** Achs-Intervall (Abstand ab `wall.start`) und absolute Höhen der Öffnung. */
from: number;
to: number;
post: boolean;
zBottom: number;
zTop: number;
/** Querausdehnung der ganzen Wand entlang der linken Normalen ab `wall.start` (`nLo` = Aussenseite). */
nLo: number;
nHi: number;
frameDepth?: number;
inset?: number;
insetOutside: boolean;
frameWidth?: number;
/** Fenster: Flügelzahl, Scheiben (1–3), Flügeltabelle. */
wingCount: number;
panes: number;
sashes: FillSash[];
/** Tür: 0 Dreh, 1 Schiebe, 2 reine Wandöffnung. */
doorKind: 0 | 1 | 2;
leafCount: number;
/** +1 Aufschlag links der Achse, −1 rechts; Richtung +1 innen, −1 aussen. */
swingSign: 1 | -1;
dirSign: 1 | -1;
hingeAtStart: boolean;
transomHeight: number;
glazed: boolean;
glazingRatio?: number;
}
/**
* Löst Flügel (`fluegel`) und Pfosten (`pfosten`) zu Intervallen auf: Pfosten und Flügel mit fester Breite
* behalten sie, die übrigen teilen den Rest gleichmässig (gleiche Regel wie `sashSegments` im 2D). Ohne
* Tabelle: `wingCount` gleiche Flügel.
* Parameter der Füllung einer Öffnung. `c` = Achs-Intervall und absolute Höhen der Öffnung, `host` =
* Querausdehnung der ganzen Wand (wie im 2D/3D).
*/
function sashSpans(sashes: readonly SashDef[] | undefined, wingCount: number, total: number): SashSpan[] {
const list: readonly SashDef[] =
sashes && sashes.length > 0
? sashes
: Array.from({ length: Math.max(1, Math.round(wingCount)) }, (): SashDef => ({ kind: "fluegel" }));
const postW = (s: SashDef): number => Math.max(0, s.postWidth ?? 0.06);
const fixedW = (s: SashDef): number | null => (s.kind === "pfosten" ? postW(s) : s.autoWidth === false ? Math.max(0, s.width ?? 0) : null);
let fixed = 0;
let auto = 0;
for (const s of list) {
const w = fixedW(s);
if (w === null) auto++;
else fixed += w;
}
const autoW = auto > 0 ? Math.max(0, total - fixed) / auto : 0;
const out: SashSpan[] = [];
let at = 0;
for (const s of list) {
const w = fixedW(s) ?? autoW;
out.push({ from: at, to: at + w, post: s.kind === "pfosten" });
at += w;
}
return out;
}
/**
* Körper und Ausführung der Füllung einer Öffnung.
*
* `c` = Achs-Intervall (`from`/`to`, Abstand ab `wall.start`) und absolute Höhen der Öffnung, `host` =
* Querausdehnung der ganzen Wand (`nLo`/`nHi` entlang der linken Normalen ab `wall.start`; `nLo` ist die
* Aussenseite, wie im 2D/3D).
*/
export function fillGeometry(
export function fillParams(
project: Project,
wall: Wall,
opening: Opening,
c: { from: number; to: number; zBottom: number; zTop: number },
host: { nLo: number; nHi: number },
): FillGeometry {
const u = norm(sub(wall.end, wall.start));
const n = leftOf(u);
): FillParams {
const isDoor = opening.kind === "door";
const W = c.to - c.from;
const H = c.zTop - c.zBottom;
const at = (a: number, b: number): Vec2 => ({
x: wall.start.x + u.x * a + n.x * b,
y: wall.start.y + u.y * a + n.y * b,
});
/** Rechteck [a0,a1] entlang der Achse × [b0,b1] quer dazu (Welt-XY). */
const rect = (a0: number, a1: number, b0: number, b1: number): Vec2[] => [at(a0, b0), at(a1, b0), at(a1, b1), at(a0, b1)];
const center = c.from + W / 2;
const origin = at(center, 0);
const parts: FillPart[] = [];
const add = (role: FillRole, a0: number, a1: number, b0: number, b1: number, z0: number, z1: number): void => {
if (a1 - a0 < 1e-6 || b1 - b0 < 1e-6 || z1 - z0 < 1e-6) return;
parts.push({ role, pts: rect(a0, a1, b0, b1), zRel: z0, depth: z1 - z0 });
};
const dt = isDoor ? getDoorType(project, opening) : undefined;
const wt = isDoor ? undefined : getWindowType(project, opening);
const t = dt ?? wt;
// Querlage des Rahmens: Tiefe (Typ oder 7 cm), Schichteinzug von der gewählten Wandfläche, auf die
// Wanddicke geklemmt — dieselbe Rechnung wie `windowSymbol` (2D) und `resolveFrameNormalRange` (3D).
const total = host.nHi - host.nLo;
const frameDepth = Math.min(total, t?.frameDepth && t.frameDepth > 1e-9 ? t.frameDepth : DEFAULT_FRAME_DEPTH);
const inset = Math.max(0, t?.insetFromFace ?? 0);
const outside = (t?.insetFace ?? "aussen") === "aussen";
const front = outside ? host.nLo + inset : host.nHi - inset;
const back = outside ? front + frameDepth : front - frameDepth;
let b0 = Math.max(host.nLo, Math.min(host.nHi, Math.min(front, back)));
let b1 = Math.max(host.nLo, Math.min(host.nHi, Math.max(front, back)));
if (b1 - b0 < MIN_DIM) {
b0 = host.nLo;
b1 = host.nHi;
}
const bMid = (b0 + b1) / 2;
// Sichtbare Rahmenbreite: höchstens ein Viertel der kleineren Öffnungsabmessung, sonst bliebe nichts offen.
const fw = Math.max(MIN_DIM, Math.min(t?.frameWidth && t.frameWidth > 1e-9 ? t.frameWidth : DEFAULT_FRAME_WIDTH, Math.min(W, H) / 4));
const aIn0 = c.from + fw;
const aIn1 = c.to - fw;
if (!isDoor) {
// ── Fenster: Blendrahmen (Pfosten links/rechts, Sturz, Sohlbank), Mittelpfosten, Glas je Flügel ──
const wing = opening.wingCount ?? wt?.wingCount ?? 1;
add(0, c.from, aIn0, b0, b1, 0, H);
add(0, aIn1, c.to, b0, b1, 0, H);
add(0, aIn0, aIn1, b0, b1, H - fw, H);
add(0, aIn0, aIn1, b0, b1, 0, fw);
const panes = wt ? glazingPanesOf(wt) : 2;
const gt = Math.min(GLASS_PACKAGE_THICKNESS[panes - 1], b1 - b0);
const g0 = bMid - gt / 2;
const g1 = bMid + gt / 2;
const spans = sashSpans(wt?.sashes, wing, aIn1 - aIn0);
let glassCount = 0;
spans.forEach((s, i) => {
const x0 = aIn0 + s.from;
const x1 = aIn0 + s.to;
if (s.post) {
add(0, x0, x1, b0, b1, fw, H - fw);
return;
}
// Zwischen zwei Flügeln ohne Pfosten steht ein Mittelpfosten (Breite = Rahmenbreite) auf der Grenze.
const prev = spans[i - 1];
const next = spans[i + 1];
const gx0 = i === 0 || prev.post ? x0 : x0 + fw / 2;
const gx1 = i === spans.length - 1 || next.post ? x1 : x1 - fw / 2;
if (next && !next.post) add(0, x1 - fw / 2, x1 + fw / 2, b0, b1, fw, H - fw);
add(2, gx0, gx1, g0, g1, fw, H - fw);
glassCount++;
});
// Teilung nach IFC: nur die senkrechten Standardfälle sind benannt (sonst NOTDEFINED, das Modell
// kennt Sprossen und Seitenverhältnisse, die IFC nicht als Enum führt).
const kind = glassCount === 1 ? "SINGLE_PANEL" : glassCount === 2 ? "DOUBLE_PANEL_VERTICAL" : glassCount === 3 ? "TRIPLE_PANEL_VERTICAL" : "NOTDEFINED";
return { origin, u, kind, parts };
}
// ── Tür ──
const kind = dt?.kind ?? (opening.doorType === "wandoeffnung" ? "wandoeffnung" : "dreh");
const leafCount = dt?.leafCount ?? 1;
// Aufschlagrichtung wie `doorSymbol`: linke Achsnormale, `openingDir: "out"` spiegelt sie.
const swingSign = (opening.swing ?? "left") === "left" ? 1 : -1;
const dirSign = (opening.openingDir ?? "in") === "in" ? 1 : -1;
const swingDir: Vec2 = { x: n.x * swingSign * dirSign, y: n.y * swingSign * dirSign };
// Füllungssystem der Tür: Y = Aufschlagrichtung (IFC: die Tür schlägt nach +Y auf), X = Y × Z.
const doorU: Vec2 = { x: swingDir.y, y: -swingDir.x };
if (kind === "wandoeffnung") return { origin, u: doorU, kind: null, parts: [] };
// Zarge: Pfosten links/rechts über die ganze Höhe und Sturz (keine Schwelle).
add(0, c.from, aIn0, b0, b1, 0, H);
add(0, aIn1, c.to, b0, b1, 0, H);
add(0, aIn0, aIn1, b0, b1, H - fw, H);
// Oberlicht: fester Glasstreifen über einem Kämpfer (Riegel in Rahmenbreite) innerhalb der Öffnungshöhe.
const th = dt?.transomHeight ?? 0;
const hasTransom = th > MIN_DIM && th < H - fw - 0.5;
const leafTop = hasTransom ? H - fw - th - fw : H - fw;
if (hasTransom) {
add(0, aIn0, aIn1, b0, b1, leafTop, leafTop + fw);
const gt = Math.min(GLASS_PACKAGE_THICKNESS[1], b1 - b0);
add(2, aIn0, aIn1, bMid - gt / 2, bMid + gt / 2, leafTop + fw, H - fw);
}
// Türblatt/-blätter im lichten Mass der Zarge, mittig in der Rahmentiefe.
const lt = Math.min(DOOR_LEAF_THICK, b1 - b0);
const l0 = bMid - lt / 2;
const l1 = bMid + lt / 2;
const leafSpans: [number, number][] =
leafCount >= 2
? [
[aIn0, (aIn0 + aIn1) / 2],
[(aIn0 + aIn1) / 2, aIn1],
]
: [[aIn0, aIn1]];
const glazed = dt?.leafStyle === "glas";
const ratio = Math.min(0.9, Math.max(0.05, dt?.glazingRatio ?? DEFAULT_GLAZING_RATIO));
for (const [x0, x1] of leafSpans) {
if (!glazed) {
add(1, x0, x1, l0, l1, 0, leafTop);
continue;
}
// Glastür: Glasfläche = `glazingRatio` des Blatts (gleichmässig verkleinert um die Blattmitte), das
// Blatt als umlaufender Rahmen darum; das Glas füllt die Blattdicke zu 60 % (4–24 mm, mittig).
const s = Math.sqrt(ratio);
const cx = (x0 + x1) / 2;
const cz = leafTop / 2;
const gw = (x1 - x0) * s;
const gh = leafTop * s;
const [px0, px1, pz0, pz1] = [cx - gw / 2, cx + gw / 2, cz - gh / 2, cz + gh / 2];
add(1, x0, x1, l0, l1, 0, pz0);
add(1, x0, x1, l0, l1, pz1, leafTop);
add(1, x0, px0, l0, l1, pz0, pz1);
add(1, px1, x1, l0, l1, pz0, pz1);
const gt = Math.min(GLASS_PACKAGE_THICKNESS[1], lt * 0.6);
add(2, px0, px1, bMid - gt / 2, bMid + gt / 2, pz0, pz1);
}
// OperationType: Blattzahl und Scharnierseite. IFC blickt von der Aufschlagseite (+Y des Füllungssystems)
// auf die Tür; "links" = Scharnier auf der +X-Seite des Systems (X = Y × Z, von +Y aus gesehen links).
const hingeAtStart = (opening.hinge ?? "start") === "start";
const hingeAxis = hingeAtStart ? c.from : c.to;
const hingeLocalX = dotv(sub(at(hingeAxis, 0), origin), doorU);
const left = hingeLocalX > 0;
let op: string;
if (kind === "schiebe") op = leafCount >= 2 ? "DOUBLE_DOOR_SLIDING" : left ? "SLIDING_TO_LEFT" : "SLIDING_TO_RIGHT";
else op = leafCount >= 2 ? "DOUBLE_DOOR_SINGLE_SWING" : left ? "SINGLE_SWING_LEFT" : "SINGLE_SWING_RIGHT";
return { origin, u: doorU, kind: op, parts };
return {
wallStart: wall.start,
wallEnd: wall.end,
from: c.from,
to: c.to,
zBottom: c.zBottom,
zTop: c.zTop,
nLo: host.nLo,
nHi: host.nHi,
frameDepth: t?.frameDepth,
inset: t?.insetFromFace,
insetOutside: (t?.insetFace ?? "aussen") === "aussen",
frameWidth: t?.frameWidth,
wingCount: opening.wingCount ?? wt?.wingCount ?? 1,
panes: wt ? glazingPanesOf(wt) : 2,
sashes: (wt?.sashes ?? []).map((s) => ({ post: s.kind === "pfosten", postWidth: s.postWidth, fixed: s.autoWidth === false, width: s.width })),
doorKind: kind === "schiebe" ? 1 : kind === "wandoeffnung" ? 2 : 0,
leafCount: dt?.leafCount ?? 1,
swingSign: (opening.swing ?? "left") === "left" ? 1 : -1,
dirSign: (opening.openingDir ?? "in") === "in" ? 1 : -1,
hingeAtStart: (opening.hinge ?? "start") === "start",
transomHeight: dt?.transomHeight ?? 0,
glazed: dt?.leafStyle === "glas",
glazingRatio: dt?.glazingRatio,
};
}
+36
View File
@@ -79,6 +79,42 @@ describe("IFC-Import als Bauteile: Rundreise Demo-Haus", () => {
expect(text).toContain('"walls":9');
});
it("Tür-Anschlag/Aufschlag und Fensterteilung aus OperationType/PartitioningType (Rundreise)", async () => {
// Lage im Raum vergleichen (die Wand kann umgekehrt ankommen): Scharnierpunkt und Aufschlagrichtung.
const physical = (o: Opening, w: Wall) => {
const l = Math.hypot(w.end.x - w.start.x, w.end.y - w.start.y);
const u = { x: (w.end.x - w.start.x) / l, y: (w.end.y - w.start.y) / l };
const along = (o.hinge ?? "start") === "start" ? o.position : o.position + o.width;
const s = ((o.swing ?? "left") === "left" ? 1 : -1) * ((o.openingDir ?? "in") === "in" ? 1 : -1);
return { hinge: { x: w.start.x + u.x * along, y: w.start.y + u.y * along }, swing: { x: -u.y * s, y: u.x * s } };
};
for (const hinge of ["start", "end"] as const)
for (const swing of ["left", "right"] as const)
for (const openingDir of ["in", "out"] as const) {
const src: Project = {
...sampleProject,
openings: (sampleProject.openings ?? []).map((o) =>
o.id === "D1" ? { ...o, hinge, swing, openingDir } : o.id === "O2" ? { ...o, wingCount: 2 } : o,
),
};
const { project: p } = await importInto(emptyProject, src);
const d1 = src.openings!.find((o) => o.id === "D1")!;
const w1 = src.walls.find((w) => w.id === d1.hostWallId)!;
const got = (p.openings ?? []).find((o) => o.kind === "door")!;
const gw = p.walls.find((w) => w.id === got.hostWallId)!;
const want = physical(d1, w1);
const have = physical(got, gw);
const tag = `${hinge}/${swing}/${openingDir}`;
expect(near(have.hinge, want.hinge), tag).toBe(true);
expect(near(have.swing, want.swing), tag).toBe(true);
expect(got.typeId, tag).toBe("door-standard");
// Fenster O2 mit zwei Flügeln: Typ mit zwei Flügeln (oder eigene Flügelzahl).
const o2 = (p.openings ?? []).find((o) => o.kind === "window" && Math.abs(o.width - 1.4) < 1e-6)!;
const wt = (p.windowTypes ?? []).find((t) => t.id === o2.typeId);
expect(o2.wingCount ?? wt?.wingCount, tag).toBe(2);
}
});
it("in ein Projekt ohne Geschosse/Typen: legt Geschosse, Wand-/Deckentypen und Materialien an", async () => {
const bare: Project = {
...emptyProject,
+42 -3
View File
@@ -77,6 +77,12 @@ export interface IfcOpeningData extends IfcInfo {
width: number;
sill: number;
height: number;
/** Ausführung: IfcDoorTypeOperationEnum bzw. IfcWindowTypePartitioningEnum (Bauteil, sonst Typ). */
operation: string | null;
/** Tür: Aufschlag links (+1) / rechts (−1) der Wandachse, 0 = unbekannt (Rust `ifc_semantic`). */
swing: number;
/** Tür: Scharnier am Wandanfang (+1) / -ende (−1), 0 = unbekannt. */
hinge: number;
}
export interface IfcSlabData extends IfcInfo {
outline: Vec2[];
@@ -117,6 +123,7 @@ interface RawElement extends IfcInfo {
n: number;
host?: number;
openingKind?: "door" | "window" | "hole";
operation?: string | null;
profile?: "rect" | "round";
longName?: string | null;
sia?: string | null;
@@ -170,8 +177,19 @@ export function decodeIfcElements(flat: IfcFlat): IfcElementsData | null {
break;
case "opening": {
const host = wallIndex.get(e.host ?? -1);
if (host !== undefined && v.length === 4) {
out.openings.push({ ...info, host, kind: e.openingKind ?? "hole", position: v[0], width: v[1], sill: v[2], height: v[3] });
if (host !== undefined && v.length === 6) {
out.openings.push({
...info,
host,
kind: e.openingKind ?? "hole",
position: v[0],
width: v[1],
sill: v[2],
height: v[3],
operation: e.operation ?? null,
swing: Math.sign(v[4]),
hinge: Math.sign(v[5]),
});
}
break;
}
@@ -422,7 +440,26 @@ export function ifcElementsToProject(
const host = walls[o.host];
if (!host) continue;
const kind = o.kind === "window" ? "window" : "door";
const typeId = o.kind === "door" ? project.doorTypes?.[0]?.id : o.kind === "window" ? project.windowTypes?.[0]?.id : undefined;
const op = o.operation ?? "";
// Tür: Typ nach Art (Dreh/Schiebe) und Blattzahl aus der Ausführung, sonst der erste Typ.
const sliding = op.includes("SLIDING");
const leaves = op.startsWith("DOUBLE_DOOR") ? 2 : 1;
const doorType =
(op ? project.doorTypes?.find((t) => t.kind === (sliding ? "schiebe" : "dreh") && t.leafCount === leaves) : undefined) ??
project.doorTypes?.[0];
// Fenster: Flügelzahl aus der Teilung (nur senkrechte Standardfälle); Typ mit dieser Flügelzahl, sonst
// der erste Typ mit eigener Flügelzahl an der Öffnung.
const wings = ({ SINGLE_PANEL: 1, DOUBLE_PANEL_VERTICAL: 2, TRIPLE_PANEL_VERTICAL: 3 } as Record<string, number>)[op];
const windowType = (wings ? project.windowTypes?.find((t) => t.wingCount === wings) : undefined) ?? project.windowTypes?.[0];
const typeId = o.kind === "door" ? doorType?.id : o.kind === "window" ? windowType?.id : undefined;
const doorExtra =
o.kind === "door"
? {
...(o.hinge !== 0 ? { hinge: o.hinge > 0 ? ("start" as const) : ("end" as const) } : {}),
...(o.swing !== 0 ? { swing: o.swing > 0 ? ("left" as const) : ("right" as const) } : {}),
}
: {};
const windowExtra = o.kind === "window" && wings && (windowType?.wingCount ?? 1) !== wings ? { wingCount: wings } : {};
openings.push({
id: newId("opening"),
type: "opening",
@@ -435,6 +472,8 @@ export function ifcElementsToProject(
sillHeight: round(o.sill, 1e-6),
...(o.kind === "hole" ? { doorType: "wandoeffnung" as const } : {}),
...(typeId ? { typeId } : {}),
...doorExtra,
...windowExtra,
});
}
+29
View File
@@ -158,6 +158,9 @@ describe("IFC-Import: Rundreise mit dem eigenen Export", () => {
// UNION/INTERSECTION/DIFFERENCE, Rotation 90°/360°, Rohr (hohl, dünn), Sweep mit fester Referenz und
// auf Ebene, Bogen-Leitkurve. Sollwerte von Hand; ifcopenshell bestätigt sie unten.
const casesFile = new URL("./testdata/ifc-geometry-cases.ifc", import.meta.url);
// Freiform-Fälle ([25], `testdata/ifc-freeform-cases.ifc`, von Hand erzeugt): IfcAdvancedBrep mit Zylinder,
// Kugel, bilinearen und rationalen B-Spline-Flächen, B-Spline-Profil, Rohre mit StartParam/EndParam.
const freeformFile = new URL("./testdata/ifc-freeform-cases.ifc", import.meta.url);
describe("IFC-Import: Öffnungen, Boolesche Körper, Rotation, Sweeps", () => {
it("alle Fälle gelesen, Volumen von Hand", async () => {
@@ -193,6 +196,24 @@ describe("IFC-Import: Öffnungen, Boolesche Körper, Rotation, Sweeps", () => {
});
});
it("Freiform-Fälle: alle gelesen, Volumen von Hand", async () => {
const { products, report } = await readIfc(new Uint8Array(readFileSync(freeformFile)));
expect(report.skippedItems).toEqual({});
const pi = Math.PI;
const want: Array<[string, number]> = [
["IfcColumn", pi * 0.25 * 2],
["IfcBuildingElementProxy", (2 / 3) * pi],
["IfcColumn", pi * 0.25],
["IfcBuildingElementProxy", 2 / 3],
["IfcColumn", pi * 0.25],
["IfcPipeSegment", pi * 0.01 * 3.5],
["IfcPipeSegment", pi * 0.01 * pi],
["IfcPipeSegment", pi * 0.01 * 2 * pi],
];
expect(products.map((p) => p.ifcClass)).toEqual(want.map((w) => w[0]));
want.forEach(([, w], i) => expect(relClose(vol(products[i]), w, 0.02), `${i}: ${vol(products[i])} ≠ ${w}`).toBe(true));
});
describe("Laden im Web-Worker", () => {
afterEach(() => vi.unstubAllGlobals());
@@ -312,6 +333,14 @@ describe.skipIf(!hasIfcOpenShell)("IFC-Import gegen ifcopenshell", { timeout: 12
expect(problems).toEqual([]);
});
it("Freiform-Fälle: Advanced Brep (Zylinder, B-Spline-Flächen), B-Spline-Profil und -Leitkurve", async () => {
// ifcopenshell 0.9 liefert die nahtlose Halbkugel nicht (Volumen 0) und übergeht StartParam/EndParam
// der Rohre (IfcOpenShell zieht absichtlich die ganze Leitkurve); diese prüft der Rust-Test von Hand.
const handOnly = ["2dome", "6pipeparams", "7pipearc"];
const problems = await compare(freeformFile.pathname, () => 0.03);
expect(problems.filter((p) => !handOnly.some((h) => p.includes(h)))).toEqual([]);
});
// Freie Beispieldateien (z. B. github.com/buildingSMART/Sample-Test-Files, nicht im Repo, Lizenz
// ungeklärt): DOSSIER_IFC_SAMPLES=<Verzeichnis> setzen.
const samples = process.env.DOSSIER_IFC_SAMPLES;
+332
View File
@@ -0,0 +1,332 @@
ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('ViewDefinition [DesignTransferView]'),'2;1');
FILE_NAME('freeform.ifc','2026-10-28T00:00:00',(''),(''),'','','');
FILE_SCHEMA(('IFC4'));
ENDSEC;
DATA;
#1=IFCPROJECT('0proj000000000000000a2',$,'P',$,$,$,$,(#8),#2);
#2=IFCUNITASSIGNMENT((#3,#4));
#3=IFCSIUNIT(*,.LENGTHUNIT.,$,.METRE.);
#4=IFCSIUNIT(*,.PLANEANGLEUNIT.,$,.RADIAN.);
#8=IFCGEOMETRICREPRESENTATIONCONTEXT($,'Model',3,1.E-05,#13,$);
#9=IFCGEOMETRICREPRESENTATIONSUBCONTEXT('Body','Model',*,*,*,*,#8,$,.MODEL_VIEW.,$);
#10=IFCCARTESIANPOINT((0.,0.,0.));#11=IFCDIRECTION((0.,0.,1.));#12=IFCDIRECTION((1.,0.,0.));
#13=IFCAXIS2PLACEMENT3D(#10,$,$);#14=IFCLOCALPLACEMENT($,#13);
#20=IFCBUILDING('0bldg00000000000000002',$,'B',$,$,#14,$,$,.ELEMENT.,$,$,$);
#24=IFCBUILDINGSTOREY('0eg0000000000000000002',$,'EG',$,$,#14,$,$,.ELEMENT.,0.);
#25=IFCRELAGGREGATES('0agg000000000000000003',$,$,$,#20,(#24));
#26=IFCRELAGGREGATES('0agg000000000000000004',$,$,$,#1,(#20));
#1001=IFCCARTESIANPOINT((0.5,0.0,0.0));
#1002=IFCVERTEXPOINT(#1001);
#1003=IFCCARTESIANPOINT((0.5,0.0,2.0));
#1004=IFCVERTEXPOINT(#1003);
#1005=IFCCARTESIANPOINT((0.0,0.0,0.0));
#1006=IFCAXIS2PLACEMENT3D(#1005,$,$);
#1007=IFCCIRCLE(#1006,0.5);
#1008=IFCCARTESIANPOINT((0.0,0.0,2.0));
#1009=IFCAXIS2PLACEMENT3D(#1008,$,$);
#1010=IFCCIRCLE(#1009,0.5);
#1011=IFCEDGECURVE(#1002,#1002,#1007,.T.);
#1012=IFCEDGECURVE(#1004,#1004,#1010,.T.);
#1013=IFCCARTESIANPOINT((0.0,0.0,0.0));
#1014=IFCAXIS2PLACEMENT3D(#1013,$,$);
#1015=IFCCYLINDRICALSURFACE(#1014,0.5);
#1016=IFCORIENTEDEDGE(*,*,#1011,.T.);
#1017=IFCEDGELOOP((#1016));
#1018=IFCFACEOUTERBOUND(#1017,.T.);
#1019=IFCORIENTEDEDGE(*,*,#1012,.F.);
#1020=IFCEDGELOOP((#1019));
#1021=IFCFACEBOUND(#1020,.T.);
#1022=IFCADVANCEDFACE((#1018,#1021),#1015,.T.);
#1023=IFCORIENTEDEDGE(*,*,#1011,.F.);
#1024=IFCEDGELOOP((#1023));
#1025=IFCFACEOUTERBOUND(#1024,.T.);
#1026=IFCCARTESIANPOINT((0.0,0.0,0.0));
#1027=IFCDIRECTION((0.0,0.0,-1.0));
#1028=IFCAXIS2PLACEMENT3D(#1026,#1027,$);
#1029=IFCPLANE(#1028);
#1030=IFCADVANCEDFACE((#1025),#1029,.T.);
#1031=IFCORIENTEDEDGE(*,*,#1012,.T.);
#1032=IFCEDGELOOP((#1031));
#1033=IFCFACEOUTERBOUND(#1032,.T.);
#1034=IFCCARTESIANPOINT((0.0,0.0,2.0));
#1035=IFCAXIS2PLACEMENT3D(#1034,$,$);
#1036=IFCPLANE(#1035);
#1037=IFCADVANCEDFACE((#1033),#1036,.T.);
#1038=IFCCLOSEDSHELL((#1022,#1030,#1037));
#1039=IFCADVANCEDBREP(#1038);
#1040=IFCCARTESIANPOINT((0.0,0.0,0.0));
#1041=IFCAXIS2PLACEMENT3D(#1040,$,$);
#1042=IFCLOCALPLACEMENT(#14,#1041);
#1043=IFCSHAPEREPRESENTATION(#9,'Body','AdvancedBrep',(#1039));
#1044=IFCPRODUCTDEFINITIONSHAPE($,$,(#1043));
#1045=IFCCOLUMN('1cylxxxxxxxxxxxxxxxxxx',$,'T',$,$,#1042,#1044,$,$);
#1046=IFCCARTESIANPOINT((1.0,0.0,0.0));
#1047=IFCVERTEXPOINT(#1046);
#1048=IFCCARTESIANPOINT((0.0,0.0,0.0));
#1049=IFCAXIS2PLACEMENT3D(#1048,$,$);
#1050=IFCCIRCLE(#1049,1.);
#1051=IFCEDGECURVE(#1047,#1047,#1050,.T.);
#1052=IFCCARTESIANPOINT((0.0,0.0,0.0));
#1053=IFCAXIS2PLACEMENT3D(#1052,$,$);
#1054=IFCSPHERICALSURFACE(#1053,1.);
#1055=IFCORIENTEDEDGE(*,*,#1051,.T.);
#1056=IFCEDGELOOP((#1055));
#1057=IFCFACEOUTERBOUND(#1056,.T.);
#1058=IFCADVANCEDFACE((#1057),#1054,.T.);
#1059=IFCORIENTEDEDGE(*,*,#1051,.F.);
#1060=IFCEDGELOOP((#1059));
#1061=IFCFACEOUTERBOUND(#1060,.T.);
#1062=IFCCARTESIANPOINT((0.0,0.0,0.0));
#1063=IFCDIRECTION((0.0,0.0,-1.0));
#1064=IFCAXIS2PLACEMENT3D(#1062,#1063,$);
#1065=IFCPLANE(#1064);
#1066=IFCADVANCEDFACE((#1061),#1065,.T.);
#1067=IFCCLOSEDSHELL((#1058,#1066));
#1068=IFCADVANCEDBREP(#1067);
#1069=IFCCARTESIANPOINT((10.0,0.0,0.0));
#1070=IFCAXIS2PLACEMENT3D(#1069,$,$);
#1071=IFCLOCALPLACEMENT(#14,#1070);
#1072=IFCSHAPEREPRESENTATION(#9,'Body','AdvancedBrep',(#1068));
#1073=IFCPRODUCTDEFINITIONSHAPE($,$,(#1072));
#1074=IFCBUILDINGELEMENTPROXY('2domexxxxxxxxxxxxxxxxx',$,'T',$,$,#1071,#1073,$,$);
#1075=IFCCARTESIANPOINT((0.5,0.0));
#1076=IFCCARTESIANPOINT((0.5,0.5));
#1077=IFCCARTESIANPOINT((0.0,0.5));
#1078=IFCCARTESIANPOINT((-0.5,0.5));
#1079=IFCCARTESIANPOINT((-0.5,0.0));
#1080=IFCCARTESIANPOINT((-0.5,-0.5));
#1081=IFCCARTESIANPOINT((0.0,-0.5));
#1082=IFCCARTESIANPOINT((0.5,-0.5));
#1083=IFCCARTESIANPOINT((0.5,0.0));
#1084=IFCRATIONALBSPLINECURVEWITHKNOTS(2,(#1075,#1076,#1077,#1078,#1079,#1080,#1081,#1082,#1083),.CIRCULAR_ARC.,.T.,.F.,(3,2,2,2,3),(0.,0.25,0.5,0.75,1.),.UNSPECIFIED.,(1.0,0.7071067811865476,1.0,0.7071067811865476,1.0,0.7071067811865476,1.0,0.7071067811865476,1.0));
#1085=IFCARBITRARYCLOSEDPROFILEDEF(.AREA.,$,#1084);
#1086=IFCEXTRUDEDAREASOLID(#1085,#13,#11,1.);
#1087=IFCCARTESIANPOINT((20.0,0.0,0.0));
#1088=IFCAXIS2PLACEMENT3D(#1087,$,$);
#1089=IFCLOCALPLACEMENT(#14,#1088);
#1090=IFCSHAPEREPRESENTATION(#9,'Body','AdvancedBrep',(#1086));
#1091=IFCPRODUCTDEFINITIONSHAPE($,$,(#1090));
#1092=IFCCOLUMN('3bspprofilexxxxxxxxxxx',$,'T',$,$,#1089,#1091,$,$);
#1093=IFCCARTESIANPOINT((-0.5,-0.5,0.0));
#1094=IFCCARTESIANPOINT((0.5,-0.5,0.0));
#1095=IFCCARTESIANPOINT((0.5,0.5,0.0));
#1096=IFCCARTESIANPOINT((-0.5,0.5,0.0));
#1097=IFCCARTESIANPOINT((0.5,-0.5,1.0));
#1098=IFCCARTESIANPOINT((0.5,0.5,1.0));
#1099=IFCCARTESIANPOINT((-0.5,0.5,1.0));
#1100=IFCCARTESIANPOINT((-0.5,-0.5,1.0));
#1101=IFCVERTEXPOINT(#1093);
#1102=IFCVERTEXPOINT(#1094);
#1103=IFCVERTEXPOINT(#1095);
#1104=IFCVERTEXPOINT(#1096);
#1105=IFCVERTEXPOINT(#1097);
#1106=IFCVERTEXPOINT(#1098);
#1107=IFCVERTEXPOINT(#1099);
#1108=IFCVERTEXPOINT(#1100);
#1109=IFCPOLYLINE((#1093,#1094));
#1110=IFCEDGECURVE(#1101,#1102,#1109,.T.);
#1111=IFCPOLYLINE((#1094,#1095));
#1112=IFCEDGECURVE(#1102,#1103,#1111,.T.);
#1113=IFCPOLYLINE((#1095,#1096));
#1114=IFCEDGECURVE(#1103,#1104,#1113,.T.);
#1115=IFCPOLYLINE((#1096,#1093));
#1116=IFCEDGECURVE(#1104,#1101,#1115,.T.);
#1117=IFCPOLYLINE((#1097,#1098));
#1118=IFCEDGECURVE(#1105,#1106,#1117,.T.);
#1119=IFCPOLYLINE((#1098,#1099));
#1120=IFCEDGECURVE(#1106,#1107,#1119,.T.);
#1121=IFCPOLYLINE((#1099,#1100));
#1122=IFCEDGECURVE(#1107,#1108,#1121,.T.);
#1123=IFCPOLYLINE((#1100,#1097));
#1124=IFCEDGECURVE(#1108,#1105,#1123,.T.);
#1125=IFCPOLYLINE((#1093,#1097));
#1126=IFCEDGECURVE(#1101,#1105,#1125,.T.);
#1127=IFCPOLYLINE((#1094,#1098));
#1128=IFCEDGECURVE(#1102,#1106,#1127,.T.);
#1129=IFCPOLYLINE((#1095,#1099));
#1130=IFCEDGECURVE(#1103,#1107,#1129,.T.);
#1131=IFCPOLYLINE((#1096,#1100));
#1132=IFCEDGECURVE(#1104,#1108,#1131,.T.);
#1133=IFCBSPLINESURFACEWITHKNOTS(1,1,((#1093,#1097),(#1094,#1098)),.UNSPECIFIED.,.F.,.F.,.F.,(2,2),(2,2),(0.,1.),(0.,1.),.UNSPECIFIED.);
#1134=IFCORIENTEDEDGE(*,*,#1110,.T.);
#1135=IFCORIENTEDEDGE(*,*,#1128,.T.);
#1136=IFCORIENTEDEDGE(*,*,#1118,.F.);
#1137=IFCORIENTEDEDGE(*,*,#1126,.F.);
#1138=IFCEDGELOOP((#1134,#1135,#1136,#1137));
#1139=IFCFACEOUTERBOUND(#1138,.T.);
#1140=IFCADVANCEDFACE((#1139),#1133,.T.);
#1141=IFCBSPLINESURFACEWITHKNOTS(1,1,((#1094,#1098),(#1095,#1099)),.UNSPECIFIED.,.F.,.F.,.F.,(2,2),(2,2),(0.,1.),(0.,1.),.UNSPECIFIED.);
#1142=IFCORIENTEDEDGE(*,*,#1112,.T.);
#1143=IFCORIENTEDEDGE(*,*,#1130,.T.);
#1144=IFCORIENTEDEDGE(*,*,#1120,.F.);
#1145=IFCORIENTEDEDGE(*,*,#1128,.F.);
#1146=IFCEDGELOOP((#1142,#1143,#1144,#1145));
#1147=IFCFACEOUTERBOUND(#1146,.T.);
#1148=IFCADVANCEDFACE((#1147),#1141,.T.);
#1149=IFCBSPLINESURFACEWITHKNOTS(1,1,((#1095,#1099),(#1096,#1100)),.UNSPECIFIED.,.F.,.F.,.F.,(2,2),(2,2),(0.,1.),(0.,1.),.UNSPECIFIED.);
#1150=IFCORIENTEDEDGE(*,*,#1114,.T.);
#1151=IFCORIENTEDEDGE(*,*,#1132,.T.);
#1152=IFCORIENTEDEDGE(*,*,#1122,.F.);
#1153=IFCORIENTEDEDGE(*,*,#1130,.F.);
#1154=IFCEDGELOOP((#1150,#1151,#1152,#1153));
#1155=IFCFACEOUTERBOUND(#1154,.T.);
#1156=IFCADVANCEDFACE((#1155),#1149,.T.);
#1157=IFCBSPLINESURFACEWITHKNOTS(1,1,((#1096,#1100),(#1093,#1097)),.UNSPECIFIED.,.F.,.F.,.F.,(2,2),(2,2),(0.,1.),(0.,1.),.UNSPECIFIED.);
#1158=IFCORIENTEDEDGE(*,*,#1116,.T.);
#1159=IFCORIENTEDEDGE(*,*,#1126,.T.);
#1160=IFCORIENTEDEDGE(*,*,#1124,.F.);
#1161=IFCORIENTEDEDGE(*,*,#1132,.F.);
#1162=IFCEDGELOOP((#1158,#1159,#1160,#1161));
#1163=IFCFACEOUTERBOUND(#1162,.T.);
#1164=IFCADVANCEDFACE((#1163),#1157,.T.);
#1165=IFCORIENTEDEDGE(*,*,#1116,.F.);
#1166=IFCORIENTEDEDGE(*,*,#1114,.F.);
#1167=IFCORIENTEDEDGE(*,*,#1112,.F.);
#1168=IFCORIENTEDEDGE(*,*,#1110,.F.);
#1169=IFCCARTESIANPOINT((0.0,0.0,0.0));
#1170=IFCDIRECTION((0.0,0.0,-1.0));
#1171=IFCAXIS2PLACEMENT3D(#1169,#1170,$);
#1172=IFCPLANE(#1171);
#1173=IFCEDGELOOP((#1165,#1166,#1167,#1168));
#1174=IFCFACEOUTERBOUND(#1173,.T.);
#1175=IFCADVANCEDFACE((#1174),#1172,.T.);
#1176=IFCORIENTEDEDGE(*,*,#1118,.T.);
#1177=IFCORIENTEDEDGE(*,*,#1120,.T.);
#1178=IFCORIENTEDEDGE(*,*,#1122,.T.);
#1179=IFCORIENTEDEDGE(*,*,#1124,.T.);
#1180=IFCCARTESIANPOINT((0.0,0.0,1.0));
#1181=IFCAXIS2PLACEMENT3D(#1180,$,$);
#1182=IFCPLANE(#1181);
#1183=IFCEDGELOOP((#1176,#1177,#1178,#1179));
#1184=IFCFACEOUTERBOUND(#1183,.T.);
#1185=IFCADVANCEDFACE((#1184),#1182,.T.);
#1186=IFCCLOSEDSHELL((#1140,#1148,#1156,#1164,#1175,#1185));
#1187=IFCADVANCEDBREP(#1186);
#1188=IFCCARTESIANPOINT((30.0,0.0,0.0));
#1189=IFCAXIS2PLACEMENT3D(#1188,$,$);
#1190=IFCLOCALPLACEMENT(#14,#1189);
#1191=IFCSHAPEREPRESENTATION(#9,'Body','AdvancedBrep',(#1187));
#1192=IFCPRODUCTDEFINITIONSHAPE($,$,(#1191));
#1193=IFCBUILDINGELEMENTPROXY('4twistxxxxxxxxxxxxxxxx',$,'T',$,$,#1190,#1192,$,$);
#1194=IFCCARTESIANPOINT((0.5,0.0,0.0));
#1195=IFCCARTESIANPOINT((0.5,0.5,0.0));
#1196=IFCCARTESIANPOINT((0.0,0.5,0.0));
#1197=IFCCARTESIANPOINT((-0.5,0.5,0.0));
#1198=IFCCARTESIANPOINT((-0.5,0.0,0.0));
#1199=IFCCARTESIANPOINT((-0.5,-0.5,0.0));
#1200=IFCCARTESIANPOINT((0.0,-0.5,0.0));
#1201=IFCCARTESIANPOINT((0.5,-0.5,0.0));
#1202=IFCCARTESIANPOINT((0.5,0.0,0.0));
#1203=IFCRATIONALBSPLINECURVEWITHKNOTS(2,(#1194,#1195,#1196,#1197,#1198,#1199,#1200,#1201,#1202),.CIRCULAR_ARC.,.T.,.F.,(3,2,2,2,3),(0.,0.25,0.5,0.75,1.),.UNSPECIFIED.,(1.0,0.7071067811865476,1.0,0.7071067811865476,1.0,0.7071067811865476,1.0,0.7071067811865476,1.0));
#1204=IFCCARTESIANPOINT((0.5,0.0,1.0));
#1205=IFCCARTESIANPOINT((0.5,0.5,1.0));
#1206=IFCCARTESIANPOINT((0.0,0.5,1.0));
#1207=IFCCARTESIANPOINT((-0.5,0.5,1.0));
#1208=IFCCARTESIANPOINT((-0.5,0.0,1.0));
#1209=IFCCARTESIANPOINT((-0.5,-0.5,1.0));
#1210=IFCCARTESIANPOINT((0.0,-0.5,1.0));
#1211=IFCCARTESIANPOINT((0.5,-0.5,1.0));
#1212=IFCCARTESIANPOINT((0.5,0.0,1.0));
#1213=IFCRATIONALBSPLINECURVEWITHKNOTS(2,(#1204,#1205,#1206,#1207,#1208,#1209,#1210,#1211,#1212),.CIRCULAR_ARC.,.T.,.F.,(3,2,2,2,3),(0.,0.25,0.5,0.75,1.),.UNSPECIFIED.,(1.0,0.7071067811865476,1.0,0.7071067811865476,1.0,0.7071067811865476,1.0,0.7071067811865476,1.0));
#1214=IFCCARTESIANPOINT((0.5,0.0,0.0));
#1215=IFCVERTEXPOINT(#1214);
#1216=IFCCARTESIANPOINT((0.5,0.0,1.0));
#1217=IFCVERTEXPOINT(#1216);
#1218=IFCEDGECURVE(#1215,#1215,#1203,.T.);
#1219=IFCEDGECURVE(#1217,#1217,#1213,.T.);
#1220=IFCCARTESIANPOINT((0.5,0.0,0.0));
#1221=IFCCARTESIANPOINT((0.5,0.0,1.0));
#1222=IFCCARTESIANPOINT((0.5,0.5,0.0));
#1223=IFCCARTESIANPOINT((0.5,0.5,1.0));
#1224=IFCCARTESIANPOINT((0.0,0.5,0.0));
#1225=IFCCARTESIANPOINT((0.0,0.5,1.0));
#1226=IFCCARTESIANPOINT((-0.5,0.5,0.0));
#1227=IFCCARTESIANPOINT((-0.5,0.5,1.0));
#1228=IFCCARTESIANPOINT((-0.5,0.0,0.0));
#1229=IFCCARTESIANPOINT((-0.5,0.0,1.0));
#1230=IFCCARTESIANPOINT((-0.5,-0.5,0.0));
#1231=IFCCARTESIANPOINT((-0.5,-0.5,1.0));
#1232=IFCCARTESIANPOINT((0.0,-0.5,0.0));
#1233=IFCCARTESIANPOINT((0.0,-0.5,1.0));
#1234=IFCCARTESIANPOINT((0.5,-0.5,0.0));
#1235=IFCCARTESIANPOINT((0.5,-0.5,1.0));
#1236=IFCCARTESIANPOINT((0.5,0.0,0.0));
#1237=IFCCARTESIANPOINT((0.5,0.0,1.0));
#1238=IFCRATIONALBSPLINESURFACEWITHKNOTS(2,1,((#1220,#1221),(#1222,#1223),(#1224,#1225),(#1226,#1227),(#1228,#1229),(#1230,#1231),(#1232,#1233),(#1234,#1235),(#1236,#1237)),.UNSPECIFIED.,.F.,.F.,.F.,(3,2,2,2,3),(2,2),(0.,0.25,0.5,0.75,1.),(0.,1.),.UNSPECIFIED.,((1.0,1.0),(0.7071067811865476,0.7071067811865476),(1.0,1.0),(0.7071067811865476,0.7071067811865476),(1.0,1.0),(0.7071067811865476,0.7071067811865476),(1.0,1.0),(0.7071067811865476,0.7071067811865476),(1.0,1.0)));
#1239=IFCCARTESIANPOINT((0.5,0.0,0.0));
#1240=IFCCARTESIANPOINT((0.5,0.0,1.0));
#1241=IFCPOLYLINE((#1239,#1240));
#1242=IFCEDGECURVE(#1215,#1217,#1241,.T.);
#1243=IFCORIENTEDEDGE(*,*,#1218,.T.);
#1244=IFCORIENTEDEDGE(*,*,#1242,.T.);
#1245=IFCORIENTEDEDGE(*,*,#1219,.F.);
#1246=IFCORIENTEDEDGE(*,*,#1242,.F.);
#1247=IFCEDGELOOP((#1243,#1244,#1245,#1246));
#1248=IFCFACEOUTERBOUND(#1247,.T.);
#1249=IFCADVANCEDFACE((#1248),#1238,.T.);
#1250=IFCORIENTEDEDGE(*,*,#1218,.F.);
#1251=IFCCARTESIANPOINT((0.0,0.0,0.0));
#1252=IFCDIRECTION((0.0,0.0,-1.0));
#1253=IFCAXIS2PLACEMENT3D(#1251,#1252,$);
#1254=IFCPLANE(#1253);
#1255=IFCEDGELOOP((#1250));
#1256=IFCFACEOUTERBOUND(#1255,.T.);
#1257=IFCADVANCEDFACE((#1256),#1254,.T.);
#1258=IFCORIENTEDEDGE(*,*,#1219,.T.);
#1259=IFCCARTESIANPOINT((0.0,0.0,1.0));
#1260=IFCAXIS2PLACEMENT3D(#1259,$,$);
#1261=IFCPLANE(#1260);
#1262=IFCEDGELOOP((#1258));
#1263=IFCFACEOUTERBOUND(#1262,.T.);
#1264=IFCADVANCEDFACE((#1263),#1261,.T.);
#1265=IFCCLOSEDSHELL((#1249,#1257,#1264));
#1266=IFCADVANCEDBREP(#1265);
#1267=IFCCARTESIANPOINT((40.0,0.0,0.0));
#1268=IFCAXIS2PLACEMENT3D(#1267,$,$);
#1269=IFCLOCALPLACEMENT(#14,#1268);
#1270=IFCSHAPEREPRESENTATION(#9,'Body','AdvancedBrep',(#1266));
#1271=IFCPRODUCTDEFINITIONSHAPE($,$,(#1270));
#1272=IFCCOLUMN('5nurbscylxxxxxxxxxxxxx',$,'T',$,$,#1269,#1271,$,$);
#1273=IFCCARTESIANPOINT((0.0,0.0,0.0));
#1274=IFCCARTESIANPOINT((4.0,0.0,0.0));
#1275=IFCCARTESIANPOINT((4.0,3.0,0.0));
#1276=IFCPOLYLINE((#1273,#1274,#1275));
#1277=IFCSWEPTDISKSOLID(#1276,0.1,$,0.5,1.5);
#1278=IFCCARTESIANPOINT((50.0,0.0,0.0));
#1279=IFCAXIS2PLACEMENT3D(#1278,$,$);
#1280=IFCLOCALPLACEMENT(#14,#1279);
#1281=IFCSHAPEREPRESENTATION(#9,'Body','AdvancedBrep',(#1277));
#1282=IFCPRODUCTDEFINITIONSHAPE($,$,(#1281));
#1283=IFCPIPESEGMENT('6pipeparamsxxxxxxxxxxx',$,'T',$,$,#1280,#1282,$,$);
#1284=IFCCARTESIANPOINT((0.0,0.0,0.0));
#1285=IFCAXIS2PLACEMENT3D(#1284,$,$);
#1286=IFCCIRCLE(#1285,2.);
#1287=IFCSWEPTDISKSOLID(#1286,0.1,$,0.,1.5707963267948966);
#1288=IFCCARTESIANPOINT((60.0,0.0,0.0));
#1289=IFCAXIS2PLACEMENT3D(#1288,$,$);
#1290=IFCLOCALPLACEMENT(#14,#1289);
#1291=IFCSHAPEREPRESENTATION(#9,'Body','AdvancedBrep',(#1287));
#1292=IFCPRODUCTDEFINITIONSHAPE($,$,(#1291));
#1293=IFCPIPESEGMENT('7pipearcxxxxxxxxxxxxxx',$,'T',$,$,#1290,#1292,$,$);
#1294=IFCCARTESIANPOINT((1.0,0.0,0.0));
#1295=IFCCARTESIANPOINT((1.0,1.0,0.0));
#1296=IFCCARTESIANPOINT((0.0,1.0,0.0));
#1297=IFCCARTESIANPOINT((-1.0,1.0,0.0));
#1298=IFCCARTESIANPOINT((-1.0,0.0,0.0));
#1299=IFCCARTESIANPOINT((-1.0,-1.0,0.0));
#1300=IFCCARTESIANPOINT((0.0,-1.0,0.0));
#1301=IFCCARTESIANPOINT((1.0,-1.0,0.0));
#1302=IFCCARTESIANPOINT((1.0,0.0,0.0));
#1303=IFCRATIONALBSPLINECURVEWITHKNOTS(2,(#1294,#1295,#1296,#1297,#1298,#1299,#1300,#1301,#1302),.CIRCULAR_ARC.,.T.,.F.,(3,2,2,2,3),(0.,0.25,0.5,0.75,1.),.UNSPECIFIED.,(1.0,0.7071067811865476,1.0,0.7071067811865476,1.0,0.7071067811865476,1.0,0.7071067811865476,1.0));
#1304=IFCSWEPTDISKSOLID(#1303,0.1,$,$,$);
#1305=IFCCARTESIANPOINT((70.0,0.0,0.0));
#1306=IFCAXIS2PLACEMENT3D(#1305,$,$);
#1307=IFCLOCALPLACEMENT(#14,#1306);
#1308=IFCSHAPEREPRESENTATION(#9,'Body','AdvancedBrep',(#1304));
#1309=IFCPRODUCTDEFINITIONSHAPE($,$,(#1308));
#1310=IFCPIPESEGMENT('8pipenurbsxxxxxxxxxxxx',$,'T',$,$,#1307,#1309,$,$);
#99=IFCRELCONTAINEDINSPATIALSTRUCTURE('0rel000000000000000002',$,$,$,(#1045,#1074,#1092,#1193,#1272,#1283,#1293,#1310),#24);
ENDSEC;
END-ISO-10303-21;