Merge branch 'worktree-agent-a4e3c0331c7b384f5' into claude/practical-noether-1hb2s1
This commit is contained in:
9 files changed
+194
-25
No files matched your search
@@ -51,6 +51,7 @@ const REC_WALL_ARC: f64 = 16.0;
|
||||
const REC_WALL_ARC_SOLID: f64 = 17.0;
|
||||
const REC_GRID: f64 = 18.0;
|
||||
const REC_TREE: f64 = 19.0;
|
||||
const REC_COLUMN_PIECES: f64 = 20.0;
|
||||
|
||||
/// Toleranz des Kerns (`wall_bands.rs::EPS`) für „Öffnung trifft Band".
|
||||
const BAND_EPS: f64 = 1e-4;
|
||||
@@ -1352,36 +1353,49 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
|
||||
// ── Stützen → IfcColumn (Profil-Extrusion, Material = Bauteil) ──────────
|
||||
for col in p.columns.as_deref().unwrap_or(&[]) {
|
||||
// [141] Von einer prioritäreren Wand beschnitten: Querschnitt ohne das Wandband (wie im 3D), wenn
|
||||
// die Aussparung über die ganze Höhe geht (ein Abschnitt); sonst der volle Querschnitt.
|
||||
let (footprint, z_bottom, z_top) = match model3d::column_pieces(&p, col).as_slice() {
|
||||
[one] => one.clone(),
|
||||
_ => {
|
||||
let (zb, zt) = p.column_vertical_extent(col);
|
||||
(model3d::column_footprint(col), zb, zt)
|
||||
}
|
||||
// [141] Von einer prioritäreren Wand beschnitten: je Höhenabschnitt ein eigenes Profil (wie im 3D),
|
||||
// als Datensatz COLUMN_PIECES mit mehreren Extrusionen in einer Darstellung; ein Abschnitt = COLUMN.
|
||||
let pieces: Vec<(Vec<Vec2>, f64, f64)> = model3d::column_pieces(&p, col).into_iter().filter(|(fp, zb, zt)| fp.len() >= 3 && zt > zb).collect();
|
||||
let pieces = if pieces.is_empty() {
|
||||
let (zb, zt) = p.column_vertical_extent(col);
|
||||
vec![(model3d::column_footprint(col), zb, zt)]
|
||||
} else {
|
||||
pieces
|
||||
};
|
||||
if footprint.len() < 3 {
|
||||
continue;
|
||||
}
|
||||
if !(z_top > z_bottom) {
|
||||
let z_bottom = pieces.iter().fold(f64::INFINITY, |m, q| m.min(q.1));
|
||||
let z_top = pieces.iter().fold(f64::NEG_INFINITY, |m, q| m.max(q.2));
|
||||
if pieces.iter().any(|(fp, zb, zt)| fp.len() < 3 || !(zt > zb)) {
|
||||
continue;
|
||||
}
|
||||
let structure = structure_of(&col.floor_id);
|
||||
classified.push((format!("column/{}", col.id), Kind::Column, col.category_code.clone()));
|
||||
let label = crate::plan::domains::column_label(col);
|
||||
let mut psets = vec![Pset { name: "Pset_ColumnCommon", props: vec![ident("Reference", &label)] }];
|
||||
psets.extend(qto("Qto_ColumnBaseQuantities", qty::column_quantities(&footprint, z_top - z_bottom)));
|
||||
let quantities = if let [(footprint, zb, zt)] = pieces.as_slice() {
|
||||
qty::column_quantities(footprint, zt - zb)
|
||||
} else {
|
||||
qty::column_pieces_quantities(&pieces)
|
||||
};
|
||||
psets.extend(qto("Qto_ColumnBaseQuantities", quantities));
|
||||
let (id, lab) = (f.str(&col.id), f.str(&label));
|
||||
f.nums(&[REC_COLUMN, structure, id, lab]);
|
||||
w_pts(&mut f, &footprint);
|
||||
if let [(footprint, _, _)] = pieces.as_slice() {
|
||||
f.nums(&[REC_COLUMN, structure, id, lab]);
|
||||
w_pts(&mut f, footprint);
|
||||
f.nums(&[z_bottom - base_of(structure), z_top - z_bottom]);
|
||||
} else {
|
||||
f.nums(&[REC_COLUMN_PIECES, structure, id, lab, pieces.len() as f64]);
|
||||
for (footprint, zb, zt) in &pieces {
|
||||
w_pts(&mut f, footprint);
|
||||
f.nums(&[zb - base_of(structure), zt - zb]);
|
||||
}
|
||||
}
|
||||
let comp = col.component_id.as_deref().filter(|s| !s.is_empty());
|
||||
let cid = comp.map_or(-1.0, |c| f.str(c));
|
||||
let cname = comp.map_or(-1.0, |c| {
|
||||
let n = component_name(&p, c);
|
||||
f.str(&n)
|
||||
});
|
||||
f.nums(&[z_bottom - base_of(structure), z_top - z_bottom, cid, cname]);
|
||||
f.nums(&[cid, cname]);
|
||||
w_psets(&mut f, &psets);
|
||||
}
|
||||
f.num(REC_END_COLUMNS);
|
||||
|
||||
@@ -282,6 +282,35 @@ pub fn column_quantities(footprint: &[Vec2], length: f64) -> Vec<Qty> {
|
||||
]
|
||||
}
|
||||
|
||||
/// [141] Basismengen einer in Höhenabschnitte geteilten Stütze (`model3d::column_pieces`): Länge = Gesamthöhe,
|
||||
/// Volumen und Mantel = Summe der Abschnitte, Querschnitt = grösster Abschnitt, Deckel nur an der Unter- und
|
||||
/// Oberkante der Stütze (die Fugen zwischen den Abschnitten sind innen).
|
||||
pub fn column_pieces_quantities(pieces: &[(Vec<Vec2>, f64, f64)]) -> Vec<Qty> {
|
||||
let z0 = pieces.iter().fold(f64::INFINITY, |m, p| m.min(p.1));
|
||||
let z1 = pieces.iter().fold(f64::NEG_INFINITY, |m, p| m.max(p.2));
|
||||
let (mut cross, mut outer, mut caps, mut volume) = (0.0f64, 0.0, 0.0, 0.0);
|
||||
for (ring, b, t) in pieces {
|
||||
let a = ring_area(ring);
|
||||
cross = cross.max(a);
|
||||
outer += ring_perimeter(ring) * (t - b);
|
||||
volume += a * (t - b);
|
||||
if (b - z0).abs() < 1e-6 {
|
||||
caps += a;
|
||||
}
|
||||
if (t - z1).abs() < 1e-6 {
|
||||
caps += a;
|
||||
}
|
||||
}
|
||||
vec![
|
||||
len("Length", z1 - z0),
|
||||
area("CrossSectionArea", cross),
|
||||
area("OuterSurfaceArea", outer),
|
||||
area("NetSurfaceArea", outer + caps),
|
||||
vol("GrossVolume", volume),
|
||||
vol("NetVolume", volume),
|
||||
]
|
||||
}
|
||||
|
||||
/// Tür-/Fenster-Basismengen (lichte Öffnung): Breite, Höhe, Umfang, Fläche.
|
||||
pub fn opening_quantities(width: f64, height: f64) -> Vec<Qty> {
|
||||
let w = clean(width);
|
||||
|
||||
@@ -429,3 +429,38 @@ fn laengsschnitt_in_der_wand_zeigt_die_getroffene_schicht() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// [141] Wand (Beton) nur 1.5 m hoch, Backsteinstütze 2.6 m: unten das beschnittene Profil (U-Form), oben der
|
||||
/// volle Querschnitt. Der IFC-Export schreibt EINEN Datensatz COLUMN_PIECES mit zwei Profilen; die Menge
|
||||
/// (Volumen) ist die Summe der Abschnitte.
|
||||
#[test]
|
||||
fn stuetze_mit_hoehenabschnitten_im_ifc() {
|
||||
use crate::ifc_data::{ifc_export_data, IfcOptions};
|
||||
let mut p = base();
|
||||
add_wall(&mut p, "bw", (0.0, 0.0), (3.0, 0.0));
|
||||
p.walls[0].height = 1.5;
|
||||
add_column(&mut p, "C", (3.0, 0.0), ColumnProfile::Rect { width: 0.3, depth: 0.3 }, Some("brick"));
|
||||
let pieces = model3d::column_pieces(&p, &p.columns.as_ref().unwrap()[0]);
|
||||
assert_eq!(pieces.len(), 2, "{pieces:?}");
|
||||
let vol: f64 = pieces.iter().map(|(fp, z0, z1)| ring_area(&fp.iter().map(|v| [v.x, v.y]).collect::<Vec<_>>()) * (z1 - z0)).sum();
|
||||
let want = (0.09 - 0.15 * 0.2) * 1.5 + 0.09 * 1.1;
|
||||
assert!((vol - want).abs() < 1e-6, "{vol} ≠ {want}");
|
||||
let f = ifc_export_data(&p, &IfcOptions::default()).unwrap();
|
||||
// Datensatz 20 (COLUMN_PIECES) zwischen Wandsätzen: Anzahl Abschnitte steht an Position +4.
|
||||
let has = f.nums.windows(5).any(|w| w[0] == 20.0 && w[4] == 2.0);
|
||||
assert!(has, "COLUMN_PIECES mit 2 Abschnitten");
|
||||
// Menge im Pset: NetVolume = Summe.
|
||||
let net = f.nums.iter().any(|v| (v - want).abs() < 1e-6);
|
||||
assert!(net, "NetVolume = {want}");
|
||||
}
|
||||
|
||||
/// Eine nicht geteilte Stütze bleibt beim Datensatz COLUMN (rückwärtskompatibel).
|
||||
#[test]
|
||||
fn stuetze_ohne_abschnitte_bleibt_column() {
|
||||
use crate::ifc_data::{ifc_export_data, IfcOptions};
|
||||
let mut p = base();
|
||||
add_column(&mut p, "C", (3.0, 0.0), ColumnProfile::Rect { width: 0.3, depth: 0.3 }, Some("brick"));
|
||||
let f = ifc_export_data(&p, &IfcOptions::default()).unwrap();
|
||||
assert!(f.nums.contains(&10.0));
|
||||
assert!(!f.nums.windows(5).any(|w| w[0] == 20.0 && w[4] == 2.0));
|
||||
}
|
||||
@@ -261,6 +261,16 @@ impl Builder {
|
||||
(placement, shape)
|
||||
}
|
||||
|
||||
/// [141] Mehrere Extrusionen (je Höhenabschnitt ein Profil `(Profil, z_rel, Tiefe)`) in EINER SweptSolid-
|
||||
/// Darstellung; das Placement liegt auf dem tiefsten Abschnitt, die übrigen sitzen als Versatz der Extrusion.
|
||||
pub(super) fn emit_pieces_product(&mut self, pieces: &[(Vec<(f64, f64)>, f64, f64)], relative_to: usize) -> (usize, usize) {
|
||||
let z0 = pieces.iter().fold(f64::INFINITY, |m, p| m.min(p.1));
|
||||
let solids: Vec<usize> = pieces.iter().map(|(fp, z, d)| self.emit_extrusion_voids(fp, &[], z - z0, *d)).collect();
|
||||
let shape = self.emit_swept_shape(&solids);
|
||||
let placement = self.emit_placement(z0, relative_to);
|
||||
(placement, shape)
|
||||
}
|
||||
|
||||
/// Dreiecks-Mesh als IfcTriangulatedFaceSet (IFC2x3: IfcFacetedBrep bzw. IfcShellBasedSurfaceModel) +
|
||||
/// Shape + Placement (Punkte tragen die Geometrie absolut im Rahmen der Trägerstruktur).
|
||||
pub(super) fn emit_triangulated_product(&mut self, mesh: &Mesh, relative_to: usize) -> (usize, usize) {
|
||||
|
||||
@@ -81,6 +81,10 @@
|
||||
// END_SPACES = 8 (bündelt die Räume je Geschoss zu IfcRelAggregates)
|
||||
// ROOF = 9, structure, id, name, predefined (Text), TYPEREF, PSETS, MESH
|
||||
// COLUMN = 10, structure, id, label, PTS, z_rel, depth, component_id (−1 = keine), component_name, PSETS
|
||||
// COLUMN_PIECES = 20, structure, id, label, n, (PTS, z_rel, depth) × n, component_id (−1 = keine),
|
||||
// component_name, PSETS ([141] Stütze mit Höhenabschnitten, je Abschnitt ein eigenes beschnittenes
|
||||
// Profil; EIN IfcColumn mit n Extrusionen in einer SweptSolid-Darstellung, Placement auf dem tiefsten
|
||||
// Abschnitt; Material und Materialzuordnung wie COLUMN; die Mengen stehen fertig in PSETS)
|
||||
// END_COLUMNS = 11 (Materialzuordnung der Stützen)
|
||||
// CLASSIFICATION = 12, name, source, edition (Text, leer = keine), n_refs, (key, code, ref_name) × n_refs
|
||||
// ([B5], 28.10.) Ein Klassifikationssystem (IfcClassification) mit je Code einer
|
||||
@@ -147,6 +151,7 @@ pub const REC_WALL_ARC: f64 = 16.0;
|
||||
pub const REC_WALL_ARC_SOLID: f64 = 17.0;
|
||||
pub const REC_GRID: f64 = 18.0;
|
||||
pub const REC_TREE: f64 = 19.0;
|
||||
pub const REC_COLUMN_PIECES: f64 = 20.0;
|
||||
|
||||
mod format;
|
||||
mod reader;
|
||||
@@ -175,6 +180,7 @@ fn rec_name(code: f64) -> &'static str {
|
||||
c if c == REC_ATTACH => "ATTACH",
|
||||
c if c == REC_GRID => "GRID",
|
||||
c if c == REC_TREE => "TREE",
|
||||
c if c == REC_COLUMN_PIECES => "COLUMN_PIECES",
|
||||
_ => "?",
|
||||
}
|
||||
}
|
||||
@@ -937,17 +943,33 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
|
||||
let (placement, shape) = w.emit_triangulated_product(&mesh, w.placement_of(structure));
|
||||
w.finish_typed("IFCROOF", format!("roof/{id}"), &name, &ty, &psets, structure, placement, shape, Some(enum_(&predefined)), false);
|
||||
}
|
||||
c if c == REC_COLUMN => {
|
||||
c if c == REC_COLUMN || c == REC_COLUMN_PIECES => {
|
||||
let structure = r.structure(n_storeys)?;
|
||||
let id = r.string()?;
|
||||
let label = r.string()?;
|
||||
let pts = r.pts()?;
|
||||
let z_rel = r.f()?;
|
||||
let depth = r.f()?;
|
||||
let pieces: Vec<(Vec<(f64, f64)>, f64, f64)> = if c == REC_COLUMN {
|
||||
let pts = r.pts()?;
|
||||
vec![(pts, r.f()?, r.f()?)]
|
||||
} else {
|
||||
let n = r.idx()?;
|
||||
if n == 0 {
|
||||
return Err(format!("Stütze ohne Abschnitte bei {}", r.pos - 1));
|
||||
}
|
||||
let mut v = Vec::new();
|
||||
for _ in 0..n {
|
||||
let pts = r.pts()?;
|
||||
v.push((pts, r.f()?, r.f()?));
|
||||
}
|
||||
v
|
||||
};
|
||||
let component = r.opt_string()?;
|
||||
let component_name = r.opt_string()?;
|
||||
let psets = r.psets()?;
|
||||
let (placement, shape) = w.emit_box_product(&pts, z_rel, depth, w.placement_of(structure));
|
||||
let (placement, shape) = if let [(pts, z_rel, depth)] = pieces.as_slice() {
|
||||
w.emit_box_product(pts, *z_rel, *depth, w.placement_of(structure))
|
||||
} else {
|
||||
w.emit_pieces_product(&pieces, w.placement_of(structure))
|
||||
};
|
||||
let g = w.gid(&format!("column/{id}"));
|
||||
let entity = w.emit_building_element("IFCCOLUMN", g, &label, placement, shape, Some(enum_("COLUMN")));
|
||||
w.add_to_containment(structure, entity);
|
||||
|
||||
@@ -1224,3 +1224,31 @@ fn kaputte_puffer_ergeben_fehler_nie_panic() {
|
||||
let (f, s) = m.data();
|
||||
assert!(build_ifc(f, &s).is_err());
|
||||
}
|
||||
|
||||
/// [141] Stütze mit zwei Höhenabschnitten: EIN IfcColumn, zwei Extrusionen in einer Darstellung; die
|
||||
/// Mengen (Volumen = Summe) stehen im Qto.
|
||||
#[test]
|
||||
fn stuetze_mit_hoehenabschnitten() {
|
||||
let mut b = mini();
|
||||
b.n(&[REC_COLUMN_PIECES, -1.0]);
|
||||
b.str("C2");
|
||||
b.str("Stütze 30");
|
||||
b.n(&[2.0]);
|
||||
b.pts(&SQUARE);
|
||||
b.n(&[0.0, 1.5]);
|
||||
b.pts(&SQUARE);
|
||||
b.n(&[1.5, 1.1]);
|
||||
b.str("c1");
|
||||
b.str("Beton");
|
||||
b.qto("Qto_ColumnBaseQuantities", &[("NetVolume", 5.0, 0.27)]);
|
||||
b.n(&[REC_END_COLUMNS]);
|
||||
let ifc = build(&b).unwrap();
|
||||
check_structure(&ifc);
|
||||
assert_eq!(count(&ifc, "IFCCOLUMN"), 1);
|
||||
assert_eq!(count(&ifc, "IFCEXTRUDEDAREASOLID"), 2, "eine Extrusion je Höhenabschnitt");
|
||||
assert_eq!(count(&ifc, "IFCSHAPEREPRESENTATION"), 1, "eine Darstellung für beide Extrusionen");
|
||||
assert!(ifc.contains("IFCQUANTITYVOLUME('NetVolume'") && ifc.contains("0.27"), "Summenvolumen");
|
||||
assert_eq!(count(&ifc, "IFCRELASSOCIATESMATERIAL"), 1);
|
||||
// Zweiter Abschnitt sitzt 1.5 m über dem ersten.
|
||||
assert!(ifc.contains("IFCCARTESIANPOINT((0.0,0.0,1.5))"), "Versatz des oberen Abschnitts");
|
||||
}
|
||||
Reference in new issue
Block a user