[K4] S2: typisiertes Rust-Modell (generiert aus TS-Typen), Document::project(), Kennzahlen rechnen auf dem Dokument; TS-Sammler entfernt
This commit is contained in:
1 parent
8a120329ee
commit
8d4952e5d0
16 files changed
+3700
-119
No files matched your search
@@ -125,9 +125,13 @@ truck (`trucksolid`) bleibt eigenes WASM-Modul (Panic-Isolation), wird vom Kern
|
||||
- ✅ **S1 Dokument im Kern** (28.10.): `document.rs` hält das Projekt als JSON-Baum, `core/document.ts` spiegelt jede
|
||||
Änderung von `store.project` (setProject, Laden, Undo/Redo) als Ops (`diffToOps` → `doc_apply`); Selbstheilung durch Neuöffnen.
|
||||
Test: 300 Zufallsänderungen, Kern-JSON == TS-Projekt. (Spiegel, TS ist noch Quelle der Änderungen.)
|
||||
- ○ **S2 Ableitungen lesen das Dokument**: typisierte Sicht (serde) je Domäne; Plan/Schnitt/Ansicht, 3D, Kennzahlen, Export
|
||||
rechnen mit `doc`-Handle statt mit flach gesammelten Arrays; TS-Sammler/-Adapter werden gelöscht ([K3d] hängt hier dran:
|
||||
Plan-Puffer v2 mit Pick-IDs und vollem Primitive-Umfang).
|
||||
- ◐ **S2 Ableitungen lesen das Dokument** (28.10.): typisiertes Rust-Modell `model/` (`generated.rs` aus den TS-Typen per
|
||||
`scripts/gen-rust-model.py`, `manual.rs` für getaggte Unions; Hin-und-zurück-Test gegen das Beispielprojekt mit
|
||||
`deny_unknown_fields`), `Document::project()` als gecachte typisierte Sicht, `documentFor(project)` (TS) hält ein gemeinsames
|
||||
Dokument per Differenz aktuell. Erster Verbraucher: Kennzahlen (`kennzahlen.rs::compute`, TS-Sammler gelöscht).
|
||||
Nächste: Baurecht/Footprint, Sonnenstand, Raumprogramm, danach Plan/Schnitt/Ansicht, 3D, Export.
|
||||
Ziel: Plan/Schnitt/Ansicht, 3D, Export rechnen mit `doc`-Handle statt flach gesammelter Arrays; TS-Sammler/-Adapter werden gelöscht
|
||||
([K3d] hängt hier dran: Plan-Puffer v2 mit Pick-IDs und vollem Primitive-Umfang).
|
||||
- ○ **S3 Änderungen kommen aus Rust**: Befehle (Zustandsautomaten, Werkzeuge) erzeugen Ops im Kern; Undo/Redo, Validierung
|
||||
(`validateOps`) und Gruppen/Ebenen-Logik wandern nach Rust; `diffToOps` entfällt, TS hält nur noch eine Leseansicht.
|
||||
- ○ **S4 Typen aus Rust**: `types.ts` wird aus den Rust-Strukturen erzeugt (ts-rs); Datei-I/O (`projectFormat`, Migration, IFC/DXF/
|
||||
|
||||
@@ -0,0 +1,259 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Einmaliger Übersetzer: TS-Modelltypen -> Rust-Strukturen (serde) für src-tauri/core/src/model/generated.rs.
|
||||
|
||||
Zweck: Startpunkt für [K4] S2/S4. Danach gehört die Rust-Datei dem Kern (von Hand gepflegt, TS-Typen
|
||||
kommen künftig aus Rust). Nicht für den Dauerbetrieb gedacht.
|
||||
"""
|
||||
import re, sys, json
|
||||
|
||||
SRC = [
|
||||
"src/model/types.ts", "src/model/viewTypes.ts", "src/text/richText.ts", "src/geometry/roomArea.ts",
|
||||
]
|
||||
# Typen, die von Hand geschrieben sind (diskriminierte Unions o. ä.) oder ersetzt werden
|
||||
MANUAL = {"Vec2", "Drawing2DGeom", "VerticalAnchor", "ColumnProfile", "LayoutAnnotation", "ParametricRule",
|
||||
"LayoutAnnotationPatch", "ContextObject", "BuiltinPaletteBank", "SiaKey", "SiaAggregate",
|
||||
"BoolMark", "TextRange"}
|
||||
TAGGED = {"GridRule", "ModuleRule", "ConditionalThicknessRule", "ReferenceLineRule", "SequenceRule", "ImportedMesh", "ContourSet", "TerrainMesh", "ContextImage"}
|
||||
ONLY = None # alle Interfaces aus SRC, die erreichbar sind
|
||||
|
||||
def strip_comments(s):
|
||||
s = re.sub(r"/\*.*?\*/", "", s, flags=re.S)
|
||||
s = re.sub(r"(?m)//.*$", "", s)
|
||||
return s
|
||||
|
||||
TOK = re.compile(r'\s*(?:(?P<str>"(?:[^"\\]|\\.)*")|(?P<num>-?\d+(?:\.\d+)?)|(?P<id>[A-Za-z_$][\w$]*)|(?P<p>=>|[{}\[\]()<>;:,|?=&*.]))')
|
||||
|
||||
def tokenize(s):
|
||||
pos = 0; out = []
|
||||
while pos < len(s):
|
||||
m = TOK.match(s, pos)
|
||||
if not m:
|
||||
if s[pos:].strip() == "": break
|
||||
pos += 1; continue
|
||||
pos = m.end()
|
||||
for k in ("str", "num", "id", "p"):
|
||||
if m.group(k) is not None:
|
||||
out.append((k, m.group(k))); break
|
||||
return out
|
||||
|
||||
class P:
|
||||
def __init__(self, toks): self.t = toks; self.i = 0
|
||||
def peek(self, o=0): return self.t[self.i + o] if self.i + o < len(self.t) else (None, None)
|
||||
def next(self): v = self.t[self.i]; self.i += 1; return v
|
||||
def eat(self, v):
|
||||
if self.peek()[1] == v: self.i += 1; return True
|
||||
return False
|
||||
|
||||
def parse_type(p):
|
||||
alts = []
|
||||
p.eat("|")
|
||||
while True:
|
||||
alts.append(parse_primary(p))
|
||||
if not p.eat("|"): break
|
||||
return alts[0] if len(alts) == 1 else ("union", alts)
|
||||
|
||||
def parse_primary(p):
|
||||
k, v = p.peek()
|
||||
if v == "(":
|
||||
p.next(); t = parse_type(p); p.eat(")"); base = t
|
||||
elif k == "str":
|
||||
p.next(); base = ("lit", json.loads(v))
|
||||
elif k == "num":
|
||||
p.next(); base = ("numlit", float(v))
|
||||
elif v == "{":
|
||||
p.next(); fields = parse_fields(p); p.eat("}"); base = ("obj", fields)
|
||||
elif v == "[":
|
||||
p.next(); items = [parse_type(p)]
|
||||
while p.eat(","): items.append(parse_type(p))
|
||||
p.eat("]"); base = ("tuple", items)
|
||||
elif k == "id":
|
||||
p.next()
|
||||
if v == "keyof":
|
||||
parse_primary(p); base = ("keyof",)
|
||||
else:
|
||||
args = []
|
||||
if p.peek()[1] == "<":
|
||||
p.next(); args.append(parse_type(p))
|
||||
while p.eat(","): args.append(parse_type(p))
|
||||
p.eat(">")
|
||||
base = ("ref", v, args)
|
||||
else:
|
||||
raise SyntaxError(f"unerwartet {p.peek()} @ {p.i}")
|
||||
while p.peek()[1] == "[" and p.peek(1)[1] == "]":
|
||||
p.next(); p.next(); base = ("array", base)
|
||||
return base
|
||||
|
||||
def parse_fields(p):
|
||||
fields = []
|
||||
while p.peek()[1] not in ("}", None):
|
||||
k, name = p.next()
|
||||
if k == "str": name = json.loads(name)
|
||||
opt = p.eat("?")
|
||||
p.eat(":")
|
||||
t = parse_type(p)
|
||||
p.eat(";") or p.eat(",")
|
||||
fields.append((name, opt, t))
|
||||
return fields
|
||||
|
||||
def parse_file(path):
|
||||
text = strip_comments(open(path).read())
|
||||
toks = tokenize(text)
|
||||
out = {}
|
||||
i = 0
|
||||
while i < len(toks):
|
||||
if toks[i][1] == "export" and toks[i+1][1] in ("interface", "type") and toks[i+2][0] == "id":
|
||||
kind = toks[i+1][1]; name = toks[i+2][1]
|
||||
j = i + 3
|
||||
try:
|
||||
p = P(toks); p.i = j
|
||||
if kind == "interface":
|
||||
while p.peek()[1] != "{": p.next()
|
||||
p.next(); fields = parse_fields(p); p.eat("}")
|
||||
out[name] = ("interface", fields)
|
||||
else:
|
||||
if p.peek()[1] == "<":
|
||||
i += 1; continue
|
||||
p.eat("=")
|
||||
out[name] = ("alias", parse_type(p))
|
||||
i = p.i
|
||||
continue
|
||||
except Exception as e:
|
||||
sys.stderr.write(f"skip {name}: {e}\n")
|
||||
i += 1
|
||||
return out
|
||||
|
||||
def snake(n):
|
||||
s = re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", n).lower()
|
||||
kw = {"type", "match", "ref", "box", "move", "in", "loop", "impl", "fn", "use", "mod", "as", "where", "for", "if", "else", "while", "static", "const", "struct", "enum", "trait", "pub", "let", "mut", "return", "break", "continue", "dyn", "async", "await", "try", "yield", "unsafe", "extern", "abstract", "final", "override", "macro", "typeof", "virtual", "become", "do", "priv", "unsized"}
|
||||
if s in ("super", "self", "crate", "Self"):
|
||||
return s + "_"
|
||||
return "r#" + s if s in kw else s
|
||||
|
||||
def pascal(v):
|
||||
parts = re.split(r"[^A-Za-z0-9]+", v)
|
||||
s = "".join(x[:1].upper() + x[1:] for x in parts if x)
|
||||
if not s or s[0].isdigit(): s = "V" + s
|
||||
return s
|
||||
|
||||
decls = {}
|
||||
for f in SRC:
|
||||
decls.update(parse_file(f))
|
||||
|
||||
out_items = [] # generated rust texts
|
||||
emitted = set()
|
||||
enum_counter = {}
|
||||
enum_lits = {}
|
||||
|
||||
PRIM = {"string": "String", "number": "f64", "boolean": "bool", "unknown": "serde_json::Value", "any": "serde_json::Value", "null": "()"}
|
||||
|
||||
def rust_enum(name, lits):
|
||||
seen = set(); lines = []
|
||||
for l in lits:
|
||||
v = pascal(l)
|
||||
base = v; n = 2
|
||||
while v in seen: v = f"{base}{n}"; n += 1
|
||||
seen.add(v)
|
||||
lines.append(f' #[serde(rename = {json.dumps(l, ensure_ascii=False)})]\n {v},')
|
||||
return ("#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]\n"
|
||||
f"pub enum {name} {{\n" + "\n".join(lines) + "\n}\n")
|
||||
|
||||
def rtype(t, ctx):
|
||||
"""-> (rust_type, is_option)"""
|
||||
k = t[0]
|
||||
if k == "ref":
|
||||
n, args = t[1], t[2]
|
||||
if n in PRIM: return PRIM[n], False
|
||||
if n == "Record": return f"std::collections::BTreeMap<String, {rtype(args[1], ctx)[0]}>", False
|
||||
if n == "Partial": return "serde_json::Value", False
|
||||
if n == "Array": return f"Vec<{rtype(args[0], ctx)[0]}>", False
|
||||
if n == "Date": return "String", False
|
||||
ensure(n)
|
||||
return n, False
|
||||
if k == "array":
|
||||
return f"Vec<{rtype(t[1], ctx)[0]}>", False
|
||||
if k == "tuple":
|
||||
if len(t[1]) == 2 and t[1][0] == t[1][1]:
|
||||
return f"[{rtype(t[1][0], ctx)[0]}; 2]", False
|
||||
return "serde_json::Value", False
|
||||
if k == "lit": return "String", False
|
||||
if k == "numlit": return "f64", False
|
||||
if k == "keyof": return "String", False
|
||||
if k == "obj":
|
||||
name = ctx
|
||||
emit_struct(name, t[1])
|
||||
return name, False
|
||||
if k == "union":
|
||||
alts = [a for a in t[1] if not (a[0] == "ref" and a[1] in ("undefined",))]
|
||||
had_undef = len(alts) != len(t[1])
|
||||
nulls = [a for a in alts if a[0] == "ref" and a[1] == "null"]
|
||||
alts = [a for a in alts if not (a[0] == "ref" and a[1] == "null")]
|
||||
opt = had_undef or bool(nulls)
|
||||
if len(alts) == 1:
|
||||
r, _ = rtype(alts[0], ctx); return (f"Option<{r}>" if nulls else r), had_undef
|
||||
if all(a[0] == "lit" for a in alts):
|
||||
lits = [a[1] for a in alts]
|
||||
ename = ctx
|
||||
n = 1
|
||||
while ename in enum_lits and enum_lits[ename] != lits:
|
||||
n += 1; ename = f"{ctx}{n}"
|
||||
if ename not in emitted:
|
||||
emitted.add(ename); enum_lits[ename] = lits; out_items.append(rust_enum(ename, lits))
|
||||
return ename, opt
|
||||
if all(a[0] == "numlit" for a in alts): return "f64", opt
|
||||
return "serde_json::Value", opt
|
||||
raise ValueError(t)
|
||||
|
||||
def emit_struct(name, fields):
|
||||
if name in emitted: return
|
||||
emitted.add(name)
|
||||
lines = []
|
||||
for fname, opt, t in fields:
|
||||
if fname == "type" and name in TAGGED:
|
||||
continue # Tag steckt im umgebenden Enum (model/manual.rs)
|
||||
sub = name + pascal(fname)
|
||||
r, uopt = rtype(t, sub)
|
||||
is_opt = opt or uopt
|
||||
rn = snake(fname)
|
||||
attrs = []
|
||||
if rn.replace("r#", "") != fname:
|
||||
attrs.append(f'rename = {json.dumps(fname)}')
|
||||
if r.startswith("Option<"):
|
||||
attrs.append('default')
|
||||
if is_opt:
|
||||
attrs.append('skip_serializing_if = "Option::is_none"')
|
||||
# sonst `T | null` ohne `?`: Feld ist da, darf null sein -> beim Schreiben `null` ausgeben
|
||||
elif is_opt:
|
||||
attrs.append('default'); attrs.append('skip_serializing_if = "Option::is_none"')
|
||||
r = f"Option<{r}>"
|
||||
a = f" #[serde({', '.join(attrs)})]\n" if attrs else ""
|
||||
lines.append(f"{a} pub {rn}: {r},")
|
||||
out_items.append("#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]\n"
|
||||
+ '#[cfg_attr(test, serde(deny_unknown_fields))]\n'
|
||||
+ f"pub struct {name} {{\n" + "\n".join(lines) + "\n}\n")
|
||||
|
||||
def ensure(n):
|
||||
if n in emitted or n in MANUAL: return
|
||||
d = decls.get(n)
|
||||
if d is None:
|
||||
sys.stderr.write(f"unbekannt: {n}\n"); return
|
||||
if d[0] == "interface":
|
||||
emit_struct(n, d[1])
|
||||
else:
|
||||
t = d[1]
|
||||
if t[0] == "union" and all(a[0] == "lit" for a in t[1]):
|
||||
emitted.add(n); enum_lits[n] = [a[1] for a in t[1]]; out_items.append(rust_enum(n, [a[1] for a in t[1]]))
|
||||
elif t[0] == "lit":
|
||||
emitted.add(n); out_items.append(rust_enum(n, [t[1]]))
|
||||
else:
|
||||
emitted.add(n)
|
||||
r, _ = rtype(t, n)
|
||||
out_items.append(f"pub type {n} = {r};\n")
|
||||
|
||||
for root in sys.argv[1:] or ["Project"]:
|
||||
ensure(root)
|
||||
|
||||
print("// GENERIERT von scripts/gen-rust-model.py aus den TS-Typen (Stand 28.10.), danach von Hand gepflegt.\n"
|
||||
"// Rust-Gegenstück zu src/model/types.ts ([K4] S2). Union-Typen mit Tag stehen in model/manual.rs.\n"
|
||||
"#![allow(clippy::large_enum_variant)]\n"
|
||||
"use super::manual::*;\nuse serde::{Deserialize, Serialize};\n")
|
||||
print("\n".join(out_items))
|
||||
Generated
+1
@@ -31,6 +31,7 @@ dependencies = [
|
||||
"console_error_panic_hook",
|
||||
"i_overlay",
|
||||
"kernel2d",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
@@ -19,6 +19,7 @@ web = ["dep:wasm-bindgen", "dep:console_error_panic_hook"]
|
||||
|
||||
[dependencies]
|
||||
i_overlay = { version = "9.1", default-features = false }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = { version = "1", features = ["preserve_order", "float_roundtrip"] }
|
||||
kernel2d = { path = "../kernel2d" }
|
||||
wasm-bindgen = { version = "0.2", optional = true }
|
||||
|
||||
@@ -7,8 +7,11 @@
|
||||
//! JSON kennt weder `undefined` noch NaN: fehlende Felder fehlen, nicht endliche Zahlen prüft TS
|
||||
//! vor dem Senden (`validateOps`).
|
||||
|
||||
use crate::model::Project;
|
||||
use serde::Deserialize;
|
||||
use serde_json::{Map, Value};
|
||||
use std::collections::HashSet;
|
||||
use std::rc::Rc;
|
||||
|
||||
/// Eine Änderung am Projekt (Spiegel von `CoreOp` in `core/ops.ts`).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
@@ -90,12 +93,14 @@ fn has_dup(v: Option<&Value>) -> bool {
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct Document {
|
||||
root: Map<String, Value>,
|
||||
/// Typisierte Sicht (Cache); jede Änderung verwirft sie.
|
||||
typed: Option<Rc<Project>>,
|
||||
}
|
||||
|
||||
impl Document {
|
||||
pub fn from_json(text: &str) -> Result<Document, String> {
|
||||
match serde_json::from_str::<Value>(text) {
|
||||
Ok(Value::Object(root)) => Ok(Document { root }),
|
||||
Ok(Value::Object(root)) => Ok(Document { root, typed: None }),
|
||||
Ok(_) => Err("Projekt ist kein JSON-Objekt".into()),
|
||||
Err(e) => Err(e.to_string()),
|
||||
}
|
||||
@@ -105,6 +110,23 @@ impl Document {
|
||||
serde_json::to_string(&self.root).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Typisierte Sicht des Projekts (gecacht bis zur nächsten Änderung). Fehler = Feld, das dem
|
||||
/// Modell widerspricht (Meldung von serde).
|
||||
pub fn project(&mut self) -> Result<Rc<Project>, String> {
|
||||
if let Some(p) = &self.typed {
|
||||
return Ok(p.clone());
|
||||
}
|
||||
// Die Map wird nur ausgeliehen: `Value::Object` braucht Besitz, daher temporär herausnehmen.
|
||||
let value = Value::Object(std::mem::take(&mut self.root));
|
||||
let parsed = Project::deserialize(&value).map_err(|e| e.to_string());
|
||||
if let Value::Object(m) = value {
|
||||
self.root = m;
|
||||
}
|
||||
let p = Rc::new(parsed?);
|
||||
self.typed = Some(p.clone());
|
||||
Ok(p)
|
||||
}
|
||||
|
||||
pub fn field(&self, key: &str) -> Option<&Value> {
|
||||
self.root.get(key)
|
||||
}
|
||||
@@ -167,6 +189,7 @@ impl Document {
|
||||
|
||||
/// Wendet `ops` atomar an. Verstösse (neue doppelte ids) → `Err(Meldungen)`, Dokument unverändert.
|
||||
pub fn apply(&mut self, ops: &[Op]) -> Result<(), Vec<String>> {
|
||||
self.typed = None;
|
||||
// Zustand der berührten Felder sichern (Rücknahme) und Alt-Doppelungen merken.
|
||||
let mut saved: Vec<(String, Option<Value>)> = Vec::new();
|
||||
let mut had_dup: HashSet<String> = HashSet::new();
|
||||
@@ -259,6 +282,17 @@ mod tests {
|
||||
d.apply(&ops(json!([{"kind":"add","collection":"walls","items":[{"id":"z"}]}]))).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn typisierte_sicht_folgt_den_ops() {
|
||||
let text = include_str!("../tests/fixtures/sample_project.json");
|
||||
let mut d = Document::from_json(text).unwrap();
|
||||
let n = d.project().unwrap().walls.len();
|
||||
assert!(n > 0);
|
||||
let id = d.project().unwrap().walls[0].id.clone();
|
||||
d.apply(&ops(json!([{"kind":"remove","collection":"walls","ids":[id]}]))).unwrap();
|
||||
assert_eq!(d.project().unwrap().walls.len(), n - 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kaputte_ops_sind_fehler() {
|
||||
assert!(Op::from_json(&json!({"kind":"add","collection":"w","items":[{"x":1}]})).is_err());
|
||||
|
||||
@@ -133,3 +133,122 @@ mod tests {
|
||||
assert_eq!(area_sums(0, &[], &[], f64::NAN, &[]), AreaSums { by_level: vec![], gv: 0.0, parcel: None });
|
||||
}
|
||||
}
|
||||
|
||||
// ── Kennzahlen aus dem Projekt-Dokument ([K4] S2) ───────────────────────────
|
||||
|
||||
use crate::model::{DrawingLevelKind, Project, SiaCategory};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct LevelKennzahlen {
|
||||
pub level_id: String,
|
||||
pub name: String,
|
||||
/// Geschossfläche (SIA 416 GF) aus den Räumen.
|
||||
pub gf: f64,
|
||||
/// Anrechenbare Fläche ≈ Nettogeschossfläche NGF.
|
||||
pub agf: f64,
|
||||
pub rooms: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
pub struct Kennzahlen {
|
||||
pub levels: Vec<LevelKennzahlen>,
|
||||
pub gf: f64,
|
||||
pub agf: f64,
|
||||
pub gv: f64,
|
||||
pub footprint: f64,
|
||||
pub az: Option<f64>,
|
||||
pub uez: Option<f64>,
|
||||
}
|
||||
|
||||
fn category_index(c: SiaCategory) -> usize {
|
||||
match c {
|
||||
SiaCategory::HNF => 0,
|
||||
SiaCategory::NNF => 1,
|
||||
SiaCategory::VF => 2,
|
||||
SiaCategory::FF => 3,
|
||||
SiaCategory::KGF => 4,
|
||||
SiaCategory::AGF => 5,
|
||||
}
|
||||
}
|
||||
|
||||
/// Flächen je Geschoss (SIA 416), Gebäudevolumen, Ausnützungs- und Überbauungsziffer.
|
||||
pub fn compute(p: &Project) -> Kennzahlen {
|
||||
let mut floors: Vec<&crate::model::DrawingLevel> = p.drawing_levels.iter().filter(|l| l.kind == DrawingLevelKind::Floor).collect();
|
||||
floors.sort_by(|a, b| a.base_elevation.unwrap_or(0.0).partial_cmp(&b.base_elevation.unwrap_or(0.0)).unwrap_or(std::cmp::Ordering::Equal));
|
||||
let mut level_index: std::collections::HashMap<&str, usize> = std::collections::HashMap::new();
|
||||
for (i, l) in floors.iter().enumerate() {
|
||||
level_index.entry(l.id.as_str()).or_insert(i);
|
||||
}
|
||||
let all_rooms = p.rooms.as_deref().unwrap_or(&[]);
|
||||
let rooms: Vec<&crate::model::Room> = all_rooms.iter().filter(|r| level_index.contains_key(r.floor_id.as_str())).collect();
|
||||
let rooms_in: Vec<RoomIn> = rooms
|
||||
.iter()
|
||||
.map(|r| RoomIn {
|
||||
level: level_index[r.floor_id.as_str()],
|
||||
category: category_index(r.sia_category),
|
||||
boundary: r.boundary.iter().map(|v| [v.x, v.y]).collect(),
|
||||
})
|
||||
.collect();
|
||||
let solids: Vec<SolidIn> = p
|
||||
.extruded_solids
|
||||
.as_deref()
|
||||
.unwrap_or(&[])
|
||||
.iter()
|
||||
.map(|s| SolidIn {
|
||||
subtract: s.operation.as_deref() == Some("subtract"),
|
||||
points: if s.circle.is_some() { vec![] } else { s.points.iter().map(|v| [v.x, v.y]).collect() },
|
||||
circle_r: s.circle.as_ref().map_or(f64::NAN, |c| c.r),
|
||||
height: s.height,
|
||||
taper: s.taper.unwrap_or(0.0),
|
||||
})
|
||||
.collect();
|
||||
let parcel_ring: Vec<[f64; 2]> = p.site_rules.as_ref().map(|r| r.parcel.iter().map(|v| [v.x, v.y]).collect()).unwrap_or_default();
|
||||
let sums = area_sums(floors.len(), &rooms_in, &solids, p.parcel_area.unwrap_or(f64::NAN), &parcel_ring);
|
||||
let levels: Vec<LevelKennzahlen> = floors
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, l)| {
|
||||
let entries: Vec<(usize, f64)> = (0..CATEGORIES).map(|k| (k, sums.by_level[i][k])).collect();
|
||||
let b = crate::room_area::balance(&entries);
|
||||
LevelKennzahlen {
|
||||
level_id: l.id.clone(),
|
||||
name: l.name.clone(),
|
||||
gf: b.agg_area[2],
|
||||
agf: b.agg_area[1],
|
||||
rooms: rooms.iter().filter(|r| r.floor_id == l.id).count(),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let gf: f64 = levels.iter().map(|l| l.gf).sum();
|
||||
let agf: f64 = levels.iter().map(|l| l.agf).sum();
|
||||
let footprint = levels.iter().find(|l| l.gf > 0.0).map_or(0.0, |l| l.gf);
|
||||
Kennzahlen {
|
||||
levels,
|
||||
gf,
|
||||
agf,
|
||||
gv: sums.gv,
|
||||
footprint,
|
||||
az: sums.parcel.filter(|x| *x != 0.0).map(|x| agf / x),
|
||||
uez: sums.parcel.filter(|x| *x != 0.0).map(|x| footprint / x),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod doc_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn kennzahlen_des_beispielprojekts() {
|
||||
let p: Project = serde_json::from_str(include_str!("../tests/fixtures/sample_project.json")).unwrap();
|
||||
let k = compute(&p);
|
||||
assert!(!k.levels.is_empty());
|
||||
let sum: f64 = k.levels.iter().map(|l| l.gf).sum();
|
||||
assert!((k.gf - sum).abs() < 1e-9);
|
||||
assert!(k.az.is_none() && k.uez.is_none());
|
||||
let with_parcel = Project { parcel_area: Some(1000.0), ..p };
|
||||
let k2 = compute(&with_parcel);
|
||||
assert!((k2.az.unwrap() - k2.agf / 1000.0).abs() < 1e-12);
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ pub mod plan_openings;
|
||||
pub mod delaunay;
|
||||
pub mod document;
|
||||
pub mod mesh_section;
|
||||
pub mod model;
|
||||
pub mod plan_elevation;
|
||||
pub mod plan_misc;
|
||||
pub mod plan_section;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,273 @@
|
||||
//! Von Hand geschriebene Teile des Modells: Typen mit Tag (diskriminierte Unions) und `Vec2`.
|
||||
//! Gegenstück zu den entsprechenden Typen in `src/model/types.ts`.
|
||||
|
||||
use super::generated::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
|
||||
#[cfg_attr(test, serde(deny_unknown_fields))]
|
||||
pub struct Vec2 {
|
||||
pub x: f64,
|
||||
pub y: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "mode")]
|
||||
pub enum VerticalAnchor {
|
||||
#[serde(rename = "floor")]
|
||||
Floor {
|
||||
#[serde(rename = "floorId")]
|
||||
floor_id: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
offset: Option<f64>,
|
||||
},
|
||||
#[serde(rename = "custom")]
|
||||
Custom { z: f64 },
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "kind")]
|
||||
pub enum ColumnProfile {
|
||||
#[serde(rename = "rect")]
|
||||
Rect { width: f64, depth: f64 },
|
||||
#[serde(rename = "round")]
|
||||
Round { radius: f64 },
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Offset2 {
|
||||
pub along: f64,
|
||||
pub perp: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum KoteKind {
|
||||
#[serde(rename = "okFertig")]
|
||||
OkFertig,
|
||||
#[serde(rename = "ukFertig")]
|
||||
UkFertig,
|
||||
#[serde(rename = "okRoh")]
|
||||
OkRoh,
|
||||
#[serde(rename = "ukRoh")]
|
||||
UkRoh,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum SplineMode {
|
||||
Fit,
|
||||
Control,
|
||||
}
|
||||
|
||||
/// Geometrie eines 2D-Zeichenelements (Tag `shape`).
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "shape")]
|
||||
pub enum Drawing2DGeom {
|
||||
#[serde(rename = "line")]
|
||||
Line { a: Vec2, b: Vec2 },
|
||||
#[serde(rename = "xline")]
|
||||
Xline { a: Vec2, b: Vec2 },
|
||||
#[serde(rename = "ray")]
|
||||
Ray { a: Vec2, b: Vec2 },
|
||||
#[serde(rename = "polyline")]
|
||||
Polyline {
|
||||
pts: Vec<Vec2>,
|
||||
closed: bool,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
bulge: Option<Vec<f64>>,
|
||||
},
|
||||
#[serde(rename = "rect")]
|
||||
Rect { min: Vec2, max: Vec2 },
|
||||
#[serde(rename = "circle")]
|
||||
Circle { center: Vec2, r: f64 },
|
||||
#[serde(rename = "arc")]
|
||||
Arc { center: Vec2, r: f64, a0: f64, a1: f64 },
|
||||
#[serde(rename = "ellipse")]
|
||||
Ellipse { center: Vec2, rx: f64, ry: f64, rotation: f64 },
|
||||
#[serde(rename = "bezier")]
|
||||
Bezier { pts: Vec<Vec2> },
|
||||
#[serde(rename = "spline")]
|
||||
Spline {
|
||||
pts: Vec<Vec2>,
|
||||
closed: bool,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
mode: Option<SplineMode>,
|
||||
},
|
||||
#[serde(rename = "dimension")]
|
||||
Dimension {
|
||||
pts: Vec<Vec2>,
|
||||
offset: f64,
|
||||
#[serde(rename = "gapMm", default, skip_serializing_if = "Option::is_none")]
|
||||
gap_mm: Option<f64>,
|
||||
#[serde(rename = "overshootMm", default, skip_serializing_if = "Option::is_none")]
|
||||
overshoot_mm: Option<f64>,
|
||||
#[serde(rename = "tickLenMm", default, skip_serializing_if = "Option::is_none")]
|
||||
tick_len_mm: Option<f64>,
|
||||
#[serde(rename = "textHeightMm", default, skip_serializing_if = "Option::is_none")]
|
||||
text_height_mm: Option<f64>,
|
||||
#[serde(rename = "lineWeightMm", default, skip_serializing_if = "Option::is_none")]
|
||||
line_weight_mm: Option<f64>,
|
||||
#[serde(rename = "extWeightMm", default, skip_serializing_if = "Option::is_none")]
|
||||
ext_weight_mm: Option<f64>,
|
||||
#[serde(rename = "tickWeightMm", default, skip_serializing_if = "Option::is_none")]
|
||||
tick_weight_mm: Option<f64>,
|
||||
#[serde(rename = "textOffsetsMm", default, skip_serializing_if = "Option::is_none")]
|
||||
text_offsets_mm: Option<Vec<Offset2>>,
|
||||
},
|
||||
#[serde(rename = "kote")]
|
||||
Kote { at: Vec2, value: f64, kind: KoteKind, rotation: f64 },
|
||||
#[serde(rename = "detailref")]
|
||||
Detailref {
|
||||
at: Vec2,
|
||||
label: String,
|
||||
#[serde(rename = "sheetLayoutId", default, skip_serializing_if = "Option::is_none")]
|
||||
sheet_layout_id: Option<String>,
|
||||
#[serde(rename = "sheetLabel", default, skip_serializing_if = "Option::is_none")]
|
||||
sheet_label: Option<String>,
|
||||
},
|
||||
#[serde(rename = "scalebar")]
|
||||
Scalebar {
|
||||
at: Vec2,
|
||||
#[serde(rename = "segmentLength")]
|
||||
segment_length: f64,
|
||||
segments: f64,
|
||||
},
|
||||
#[serde(rename = "pointmarker")]
|
||||
Pointmarker { at: Vec2 },
|
||||
#[serde(rename = "text")]
|
||||
Text {
|
||||
at: Vec2,
|
||||
text: String,
|
||||
height: f64,
|
||||
angle: f64,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
width: Option<f64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
marks: Option<Marks>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
doc: Option<RichTextDoc>,
|
||||
#[serde(rename = "leaderTarget", default, skip_serializing_if = "Option::is_none")]
|
||||
leader_target: Option<Vec2>,
|
||||
#[serde(rename = "leaderBendPoints", default, skip_serializing_if = "Option::is_none")]
|
||||
leader_bend_points: Option<Vec<Vec2>>,
|
||||
#[serde(rename = "pathPts", default, skip_serializing_if = "Option::is_none")]
|
||||
path_pts: Option<Vec<Vec2>>,
|
||||
},
|
||||
#[serde(rename = "block")]
|
||||
Block {
|
||||
#[serde(rename = "blockDefId")]
|
||||
block_def_id: String,
|
||||
at: Vec2,
|
||||
rotation: f64,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
scale: Option<f64>,
|
||||
},
|
||||
#[serde(rename = "image")]
|
||||
Image {
|
||||
min: Vec2,
|
||||
max: Vec2,
|
||||
src: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
opacity: Option<f64>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Layout-Beschriftung (Tag `kind`).
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "kind")]
|
||||
pub enum LayoutAnnotation {
|
||||
#[serde(rename = "line")]
|
||||
Line {
|
||||
id: String,
|
||||
#[serde(rename = "x1Mm")]
|
||||
x1_mm: f64,
|
||||
#[serde(rename = "y1Mm")]
|
||||
y1_mm: f64,
|
||||
#[serde(rename = "x2Mm")]
|
||||
x2_mm: f64,
|
||||
#[serde(rename = "y2Mm")]
|
||||
y2_mm: f64,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
color: Option<String>,
|
||||
#[serde(rename = "weightMm", default, skip_serializing_if = "Option::is_none")]
|
||||
weight_mm: Option<f64>,
|
||||
},
|
||||
#[serde(rename = "rect")]
|
||||
Rect {
|
||||
id: String,
|
||||
#[serde(rename = "xMm")]
|
||||
x_mm: f64,
|
||||
#[serde(rename = "yMm")]
|
||||
y_mm: f64,
|
||||
#[serde(rename = "widthMm")]
|
||||
width_mm: f64,
|
||||
#[serde(rename = "heightMm")]
|
||||
height_mm: f64,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
color: Option<String>,
|
||||
#[serde(rename = "weightMm", default, skip_serializing_if = "Option::is_none")]
|
||||
weight_mm: Option<f64>,
|
||||
},
|
||||
#[serde(rename = "text")]
|
||||
Text {
|
||||
id: String,
|
||||
#[serde(rename = "xMm")]
|
||||
x_mm: f64,
|
||||
#[serde(rename = "yMm")]
|
||||
y_mm: f64,
|
||||
text: String,
|
||||
#[serde(rename = "heightMm")]
|
||||
height_mm: f64,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
color: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
doc: Option<RichTextDoc>,
|
||||
#[serde(rename = "widthMm", default, skip_serializing_if = "Option::is_none")]
|
||||
width_mm: Option<f64>,
|
||||
},
|
||||
#[serde(rename = "image")]
|
||||
Image {
|
||||
id: String,
|
||||
#[serde(rename = "xMm")]
|
||||
x_mm: f64,
|
||||
#[serde(rename = "yMm")]
|
||||
y_mm: f64,
|
||||
#[serde(rename = "widthMm")]
|
||||
width_mm: f64,
|
||||
#[serde(rename = "heightMm")]
|
||||
height_mm: f64,
|
||||
src: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
opacity: Option<f64>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Parametrische Wandregel (Tag `type`).
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum ParametricRule {
|
||||
#[serde(rename = "grid")]
|
||||
Grid(GridRule),
|
||||
#[serde(rename = "module")]
|
||||
Module(ModuleRule),
|
||||
#[serde(rename = "conditional-thickness")]
|
||||
ConditionalThickness(ConditionalThicknessRule),
|
||||
#[serde(rename = "reference-line")]
|
||||
ReferenceLine(ReferenceLineRule),
|
||||
#[serde(rename = "sequence")]
|
||||
Sequence(SequenceRule),
|
||||
}
|
||||
|
||||
/// Kontext-Objekt (Tag `type`).
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum ContextObject {
|
||||
#[serde(rename = "importedMesh")]
|
||||
ImportedMesh(ImportedMesh),
|
||||
#[serde(rename = "contourSet")]
|
||||
ContourSet(ContourSet),
|
||||
#[serde(rename = "terrainMesh")]
|
||||
TerrainMesh(TerrainMesh),
|
||||
#[serde(rename = "image")]
|
||||
Image(ContextImage),
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
//! Typisiertes Projektmodell ([K4] S2): Rust-Gegenstück zu `src/model/types.ts`. `generated.rs`
|
||||
//! entstand aus den TS-Typen (`scripts/gen-rust-model.py`) und wird ab jetzt von Hand gepflegt;
|
||||
//! Typen mit Tag stehen in `manual.rs`.
|
||||
|
||||
pub mod generated;
|
||||
pub mod manual;
|
||||
|
||||
pub use generated::*;
|
||||
pub use manual::*;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use serde_json::Value;
|
||||
|
||||
/// Zahlen als f64 vergleichbar machen (JS kennt keinen Unterschied zwischen 3 und 3.0).
|
||||
fn norm(v: &Value) -> Value {
|
||||
match v {
|
||||
Value::Number(n) => serde_json::Number::from_f64(n.as_f64().unwrap()).map_or(Value::Null, Value::Number),
|
||||
Value::Array(a) => Value::Array(a.iter().map(norm).collect()),
|
||||
Value::Object(o) => Value::Object(o.iter().map(|(k, v)| (k.clone(), norm(v))).collect()),
|
||||
other => other.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
fn roundtrip(name: &str, text: &str) {
|
||||
let raw: Value = serde_json::from_str(text).unwrap();
|
||||
// `deny_unknown_fields` (nur im Test) meldet jedes Feld, das dem Modell fehlt.
|
||||
let p: Project = serde_json::from_value(raw.clone()).unwrap_or_else(|e| panic!("{name}: {e}"));
|
||||
let back = serde_json::to_value(&p).unwrap();
|
||||
assert_eq!(norm(&back), norm(&raw), "{name}: Hin-und-zurück weicht ab");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn beispielprojekt_hin_und_zurueck() {
|
||||
roundtrip("sample_project", include_str!("../../tests/fixtures/sample_project.json"));
|
||||
}
|
||||
}
|
||||
@@ -61,3 +61,11 @@ pub fn doc_apply(h: u32, ops_json: &str) -> String {
|
||||
pub fn doc_json(h: u32) -> String {
|
||||
with_doc(h, |d| d.to_json()).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Kennzahlen des Projekts als JSON (leer bei Fehler: Dokument nicht offen oder Modell passt nicht).
|
||||
#[wasm_bindgen]
|
||||
pub fn doc_kennzahlen(h: u32) -> String {
|
||||
with_doc(h, |d| d.project().ok().map(|p| serde_json::to_string(&crate::kennzahlen::compute(&p)).unwrap_or_default()))
|
||||
.flatten()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
//! Bindungen der Kennzahlen-Rechenteile (`crate::kennzahlen`).
|
||||
|
||||
use crate::flat_read::pairs;
|
||||
use crate::flat_read::Reader;
|
||||
use crate::kennzahlen::{self, RoomIn, SolidIn};
|
||||
use crate::kennzahlen;
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Grundriss `[x0, y0, …]`, Kreisradius (NaN = kein Kreis), Höhe, Verjüngung → m³.
|
||||
@@ -10,41 +9,3 @@ use wasm_bindgen::prelude::wasm_bindgen;
|
||||
pub fn kz_solid_volume(points: &[f64], circle_r: f64, height: f64, taper: f64) -> f64 {
|
||||
kennzahlen::solid_volume(&pairs(points), circle_r, height, taper)
|
||||
}
|
||||
|
||||
fn read_rooms(buf: &[f64]) -> Option<Vec<RoomIn>> {
|
||||
let mut r = Reader::new(buf);
|
||||
let n = r.count()?;
|
||||
let mut out = Vec::with_capacity(n.min(1 << 16));
|
||||
for _ in 0..n {
|
||||
let (level, category) = (r.count()?, r.count()?);
|
||||
out.push(RoomIn { level, category, boundary: r.ring()? });
|
||||
}
|
||||
Some(out)
|
||||
}
|
||||
|
||||
fn read_solids(buf: &[f64]) -> Option<Vec<SolidIn>> {
|
||||
let mut r = Reader::new(buf);
|
||||
let n = r.count()?;
|
||||
let mut out = Vec::with_capacity(n.min(1 << 16));
|
||||
for _ in 0..n {
|
||||
let subtract = r.num()? != 0.0;
|
||||
let (circle_r, height, taper) = (r.num()?, r.num()?, r.num()?);
|
||||
out.push(SolidIn { subtract, points: r.ring()?, circle_r, height, taper });
|
||||
}
|
||||
Some(out)
|
||||
}
|
||||
|
||||
/// Räume `[n, (geschoss, kategorie, nPkt, x, y, …)…]`, Körper
|
||||
/// `[n, (abzug 0/1, radius|NaN, höhe, verjüngung, nPkt, x, y, …)…]`, Parzellenzahl, Parzellenring
|
||||
/// `[x0, y0, …]` → `[gv, parzelle|NaN, (6 Kategorie-Summen je Geschoss)…]`.
|
||||
#[wasm_bindgen]
|
||||
pub fn kz_area_sums(n_levels: u32, rooms: &[f64], solids: &[f64], parcel_area: f64, parcel_ring: &[f64]) -> Vec<f64> {
|
||||
let rooms = read_rooms(rooms).unwrap_or_default();
|
||||
let solids = read_solids(solids).unwrap_or_default();
|
||||
let s = kennzahlen::area_sums(n_levels.min(1 << 16) as usize, &rooms, &solids, parcel_area, &pairs(parcel_ring));
|
||||
let mut out = vec![s.gv, s.parcel.unwrap_or(f64::NAN)];
|
||||
for l in s.by_level {
|
||||
out.extend(l);
|
||||
}
|
||||
out
|
||||
}
|
||||
+936
@@ -0,0 +1,936 @@
|
||||
{
|
||||
"id": "demo",
|
||||
"name": "Demo-Haus",
|
||||
"lineStyles": [
|
||||
{
|
||||
"id": "hatch-hair",
|
||||
"name": "Volllinie 0.02",
|
||||
"weight": 0.02,
|
||||
"color": "#1a1a1a",
|
||||
"dash": null
|
||||
},
|
||||
{
|
||||
"id": "thin",
|
||||
"name": "Volllinie 0.13",
|
||||
"weight": 0.13,
|
||||
"color": "#1a1a1a",
|
||||
"dash": null
|
||||
},
|
||||
{
|
||||
"id": "medium",
|
||||
"name": "Volllinie 0.25",
|
||||
"weight": 0.25,
|
||||
"color": "#1a1a1a",
|
||||
"dash": null
|
||||
},
|
||||
{
|
||||
"id": "thick",
|
||||
"name": "Volllinie 0.5",
|
||||
"weight": 0.5,
|
||||
"color": "#0a0a0a",
|
||||
"dash": null
|
||||
},
|
||||
{
|
||||
"id": "hatch-dash",
|
||||
"name": "Dämmungsstrich",
|
||||
"weight": 0.02,
|
||||
"color": "#1a1a1a",
|
||||
"dash": [
|
||||
0.35,
|
||||
0.3
|
||||
]
|
||||
}
|
||||
],
|
||||
"hatches": [
|
||||
{
|
||||
"id": "none",
|
||||
"name": "Ohne",
|
||||
"pattern": "none",
|
||||
"scale": 1,
|
||||
"angle": 0,
|
||||
"color": "#1a1a1a"
|
||||
},
|
||||
{
|
||||
"id": "insulation",
|
||||
"name": "Wärmedämmung",
|
||||
"pattern": "insulation",
|
||||
"scale": 1,
|
||||
"angle": 0,
|
||||
"color": "#1a1a1a",
|
||||
"lineStyleId": "thin"
|
||||
},
|
||||
{
|
||||
"id": "diagonal",
|
||||
"name": "Diagonal",
|
||||
"pattern": "diagonal",
|
||||
"scale": 1,
|
||||
"angle": 45,
|
||||
"color": "#1a1a1a",
|
||||
"lineStyleId": "thin"
|
||||
},
|
||||
{
|
||||
"id": "crosshatch",
|
||||
"name": "Kreuzschraffur",
|
||||
"pattern": "crosshatch",
|
||||
"scale": 1,
|
||||
"angle": 0,
|
||||
"color": "#1a1a1a",
|
||||
"lineStyleId": "thin"
|
||||
},
|
||||
{
|
||||
"id": "solid-concrete",
|
||||
"name": "Beton (voll)",
|
||||
"pattern": "solid",
|
||||
"scale": 1,
|
||||
"angle": 0,
|
||||
"color": "#9aa0a6",
|
||||
"lineStyleId": "thin"
|
||||
},
|
||||
{
|
||||
"id": "sia-concrete",
|
||||
"name": "Beton (Kreuz)",
|
||||
"pattern": "crosshatch",
|
||||
"scale": 0.5,
|
||||
"angle": 45,
|
||||
"color": "#1a1a1a",
|
||||
"lineStyleId": "hatch-hair"
|
||||
},
|
||||
{
|
||||
"id": "sia-brick",
|
||||
"name": "Backstein (Diagonal)",
|
||||
"pattern": "diagonal",
|
||||
"scale": 0.5,
|
||||
"angle": 45,
|
||||
"relativeToWall": true,
|
||||
"color": "#1a1a1a",
|
||||
"lineStyleId": "hatch-hair"
|
||||
},
|
||||
{
|
||||
"id": "sia-insulation",
|
||||
"name": "Dämmung (Strich)",
|
||||
"pattern": "diagonal",
|
||||
"scale": 0.45,
|
||||
"angle": 0,
|
||||
"relativeToWall": true,
|
||||
"color": "#1a1a1a",
|
||||
"lineStyleId": "hatch-hair"
|
||||
}
|
||||
],
|
||||
"components": [
|
||||
{
|
||||
"id": "render-ext",
|
||||
"name": "Aussenputz",
|
||||
"color": "#d8d2c7",
|
||||
"hatchId": "none",
|
||||
"joinPriority": 10,
|
||||
"material": {
|
||||
"libraryId": "Plaster001",
|
||||
"color": "/assets/materials/Plaster001/color.jpg",
|
||||
"normal": "/assets/materials/Plaster001/normal.jpg",
|
||||
"roughness": "/assets/materials/Plaster001/roughness.jpg",
|
||||
"displacement": "/assets/materials/Plaster001/displacement.jpg",
|
||||
"sizeM": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "insulation",
|
||||
"name": "Wärmedämmung",
|
||||
"color": "#ffffff",
|
||||
"hatchId": "sia-insulation",
|
||||
"joinPriority": 20
|
||||
},
|
||||
{
|
||||
"id": "brick",
|
||||
"name": "Backstein",
|
||||
"color": "#8c5544",
|
||||
"hatchId": "sia-brick",
|
||||
"joinPriority": 50,
|
||||
"material": {
|
||||
"libraryId": "Bricks104",
|
||||
"color": "/assets/materials/Bricks104/color.jpg",
|
||||
"normal": "/assets/materials/Bricks104/normal.jpg",
|
||||
"roughness": "/assets/materials/Bricks104/roughness.jpg",
|
||||
"displacement": "/assets/materials/Bricks104/displacement.jpg",
|
||||
"ao": "/assets/materials/Bricks104/ao.jpg",
|
||||
"sizeM": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "render-int",
|
||||
"name": "Innenputz",
|
||||
"color": "#efece6",
|
||||
"hatchId": "none",
|
||||
"joinPriority": 10,
|
||||
"material": {
|
||||
"libraryId": "Plaster001",
|
||||
"color": "/assets/materials/Plaster001/color.jpg",
|
||||
"normal": "/assets/materials/Plaster001/normal.jpg",
|
||||
"roughness": "/assets/materials/Plaster001/roughness.jpg",
|
||||
"displacement": "/assets/materials/Plaster001/displacement.jpg",
|
||||
"sizeM": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "roof-tiles",
|
||||
"name": "Dachziegel",
|
||||
"color": "#b8735c",
|
||||
"hatchId": "sia-brick",
|
||||
"joinPriority": 15,
|
||||
"material": {
|
||||
"libraryId": "RoofingTiles013A",
|
||||
"color": "/assets/materials/RoofingTiles013A/color.jpg",
|
||||
"normal": "/assets/materials/RoofingTiles013A/normal.jpg",
|
||||
"roughness": "/assets/materials/RoofingTiles013A/roughness.jpg",
|
||||
"displacement": "/assets/materials/RoofingTiles013A/displacement.jpg",
|
||||
"ao": "/assets/materials/RoofingTiles013A/ao.jpg",
|
||||
"sizeM": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "concrete",
|
||||
"name": "Beton",
|
||||
"color": "#9aa0a6",
|
||||
"hatchId": "sia-concrete",
|
||||
"joinPriority": 100,
|
||||
"material": {
|
||||
"libraryId": "Concrete048",
|
||||
"color": "/assets/materials/Concrete048/color.jpg",
|
||||
"normal": "/assets/materials/Concrete048/normal.jpg",
|
||||
"roughness": "/assets/materials/Concrete048/roughness.jpg",
|
||||
"displacement": "/assets/materials/Concrete048/displacement.jpg",
|
||||
"ao": "/assets/materials/Concrete048/ao.jpg",
|
||||
"sizeM": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "screed",
|
||||
"name": "Zementestrich",
|
||||
"color": "#c9c2b3",
|
||||
"hatchId": "diagonal",
|
||||
"joinPriority": 30
|
||||
}
|
||||
],
|
||||
"wallTypes": [
|
||||
{
|
||||
"id": "aw",
|
||||
"name": "Aussenwand 34.5 cm",
|
||||
"layers": [
|
||||
{
|
||||
"componentId": "render-ext",
|
||||
"thickness": 0.02
|
||||
},
|
||||
{
|
||||
"componentId": "insulation",
|
||||
"thickness": 0.16,
|
||||
"jointLineStyleId": "thin"
|
||||
},
|
||||
{
|
||||
"componentId": "brick",
|
||||
"thickness": 0.15
|
||||
},
|
||||
{
|
||||
"componentId": "render-int",
|
||||
"thickness": 0.015
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "iw",
|
||||
"name": "Innenwand Mauerwerk verputzt 15 cm",
|
||||
"layers": [
|
||||
{
|
||||
"componentId": "render-int",
|
||||
"thickness": 0.015
|
||||
},
|
||||
{
|
||||
"componentId": "brick",
|
||||
"thickness": 0.12
|
||||
},
|
||||
{
|
||||
"componentId": "render-int",
|
||||
"thickness": 0.015
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"ceilingTypes": [
|
||||
{
|
||||
"id": "dg-massiv",
|
||||
"name": "Geschossdecke mehrschichtig",
|
||||
"layers": [
|
||||
{
|
||||
"componentId": "screed",
|
||||
"thickness": 0.06
|
||||
},
|
||||
{
|
||||
"componentId": "insulation",
|
||||
"thickness": 0.04,
|
||||
"jointLineStyleId": "thin"
|
||||
},
|
||||
{
|
||||
"componentId": "concrete",
|
||||
"thickness": 0.2
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"roofTypes": [
|
||||
{
|
||||
"id": "roof-warm",
|
||||
"name": "Steildach gedämmt",
|
||||
"layers": [
|
||||
{
|
||||
"componentId": "roof-tiles",
|
||||
"thickness": 0.04
|
||||
},
|
||||
{
|
||||
"componentId": "insulation",
|
||||
"thickness": 0.22,
|
||||
"jointLineStyleId": "thin"
|
||||
},
|
||||
{
|
||||
"componentId": "render-int",
|
||||
"thickness": 0.0125
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"doorTypes": [
|
||||
{
|
||||
"id": "door-standard",
|
||||
"name": "Zimmertür 0.9 m",
|
||||
"kind": "dreh",
|
||||
"leafCount": 1,
|
||||
"leafStyle": "glatt",
|
||||
"frameThickness": 0.05,
|
||||
"frameKind": "zarge",
|
||||
"frameWidth": 0.06,
|
||||
"defaultWidth": 0.9,
|
||||
"defaultHeight": 2
|
||||
},
|
||||
{
|
||||
"id": "door-entry",
|
||||
"name": "Haustür Blockrahmen (Oberlicht)",
|
||||
"kind": "dreh",
|
||||
"leafCount": 1,
|
||||
"leafStyle": "glas",
|
||||
"glazingRatio": 0.35,
|
||||
"frameThickness": 0.07,
|
||||
"frameKind": "blockrahmen",
|
||||
"frameWidth": 0.09,
|
||||
"insetFromFace": 0.14,
|
||||
"insetFace": "aussen",
|
||||
"transomHeight": 0.45,
|
||||
"threshold": true,
|
||||
"defaultWidth": 1.1,
|
||||
"defaultHeight": 2.1
|
||||
}
|
||||
],
|
||||
"windowTypes": [
|
||||
{
|
||||
"id": "window-standard",
|
||||
"name": "Fenster 1.2 × 1.4 m",
|
||||
"kind": "drehkipp",
|
||||
"wingCount": 1,
|
||||
"glazing": "zweifach",
|
||||
"frameThickness": 0.06,
|
||||
"frameWidth": 0.06,
|
||||
"defaultSillHeight": 0.9,
|
||||
"defaultWidth": 1.2,
|
||||
"defaultHeight": 1.4
|
||||
},
|
||||
{
|
||||
"id": "window-double",
|
||||
"name": "Fenster 2-flügl. + Oberlicht",
|
||||
"kind": "drehkipp",
|
||||
"wingCount": 2,
|
||||
"mullionRows": 1,
|
||||
"glazing": "dreifach",
|
||||
"frameThickness": 0.07,
|
||||
"frameWidth": 0.07,
|
||||
"insetFromFace": 0.12,
|
||||
"insetFace": "aussen",
|
||||
"transomHeight": 0.4,
|
||||
"defaultSillHeight": 0.85,
|
||||
"defaultWidth": 1.8,
|
||||
"defaultHeight": 1.9
|
||||
}
|
||||
],
|
||||
"stairTypes": [
|
||||
{
|
||||
"id": "stair-standard",
|
||||
"name": "Betontreppe 1.0 m",
|
||||
"structure": "beton",
|
||||
"closedRisers": true,
|
||||
"treadThickness": 0.05,
|
||||
"nosing": 0.03,
|
||||
"railing": "keine",
|
||||
"defaultWidth": 1
|
||||
},
|
||||
{
|
||||
"id": "stair-massiv",
|
||||
"name": "Massivtreppe (auf Sockel)",
|
||||
"structure": "massiv",
|
||||
"closedRisers": true,
|
||||
"treadThickness": 0.04,
|
||||
"nosing": 0.03,
|
||||
"railing": "keine",
|
||||
"defaultWidth": 1
|
||||
},
|
||||
{
|
||||
"id": "stair-wange-holz",
|
||||
"name": "Wangentreppe Holz (offen)",
|
||||
"structure": "wange",
|
||||
"closedRisers": false,
|
||||
"treadThickness": 0.05,
|
||||
"nosing": 0.03,
|
||||
"railing": "keine",
|
||||
"defaultWidth": 1
|
||||
},
|
||||
{
|
||||
"id": "stair-aufgesattelt",
|
||||
"name": "Aufgesattelt (Setzstufen)",
|
||||
"structure": "aufgesattelt",
|
||||
"closedRisers": true,
|
||||
"treadThickness": 0.05,
|
||||
"nosing": 0.025,
|
||||
"railing": "keine",
|
||||
"defaultWidth": 1
|
||||
}
|
||||
],
|
||||
"drawingLevels": [
|
||||
{
|
||||
"id": "eg",
|
||||
"name": "Erdgeschoss",
|
||||
"kind": "floor",
|
||||
"visible": true,
|
||||
"locked": false,
|
||||
"floorHeight": 2.6,
|
||||
"cutHeight": 1,
|
||||
"baseElevation": 0
|
||||
},
|
||||
{
|
||||
"id": "og",
|
||||
"name": "Obergeschoss",
|
||||
"kind": "floor",
|
||||
"visible": true,
|
||||
"locked": false,
|
||||
"floorHeight": 2.6,
|
||||
"cutHeight": 1,
|
||||
"baseElevation": 2.6
|
||||
},
|
||||
{
|
||||
"id": "schnitt-a",
|
||||
"name": "Schnitt A",
|
||||
"kind": "section",
|
||||
"visible": true,
|
||||
"locked": false,
|
||||
"linePoints": [
|
||||
{
|
||||
"x": -1,
|
||||
"y": 2
|
||||
},
|
||||
{
|
||||
"x": 6,
|
||||
"y": 2
|
||||
}
|
||||
],
|
||||
"directionSign": 1
|
||||
},
|
||||
{
|
||||
"id": "ansicht-sued",
|
||||
"name": "Ansicht Süd",
|
||||
"kind": "elevation",
|
||||
"visible": true,
|
||||
"locked": false,
|
||||
"linePoints": [
|
||||
{
|
||||
"x": -1,
|
||||
"y": -2
|
||||
},
|
||||
{
|
||||
"x": 6,
|
||||
"y": -2
|
||||
}
|
||||
],
|
||||
"directionSign": 1,
|
||||
"shadows": true
|
||||
},
|
||||
{
|
||||
"id": "detail-1",
|
||||
"name": "Detail 1",
|
||||
"kind": "drawing",
|
||||
"visible": true,
|
||||
"locked": false
|
||||
}
|
||||
],
|
||||
"layers": [
|
||||
{
|
||||
"code": "00",
|
||||
"name": "Raster",
|
||||
"color": "#484850",
|
||||
"lw": 0.13,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "01",
|
||||
"name": "Vermessung",
|
||||
"color": "#707078",
|
||||
"lw": 0.18,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "05",
|
||||
"name": "Kontext",
|
||||
"color": "#707078",
|
||||
"lw": 0.13,
|
||||
"visible": true,
|
||||
"locked": false,
|
||||
"children": [
|
||||
{
|
||||
"code": "10",
|
||||
"name": "Situation",
|
||||
"color": "#909090",
|
||||
"lw": 0.18,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "11",
|
||||
"name": "Strasse",
|
||||
"color": "#a89070",
|
||||
"lw": 0.18,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "12",
|
||||
"name": "Gebäude",
|
||||
"color": "#888888",
|
||||
"lw": 0.25,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "13",
|
||||
"name": "Bäume",
|
||||
"color": "#50a050",
|
||||
"lw": 0.13,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "14",
|
||||
"name": "Höhenlinien",
|
||||
"color": "#909050",
|
||||
"lw": 0.18,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "20",
|
||||
"name": "Wände",
|
||||
"color": "#0a0a0a",
|
||||
"lw": 0.35,
|
||||
"visible": true,
|
||||
"locked": false,
|
||||
"children": [
|
||||
{
|
||||
"code": "21",
|
||||
"name": "Türen/Fenster",
|
||||
"color": "#5080c8",
|
||||
"lw": 0.25,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "22",
|
||||
"name": "Möbel",
|
||||
"color": "#909090",
|
||||
"lw": 0.13,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "25",
|
||||
"name": "Stützen",
|
||||
"color": "#c87050",
|
||||
"lw": 0.5,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "30",
|
||||
"name": "Decken",
|
||||
"color": "#605850",
|
||||
"lw": 0.35,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "31",
|
||||
"name": "Dächer",
|
||||
"color": "#7a4a3a",
|
||||
"lw": 0.35,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "40",
|
||||
"name": "Treppen",
|
||||
"color": "#4a6a58",
|
||||
"lw": 0.35,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "35",
|
||||
"name": "Träger",
|
||||
"color": "#a87858",
|
||||
"lw": 0.5,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "50",
|
||||
"name": "Text",
|
||||
"color": "#d0d0d0",
|
||||
"lw": 0.13,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "60",
|
||||
"name": "Räume",
|
||||
"color": "#5a7a9a",
|
||||
"lw": 0.13,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "90",
|
||||
"name": "Referenzen",
|
||||
"color": "#585860",
|
||||
"lw": 0.13,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"code": "99",
|
||||
"name": "Konstruktion",
|
||||
"color": "#404048",
|
||||
"lw": 0.13,
|
||||
"visible": true,
|
||||
"locked": false
|
||||
}
|
||||
],
|
||||
"walls": [
|
||||
{
|
||||
"id": "W1",
|
||||
"type": "wall",
|
||||
"floorId": "eg",
|
||||
"categoryCode": "20",
|
||||
"start": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"end": {
|
||||
"x": 5,
|
||||
"y": 0
|
||||
},
|
||||
"wallTypeId": "aw",
|
||||
"height": 2.6
|
||||
},
|
||||
{
|
||||
"id": "W2",
|
||||
"type": "wall",
|
||||
"floorId": "eg",
|
||||
"categoryCode": "20",
|
||||
"start": {
|
||||
"x": 5,
|
||||
"y": 0
|
||||
},
|
||||
"end": {
|
||||
"x": 5,
|
||||
"y": 4
|
||||
},
|
||||
"wallTypeId": "aw",
|
||||
"height": 2.6
|
||||
},
|
||||
{
|
||||
"id": "W3",
|
||||
"type": "wall",
|
||||
"floorId": "eg",
|
||||
"categoryCode": "20",
|
||||
"start": {
|
||||
"x": 5,
|
||||
"y": 4
|
||||
},
|
||||
"end": {
|
||||
"x": 0,
|
||||
"y": 4
|
||||
},
|
||||
"wallTypeId": "aw",
|
||||
"height": 2.6
|
||||
},
|
||||
{
|
||||
"id": "W4",
|
||||
"type": "wall",
|
||||
"floorId": "eg",
|
||||
"categoryCode": "20",
|
||||
"start": {
|
||||
"x": 0,
|
||||
"y": 4
|
||||
},
|
||||
"end": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"wallTypeId": "aw",
|
||||
"height": 2.6
|
||||
},
|
||||
{
|
||||
"id": "W9",
|
||||
"type": "wall",
|
||||
"floorId": "eg",
|
||||
"categoryCode": "20",
|
||||
"start": {
|
||||
"x": 2.4,
|
||||
"y": 0
|
||||
},
|
||||
"end": {
|
||||
"x": 2.4,
|
||||
"y": 4
|
||||
},
|
||||
"wallTypeId": "iw",
|
||||
"height": 2.6
|
||||
},
|
||||
{
|
||||
"id": "W5",
|
||||
"type": "wall",
|
||||
"floorId": "og",
|
||||
"categoryCode": "20",
|
||||
"start": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"end": {
|
||||
"x": 5,
|
||||
"y": 0
|
||||
},
|
||||
"wallTypeId": "aw",
|
||||
"height": 2.6
|
||||
},
|
||||
{
|
||||
"id": "W6",
|
||||
"type": "wall",
|
||||
"floorId": "og",
|
||||
"categoryCode": "20",
|
||||
"start": {
|
||||
"x": 5,
|
||||
"y": 0
|
||||
},
|
||||
"end": {
|
||||
"x": 5,
|
||||
"y": 3
|
||||
},
|
||||
"wallTypeId": "aw",
|
||||
"height": 2.6
|
||||
},
|
||||
{
|
||||
"id": "W7",
|
||||
"type": "wall",
|
||||
"floorId": "og",
|
||||
"categoryCode": "20",
|
||||
"start": {
|
||||
"x": 5,
|
||||
"y": 3
|
||||
},
|
||||
"end": {
|
||||
"x": 0,
|
||||
"y": 3
|
||||
},
|
||||
"wallTypeId": "aw",
|
||||
"height": 2.6
|
||||
},
|
||||
{
|
||||
"id": "W8",
|
||||
"type": "wall",
|
||||
"floorId": "og",
|
||||
"categoryCode": "20",
|
||||
"start": {
|
||||
"x": 0,
|
||||
"y": 3
|
||||
},
|
||||
"end": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"wallTypeId": "aw",
|
||||
"height": 2.6
|
||||
}
|
||||
],
|
||||
"openings": [
|
||||
{
|
||||
"id": "D1",
|
||||
"type": "opening",
|
||||
"hostWallId": "W1",
|
||||
"categoryCode": "21",
|
||||
"kind": "door",
|
||||
"typeId": "door-standard",
|
||||
"position": 0.8,
|
||||
"width": 0.9,
|
||||
"height": 2.1,
|
||||
"sillHeight": 0,
|
||||
"swing": "left",
|
||||
"hinge": "start"
|
||||
},
|
||||
{
|
||||
"id": "O1",
|
||||
"type": "opening",
|
||||
"hostWallId": "W1",
|
||||
"categoryCode": "21",
|
||||
"kind": "window",
|
||||
"typeId": "window-standard",
|
||||
"position": 3,
|
||||
"width": 1,
|
||||
"height": 1.2,
|
||||
"sillHeight": 0.9
|
||||
},
|
||||
{
|
||||
"id": "O2",
|
||||
"type": "opening",
|
||||
"hostWallId": "W3",
|
||||
"categoryCode": "21",
|
||||
"kind": "window",
|
||||
"typeId": "window-standard",
|
||||
"position": 0.6,
|
||||
"width": 1.4,
|
||||
"height": 1.3,
|
||||
"sillHeight": 0.9
|
||||
}
|
||||
],
|
||||
"ceilings": [
|
||||
{
|
||||
"id": "C1",
|
||||
"type": "ceiling",
|
||||
"floorId": "eg",
|
||||
"categoryCode": "30",
|
||||
"outline": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 5,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 5,
|
||||
"y": 4
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 4
|
||||
}
|
||||
],
|
||||
"wallTypeId": "aw",
|
||||
"ceilingTypeId": "dg-massiv"
|
||||
}
|
||||
],
|
||||
"roofs": [
|
||||
{
|
||||
"id": "RF1",
|
||||
"type": "roof",
|
||||
"floorId": "og",
|
||||
"categoryCode": "31",
|
||||
"outline": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 5,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 5,
|
||||
"y": 4
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 4
|
||||
}
|
||||
],
|
||||
"shape": "sattel",
|
||||
"pitchDeg": 30,
|
||||
"overhang": 0.4,
|
||||
"ridgeAxis": "x",
|
||||
"thickness": 0.2
|
||||
}
|
||||
],
|
||||
"stairs": [
|
||||
{
|
||||
"id": "ST1",
|
||||
"type": "stair",
|
||||
"floorId": "eg",
|
||||
"categoryCode": "40",
|
||||
"shape": "straight",
|
||||
"typeId": "stair-standard",
|
||||
"start": {
|
||||
"x": 3.7,
|
||||
"y": 0.4
|
||||
},
|
||||
"dir": {
|
||||
"x": 0,
|
||||
"y": 1
|
||||
},
|
||||
"runLength": 3.2,
|
||||
"width": 1,
|
||||
"totalRise": 2.6,
|
||||
"stepCount": 15,
|
||||
"up": true
|
||||
}
|
||||
],
|
||||
"rooms": [
|
||||
{
|
||||
"id": "R1",
|
||||
"type": "room",
|
||||
"floorId": "eg",
|
||||
"categoryCode": "60",
|
||||
"siaCategory": "HNF",
|
||||
"name": "Wohnen",
|
||||
"boundary": [
|
||||
{
|
||||
"x": 0.1725,
|
||||
"y": 0.1725
|
||||
},
|
||||
{
|
||||
"x": 4.8275,
|
||||
"y": 0.1725
|
||||
},
|
||||
{
|
||||
"x": 4.8275,
|
||||
"y": 3.8275
|
||||
},
|
||||
{
|
||||
"x": 0.1725,
|
||||
"y": 3.8275
|
||||
}
|
||||
],
|
||||
"color": "#6b7280",
|
||||
"stampAnchor": {
|
||||
"x": 2.5,
|
||||
"y": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"drawings2d": [],
|
||||
"context": []
|
||||
}
|
||||
@@ -6,14 +6,14 @@
|
||||
// • Ausnützungs-/Überbauungsziffer nur mit `project.parcelArea` oder der Parzellengrenze (`siteRules`).
|
||||
// • Raumprogramm (`project.roomProgram`, Soll) gegen die gezeichneten Räume.
|
||||
// Exakt für Prismen/Kegelstümpfe/Kreise, Näherung sonst (Fasen/Rundungen). Raumflächen je
|
||||
// Geschoss und Kategorie, Volumen und Parzellenfläche rechnet der Rust-Kern
|
||||
// (`src-tauri/core/src/kennzahlen.rs`); die Zusammenfassung nach SIA 416 (NF/NGF/GF) bleibt bei
|
||||
// `geometry/roomArea.ts::balance`, die auch Raumstempel, Bilanz, Raumliste und IFC nutzen.
|
||||
// Geschoss und Kategorie, Volumen, Parzellenfläche und die SIA-416-Zusammenfassung rechnet der
|
||||
// Rust-Kern auf dem Projekt-Dokument (`src-tauri/core/src/kennzahlen.rs`).
|
||||
|
||||
import type { ExtrudedSolid, Project } from "../model/types";
|
||||
import { SIA_CATEGORIES, balance, polygonArea } from "../geometry/roomArea";
|
||||
import { polygonArea } from "../geometry/roomArea";
|
||||
import { core } from "../engine/coreWasm";
|
||||
import { FlatWriter } from "../geometry/coreFlat";
|
||||
import { documentFor } from "../core/document";
|
||||
|
||||
export interface LevelKennzahlen {
|
||||
levelId: string;
|
||||
@@ -46,56 +46,12 @@ export function solidVolume(s: ExtrudedSolid): number {
|
||||
|
||||
const finite = (n: number): number => (Number.isFinite(n) ? n : 0);
|
||||
|
||||
/** Körper flach (`web/kennzahlen.rs`). */
|
||||
function encodeSolids(solids: ExtrudedSolid[]): Float64Array {
|
||||
const w = new FlatWriter().num(solids.length);
|
||||
for (const s of solids) {
|
||||
w.num(s.operation === "subtract" ? 1 : 0, s.circle ? s.circle.r : Number.NaN, s.height, s.taper ?? 0).ring(s.circle ? [] : s.points);
|
||||
}
|
||||
return w.done();
|
||||
}
|
||||
|
||||
/**
|
||||
* Flächen je Geschoss (SIA 416), Gebäudevolumen, Ausnützungs- und Überbauungsziffer. Rechnet der
|
||||
* Kern auf dem Projekt-Dokument (`kennzahlen.rs`, [K4] S2).
|
||||
*/
|
||||
export function computeKennzahlen(project: Project): Kennzahlen {
|
||||
const floors = project.drawingLevels
|
||||
.filter((l) => l.kind === "floor")
|
||||
.slice()
|
||||
.sort((a, b) => (a.baseElevation ?? 0) - (b.baseElevation ?? 0));
|
||||
const levelIndex = new Map<string, number>();
|
||||
floors.forEach((l, i) => levelIndex.has(l.id) || levelIndex.set(l.id, i));
|
||||
const rooms = (project.rooms ?? []).filter((r) => levelIndex.has(r.floorId));
|
||||
const rw = new FlatWriter().num(rooms.length);
|
||||
for (const r of rooms) {
|
||||
const k = SIA_CATEGORIES.indexOf(r.siaCategory);
|
||||
// Unbekannte Kategorie → Index ausserhalb, zählt im Kern nicht.
|
||||
rw.num(levelIndex.get(r.floorId)!, k < 0 ? SIA_CATEGORIES.length : k).ring(r.boundary);
|
||||
}
|
||||
const parcelRing = project.siteRules?.parcel ?? [];
|
||||
const sums = core().kz_area_sums(
|
||||
floors.length,
|
||||
rw.done(),
|
||||
encodeSolids(project.extrudedSolids ?? []),
|
||||
project.parcelArea ?? Number.NaN,
|
||||
new FlatWriter().pts(Array.isArray(parcelRing) ? parcelRing : []).done(),
|
||||
);
|
||||
const gv = sums[0];
|
||||
const parcel = Number.isNaN(sums[1]) ? null : sums[1];
|
||||
const levels: LevelKennzahlen[] = floors.map((l, i) => {
|
||||
// Kategorie-Summen als Einträge der SIA-416-Bilanz → GF und NGF.
|
||||
const b = balance(SIA_CATEGORIES.map((category, k) => ({ category, area: sums[2 + i * SIA_CATEGORIES.length + k] })));
|
||||
return { levelId: l.id, name: l.name, gf: b.byKey.GF, agf: b.byKey.NGF, rooms: rooms.filter((r) => r.floorId === l.id).length };
|
||||
});
|
||||
const gf = levels.reduce((s, l) => s + l.gf, 0);
|
||||
const agf = levels.reduce((s, l) => s + l.agf, 0);
|
||||
const footprint = levels.find((l) => l.gf > 0)?.gf ?? 0;
|
||||
return {
|
||||
levels,
|
||||
gf,
|
||||
agf,
|
||||
gv,
|
||||
footprint,
|
||||
az: parcel ? agf / parcel : null,
|
||||
uez: parcel ? footprint / parcel : null,
|
||||
};
|
||||
return documentFor(project).kennzahlen();
|
||||
}
|
||||
|
||||
export type ProgramStatus = "ok" | "zu klein" | "zu gross" | "fehlt" | "zu wenige" | "zu viele";
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import type { Project } from "../model/types";
|
||||
import { core } from "../engine/coreWasm";
|
||||
import { diffToOps } from "./ops";
|
||||
import type { Kennzahlen } from "../analysis/kennzahlen";
|
||||
|
||||
export class ProjectDocument {
|
||||
private handle = 0;
|
||||
@@ -45,6 +46,13 @@ export class ProjectDocument {
|
||||
}
|
||||
}
|
||||
|
||||
/** Kennzahlen aus dem Kern (`kennzahlen.rs`). */
|
||||
kennzahlen(): Kennzahlen {
|
||||
const text = this.handle ? core().doc_kennzahlen(this.handle) : "";
|
||||
if (!text) throw new Error("Kennzahlen: Projekt passt nicht zum Kern-Modell");
|
||||
return JSON.parse(text) as Kennzahlen;
|
||||
}
|
||||
|
||||
/** Das Dokument als JSON-Text (Test, Export). */
|
||||
json(): string {
|
||||
return this.handle ? core().doc_json(this.handle) : "";
|
||||
@@ -55,3 +63,16 @@ export class ProjectDocument {
|
||||
this.handle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
let shared: ProjectDocument | null = null;
|
||||
|
||||
/**
|
||||
* Das gemeinsame Kern-Dokument, auf den Stand von `project` gebracht. Der Abgleich läuft über die
|
||||
* Differenz zum zuletzt gesehenen Projekt (Referenzvergleich, unveränderte Teile kosten nichts);
|
||||
* wechselt ein Aufrufer zwischen sehr verschiedenen Projekten, ist es nur langsamer, nie falsch.
|
||||
*/
|
||||
export function documentFor(project: Project): ProjectDocument {
|
||||
if (!shared) shared = new ProjectDocument(project);
|
||||
else shared.sync(project);
|
||||
return shared;
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import { createStore } from "./store";
|
||||
import { ProjectDocument } from "../core/document";
|
||||
import type { StoreApi } from "./store";
|
||||
import { createProjectSlice } from "./projectSlice";
|
||||
import type { ProjectSlice } from "./projectSlice";
|
||||
@@ -65,24 +64,3 @@ export const useStore = store.useStore;
|
||||
export const getState = store.getState;
|
||||
export const setState = store.setState;
|
||||
|
||||
// Kern-Dokument ([K4] S1): spiegelt jede Änderung von `project` (Setzen, Laden, Undo/Redo) als Ops
|
||||
// in den Rust-Kern. Ohne geladenen Kern (Start, manche Tests) bleibt es aus und holt sich beim
|
||||
// nächsten Zugriff den vollen Stand.
|
||||
let coreDoc: ProjectDocument | null = null;
|
||||
|
||||
/** Das Rust-Dokument zum aktuellen Projekt (synchron nachgezogen); `null`, solange der Kern fehlt. */
|
||||
export function projectDocument(): ProjectDocument | null {
|
||||
try {
|
||||
const p = store.getState().project;
|
||||
if (!coreDoc) coreDoc = new ProjectDocument(p);
|
||||
else coreDoc.sync(p);
|
||||
return coreDoc;
|
||||
} catch {
|
||||
coreDoc = null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
store.subscribe(() => {
|
||||
void projectDocument();
|
||||
});
|
||||
Reference in new issue
Block a user