[280] Träger/Unterzug als eigenes Bauteil: Project.beams, Plan (gestrichelt mit Achse), Schnitt, Ansicht, 3D, IFC IfcBeam, DXF, Befehl traeger, Objekt-Info, Griffe, Beispiel Musterhaus komplex
This commit is contained in:
97 files changed
+1479
-81
No files matched your search
@@ -47,6 +47,7 @@ Neues Modul: `<modul>.rs` und `mod` in `lib.rs`, Bindungen in `web/<modul>.rs` u
|
||||
| `model3d/` | 3D-Ableitung aus dem Projekt: `parts()` in `mod.rs`; je eine Datei für Decken, Stützen und Bäume, Wände, Öffnungen, Treppen, Dächer, Kontext, freie Körper (`solids.rs`, [115]), Wandkörper mit Formöffnungen (`wall_body.rs`, [216]), Zeichnungs-Spuren, Pick-Geometrie, Klassen-Filter (`classes.rs`, [180]); Tests in `tests.rs` |
|
||||
| `model3d_cache.rs` | inkrementelle 3D-Ableitung (Cache je Wand und Öffnung) |
|
||||
| `wall_bands.rs`, `wall_mesh_cut.rs` | Schichtbänder einer Wand; Wandnetz mit echtem Loch für Datei-Exporte |
|
||||
| `beam_tests.rs` | [280] Träger/Unterzug (`Project.beams`): wird wie eine Stütze ausgewertet (`Beam::as_column`, `model/helpers.rs`); Tests zu Höhenlage, Grundriss, Schnitt, 3D, Objekt-Info, Befehl, Griffe |
|
||||
| `ceilings3d.rs`, `columns3d.rs`, `stairs3d.rs`, `openings3d.rs`, `drawing2d_3d.rs`, `mesh3d.rs` | Netze je Bauteilart |
|
||||
| `explode3d.rs`, `highlight3d.rs`, `surface_pattern3d.rs` | Explosionsaxonometrie, Auswahl-Umrisse, Ansichtsschraffur auf 3D-Flächen |
|
||||
| `solid_bool.rs`, `solid_specs.rs`, `solid_mesh.rs` | Körper-Booleans über Manifold; B-Rep-Spezifikationen für truck; Netze der freien Körper für Grundriss, Schnitt, Ansicht, 3D und Kennwerte ([115]) |
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
//! [280] Träger/Unterzug: Höhenlage, Grundriss (gestrichelt mit Achse), Schnitt (quer und längs), 3D, Objekt-Info,
|
||||
//! Befehl und Griffe. Wie eine Stütze ausgewertet (`Beam::as_column`), liegt aber in `Project.beams`.
|
||||
|
||||
use crate::model::*;
|
||||
use crate::plan::domains::{plan_domains, PlanArgs};
|
||||
use crate::plan::prim::Primitive;
|
||||
use crate::plan::section::{compute_section, Kind, LevelSpec};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
/// Geschoss EG 0 … 2.6 m, Decke (25 cm, UK 2.35) 0..6 × 0..4, Träger 25 × 40 cm auf der Achse (1, 2) → (5, 2).
|
||||
fn project(beam_extra: Value) -> Project {
|
||||
let mut beam = json!({"id": "T1", "type": "beam", "floorId": "eg", "categoryCode": "50", "start": {"x": 1, "y": 2}, "end": {"x": 5, "y": 2}, "width": 0.25, "height": 0.4});
|
||||
beam.as_object_mut().unwrap().extend(beam_extra.as_object().unwrap().clone());
|
||||
serde_json::from_value(json!({
|
||||
"id": "p", "name": "t", "lineStyles": [], "hatches": [], "components": [], "wallTypes": [{"id": "wt", "name": "WT", "layers": []}], "layers": [], "openings": [], "walls": [], "drawings2d": [],
|
||||
"drawingLevels": [{"id": "eg", "name": "EG", "kind": "floor", "visible": true, "locked": false, "floorHeight": 2.6, "baseElevation": 0.0}],
|
||||
"ceilings": [{"id": "D1", "type": "ceiling", "floorId": "eg", "categoryCode": "30", "wallTypeId": "wt", "thickness": 0.25,
|
||||
"outline": [{"x": 0, "y": 0}, {"x": 6, "y": 0}, {"x": 6, "y": 4}, {"x": 0, "y": 4}]}],
|
||||
"beams": [beam]
|
||||
}))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn plan(p: &Project) -> crate::plan::domains::DomainPrims {
|
||||
let t = json!({"floor": "eg", "show": ["30", "50"], "grey": [], "scale": 50, "global": true, "mono": true}).to_string();
|
||||
plan_domains(p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn oberkante_buendig_an_deckenunterkante() {
|
||||
let p = project(json!({}));
|
||||
let b = &p.beams.as_ref().unwrap()[0];
|
||||
let (zb, zt) = p.beam_vertical_extent(b);
|
||||
assert!((zt - 2.35).abs() < 1e-9 && (zb - 1.95).abs() < 1e-9, "{zb} {zt}");
|
||||
// Versatz nach oben in die Decke, ohne Decke darüber: Geschoss-Oberkante.
|
||||
let p2 = project(json!({"topOffset": 0.1}));
|
||||
let (_, zt) = p2.beam_vertical_extent(&p2.beams.as_ref().unwrap()[0]);
|
||||
assert!((zt - 2.45).abs() < 1e-9);
|
||||
let mut p3 = project(json!({}));
|
||||
p3.ceilings = None;
|
||||
let (zb, zt) = p3.beam_vertical_extent(&p3.beams.as_ref().unwrap()[0]);
|
||||
assert!((zt - 2.6).abs() < 1e-9 && (zb - 2.2).abs() < 1e-9);
|
||||
// Achsmitte ausserhalb der Decke: nicht darunter.
|
||||
let p4 = project(json!({"start": {"x": 8, "y": 2}, "end": {"x": 12, "y": 2}}));
|
||||
assert!((p4.beam_vertical_extent(&p4.beams.as_ref().unwrap()[0]).1 - 2.6).abs() < 1e-9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grundriss_gestrichelt_mit_achse() {
|
||||
let p = project(json!({}));
|
||||
let d = plan(&p);
|
||||
// Schnitthöhe 1.0 liegt unter dem Träger (1.95 … 2.35): „über Schnitt“ → Pick-Fläche ohne Füllung, Kanten gestrichelt.
|
||||
let pick = d.columns.iter().filter(|q| matches!(q, Primitive::Polygon { column_id: Some(id), .. } if id == "T1")).count();
|
||||
assert_eq!(pick, 1);
|
||||
assert!(d.columns.iter().all(|q| !matches!(q, Primitive::Polygon { column_id: Some(_), fill, .. } if fill != "none")));
|
||||
let dashed = d.columns.iter().filter(|q| matches!(q, Primitive::Line { cls, dash: Some(Some(_)), .. } if cls == "column-view")).count();
|
||||
assert_eq!(dashed, 4, "vier gestrichelte Kanten");
|
||||
let axis: Vec<_> = d.columns.iter().filter_map(|q| match q { Primitive::Line { cls, a, b, dash: Some(Some(_)), .. } if cls == "beam-axis" => Some((a, b)), _ => None }).collect();
|
||||
assert_eq!(axis.len(), 1, "eine Achse");
|
||||
let (a, b) = axis[0];
|
||||
assert!((a.x - 1.0).abs() < 1e-9 && (b.x - 5.0).abs() < 1e-9 && (a.y - 2.0).abs() < 1e-9 && (b.y - 2.0).abs() < 1e-9);
|
||||
// Klasse aus: nichts.
|
||||
let t = json!({"floor": "eg", "show": ["30"], "grey": [], "scale": 50, "global": true, "mono": true}).to_string();
|
||||
let none = plan_domains(&p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap();
|
||||
assert!(none.columns.is_empty());
|
||||
}
|
||||
|
||||
fn section(p: &Project, line: [(f64, f64); 2]) -> crate::plan::section::Output {
|
||||
let lv = LevelSpec { kind: "section".into(), line: Some([Vec2 { x: line[0].0, y: line[0].1 }, Vec2 { x: line[1].0, y: line[1].1 }]), direction_sign: Some(1.0), ..Default::default() };
|
||||
compute_section(p, &lv, &[]).unwrap().unwrap()
|
||||
}
|
||||
|
||||
fn area(pts: &[[f64; 2]]) -> f64 {
|
||||
let n = pts.len();
|
||||
(0..n).map(|i| pts[i][0] * pts[(i + 1) % n][1] - pts[(i + 1) % n][0] * pts[i][1]).sum::<f64>().abs() / 2.0
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schnitt_quer_und_laengs() {
|
||||
let p = project(json!({}));
|
||||
// Quer: Schnittlinie x = 3 (entlang y) trifft den Träger: Querschnitt 25 × 40 cm.
|
||||
let o = section(&p, [(3.0, -2.0), (3.0, 8.0)]);
|
||||
let c: Vec<_> = o.cuts.iter().filter(|c| c.source_id.as_deref() == Some("T1")).collect();
|
||||
assert_eq!(c.len(), 1, "{:?}", o.cuts.iter().map(|c| &c.source_id).collect::<Vec<_>>());
|
||||
assert!((area(&c[0].pts) - 0.25 * 0.4).abs() < 1e-6, "{}", area(&c[0].pts));
|
||||
assert_eq!(c[0].kind, Kind::Slab);
|
||||
assert_eq!(c[0].category.as_deref(), Some("50"));
|
||||
// Längs: Schnittlinie y = 2 durch die Achse: Länge 4 m × 40 cm.
|
||||
let o = section(&p, [(-1.0, 2.0), (8.0, 2.0)]);
|
||||
let c: Vec<_> = o.cuts.iter().filter(|c| c.source_id.as_deref() == Some("T1")).collect();
|
||||
assert_eq!(c.len(), 1);
|
||||
assert!((area(&c[0].pts) - 4.0 * 0.4).abs() < 1e-6, "{}", area(&c[0].pts));
|
||||
// Daneben vorbei (y = 3.5): nicht geschnitten, aber in der Projektion (Kanten dahinter).
|
||||
let o = section(&p, [(-1.0, 3.5), (8.0, 3.5)]);
|
||||
assert!(o.cuts.iter().all(|c| c.source_id.as_deref() != Some("T1")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dreid_netz_pick_und_klasse() {
|
||||
let p = project(json!({}));
|
||||
let m = crate::model3d::emit_columns(&p);
|
||||
assert_eq!(m.len(), 1);
|
||||
assert!(matches!(m[0].owner, crate::model3d::Owner::Beam(0)));
|
||||
// Quader 4 × 0.25 × 0.4: z von 1.95 bis 2.35.
|
||||
let zs: Vec<f64> = m[0].positions.chunks(3).map(|v| v[2]).collect();
|
||||
let (lo, hi) = (zs.iter().cloned().fold(f64::INFINITY, f64::min), zs.iter().cloned().fold(f64::NEG_INFINITY, f64::max));
|
||||
assert!((lo - 1.95).abs() < 1e-9 && (hi - 2.35).abs() < 1e-9, "{lo} {hi}");
|
||||
assert_eq!(crate::model3d::Owner::Beam(0).id(&p), Some("T1"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn objekt_info_traeger() {
|
||||
let p = project(json!({"profileName": "HEB 200", "topOffset": 0.05}));
|
||||
let root = serde_json::to_value(&p).unwrap();
|
||||
let root = root.as_object().unwrap();
|
||||
let a: crate::selection_info::SelArgs = serde_json::from_value(json!({"columnId": "T1"})).unwrap();
|
||||
let s = crate::selection_info::derive(&crate::document::Lookup::plain(root), &a).unwrap().into_string();
|
||||
let v: Value = serde_json::from_str(&s).unwrap();
|
||||
assert_eq!(v["kind"], "beam");
|
||||
assert_eq!(v["beam"]["profileName"], "HEB 200");
|
||||
assert!((v["beam"]["zTop"].as_f64().unwrap() - 2.40).abs() < 1e-9, "{v}");
|
||||
assert!((v["beam"]["length"].as_f64().unwrap() - 4.0).abs() < 1e-9);
|
||||
assert!((v["bbox"]["minX"].as_f64().unwrap() - 1.0).abs() < 1e-9, "{v}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn befehl_traeger_legt_beam_an() {
|
||||
let root = serde_json::Map::new();
|
||||
let p = Project::default();
|
||||
let v = json!({"cmd": "beam", "pts": [[0.0, 0.0], [4.0, 0.0]], "width": 0.2, "height": 0.2, "profileName": "HEB 200", "stamp": "s", "ctx": {"level": "eg", "floorHeight": 2.6, "cat": "10", "wallType": "x"}});
|
||||
let ops = crate::cmd_create::ops(&root, &p, &v).unwrap();
|
||||
let Some(crate::ops::Op::Add { collection, items, .. }) = ops.first() else { panic!("add erwartet") };
|
||||
assert_eq!(collection, "beams");
|
||||
let b = &items[0];
|
||||
assert_eq!((b["type"].as_str(), b["floorId"].as_str(), b["categoryCode"].as_str()), (Some("beam"), Some("eg"), Some("10")), "ohne Klasse 25/50: die aktive");
|
||||
assert_eq!(b["profileName"], "HEB 200");
|
||||
assert_eq!(b["end"]["x"], 4.0);
|
||||
// Nulllänge: nichts.
|
||||
let v0 = json!({"cmd": "beam", "pts": [[1.0, 1.0], [1.0, 1.0]], "stamp": "s", "ctx": {"level": "eg"}});
|
||||
assert!(crate::cmd_create::ops(&root, &p, &v0).unwrap().is_empty());
|
||||
// Das neue Element liest das Modell.
|
||||
let _: Beam = serde_json::from_value(b.clone()).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn umbaufilter_wie_stuetze() {
|
||||
// Träger Neu: im Filter „Bestand“ weg, im „Neubau“ da (Pick-Fläche + Kanten), in „Abbruch“ weg.
|
||||
let p = project(json!({"renovation": {"status": "new"}}));
|
||||
let with = |f: &str| {
|
||||
let t = json!({"floor": "eg", "show": ["30", "50"], "grey": [], "scale": 50, "global": true, "mono": true, "renovation": f}).to_string();
|
||||
plan_domains(&p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap().columns.len()
|
||||
};
|
||||
assert_eq!(with("bestand"), 0);
|
||||
assert_eq!(with("abbruch"), 0);
|
||||
assert!(with("neubau") > 0);
|
||||
}
|
||||
@@ -969,6 +969,36 @@ fn column_ops(v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
|
||||
)
|
||||
}
|
||||
|
||||
/// [280] Träger: Achse `pts[0]` → `pts[1]` auf dem aktiven Geschoss, Klasse „25“ (Stützen) bzw. „50“, Querschnitt `width` × `height`
|
||||
/// (Vorgabe 25 × 40 cm), Profilname nur als Text, Oberkante bündig an der Deckenunterkante (`topOffset` 0).
|
||||
fn beam_ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
|
||||
let pts = pts_of(v, "pts");
|
||||
let [a, b] = pts[..] else { return Vec::new() };
|
||||
if seg_len(a, b) < EPS {
|
||||
return Vec::new();
|
||||
}
|
||||
let num = |k: &str, d: f64| opt_n(v, k).filter(|x| *x > 0.0 && x.is_finite()).unwrap_or(d);
|
||||
let mut f = vec![
|
||||
("id", s(&ids.next("beam"))),
|
||||
("type", s("beam")),
|
||||
("floorId", s(ctx.level)),
|
||||
// Klasse „25“ (Stützen), sonst „50“ (Tragwerk), sonst die aktive (wie beim Erkennen von Stützen).
|
||||
("categoryCode", if has_category(p, "25") { s("25") } else { category_or(p, "50", ctx) }),
|
||||
("start", pv(a)),
|
||||
("end", pv(b)),
|
||||
("width", js_num(num("width", 0.25))),
|
||||
("height", js_num(num("height", 0.4))),
|
||||
];
|
||||
let name = s_of(v, "profileName").trim();
|
||||
if !name.is_empty() {
|
||||
f.push(("profileName", s(name)));
|
||||
}
|
||||
if let Some(o) = opt_n(v, "topOffset").filter(|x| x.is_finite() && x.abs() > 1e-9) {
|
||||
f.push(("topOffset", js_num(o)));
|
||||
}
|
||||
add_op("beams", vec![obj(f)])
|
||||
}
|
||||
|
||||
/// [149] Baum am Punkt `at`: Ebene „13" (Bäume), falls vorhanden, sonst die aktive; Abmessungen, Form,
|
||||
/// Bestand und Laub/Nadel aus den Werkzeug-Vorgaben (fehlende/unsinnige Werte: Vorgaben aus `tree.rs`).
|
||||
fn tree_ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
|
||||
@@ -1155,6 +1185,7 @@ pub fn ops(root: &Map<String, Value>, p: &Project, v: &Value) -> Option<Vec<Op>>
|
||||
"opening" => opening_ops(root, p, v, &ctx, ids),
|
||||
"roof" => roof_ops(p, v, &ctx, ids),
|
||||
"column" => column_ops(v, &ctx, ids),
|
||||
"beam" => beam_ops(p, v, &ctx, ids),
|
||||
"tree" => tree_ops(p, v, &ctx, ids),
|
||||
"circlesToTrees" => circles_to_trees_ops(root, p, v, &ctx, ids),
|
||||
"extrude" => extrude_ops(root, v, &ctx, ids),
|
||||
@@ -1239,6 +1270,18 @@ pub fn preview_req(root: &Map<String, Value>, project: &Project, req: &Req, pts:
|
||||
out.poly(&column_footprint(*at, v));
|
||||
}
|
||||
}
|
||||
"beam" => {
|
||||
// [280] Rechteck um die Achse vom ersten Punkt zum Cursor.
|
||||
if let [a, b] = pts[..] {
|
||||
let w = opt_n(v, "width").filter(|x| *x > 0.0 && x.is_finite()).unwrap_or(0.25);
|
||||
let beam = crate::model::Beam { start: crate::model::Vec2 { x: a.0, y: a.1 }, end: crate::model::Vec2 { x: b.0, y: b.1 }, width: w, ..Default::default() };
|
||||
let fp = beam.footprint();
|
||||
if fp.len() == 4 {
|
||||
out.poly(&fp.iter().map(|q| (q.x, q.y)).collect::<Vec<_>>());
|
||||
out.line(a, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
"tree" => {
|
||||
// [149] Kronenkreis und Stamm am Cursor.
|
||||
if let Some(at) = pts.first() {
|
||||
|
||||
@@ -20,7 +20,7 @@ use std::collections::HashMap;
|
||||
|
||||
/// Listen der Zwischenablage: (Schlüssel in `clip`, Projekt-Liste, id-Präfix, Geschoss-Feld).
|
||||
/// Reihenfolge = Reihenfolge der ids und der Ops (Wände vor Öffnungen).
|
||||
const LISTS: [(&str, &str, &str, &str); 11] = [
|
||||
const LISTS: [(&str, &str, &str, &str); 12] = [
|
||||
("walls", "walls", "W", "floorId"),
|
||||
("drawings", "drawings2d", "dr2d", "levelId"),
|
||||
("ceilings", "ceilings", "C", "floorId"),
|
||||
@@ -30,6 +30,7 @@ const LISTS: [(&str, &str, &str, &str); 11] = [
|
||||
("rooms", "rooms", "RM", "floorId"),
|
||||
("extrudedSolids", "extrudedSolids", "extrude", "levelId"),
|
||||
("columns", "columns", "column", "floorId"),
|
||||
("beams", "beams", "beam", "floorId"),
|
||||
("trees", "trees", "tree", "floorId"),
|
||||
("cameras", "cameras", "camera", "floorId"),
|
||||
];
|
||||
|
||||
@@ -292,6 +292,14 @@ fn mv_wall(w: &Value, xf: &Xf) -> Value {
|
||||
}
|
||||
|
||||
/// Stütze: Einfügepunkt und Profil-Drehung (über einen mit abgebildeten Richtungspunkt).
|
||||
/// [280] Träger: Anfangs- und Endpunkt der Achse werden abgebildet (Querschnitt bleibt).
|
||||
fn mv_beam(b: &Value, xf: &Xf) -> Value {
|
||||
let (sx, sy) = xy(field(b, "start").unwrap_or(&Value::Null));
|
||||
let (ex, ey) = xy(field(b, "end").unwrap_or(&Value::Null));
|
||||
let (s, e) = (xf.apply(sx, sy), xf.apply(ex, ey));
|
||||
with_all(b, vec![("start", pt(s.0, s.1)), ("end", pt(e.0, e.1))])
|
||||
}
|
||||
|
||||
fn mv_column(c: &Value, xf: &Xf) -> Value {
|
||||
let (bx, by) = xy(field(c, "position").unwrap_or(&Value::Null));
|
||||
let rot = num_or(field(c, "rotation"), 0.0);
|
||||
@@ -776,6 +784,8 @@ enum Kind {
|
||||
Drawing,
|
||||
Solid,
|
||||
Column,
|
||||
/// [280] Träger (Auswahlkanal der Stützen).
|
||||
Beam,
|
||||
Ceiling,
|
||||
Roof,
|
||||
Stair,
|
||||
@@ -809,6 +819,9 @@ fn gather<'a>(root: &'a Map<String, Value>, sel: &Sel, op: &str, ignore_lock: bo
|
||||
if let Some(c) = list(root, "columns").iter().find(|c| id_of(c) == Some(id)).filter(|c| free(c)) {
|
||||
out.push((Kind::Column, c));
|
||||
}
|
||||
if let Some(b) = list(root, "beams").iter().find(|c| id_of(c) == Some(id)).filter(|c| free(c)) {
|
||||
out.push((Kind::Beam, b));
|
||||
}
|
||||
}
|
||||
let mut each = |key: &str, set: Ids, kind: Kind| out.extend(list(root, key).iter().filter(|e| set.has(e) && free(e)).map(|e| (kind, e)));
|
||||
each("ceilings", Ids::opt(&sel.ceiling_ids), Kind::Ceiling);
|
||||
@@ -981,6 +994,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
|
||||
}
|
||||
if let Some(id) = nonempty(&sel.column_id) {
|
||||
patch("columns", &|c| id_of(c) == Some(id) && !locked(c), &|c| mv_column(c, &xf));
|
||||
patch("beams", &|c| id_of(c) == Some(id) && !locked(c), &|c| mv_beam(c, &xf));
|
||||
}
|
||||
let (ceil, roofs, stairs, rooms) = (Ids::opt(&sel.ceiling_ids), Ids::opt(&sel.roof_ids), Ids::opt(&sel.stair_ids), Ids::opt(&sel.room_ids));
|
||||
if !ceil.is_empty() {
|
||||
@@ -1029,7 +1043,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
|
||||
|
||||
// Kopien (Kopie/Reihe/Verteilen bzw. gespiegelte Kopie).
|
||||
let mut ids = IdGen::new(&req.stamp);
|
||||
let mut new: [Vec<Value>; 11] = Default::default();
|
||||
let mut new: [Vec<Value>; 12] = Default::default();
|
||||
let mut new_openings = Vec::new();
|
||||
// [213] Namen der vorhandenen Kameras (Kopien heissen „… Kopie“, nummeriert bei Kollision).
|
||||
let mut cam_names: std::collections::HashSet<String> = list(root, "cameras").iter().filter_map(|c| field(c, "name").and_then(Value::as_str).map(String::from)).collect();
|
||||
@@ -1042,6 +1056,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
|
||||
Kind::Drawing => "dr2d",
|
||||
Kind::Solid => "extrude",
|
||||
Kind::Column => "column",
|
||||
Kind::Beam => "beam",
|
||||
Kind::Ceiling => "C",
|
||||
Kind::Roof => "RF",
|
||||
Kind::Stair => "ST",
|
||||
@@ -1069,6 +1084,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
|
||||
Kind::Drawing => (1, fix_refs(with_geom(e, geom_at(field(e, "geom").unwrap_or(&Value::Null), &xf, t)), &to_copy)),
|
||||
Kind::Solid => (2, mv_solid(e, &xf, k_at(t))),
|
||||
Kind::Column => (3, mv_column(e, &xf)),
|
||||
Kind::Beam => (11, mv_beam(e, &xf)),
|
||||
Kind::Ceiling => (4, mv_ceiling(e, &xf)),
|
||||
Kind::Roof => (5, mv_roof(e, &xf)),
|
||||
Kind::Stair => (6, mv_stair(e, &xf, k_at(t))),
|
||||
@@ -1102,7 +1118,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
|
||||
}
|
||||
}
|
||||
}
|
||||
let keys = ["walls", "drawings2d", "extrudedSolids", "columns", "ceilings", "roofs", "stairs", "rooms", "trees", "context", "cameras"];
|
||||
let keys = ["walls", "drawings2d", "extrudedSolids", "columns", "ceilings", "roofs", "stairs", "rooms", "trees", "context", "cameras", "beams"];
|
||||
for (key, items) in keys.iter().zip(new) {
|
||||
ops.extend(add(key, items));
|
||||
}
|
||||
@@ -1407,6 +1423,12 @@ fn item_preview(p: &Project, kind: Kind, e: &Value, xf: &Xf, out: &mut Pending)
|
||||
s.poly(&mapped(&fp, xf));
|
||||
}
|
||||
}
|
||||
Kind::Beam => {
|
||||
if let Ok(b) = serde_json::from_value::<crate::model::Beam>(mv_beam(e, xf)) {
|
||||
let fp: Vec<(f64, f64)> = b.footprint().iter().map(|q| (q.x, q.y)).collect();
|
||||
s.poly(&fp);
|
||||
}
|
||||
}
|
||||
Kind::Ceiling | Kind::Roof => s.poly(&mapped(&pts_of(field(e, "outline")), xf)),
|
||||
Kind::Room => s.poly(&mapped(&pts_of(field(e, "boundary")), xf)),
|
||||
Kind::Stair => stair_preview(e, xf, s),
|
||||
|
||||
@@ -53,7 +53,7 @@ pub fn ops(root: &Map<String, Value>, p: &Project, text: &str) -> Result<Vec<Op>
|
||||
}
|
||||
|
||||
/// Listen, deren neue Elemente den Zeichen-Status bekommen ([271]).
|
||||
const RENOVATION_COLLECTIONS: [&str; 8] = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms"];
|
||||
const RENOVATION_COLLECTIONS: [&str; 9] = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "beams", "extrudedSolids", "rooms"];
|
||||
|
||||
/// [271] Neue Bauteile der Ops (`add` in [`RENOVATION_COLLECTIONS`]) erhalten `renovation` (ein Objekt mit gültigem
|
||||
/// `status`), sofern sie keines tragen; sonst unverändert.
|
||||
|
||||
@@ -13,7 +13,7 @@ use serde_json::{json, Map, Value};
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
|
||||
/// Listen, deren Elemente eine Variante tragen können (Wurzel-Schlüssel).
|
||||
pub const COLLECTIONS: [&str; 9] = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms", "drawings2d"];
|
||||
pub const COLLECTIONS: [&str; 10] = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "beams", "extrudedSolids", "rooms", "drawings2d"];
|
||||
|
||||
/// Höchstens so viele Kombinationen im Vergleich (Kreuzprodukt der Sätze).
|
||||
pub const MAX_COMPARE: usize = 24;
|
||||
@@ -54,6 +54,7 @@ pub fn active(p: &Project) -> bool {
|
||||
|| p.roofs.iter().flatten().any(|x| known(x.design_option.as_ref()))
|
||||
|| p.stairs.iter().flatten().any(|x| known(x.design_option.as_ref()))
|
||||
|| p.columns.iter().flatten().any(|x| known(x.design_option.as_ref()))
|
||||
|| p.beams.iter().flatten().any(|x| known(x.design_option.as_ref()))
|
||||
|| p.extruded_solids.iter().flatten().any(|x| known(x.design_option.as_ref()))
|
||||
|| p.rooms.iter().flatten().any(|x| known(x.design_option.as_ref()))
|
||||
|| p.drawings2d.iter().any(|x| known(x.design_option.as_ref()))
|
||||
@@ -766,6 +767,7 @@ pub fn info(p: &Project) -> Value {
|
||||
p.roofs.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
|
||||
p.stairs.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
|
||||
p.columns.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
|
||||
p.beams.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
|
||||
p.extruded_solids.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
|
||||
p.rooms.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
|
||||
p.drawings2d.iter().for_each(|x| add(x.design_option.as_ref()));
|
||||
|
||||
@@ -48,6 +48,9 @@ impl<'a> Explode<'a> {
|
||||
for c in p.columns.as_deref().unwrap_or(&[]) {
|
||||
floor_of.insert(&c.id, &c.floor_id);
|
||||
}
|
||||
for b in p.beams.as_deref().unwrap_or(&[]) {
|
||||
floor_of.insert(&b.id, &b.floor_id);
|
||||
}
|
||||
for t in p.trees.as_deref().unwrap_or(&[]) {
|
||||
floor_of.insert(&t.id, &t.floor_id);
|
||||
}
|
||||
@@ -166,6 +169,7 @@ pub fn parts_filtered(p: &Project, layered: bool, detail: f64, for_section: bool
|
||||
for (g, dz) in groups {
|
||||
let pick = |fid: &str| ex.in_group(fid, g);
|
||||
q.columns = p.columns.as_ref().map(|v| v.iter().filter(|c| pick(&c.floor_id)).cloned().collect());
|
||||
q.beams = p.beams.as_ref().map(|v| v.iter().filter(|c| pick(&c.floor_id)).cloned().collect());
|
||||
q.trees = p.trees.as_ref().map(|v| v.iter().filter(|t| pick(&t.floor_id)).cloned().collect());
|
||||
q.stairs = p.stairs.as_ref().map(|v| v.iter().filter(|s| pick(&s.floor_id)).cloned().collect());
|
||||
q.roofs = p.roofs.as_ref().map(|v| v.iter().filter(|r| pick(&r.floor_id)).cloned().collect());
|
||||
|
||||
@@ -167,6 +167,20 @@ pub fn schedule_rows(p: &Project) -> Vec<ScheduleRow> {
|
||||
area: None,
|
||||
});
|
||||
}
|
||||
// [280] Träger: Typ = Profilname (sonst Rechteck), Länge der Achse, Querschnitt Breite, Höhe.
|
||||
for b in p.beams.as_deref().unwrap_or(&[]) {
|
||||
rows.push(ScheduleRow {
|
||||
kind: "Träger",
|
||||
id: b.id.clone(),
|
||||
type_name: b.profile_name.clone().filter(|n| !n.trim().is_empty()).unwrap_or_else(|| "Rechteck".into()),
|
||||
floor: floor_name(p, &b.floor_id),
|
||||
floor_id: Some(b.floor_id.clone()),
|
||||
length: Some((b.end.x - b.start.x).hypot(b.end.y - b.start.y)),
|
||||
height_m: Some(b.height),
|
||||
thickness: Some(b.width),
|
||||
area: None,
|
||||
});
|
||||
}
|
||||
rows
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
use serde_json::{json, Map, Value};
|
||||
|
||||
/// Projekt-Listen, die verschoben werden (jedes Element hat eine `id`), in Op-Reihenfolge.
|
||||
pub const TRANSLATED_LISTS: [&str; 12] = ["walls", "ceilings", "roofs", "stairs", "rooms", "columns", "extrudedSolids", "drawings2d", "context", "drawingLevels", "trees", "cameras"];
|
||||
pub const TRANSLATED_LISTS: [&str; 13] = ["walls", "ceilings", "roofs", "stairs", "rooms", "columns", "beams", "extrudedSolids", "drawings2d", "context", "drawingLevels", "trees", "cameras"];
|
||||
|
||||
fn shift(p: &Value, dx: f64, dy: f64) -> Value {
|
||||
let c = |k: &str| p.get(k).and_then(Value::as_f64).unwrap_or(f64::NAN);
|
||||
@@ -163,6 +163,7 @@ fn shift_element(key: &str, e: &Value, dx: f64, dy: f64) -> (Value, bool) {
|
||||
set(&mut m, "stampAnchor", c);
|
||||
}
|
||||
"columns" => shift_pts_fields(&mut m, &["position"], dx, dy, &[]),
|
||||
"beams" => shift_pts_fields(&mut m, &["start", "end"], dx, dy, &[]),
|
||||
"trees" => shift_pts_fields(&mut m, &["position"], dx, dy, &[]),
|
||||
"cameras" => shift_pts_fields(&mut m, &["position", "target"], dx, dy, &[]),
|
||||
"extrudedSolids" => {
|
||||
|
||||
@@ -295,6 +295,27 @@ pub fn run(lk: &Lookup, req: &Request) -> Result<GripResult, String> {
|
||||
})
|
||||
.into()
|
||||
}
|
||||
// [280] Träger: Griff 0 = Anfang, 1 = Ende der Achse, 2 = Mitte (verschiebt den ganzen Träger).
|
||||
"beamGrip" => {
|
||||
let (index, (x, y)) = (r.n("index"), r.p("pt"));
|
||||
patch("beams", r.s("id"), &|e| {
|
||||
if truthy(field(e, "locked")) {
|
||||
return None;
|
||||
}
|
||||
let (s, t) = (xy(field(e, "start")?), xy(field(e, "end")?));
|
||||
if index == 0.0 {
|
||||
Some(with(e, "start", pt(x, y)))
|
||||
} else if index == 1.0 {
|
||||
Some(with(e, "end", pt(x, y)))
|
||||
} else if index == 2.0 {
|
||||
let (dx, dy) = (x - (s.0 + t.0) / 2.0, y - (s.1 + t.1) / 2.0);
|
||||
Some(with_all(e, vec![("start", pt(s.0 + dx, s.1 + dy)), ("end", pt(t.0 + dx, t.1 + dy))]))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.into()
|
||||
}
|
||||
"ceilingGrip" | "roomGrip" => {
|
||||
let (coll, field) = if op == "ceilingGrip" { ("ceilings", "outline") } else { ("rooms", "boundary") };
|
||||
let (index, (x, y)) = (r.n("index"), r.p("pt"));
|
||||
@@ -2031,6 +2052,24 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// [280] Träger: Griff 0 Anfang, 1 Ende, 2 Mitte verschiebt; gesperrt/unbekannt/Index daneben ändern nichts.
|
||||
#[test]
|
||||
fn traeger_griffe() {
|
||||
let r = root(json!({"beams": [{"id": "b", "start": {"x": 0, "y": 0}, "end": {"x": 4, "y": 0}, "width": 0.2, "height": 0.4}]}));
|
||||
let ent = |req: Value| run(&Lookup::plain(&r), &rq(req)).unwrap();
|
||||
let p = |v: &Value| (v["x"].as_f64().unwrap(), v["y"].as_f64().unwrap());
|
||||
let e = ent(json!({"op": "beamGrip", "id": "b", "index": 0, "pt": [1, 1]}));
|
||||
assert_eq!((p(&entity(&e)["start"]), p(&entity(&e)["end"])), ((1.0, 1.0), (4.0, 0.0)));
|
||||
let e = ent(json!({"op": "beamGrip", "id": "b", "index": 1, "pt": [5, 2]}));
|
||||
assert_eq!(p(&entity(&e)["end"]), (5.0, 2.0));
|
||||
let e = ent(json!({"op": "beamGrip", "id": "b", "index": 2, "pt": [3, 1]}));
|
||||
assert_eq!((p(&entity(&e)["start"]), p(&entity(&e)["end"])), ((1.0, 1.0), (5.0, 1.0)));
|
||||
assert!(ent(json!({"op": "beamGrip", "id": "b", "index": 3, "pt": [3, 1]})).ops.is_empty());
|
||||
assert!(ent(json!({"op": "beamGrip", "id": "x", "index": 0, "pt": [3, 1]})).ops.is_empty());
|
||||
let locked = root(json!({"beams": [{"id": "b", "locked": true, "start": {"x": 0, "y": 0}, "end": {"x": 4, "y": 0}}]}));
|
||||
assert!(run(&Lookup::plain(&locked), &rq(json!({"op": "beamGrip", "id": "b", "index": 0, "pt": [1, 1]}))).unwrap().ops.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn js_zahlen() {
|
||||
assert_eq!(js_num(5.0).to_string(), "5");
|
||||
|
||||
@@ -263,6 +263,17 @@ pub fn selection_highlight_lines(p: &Project, a: &Args) -> Result<Vec<f32>, Stri
|
||||
lift(&mut out, n, &col.id);
|
||||
}
|
||||
}
|
||||
// [280] Träger liegen im Auswahlkanal der Stützen.
|
||||
for b in p.beams.as_deref().unwrap_or(&[]) {
|
||||
if columns.contains(b.id.as_str()) {
|
||||
let col = b.as_column(p);
|
||||
let (z0, z1) = p.column_vertical_extent(&col);
|
||||
let foot: Vec<[f64; 2]> = crate::model3d::column_footprint(&col).iter().map(|q| [q.x, q.y]).collect();
|
||||
let n = out.v.len();
|
||||
out.prism_edges(&foot, z0, z1);
|
||||
lift(&mut out, n, &b.id);
|
||||
}
|
||||
}
|
||||
let trees = set(&a.trees);
|
||||
if !trees.is_empty() {
|
||||
let list = p.trees.as_deref().unwrap_or(&[]);
|
||||
|
||||
@@ -44,6 +44,7 @@ const REC_END_SPACES: f64 = 8.0;
|
||||
const REC_ROOF: f64 = 9.0;
|
||||
const REC_COLUMN: f64 = 10.0;
|
||||
const REC_END_COLUMNS: f64 = 11.0;
|
||||
const REC_BEAM: f64 = 27.0;
|
||||
const REC_CLASSIFICATION: f64 = 12.0;
|
||||
const REC_ZONE: f64 = 13.0;
|
||||
const REC_ATTACH: f64 = 14.0;
|
||||
@@ -1085,6 +1086,7 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
p.ceilings.iter().flatten().for_each(|x| push(format!("slab/{}", x.id), &x.ifc_global_id));
|
||||
p.roofs.iter().flatten().for_each(|x| push(format!("roof/{}", x.id), &x.ifc_global_id));
|
||||
p.columns.iter().flatten().for_each(|x| push(format!("column/{}", x.id), &x.ifc_global_id));
|
||||
p.beams.iter().flatten().for_each(|x| push(format!("beam/{}", x.id), &x.ifc_global_id));
|
||||
p.stairs.iter().flatten().for_each(|x| push(format!("stair/{}", x.id), &x.ifc_global_id));
|
||||
p.rooms.iter().flatten().for_each(|x| push(format!("space/{}", x.id), &x.ifc_global_id));
|
||||
p.extruded_solids.iter().flatten().for_each(|x| push(format!("extrusion/{}", x.id), &x.ifc_global_id));
|
||||
@@ -1832,6 +1834,38 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
f.nums(&[cid, cname]);
|
||||
w_psets(&mut f, &psets);
|
||||
}
|
||||
// ── [280] Träger → IfcBeam (Profil-Extrusion des Grundriss-Rechtecks über die Querschnittshöhe, Material = Bauteil;
|
||||
// Datensatz wie COLUMN, in derselben Materialzuordnung) ──────────────────────────────────────────────────
|
||||
for b in p.beams.as_deref().unwrap_or(&[]) {
|
||||
let footprint = b.footprint();
|
||||
let (zb, zt) = p.beam_vertical_extent(b);
|
||||
if footprint.len() < 4 || !(zt > zb) {
|
||||
continue;
|
||||
}
|
||||
let structure = structure_of(&b.floor_id);
|
||||
classified.push((format!("beam/{}", b.id), Kind::Column, b.category_code.clone()));
|
||||
let label = crate::plan::domains::column_label(&b.as_column(&p));
|
||||
let label = match b.profile_name.as_deref().map(str::trim).filter(|n| !n.is_empty()) {
|
||||
Some(n) => format!("{label} ({n})"),
|
||||
None => label,
|
||||
};
|
||||
let length = (b.end.x - b.start.x).hypot(b.end.y - b.start.y);
|
||||
let mut psets = vec![Pset { name: "Pset_BeamCommon", props: vec![ident("Reference", &label), ident("Span", &format!("{length:.3}"))] }];
|
||||
renovation_props(&p, &mut psets, "Pset_BeamCommon", b.renovation.as_ref());
|
||||
psets.extend(qto("Qto_BeamBaseQuantities", qty::beam_quantities(&footprint, length, zt - zb)));
|
||||
let (id, lab) = (f.str(&b.id), f.str(&label));
|
||||
f.nums(&[REC_BEAM, structure, id, lab]);
|
||||
w_pts(&mut f, &footprint);
|
||||
f.nums(&[zb - base_of(structure), zt - zb]);
|
||||
let comp = b.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(&[cid, cname]);
|
||||
w_psets(&mut f, &psets);
|
||||
}
|
||||
f.num(REC_END_COLUMNS);
|
||||
|
||||
// ── Bäume ([149]) → IfcGeographicElement (IFC2x3: IfcBuildingElementProxy), Netz Stamm + Krone ──
|
||||
|
||||
@@ -302,6 +302,23 @@ pub fn column_quantities(footprint: &[Vec2], length: f64) -> Vec<Qty> {
|
||||
]
|
||||
}
|
||||
|
||||
/// [280] Träger-Basismengen (`Qto_BeamBaseQuantities`): Länge der Achse, Querschnitt, Mantel, Oberfläche, Volumen;
|
||||
/// `footprint` = Grundriss-Rechteck, `height` = Querschnittshöhe.
|
||||
pub fn beam_quantities(footprint: &[Vec2], length: f64, height: f64) -> Vec<Qty> {
|
||||
let plan = ring_area(footprint);
|
||||
let cross = if length > 1e-9 { plan / length * height } else { 0.0 };
|
||||
let width = if length > 1e-9 { plan / length } else { 0.0 };
|
||||
let outer = 2.0 * (width + height) * length;
|
||||
vec![
|
||||
len("Length", length),
|
||||
area("CrossSectionArea", cross),
|
||||
area("OuterSurfaceArea", outer),
|
||||
area("NetSurfaceArea", outer + 2.0 * cross),
|
||||
vol("GrossVolume", cross * length),
|
||||
vol("NetVolume", cross * length),
|
||||
]
|
||||
}
|
||||
|
||||
/// [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).
|
||||
|
||||
@@ -383,6 +383,7 @@ pub fn selection_category_codes(p: &Project, sel: &SelectionMembers) -> Vec<Stri
|
||||
scan(&sel.room_ids, &mut p.rooms.iter().flatten().map(|o| (o.id.as_str(), o.category_code.as_str())));
|
||||
scan(&sel.stair_ids, &mut p.stairs.iter().flatten().map(|o| (o.id.as_str(), o.category_code.as_str())));
|
||||
scan(&sel.column_ids, &mut p.columns.iter().flatten().map(|o| (o.id.as_str(), o.category_code.as_str())));
|
||||
scan(&sel.column_ids, &mut p.beams.iter().flatten().map(|o| (o.id.as_str(), o.category_code.as_str())));
|
||||
scan(&sel.roof_ids, &mut p.roofs.iter().flatten().map(|o| (o.id.as_str(), o.category_code.as_str())));
|
||||
scan(&sel.opening_ids, &mut p.openings.iter().flatten().map(|o| (o.id.as_str(), o.category_code.as_str())));
|
||||
out
|
||||
|
||||
@@ -131,6 +131,8 @@ pub mod cmd_massing;
|
||||
pub mod cmd_draw;
|
||||
#[cfg(test)]
|
||||
mod cmd_autodim_tests;
|
||||
#[cfg(test)]
|
||||
mod beam_tests;
|
||||
pub mod cmd_solid;
|
||||
pub mod polyline_vertex;
|
||||
pub mod import_drawing;
|
||||
|
||||
@@ -470,7 +470,9 @@ pub(crate) fn collect_scene(src: &Project, opt: &MeshOptions) -> Result<SceneDat
|
||||
groups.push(g);
|
||||
}
|
||||
p.roofs = roofs;
|
||||
// [280] `emit_columns` liefert auch die Träger: je Gruppe nur das eine Element in `p` lassen.
|
||||
let columns = p.columns.take();
|
||||
let beams = p.beams.take();
|
||||
for col in columns.as_deref().unwrap_or(&[]) {
|
||||
let mut g = Group::new(format!("Stuetze_{}", sanitize_name(&col.id)), "column", &col.id, level_of(Some(&col.floor_id)));
|
||||
p.columns = Some(vec![col.clone()]);
|
||||
@@ -478,7 +480,16 @@ pub(crate) fn collect_scene(src: &Project, opt: &MeshOptions) -> Result<SceneDat
|
||||
add_meshes(&mut g, &mut mats, &model3d::emit_columns(&p), &name);
|
||||
groups.push(g);
|
||||
}
|
||||
p.columns = None;
|
||||
for b in beams.as_deref().unwrap_or(&[]) {
|
||||
let mut g = Group::new(format!("Traeger_{}", sanitize_name(&b.id)), "beam", &b.id, level_of(Some(&b.floor_id)));
|
||||
p.beams = Some(vec![b.clone()]);
|
||||
let name = component_name(&p, b.component_id.as_deref(), "Traeger");
|
||||
add_meshes(&mut g, &mut mats, &model3d::emit_columns(&p), &name);
|
||||
groups.push(g);
|
||||
}
|
||||
p.columns = columns;
|
||||
p.beams = beams;
|
||||
// [149] Bäume: je Baum eine Gruppe (Stamm + Krone).
|
||||
let trees = p.trees.take();
|
||||
for t in trees.as_deref().unwrap_or(&[]) {
|
||||
|
||||
@@ -5444,6 +5444,121 @@ pub struct Column {
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [280] Ein Träger/Unterzug (Beam) — geschossgebundenes Tragwerk-Bauteil (Kategorie „50"): Achse
|
||||
/// `start` → `end` im Grundriss, rechteckiger Querschnitt `width` × `height` (Aussenmasse; `profileName`
|
||||
/// ist nur ein Text wie „HEB 200", gezeichnet wird das Rechteck). Oberkante = Unterkante der Decke darüber
|
||||
/// (höchstens die Geschoss-Oberkante) plus `topOffset`; bündig (0) ⇒ Unterzug. Wird wie eine Stütze
|
||||
/// ausgewertet (`Beam::as_column`), liegt aber in `Project.beams`; im Auswahlkanal der Stützen.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct Beam {
|
||||
pub id: String,
|
||||
#[ts(type = "\"beam\"")]
|
||||
pub r#type: String,
|
||||
/// Zugehörige Zeichnungsebene (Geschoss).
|
||||
#[serde(rename = "floorId")]
|
||||
pub floor_id: String,
|
||||
/// Grafik-Kategorie (Ebene), z. B. "50" für Tragwerk.
|
||||
#[serde(rename = "categoryCode")]
|
||||
pub category_code: String,
|
||||
/// [201] IFC-GlobalId des Quell-Bauteils (IFC-Import); der IFC-Export schreibt sie zurück, damit
|
||||
/// die Rundreise dieselben GUIDs behält. Kopien (Einfügen, Kopieren, Reihe, Wand teilen) tragen sie NICHT.
|
||||
#[serde(rename = "ifcGlobalId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub ifc_global_id: Option<String>,
|
||||
/// Objekt-Sperre, analog `Wall.locked`.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub locked: Option<bool>,
|
||||
/// Achse: Anfangspunkt im Grundriss (Meter).
|
||||
pub start: Vec2,
|
||||
/// Achse: Endpunkt im Grundriss (Meter).
|
||||
pub end: Vec2,
|
||||
/// Querschnittsbreite (quer zur Achse, Meter, > 0).
|
||||
pub width: f64,
|
||||
/// Querschnittshöhe (Meter, > 0), nach unten ab der Oberkante.
|
||||
pub height: f64,
|
||||
/// Profilname als Text (z. B. „HEB 200", „BSH 20/40"); ohne Wirkung auf die Geometrie, geht in Liste und IFC.
|
||||
#[serde(rename = "profileName", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub profile_name: Option<String>,
|
||||
/// Versatz der Oberkante gegenüber der Unterkante der Decke darüber (Meter, + nach oben in die Decke).
|
||||
/// Fehlt ⇒ 0: bündig, Unterzug.
|
||||
#[serde(rename = "topOffset", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub top_offset: Option<f64>,
|
||||
/// Optionales tragendes Bauteil (Component) für Poché/3D-Farbe/Schraffur.
|
||||
#[serde(rename = "componentId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub component_id: Option<String>,
|
||||
/// Optionale Übersteuerung der Strich-/Umrandungsfarbe; sonst gilt die
|
||||
/// Kategorie-Farbe.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub color: Option<String>,
|
||||
/// Stift-Kopplung von `color` (s. `Component.colorPenId`-Doku).
|
||||
#[serde(rename = "colorPenId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub color_pen_id: Option<String>,
|
||||
/// Attribut-Override der Muster-/Schraffurfarbe (Vordergrund) DIESER Stütze.
|
||||
/// `undefined` = „Nach System" (erben → Component.foreground), analog `Wall.
|
||||
/// foreground`.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub foreground: Option<String>,
|
||||
/// Attribut-Override der Füllfarbe (Hintergrund/Poché) DIESER Stütze.
|
||||
/// `undefined` = „Nach System" (neutrale SIA-Poché HATCH_INK/HATCH_PAPER je
|
||||
/// nach Schraffur-Muster), analog `Wall.background`.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub background: Option<String>,
|
||||
/// Stift-Kopplung von `foreground` (s. `Component.foregroundPenId`-Doku).
|
||||
#[serde(rename = "foregroundPenId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub foreground_pen_id: Option<String>,
|
||||
/// Stift-Kopplung von `background`, analog {@link Wall.foregroundPenId}.
|
||||
#[serde(rename = "backgroundPenId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub background_pen_id: Option<String>,
|
||||
/// Attribut-Override der Strichstärke (mm Papier) DIESER Stütze. `undefined`
|
||||
/// = „Nach System" (erben → `strokeWeightSource`), analog `Wall.strokeWeight`.
|
||||
#[serde(rename = "strokeWeight", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub stroke_weight: Option<f64>,
|
||||
/// Attribut-Override der Schnitt-Schraffur (Hatch Manager) DIESER Stütze.
|
||||
/// `undefined` = „Nach System" (erben → `hatchSource`), analog `Wall.hatchId`.
|
||||
#[serde(rename = "hatchId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub hatch_id: Option<String>,
|
||||
/// Quelle des Vordergrunds, wenn kein explizites `foreground` gesetzt ist — analog `Wall.foregroundSource`.
|
||||
#[serde(rename = "foregroundSource", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub foreground_source: Option<AttributeSource>,
|
||||
/// Quelle des Hintergrunds, analog {@link Beam.foregroundSource}.
|
||||
#[serde(rename = "backgroundSource", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub background_source: Option<AttributeSource>,
|
||||
/// Quelle der Strichstärke, analog {@link Beam.foregroundSource}.
|
||||
#[serde(rename = "strokeWeightSource", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub stroke_weight_source: Option<AttributeSource>,
|
||||
/// Quelle der Schraffur, analog {@link Beam.foregroundSource}.
|
||||
#[serde(rename = "hatchSource", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub hatch_source: Option<AttributeSource>,
|
||||
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub renovation: Option<Renovation>,
|
||||
/// [272] Variante, zu der das Element gehört (`Project.designOptionSets`). Fehlt ⇒ Hauptmodell (immer sichtbar).
|
||||
#[serde(rename = "designOption", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub design_option: Option<DesignOptionRef>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// Kronenform eines Baums ([149]): Grundform der Silhouette (Schnitt/Ansicht), des 3D-Körpers und
|
||||
/// des Schattenwerfers.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
@@ -6997,6 +7112,10 @@ pub struct Project {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub columns: Option<Vec<Column>>,
|
||||
/// [280] Träger/Unterzüge, siehe {@link Beam}. Optional wie `columns`.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub beams: Option<Vec<Beam>>,
|
||||
/// Bäume ([149]) — eigene Objekte mit Stamm, Krone und Höhe, siehe {@link Tree}. Optional, damit
|
||||
/// bestehende Projekte ohne `trees` gültig bleiben (Default: leer behandeln).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
@@ -7896,6 +8015,12 @@ impl Project {
|
||||
None => Default::default(),
|
||||
};
|
||||
}
|
||||
"beams" => {
|
||||
self.beams = match v {
|
||||
Some(v) => <Option<Vec<Beam>>>::deserialize(v).map_err(|e| e.to_string())?,
|
||||
None => Default::default(),
|
||||
};
|
||||
}
|
||||
"trees" => {
|
||||
self.trees = match v {
|
||||
Some(v) => <Option<Vec<Tree>>>::deserialize(v).map_err(|e| e.to_string())?,
|
||||
|
||||
@@ -231,6 +231,21 @@ impl Project {
|
||||
heights::element(floor_base, self.resolve_anchor(c.bottom.as_ref()), self.resolve_anchor(c.top.as_ref()), c.height)
|
||||
}
|
||||
|
||||
/// [280] (UK, OK) eines Trägers (absolutes Z): Referenz ist die Unterkante der tiefsten Decke desselben
|
||||
/// Geschosses, die die Achsmitte überdeckt (nicht in einer Aussparung), sonst die Geschoss-Oberkante;
|
||||
/// dazu `topOffset` (Vorgabe 0 = bündig, Unterzug). UK = OK − Querschnittshöhe.
|
||||
pub fn beam_vertical_extent(&self, b: &Beam) -> (f64, f64) {
|
||||
let floor_top = self.floor(&b.floor_id).map_or(0.0, |f| f.base_elevation.unwrap_or(0.0) + f.floor_height.unwrap_or(0.0));
|
||||
let mid = kernel2d::Vec2::new((b.start.x + b.end.x) / 2.0, (b.start.y + b.end.y) / 2.0);
|
||||
let ring = |r: &[Vec2]| -> Vec<kernel2d::Vec2> { r.iter().map(|q| kernel2d::Vec2::new(q.x, q.y)).collect() };
|
||||
let under = self.ceilings.iter().flatten().filter(|c| c.floor_id == b.floor_id && c.outline.len() >= 3).filter_map(|c| {
|
||||
let (cb, ct) = self.ceiling_vertical_extent(c);
|
||||
let covers = (ct > cb) && kernel2d::point_in_outline(mid, &ring(&c.outline)) && !c.openings.iter().flatten().any(|h| h.len() >= 3 && kernel2d::point_in_outline(mid, &ring(h)));
|
||||
covers.then_some(cb)
|
||||
});
|
||||
heights::beam(floor_top, under, b.top_offset.unwrap_or(0.0), b.height)
|
||||
}
|
||||
|
||||
/// Traufhöhe (absolutes Z): `baseElevation`, sonst Oberkante des Geschosses (`roofBaseElevation`).
|
||||
pub fn roof_base_elevation(&self, r: &Roof) -> f64 {
|
||||
if let Some(b) = r.base_elevation {
|
||||
@@ -340,6 +355,14 @@ pub mod heights {
|
||||
(zb, top.unwrap_or(zb + height))
|
||||
}
|
||||
|
||||
/// [280] Träger: Referenz = tiefste Deckenunterkante `under` (der Decken, die die Achsmitte überdecken) unterhalb
|
||||
/// der Geschoss-Oberkante, sonst diese; OK = Referenz + Versatz, UK = OK − Querschnittshöhe.
|
||||
pub fn beam(floor_top: f64, under: impl IntoIterator<Item = f64>, top_offset: f64, height: f64) -> (f64, f64) {
|
||||
let reference = under.into_iter().filter(|z| z.is_finite()).fold(floor_top, f64::min);
|
||||
let top = reference + if top_offset.is_finite() { top_offset } else { 0.0 };
|
||||
(top - height, top)
|
||||
}
|
||||
|
||||
/// Decke: OK aus `top`, sonst Geschoss-Oberkante; UK aus `bottom`, sonst OK − Dicke (die Decke wächst
|
||||
/// nach unten; die Dicke wird nur dann bestimmt).
|
||||
pub fn ceiling(floor_top: f64, bottom: Option<f64>, top: Option<f64>, thickness: impl FnOnce() -> f64) -> (f64, f64) {
|
||||
@@ -362,6 +385,66 @@ pub mod heights {
|
||||
assert_eq!(ceiling(2.6, Some(2.2), None, || panic!("Dicke nicht gebraucht")), (2.2, 2.6));
|
||||
assert_eq!(ceiling(2.6, None, Some(3.0), || 0.2), (2.8, 3.0));
|
||||
assert_eq!(floor_anchor(2.8, 0.1), 2.8 + 0.1);
|
||||
// Träger: bündig an der tiefsten Deckenunterkante, Versatz nach oben.
|
||||
let near = |a: (f64, f64), b: (f64, f64)| (a.0 - b.0).abs() < 1e-9 && (a.1 - b.1).abs() < 1e-9;
|
||||
assert!(near(beam(2.6, [2.35, 2.5], 0.0, 0.4), (1.95, 2.35)));
|
||||
assert!(near(beam(2.6, [], 0.0, 0.4), (2.2, 2.6)));
|
||||
assert!(near(beam(2.6, [2.35], 0.1, 0.4), (2.05, 2.45)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Beam {
|
||||
/// [280] Grundriss-Rechteck des Trägers: Achse ± halbe Breite (leer bei Länge 0).
|
||||
pub fn footprint(&self) -> Vec<Vec2> {
|
||||
let (dx, dy) = (self.end.x - self.start.x, self.end.y - self.start.y);
|
||||
let l = dx.hypot(dy);
|
||||
if !(l > 1e-9) || !l.is_finite() {
|
||||
return Vec::new();
|
||||
}
|
||||
let (nx, ny) = (-dy / l * self.width / 2.0, dx / l * self.width / 2.0);
|
||||
vec![
|
||||
Vec2 { x: self.start.x + nx, y: self.start.y + ny },
|
||||
Vec2 { x: self.end.x + nx, y: self.end.y + ny },
|
||||
Vec2 { x: self.end.x - nx, y: self.end.y - ny },
|
||||
Vec2 { x: self.start.x - nx, y: self.start.y - ny },
|
||||
]
|
||||
}
|
||||
|
||||
/// [280] Der Träger als gleichwertige Stütze: Rechteck-Profil Länge × Breite um die Achsmitte, gedreht auf die
|
||||
/// Achsrichtung, Höhenlage als feste Anker. Alle Ableitungen (Grundriss, Schnitt, Ansicht, 3D, Griffe …)
|
||||
/// laufen so über den Stützen-Code; die Kennung bleibt die des Trägers.
|
||||
pub fn as_column(&self, p: &Project) -> Column {
|
||||
let (zb, zt) = p.beam_vertical_extent(self);
|
||||
let (dx, dy) = (self.end.x - self.start.x, self.end.y - self.start.y);
|
||||
Column {
|
||||
id: self.id.clone(),
|
||||
r#type: "beam".into(),
|
||||
floor_id: self.floor_id.clone(),
|
||||
category_code: self.category_code.clone(),
|
||||
locked: self.locked,
|
||||
position: Vec2 { x: (self.start.x + self.end.x) / 2.0, y: (self.start.y + self.end.y) / 2.0 },
|
||||
profile: ColumnProfile::Rect { width: dx.hypot(dy), depth: self.width },
|
||||
rotation: crate::jsnum::atan2(dy, dx),
|
||||
height: zt - zb,
|
||||
component_id: self.component_id.clone(),
|
||||
bottom: Some(VerticalAnchor::Custom { z: zb }),
|
||||
top: Some(VerticalAnchor::Custom { z: zt }),
|
||||
color: self.color.clone(),
|
||||
color_pen_id: self.color_pen_id.clone(),
|
||||
foreground: self.foreground.clone(),
|
||||
background: self.background.clone(),
|
||||
foreground_pen_id: self.foreground_pen_id.clone(),
|
||||
background_pen_id: self.background_pen_id.clone(),
|
||||
stroke_weight: self.stroke_weight,
|
||||
hatch_id: self.hatch_id.clone(),
|
||||
foreground_source: self.foreground_source.clone(),
|
||||
background_source: self.background_source.clone(),
|
||||
stroke_weight_source: self.stroke_weight_source.clone(),
|
||||
hatch_source: self.hatch_source.clone(),
|
||||
renovation: self.renovation.clone(),
|
||||
design_option: self.design_option.clone(),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ impl Project {
|
||||
"context" => put_opt(&mut self.context, i, v),
|
||||
"extrudedSolids" => put_opt(&mut self.extruded_solids, i, v),
|
||||
"columns" => put_opt(&mut self.columns, i, v),
|
||||
"beams" => put_opt(&mut self.beams, i, v),
|
||||
"trees" => put_opt(&mut self.trees, i, v),
|
||||
"cameras" => put_opt(&mut self.cameras, i, v),
|
||||
"groups" => put_opt(&mut self.groups, i, v),
|
||||
|
||||
@@ -31,6 +31,8 @@ pub enum Owner {
|
||||
None,
|
||||
Roof(usize),
|
||||
Column(usize),
|
||||
/// [280] Index in `Project::beams`.
|
||||
Beam(usize),
|
||||
Tree(usize),
|
||||
Stair(usize),
|
||||
Context(usize),
|
||||
@@ -48,6 +50,7 @@ impl Owner {
|
||||
Owner::None => None,
|
||||
Owner::Roof(i) => at(&p.roofs, i).map(|e| e.id.as_str()),
|
||||
Owner::Column(i) => at(&p.columns, i).map(|e| e.id.as_str()),
|
||||
Owner::Beam(i) => at(&p.beams, i).map(|e| e.id.as_str()),
|
||||
Owner::Tree(i) => at(&p.trees, i).map(|e| e.id.as_str()),
|
||||
Owner::Stair(i) => at(&p.stairs, i).map(|e| e.id.as_str()),
|
||||
Owner::Context(i) => at(&p.context, i).map(|e| e.id()),
|
||||
@@ -158,6 +161,9 @@ impl ClassFilter {
|
||||
for c in p.columns.as_deref().unwrap_or(&[]) {
|
||||
add(&c.category_code, &c.id, &c.floor_id);
|
||||
}
|
||||
for b in p.beams.as_deref().unwrap_or(&[]) {
|
||||
add(&b.category_code, &b.id, &b.floor_id);
|
||||
}
|
||||
for t in p.trees.as_deref().unwrap_or(&[]) {
|
||||
add(&t.category_code, &t.id, &t.floor_id);
|
||||
}
|
||||
@@ -190,6 +196,7 @@ impl ClassFilter {
|
||||
.chain(p.roofs.iter().flatten().map(|r| &r.id))
|
||||
.chain(p.stairs.iter().flatten().map(|s| &s.id))
|
||||
.chain(p.columns.iter().flatten().map(|c| &c.id))
|
||||
.chain(p.beams.iter().flatten().map(|c| &c.id))
|
||||
.chain(p.trees.iter().flatten().map(|t| &t.id))
|
||||
.chain(p.extruded_solids.iter().flatten().map(|s| &s.id))
|
||||
.chain(p.drawings2d.iter().map(|d| &d.id))
|
||||
|
||||
@@ -54,7 +54,8 @@ pub fn column_pieces(p: &Project, col: &Column) -> Vec<(Vec<Vec2>, f64, f64)> {
|
||||
let fp = column_footprint(col);
|
||||
let (zb, zt) = p.column_vertical_extent(col);
|
||||
let full = vec![(fp.clone(), zb, zt)];
|
||||
if fp.len() < 3 || !(zt > zb) {
|
||||
// [280] Träger (als Stütze, `type == "beam"`) lassen die Wände ganz.
|
||||
if fp.len() < 3 || !(zt > zb) || col.r#type == "beam" {
|
||||
return full;
|
||||
}
|
||||
let mut clips: Vec<(Vec<Vec2>, f64, f64)> = Vec::new();
|
||||
@@ -121,19 +122,26 @@ pub(super) fn column_mesh(p: &Project, col: &Column) -> Option<(Vec<f64>, Vec<u3
|
||||
(!m.is_empty()).then_some((m.positions, m.indices))
|
||||
}
|
||||
|
||||
/// [141] Stützen als lotrechte Prismen-Platten (Schnitt, Ansicht): je Höhenabschnitt der Querschnitt aus
|
||||
/// [`column_pieces`], Herkunft `SlabSource::Column`.
|
||||
/// [280] Träger als Stützen (Rechteck-Prisma über der Achse), mit Index in `Project::beams`.
|
||||
fn beam_columns(p: &Project) -> impl Iterator<Item = (usize, Column)> + '_ {
|
||||
p.beams.as_deref().unwrap_or(&[]).iter().enumerate().map(|(i, b)| (i, b.as_column(p)))
|
||||
}
|
||||
|
||||
/// [141] Stützen und [280] Träger als lotrechte Prismen-Platten (Schnitt, Ansicht): je Höhenabschnitt der
|
||||
/// Querschnitt aus [`column_pieces`], Herkunft `SlabSource::Column` bzw. `SlabSource::Beam`.
|
||||
pub fn column_slabs(p: &Project) -> Vec<RSlab> {
|
||||
let mut out = Vec::new();
|
||||
for (index, c) in p.columns.as_deref().unwrap_or(&[]).iter().enumerate() {
|
||||
let columns = p.columns.as_deref().unwrap_or(&[]).iter().enumerate().map(|(i, c)| (SlabSource::Column { index: i }, std::borrow::Cow::Borrowed(c)));
|
||||
let beams = beam_columns(p).map(|(i, c)| (SlabSource::Beam { index: i }, std::borrow::Cow::Owned(c)));
|
||||
for (source, c) in columns.chain(beams) {
|
||||
if !(c.height > 0.0) {
|
||||
continue;
|
||||
}
|
||||
let color = c.component_id.as_deref().and_then(|id| p.component(id)).map_or(COLUMN_RGB, |k| hex_to_rgb(&k.color, COLUMN_RGB));
|
||||
for (foot, z_bottom, z_top) in column_pieces(p, c) {
|
||||
for (foot, z_bottom, z_top) in column_pieces(p, &c) {
|
||||
let outline: Vec<RVec2> = foot.iter().map(|q| [q.x, q.y]).collect();
|
||||
if z_top - z_bottom > 1e-6 && outline.iter().flatten().all(|v| v.is_finite()) {
|
||||
out.push(RSlab { outline, z_bottom, z_top, color, ceiling_id: c.id.clone(), hatch: None, cut: None, monolith: None, source: SlabSource::Column { index } });
|
||||
out.push(RSlab { outline, z_bottom, z_top, color, ceiling_id: c.id.clone(), hatch: None, cut: None, monolith: None, source });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,6 +165,15 @@ pub fn emit_columns(p: &Project) -> Vec<RMesh> {
|
||||
let crease_angle = matches!(col.profile, ColumnProfile::Round { .. }).then_some(COLUMN_CREASE_DEG);
|
||||
out.push(RMesh { crease_angle, positions, indices, kind: "extrusion", color, vertex_colors: None, material_index: None, owner: Owner::Column(ci) });
|
||||
}
|
||||
// [280] Träger: Prisma über der Achse, Farbe des Bauteils.
|
||||
for (bi, col) in beam_columns(p) {
|
||||
if col.height <= 0.0 {
|
||||
continue;
|
||||
}
|
||||
let Some((positions, indices)) = column_mesh(p, &col) else { continue };
|
||||
let color = col.component_id.as_deref().and_then(|id| p.component(id)).map_or(COLUMN_RGB, |c| hex_to_rgb(&c.color, COLUMN_RGB));
|
||||
out.push(RMesh { crease_angle: None, positions, indices, kind: "extrusion", color, vertex_colors: None, material_index: None, owner: Owner::Beam(bi) });
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,8 @@ pub enum SlabSource {
|
||||
Stair { index: usize },
|
||||
/// [141] Index in `Project::columns` (Stützen-Prisma, je Höhenabschnitt von [`column_pieces`]).
|
||||
Column { index: usize },
|
||||
/// [280] Index in `Project::beams` (Träger-Prisma wie eine Stütze).
|
||||
Beam { index: usize },
|
||||
}
|
||||
|
||||
/// Ein rohes Dreiecks-Mesh (`RMesh`).
|
||||
|
||||
@@ -450,5 +450,16 @@ fn pick_columns(p: &Project) -> Vec<PickColumn> {
|
||||
out.push(PickColumn { tris, column_id: col.id.clone() });
|
||||
}
|
||||
}
|
||||
// [280] Träger
|
||||
for col in p.beams.iter().flatten().map(|b| b.as_column(p)) {
|
||||
if !(col.height > 0.0) {
|
||||
continue;
|
||||
}
|
||||
let Some((pos, idx)) = column_mesh(p, &col) else { continue };
|
||||
let tris = extrusion_tris(&pos, &idx);
|
||||
if !tris.is_empty() {
|
||||
out.push(PickColumn { tris, column_id: col.id.clone() });
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -233,6 +233,7 @@ pub fn rebake_ops(root: &Map<String, Value>) -> Vec<Value> {
|
||||
patch_items(root, "drawings2d", &|d| bake_color_weight(&a, d, "weightMm"), &mut ops);
|
||||
patch_items(root, "ceilings", &|c| bake_color_weight(&a, c, "strokeWeight"), &mut ops);
|
||||
patch_items(root, "columns", &|c| bake_color_weight(&a, c, "strokeWeight"), &mut ops);
|
||||
patch_items(root, "beams", &|c| bake_color_weight(&a, c, "strokeWeight"), &mut ops);
|
||||
for coll in ["roofs", "openings", "stairs", "rooms"] {
|
||||
patch_items(root, coll, &|x| bake_color(&a, x), &mut ops);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ pub const NOT_FOR_DRAWINGS: &[&str] = &[
|
||||
"rooms",
|
||||
"units",
|
||||
"columns",
|
||||
"beams",
|
||||
"trees",
|
||||
"cameras",
|
||||
"extrudedSolids",
|
||||
|
||||
@@ -1705,6 +1705,12 @@ pub fn room_stamp_spots(p: &Project, floor: &str, show: &HashSet<String>, scale:
|
||||
|
||||
/// `columnLabel` (für `object_name`).
|
||||
pub fn column_label(col: &Column) -> String {
|
||||
// [280] Träger (als Stütze ausgewertet): Breite × Höhe des Querschnitts.
|
||||
if col.r#type == "beam" {
|
||||
if let ColumnProfile::Rect { depth, .. } = &col.profile {
|
||||
return format!("Träger {}×{}", to_fixed(depth * 100.0, 0), to_fixed(col.height * 100.0, 0));
|
||||
}
|
||||
}
|
||||
match &col.profile {
|
||||
ColumnProfile::Round { radius } => format!("Stütze Ø{}", to_fixed(radius * 200.0, 0)),
|
||||
ColumnProfile::Rect { width, depth } => format!("Stütze {}×{}", to_fixed(width * 100.0, 0), to_fixed(depth * 100.0, 0)),
|
||||
@@ -1714,7 +1720,12 @@ pub fn column_label(col: &Column) -> String {
|
||||
pub(super) fn columns(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
let p = c.p;
|
||||
let range = super::view_range::ViewRange::of(p, &c.a.floor);
|
||||
for col in p.columns.as_deref().unwrap_or(&[]).iter().filter(|k| k.floor_id == c.a.floor && c.vis(&k.category_code, &k.id)) {
|
||||
// [280] Träger laufen als Stützen mit `type == "beam"` durch denselben Code (Rechteck um die Achsmitte).
|
||||
let beams = p.beams.as_deref().unwrap_or(&[]).iter().filter(|k| k.floor_id == c.a.floor && c.vis(&k.category_code, &k.id)).map(|b| std::borrow::Cow::Owned(b.as_column(p)));
|
||||
let cols = p.columns.as_deref().unwrap_or(&[]).iter().filter(|k| k.floor_id == c.a.floor && c.vis(&k.category_code, &k.id)).map(std::borrow::Cow::Borrowed);
|
||||
for col in cols.chain(beams) {
|
||||
let col: &Column = &col;
|
||||
let is_beam = col.r#type == "beam";
|
||||
let (zb, zt) = p.column_vertical_extent(col);
|
||||
let zone = range.classify(zb, zt);
|
||||
if zone == super::view_range::Zone::Hidden {
|
||||
@@ -1723,7 +1734,7 @@ pub(super) fn columns(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
let out_start = out.len();
|
||||
let greyed = Some(c.greyed(&col.category_code));
|
||||
let category = c.cat(&col.category_code);
|
||||
let ov = c.overrides(Some("column"), &col.category_code, Some(&column_label(col)));
|
||||
let ov = c.overrides(Some(if is_beam { "beam" } else { "column" }), &col.category_code, Some(&column_label(col)));
|
||||
let lw = ov.lineweight.unwrap_or_else(|| resolve_stroke_weight(col.stroke_weight, col.stroke_weight_source, category, category.map_or(WALL_FALLBACK_MM, |k| k.lw)));
|
||||
let color = ov.color.as_deref().or(col.color.as_deref());
|
||||
let cat_color = category.map(|k| k.color.as_str());
|
||||
@@ -1767,15 +1778,37 @@ pub(super) fn columns(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
for i in 0..n {
|
||||
out.push(line(fp[i], fp[(i + 1) % n], "column-view", LAYER_JOINT_MM * c.a.detail.layer_factor(), None, stroke, greyed));
|
||||
}
|
||||
if let Some(d) = range.restyle_dash(zone) {
|
||||
// [280] Träger über der Schnitthöhe (Unterzug) immer gestrichelt, dazu die Achse als Strichpunktlinie.
|
||||
let dash = if is_beam && zone == super::view_range::Zone::Above { Some(&super::view_range::ABOVE_DASH[..]) } else { range.restyle_dash(zone) };
|
||||
if let Some(d) = dash {
|
||||
super::view_range::restyle(out, out_start, d);
|
||||
}
|
||||
if is_beam {
|
||||
if let ColumnProfile::Rect { width: len, .. } = &col.profile {
|
||||
let (ux, uy) = (crate::jsnum::cos(col.rotation), crate::jsnum::sin(col.rotation));
|
||||
out.push(Primitive::Line {
|
||||
a: Vec2 { x: col.position.x - ux * len / 2.0, y: col.position.y - uy * len / 2.0 },
|
||||
b: Vec2 { x: col.position.x + ux * len / 2.0, y: col.position.y + uy * len / 2.0 },
|
||||
cls: "beam-axis".into(),
|
||||
weight_mm: lw * 0.5,
|
||||
dash: Some(Some(super::line_pattern::AXIS.to_vec())),
|
||||
zigzag: None,
|
||||
motif: None,
|
||||
color: Some(stroke.to_string().into()),
|
||||
drawing_id: None,
|
||||
opening_id: None,
|
||||
stair_id: None,
|
||||
greyed,
|
||||
opacity: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// [141] Geschnittene Wände, die in der (geschnittenen) Stütze enden: prioritärere Wand beschneidet
|
||||
// die Stütze, gleiches Bauteil verschmilzt (Kontur über diesen Schichten fehlt).
|
||||
let (mut clip, mut merge): (Vec<Vec<Vec2>>, Vec<crate::plan::wall_poche::WallFootprint>) = (Vec::new(), Vec::new());
|
||||
if zone == super::view_range::Zone::Cut {
|
||||
if zone == super::view_range::Zone::Cut && !is_beam {
|
||||
use super::wall_columns::{band_polys, relation, wall_meets_column, Rel};
|
||||
for w in p.walls.iter().filter(|w| w.floor_id == c.a.floor && c.vis(&w.category_code, &w.id)) {
|
||||
let (zb, zt) = p.wall_vertical_extent(w);
|
||||
|
||||
@@ -1508,6 +1508,9 @@ fn renovation_layers(cx: &mut Ctx, cats: &[&LayerCategory]) -> HashMap<String, S
|
||||
for c in p.columns.iter().flatten() {
|
||||
items.push((&c.id, &c.category_code, crate::renovation::status_of(c.renovation.as_ref())));
|
||||
}
|
||||
for c in p.beams.iter().flatten() {
|
||||
items.push((&c.id, &c.category_code, crate::renovation::status_of(c.renovation.as_ref())));
|
||||
}
|
||||
for o in p.openings.iter().flatten() {
|
||||
items.push((&o.id, &o.category_code, crate::renovation::status_of(crate::renovation::opening_renovation(p, o))));
|
||||
}
|
||||
@@ -1531,7 +1534,8 @@ fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code:
|
||||
// 2) Rückverweise Primitiv → Kategorie.
|
||||
let code_by_wall: HashMap<&str, &str> = project.walls.iter().map(|w| (w.id.as_str(), w.category_code.as_str())).collect();
|
||||
let code_by_drawing: HashMap<&str, &str> = project.drawings2d.iter().map(|d| (d.id.as_str(), d.category_code.as_str())).collect();
|
||||
let code_by_column: HashMap<&str, &str> = project.columns.iter().flatten().map(|c| (c.id.as_str(), c.category_code.as_str())).collect();
|
||||
// [280] Träger tragen im Plan ihre Kennung als `column_id`.
|
||||
let code_by_column: HashMap<&str, &str> = project.columns.iter().flatten().map(|c| (c.id.as_str(), c.category_code.as_str())).chain(project.beams.iter().flatten().map(|c| (c.id.as_str(), c.category_code.as_str()))).collect();
|
||||
let code_by_room: HashMap<&str, &str> = project.rooms.iter().flatten().map(|r| (r.id.as_str(), r.category_code.as_str())).collect();
|
||||
let layer_of_code = |m: &HashMap<&str, &str>, id: &str| -> Option<String> { layer_by_code.get(m.get(id).copied().unwrap_or("")).cloned() };
|
||||
let drawing_layer = |id: Option<&String>, fallback: &str| -> String {
|
||||
|
||||
@@ -155,7 +155,11 @@ pub(super) fn face_overrides(p: &Project, faces: &mut [Face], v: RuleView) {
|
||||
let layers = p.roof_layers(r);
|
||||
surf_ov(p, v, "roof", &r.category_code, None, &layers, Some(0))
|
||||
}),
|
||||
Role::Column => p.columns.as_deref().unwrap_or(&[]).iter().find(|c| c.id == id).and_then(|c| surf_ov(p, v, "column", &c.category_code, Some(&super::super::domains::column_label(c)), &[], None)),
|
||||
Role::Column => match p.columns.as_deref().unwrap_or(&[]).iter().find(|c| c.id == id) {
|
||||
Some(c) => surf_ov(p, v, "column", &c.category_code, Some(&super::super::domains::column_label(c)), &[], None),
|
||||
// [280] Träger
|
||||
None => p.beams.as_deref().unwrap_or(&[]).iter().find(|b| b.id == id).and_then(|b| surf_ov(p, v, "beam", &b.category_code, Some(&super::super::domains::column_label(&b.as_column(p))), &[], None)),
|
||||
},
|
||||
Role::Mesh => p.context.as_deref().unwrap_or(&[]).iter().find_map(|c| match c {
|
||||
ContextObject::ImportedMesh(m) if m.id == id => Some(m),
|
||||
_ => None,
|
||||
|
||||
@@ -265,6 +265,9 @@ pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, m
|
||||
for c in p.columns.as_deref().unwrap_or(&[]) {
|
||||
col_cat.entry(c.id.as_str()).or_insert(c.category_code.as_str());
|
||||
}
|
||||
for b in p.beams.as_deref().unwrap_or(&[]) {
|
||||
col_cat.entry(b.id.as_str()).or_insert(b.category_code.as_str());
|
||||
}
|
||||
let mut mesh_cat: HashMap<&str, &str> = HashMap::new();
|
||||
for c in p.context.as_deref().unwrap_or(&[]) {
|
||||
match c {
|
||||
|
||||
@@ -422,7 +422,9 @@ pub fn subtract_voids(prims: Vec<Primitive>, p: &Project, cut_z: f64) -> Vec<Pri
|
||||
}
|
||||
// Maps wie in TS: bei doppelter id gewinnt der letzte Eintrag.
|
||||
let ceilings: HashMap<&str, &Ceiling> = p.ceilings.as_deref().unwrap_or(&[]).iter().map(|c| (c.id.as_str(), c)).collect();
|
||||
let columns: HashMap<&str, &Column> = p.columns.as_deref().unwrap_or(&[]).iter().map(|c| (c.id.as_str(), c)).collect();
|
||||
// [280] Träger als Stützen (virtuell).
|
||||
let beam_cols: Vec<Column> = p.beams.as_deref().unwrap_or(&[]).iter().map(|b| b.as_column(p)).collect();
|
||||
let columns: HashMap<&str, &Column> = p.columns.as_deref().unwrap_or(&[]).iter().chain(beam_cols.iter()).map(|c| (c.id.as_str(), c)).collect();
|
||||
let ring_of = |pts: &[Vec2]| -> Vec<[f64; 2]> { pts.iter().map(|q| [q.x, q.y]).collect() };
|
||||
// [G1] Abzugskörper beliebiger Form: Grundriss des Körpers im Höhenbereich des Bauteils.
|
||||
let cutters_for = |z0: f64, z1: f64| -> Vec<CutPoly> {
|
||||
|
||||
@@ -159,6 +159,15 @@ fn component_occluders(c: &Ctx, range: &ViewRange, out: &mut Vec<crate::hlr::Fac
|
||||
out.extend(occluder(&ring, d));
|
||||
}
|
||||
}
|
||||
// [280] Träger verdecken die Aufsicht importierter Netze wie Stützen.
|
||||
for b in p.beams.as_deref().unwrap_or(&[]).iter().filter(|k| k.floor_id == c.a.floor && c.vis(&k.category_code, &k.id)) {
|
||||
let col = b.as_column(p);
|
||||
let (zb, zt) = p.column_vertical_extent(&col);
|
||||
if let Some(d) = depth(zb, zt) {
|
||||
let ring: Vec<[f64; 2]> = crate::model3d::column_footprint(&col).iter().map(|q| [q.x, q.y]).collect();
|
||||
out.extend(occluder(&ring, d));
|
||||
}
|
||||
}
|
||||
for ce in p.ceilings.as_deref().unwrap_or(&[]).iter().filter(|x| c.vis(&x.category_code, &x.id)) {
|
||||
let (zb, zt) = p.ceiling_vertical_extent(ce);
|
||||
let zone = range.classify(zb, zt);
|
||||
|
||||
@@ -350,6 +350,11 @@ pub fn hidden_elements(p: &Project, v: RuleView) -> HashSet<String> {
|
||||
out.insert(c.id.clone());
|
||||
}
|
||||
}
|
||||
for b in p.beams.iter().flatten() {
|
||||
if test("beam", &b.category_code, Some(&super::domains::column_label(&b.as_column(p)))) {
|
||||
out.insert(b.id.clone());
|
||||
}
|
||||
}
|
||||
for r in p.rooms.iter().flatten() {
|
||||
if test("room", &r.category_code, Some(&r.name)) {
|
||||
out.insert(r.id.clone());
|
||||
|
||||
@@ -126,6 +126,8 @@ pub enum SlabOwner<'a> {
|
||||
Ceiling(&'a Ceiling, Option<usize>),
|
||||
Stair(&'a Stair),
|
||||
Column(&'a Column),
|
||||
/// [280] Träger.
|
||||
Beam(&'a Beam),
|
||||
}
|
||||
|
||||
/// Je emittierter Platte (Deckenschicht, Treppentritt, Podest) ihre Herkunft (`RSlab::source`).
|
||||
@@ -138,6 +140,7 @@ pub fn slab_owners<'a>(p: &'a Project, slabs: &[RSlab]) -> Vec<SlabOwner<'a>> {
|
||||
SlabSource::Ceiling { index, layer } => ceilings.get(index).map_or(SlabOwner::None, |c| SlabOwner::Ceiling(c, layer)),
|
||||
SlabSource::Stair { index } => stairs.get(index).map_or(SlabOwner::None, SlabOwner::Stair),
|
||||
SlabSource::Column { index } => p.columns.as_deref().and_then(|c| c.get(index)).map_or(SlabOwner::None, SlabOwner::Column),
|
||||
SlabSource::Beam { index } => p.beams.as_deref().and_then(|c| c.get(index)).map_or(SlabOwner::None, SlabOwner::Beam),
|
||||
SlabSource::None => SlabOwner::None,
|
||||
})
|
||||
.collect()
|
||||
@@ -685,14 +688,20 @@ pub(super) fn attach_cut_styles(cuts: Vec<Cut>, p: &Project, plane: &Plane, wall
|
||||
cp.category = Some(st.category_code.clone());
|
||||
}
|
||||
// [141] Stütze: Stil und Rang ihres Bauteils (wie im Grundriss); ohne Bauteil dominiert sie.
|
||||
SlabOwner::Column(c) => {
|
||||
cp.source_id = Some(c.id.clone());
|
||||
cp.category = Some(c.category_code.clone());
|
||||
let comp = c.component_id.as_deref().filter(|s| !s.is_empty()).and_then(|id| p.component(id));
|
||||
// [280] Träger genauso (eigene Felder, gleiche Auflösung).
|
||||
o @ (SlabOwner::Column(_) | SlabOwner::Beam(_)) => {
|
||||
let (id, code, component_id, hatch_id, hatch_source, foreground, foreground_source) = match o {
|
||||
SlabOwner::Column(c) => (&c.id, &c.category_code, &c.component_id, &c.hatch_id, c.hatch_source, &c.foreground, c.foreground_source),
|
||||
SlabOwner::Beam(c) => (&c.id, &c.category_code, &c.component_id, &c.hatch_id, c.hatch_source, &c.foreground, c.foreground_source),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
cp.source_id = Some(id.clone());
|
||||
cp.category = Some(code.clone());
|
||||
let comp = component_id.as_deref().filter(|s| !s.is_empty()).and_then(|id| p.component(id));
|
||||
if let Some(k) = comp {
|
||||
let category = p.layer_category(&c.category_code);
|
||||
let hid = resolve_hatch_id(c.hatch_id.as_deref(), c.hatch_source, category, Some(&k.hatch_id)).unwrap_or(&k.hatch_id);
|
||||
if let Some(h) = resolve_hatch(p, hid, None, resolve_foreground(k, c.foreground.as_deref(), category, c.foreground_source), None) {
|
||||
let category = p.layer_category(code);
|
||||
let hid = resolve_hatch_id(hatch_id.as_deref(), hatch_source, category, Some(&k.hatch_id)).unwrap_or(&k.hatch_id);
|
||||
if let Some(h) = resolve_hatch(p, hid, None, resolve_foreground(k, foreground.as_deref(), category, foreground_source), None) {
|
||||
cp.fill = Some(poche_fill(h.pattern).to_string());
|
||||
cp.hatch = Some(h);
|
||||
}
|
||||
|
||||
@@ -602,6 +602,7 @@ pub(crate) fn edge_categories(p: &Project, walls: &[Option<&Wall>], slabs: &[ban
|
||||
bands::SlabOwner::Ceiling(c, _) => &c.category_code,
|
||||
bands::SlabOwner::Stair(st) => &st.category_code,
|
||||
bands::SlabOwner::Column(c) => &c.category_code,
|
||||
bands::SlabOwner::Beam(c) => &c.category_code,
|
||||
bands::SlabOwner::None => continue,
|
||||
};
|
||||
m.insert((Kind::Slab, i), code.clone());
|
||||
@@ -628,6 +629,7 @@ pub(crate) fn edge_ids(p: &Project, walls: &[Option<&Wall>], slabs: &[bands::Sla
|
||||
bands::SlabOwner::Ceiling(c, _) => &c.id,
|
||||
bands::SlabOwner::Stair(st) => &st.id,
|
||||
bands::SlabOwner::Column(c) => &c.id,
|
||||
bands::SlabOwner::Beam(c) => &c.id,
|
||||
bands::SlabOwner::None => continue,
|
||||
};
|
||||
m.insert((Kind::Slab, i), id.clone());
|
||||
|
||||
@@ -329,7 +329,7 @@ impl<'a> SectionMv<'a> {
|
||||
pos.get(li).copied()
|
||||
})
|
||||
.collect();
|
||||
let columns = p.columns.as_deref().unwrap_or(&[]).iter().map(|c| c.id.clone()).collect();
|
||||
let columns = p.columns.as_deref().unwrap_or(&[]).iter().map(|c| c.id.clone()).chain(p.beams.iter().flatten().map(|b| b.id.clone())).collect();
|
||||
SectionMv { o, layer_pos, columns }
|
||||
}
|
||||
|
||||
|
||||
@@ -348,6 +348,7 @@ pub(crate) fn model_view_faces(p: &Project, vis: &Visibility, view: &dyn Fn([f64
|
||||
Some(SlabOwner::Ceiling(c, _)) => (Some(c.id.clone()), false, false),
|
||||
Some(SlabOwner::Stair(s)) => (Some(s.id.clone()), true, false),
|
||||
Some(SlabOwner::Column(c)) => (Some(c.id.clone()), false, true),
|
||||
Some(SlabOwner::Beam(c)) => (Some(c.id.clone()), false, true),
|
||||
_ => (None, false, false),
|
||||
},
|
||||
Kind::Roof => (roofs.get(i).map(|r| r.id.clone()), false, false),
|
||||
|
||||
@@ -15,12 +15,12 @@ const REQUIRED_ARRAYS: [&str; 3] = ["walls", "layers", "drawingLevels"];
|
||||
const DEFAULT_ARRAYS: [&str; 5] = ["lineStyles", "hatches", "components", "wallTypes", "drawings2d"];
|
||||
|
||||
/// Bekannte Felder von `Project` (für die Meldung unbekannter Felder).
|
||||
const KNOWN_KEYS: [&str; 63] = [
|
||||
const KNOWN_KEYS: [&str; 64] = [
|
||||
"formatVersion", "id", "name", "lineStyles", "textStyles", "hatches", "components", "wallTypes",
|
||||
"ceilingTypes", "roofTypes", "blockDefs", "doorTypes", "windowTypes", "stairTypes", "pens",
|
||||
"penSets", "activePenSetId", "customPalettes", "builtinPaletteBanks", "drawingLevels", "layers",
|
||||
"walls", "ceilings", "roofs", "openings", "stairs", "rooms", "drawings2d", "context",
|
||||
"extrudedSolids", "columns", "groups", "parametricWalls", "overrideRules", "viewSnapshots",
|
||||
"extrudedSolids", "columns", "beams", "groups", "parametricWalls", "overrideRules", "viewSnapshots",
|
||||
"viewSnapshotFolders", "viewTemplates", "layouts", "masterLayouts", "layoutFolders", "publishSets", "publishLog", "projectNumber", "competition", "referenceElevationMasl",
|
||||
"geoAnchor", "roomProgram", "roomProgramTolerance", "parcelArea", "sunStudy", "siteRules", "scaleLineWeights",
|
||||
"lineCap", "lineJoin", "trees", "uiState",
|
||||
|
||||
@@ -96,6 +96,11 @@ pub fn dangling_refs(p: &Project) -> Vec<String> {
|
||||
miss(&mut out, "Stütze", &c.id, "Bauteil", c.component_id.as_deref().unwrap_or(""), &components);
|
||||
miss(&mut out, "Stütze", &c.id, "Schraffur", c.hatch_id.as_deref().unwrap_or(""), &hatches);
|
||||
}
|
||||
for c in p.beams.as_deref().unwrap_or(&[]) {
|
||||
miss(&mut out, "Träger", &c.id, "Geschoss", &c.floor_id, &levels);
|
||||
miss(&mut out, "Träger", &c.id, "Bauteil", c.component_id.as_deref().unwrap_or(""), &components);
|
||||
miss(&mut out, "Träger", &c.id, "Schraffur", c.hatch_id.as_deref().unwrap_or(""), &hatches);
|
||||
}
|
||||
for r in p.rooms.as_deref().unwrap_or(&[]) {
|
||||
miss(&mut out, "Raum", &r.id, "Geschoss", &r.floor_id, &levels);
|
||||
}
|
||||
@@ -172,7 +177,7 @@ pub fn dangling_refs(p: &Project) -> Vec<String> {
|
||||
("Decke", ids(p.ceilings.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
("Raum", ids(p.rooms.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
("Treppe", ids(p.stairs.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
("Stütze", ids(p.columns.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
("Stütze", ids(p.columns.as_deref().unwrap_or(&[]), |x| x.id.as_str()).into_iter().chain(ids(p.beams.as_deref().unwrap_or(&[]), |x| x.id.as_str())).collect()),
|
||||
("Dach", ids(p.roofs.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
("Öffnung", ids(p.openings.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
("Baum", ids(p.trees.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
|
||||
|
||||
@@ -472,6 +472,9 @@ impl View {
|
||||
for x in p.columns.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), out);
|
||||
}
|
||||
for x in p.beams.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), out);
|
||||
}
|
||||
for x in p.extruded_solids.iter().flatten() {
|
||||
put(&x.id, self.treat(x.renovation.as_ref()), out);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Export-Scope „nur Auswahl" ([K4] S3, vorher `filterProjectToSelection` in `src/state/exportScope.ts`):
|
||||
//! die Listen der acht Elementarten auf die ausgewählten ids kürzen (jede Art ohne Eintrag wird leer);
|
||||
//! die Listen der Elementarten auf die ausgewählten ids kürzen (jede Art ohne Eintrag wird leer);
|
||||
//! Bibliotheken, Ebenen und Geschosse bleiben, damit id-Verweise weiter auflösen. Liefert die gekürzten
|
||||
//! Listen als Patch für `{...project, ...patch}`.
|
||||
|
||||
@@ -8,13 +8,15 @@ use serde_json::{Map, Value};
|
||||
use std::collections::HashSet;
|
||||
|
||||
/// Projekt-Liste → (Mitglieds-ids der Art).
|
||||
const KINDS: [(&str, &str); 8] = [
|
||||
const KINDS: [(&str, &str); 9] = [
|
||||
("walls", "wallIds"),
|
||||
("drawings2d", "drawingIds"),
|
||||
("ceilings", "ceilingIds"),
|
||||
("rooms", "roomIds"),
|
||||
("stairs", "stairIds"),
|
||||
("columns", "columnIds"),
|
||||
// [280] Träger liegen im Auswahlkanal der Stützen.
|
||||
("beams", "columnIds"),
|
||||
("roofs", "roofIds"),
|
||||
("openings", "openingIds"),
|
||||
];
|
||||
@@ -53,7 +55,7 @@ mod tests {
|
||||
assert_eq!(p["rooms"], json!([]));
|
||||
assert_eq!(p["drawings2d"], json!([]));
|
||||
assert_eq!(p["roofs"], json!([]));
|
||||
assert_eq!(p.len(), 8);
|
||||
assert_eq!(p.len(), 9);
|
||||
assert!(p.get("layers").is_none());
|
||||
}
|
||||
}
|
||||
@@ -430,7 +430,11 @@ pub fn derive(lk: &Lookup, a: &SelArgs) -> Result<J, String> {
|
||||
return Ok(lk.find("extrudedSolids", i).map_or(J::null(), |s| solid_selection(root, s)));
|
||||
}
|
||||
if let Some(i) = id(&a.column_id) {
|
||||
return lk.find("columns", i).map_or(Ok(J::null()), |c| column_selection(root, c));
|
||||
if let Some(c) = lk.find("columns", i) {
|
||||
return column_selection(root, c);
|
||||
}
|
||||
// [280] Träger liegen im Auswahlkanal der Stützen.
|
||||
return lk.find("beams", i).map_or(Ok(J::null()), |b| beam_selection(root, b));
|
||||
}
|
||||
if let Some(i) = id(&a.opening_id) {
|
||||
if let Some(o) = lk.find("openings", i) {
|
||||
@@ -1121,6 +1125,72 @@ fn column_selection(root: &Map<String, Value>, c: &Value) -> Result<J, String> {
|
||||
.done())
|
||||
}
|
||||
|
||||
/// [280] (UK, OK) eines Trägers aus der rohen Wurzel (wie `Project::beam_vertical_extent`).
|
||||
fn beam_extent(root: &Map<String, Value>, b: &Value) -> (f64, f64) {
|
||||
let floor_top = level(root, field(b, "floorId")).map_or(0.0, |f| num_or(field(f, "baseElevation"), 0.0) + num_or(field(f, "floorHeight"), 0.0));
|
||||
let (s, e) = (xy(field(b, "start").unwrap_or(&Value::Null)), xy(field(b, "end").unwrap_or(&Value::Null)));
|
||||
let mid = kernel2d::Vec2::new((s.0 + e.0) / 2.0, (s.1 + e.1) / 2.0);
|
||||
let ring = |v: Option<&Value>| -> Vec<kernel2d::Vec2> { pts_of(v).into_iter().map(|(x, y)| kernel2d::Vec2::new(x, y)).collect() };
|
||||
let under = arr(root.get("ceilings")).iter().filter(|c| field(c, "floorId") == field(b, "floorId")).filter_map(|c| {
|
||||
let outline = ring(field(c, "outline"));
|
||||
let (cb, ct) = ceiling_extent(root, c, ceiling_thickness(root, c));
|
||||
let in_hole = arr(field(c, "openings")).iter().any(|h| h.as_array().is_some_and(|a| a.len() >= 3) && kernel2d::point_in_outline(mid, &ring(Some(h))));
|
||||
(outline.len() >= 3 && ct > cb && kernel2d::point_in_outline(mid, &outline) && !in_hole).then_some(cb)
|
||||
});
|
||||
heights::beam(floor_top, under, num_or(field(b, "topOffset"), 0.0), num_of(field(b, "height")))
|
||||
}
|
||||
|
||||
fn beam_selection(root: &Map<String, Value>, b: &Value) -> Result<J, String> {
|
||||
let floor = level(root, field(b, "floorId"));
|
||||
let cat = category(root, field(b, "categoryCode"));
|
||||
let typed: crate::model::Beam = serde_json::from_value(b.clone()).map_err(|e| format!("Träger passt nicht zum Kern-Modell: {e}"))?;
|
||||
let bb = bbox_of(typed.footprint().into_iter().map(|p| (p.x, p.y)));
|
||||
let (zb, zt) = beam_extent(root, b);
|
||||
let (dx, dy) = (typed.end.x - typed.start.x, typed.end.y - typed.start.y);
|
||||
let info = O::default()
|
||||
.raw("width", b, "width")
|
||||
.raw("height", b, "height")
|
||||
.v("profileName", nn(field(b, "profileName")).cloned().unwrap_or(Value::Null))
|
||||
.n("topOffset", num_or(field(b, "topOffset"), 0.0))
|
||||
.n("length", dx.hypot(dy))
|
||||
.raw("floorId", b, "floorId")
|
||||
.o("floorName", floor_name(floor, field(b, "floorId")))
|
||||
.n("zBottom", zb)
|
||||
.n("zTop", zt)
|
||||
.done();
|
||||
let comp = if truthy(field(b, "componentId")) { find_by(arr(root.get("components")), "id", field(b, "componentId")) } else { None };
|
||||
let (fg, bg, hatch) = effective(b, comp, cat);
|
||||
let weight = match nn(field(b, "strokeWeight")) {
|
||||
Some(w) => w.clone(),
|
||||
None if is_layer(field(b, "strokeWeightSource")) => cat.and_then(|k| nn(field(k, "lw"))).cloned().unwrap_or_else(|| js_num(WALL_FALLBACK_MM)),
|
||||
None => js_num(WALL_FALLBACK_MM),
|
||||
};
|
||||
Ok(O::default()
|
||||
.s("kind", "beam")
|
||||
.raw("id", b, "id")
|
||||
.raw("categoryCode", b, "categoryCode")
|
||||
.raw("floorId", b, "floorId")
|
||||
.v("color", color_of(b, cat, COLUMN_COLOR))
|
||||
.raw("colorPenId", b, "colorPenId")
|
||||
.v("weightMm", weight)
|
||||
.raw("fillHatchId", b, "hatchId")
|
||||
.raw("foreground", b, "foreground")
|
||||
.raw("foregroundPenId", b, "foregroundPenId")
|
||||
.raw("background", b, "background")
|
||||
.raw("backgroundPenId", b, "backgroundPenId")
|
||||
.raw("foregroundSource", b, "foregroundSource")
|
||||
.raw("backgroundSource", b, "backgroundSource")
|
||||
.o("effectiveForeground", fg)
|
||||
.o("effectiveBackground", bg)
|
||||
.o("effectiveHatchId", hatch)
|
||||
.raw("strokeWeightOverride", b, "strokeWeight")
|
||||
.raw("strokeWeightSource", b, "strokeWeightSource")
|
||||
.raw("hatchSource", b, "hatchSource")
|
||||
.v("bbox", bbox_value(bb))
|
||||
.v("beam", info)
|
||||
.done())
|
||||
}
|
||||
|
||||
fn context_selection(root: &Map<String, Value>, o: &Value) -> J {
|
||||
let kind = str_of(field(o, "type"));
|
||||
let mut pts: Vec<(f64, f64)> = Vec::new();
|
||||
|
||||
@@ -298,6 +298,7 @@ fn candidate_codes(p: &Project) -> HashSet<String> {
|
||||
// [115] Freie Körper und Stützen ebenso.
|
||||
codes.extend(p.extruded_solids.iter().flatten().map(|e| e.category_code.clone()));
|
||||
codes.extend(p.columns.iter().flatten().map(|e| e.category_code.clone()));
|
||||
codes.extend(p.beams.iter().flatten().map(|e| e.category_code.clone()));
|
||||
codes
|
||||
}
|
||||
|
||||
|
||||
@@ -206,6 +206,12 @@ pub fn collect_model_at(p: &Project, level: &str, codes: &HashSet<String>, skip:
|
||||
ColumnProfile::Round { radius } => circles.push(Circle { cx: col.position.x, cy: col.position.y, r: radius, arc: None }),
|
||||
}
|
||||
}
|
||||
// [280] Träger: Rechteck um die Achse (Fang an Ecken und Kanten).
|
||||
for b in p.beams.as_deref().unwrap_or(&[]) {
|
||||
if vis_el(&b.id, &b.floor_id, &b.category_code) {
|
||||
closed_poly(&crate::model3d::column_footprint(&b.as_column(p)), &mut segs);
|
||||
}
|
||||
}
|
||||
circles.extend(stair_arcs);
|
||||
for r in p.rooms.as_deref().unwrap_or(&[]) {
|
||||
if vis_el(&r.id, &r.floor_id, &r.category_code) && r.boundary.len() >= 3 {
|
||||
|
||||
@@ -1065,6 +1065,13 @@ fn collect(p: &Project, k: [f64; 2], cut: Option<f64>, ground: Option<&Ground>)
|
||||
let footprint = crate::model3d::column_footprint(c).iter().map(|v| [v.x, v.y]).collect();
|
||||
prisms.push((Prism { footprint, z_bottom, z_top }, vec![]));
|
||||
}
|
||||
// [280] Träger werfen Schatten wie Stützen.
|
||||
for b in p.beams.as_deref().unwrap_or(&[]) {
|
||||
let c = b.as_column(p);
|
||||
let (z_bottom, z_top) = p.column_vertical_extent(&c);
|
||||
let footprint = crate::model3d::column_footprint(&c).iter().map(|v| [v.x, v.y]).collect();
|
||||
prisms.push((Prism { footprint, z_bottom, z_top }, vec![]));
|
||||
}
|
||||
// [142] Decken (auch Balkone, Auskragungen) werfen Schatten, decken Tieferes ab und empfangen ihn.
|
||||
for ce in p.ceilings.as_deref().unwrap_or(&[]) {
|
||||
let (zb, zt) = p.ceiling_vertical_extent(ce);
|
||||
|
||||
Reference in new issue
Block a user