Merge branch 'worktree-agent-a6b600eecf6bd85ef' into claude/practical-noether-1hb2s1

# Conflicts:
#	src-tauri/core/src/plan/context.rs
#	src/plan/__golden__/komplex-ansicht-ansicht-sued.txt
This commit is contained in:
Claude committed 2026-11-11 05:37:26 +00:00
commit 2213a674d4
53 files changed
+680 -81

No files matched your search

+6 -1
View File
@@ -1219,10 +1219,15 @@ fn autodim_scale(v: &Value) -> f64 {
}
fn autodim_ops(root: &Map<String, Value>, p: &Project, v: &Value, ctx: &Ctx) -> Vec<Op> {
let dims = auto_dims(root, p, ctx, "autodim", autodim_scale(v));
let mut dims = auto_dims(root, p, ctx, "autodim", autodim_scale(v));
if dims.is_empty() {
return Vec::new();
}
// [180] Eigene Klasse „Auto-Bemassung" (ohne sie im Projekt: die aktive Klasse); je Kette änderbar.
let cat = crate::cmd_create::category_or(p, crate::standards::AUTO_DIM_CATEGORY, ctx);
for d in &mut dims {
d["categoryCode"] = cat.clone();
}
let own = format!("autodim-{}-", ctx.level);
let old: Vec<&str> = arr(root.get("drawings2d")).iter().filter_map(id_of).filter(|id| id.starts_with(&own)).collect();
let mut ops = crate::cmd_create::remove_op(root, "drawings2d", &old);
+4
View File
@@ -253,6 +253,7 @@ fn brep_solid_ops(root: &Map<String, Value>, ctx: &Ctx, ids: &mut IdGen, sources
("id", s(&ids.next("body"))),
("type", s("extrudedSolid")),
("levelId", s(ctx.level)),
("categoryCode", s(ctx.cat)),
("points", pvs(&pts)),
("height", js_num(height)),
("brep", obj(vec![("spec", spec), ("origin", pv(pts[0])), ("label", s(&label))])),
@@ -284,6 +285,7 @@ fn solid_ops(v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
("id", s(&ids.next("body"))),
("type", s("extrudedSolid")),
("levelId", s(ctx.level)),
("categoryCode", s(ctx.cat)),
("points", pvs(&pts)),
("height", js_num(height)),
("brep", obj(vec![("spec", spec), ("origin", pv(pts[0])), ("label", s(&label))])),
@@ -400,6 +402,7 @@ pub fn combine_solids(a: &Value, b: &Value, op: &str, id: String) -> Option<Valu
("id", s(&id)),
("type", s("extrudedSolid")),
("levelId", field(a, "levelId").cloned().unwrap_or(Value::Null)),
("categoryCode", field(a, "categoryCode").cloned().unwrap_or(Value::Null)),
("points", Value::Array(points)),
("height", js_num(height)),
(
@@ -435,6 +438,7 @@ fn voidbox_ops(v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
("id", s(&ids.next("void"))),
("type", s("extrudedSolid")),
("levelId", s(ctx.level)),
("categoryCode", s(ctx.cat)),
("points", pvs(&rect_corners(a, b))),
("height", js_num(height)),
("operation", s("subtract")),
+3 -1
View File
@@ -25,6 +25,8 @@ const COLUMN_CATEGORY: &str = "50";
const ROOM_CATEGORY: &str = "60";
const ROOF_CATEGORY: &str = "35";
const STAIR_CATEGORY: &str = "40";
/// [180] Träger (Extrusionskörper) wie „35 Träger" der Musterprojekte.
const BEAM_CATEGORY: &str = "35";
const ROOM_COLOR: &str = "#6b7280";
const SIA: [&str; 6] = ["HNF", "NNF", "VF", "FF", "KGF", "AGF"];
const LEVEL_TOL: f64 = 0.005;
@@ -957,7 +959,7 @@ fn elements_ops(root: &Map<String, Value>, meta: &Value, products: &[IfcProduct]
for b in &el.beams {
let (fid, base, _) = floor_of(&mut ctx, b.info.storey, b.z0);
let mut v = json!({
"id": ctx.new_id("solid"), "type": "extrudedSolid", "levelId": fid,
"id": ctx.new_id("solid"), "type": "extrudedSolid", "levelId": fid, "categoryCode": BEAM_CATEGORY,
"points": b.outline.iter().map(|&p| mv(p)).collect::<Vec<_>>(), "height": js_num(round(b.z1 - b.z0, 1e-6)),
});
let off = anchor_offset(b.z0, base);
+3
View File
@@ -4491,6 +4491,9 @@ pub struct ExtrudedSolid {
/// Geschoss, dessen `baseElevation` die UK des Körpers bestimmt.
#[serde(rename = "levelId")]
pub level_id: String,
/// [180] Klasse (Ebene/Kategorie) wie bei jedem Bauteil: Sichtbarkeit in Grundriss, Schnitt und Ansicht.
#[serde(rename = "categoryCode")]
pub category_code: String,
/// Geschlossenes Profil in der XY-Ebene (Grundriss), ≥3 Punkte. Bei einem
/// Kreis-Profil (`circle` gesetzt) eine Tessellierung des Kreises (48-Eck) —
/// für 2D-Footprint/Auswahl/bbox/Verschieben; die 3D-Extrusion nutzt in dem
+3 -2
View File
@@ -12,7 +12,8 @@ use crate::model::*;
const CONTEXT_LINE_COLOR: &str = "#9aa3ad";
const CONTEXT_LINE_MM: f64 = 0.1;
/// Kategorie der Schnittführungs-Symbole (Referenzen).
const SECTION_LINE_CATEGORY: &str = "90";
/// [180] Schnitt-/Ansichtsmarken liegen auf der Standard-Klasse „Schnittmarken" (früher „90 Referenzen").
const SECTION_LINE_CATEGORY: &str = crate::standards::SECTION_MARK_CATEGORY;
const SECTION_LINE_INK: &str = "#1f242c";
const SECTION_LINE_MM: f64 = 0.18;
/// [176] Kräftige Endstücke und Blickrichtungs-Schenkel.
@@ -878,7 +879,7 @@ fn view_marker(c: &Ctx, level: &DrawingLevel, p0: Vec2, p1: Vec2, sign: f64, k:
/// Schnittführungs-Symbole aller Schnitt-/Ansichtsebenen mit Linie (`addSectionLines`).
pub fn plan_section_lines(c: &Ctx, out: &mut Vec<Primitive>) {
if !c.shown(SECTION_LINE_CATEGORY) {
if !c.derived_shown(SECTION_LINE_CATEGORY) {
return;
}
// Auf freien Zeichnungsebenen (Blätter wie „Raumprogramm", Detail) gehören die Symbole nicht hin:
@@ -0,0 +1,203 @@
//! [180] Alles Sichtbare liegt auf einer Klasse: Grundriss, Schnitt und Ansicht des Musterprojekts (Fixture) mit
//! Schattenstudie, Körpern, Raster und Schnittführungen. Sind alle Klassen aus, bleibt nichts; jede Klasse der
//! abgeleiteten Darstellung (`standards::DERIVED_CATEGORIES`) entfernt genau ihre Primitive.
//! Die beiden Musterhäuser (TS-Bauer) prüft `src/plan/derivedCategories.test.ts` über den WASM-Kern.
use super::domains::{plan_domains_buf, PlanArgs};
use super::prim::Primitive;
use crate::model::*;
use crate::standards::{derived_categories, AUTO_DIM_CATEGORY, SECTION_MARK_CATEGORY, SHADOW_CATEGORY};
use serde_json::{json, Value};
/// 2026-06-21T08:00:00Z (Morgensonne: lange Schatten).
const WHEN: f64 = 1_782_028_800_000.0;
fn project() -> Project {
let mut v: Value = serde_json::from_str(include_str!("../../tests/fixtures/sample_project.json")).unwrap();
let layers = v["layers"].as_array_mut().unwrap();
layers.extend(derived_categories());
v["sunStudy"] = json!({"when": "2026-06-21T08:00:00Z", "show": true});
// Körper (Klasse „35") und Abzugskörper (Klasse „20") im EG, Achsraster (Klasse „00").
v["extrudedSolids"] = json!([
{"id": "k1", "type": "extrudedSolid", "levelId": "eg", "categoryCode": "35", "points": [{"x": 7, "y": 1}, {"x": 8, "y": 1}, {"x": 8, "y": 2}, {"x": 7, "y": 2}], "height": 1.5},
{"id": "v1", "type": "extrudedSolid", "levelId": "eg", "categoryCode": "20", "operation": "subtract", "points": [{"x": 1, "y": -0.2}, {"x": 1.5, "y": -0.2}, {"x": 1.5, "y": 0.2}, {"x": 1, "y": 0.2}], "height": 0.5, "baseOffset": 1.0}
]);
v["drawings2d"].as_array_mut().unwrap().push(json!({"id": "raster", "type": "drawing2d", "levelId": "eg", "categoryCode": "00",
"geom": {"shape": "grid", "origin": {"x": 0, "y": 0}, "angle": 0,
"a": [{"label": "1", "pos": 0}, {"label": "2", "pos": 5}], "b": [{"label": "A", "pos": 0}, {"label": "B", "pos": 4}]}}));
serde_json::from_value(v).unwrap()
}
fn all_codes(p: &Project) -> Vec<String> {
p.flat_categories().iter().map(|c| c.code.clone()).collect()
}
fn plan(p: &Project, floor: &str, show: &[String]) -> Vec<Primitive> {
let a = PlanArgs::parse(1.0, &json!({"floor": floor, "show": show, "global": true, "scale": 100, "sunWhen": WHEN}).to_string()).unwrap();
let buf = plan_domains_buf(p, &a).unwrap();
super::buf::View::parse(&buf).unwrap().prims().unwrap()
}
/// Sichtbarkeit wie `visibilityArgs` in TS: unsichtbar sind alle Codes (Baum und Bauteile) ausser `show`.
fn vis_json(p: &Project, show: &[String]) -> Value {
let mut codes: Vec<String> = all_codes(p);
codes.extend(p.walls.iter().map(|w| w.category_code.clone()));
codes.extend(p.openings.iter().flatten().map(|o| o.category_code.clone()));
codes.extend(p.stairs.iter().flatten().map(|o| o.category_code.clone()));
let invisible: Vec<String> = codes.into_iter().filter(|c| !show.contains(c)).collect();
json!({"hasVis": true, "invisible": invisible, "hasDisplay": false})
}
fn level_of<'a>(p: &'a Project, kind: DrawingLevelKind) -> &'a DrawingLevel {
p.drawing_levels.iter().find(|l| l.kind == kind).unwrap()
}
fn section(p: &Project, show: &[String]) -> Vec<Primitive> {
let mut t = vis_json(p, show);
t["level"] = serde_json::to_value(level_of(p, DrawingLevelKind::Section)).unwrap();
let buf = super::section::section_plan_buf(p, &[0.0, 1.0, 0.0], &t.to_string()).unwrap();
super::buf::View::parse(&buf).unwrap().prims().unwrap()
}
fn elevation(p: &Project, show: &[String]) -> Vec<Primitive> {
let mut t = vis_json(p, show);
t["level"] = serde_json::to_value(level_of(p, DrawingLevelKind::Elevation)).unwrap();
let buf = super::elevation::elevation_plan_buf(p, &[0.0, 1.0, 100.0], &t.to_string()).unwrap();
super::buf::View::parse(&buf).unwrap().prims().unwrap()
}
fn without(codes: &[String], code: &str) -> Vec<String> {
codes.iter().filter(|c| *c != code).cloned().collect()
}
fn ctx_id(q: &Primitive) -> Option<&str> {
match q {
Primitive::Polygon { context_object_id, .. } => context_object_id.as_deref(),
_ => None,
}
}
fn section_mark(q: &Primitive) -> bool {
match q {
Primitive::Polygon { section_line_id, .. } => section_line_id.is_some(),
Primitive::Line { cls, .. } => cls.starts_with("section-line") || cls.starts_with("section-mark"),
_ => false,
}
}
/// Alle Klassen aus ⇒ Grundriss, Schnitt und Ansicht leer. Mit allen Klassen ist von allem etwas da.
#[test]
fn alle_klassen_aus_leert_plan_schnitt_ansicht() {
let p = project();
let all = all_codes(&p);
let full = plan(&p, "eg", &all);
assert!(full.iter().any(|q| ctx_id(q) == Some(super::extras::SITE_PICK_SUN)), "Schatten");
assert!(full.iter().any(|q| matches!(q, Primitive::Polygon { extruded_solid_id: Some(_), .. })), "Körper");
assert!(full.iter().any(|q| matches!(q, Primitive::Polygon { section_line_id: Some(_), .. })), "Schnittmarken");
for floor in ["eg", "og"] {
let rest = plan(&p, floor, &[]);
assert!(rest.is_empty(), "Grundriss {floor}: {rest:?}");
}
assert!(!section(&p, &all).is_empty());
let rest = section(&p, &[]);
assert!(rest.is_empty(), "Schnitt: {rest:?}");
let full = elevation(&p, &all);
assert!(full.iter().any(|q| ctx_id(q) == Some(super::extras::SITE_PICK_VIEW_SHADOWS)), "Schlagschatten der Ansicht");
let rest = elevation(&p, &[]);
assert!(rest.is_empty(), "Ansicht: {rest:?}");
}
/// Klasse „Schatten" aus: Grundriss ohne Sonnenschatten, Ansicht ohne Schlagschatten, sonst gleich.
#[test]
fn klasse_schatten() {
let p = project();
let all = all_codes(&p);
let off = without(&all, SHADOW_CATEGORY);
let (a, b) = (plan(&p, "eg", &all), plan(&p, "eg", &off));
let sun = |v: &[Primitive]| v.iter().filter(|q| ctx_id(q) == Some(super::extras::SITE_PICK_SUN)).count();
assert!(sun(&a) > 0 && sun(&b) == 0);
assert_eq!(a.len() - sun(&a), b.len());
let shade = |v: &[Primitive]| v.iter().filter(|q| ctx_id(q) == Some(super::extras::SITE_PICK_VIEW_SHADOWS)).count();
let (a, b) = (elevation(&p, &all), elevation(&p, &off));
assert!(shade(&a) > 0 && shade(&b) == 0);
// Ohne die Klasse im Projekt (vor „Standards laden") bleibt der Schatten sichtbar.
let mut q = p.clone();
q.layers.retain(|l| l.code != SHADOW_CATEGORY);
assert_eq!(sun(&plan(&q, "eg", &off)), sun(&plan(&p, "eg", &all)));
}
/// Klasse „Schnittmarken" aus: Grundriss ohne Schnitt-/Ansichtsmarken, sonst gleich.
#[test]
fn klasse_schnittmarken() {
let p = project();
let all = all_codes(&p);
let (a, b) = (plan(&p, "eg", &all), plan(&p, "eg", &without(&all, SECTION_MARK_CATEGORY)));
let marks = |v: &[Primitive]| v.iter().filter(|q| matches!(q, Primitive::Polygon { section_line_id: Some(_), .. })).count();
assert!(marks(&a) > 0 && marks(&b) == 0);
assert!(b.len() < a.len());
assert!(!b.iter().any(section_mark));
}
/// Körper (auch Abzugskörper) liegen auf ihrer Klasse: im Grundriss und im Schnitt (Projektion) weg mit ihr.
#[test]
fn koerper_auf_ihrer_klasse() {
let p = project();
let all = all_codes(&p);
let solid = |v: &[Primitive], id: &str| v.iter().any(|q| matches!(q, Primitive::Polygon { extruded_solid_id: Some(s), .. } if s == id));
let a = plan(&p, "eg", &all);
assert!(solid(&a, "k1") && solid(&a, "v1"));
let b = plan(&p, "eg", &without(&all, "35"));
assert!(!solid(&b, "k1") && solid(&b, "v1"));
}
/// Ansicht: Öffnungen und Treppen folgen ihrer Klasse (früher nur zusammen mit dem Darstellungsmodus); Raster
/// in Schnitt und Ansicht seiner.
#[test]
fn ansicht_oeffnungen_treppen_raster() {
let p = project();
let all = all_codes(&p);
let opening = |v: &[Primitive]| v.iter().any(|q| matches!(q, Primitive::Polygon { opening_id: Some(_), .. }));
let stair = |v: &[Primitive]| v.iter().any(|q| matches!(q, Primitive::Polygon { ceiling_id: Some(id), .. } if id == "ST1"));
let grid = |v: &[Primitive]| v.iter().any(|q| matches!(q, Primitive::DrawingCircle { drawing_id: Some(id), .. } if id == "raster"));
let a = elevation(&p, &all);
assert!(opening(&a) && stair(&a) && grid(&a));
let codes: Vec<String> = all.iter().filter(|c| *c != "21").cloned().collect();
let b = elevation(&p, &codes);
assert!(!opening(&b), "Öffnungen aus");
assert!(!stair(&elevation(&p, &without(&all, "40"))), "Treppe aus");
assert!(!grid(&elevation(&p, &without(&all, "00"))), "Raster aus (Ansicht)");
assert!(grid(&section(&p, &all)) && !grid(&section(&p, &without(&all, "00"))), "Raster (Schnitt)");
// Wand aus: ihre Öffnungen gehen mit.
let c = elevation(&p, &without(&all, "20"));
assert!(!opening(&c), "Öffnungen einer ausgeblendeten Wand");
}
/// Schnitt: Projektionskanten folgen der Klasse ihres Bauteils.
#[test]
fn schnitt_projektion_nach_klasse() {
let p = project();
let all = all_codes(&p);
let visible = |v: &[Primitive]| v.iter().filter(|q| matches!(q, Primitive::Line { cls, .. } if cls == "section-visible")).count();
let a = section(&p, &all);
let b = section(&p, &without(&all, "20"));
assert!(visible(&a) > visible(&b), "{} {}", visible(&a), visible(&b));
}
/// Aussenbemassung landet auf „Auto-Bemassung" (ohne die Klasse im Projekt: auf der aktiven).
#[test]
fn aussenbemassung_auf_eigener_klasse() {
let p = project();
let mut r: serde_json::Map<String, Value> = serde_json::from_value(serde_json::to_value(&p).unwrap()).unwrap();
let run = |r: &serde_json::Map<String, Value>| -> Vec<String> {
let ops = crate::commands::ops(r, &crate::model::lenient::typed_for_test(r), &json!({"cmd": "autodim", "ctx": {"level": "eg", "cat": "50"}, "stamp": "s"}).to_string()).unwrap();
ops.iter()
.filter_map(|o| if let crate::ops::Op::Add { items, .. } = o { Some(items) } else { None })
.flatten()
.map(|d| d["categoryCode"].as_str().unwrap_or_default().to_string())
.collect()
};
let cats = run(&r);
assert!(!cats.is_empty() && cats.iter().all(|c| c == AUTO_DIM_CATEGORY), "{cats:?}");
r.insert("layers".into(), json!([{"code": "50", "name": "Text", "color": "#000", "lw": 0.13, "visible": true, "locked": false}]));
assert!(run(&r).iter().all(|c| c == "50"));
}
+19 -7
View File
@@ -203,6 +203,12 @@ impl<'a> Ctx<'a> {
self.a.show.contains(code)
}
/// [180] Abgeleitete Darstellung auf einer Standard-Klasse (`standards::DERIVED_CATEGORIES`): eingeblendet, oder
/// die Klasse fehlt im Projekt.
pub fn derived_shown(&self, code: &str) -> bool {
self.shown(code) || !self.cats.contains_key(code)
}
/// [33] Element sichtbar: Kategorie eingeblendet und keine Regel „Ausblenden“ trifft es.
pub fn vis(&self, code: &str, id: &str) -> bool {
self.shown(code) && !self.hidden.contains(id)
@@ -1544,7 +1550,9 @@ pub(super) fn columns(c: &Ctx, out: &mut Vec<Primitive>) {
fn solids(c: &Ctx, out: &mut Vec<Primitive>) {
let range = super::view_range::ViewRange::of(c.p, &c.a.floor);
let base = c.p.floor(&c.a.floor).and_then(|f| f.base_elevation).unwrap_or(0.0);
for s in c.p.extruded_solids.as_deref().unwrap_or(&[]).iter().filter(|s| s.level_id == c.a.floor) {
// [180] Körper und Abzugskörper liegen wie jedes Bauteil auf ihrer Klasse (die Aussparung wirkt unabhängig davon).
for s in c.p.extruded_solids.as_deref().unwrap_or(&[]).iter().filter(|s| s.level_id == c.a.floor && c.vis(&s.category_code, &s.id)) {
let greyed = c.greyed(&s.category_code).then_some(true);
let subtract = s.operation.as_deref() == Some("subtract");
let zb = base + s.base_offset.unwrap_or(0.0);
let zone = if subtract { super::view_range::Zone::Cut } else { range.classify(zb, zb + s.height) };
@@ -1553,9 +1561,9 @@ fn solids(c: &Ctx, out: &mut Vec<Primitive>) {
}
let out_start = out.len();
if s.operation.as_deref() == Some("subtract") {
out.push(polygon(s.points.clone(), "none", "none", 0.0, no_hatch(), None, None, Pick::Solid(&s.id)));
out.push(polygon(s.points.clone(), "none", "none", 0.0, no_hatch(), greyed, None, Pick::Solid(&s.id)));
let n = s.points.len();
let seg = |a: Vec2, b: Vec2, dash: Option<Vec<f64>>| line(a, b, "void", SYMBOL_HAIRLINE_MM, Some(dash), EXTRUSION_STROKE, None);
let seg = |a: Vec2, b: Vec2, dash: Option<Vec<f64>>| line(a, b, "void", SYMBOL_HAIRLINE_MM, Some(dash), EXTRUSION_STROKE, greyed);
for i in 0..n {
out.push(seg(s.points[i], s.points[(i + 1) % n], Some(vec![2.0, 1.0])));
}
@@ -1564,12 +1572,12 @@ fn solids(c: &Ctx, out: &mut Vec<Primitive>) {
out.push(seg(s.points[1], s.points[3], None));
}
} else {
out.push(polygon(s.points.clone(), "none", EXTRUSION_STROKE, SYMBOL_HAIRLINE_MM, no_hatch(), None, None, Pick::Solid(&s.id)));
out.push(polygon(s.points.clone(), "none", EXTRUSION_STROKE, SYMBOL_HAIRLINE_MM, no_hatch(), greyed, None, Pick::Solid(&s.id)));
// [G1] Schnittfläche auf Schnitthöhe (Poché); der Umriss darunter bleibt als Projektion.
if zone == super::view_range::Zone::Cut {
if let Some(ring) = body_cut_ring(s, zb, range.cut) {
let (fill, hatch) = if c.solid_cut() { (HATCH_INK, no_hatch()) } else { (super::section::BODY_FILL, super::section::section_hatch()) };
out.push(polygon(ring, fill, POCHE_STROKE, WALL_FALLBACK_MM, hatch, None, None, Pick::Solid(&s.id)));
out.push(polygon(ring, fill, POCHE_STROKE, WALL_FALLBACK_MM, hatch, greyed, None, Pick::Solid(&s.id)));
}
}
}
@@ -1748,8 +1756,10 @@ pub fn plan_domains_buf(p: &Project, a: &PlanArgs) -> Result<Vec<u8>, String> {
fn extras_of(p: &Project, a: &PlanArgs) -> (Vec<(Primitive, u32)>, Vec<Primitive>) {
if a.global {
// [66] Baurecht (Parzelle, Baubereich, Verstösse) gehört zur Vermessung: ausgeblendete Kategorie „01" ⇒ ohne.
let site = !(p.flat_categories().iter().any(|c| c.code == super::extras::SITE_CATEGORY) && !a.show.contains(super::extras::SITE_CATEGORY));
super::extras::site_and_shadow(p, &a.floor, a.sun_when, a.scale, site)
let site = crate::standards::derived_visible(p, super::extras::SITE_CATEGORY, |k| a.show.contains(k));
// [180] Sonnenschatten auf der Klasse „Schatten".
let sun_when = a.sun_when.filter(|_| crate::standards::derived_visible(p, crate::standards::SHADOW_CATEGORY, |k| a.show.contains(k)));
super::extras::site_and_shadow(p, &a.floor, sun_when, a.scale, site)
} else {
(Vec::new(), Vec::new())
}
@@ -2600,6 +2610,7 @@ mod tests {
let mk = |id: &str, off: f64, h: f64| ExtrudedSolid {
id: id.into(),
level_id: "eg".into(),
category_code: "20".into(),
points: vec![Vec2 { x: 0.0, y: 0.0 }, Vec2 { x: 1.0, y: 0.0 }, Vec2 { x: 1.0, y: 1.0 }, Vec2 { x: 0.0, y: 1.0 }],
height: h,
base_offset: Some(off),
@@ -3351,6 +3362,7 @@ mod tests {
let mk = |id: &str, off: f64, h: f64, taper: Option<f64>, op: Option<&str>| ExtrudedSolid {
id: id.into(),
level_id: "eg".into(),
category_code: "20".into(),
points: vec![Vec2 { x: 20.0, y: 0.0 }, Vec2 { x: 22.0, y: 0.0 }, Vec2 { x: 22.0, y: 2.0 }, Vec2 { x: 20.0, y: 2.0 }],
height: h,
base_offset: Some(off),
+21 -4
View File
@@ -213,6 +213,10 @@ pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool,
for c in p.ceilings.as_deref().unwrap_or(&[]) {
ceil_cat.entry(c.id.as_str()).or_insert(c.category_code.as_str());
}
// [180] Treppen kommen als Platten (Tritte, Läufe) mit der Treppen-Id.
for st in p.stairs.as_deref().unwrap_or(&[]) {
ceil_cat.entry(st.id.as_str()).or_insert(st.category_code.as_str());
}
let mut roof_cat: HashMap<&str, &str> = HashMap::new();
for r in p.roofs.as_deref().unwrap_or(&[]) {
roof_cat.entry(r.id.as_str()).or_insert(r.category_code.as_str());
@@ -239,9 +243,9 @@ pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool,
Role::Mesh => mesh_cat.get(f.id.as_str()).copied(),
}
};
if vis.has_vis && vis.has_display {
faces.retain(|f| category(f).is_none_or(|c| vis.visible(c) && vis.render(c)));
}
// [180] Klassen-Sichtbarkeit und Darstellungsmodus wirken je für sich (früher nur beide zusammen: ein Blatt-
// Ausschnitt mit ausgeblendeter Klasse zeigte sie in der Ansicht trotzdem).
faces.retain(|f| category(f).is_none_or(|c| vis.visible(c) && vis.render(c)));
let greyed = |f: &Face| vis.has_display && category(f).is_some_and(|c| vis.greyed(c));
// [33] Override-Regeln: ausgeblendete Bauteile entfallen wie ausgeblendete Kategorien (verdecken nichts),
// Wände samt ihren Öffnungen.
@@ -256,6 +260,17 @@ pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool,
let mvo = crate::plan::model_view::for_view(p, level.model_view.as_deref(), crate::plan::style::Detail::Mittel, scale);
let win = &mvo.window;
let mut openings = collect_openings(p, &frame, win);
// [180] Öffnungen nach ihrer Klasse und der ihres Wirts (Wand, Dach): ausgeblendet ⇒ ohne Öffnung.
{
let shown = |c: &str| vis.visible(c) && vis.render(c);
let host_shown = |o: &Opening| {
let wall = (!o.host_wall_id.is_empty()).then(|| wall_cat.get(o.host_wall_id.as_str()).copied()).flatten();
let roof = o.host_roof_id.as_deref().and_then(|r| roof_cat.get(r).copied());
wall.is_none_or(shown) && roof.is_none_or(shown)
};
let all = p.openings.as_deref().unwrap_or(&[]);
openings.retain(|op| all.iter().find(|o| o.id == op.id).is_none_or(|o| shown(&o.category_code) && host_shown(o)));
}
// [173] Fensterteilung (Flügel, Sprossen, Kämpfer) nach der Modelldarstellung.
if !win.elevation_division {
for op in openings.iter_mut().filter(|op| p.openings.as_deref().unwrap_or(&[]).iter().any(|o| o.id == op.id && o.kind != ElementKind::Door)) {
@@ -439,6 +454,8 @@ pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool,
}
// [33] Schlagschatten über Regeln (Bauteilart „Schatten“): Ausblenden, Füllung, Linie (Umriss).
// [180] Schlagschatten liegen auf der Klasse „Schatten" (fehlt sie im Projekt, gilt sie als sichtbar).
let shadows = shadows && vis.visible(crate::standards::SHADOW_CATEGORY) && vis.render(crate::standards::SHADOW_CATEGORY);
let sov = if shadows { super::overrides::shadow_override(p, rv) } else { None };
let shadows = shadows && !sov.as_ref().is_some_and(|(a, _)| a.hidden());
let shadow_style = |mut q: Primitive| -> Primitive {
@@ -721,7 +738,7 @@ pub fn elevation_plan_buf(p: &Project, args: &[f64], text: &str) -> Result<Vec<u
super::extras::scale_line_weights(p, scale, &mut prims);
w.group(&prims);
// Achsraster ([112]): Achsen quer zur Blickebene.
let grid = super::grid_view::grid_prims(p, &level, bounds, scale);
let grid = super::grid_view::grid_prims_in(p, &level, bounds, scale, &vis);
if !grid.is_empty() {
w.group(&grid);
}
@@ -79,6 +79,10 @@ pub(super) fn surface_patterns(p: &Project, faces: &mut [Face], frame: &[f64; 9]
}
// Dachflächen: äusserste Schicht (Eindeckung).
for roof in p.roofs.as_deref().unwrap_or(&[]) {
// [180] Nur Dächer mit sichtbaren Flächen (ausgeblendete Klasse, Regel oder Ansichtsbereich ⇒ ohne Muster).
if !faces.iter().any(|f| f.role == Role::Roof && f.id == roof.id) {
continue;
}
let Some(comp) = p.roof_layers(roof).first().filter(|l| !l.component_id.is_empty()).and_then(|l| p.component(&l.component_id)) else { continue };
if !mono && roof.color.as_deref().is_none_or(|c| c.is_empty()) {
if let Some(c) = comp.elevation_color.as_deref().filter(|c| !c.trim().is_empty()) {
+13 -1
View File
@@ -3,7 +3,7 @@
//! oben (bzw. unten bei „nur Anfang"). Hängt als eigene Gruppe hinter dem Schnitt/der Ansicht.
use super::prim::Primitive;
use super::section::{LevelSpec, Plane};
use super::section::{LevelSpec, Plane, Visibility};
use crate::grid::{bubble_diameter, section_axes, Spec};
use crate::model::{Drawing2DGeom, GridBubbles, Project, Vec2};
@@ -21,10 +21,19 @@ fn v2(x: f64, y: f64) -> Vec2 {
/// Achslinien und Blasen für eine Ebene; `bounds` = Ausmass des Schnitts/der Ansicht (x0, y0, x1, y1),
/// `scale` = Massstabsnenner. Leer ohne Raster oder ohne Ebene.
pub fn grid_prims(p: &Project, level: &LevelSpec, bounds: [f64; 4], scale: f64) -> Vec<Primitive> {
grid_prims_in(p, level, bounds, scale, &Visibility::default())
}
/// [180] Wie [`grid_prims`], nur Raster, deren Klasse sichtbar ist (`vis`); gedimmte Klasse ⇒ gedimmt.
pub fn grid_prims_in(p: &Project, level: &LevelSpec, bounds: [f64; 4], scale: f64, vis: &Visibility) -> Vec<Primitive> {
let Some(plane) = level.plane() else { return Vec::new() };
let mut out = Vec::new();
for d in &p.drawings2d {
let Drawing2DGeom::Grid { bubble_mm, bubbles, .. } = &d.geom else { continue };
if !(vis.visible(&d.category_code) && vis.render(&d.category_code)) {
continue;
}
let greyed = vis.has_display && vis.greyed(&d.category_code);
let Some(spec) = Spec::of(&d.geom) else { continue };
// [137] Achsen, Blasen und Beschriftung tragen die Raster-Id: im Schnitt/in der Ansicht anwählbar.
let id = Some(d.id.clone());
@@ -33,6 +42,9 @@ pub fn grid_prims(p: &Project, level: &LevelSpec, bounds: [f64; 4], scale: f64)
Primitive::Line { drawing_id, .. } | Primitive::DrawingCircle { drawing_id, .. } | Primitive::DrawingText { drawing_id, .. } => *drawing_id = id.clone(),
_ => {}
}
if greyed {
q = q.with_greyed(true);
}
q
}));
}
+2
View File
@@ -47,3 +47,5 @@ pub(crate) mod wall_join_tests;
mod hatch_dir_tests;
#[cfg(test)]
mod arc_output_tests;
#[cfg(test)]
mod derived_class_tests;
@@ -68,6 +68,8 @@ pub(super) fn append_body_sections(cuts: &mut Vec<Cut>, p: &Project, bodies: &[&
c.fill = Some(BODY_FILL.into());
c.nse = nse;
c.source_id = solids.get(b.index).map(|s| s.id.clone());
// [180] Klasse des Körpers (Sichtbarkeit, Darstellungsmodus).
c.category = solids.get(b.index).map(|s| s.category_code.clone());
cuts.push(c);
}
}
+31 -1
View File
@@ -491,6 +491,35 @@ pub struct Output {
pub meshes: Vec<MeshMeta>,
/// [152] Offene Schnittlinien importierter Netze (offene/nicht-mannigfaltige Netze): Netz-Index, Linienzug.
pub mesh_lines: Vec<(usize, Vec<[f64; 2]>)>,
/// [180] Klasse der Bauteile hinter den Projektionskanten (`Edge::kind`, `Edge::index`; Netze über `meshes`).
pub edge_cats: HashMap<(Kind, usize), String>,
}
/// [180] Klassen der Projektions-Besitzer: Wände (Index in `walls_r`), Platten (Decken, Treppen, Stützen; Index in
/// `slabs_r`), Dächer, Körper (Index in `extrudedSolids`).
fn edge_categories(p: &Project, walls: &[Option<&Wall>], slabs: &[bands::SlabOwner]) -> HashMap<(Kind, usize), String> {
let mut m = HashMap::new();
for (i, w) in walls.iter().enumerate() {
if let Some(w) = w {
m.insert((Kind::Wall, i), w.category_code.clone());
}
}
for (i, s) in slabs.iter().enumerate() {
let code = match s {
bands::SlabOwner::Ceiling(c, _) => &c.category_code,
bands::SlabOwner::Stair(st) => &st.category_code,
bands::SlabOwner::Column(c) => &c.category_code,
bands::SlabOwner::None => continue,
};
m.insert((Kind::Slab, i), code.clone());
}
for (i, r) in p.roofs.as_deref().unwrap_or(&[]).iter().enumerate() {
m.insert((Kind::Roof, i), r.category_code.clone());
}
for (i, b) in p.extruded_solids.as_deref().unwrap_or(&[]).iter().enumerate() {
m.insert((Kind::Body, i), b.category_code.clone());
}
m
}
/// [152] Ein importiertes Netz im Schnitt.
@@ -577,6 +606,7 @@ fn compute_plane(p: &Project, level: &LevelSpec, bodies: &[BodyMesh], strip: Opt
.collect();
let walls: Vec<Option<&Wall>> = owners.iter().zip(&virt).map(|(o, v)| v.as_ref().or(*o)).collect();
let slabs = slab_owners(p, &slabs_r);
let edge_cats = edge_categories(p, &walls, &slabs);
let cuts = attach_cut_styles(cuts, p, &plane, &walls, &slabs)?;
let cuts = merge_monolith_cuts(cuts, &slabs_r, &stair_flight_sections(p, plane.base(), plane.u_model()));
let base = plane.base();
@@ -603,7 +633,7 @@ fn compute_plane(p: &Project, level: &LevelSpec, bodies: &[BodyMesh], strip: Opt
let (mut visible, hidden) = projection_edges(p, &plane, &walls_r, &wi, &slabs_r, &bodies, &meshes, &cuts, level.hidden_lines, level.depth, strip.map_or(&[][..], |s| &s.half[..]));
shaped_projection(&mut visible, p, &walls_r, &plane);
let meshes = meshes.iter().map(|m| MeshMeta { id: m.mesh.id.clone(), name: m.mesh.name.clone(), category: Some(m.mesh.category_code.clone()) }).collect();
let mut out = Output { cuts, visible, hidden, profiles: Vec::new(), earth: Vec::new(), terrain_id: None, meshes, mesh_lines };
let mut out = Output { cuts, visible, hidden, profiles: Vec::new(), earth: Vec::new(), terrain_id: None, meshes, mesh_lines, edge_cats };
append_terrain_profiles(&mut out, p, base, u);
if let Some(s) = strip {
unfold::clip_output(&mut out, s);
@@ -586,7 +586,14 @@ pub fn section_primitives_mv(out: &Output, mono: bool, hidden_lines: bool, vis:
(StairPart::Rail, Some(m)) => m.o.stair.section_beyond && m.o.stair.handrail.is_some(),
};
// [152] Importierte Netze: Kanten nur, wenn die Kategorie gezeigt wird; Linien nach den Regeln des Netzes.
let mesh_shown = |e: &Edge| stair_shown(e) && (e.kind != Kind::Mesh || out.meshes.get(e.index).and_then(|m| m.category.as_deref()).is_none_or(shown));
// [180] Projektionskanten der übrigen Bauteile nach deren Klasse.
let mesh_shown = |e: &Edge| {
stair_shown(e)
&& match e.kind {
Kind::Mesh => out.meshes.get(e.index).and_then(|m| m.category.as_deref()).is_none_or(shown),
_ => out.edge_cats.get(&(e.kind, e.index)).is_none_or(|c| shown(c)),
}
};
let mesh_style = |e: &Edge, l: &mut Primitive| {
if e.kind == Kind::Mesh {
if let Some(s) = rules.mesh.get(&e.index) {
+1 -1
View File
@@ -118,7 +118,7 @@ pub fn section_plan_buf(p: &Project, args: &[f64], text: &str) -> Result<Vec<u8>
.flat_map(|(l, s)| {
let off = s.as_ref().map_or(0.0, |s| s.offset);
let b = if off == 0.0 { bounds } else { [bounds[0] - off, bounds[1], bounds[2] - off, bounds[3]] };
unfold::clip_prims(crate::plan::grid_view::grid_prims(p, l, b, scale), s.as_ref())
unfold::clip_prims(crate::plan::grid_view::grid_prims_in(p, l, b, scale, &vis), s.as_ref())
})
.collect();
if !grid.is_empty() {
@@ -231,6 +231,7 @@ pub(super) fn merge_output(acc: &mut Option<Output>, o: Output) {
a.profiles.extend(o.profiles);
a.earth.extend(o.earth);
a.mesh_lines.extend(o.mesh_lines);
a.edge_cats.extend(o.edge_cats);
if a.terrain_id.is_none() {
a.terrain_id = o.terrain_id;
}
+2 -1
View File
@@ -1031,7 +1031,8 @@ fn solid_selection(root: &Map<String, Value>, s: &Value) -> J {
O::default()
.s("kind", "extrudedSolid")
.raw("id", s, "id")
.s("categoryCode", "")
// [180] Klasse wie jedes Bauteil (im Kopf der Objekt-Info änderbar).
.s("categoryCode", str_of(field(s, "categoryCode")).unwrap_or(""))
.raw("floorId", s, "levelId")
.s("color", EXTRUSION_COLOR)
.n("weightMm", WALL_FALLBACK_MM)
+3 -1
View File
@@ -252,7 +252,9 @@ fn section_view_buf(p: &Project, level: &DrawingLevel, snap: &ViewSnapshot, scal
let mut b = rv.bounds().unwrap_or([0.0, 0.0, 1.0, 1.0]);
// Automatische Koten: Ebene > [173] Modelldarstellung (Ausschnitt, sonst Ebene) > an.
let mv_id = crate::plan::model_view::selected_id(p, &level.id, args.model_view.as_deref());
let marks_on = crate::plan::model_view::for_view(p, mv_id, crate::plan::style::Detail::Mittel, scale).level_marks(level.level_marks);
// [180] … und nur mit sichtbarer Klasse „Höhenkoten".
let marks_on = crate::plan::model_view::for_view(p, mv_id, crate::plan::style::Detail::Mittel, scale).level_marks(level.level_marks)
&& crate::standards::derived_visible(p, crate::standards::LEVEL_MARK_CATEGORY, |k| args.show.contains(k));
let own_buf = plan_domains_buf(p, &PlanArgs { global: false, ..args }).ok()?;
let ov = crate::plan::buf::View::parse(&own_buf)?;
let own = ov.prims().unwrap_or_default();
+74 -9
View File
@@ -276,7 +276,7 @@ pub fn roof_types() -> Vec<Value> {
pub fn view_templates() -> Vec<Value> {
vec![
json!({"id": "std-vt-praesentation", "name": "Präsentation", "detail": "mittel", "mono": true, "shadows": true, "hiddenLines": false,
"layerVisibility": {"90": false, "99": false}}),
"layerVisibility": {"90": false, "91": false, "99": false}}),
json!({"id": "std-vt-eingabe-100", "name": "Eingabeplan 1:100", "detail": "mittel", "scaleDenominator": 100, "mono": true, "shadows": false,
"layerVisibility": {"99": false}}),
json!({"id": "std-vt-ausfuehrung-50", "name": "Ausführungsplan 1:50", "detail": "fein", "scaleDenominator": 50, "mono": true, "shadows": false,
@@ -347,13 +347,49 @@ pub fn light_category() -> Value {
json!({"code": LIGHT_CATEGORY_CODE, "name": "Leuchten", "color": "#1a1a1a", "lw": 0.18, "visible": true, "locked": false})
}
// ── [180] Klassen der abgeleiteten Darstellung ────────────────────────────────
//
// Alles Sichtbare liegt auf einer Klasse (Vorgabe Maintainer): was nicht zu einem Element gehört (Schatten,
// Schnittmarken, automatische Koten) oder als Element von einem Befehl erzeugt wird (Aussenbemassung), bekommt
// eine Standard-Klasse. Sichtbarkeit über den gewöhnlichen Mechanismus (Klassen-Sichtbarkeit, Darstellungsmodus,
// Ebenen-Kombination). Fehlt die Klasse im Projekt (vor „Standards laden"), bleibt die Darstellung sichtbar
// (wie [66] Baurecht unter „01"), sonst gäbe es keinen Schalter dafür.
/// Schlagschatten: Sonnenschatten im Grundriss (Schattenstudie), Schlagschatten in der Ansicht.
pub const SHADOW_CATEGORY: &str = "08";
/// Automatische Aussenbemassung (Befehl `autodim`, Elemente `autodim-…`; je Element änderbar).
pub const AUTO_DIM_CATEGORY: &str = "81";
/// Automatische Höhenkoten in Schnitt und Ansicht (`levelMarkers`).
pub const LEVEL_MARK_CATEGORY: &str = "82";
/// Schnitt- und Ansichtsmarken im Grundriss (Schnittführung mit Pfeilen und Beschriftung).
pub const SECTION_MARK_CATEGORY: &str = "91";
/// Die Klassen der abgeleiteten Darstellung (Code, Name, Farbe, Strichstärke).
pub const DERIVED_CATEGORIES: [(&str, &str, &str, f64); 4] = [
(SHADOW_CATEGORY, "Schatten", "#707078", 0.13),
(AUTO_DIM_CATEGORY, "Auto-Bemassung", "#303038", 0.13),
(LEVEL_MARK_CATEGORY, "Höhenkoten", "#1a1a1a", 0.13),
(SECTION_MARK_CATEGORY, "Schnittmarken", "#1a1a1a", 0.18),
];
pub fn derived_categories() -> Vec<Value> {
DERIVED_CATEGORIES.iter().map(|(code, name, color, lw)| json!({"code": code, "name": name, "color": color, "lw": lw, "visible": true, "locked": false})).collect()
}
/// [180] Abgeleitete Darstellung der Klasse `code` sichtbar? `shown(code)` (Klasse eingeblendet), oder die Klasse
/// fehlt im Projekt.
pub fn derived_visible(p: &crate::model::Project, code: &str, shown: impl Fn(&str) -> bool) -> bool {
shown(code) || p.layer_category(code).is_none()
}
/// Gibt es im Kategorie-Baum schon den Code oder den Namen `name` (klein)?
fn has_category(layers: &[Value], code: &str, name: &str) -> bool {
layers.iter().any(|l| l["code"].as_str() == Some(code) || name_key(l).as_deref() == Some(name) || l["children"].as_array().is_some_and(|c| has_category(c, code, name)))
}
/// Gibt es im Kategorie-Baum schon den Code oder den Namen der Leuchten-Kategorie?
fn has_light_category(layers: &[Value]) -> bool {
layers.iter().any(|l| {
l["code"].as_str() == Some(LIGHT_CATEGORY_CODE)
|| name_key(l).as_deref() == Some("leuchten")
|| l["children"].as_array().is_some_and(|c| has_light_category(c))
})
has_category(layers, LIGHT_CATEGORY_CODE, "leuchten")
}
pub fn library() -> Vec<(&'static str, Vec<Value>)> {
@@ -427,10 +463,18 @@ fn merge_plan(root: &Map<String, Value>) -> (Vec<Value>, HashMap<String, String>
}
}
// Kategorie „Leuchten“ (Kategorien haben keine id: ganze Liste setzen, ein Undo-Schritt).
// [180] Dazu die Klassen der abgeleiteten Darstellung.
let layers = root.get("layers").and_then(Value::as_array).cloned().unwrap_or_default();
let mut all = layers.clone();
if !has_light_category(&layers) {
let mut all = layers;
all.push(light_category());
}
for (c, d) in DERIVED_CATEGORIES.iter().zip(derived_categories()) {
if !has_category(&layers, c.0, &c.1.to_lowercase()) {
all.push(d);
}
}
if all.len() != layers.len() {
ops.push(json!({"kind": "setField", "key": "layers", "value": all}));
}
(ops, ids)
@@ -792,11 +836,32 @@ mod tests {
let mut own = empty_root();
own.insert("layers".into(), json!([{"code": "20", "name": "Wände", "color": "#000", "lw": 0.35, "visible": true, "locked": false,
"children": [{"code": "28", "name": "Leuchten", "color": "#000", "lw": 0.13, "visible": true, "locked": false}]}]));
assert!(!merge_ops(&own).iter().any(|o| o["key"] == "layers"));
let op = merge_ops(&own).into_iter().find(|o| o["key"] == "layers").unwrap();
assert!(!op["value"].as_array().unwrap().iter().any(|l| l["code"] == "65"), "keine zweite Leuchten-Kategorie");
// Andere Kategorien bleiben, die neue kommt ans Ende.
own.insert("layers".into(), json!([{"code": "20", "name": "Wände", "color": "#000", "lw": 0.35, "visible": true, "locked": false}]));
let op = merge_ops(&own).into_iter().find(|o| o["key"] == "layers").unwrap();
assert_eq!(op["value"].as_array().unwrap().iter().map(|l| l["code"].as_str().unwrap()).collect::<Vec<_>>(), ["20", "65"]);
assert_eq!(op["value"].as_array().unwrap().iter().map(|l| l["code"].as_str().unwrap()).collect::<Vec<_>>(), ["20", "65", "08", "81", "82", "91"]);
}
/// [180] Klassen der abgeleiteten Darstellung: „Standards laden" legt sie an, einmal; vorhandene (Code oder Name) bleiben.
#[test]
fn klassen_der_abgeleiteten_darstellung() {
let r = apply(&empty_root(), &merge_ops(&empty_root()));
let p: Project = serde_json::from_value(Value::Object(r.clone())).unwrap();
for (code, name, ..) in DERIVED_CATEGORIES {
assert!(p.layers.iter().any(|l| l.code == code && l.name == name), "{name}");
}
assert!(merge_ops(&r).is_empty(), "zweites Laden ergänzt nichts");
let mut own = empty_root();
own.insert("layers".into(), json!([{"code": "77", "name": "schatten", "color": "#000", "lw": 0.13, "visible": true, "locked": false}]));
let op = merge_ops(&own).into_iter().find(|o| o["key"] == "layers").unwrap();
let codes: Vec<&str> = op["value"].as_array().unwrap().iter().map(|l| l["code"].as_str().unwrap()).collect();
assert_eq!(codes, ["77", "65", "81", "82", "91"]);
// Sichtbar, solange die Klasse fehlt; sonst nach der Klassen-Sichtbarkeit.
assert!(derived_visible(&p, SHADOW_CATEGORY, |c| c == SHADOW_CATEGORY));
assert!(!derived_visible(&p, SHADOW_CATEGORY, |_| false));
assert!(derived_visible(&Project::default(), SHADOW_CATEGORY, |_| false));
}
#[test]