[191] Dach-Bögen in 3D-Griffen (Kern-Eingabe mit Bulge) und IFC-Profil mit IfcCompositeCurve für Decken/Räume

This commit is contained in:
Claude committed 2026-11-12 04:59:36 +00:00
1 parent 42d9b2fed8
commit 67d90d4a67
10 files changed
+273 -31

No files matched your search

+34 -3
View File
@@ -310,8 +310,9 @@ impl Builder {
(placement, shape)
}
/// Profil aus Ecken mit Bulge (zur nächsten Ecke; DXF-Sinn) als IfcCompositeCurve → IfcExtrudedAreaSolid.
pub(super) fn emit_bulge_extrusion(&mut self, ring: &[(f64, f64, f64)], z_rel: f64, depth: f64) -> usize {
/// Ring aus Ecken mit Bulge (zur nächsten Ecke; DXF-Sinn) als IfcCompositeCurve (Strecken als IfcPolyline,
/// Bögen als IfcTrimmedCurve auf IfcCircle).
fn emit_bulge_curve(&mut self, ring: &[(f64, f64, f64)]) -> usize {
let n = ring.len();
let mut segs = Vec::with_capacity(n);
for i in 0..n {
@@ -335,7 +336,37 @@ impl Builder {
};
segs.push(self.add("IFCCOMPOSITECURVESEGMENT", format!("{},.T.,#{curve}", enum_("CONTINUOUS"))));
}
let cc = self.add("IFCCOMPOSITECURVE", format!("{},.F.", refs(&segs)));
self.add("IFCCOMPOSITECURVE", format!("{},.F.", refs(&segs)))
}
/// Ring mit Bulge: ohne Bogenkante als geschlossener Linienzug, sonst als IfcCompositeCurve.
fn emit_ring_curve(&mut self, ring: &[(f64, f64, f64)]) -> usize {
if ring.iter().any(|v| v.2.abs() >= 1e-9) {
self.emit_bulge_curve(ring)
} else {
let pts: Vec<(f64, f64)> = ring.iter().map(|v| (v.0, v.1)).collect();
self.emit_closed_polyline(&pts)
}
}
/// [191] Wie {@link emit_box_product_voids}, Umriss und Aussparungen mit Bögen (`(x, y, bulge)`).
pub(super) fn emit_box_product_voids_arcs(&mut self, footprint: &[(f64, f64, f64)], inner: &[Vec<(f64, f64, f64)>], z_bottom_rel: f64, depth: f64, relative_to: usize) -> (usize, usize) {
let outer = self.emit_ring_curve(footprint);
let profile = if inner.is_empty() {
self.add("IFCARBITRARYCLOSEDPROFILEDEF", format!("{},$,#{outer}", enum_("AREA")))
} else {
let holes: Vec<usize> = inner.iter().map(|ring| self.emit_ring_curve(ring)).collect();
self.add("IFCARBITRARYPROFILEDEFWITHVOIDS", format!("{},$,#{outer},{}", enum_("AREA"), refs(&holes)))
};
let solid = self.add("IFCEXTRUDEDAREASOLID", format!("#{profile},#{},#{},{}", self.identity_axis, self.extrude_dir, fmt_real(depth.max(0.001))));
let shape = self.emit_swept_shape(&[solid]);
let placement = self.emit_placement(z_bottom_rel, relative_to);
(placement, shape)
}
/// Profil aus Ecken mit Bulge (zur nächsten Ecke; DXF-Sinn) als IfcCompositeCurve → IfcExtrudedAreaSolid.
pub(super) fn emit_bulge_extrusion(&mut self, ring: &[(f64, f64, f64)], z_rel: f64, depth: f64) -> usize {
let cc = self.emit_bulge_curve(ring);
let profile = self.add("IFCARBITRARYCLOSEDPROFILEDEF", format!("{},$,#{cc}", enum_("AREA")));
let mut position = self.identity_axis;
if z_rel != 0.0 {
+27 -7
View File
@@ -47,6 +47,9 @@
// Linienzüge in Welt-XY (Bögen schon in Sehnen zerlegt); Placement der Trägerstruktur, ohne Darstellung.
// CEILING = 3, structure, id, name, TYPEREF, PSETS, PTS, n_inner, PTS × n_inner, z_rel, depth
// (innere Ringe = Deckenaussparungen, IfcArbitraryProfileDefWithVoids)
// CEILING_ARC = 21 ([191] Decke mit Bogenkanten): wie CEILING, aber jeder Ring als BPTS = n, (x, y, bulge) × n
// (bulge zur nächsten Ecke, DXF-Sinn); Profil als IfcCompositeCurve (Bögen: IfcTrimmedCurve auf IfcCircle)
// SPACE_ARC = 22 ([191]): wie SPACE (7), Umriss als BPTS
// OPENING = 4, wall_id, structure, opening_id, is_door (0/1), fill_name, PTS (Öffnungskörper), z_rel,
// depth, width, FILL, PSETS
// FILL (Parameter aus dem Modell; Körper, Placement und OperationType/PartitioningType rechnet
@@ -152,6 +155,8 @@ pub const REC_WALL_ARC_SOLID: f64 = 17.0;
pub const REC_GRID: f64 = 18.0;
pub const REC_TREE: f64 = 19.0;
pub const REC_COLUMN_PIECES: f64 = 20.0;
pub const REC_CEILING_ARC: f64 = 21.0;
pub const REC_SPACE_ARC: f64 = 22.0;
mod format;
mod reader;
@@ -173,6 +178,8 @@ fn rec_name(code: f64) -> &'static str {
c if c == REC_WALL_ARC => "WALL_ARC",
c if c == REC_WALL_ARC_SOLID => "WALL_ARC_SOLID",
c if c == REC_CEILING => "CEILING",
c if c == REC_CEILING_ARC => "CEILING_ARC",
c if c == REC_SPACE_ARC => "SPACE_ARC",
c if c == REC_OPENING => "OPENING",
c if c == REC_OPENING_SOLID => "OPENING_SOLID",
c if c == REC_CLASSIFICATION => "CLASSIFICATION",
@@ -556,21 +563,28 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
let entity = w.finish_typed("IFCWALL", format!("wall/{id}"), &name, &ty, &psets, structure, placement, shape, None, true);
w.walls.insert(id, (entity, placement, Frame::WORLD));
}
c if c == REC_CEILING => {
c if c == REC_CEILING || c == REC_CEILING_ARC => {
let arcs = c == REC_CEILING_ARC;
let structure = r.structure(n_storeys)?;
let id = r.string()?;
let name = r.string()?;
let ty = r.type_ref()?;
let psets = r.psets()?;
let pts = r.pts()?;
let pts = if arcs { r.bpts()? } else { r.pts()?.into_iter().map(|p| (p.0, p.1, 0.0)).collect() };
let n_inner = r.idx()?;
let mut inner = Vec::new();
for _ in 0..n_inner {
inner.push(r.pts()?);
inner.push(if arcs { r.bpts()? } else { r.pts()?.into_iter().map(|p| (p.0, p.1, 0.0)).collect::<Vec<_>>() });
}
let z_rel = r.f()?;
let depth = r.f()?;
let (placement, shape) = w.emit_box_product_voids(&pts, &inner, z_rel, depth, w.placement_of(structure));
let (placement, shape) = if arcs {
w.emit_box_product_voids_arcs(&pts, &inner, z_rel, depth, w.placement_of(structure))
} else {
let plain: Vec<(f64, f64)> = pts.iter().map(|p| (p.0, p.1)).collect();
let plain_inner: Vec<Vec<(f64, f64)>> = inner.iter().map(|ring| ring.iter().map(|p| (p.0, p.1)).collect()).collect();
w.emit_box_product_voids(&plain, &plain_inner, z_rel, depth, w.placement_of(structure))
};
w.finish_typed("IFCSLAB", format!("slab/{id}"), &name, &ty, &psets, structure, placement, shape, Some(enum_("FLOOR")), true);
}
c if c == REC_OPENING => {
@@ -839,19 +853,25 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
w.add_to_containment(structure, entity);
w.elements.insert(format!("extrusion/{id}"), entity);
}
c if c == REC_SPACE => {
c if c == REC_SPACE || c == REC_SPACE_ARC => {
let arcs = c == REC_SPACE_ARC;
let structure = r.structure(n_storeys)?;
let id = r.string()?;
let name = r.string()?;
let long_name = r.string()?;
let external = r.flag()?;
let height = r.f()?;
let pts = r.pts()?;
let pts = if arcs { r.bpts()? } else { r.pts()?.into_iter().map(|p| (p.0, p.1, 0.0)).collect() };
let net = r.f()?;
let gross = r.f()?;
let sia = r.string()?;
let psets = r.psets()?;
let (placement, shape) = w.emit_box_product(&pts, 0.0, height, w.placement_of(structure));
let (placement, shape) = if arcs {
w.emit_box_product_voids_arcs(&pts, &[], 0.0, height, w.placement_of(structure))
} else {
let plain: Vec<(f64, f64)> = pts.iter().map(|p| (p.0, p.1)).collect();
w.emit_box_product(&plain, 0.0, height, w.placement_of(structure))
};
let g = w.gid(&format!("space/{id}"));
let space = w.add(
"IFCSPACE",
@@ -95,6 +95,12 @@ 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())
}
/// [191] Ring mit Bögen: n, (x, y, bulge) × n.
pub(super) fn bpts(&mut self) -> Result<Vec<(f64, f64, f64)>, String> {
let n = self.idx()?;
let s = self.take(n.checked_mul(3).ok_or("Überlauf")?)?;
Ok(s.chunks_exact(3).map(|c| (c[0], c[1], c[2])).collect())
}
/// Optionaler Wert: has (0/1), value.
fn opt_f(&mut self) -> Result<Option<f64>, String> {
let has = self.flag()?;
+26
View File
@@ -775,6 +775,32 @@ fn decke_mit_aussparung_hat_profil_mit_loechern() {
assert_eq!(count(&plain, "IFCARBITRARYPROFILEDEFWITHVOIDS"), 0);
}
/// [191] Decke mit Bogenkante und runder Aussparung: Profil als IfcCompositeCurve mit IfcTrimmedCurve/IfcCircle.
#[test]
fn decke_mit_bogenkante_hat_zusammengesetzte_kurve() {
let mut b = mini();
b.n(&[REC_CEILING_ARC, -1.0]);
b.str("D1");
b.str("Decke");
b.no_type();
b.qto("Qto_SlabBaseQuantities", &[("GrossArea", 4.0, 2.0), ("NetArea", 4.0, 1.5)]);
// Quadrat, rechte Kante Halbkreis nach aussen (Scheitel rechts der Kante 1 -> 2 = negativer Bulge).
b.n(&[4.0, 0.0, 0.0, 0.0, 2.0, 0.0, -1.0, 2.0, 2.0, 0.0, 0.0, 2.0, 0.0]);
b.n(&[1.0]);
b.n(&[3.0, 0.2, 0.2, 0.0, 0.8, 0.2, 0.0, 0.5, 0.8, 0.0]);
b.n(&[2.6, 0.2]);
let ifc = build(&b).unwrap();
check_structure(&ifc);
assert_eq!(count(&ifc, "IFCARBITRARYPROFILEDEFWITHVOIDS"), 1);
assert_eq!(count(&ifc, "IFCCOMPOSITECURVE("), 1);
assert_eq!(count(&ifc, "IFCCOMPOSITECURVESEGMENT"), 4);
assert_eq!(count(&ifc, "IFCCIRCLE"), 1);
assert_eq!(count(&ifc, "IFCTRIMMEDCURVE"), 1);
// Aussparung ohne Bögen bleibt Linienzug.
assert_eq!(count(&ifc, "IFCPOLYLINE"), 4);
assert!(first_line(&ifc, "IFCTRIMMEDCURVE").contains(".F.,.CARTESIAN."));
}
/// Treppe mit zwei Läufen (Prismen), Podest und Geländer (Mesh).
fn stair_with_parts(b: &mut B) {
b.n(&[REC_STAIR, -1.0]);