[33] Overrides auf Bauteilschichten: Kriterien Bauteilart/Schichtfunktion/Lage/Baustoff/Kategorie, Aktionen Füllung/Schraffur/Umriss mit Vorrang vor 1:100 schwarz; Baustein „Deckenaufbau weiss“, Vorlagen-Dialog, CLI --template/--rule
This commit is contained in:
23 files changed
+1316
-406
No files matched your search
@@ -671,11 +671,51 @@ pub struct Layer {
|
||||
#[serde(rename = "jointWeightMm", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub joint_weight_mm: Option<f64>,
|
||||
/// [33] Funktion der Schicht im Aufbau (tragend, Dämmung, Unterlagsboden …) für Grafik-Overrides auf
|
||||
/// Schichten. Fehlt sie, leitet der Kern sie aus dem Baustoff ab (`plan::overrides::layer_function`).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub function: Option<LayerFunction>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// [33] Funktion einer Bauteilschicht (für Override-Regeln auf Schichten).
|
||||
/// • "structure" — tragend (Beton, Mauerwerk, Holz-/Stahltragwerk)
|
||||
/// • "insulation" — Wärme-/Trittschalldämmung
|
||||
/// • "screed" — Unterlagsboden/Estrich
|
||||
/// • "finish" — Belag (Parkett, Platten)
|
||||
/// • "plaster" — Putz, Gipsbekleidung
|
||||
/// • "substructure" — Unterbau (Kies, Magerbeton, Erdreich)
|
||||
/// • "membrane" — Abdichtung, Dampfbremse
|
||||
/// • "cladding" — Bekleidung, Eindeckung, Lattung
|
||||
/// • "air" — Luftschicht, Hinterlüftung
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
|
||||
pub enum LayerFunction {
|
||||
#[serde(rename = "structure")]
|
||||
Structure,
|
||||
#[serde(rename = "insulation")]
|
||||
Insulation,
|
||||
#[serde(rename = "screed")]
|
||||
Screed,
|
||||
#[serde(rename = "finish")]
|
||||
Finish,
|
||||
#[serde(rename = "plaster")]
|
||||
Plaster,
|
||||
#[serde(rename = "substructure")]
|
||||
Substructure,
|
||||
#[serde(rename = "membrane")]
|
||||
Membrane,
|
||||
#[serde(rename = "cladding")]
|
||||
Cladding,
|
||||
#[serde(rename = "air")]
|
||||
Air,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// Ein Wandtyp = geordneter Schichtaufbau (außen → innen).
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
@@ -3907,12 +3947,23 @@ pub struct ParametricWall {
|
||||
// gelegt werden (reines Rendering-Overlay — die Elementdaten bleiben
|
||||
// unverändert, jederzeit reversibel). Regeln werden additiv angewendet: pro
|
||||
// Aktions-Feld gewinnt die OBERSTE (erste) aktive Regel, die es setzt.
|
||||
// Auswertung: `src/overrides/engine.ts`; Einhängepunkt: `plan/generatePlan.ts`.
|
||||
// Auswertung: Kern `plan/overrides.rs` ([33]: auch auf Bauteilschichten).
|
||||
|
||||
/// Bedingungs-Typ einer Override-Regel — wogegen der Wert verglichen wird:
|
||||
/// • "layer_name" — Name ODER Code der Ebene (LayerCategory) des Elements.
|
||||
/// • "object_name" — Element-/Typ-Name (z. B. Wandtyp-Name, Raum-Name,
|
||||
/// Öffnungs-Label, Drawing2D-Formname).
|
||||
/// • "element_kind" — [33] Bauteilart: "wall", "slab" (Decke), "ground_slab"
|
||||
/// (Bodenplatte), "roof".
|
||||
/// Schicht-Bedingungen ([33]; eine Regel mit einer davon wirkt nur auf
|
||||
/// Bauteilschichten, nicht auf ganze Elemente):
|
||||
/// • "layer_function" — Funktion der Schicht (`LayerFunction`, sonst aus dem Baustoff).
|
||||
/// • "layer_position" — Lage zur tragenden Schicht: "above" (oben/aussen),
|
||||
/// "structure", "below" (unten/innen).
|
||||
/// • "material" — Baustoff: id, Standard-Kennung (`std-c-…`) oder Name.
|
||||
/// • "material_category" — Baustoff-Kategorie (aus Standard-Kennung/Name abgeleitet:
|
||||
/// "concrete", "masonry", "timber", "insulation", "screed", "flooring", "plaster",
|
||||
/// "loose_fill", "metal", "glass", "membrane", "air", "cladding", "stone", "other").
|
||||
/// Ein `user_string`-Tag (DOSSIER-Rhino) existiert am Element noch nicht und
|
||||
/// ist deshalb bewusst NICHT enthalten (kein Schein-Feature).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
@@ -3922,6 +3973,16 @@ pub enum OverrideConditionType {
|
||||
LayerName,
|
||||
#[serde(rename = "object_name")]
|
||||
ObjectName,
|
||||
#[serde(rename = "element_kind")]
|
||||
ElementKind,
|
||||
#[serde(rename = "layer_function")]
|
||||
LayerFunction,
|
||||
#[serde(rename = "layer_position")]
|
||||
LayerPosition,
|
||||
#[serde(rename = "material")]
|
||||
Material,
|
||||
#[serde(rename = "material_category")]
|
||||
MaterialCategory,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
@@ -3974,6 +4035,21 @@ pub struct OverrideActions {
|
||||
#[serde(rename = "linetypeId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub linetype_id: Option<String>,
|
||||
/// [33] Füllfarbe geschnittener Flächen/Schichten (hex) — hat Vorrang vor der
|
||||
/// Massstabsregel „Schnittflächen 1:100 schwarz“.
|
||||
#[serde(rename = "fillColor", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub fill_color: Option<String>,
|
||||
/// [33] Schraffur geschnittener Flächen/Schichten: "none" (ohne), "material"
|
||||
/// (Schraffur des Baustoffs, auch ab 1:100) oder die id einer Schraffur.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub hatch: Option<String>,
|
||||
/// [33] Umriss/Fugenlinie geschnittener Flächen/Schichten: an (true) oder aus.
|
||||
/// Benachbarte Schichten mit gleicher Darstellung ohne Muster bilden eine Fläche.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub outline: Option<bool>,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
@@ -3989,6 +4065,10 @@ pub struct OverrideRule {
|
||||
/// Deaktivierte Regeln werden bei der Auswertung übersprungen.
|
||||
pub enabled: bool,
|
||||
pub condition: OverrideCondition,
|
||||
/// [33] Weitere Bedingungen; die Regel trifft nur, wenn ALLE zutreffen.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub conditions: Option<Vec<OverrideCondition>>,
|
||||
pub actions: OverrideActions,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
|
||||
@@ -138,7 +138,7 @@ impl<'a> Ctx<'a> {
|
||||
|
||||
/// Effektive Override-Aktionen eines Elements (`overrideFor` in TS).
|
||||
pub fn overrides(&self, code: &str, object_name: Option<&str>) -> Actions {
|
||||
overrides::effective(self.p.override_rules.as_deref(), &Subject { layer_name: self.cat(code).map(|c| c.name.as_str()), layer_code: Some(code), object_name })
|
||||
overrides::effective(self.p.override_rules.as_deref(), &Subject { layer_name: self.cat(code).map(|c| c.name.as_str()), layer_code: Some(code), object_name, ..Default::default() })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1483,6 +1483,40 @@ mod tests {
|
||||
assert!(h > 0 && ink == 0, "Ebene schraffiert: {h} {ink}");
|
||||
}
|
||||
|
||||
/// [33] Override auf Wandschichten im Grundriss: „Dämmung weiss, ohne Schraffur“ (Baustoff-Kategorie) zeigt
|
||||
/// im 1:100 die Dämmschicht als weisses Band, die übrigen Schichten schwarz ohne Fugen dazwischen; im 1:50
|
||||
/// ohne Schraffur statt der Dämmschlange. Ausgeschaltet bzw. ohne Regel wie bisher (Sammelfläche).
|
||||
#[test]
|
||||
fn override_auf_wandschichten_im_grundriss() {
|
||||
let mut p = sample();
|
||||
let run = |p: &Project, scale: f64| {
|
||||
let t = serde_json::json!({ "floor": "eg", "show": ["20"], "grey": [], "scale": scale }).to_string();
|
||||
plan_domains(p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap().walls
|
||||
};
|
||||
let fills = |prims: &[Primitive]| prims.iter().filter_map(|q| match q { Primitive::Polygon { fill, hatch, .. } => Some((fill.clone(), hatch.pattern)), _ => None }).collect::<Vec<_>>();
|
||||
let before100 = fills(&run(&p, 100.0));
|
||||
let before50 = fills(&run(&p, 50.0));
|
||||
let mut rule: OverrideRule = serde_json::from_value(serde_json::json!({"id": "d", "name": "Dämmung weiss", "enabled": false,
|
||||
"condition": {"type": "material_category", "operator": "equals", "value": "insulation"},
|
||||
"conditions": [{"type": "element_kind", "operator": "equals", "value": "wall"}],
|
||||
"actions": {"fillColor": "#ffffff", "hatch": "none"}})).unwrap();
|
||||
p.override_rules = Some(vec![rule.clone()]);
|
||||
assert_eq!(fills(&run(&p, 100.0)), before100, "Regel aus");
|
||||
rule.enabled = true;
|
||||
p.override_rules = Some(vec![rule]);
|
||||
let r100 = run(&p, 100.0);
|
||||
let f = fills(&r100);
|
||||
assert!(f.iter().any(|(c, h)| c == "#ffffff" && *h == HatchPattern::None), "{f:?}");
|
||||
assert!(f.iter().any(|(c, _)| c == HATCH_INK));
|
||||
assert!(f.iter().all(|(_, h)| *h == HatchPattern::None), "1:100 ohne Schraffur");
|
||||
// Fugen nur an der weissen Schicht (Backstein|Putz schwarz an schwarz ohne Fuge).
|
||||
let joints = r100.iter().filter(|q| matches!(q, Primitive::Line { cls, .. } if cls == "layer-joint")).count();
|
||||
assert!(joints > 0);
|
||||
let f50 = fills(&run(&p, 50.0));
|
||||
assert_eq!(f50.len(), before50.len());
|
||||
assert!(f50.iter().zip(&before50).any(|(a, b)| a.0 == "#ffffff" && a.1 == HatchPattern::None && b.1 != HatchPattern::None));
|
||||
}
|
||||
|
||||
/// [140] „mittel" ab 1:200 wie „grob" (Wände als Sammelfläche), „fein" bleibt; explizit „grob" ohne Stempel.
|
||||
#[test]
|
||||
fn mittel_ab_1_200_automatisch_grob() {
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
//! Grafische Overrides ([K3d]): wertet `Project.overrideRules` für ein Element aus — Rust-Gegenstück
|
||||
//! zu `src/overrides/engine.ts`. Pro Aktions-Feld gewinnt die OBERSTE aktive Regel, deren Bedingung
|
||||
//! passt; spätere Regeln füllen nur noch offene Felder. Vergleiche ohne Gross-/Kleinschreibung, Werte
|
||||
//! Grafische Overrides ([K3d], [33]): wertet `Project.overrideRules` für ein Element bzw. eine
|
||||
//! Bauteilschicht aus. Pro Aktions-Feld gewinnt die OBERSTE aktive Regel, deren Bedingungen passen;
|
||||
//! spätere Regeln füllen nur noch offene Felder. Vergleiche ohne Gross-/Kleinschreibung, Werte
|
||||
//! getrimmt (wie JS `trim()`/`toLowerCase()`).
|
||||
//!
|
||||
//! [33] Schicht-Regeln: Eine Regel mit einer Schicht-Bedingung (Funktion, Lage zur tragenden Schicht,
|
||||
//! Baustoff, Baustoff-Kategorie) wirkt nur auf Bauteilschichten (Schnittflächen im Schnitt, Wandschichten
|
||||
//! im Grundriss), nie auf ganze Elemente ([`effective`] überspringt sie). Schicht-Aktionen (Füllung,
|
||||
//! Schraffur, Umriss) wertet [`effective_layer`] aus — dort zählen auch Element-Regeln (Ebene, Name,
|
||||
//! Bauteilart), deren Bedingungen auf das Bauteil der Schicht passen. Die Aktionen haben Vorrang vor der
|
||||
//! Massstabsregel „Schnittflächen 1:100 schwarz“ (`style::solid_cut`) und der Ausnahme für lose
|
||||
//! Schüttungen (`standards::is_loose_fill`).
|
||||
|
||||
use crate::model::*;
|
||||
|
||||
/// Die vergleichbaren Eigenschaften eines Elements.
|
||||
/// Die vergleichbaren Eigenschaften eines Elements bzw. einer Schicht (Schicht-Felder `None` = Element).
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
pub struct Subject<'a> {
|
||||
/// Name der Ebene (`LayerCategory.name`).
|
||||
@@ -14,6 +22,18 @@ pub struct Subject<'a> {
|
||||
pub layer_code: Option<&'a str>,
|
||||
/// Element-/Typ-Name (Wandtyp, Raum, Öffnungs-Label …).
|
||||
pub object_name: Option<&'a str>,
|
||||
/// [33] Bauteilart: "wall", "slab", "ground_slab", "roof".
|
||||
pub element_kind: Option<&'a str>,
|
||||
/// [33] Funktion der Schicht ([`function_key`]).
|
||||
pub layer_function: Option<&'a str>,
|
||||
/// [33] Lage zur tragenden Schicht: "above", "structure", "below".
|
||||
pub layer_position: Option<&'a str>,
|
||||
/// [33] Baustoff: id, Standard-Kennung, Name.
|
||||
pub material_id: Option<&'a str>,
|
||||
pub material_standard: Option<&'a str>,
|
||||
pub material_name: Option<&'a str>,
|
||||
/// [33] Baustoff-Kategorie (`standards::material_category`).
|
||||
pub material_category: Option<&'a str>,
|
||||
}
|
||||
|
||||
/// Effektive Aktionen (alle `None` = kein Override).
|
||||
@@ -30,6 +50,29 @@ impl Actions {
|
||||
}
|
||||
}
|
||||
|
||||
/// [33] Effektive Schicht-Aktionen (Füllung, Schraffur, Umriss) einer Schicht.
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct LayerActions {
|
||||
pub fill_color: Option<String>,
|
||||
/// "none", "material" oder id einer Schraffur.
|
||||
pub hatch: Option<String>,
|
||||
pub outline: Option<bool>,
|
||||
}
|
||||
|
||||
impl LayerActions {
|
||||
/// Ändert die Regel Füllung oder Schraffur (und hebt damit „schwarz ab 1:100“ auf)?
|
||||
pub fn styles(&self) -> bool {
|
||||
self.fill_color.is_some() || self.hatch.is_some()
|
||||
}
|
||||
pub fn any(&self) -> bool {
|
||||
self.styles() || self.outline.is_some()
|
||||
}
|
||||
/// Fläche ohne Muster (Schraffur "none")?
|
||||
pub fn plain(&self) -> bool {
|
||||
self.hatch.as_deref() == Some("none")
|
||||
}
|
||||
}
|
||||
|
||||
/// Leerraum im Sinne von JS `String.prototype.trim` (WhiteSpace + LineTerminator).
|
||||
pub fn js_space(c: char) -> bool {
|
||||
matches!(c, '\u{9}' | '\u{A}' | '\u{B}' | '\u{C}' | '\u{D}' | ' ' | '\u{A0}' | '\u{1680}' | '\u{2000}'..='\u{200A}' | '\u{2028}' | '\u{2029}' | '\u{202F}' | '\u{205F}' | '\u{3000}' | '\u{FEFF}')
|
||||
@@ -44,18 +87,39 @@ fn norm(s: &str) -> String {
|
||||
js_trim(s).to_lowercase()
|
||||
}
|
||||
|
||||
/// [33] Bedingung auf eine Schicht-Eigenschaft (Regel wirkt dann nur auf Schichten)?
|
||||
pub fn is_layer_condition(t: OverrideConditionType) -> bool {
|
||||
use OverrideConditionType as T;
|
||||
matches!(t, T::LayerFunction | T::LayerPosition | T::Material | T::MaterialCategory)
|
||||
}
|
||||
|
||||
/// Alle Bedingungen einer Regel (Haupt- und weitere).
|
||||
fn conditions(rule: &OverrideRule) -> impl Iterator<Item = &OverrideCondition> {
|
||||
std::iter::once(&rule.condition).chain(rule.conditions.iter().flatten())
|
||||
}
|
||||
|
||||
/// [33] Wirkt die Regel nur auf Schichten?
|
||||
pub fn is_layer_rule(rule: &OverrideRule) -> bool {
|
||||
conditions(rule).any(|c| is_layer_condition(c.r#type))
|
||||
}
|
||||
|
||||
/// `matchesCondition`: `layer_name` vergleicht Name UND Code (positive Operatoren: einer passt;
|
||||
/// `not_equals`: keiner gleich), `object_name` den Element-Namen. Fehlt die Eigenschaft, trifft nur
|
||||
/// `not_equals`.
|
||||
/// `not_equals`: keiner gleich), `object_name` den Element-Namen, `material` id, Standard-Kennung und
|
||||
/// Name. Fehlt die Eigenschaft, trifft nur `not_equals`.
|
||||
pub fn matches_condition(c: &OverrideCondition, s: &Subject) -> bool {
|
||||
use OverrideConditionType as T;
|
||||
let value = norm(&c.value);
|
||||
let mut cands: Vec<String> = Vec::with_capacity(2);
|
||||
if c.r#type == OverrideConditionType::LayerName {
|
||||
cands.extend(s.layer_name.map(norm));
|
||||
cands.extend(s.layer_code.map(norm));
|
||||
} else {
|
||||
cands.extend(s.object_name.map(norm));
|
||||
}
|
||||
let raw: [Option<&str>; 3] = match c.r#type {
|
||||
T::LayerName => [s.layer_name, s.layer_code, None],
|
||||
T::ObjectName => [s.object_name, None, None],
|
||||
T::ElementKind => [s.element_kind, None, None],
|
||||
T::LayerFunction => [s.layer_function, None, None],
|
||||
T::LayerPosition => [s.layer_position, None, None],
|
||||
T::Material => [s.material_id, s.material_standard, s.material_name],
|
||||
T::MaterialCategory => [s.material_category, None, None],
|
||||
T::Unknown => [None, None, None],
|
||||
};
|
||||
let cands: Vec<String> = raw.iter().flatten().map(|x| norm(x)).collect();
|
||||
if cands.is_empty() {
|
||||
return c.operator == OverrideOperator::NotEquals;
|
||||
}
|
||||
@@ -68,12 +132,17 @@ pub fn matches_condition(c: &OverrideCondition, s: &Subject) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
/// `effectiveOverrides`: kollabiert die Regelliste für ein Subjekt.
|
||||
/// Treffen alle Bedingungen der Regel?
|
||||
pub fn rule_matches(rule: &OverrideRule, s: &Subject) -> bool {
|
||||
conditions(rule).all(|c| matches_condition(c, s))
|
||||
}
|
||||
|
||||
/// `effectiveOverrides`: kollabiert die Regelliste für ein Element (Schicht-Regeln zählen nicht).
|
||||
pub fn effective(rules: Option<&[OverrideRule]>, s: &Subject) -> Actions {
|
||||
let mut out = Actions::default();
|
||||
let Some(rules) = rules else { return out };
|
||||
for rule in rules {
|
||||
if !rule.enabled || !matches_condition(&rule.condition, s) {
|
||||
if !rule.enabled || is_layer_rule(rule) || !rule_matches(rule, s) {
|
||||
continue;
|
||||
}
|
||||
let a = &rule.actions;
|
||||
@@ -93,11 +162,133 @@ pub fn effective(rules: Option<&[OverrideRule]>, s: &Subject) -> Actions {
|
||||
out
|
||||
}
|
||||
|
||||
/// [33] Schicht-Aktionen für eine Schicht (alle aktiven Regeln, deren Bedingungen passen).
|
||||
pub fn effective_layer(rules: Option<&[OverrideRule]>, s: &Subject) -> LayerActions {
|
||||
let mut out = LayerActions::default();
|
||||
let Some(rules) = rules else { return out };
|
||||
for rule in rules {
|
||||
let a = &rule.actions;
|
||||
if !rule.enabled || (a.fill_color.is_none() && a.hatch.is_none() && a.outline.is_none()) || !rule_matches(rule, s) {
|
||||
continue;
|
||||
}
|
||||
if out.fill_color.is_none() {
|
||||
out.fill_color = a.fill_color.as_deref().map(js_trim).filter(|x| !x.is_empty()).map(String::from);
|
||||
}
|
||||
if out.hatch.is_none() {
|
||||
out.hatch = a.hatch.as_deref().map(js_trim).filter(|x| !x.is_empty()).map(String::from);
|
||||
}
|
||||
if out.outline.is_none() {
|
||||
out.outline = a.outline;
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Gibt es überhaupt aktive Regeln mit Schicht-Aktionen? (Schnellpfad: sonst nichts auswerten.)
|
||||
pub fn has_layer_actions(p: &Project) -> bool {
|
||||
p.override_rules.iter().flatten().any(|r| r.enabled && (r.actions.fill_color.is_some() || r.actions.hatch.is_some() || r.actions.outline.is_some()))
|
||||
}
|
||||
|
||||
/// Schlüssel einer Schichtfunktion (wie im JSON).
|
||||
pub fn function_key(f: LayerFunction) -> Option<&'static str> {
|
||||
Some(match f {
|
||||
LayerFunction::Structure => "structure",
|
||||
LayerFunction::Insulation => "insulation",
|
||||
LayerFunction::Screed => "screed",
|
||||
LayerFunction::Finish => "finish",
|
||||
LayerFunction::Plaster => "plaster",
|
||||
LayerFunction::Substructure => "substructure",
|
||||
LayerFunction::Membrane => "membrane",
|
||||
LayerFunction::Cladding => "cladding",
|
||||
LayerFunction::Air => "air",
|
||||
LayerFunction::Unknown => return None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Funktion einer Schicht: eigenes Feld, sonst aus dem Baustoff.
|
||||
pub fn layer_function(p: &Project, l: &Layer) -> Option<LayerFunction> {
|
||||
l.function.filter(|f| *f != LayerFunction::Unknown).or_else(|| crate::standards::layer_function_of_category(crate::standards::material_category(p.component_or_fallback(&l.component_id))))
|
||||
}
|
||||
|
||||
/// [33] Lage jeder Schicht zur tragenden Schicht: Schichten liegen aussen/oben → innen/unten; die tragende
|
||||
/// ist die mit Funktion „tragend“ und dem höchsten Verschneidungs-Rang (Gleichstand: die dickere), ohne
|
||||
/// tragende die mit dem höchsten Rang. Davor "above", danach "below".
|
||||
pub fn layer_positions(p: &Project, layers: &[Layer]) -> Vec<&'static str> {
|
||||
let rank = |i: usize| {
|
||||
let l = &layers[i];
|
||||
let st = layer_function(p, l) == Some(LayerFunction::Structure);
|
||||
(st, p.component_or_fallback(&l.component_id).join_priority, l.thickness)
|
||||
};
|
||||
let core = (0..layers.len()).max_by(|&a, &b| {
|
||||
let (x, y) = (rank(a), rank(b));
|
||||
x.0.cmp(&y.0).then(x.1.total_cmp(&y.1)).then(x.2.total_cmp(&y.2)).then(b.cmp(&a))
|
||||
});
|
||||
(0..layers.len())
|
||||
.map(|i| match core {
|
||||
Some(c) if i < c => "above",
|
||||
Some(c) if i > c => "below",
|
||||
_ => "structure",
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// [33] Bodenplatte: Decke mit Unterbau-Schicht (Kies, Magerbeton, Erdreich) oder auf dem untersten
|
||||
/// Geschoss mit Oberkante auf dessen Boden.
|
||||
pub fn is_ground_slab(p: &Project, c: &Ceiling, layers: &[Layer]) -> bool {
|
||||
if layers.iter().any(|l| crate::standards::is_loose_fill(p.component_or_fallback(&l.component_id))) {
|
||||
return true;
|
||||
}
|
||||
let lowest = p.drawing_levels.iter().filter(|l| l.kind == DrawingLevelKind::Floor).min_by(|a, b| a.base_elevation.unwrap_or(0.0).total_cmp(&b.base_elevation.unwrap_or(0.0)));
|
||||
lowest.is_some_and(|lv| lv.id == c.floor_id && matches!(&c.top, Some(VerticalAnchor::Floor { floor_id, offset }) if *floor_id == c.floor_id && offset.unwrap_or(0.0) <= 1e-6))
|
||||
}
|
||||
|
||||
/// [33] Schicht-Aktionen je Schicht eines Bauteils (`kind` "wall"/"slab"/"ground_slab"/"roof"). Ohne aktive
|
||||
/// Regel mit Schicht-Aktionen: lauter leere Aktionen (Schnellpfad).
|
||||
pub fn layer_actions(p: &Project, kind: &str, category_code: &str, object_name: Option<&str>, layers: &[Layer]) -> Vec<LayerActions> {
|
||||
if !has_layer_actions(p) {
|
||||
return vec![LayerActions::default(); layers.len()];
|
||||
}
|
||||
let rules = p.override_rules.as_deref();
|
||||
let cat = p.layer_category(category_code);
|
||||
let pos = layer_positions(p, layers);
|
||||
layers
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, l)| {
|
||||
let comp = p.component_or_fallback(&l.component_id);
|
||||
let s = Subject {
|
||||
layer_name: cat.map(|c| c.name.as_str()),
|
||||
layer_code: Some(category_code),
|
||||
object_name,
|
||||
element_kind: Some(kind),
|
||||
layer_function: layer_function(p, l).and_then(function_key),
|
||||
layer_position: Some(pos[i]),
|
||||
material_id: Some(comp.id.as_str()),
|
||||
material_standard: comp.standard_id.as_deref(),
|
||||
material_name: Some(comp.name.as_str()),
|
||||
material_category: Some(crate::standards::material_category(comp)),
|
||||
};
|
||||
effective_layer(rules, &s)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const WALL: Subject = Subject { layer_name: Some("Wände"), layer_code: Some("20"), object_name: Some("AW 24") };
|
||||
const WALL: Subject = Subject {
|
||||
layer_name: Some("Wände"),
|
||||
layer_code: Some("20"),
|
||||
object_name: Some("AW 24"),
|
||||
element_kind: None,
|
||||
layer_function: None,
|
||||
layer_position: None,
|
||||
material_id: None,
|
||||
material_standard: None,
|
||||
material_name: None,
|
||||
material_category: None,
|
||||
};
|
||||
|
||||
fn cond(t: OverrideConditionType, op: OverrideOperator, v: &str) -> OverrideCondition {
|
||||
OverrideCondition { r#type: t, operator: op, value: v.into(), ..Default::default() }
|
||||
@@ -147,4 +338,75 @@ mod tests {
|
||||
assert!(!effective(None, &WALL).any());
|
||||
assert!(!effective(Some(&[]), &WALL).any());
|
||||
}
|
||||
|
||||
/// [33] Schicht-Regeln: wirken nur auf Schichten (nicht aufs ganze Element), alle Bedingungen müssen
|
||||
/// passen, Material nach id/Standard/Name; Element-Regeln mit Schicht-Aktionen gelten für alle Schichten.
|
||||
#[test]
|
||||
fn schicht_regeln() {
|
||||
let screed = Subject {
|
||||
element_kind: Some("slab"),
|
||||
layer_function: Some("screed"),
|
||||
layer_position: Some("above"),
|
||||
material_id: Some("c7"),
|
||||
material_standard: Some("std-c-zementestrich"),
|
||||
material_name: Some("Zementestrich"),
|
||||
material_category: Some("screed"),
|
||||
..WALL
|
||||
};
|
||||
let core = Subject { layer_function: Some("structure"), layer_position: Some("structure"), material_id: Some("c1"), material_standard: None, material_name: Some("STB"), material_category: Some("concrete"), ..screed };
|
||||
let mut white = rule(true, cond(LayerPosition, Equals, "above"), Some("#00f"), None, None);
|
||||
white.conditions = Some(vec![cond(ElementKind, Contains, "slab")]);
|
||||
white.actions.fill_color = Some("#ffffff".into());
|
||||
white.actions.hatch = Some("none".into());
|
||||
white.actions.outline = Some(true);
|
||||
assert!(is_layer_rule(&white));
|
||||
// Nicht aufs Element (auch nicht die Farbe).
|
||||
assert!(!effective(Some(std::slice::from_ref(&white)), &WALL).any());
|
||||
let a = effective_layer(Some(std::slice::from_ref(&white)), &screed);
|
||||
assert_eq!(a, LayerActions { fill_color: Some("#ffffff".into()), hatch: Some("none".into()), outline: Some(true) });
|
||||
assert!(!effective_layer(Some(std::slice::from_ref(&white)), &core).any());
|
||||
// Weitere Bedingung verfehlt: Wand.
|
||||
assert!(!effective_layer(Some(std::slice::from_ref(&white)), &Subject { element_kind: Some("wall"), ..screed }).any());
|
||||
// Material: Standard-Kennung oder Name; Kategorie.
|
||||
assert!(matches_condition(&cond(Material, Equals, "std-c-zementestrich"), &screed));
|
||||
assert!(matches_condition(&cond(Material, Contains, "estrich"), &screed));
|
||||
assert!(matches_condition(&cond(MaterialCategory, Equals, "screed"), &screed));
|
||||
assert!(!matches_condition(&cond(MaterialCategory, Equals, "screed"), &core));
|
||||
// Element-Regel (Ebene) mit Schicht-Aktion: auf jede Schicht; oberste Regel gewinnt je Feld.
|
||||
let mut by_layer = rule(true, cond(LayerName, Equals, "20"), None, None, None);
|
||||
by_layer.actions.hatch = Some("material".into());
|
||||
let rules = vec![white.clone(), by_layer];
|
||||
assert_eq!(effective_layer(Some(&rules), &screed).hatch.as_deref(), Some("none"));
|
||||
assert_eq!(effective_layer(Some(&rules), &core).hatch.as_deref(), Some("material"));
|
||||
// Ausgeschaltet: nichts.
|
||||
white.enabled = false;
|
||||
assert!(!effective_layer(Some(&[white]), &screed).any());
|
||||
}
|
||||
|
||||
/// [33] Lage zur tragenden Schicht und Funktion aus dem Baustoff (Standard-Deckenaufbau).
|
||||
#[test]
|
||||
fn lage_zur_tragenden_schicht() {
|
||||
let mut p: Project = serde_json::from_value(serde_json::json!({"id": "p", "name": "P", "drawingLevels": [], "walls": [], "openings": [], "wallTypes": [], "lineStyles": [], "hatches": []})).unwrap();
|
||||
p.components = crate::standards::components().into_iter().map(|v| serde_json::from_value(v).unwrap()).collect();
|
||||
let l = |c: &str, t: f64| Layer { component_id: c.into(), thickness: t, ..Default::default() };
|
||||
let deck = [l("std-c-parkett", 0.015), l("std-c-zementestrich", 0.07), l("std-c-trittschall", 0.04), l("std-c-stahlbeton", 0.24), l("std-c-innenputz", 0.01)];
|
||||
assert_eq!(layer_positions(&p, &deck), ["above", "above", "above", "structure", "below"]);
|
||||
let f: Vec<_> = deck.iter().map(|x| layer_function(&p, x).and_then(function_key)).collect();
|
||||
assert_eq!(f, [Some("finish"), Some("screed"), Some("insulation"), Some("structure"), Some("plaster")]);
|
||||
// Eigene Funktion schlägt den Baustoff.
|
||||
let mut own = l("std-c-holz", 0.03);
|
||||
own.function = Some(crate::model::LayerFunction::Finish);
|
||||
assert_eq!(layer_function(&p, &own), Some(crate::model::LayerFunction::Finish));
|
||||
// Ohne tragenden Baustoff: höchster Rang (Estrich vor Dämmung).
|
||||
assert_eq!(layer_positions(&p, &[l("std-c-zementestrich", 0.05), l("std-c-eps", 0.1)]), ["structure", "below"]);
|
||||
// Ohne aktive Regel: Schnellpfad, lauter leere Aktionen.
|
||||
assert!(layer_actions(&p, "slab", "30", None, &deck).iter().all(|a| !a.any()));
|
||||
p.override_rules = Some(crate::standards::override_rules().into_iter().map(|v| serde_json::from_value(v).unwrap()).collect());
|
||||
assert!(layer_actions(&p, "slab", "30", None, &deck).iter().all(|a| !a.any()), "Standardregel ist aus");
|
||||
p.override_rules.as_mut().unwrap()[0].enabled = true;
|
||||
let a = layer_actions(&p, "slab", "30", None, &deck);
|
||||
assert_eq!(a.iter().map(|x| x.styles()).collect::<Vec<_>>(), [true, true, true, false, false]);
|
||||
assert!(layer_actions(&p, "ground_slab", "30", None, &deck)[1].plain());
|
||||
assert!(!layer_actions(&p, "wall", "20", None, &deck)[1].any());
|
||||
}
|
||||
}
|
||||
@@ -178,14 +178,120 @@ pub struct Cut {
|
||||
pub source_id: Option<String>,
|
||||
pub category: Option<String>,
|
||||
pub stair_id: Option<String>,
|
||||
/// [33] Index der Schicht im Aufbau des Bauteils (Wand-, Decken-, Dachtyp), wo bekannt.
|
||||
pub layer_index: Option<usize>,
|
||||
/// [33] Override der Schicht (nur beim Zeichnen gesetzt, [`cut_overrides`]).
|
||||
pub ov: Option<CutOv>,
|
||||
}
|
||||
|
||||
impl Cut {
|
||||
fn new(kind: Kind, index: usize, pts: Vec<[f64; 2]>) -> Cut {
|
||||
Cut { kind, index, pts, nse: None, fill: None, hatch: None, join_priority: None, component_id: None, source_id: None, category: None, stair_id: None }
|
||||
Cut { kind, index, pts, nse: None, fill: None, hatch: None, join_priority: None, component_id: None, source_id: None, category: None, stair_id: None, layer_index: None, ov: None }
|
||||
}
|
||||
}
|
||||
|
||||
/// [33] Schraffur-Aktion eines Overrides auf eine Schnittfläche.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum HatchOv {
|
||||
/// Wie ohne Regel (schwarz ab 1:100 nur, wenn die Regel auch keine Füllung setzt).
|
||||
Keep,
|
||||
/// Ohne Muster.
|
||||
None,
|
||||
/// Schraffur des Baustoffs, auch ab 1:100.
|
||||
Material,
|
||||
/// Eine Schraffur des Projekts.
|
||||
Pattern(HatchRender),
|
||||
}
|
||||
|
||||
/// [33] Override einer Schnittfläche (aus `plan::overrides::layer_actions`).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct CutOv {
|
||||
pub fill: Option<String>,
|
||||
pub hatch: HatchOv,
|
||||
pub outline: Option<bool>,
|
||||
}
|
||||
|
||||
impl CutOv {
|
||||
/// Hebt die Regel „schwarz ab 1:100“ auf?
|
||||
fn styles(&self) -> bool {
|
||||
self.fill.is_some() || self.hatch != HatchOv::Keep
|
||||
}
|
||||
}
|
||||
|
||||
/// [33] Zeichen-Regeln der Schnittflächen: lose Schüttungen (Bauteil-ids, s. [`loose_fill_components`]) und
|
||||
/// Overrides je Fläche von `Output::cuts` (gleiche Reihenfolge; leer = keine).
|
||||
#[derive(Default)]
|
||||
pub struct CutRules {
|
||||
pub loose: HashSet<String>,
|
||||
pub ov: Vec<Option<CutOv>>,
|
||||
}
|
||||
|
||||
impl CutRules {
|
||||
pub fn of(p: &Project, out: &Output) -> CutRules {
|
||||
CutRules { loose: loose_fill_components(p), ov: cut_overrides(p, &out.cuts) }
|
||||
}
|
||||
}
|
||||
|
||||
/// [33] Overrides je Schnittfläche: Bauteil (Wand, Decke/Bodenplatte, Dach) und Schicht der Fläche, dann
|
||||
/// `overrides::layer_actions`. Ohne aktive Regel mit Schicht-Aktionen leer.
|
||||
pub fn cut_overrides(p: &Project, cuts: &[Cut]) -> Vec<Option<CutOv>> {
|
||||
use super::overrides::{has_layer_actions, is_ground_slab, layer_actions, LayerActions};
|
||||
if !has_layer_actions(p) {
|
||||
return Vec::new();
|
||||
}
|
||||
let mut memo: HashMap<(u8, String), (Vec<Layer>, Vec<LayerActions>)> = HashMap::new();
|
||||
let roofs = p.roofs.as_deref().unwrap_or(&[]);
|
||||
let ceilings = p.ceilings.as_deref().unwrap_or(&[]);
|
||||
cuts.iter()
|
||||
.map(|c| {
|
||||
let src = c.source_id.as_deref()?;
|
||||
if c.stair_id.is_some() {
|
||||
return None;
|
||||
}
|
||||
let tag = match c.kind {
|
||||
Kind::Wall => 0u8,
|
||||
Kind::Slab => 1,
|
||||
Kind::Roof => 2,
|
||||
Kind::Body => return None,
|
||||
};
|
||||
let key = (tag, src.to_string());
|
||||
if !memo.contains_key(&key) {
|
||||
let entry = match c.kind {
|
||||
Kind::Wall => {
|
||||
let w = p.walls.iter().find(|w| w.id == src)?;
|
||||
let wt = p.wall_type_or_fallback(w);
|
||||
(wt.layers.clone(), layer_actions(p, "wall", &w.category_code, Some(&wt.name), &wt.layers))
|
||||
}
|
||||
Kind::Slab => {
|
||||
let ce = ceilings.iter().find(|x| x.id == src)?;
|
||||
let (name, layers) = model3d::ceiling_type_ref(p, ce).map_or((None, Project::fallback_layers()), |t| (Some(t.1), t.2));
|
||||
let kind = if is_ground_slab(p, ce, layers) { "ground_slab" } else { "slab" };
|
||||
(layers.to_vec(), layer_actions(p, kind, &ce.category_code, name, layers))
|
||||
}
|
||||
_ => {
|
||||
let r = roofs.iter().find(|x| x.id == src)?;
|
||||
let layers = p.roof_layers(r);
|
||||
let acts = layer_actions(p, "roof", &r.category_code, None, &layers);
|
||||
(layers, acts)
|
||||
}
|
||||
};
|
||||
memo.insert(key.clone(), entry);
|
||||
}
|
||||
let (layers, acts) = memo.get(&key)?;
|
||||
let li = c.layer_index.or_else(|| if layers.len() == 1 { Some(0) } else { c.component_id.as_deref().and_then(|id| layers.iter().position(|l| l.component_id == id)) })?;
|
||||
let a = acts.get(li).filter(|a| a.any())?;
|
||||
let angle = if c.kind == Kind::Wall { Some(SECTION_WALL_AXIS_ANGLE_DEG) } else { Some(SECTION_SLAB_AXIS_ANGLE_DEG) };
|
||||
let hatch = match a.hatch.as_deref() {
|
||||
None => HatchOv::Keep,
|
||||
Some("none") => HatchOv::None,
|
||||
Some("material") => HatchOv::Material,
|
||||
Some(id) => resolve_hatch(p, id, angle, None, None).map_or(HatchOv::Keep, HatchOv::Pattern),
|
||||
};
|
||||
Some(CutOv { fill: a.fill_color.clone(), hatch, outline: a.outline })
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Eine projizierte Kante (`SectionEdge`).
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Edge {
|
||||
@@ -670,6 +776,7 @@ fn split_wall_layers(cp: &Cut, p: &Project, layers: &[Layer], owner: &Wall, u_wo
|
||||
c.component_id = Some(comp.id.clone());
|
||||
c.source_id = cp.source_id.clone();
|
||||
c.category = cp.category.clone();
|
||||
c.layer_index = Some(li);
|
||||
c
|
||||
};
|
||||
let shift = |s: &Option<EdgeJoin>| s.as_ref().map_or(0.0, |e| e.shift(li));
|
||||
@@ -926,6 +1033,7 @@ fn attach_cut_styles(cuts: Vec<Cut>, p: &Project, plane: &Plane, walls: &[Option
|
||||
// Schicht-Platte: Stil genau dieser Schicht; ohne Schicht (Dicke 0) ohne Stil.
|
||||
if let Some(l) = layer.and_then(|i| layers.get(i)) {
|
||||
style_slab_layer(&mut cp, p, l, o)?;
|
||||
cp.layer_index = layer;
|
||||
}
|
||||
} else {
|
||||
if let Some((fill, hatch)) = ceiling_section_style(p, o) {
|
||||
@@ -1042,6 +1150,7 @@ fn subtract_dominant_bands(bands: Vec<Cut>) -> Vec<Cut> {
|
||||
// Herkunft bleibt am Stück (Ebenen-Sichtbarkeit, Treppen-Pick).
|
||||
c.category = src.category.clone();
|
||||
c.stair_id = src.stair_id.clone();
|
||||
c.layer_index = src.layer_index;
|
||||
c
|
||||
})
|
||||
.collect();
|
||||
@@ -1236,7 +1345,9 @@ fn append_roof_sections(cuts: &mut Vec<Cut>, p: &Project, plane: &Plane) {
|
||||
for (index, roof) in roofs.iter().enumerate() {
|
||||
// Verschnittene Dächer und Gauben ([G5]): Schnitt durch die Körper je Schicht.
|
||||
if let Some(solids) = crate::roof_assembly::roof_solids_with(p, index, &nb) {
|
||||
let rl = p.roof_layers(roof);
|
||||
for part in &solids.parts {
|
||||
let li = rl.iter().position(|l| !part.component_id.is_empty() && l.component_id == part.component_id);
|
||||
let rings = crate::roof_assembly::section_rings(&part.mesh, (bx, by), (ux, uy));
|
||||
if rings.is_empty() {
|
||||
continue;
|
||||
@@ -1247,6 +1358,7 @@ fn append_roof_sections(cuts: &mut Vec<Cut>, p: &Project, plane: &Plane) {
|
||||
let slope = if wall { None } else { Some(ring_slope_deg(&pts)) };
|
||||
let hatch = if part.component_id.is_empty() { None } else { p.component(&part.component_id).and_then(|comp| resolve_hatch(p, &comp.hatch_id, slope, None, None)) };
|
||||
let mut c = Cut::new(Kind::Roof, index, pts);
|
||||
c.layer_index = li;
|
||||
if let Some(h) = &hatch {
|
||||
c.fill = Some(poche_fill(h.pattern).to_string());
|
||||
c.hatch = Some(h.clone());
|
||||
@@ -1281,7 +1393,7 @@ fn append_roof_sections(cuts: &mut Vec<Cut>, p: &Project, plane: &Plane) {
|
||||
let o = 1 + 5 * k;
|
||||
let (t_lo, t_hi, z0, z1, cos_t) = (sg[o], sg[o + 1], sg[o + 2], sg[o + 3], sg[o + 4]);
|
||||
let mut prefix = 0.0;
|
||||
for layer in &layers {
|
||||
for (li, layer) in layers.iter().enumerate() {
|
||||
let t = max(0.0, layer.thickness);
|
||||
if t <= 1e-9 {
|
||||
continue;
|
||||
@@ -1299,6 +1411,7 @@ fn append_roof_sections(cuts: &mut Vec<Cut>, p: &Project, plane: &Plane) {
|
||||
let hatch = if layer.component_id.is_empty() { None } else { p.component(&layer.component_id).and_then(|comp| resolve_hatch(p, &comp.hatch_id, Some(slope_deg), None, None)) };
|
||||
for pts in pieces {
|
||||
let mut c = Cut::new(Kind::Roof, index, pts);
|
||||
c.layer_index = Some(li);
|
||||
if let Some(h) = &hatch {
|
||||
c.fill = Some(poche_fill(h.pattern).to_string());
|
||||
c.hatch = Some(h.clone());
|
||||
@@ -1532,6 +1645,7 @@ fn parallel_reveal_cuts(mut cuts: Vec<Cut>, p: &Project, plane: &Plane, walls: &
|
||||
c.component_id = Some(comp.id.clone());
|
||||
c.source_id = Some(w.id.clone());
|
||||
c.category = Some(w.category_code.clone());
|
||||
c.layer_index = Some(li);
|
||||
cuts.push(c);
|
||||
}
|
||||
}
|
||||
@@ -2322,7 +2436,8 @@ pub fn merge_thin_cuts(cuts: &[Cut], scale: f64) -> Vec<Cut> {
|
||||
return cuts.to_vec();
|
||||
}
|
||||
let bbox: Vec<[f64; 4]> = cuts.iter().map(|c| ring_bbox(&c.pts)).collect();
|
||||
let same_part = |a: &Cut, b: &Cut| a.kind == b.kind && a.index == b.index && a.source_id == b.source_id;
|
||||
// [33] Nur Schichten mit gleichem Override (eine weisse Schicht geht nicht in der schwarzen auf).
|
||||
let same_part = |a: &Cut, b: &Cut| a.kind == b.kind && a.index == b.index && a.source_id == b.source_id && a.ov == b.ov;
|
||||
let touch = |i: usize, j: usize| {
|
||||
let (a, b) = (bbox[i], bbox[j]);
|
||||
a[0] <= b[2] + 1e-4 && b[0] <= a[2] + 1e-4 && a[1] <= b[3] + 1e-4 && b[1] <= a[3] + 1e-4
|
||||
@@ -2390,9 +2505,58 @@ pub fn merge_thin_cuts(cuts: &[Cut], scale: f64) -> Vec<Cut> {
|
||||
out
|
||||
}
|
||||
|
||||
/// [33] Schichten desselben Bauteils mit gleichem Override ohne Muster (Schraffur "none", z. B. „Deckenaufbau
|
||||
/// weiss“) zu einer Fläche vereinigen: ein Umriss um den ganzen Aufbau, keine Fugen dazwischen. Flächen mit
|
||||
/// Loch bleiben einzeln.
|
||||
fn merge_override_groups(cuts: Vec<Cut>) -> Vec<Cut> {
|
||||
let plain = |c: &Cut| c.ov.as_ref().is_some_and(|o| o.hatch == HatchOv::None) && c.stair_id.is_none() && c.pts.len() >= 3;
|
||||
if !cuts.iter().any(plain) {
|
||||
return cuts;
|
||||
}
|
||||
// Gleiches Bauteil: Decken-Schichten sind je eine eigene Platte (eigener `index`), darum über `source_id`.
|
||||
let same = |a: &Cut, b: &Cut| a.kind == b.kind && a.source_id.is_some() && a.source_id == b.source_id && a.ov == b.ov;
|
||||
let n = cuts.len();
|
||||
let mut group: Vec<Option<usize>> = vec![None; n];
|
||||
for i in 0..n {
|
||||
if !plain(&cuts[i]) || group[i].is_some() {
|
||||
continue;
|
||||
}
|
||||
group[i] = Some(i);
|
||||
for j in i + 1..n {
|
||||
if group[j].is_none() && plain(&cuts[j]) && same(&cuts[i], &cuts[j]) {
|
||||
group[j] = Some(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut out = Vec::with_capacity(n);
|
||||
for i in 0..n {
|
||||
match group[i] {
|
||||
None => out.push(cuts[i].clone()),
|
||||
Some(g) if g != i => {}
|
||||
Some(_) => {
|
||||
let members: Vec<usize> = (i..n).filter(|&j| group[j] == Some(i)).collect();
|
||||
if members.len() == 1 {
|
||||
out.push(cuts[i].clone());
|
||||
continue;
|
||||
}
|
||||
let polys: Vec<crate::flat::Polygon> = members.iter().map(|&j| vec![cuts[j].pts.clone()]).collect();
|
||||
let u = crate::polygon_bool::union(&polys);
|
||||
if !u.is_empty() && u.iter().all(|poly| poly.len() == 1) {
|
||||
for poly in u {
|
||||
out.push(Cut { pts: poly.into_iter().next().unwrap_or_default(), nse: None, ..cuts[i].clone() });
|
||||
}
|
||||
} else {
|
||||
out.extend(members.iter().map(|&j| cuts[j].clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// `generateSectionPlan`: Primitive (u → x, Höhe → y) und Ausmass.
|
||||
pub fn section_primitives(out: &Output, mono: bool, hidden_lines: bool, vis: &Visibility) -> (Vec<Primitive>, [f64; 4]) {
|
||||
section_primitives_at(out, mono, hidden_lines, vis, 0.0, Detail::Mittel, false, &HashSet::new())
|
||||
section_primitives_at(out, mono, hidden_lines, vis, 0.0, Detail::Mittel, false, &CutRules::default())
|
||||
}
|
||||
|
||||
/// [140] Bauteile (ids) aus losen Schüttungen/Unterbau (`standards::is_loose_fill`: Kies, Magerbeton,
|
||||
@@ -2410,12 +2574,21 @@ fn loose_cut(cp: &Cut, loose: &HashSet<String>) -> bool {
|
||||
/// [`section_primitives`] beim Massstab 1:`scale` (dünne Schichten zusammengefasst, [`merge_thin_cuts`];
|
||||
/// Detail „fein" zeigt alle Schichten, `style::simplify_thin_layers`). Ab 1:100 (`style::solid_cut`, ausser
|
||||
/// `cut_hatch`/„fein") sind die geschnittenen Flächen schwarz ohne Fugen und Schraffur, nur mit dem Umriss —
|
||||
/// ausser Schichten aus losen Schüttungen/Unterbau (`loose`, s. [`loose_cut`]): die bleiben schraffiert.
|
||||
/// ausser Schichten aus losen Schüttungen/Unterbau (`rules.loose`, s. [`loose_cut`]): die bleiben schraffiert.
|
||||
/// [33] Overrides (`rules.ov`) haben Vorrang vor beidem: Füllung, Schraffur und Umriss der Regel.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn section_primitives_at(out: &Output, mono: bool, hidden_lines: bool, vis: &Visibility, scale: f64, detail: Detail, cut_hatch: bool, loose: &HashSet<String>) -> (Vec<Primitive>, [f64; 4]) {
|
||||
pub fn section_primitives_at(out: &Output, mono: bool, hidden_lines: bool, vis: &Visibility, scale: f64, detail: Detail, cut_hatch: bool, rules: &CutRules) -> (Vec<Primitive>, [f64; 4]) {
|
||||
let loose = &rules.loose;
|
||||
let black = solid_cut(detail, scale, cut_hatch);
|
||||
let thin_scale = if simplify_thin_layers(detail, scale) && !black { scale } else { 0.0 };
|
||||
let merged = plain_thin_insulation(merge_thin_cuts(&out.cuts, thin_scale), thin_scale);
|
||||
let with_ov: Vec<Cut>;
|
||||
let cuts: &[Cut] = if rules.ov.is_empty() {
|
||||
&out.cuts
|
||||
} else {
|
||||
with_ov = out.cuts.iter().zip(rules.ov.iter().chain(std::iter::repeat(&None))).map(|(c, o)| Cut { ov: o.clone(), ..c.clone() }).collect();
|
||||
&with_ov
|
||||
};
|
||||
let merged = merge_override_groups(plain_thin_insulation(merge_thin_cuts(cuts, thin_scale), thin_scale));
|
||||
let mut prims = Vec::new();
|
||||
let mut acc = Acc::new();
|
||||
let shown = |code: &str| vis.visible(code) && vis.render(code);
|
||||
@@ -2452,8 +2625,12 @@ pub fn section_primitives_at(out: &Output, mono: bool, hidden_lines: bool, vis:
|
||||
let fill = cp.fill.as_deref().unwrap_or(HATCH_PAPER);
|
||||
let hatch = cp.hatch.clone().unwrap_or_else(section_hatch);
|
||||
let solid = hatch.pattern == HatchPattern::Solid;
|
||||
let black = black && !loose_cut(cp, loose);
|
||||
let (fill, hatch) = if black {
|
||||
let ov = cp.ov.as_ref();
|
||||
// Ohne Override: schwarz ab 1:100 (ausser lose Schüttungen). Mit Override, der Füllung oder Schraffur
|
||||
// setzt, gilt die Regel ([33]); eine Regel, die nur den Umriss setzt, lässt die Fläche schwarz.
|
||||
let base_black = black && !loose_cut(cp, loose);
|
||||
let black = base_black && !ov.is_some_and(|o| o.styles());
|
||||
let (mut fill, mut hatch) = if black {
|
||||
(HATCH_INK.to_string(), no_hatch())
|
||||
} else if mono {
|
||||
let mono_fill = if solid { HATCH_INK } else { HATCH_PAPER };
|
||||
@@ -2462,8 +2639,22 @@ pub fn section_primitives_at(out: &Output, mono: bool, hidden_lines: bool, vis:
|
||||
} else {
|
||||
(fill.to_string(), hatch)
|
||||
};
|
||||
if let Some(o) = ov.filter(|o| o.styles()) {
|
||||
match &o.hatch {
|
||||
// Nur Füllung gesetzt: ab 1:100 (sonst schwarz) ohne Muster, sonst Muster wie gehabt.
|
||||
HatchOv::Keep if base_black => hatch = no_hatch(),
|
||||
HatchOv::Keep | HatchOv::Material => {}
|
||||
HatchOv::None => hatch = no_hatch(),
|
||||
HatchOv::Pattern(h) => hatch = if mono { HatchRender { color: SECTION_INK.into(), ..h.clone() } } else { h.clone() },
|
||||
}
|
||||
if let Some(f) = &o.fill {
|
||||
fill = f.clone();
|
||||
}
|
||||
}
|
||||
let outline = ov.and_then(|o| o.outline);
|
||||
let src = cp.source_id.clone();
|
||||
let mut pr = if black { polygon(pts, &fill, "none", 0.0, hatch) } else { polygon(pts, &fill, SECTION_INK, SECTION_JOINT_MM, hatch) };
|
||||
let stroked = if black { outline == Some(true) } else { outline != Some(false) };
|
||||
let mut pr = if stroked { polygon(pts, &fill, SECTION_INK, SECTION_JOINT_MM, hatch) } else { polygon(pts, &fill, "none", 0.0, hatch) };
|
||||
if let Primitive::Polygon { wall_id, ceiling_id, roof_id, stair_id, extruded_solid_id, no_stroke_edges, greyed, .. } = &mut pr {
|
||||
*wall_id = if cp.kind == Kind::Wall { src.clone() } else { None };
|
||||
*ceiling_id = if cp.kind == Kind::Slab && cp.stair_id.is_none() { src.clone() } else { None };
|
||||
@@ -2973,7 +3164,7 @@ pub fn section_plan_buf(p: &Project, args: &[f64], text: &str) -> Result<Vec<u8>
|
||||
let hidden = v.get("hiddenLines").and_then(|b| b.as_bool()).unwrap_or(false);
|
||||
let scale = v.get("scale").and_then(|s| s.as_f64()).filter(|s| *s > 0.0 && s.is_finite()).unwrap_or(100.0);
|
||||
let detail = Detail::parse(v.get("detail").and_then(|d| d.as_str()).unwrap_or("mittel"));
|
||||
let (mut prims, bounds) = section_primitives_at(&out, mono, hidden, &vis, scale, detail, level.cut_hatch, &loose_fill_components(p));
|
||||
let (mut prims, bounds) = section_primitives_at(&out, mono, hidden, &vis, scale, detail, level.cut_hatch, &CutRules::of(p, &out));
|
||||
w.post = super::extras::sketch_post(Some(level.sketch), scale);
|
||||
// Strichstärken nach Massstab ([32]) wie im Grundriss.
|
||||
super::extras::scale_line_weights(p, scale, &mut prims);
|
||||
@@ -3206,7 +3397,7 @@ mod tests {
|
||||
};
|
||||
let loose: HashSet<String> = ["mager".to_string()].into();
|
||||
let fills = |scale: f64, loose: &HashSet<String>| -> Vec<(String, HatchPattern, String)> {
|
||||
let (prims, _) = section_primitives_at(&out, true, false, &Visibility::default(), scale, Detail::Mittel, false, loose);
|
||||
let (prims, _) = section_primitives_at(&out, true, false, &Visibility::default(), scale, Detail::Mittel, false, &CutRules { loose: loose.clone(), ov: Vec::new() });
|
||||
prims.iter().filter_map(|q| match q { Primitive::Polygon { fill, hatch, stroke, ceiling_id: Some(_), .. } => Some((fill.clone(), hatch.pattern, stroke.clone())), _ => None }).collect()
|
||||
};
|
||||
let f = fills(100.0, &loose);
|
||||
@@ -3233,7 +3424,7 @@ mod tests {
|
||||
let out = compute_section(&p, &l, &[]).unwrap().unwrap();
|
||||
let vis = Visibility::default();
|
||||
let stat = |scale: f64, detail: Detail, cut_hatch: bool| {
|
||||
let (prims, _) = section_primitives_at(&out, true, false, &vis, scale, detail, cut_hatch, &loose_fill_components(&p));
|
||||
let (prims, _) = section_primitives_at(&out, true, false, &vis, scale, detail, cut_hatch, &CutRules::of(&p, &out));
|
||||
let cuts: Vec<_> = prims.iter().filter_map(|q| match q { Primitive::Polygon { fill, hatch, stroke, wall_id, ceiling_id, .. } if wall_id.is_some() || ceiling_id.is_some() => Some((fill.clone(), hatch.pattern, stroke.clone())), _ => None }).collect();
|
||||
let outline = prims.iter().filter(|q| matches!(q, Primitive::Line { cls, .. } if cls == "section-cut-outline")).count();
|
||||
(cuts, outline)
|
||||
@@ -3247,6 +3438,56 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// [33] „Deckenaufbau weiss“ (Standardregel, über eine Ansichtsvorlage eingeschaltet): im Schnitt 1:100 sind
|
||||
/// Unterlagsboden und Dämmung über der Betondecke EINE weisse Fläche ohne Schraffur mit Umriss, die Decke
|
||||
/// selbst und die Wände bleiben schwarz; 1:50 ebenso weiss statt schraffiert. Ohne Regel (oder Regel aus)
|
||||
/// unverändert. Eine Regel nach Baustoff-Kategorie mit Schraffur „material“ zeigt die Schraffur auch ab 1:100.
|
||||
#[test]
|
||||
fn override_deckenaufbau_weiss() {
|
||||
let mut p = sample();
|
||||
let l = level(&p, "schnitt-a");
|
||||
let out = compute_section(&p, &l, &[]).unwrap().unwrap();
|
||||
let vis = Visibility::default();
|
||||
let slab = |p: &Project, scale: f64| {
|
||||
let (prims, _) = section_primitives_at(&out, true, false, &vis, scale, Detail::Mittel, false, &CutRules::of(p, &out));
|
||||
prims.iter().filter_map(|q| match q { Primitive::Polygon { fill, hatch, stroke, ceiling_id: Some(_), .. } => Some((fill.clone(), hatch.pattern, stroke.clone())), _ => None }).collect::<Vec<_>>()
|
||||
};
|
||||
let before = slab(&p, 100.0);
|
||||
// Estrich-Stücke (Dämmung liegt jeweils darunter, gleich breit oder fehlt am Wandanschluss) und Beton.
|
||||
let n = |comp: &str| out.cuts.iter().filter(|c| c.kind == Kind::Slab && c.component_id.as_deref() == Some(comp)).count();
|
||||
let (screed, insulation, concrete) = (n("screed"), n("insulation"), n("concrete"));
|
||||
assert!(screed >= insulation && insulation > 0 && concrete > 0);
|
||||
assert_eq!(before.len(), screed + insulation + concrete);
|
||||
assert!(before.iter().all(|(f, _, s)| f == HATCH_INK && s == "none"));
|
||||
// Standardregel geladen, aber aus: nichts ändert sich.
|
||||
p.override_rules = Some(crate::standards::override_rules().into_iter().map(|v| serde_json::from_value(v).unwrap()).collect());
|
||||
assert_eq!(slab(&p, 100.0), before);
|
||||
assert!(cut_overrides(&p, &out.cuts).is_empty());
|
||||
p.override_rules.as_mut().unwrap()[0].enabled = true;
|
||||
let after = slab(&p, 100.0);
|
||||
let white: Vec<_> = after.iter().filter(|(f, _, _)| f == "#ffffff").collect();
|
||||
assert_eq!(white.len(), screed, "Estrich + Dämmung je Stück als eine Fläche: {after:?}");
|
||||
assert!(white.iter().all(|w| (w.1, w.2.as_str()) == (HatchPattern::None, SECTION_INK)));
|
||||
assert_eq!(after.iter().filter(|(f, _, s)| f == HATCH_INK && s == "none").count(), concrete, "Betondecke bleibt schwarz");
|
||||
let at50 = slab(&p, 50.0);
|
||||
assert_eq!(at50.iter().filter(|(f, h, _)| f == "#ffffff" && *h == HatchPattern::None).count(), screed);
|
||||
assert!(at50.iter().any(|(f, h, _)| f != "#ffffff" && *h != HatchPattern::None), "Beton 1:50 schraffiert");
|
||||
// Wände unberührt (Regel gilt nur für Decken).
|
||||
let walls = |p: &Project| {
|
||||
let (prims, _) = section_primitives_at(&out, true, false, &vis, 100.0, Detail::Mittel, false, &CutRules::of(p, &out));
|
||||
prims.iter().filter(|q| matches!(q, Primitive::Polygon { wall_id: Some(_), fill, .. } if fill != HATCH_INK)).count()
|
||||
};
|
||||
assert_eq!(walls(&p), 0);
|
||||
// Baustoff-Kategorie „insulation“ mit Materialschraffur: Dämmung der Wände auch 1:100 schraffiert.
|
||||
let mut r: OverrideRule = serde_json::from_value(serde_json::json!({"id": "d", "name": "Dämmung", "enabled": true,
|
||||
"condition": {"type": "material_category", "operator": "equals", "value": "insulation"}, "actions": {"hatch": "material"}})).unwrap();
|
||||
p.override_rules = Some(vec![r.clone()]);
|
||||
assert!(walls(&p) > 0);
|
||||
r.enabled = false;
|
||||
p.override_rules = Some(vec![r]);
|
||||
assert_eq!(walls(&p), 0);
|
||||
}
|
||||
|
||||
/// [140] Trittschall 4 cm: 1:100 (0.4 mm Papier) ohne Zickzack, 1:50 mit; dicke Dämmung bleibt.
|
||||
#[test]
|
||||
fn duenne_daemmung_ohne_muster_ab_1_100() {
|
||||
|
||||
@@ -245,18 +245,46 @@ fn wall_poche(c: &Ctx, out: &mut Vec<Primitive>, e: &EffWall, gaps: &[(f64, f64)
|
||||
let outline_mm = wall_lw * detail.outline_factor();
|
||||
let layer_mm = LAYER_JOINT_MM * detail.layer_factor();
|
||||
let thick: Vec<f64> = wt.layers.iter().map(|l| l.thickness).collect();
|
||||
// [140] Ab 1:100 (und „grob") schwarze Sammelfläche mit Umriss, ohne Schichten (`style::solid_cut`).
|
||||
let f = crate::plan::wall_poche::wall_poche(&encode_wall_poche(w, &thick, total, ref_off, gaps, cuts, c.solid_cut(), view_only, reveals));
|
||||
// [33] Overrides auf Schichten (Füllung, Schraffur, Umriss); ohne aktive Regel lauter leere Aktionen.
|
||||
let lov = super::overrides::layer_actions(p, "wall", &w.category_code, Some(&wt.name), &wt.layers);
|
||||
let solid = c.solid_cut();
|
||||
// [140] Ab 1:100 (und „grob") schwarze Sammelfläche mit Umriss, ohne Schichten (`style::solid_cut`) —
|
||||
// [33] ausser eine Regel stylt eine Schicht: dann Schichten, die übrigen schwarz ohne Fugen dazwischen.
|
||||
let layered_solid = solid && lov.iter().any(|a| a.styles());
|
||||
let f = crate::plan::wall_poche::wall_poche(&encode_wall_poche(w, &thick, total, ref_off, gaps, cuts, solid && !layered_solid, view_only, reveals));
|
||||
let target = thin_layer_targets(&thick, detail, c.a.scale);
|
||||
if f.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
let ov_of = |li: usize| lov.get(target.get(li).copied().unwrap_or(li));
|
||||
// Stil einer Schicht mit Override bzw. schwarz (Schicht ohne Override in `layered_solid`).
|
||||
let apply_ov = |li: usize, (hatch, fill): (HatchRender, String)| -> (HatchRender, String) {
|
||||
let Some(o) = ov_of(li).filter(|o| o.styles()) else {
|
||||
return if layered_solid { (no_hatch(), HATCH_INK.to_string()) } else { (hatch, fill) };
|
||||
};
|
||||
let hatch = match o.hatch.as_deref() {
|
||||
None if solid => no_hatch(),
|
||||
None | Some("material") => hatch,
|
||||
Some("none") => no_hatch(),
|
||||
Some(id) => super::domains::resolve_hatch_or_none(p, id, Some(angle), None),
|
||||
};
|
||||
(hatch, o.fill_color.clone().unwrap_or(fill))
|
||||
};
|
||||
// Fuge zwischen Schicht `a` und `b` weglassen: beide schwarz, gleicher Override ohne Muster, oder Umriss aus.
|
||||
let skip_joint = |a: usize, b: Option<usize>| {
|
||||
let (oa, ob) = (ov_of(a), b.and_then(ov_of));
|
||||
let styled = |o: Option<&super::overrides::LayerActions>| o.is_some_and(|o| o.styles());
|
||||
(layered_solid && !styled(oa) && b.is_none_or(|_| !styled(ob)))
|
||||
|| (b.is_some() && oa.is_some_and(|o| o.styles() && o.plain()) && oa == ob)
|
||||
|| oa.is_some_and(|o| o.outline == Some(false))
|
||||
|| ob.is_some_and(|o| o.outline == Some(false))
|
||||
};
|
||||
let mut styles: HashMap<usize, (HatchRender, String)> = HashMap::new();
|
||||
let mut style_of = |li: usize| -> Result<(HatchRender, String), String> {
|
||||
if let Some(s) = styles.get(&li) {
|
||||
return Ok(s.clone());
|
||||
}
|
||||
let (mut hatch, fill) = layer_style(p, w, wt, target.get(li).copied().unwrap_or(li), category, angle)?;
|
||||
let (mut hatch, fill) = apply_ov(li, layer_style(p, w, wt, target.get(li).copied().unwrap_or(li), category, angle)?);
|
||||
if bend.is_none() {
|
||||
anchor_band_pattern(&mut hatch, w, cuts, thick.get(li).copied().unwrap_or(0.0));
|
||||
}
|
||||
@@ -280,7 +308,7 @@ fn wall_poche(c: &Ctx, out: &mut Vec<Primitive>, e: &EffWall, gaps: &[(f64, f64)
|
||||
// im Uhrzeigersinn: Laufrichtung 0° bzw. 180° im Gegenuhrzeigersinn; gebogen wird das
|
||||
// Band danach in `bend_prims`).
|
||||
let local = if u.arc.sigma() > 0.0 { 180.0 } else { 0.0 };
|
||||
let (mut hatch, fill) = layer_style(p, w, wt, target.get(li).copied().unwrap_or(li), category, local)?;
|
||||
let (mut hatch, fill) = apply_ov(li, layer_style(p, w, wt, target.get(li).copied().unwrap_or(li), category, local)?);
|
||||
hatch.polar = Some([u.arc.center.x, u.arc.center.y, u.arc.r]);
|
||||
out.push(wall_polygon(pts, &fill, "none", 0.0, hatch, greyed, Some(no_stroke), Some(&w.id), None));
|
||||
continue;
|
||||
@@ -304,6 +332,10 @@ fn wall_poche(c: &Ctx, out: &mut Vec<Primitive>, e: &EffWall, gaps: &[(f64, f64)
|
||||
if (art == 1.0 && target.get(li).is_some() && target.get(li) == target.get(li + 1)) || (art == 0.0 && merged(li)) {
|
||||
continue;
|
||||
}
|
||||
// [33] Fugen um Schichten mit Override (bzw. zwischen schwarzen Schichten) nach der Regel.
|
||||
if (art == 1.0 && skip_joint(li, Some(li + 1))) || (art == 0.0 && skip_joint(li, None)) {
|
||||
continue;
|
||||
}
|
||||
if art == 0.0 {
|
||||
out.push(mk_line(a, b, "layer-joint-l", layer_mm, None, Some(stroke), greyed, None));
|
||||
} else if art == 1.0 {
|
||||
|
||||
@@ -320,6 +320,7 @@ pub fn library() -> Vec<(&'static str, Vec<Value>)> {
|
||||
("roofTypes", roof_types()),
|
||||
("viewTemplates", view_templates()),
|
||||
("blockDefs", block_defs()),
|
||||
("overrideRules", override_rules()),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -416,6 +417,7 @@ fn managed(key: &str) -> &'static [&'static str] {
|
||||
"abbrev",
|
||||
],
|
||||
"blockDefs" => &["geom2d"],
|
||||
"overrideRules" => &["condition", "conditions", "actions"],
|
||||
_ => &["layers"],
|
||||
}
|
||||
}
|
||||
@@ -579,6 +581,99 @@ pub fn is_loose_fill(c: &crate::model::Component) -> bool {
|
||||
WORDS.iter().any(|w| name.contains(w)) && !name.contains("stein")
|
||||
}
|
||||
|
||||
/// [33] Baustoff-Kategorie eines Bauteils (für Override-Regeln „Materialkategorie“): an der Standard-Kennung
|
||||
/// (`std-c-…`), sonst am Namen (deutsch/englisch, Gross-/Kleinschreibung egal). Werte: "concrete", "masonry",
|
||||
/// "timber", "insulation", "screed", "flooring", "plaster", "loose_fill", "metal", "glass", "membrane", "air",
|
||||
/// "cladding", "stone", "other". Lose Schüttungen wie [`is_loose_fill`].
|
||||
pub fn material_category(c: &crate::model::Component) -> &'static str {
|
||||
let std = c.standard_id.as_deref().filter(|s| s.starts_with("std-c-")).unwrap_or(c.id.as_str());
|
||||
let by_std = match std {
|
||||
"std-c-beton" | "std-c-stahlbeton" => Some("concrete"),
|
||||
"std-c-backstein" | "std-c-kalksandstein" | "std-c-porenbeton" => Some("masonry"),
|
||||
"std-c-holz" | "std-c-bsp" | "std-c-holzwerkstoff" => Some("timber"),
|
||||
"std-c-mineralwolle" | "std-c-steinwolle" | "std-c-eps" | "std-c-xps" | "std-c-holzfaser" | "std-c-trittschall" => Some("insulation"),
|
||||
"std-c-gipskarton" | "std-c-innenputz" | "std-c-aussenputz" => Some("plaster"),
|
||||
"std-c-zementestrich" => Some("screed"),
|
||||
"std-c-parkett" | "std-c-keramik" => Some("flooring"),
|
||||
"std-c-glas" => Some("glass"),
|
||||
"std-c-stahl" | "std-c-aluminium" => Some("metal"),
|
||||
"std-c-naturstein" => Some("stone"),
|
||||
"std-c-erdreich" | "std-c-kies" => Some("loose_fill"),
|
||||
"std-c-sperrschicht" => Some("membrane"),
|
||||
"std-c-luft" => Some("air"),
|
||||
"std-c-lattung-v" | "std-c-lattung-h" | "std-c-boden-deckel" | "std-c-schindeln" | "std-c-trapezblech" | "std-c-faserzement" | "std-c-tonziegel" => Some("cladding"),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(k) = by_std {
|
||||
return k;
|
||||
}
|
||||
if is_loose_fill(c) {
|
||||
return "loose_fill";
|
||||
}
|
||||
let n = c.name.to_lowercase();
|
||||
let has = |ws: &[&str]| ws.iter().any(|w| n.contains(w));
|
||||
// Reihenfolge: spezifische Wörter vor allgemeinen („Faserzementplatten“ ist Bekleidung, nicht Belag).
|
||||
if has(&["estrich", "unterlagsboden", "anhydrit", "screed"]) {
|
||||
"screed"
|
||||
} else if has(&["lattung", "schalung", "schindel", "blech", "faserzement", "ziegel", "eindeckung", "bekleidung", "verkleidung", "cladding", "shingle"]) {
|
||||
"cladding"
|
||||
} else if has(&["dämm", "daemm", "wolle", "eps", "xps", "holzfaser", "trittschall", "insulation"]) {
|
||||
"insulation"
|
||||
} else if has(&["parkett", "platten", "belag", "linoleum", "teppich", "fliesen", "keramik", "flooring", "parquet", "tiles"]) {
|
||||
"flooring"
|
||||
} else if has(&["putz", "gips", "plaster"]) {
|
||||
"plaster"
|
||||
} else if has(&["abdicht", "sperr", "folie", "dampf", "bitumen", "membran"]) {
|
||||
"membrane"
|
||||
} else if has(&["luft", "hinterlüft", "air gap", "cavity"]) {
|
||||
"air"
|
||||
} else if has(&["beton", "concrete"]) {
|
||||
"concrete"
|
||||
} else if has(&["naturstein", "granit", "marmor", "kalkstein", "natural stone"]) {
|
||||
"stone"
|
||||
} else if has(&["stein", "mauerwerk", "brick", "masonry", "block"]) {
|
||||
"masonry"
|
||||
} else if has(&["holz", "bsp", "osb", "brettschicht", "timber", "wood", "clt", "glulam"]) {
|
||||
"timber"
|
||||
} else if has(&["stahl", "alu", "metall", "steel", "metal"]) {
|
||||
"metal"
|
||||
} else if has(&["glas", "glass"]) {
|
||||
"glass"
|
||||
} else {
|
||||
"other"
|
||||
}
|
||||
}
|
||||
|
||||
/// [33] Funktion einer Schicht, abgeleitet aus der Baustoff-Kategorie ([`material_category`]); "other" ohne.
|
||||
pub fn layer_function_of_category(cat: &str) -> Option<crate::model::LayerFunction> {
|
||||
use crate::model::LayerFunction as F;
|
||||
Some(match cat {
|
||||
"concrete" | "masonry" | "timber" | "metal" | "stone" => F::Structure,
|
||||
"insulation" => F::Insulation,
|
||||
"screed" => F::Screed,
|
||||
"flooring" => F::Finish,
|
||||
"plaster" => F::Plaster,
|
||||
"loose_fill" => F::Substructure,
|
||||
"membrane" => F::Membrane,
|
||||
"air" => F::Air,
|
||||
"cladding" | "glass" => F::Cladding,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
/// [33] Mitgelieferte Override-Regeln (Bausteine für Ansichtsvorlagen). Ausgeschaltet: sie wirken erst, wenn
|
||||
/// eine Ansichtsvorlage sie einschaltet (`enabledOverrideRuleIds`) — ohne Regel bleibt jede Darstellung, wie
|
||||
/// sie ist. „Deckenaufbau weiss“: die Schichten über der tragenden Schicht von Decken und Bodenplatten
|
||||
/// (Unterlagsboden, Trittschall, Belag) im Schnitt als weisse Fläche mit Umriss, auch ab 1:100 (statt schwarz).
|
||||
pub const STD_RULE_FLOOR_BUILDUP_WHITE: &str = "std-or-deckenaufbau-weiss";
|
||||
|
||||
pub fn override_rules() -> Vec<Value> {
|
||||
vec![json!({"id": STD_RULE_FLOOR_BUILDUP_WHITE, "name": "Deckenaufbau weiss", "enabled": false,
|
||||
"condition": {"type": "layer_position", "operator": "equals", "value": "above"},
|
||||
"conditions": [{"type": "element_kind", "operator": "contains", "value": "slab"}],
|
||||
"actions": {"fillColor": "#ffffff", "hatch": "none", "outline": true}})]
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in new issue
Block a user