[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
@@ -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),
|
||||
|
||||
Reference in new issue
Block a user