Merge branch 'worktree-agent-a503ff91dcc2f951c' into claude/practical-noether-1hb2s1
This commit is contained in:
13 files changed
+202
-18
No files matched your search
@@ -292,6 +292,26 @@ pub fn bike(p: &Params, _chairs: &[(f64, f64, f64)], b: &mut B3) {
|
||||
b.cuboid(cx - 0.06, seat[1] - 0.12, 0.84 * h, cx + 0.06, seat[1] + 0.08, 0.84 * h + 0.04, TYRE);
|
||||
}
|
||||
|
||||
/// [253] IFC: Personen, Velo und Auto sind Entourage, keine Bauteile (nur mit Option „Entourage mitexportieren").
|
||||
pub fn is_entourage(lib_id: &str) -> bool {
|
||||
matches!(lib_id, "lib:person-stehend" | "lib:person-gehend" | "lib:velo" | "lib:auto")
|
||||
}
|
||||
|
||||
/// [253] IFC-Name aus der Katalog-Id (`lib:tisch-rund-120` → „Tisch rund 120") und `IfcFurnitureTypeEnum` (IFC4).
|
||||
pub fn ifc_name_and_type(lib_id: &str) -> (String, &'static str) {
|
||||
let raw = lib_id.strip_prefix("lib:").unwrap_or(lib_id).replace('-', " ");
|
||||
let mut cs = raw.chars();
|
||||
let name = cs.next().map_or(String::new(), |c| c.to_uppercase().chain(cs).collect());
|
||||
let kind = if lib_id.starts_with("lib:tisch") {
|
||||
"TABLE"
|
||||
} else if lib_id.starts_with("lib:stuhl") {
|
||||
"CHAIR"
|
||||
} else {
|
||||
"NOTDEFINED"
|
||||
};
|
||||
(name, kind)
|
||||
}
|
||||
|
||||
/// Alle Platzierungen einer Instanz in Weltkoordinaten (Modell-x/y, z = absolute Höhe).
|
||||
fn place(meshes: &[Mesh3], at: [f64; 2], rot: f64, base: f64) -> Vec<Mesh3> {
|
||||
let (c, s) = (cos(rot), sin(rot));
|
||||
|
||||
@@ -45,6 +45,8 @@ const REC_ROOF: f64 = 9.0;
|
||||
const REC_COLUMN: f64 = 10.0;
|
||||
const REC_END_COLUMNS: f64 = 11.0;
|
||||
const REC_BEAM: f64 = 28.0;
|
||||
/// [253] Bibliotheksobjekt mit 3D-Netz (Möbel) → `IfcFurniture`; Entourage nur mit `IfcOptions::entourage`.
|
||||
const REC_FURNITURE: f64 = 29.0;
|
||||
const REC_CLASSIFICATION: f64 = 12.0;
|
||||
const REC_ZONE: f64 = 13.0;
|
||||
const REC_ATTACH: f64 = 14.0;
|
||||
@@ -80,6 +82,8 @@ pub struct IfcOptions {
|
||||
/// [259] Kontext mitgeben: Gelände-Netze (IfcGeographicElement TERRAIN) und Netze auf Umgebungsklassen
|
||||
/// (Nachbargebäude → IfcBuildingElementProxy), am IfcSite. Fachplaner wollen oft nur das Gebäude: Vorgabe aus.
|
||||
pub context: bool,
|
||||
/// [253] Entourage (Person, Velo, Auto) mitgeben: IfcBuildingElementProxy ObjectType „Entourage". Vorgabe aus (keine Bauteile).
|
||||
pub entourage: bool,
|
||||
/// Zeitstempel (Sekunden seit 1970) und dieselbe Zeit als ISO-Text ohne Sekundenbruchteil.
|
||||
pub now: f64,
|
||||
pub iso: String,
|
||||
@@ -2069,6 +2073,41 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
w_mesh(&mut f, &positions, &indices, false);
|
||||
}
|
||||
|
||||
// ── [253] Möbel der Bibliothek (3D-Netz) → IfcFurniture (IFC2x3: IfcFurnishingElement); Person/Velo/Auto sind Entourage
|
||||
// und nur mit Option als IfcBuildingElementProxy dabei. Netz Welt rel. Geschoss-UK, Status wie andere Bauteile. ──
|
||||
for (i, parts) in crate::furniture_3d::placed(&p) {
|
||||
let d = &p.drawings2d[i];
|
||||
let Drawing2DGeom::Libobj { lib_id, .. } = &d.geom else { continue };
|
||||
let entourage = crate::furniture_3d::is_entourage(lib_id);
|
||||
if entourage && !opt.entourage {
|
||||
continue;
|
||||
}
|
||||
let structure = structure_of(&d.level_id);
|
||||
let base = base_of(structure);
|
||||
let (mut positions, mut indices) = (Vec::new(), Vec::new());
|
||||
for m in &parts {
|
||||
let at = (positions.len() / 3) as u32;
|
||||
positions.extend_from_slice(&m.positions);
|
||||
indices.extend(m.indices.iter().map(|k| k + at));
|
||||
}
|
||||
if indices.is_empty() {
|
||||
continue;
|
||||
}
|
||||
for z in positions.iter_mut().skip(2).step_by(3) {
|
||||
*z -= base;
|
||||
}
|
||||
let (name, kind) = crate::furniture_3d::ifc_name_and_type(lib_id);
|
||||
let mut psets = vec![Pset { name: "Pset_FurnitureTypeCommon", props: vec![ident("Reference", &name)] }];
|
||||
renovation_props(&p, &mut psets, "Pset_FurnitureTypeCommon", d.renovation.as_ref());
|
||||
psets.push(Pset { name: "Dossier_Furniture", props: vec![ident("LibId", lib_id)] });
|
||||
let (id, nm, ty) = (f.str(&d.id), f.str(&name), f.str(lib_id));
|
||||
let kind = f.str(if entourage { "ENTOURAGE" } else { kind });
|
||||
f.nums(&[REC_FURNITURE, structure, id, nm, ty, kind, if entourage { 1.0 } else { 0.0 }]);
|
||||
w_psets(&mut f, &psets);
|
||||
// Teile einzeln geschlossen, zusammen kein dichtes Netz (IFC2x3: Flächenmodell).
|
||||
w_mesh(&mut f, &positions, &indices, false);
|
||||
}
|
||||
|
||||
// ── [279] Geländer → IfcRailing (GUARDRAIL; HANDRAIL, wenn nur der Handlauf bleibt), Netz aus den Prismen ──
|
||||
for r in p.railings.as_deref().unwrap_or(&[]) {
|
||||
let (Some(s), Some(ax)) = (crate::railing::spec(&p, r), crate::railing::axis(r)) else { continue };
|
||||
@@ -2391,6 +2430,26 @@ mod tests {
|
||||
assert!(!strings(&ifc_export_data(&p, &IfcOptions::default()).unwrap()).iter().any(|x| x == "Dossier_Qto_Tree"));
|
||||
}
|
||||
|
||||
/// [253] Möbel mit 3D-Netz als eigener Datensatz (Name aus der Katalog-Id, Status wie Bauteile); Person/Velo/Auto nur mit Option.
|
||||
#[test]
|
||||
fn moebel_datensatz_ohne_entourage() {
|
||||
let mut p = sample();
|
||||
let floor = p.drawing_levels.iter().find(|l| l.kind == DrawingLevelKind::Floor).unwrap().id.clone();
|
||||
let lib = |id: &str, lib_id: &str, x: f64| -> Drawing2D {
|
||||
serde_json::from_value(serde_json::json!({"id": id, "type": "drawing2d", "levelId": floor, "categoryCode": "22", "geom": {"shape": "libobj", "libId": lib_id, "at": {"x": x, "y": 2.0}, "rotation": 0.0}})).unwrap()
|
||||
};
|
||||
p.drawings2d.extend([lib("m1", "lib:tisch-rund-120", 1.0), lib("m2", "lib:sitzbank", 3.0), lib("m3", "lib:person-stehend", 5.0), lib("m4", "lib:wc-wand", 7.0)]);
|
||||
let has = |f: &Flat, id: &str| strings(f).iter().any(|x| x == id);
|
||||
let f = ifc_export_data(&p, &IfcOptions::default()).unwrap();
|
||||
let s = strings(&f);
|
||||
assert!(has(&f, "lib:tisch-rund-120") && has(&f, "lib:sitzbank"), "Tisch und Bank");
|
||||
assert!(!has(&f, "lib:person-stehend") && !has(&f, "lib:wc-wand"), "Person (Entourage) und WC (kein Netz) nicht");
|
||||
assert!(s.iter().any(|x| x == "Tisch rund 120") && s.iter().any(|x| x == "TABLE") && s.iter().any(|x| x == "Sitzbank"));
|
||||
let f = ifc_export_data(&p, &IfcOptions { entourage: true, ..Default::default() }).unwrap();
|
||||
assert!(has(&f, "lib:person-stehend") && !has(&f, "lib:wc-wand"));
|
||||
assert!(strings(&f).iter().any(|x| x == "ENTOURAGE"));
|
||||
}
|
||||
|
||||
/// [G3]/[103] Formöffnung und Dachfenster als Öffnungskörper-Datensatz mit Wirt.
|
||||
#[test]
|
||||
fn formoeffnung_und_dachfenster() {
|
||||
|
||||
@@ -400,13 +400,13 @@ pub fn run_bin(p: &Project, name: &str, args: &[f64], text: &str) -> Result<Vec<
|
||||
match (name, args.len()) {
|
||||
("planDomains", 1) => crate::plan::domains::plan_domains_buf(p, &crate::plan::domains::PlanArgs::parse_in(p, args[0], text)?),
|
||||
// Export-Sammler ([K4], [B5], [C11]): flacher Puffer für `fileio` (Byte-Hülle `export_flat.rs`).
|
||||
("ifcExportData", 4 | 5) => {
|
||||
// 5. Argument [259]: Kontext (Gelände, Nachbarn) mitgeben.
|
||||
("ifcExportData", 4..=6) => {
|
||||
// 5. Argument [259]: Kontext (Gelände, Nachbarn) mitgeben; 6. [253]: Entourage mitgeben.
|
||||
// [272] `text` = Zeitstempel (ISO) oder `{"iso", "designOptions", "renovation"}`: Kombination der Ansicht.
|
||||
let json_text = text.trim_start().starts_with('{');
|
||||
let iso = if json_text { serde_json::from_str::<serde_json::Value>(text).ok().and_then(|v| v.get("iso").and_then(|x| x.as_str()).map(String::from)).unwrap_or_default() } else { text.to_string() };
|
||||
let q = options_state(p, text);
|
||||
let opt = crate::ifc_data::IfcOptions { now: args[0], ifc2x3: args[1] != 0.0, ebkph: args[2] != 0.0, layer_codes: args[3] != 0.0, context: args.get(4).is_some_and(|v| *v != 0.0), iso };
|
||||
let opt = crate::ifc_data::IfcOptions { now: args[0], ifc2x3: args[1] != 0.0, ebkph: args[2] != 0.0, layer_codes: args[3] != 0.0, context: args.get(4).is_some_and(|v| *v != 0.0), entourage: args.get(5).is_some_and(|v| *v != 0.0), iso };
|
||||
crate::ifc_data::ifc_export_data(&q, &opt).map(|f| f.to_bytes())
|
||||
}
|
||||
("meshExportData", 3 | 4) => {
|
||||
|
||||
@@ -123,6 +123,9 @@
|
||||
// TREE = 19 ([149] Baum), structure, id, name, PSETS, MESH (Stamm + Krone, Welt rel. Geschoss-UK)
|
||||
// IFC4: IfcGeographicElement (ObjectType „Baum", PredefinedType USERDEFINED); IFC2x3 (kennt die
|
||||
// Klasse nicht): IfcBuildingElementProxy mit ObjectType „Baum". GlobalId aus `tree/<id>`.
|
||||
// FURNITURE = 29 ([253] Bibliotheksobjekt mit 3D-Netz), structure, id, name, object_type (Katalog-Id), predefined (IfcFurnitureTypeEnum,
|
||||
// nur IFC4), entourage (0/1), PSETS, MESH (Welt rel. Geschoss-UK): IFC4 IfcFurniture, IFC2x3 IfcFurnishingElement;
|
||||
// entourage = 1 (Person/Velo/Auto, nur mit Option): IfcBuildingElementProxy, ObjectType „Entourage". GlobalId `furniture/<id>`.
|
||||
// RAILING = 26 ([279] Geländer), structure, id, name, predefined (GUARDRAIL | HANDRAIL | BALUSTRADE), PSETS, MESH (Prismen,
|
||||
// Welt rel. Geschoss-UK): IfcRailing mit PredefinedType (IFC4 und IFC2x3). GlobalId aus `railing/<id>`.
|
||||
// CONTEXT = 24 ([259] Kontext, nur mit Option), kind (0 Netz auf Umgebungsklasse, 1 Gelände), id, name, class
|
||||
@@ -191,6 +194,8 @@ pub const REC_SPACE_ARC: f64 = 22.0;
|
||||
/// [281] Geneigte Decke als Netz (Flag Rampe ⇒ `IfcRamp` + `IfcRampFlight`).
|
||||
pub const REC_CEILING_MESH: f64 = 27.0;
|
||||
pub const REC_BEAM: f64 = 28.0;
|
||||
/// [253] Möbel/Entourage der Bibliothek mit 3D-Netz.
|
||||
pub const REC_FURNITURE: f64 = 29.0;
|
||||
|
||||
mod format;
|
||||
mod reader;
|
||||
@@ -228,6 +233,7 @@ fn rec_name(code: f64) -> &'static str {
|
||||
c if c == REC_RAILING => "RAILING",
|
||||
c if c == REC_COLUMN_PIECES => "COLUMN_PIECES",
|
||||
c if c == REC_BEAM => "BEAM",
|
||||
c if c == REC_FURNITURE => "FURNITURE",
|
||||
_ => "?",
|
||||
}
|
||||
}
|
||||
@@ -1133,6 +1139,33 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
|
||||
w.add_pset(p, entity, &key);
|
||||
}
|
||||
}
|
||||
c if c == REC_FURNITURE => {
|
||||
let structure = r.structure(n_storeys)?;
|
||||
let id = r.string()?;
|
||||
let name = r.string()?;
|
||||
let object_type = r.string()?;
|
||||
let predefined = r.string()?;
|
||||
let entourage = r.idx()? == 1;
|
||||
let psets = r.psets()?;
|
||||
let mesh = r.mesh()?;
|
||||
let (placement, shape) = w.emit_triangulated_product(&mesh, w.placement_of(structure));
|
||||
let key = format!("furniture/{id}");
|
||||
let g = w.gid(&key);
|
||||
let head = format!("{g},#{},{},$,{},#{placement},#{shape},$", w.owner_history, ifc_string(&name), ifc_string(if entourage { "Entourage" } else { &object_type }));
|
||||
let entity = if entourage {
|
||||
w.add("IFCBUILDINGELEMENTPROXY", format!("{head},$"))
|
||||
} else if w.v2() {
|
||||
w.add("IFCFURNISHINGELEMENT", head)
|
||||
} else {
|
||||
let kind = if ["CHAIR", "TABLE", "DESK", "BED", "FILECABINET", "SHELF", "SOFA", "TECHNICALCABINET", "USERDEFINED"].contains(&predefined.as_str()) { predefined } else { "NOTDEFINED".to_string() };
|
||||
w.add("IFCFURNITURE", format!("{head},{}", enum_(&kind)))
|
||||
};
|
||||
w.add_to_containment(structure, entity);
|
||||
w.elements.insert(key.clone(), entity);
|
||||
for p in &psets {
|
||||
w.add_pset(p, entity, &key);
|
||||
}
|
||||
}
|
||||
c if c == REC_RAILING => {
|
||||
let structure = r.structure(n_storeys)?;
|
||||
let id = r.string()?;
|
||||
|
||||
@@ -1142,6 +1142,38 @@ fn baum_als_geografisches_element() {
|
||||
}
|
||||
}
|
||||
|
||||
/// [253] Möbel: IFC4 IfcFurniture (PredefinedType), IFC2x3 IfcFurnishingElement, Entourage als Proxy „Entourage"; im Geschoss
|
||||
/// enthalten, GlobalId aus `furniture/<id>`.
|
||||
#[test]
|
||||
fn moebel_als_ifc_furniture() {
|
||||
for v2 in [false, true] {
|
||||
let mut b = mini_in(if v2 { B::v2() } else { B::new() });
|
||||
for (id, name, kind, entourage) in [("M1", "Tisch 80x140", "TABLE", 0.0), ("P1", "Person stehend", "NOTDEFINED", 1.0)] {
|
||||
b.n(&[REC_FURNITURE, -1.0]);
|
||||
b.str(id);
|
||||
b.str(name);
|
||||
b.str(&format!("lib:{id}"));
|
||||
b.str(kind);
|
||||
b.n(&[entourage]);
|
||||
b.qto("Dossier_Qto_Tree", &[("Height", 3.0, 1.0)]);
|
||||
b.n(&[4.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 12.0]);
|
||||
b.n(&[4.0, 0.0, 2.0, 1.0, 0.0, 1.0, 3.0, 1.0, 2.0, 3.0, 0.0, 3.0, 2.0, 0.0]);
|
||||
}
|
||||
let ifc = build(&b).unwrap();
|
||||
check_structure(&ifc);
|
||||
let ty = if v2 { "IFCFURNISHINGELEMENT" } else { "IFCFURNITURE" };
|
||||
assert_eq!(count(&ifc, ty), 1, "{ifc}");
|
||||
assert_eq!(count(&ifc, "IFCBUILDINGELEMENTPROXY"), 1);
|
||||
let line = ifc.lines().find(|l| l.contains(&format!("={ty}("))).unwrap();
|
||||
assert!(line.contains("'Tisch 80x140'") && line.contains("'lib:M1'"), "{line}");
|
||||
assert_eq!(line.ends_with(".TABLE.);"), !v2, "{line}");
|
||||
assert!(line.contains(&ifc_guid("t/furniture/M1")), "{line}");
|
||||
let proxy = ifc.lines().find(|l| l.contains("=IFCBUILDINGELEMENTPROXY(")).unwrap();
|
||||
assert!(proxy.contains("'Entourage'"), "{proxy}");
|
||||
assert_eq!(count(&ifc, "IFCRELCONTAINEDINSPATIALSTRUCTURE"), 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// [259] Kontext: Gelände als IfcGeographicElement TERRAIN, Nachbar als Proxy „Kontext"; beide am IfcSite (eigene
|
||||
/// Eingliederung, nicht im Gebäude/Geschoss), Klasse als Beschreibung. IFC2x3: beide als Proxy.
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user