[180] Klassen: alles Sichtbare auf einer Klasse (Schatten, Auto-Bemassung, Höhenkoten, Schnittmarken, Körper)
- Standard-Klassen der abgeleiteten Darstellung in standards.rs (08 Schatten, 81 Auto-Bemassung, 82 Höhenkoten, 91 Schnittmarken statt 90): Standards laden, neue Projekte, Musterprojekte; fehlt die Klasse, bleibt die Darstellung sichtbar - ExtrudedSolid.categoryCode (Pflicht), Grundriss/Schnitt nach Klasse, Objekt-Info änderbar - Schnitt: Projektionskanten und Raster nach Klasse; Ansicht: Klassen wirken ohne Darstellungsmodus, Öffnungen (mit Wirt), Treppen, Raster, Dachmuster nach Klasse - autodim legt Ketten auf 81, automatische Koten folgen 82 (App, Blatt, CLI), CLI --hide - Tests: plan/derived_class_tests.rs, src/plan/derivedCategories.test.ts; Audit in ARCHITEKTUR 3.6 - Goldens: Ansicht Süd ohne doppeltes Ziegelraster, Schnitt A ohne Stützen der Kind-Klasse 25
This commit is contained in:
53 files changed
+681
-82
No files matched your search
@@ -60,7 +60,17 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `*
|
||||
`doc/ARCHITEKTUR.md` Abschnitt 8. Geprüft: Rust/vitest/e2e, Musterhaus komplex mit Nachbarnetzen Grundriss 1:200/Schnitt/
|
||||
Ansicht per CLI vor/nach byte-gleich. Offen: Linien des Standort-Imports (OSM/swisstopo-Umrisse) bleiben je Klasse ein
|
||||
`contourSet` statt einzelner 2D-Zeichnungen; Tag-Namen `importedMesh`/`terrainMesh` historisch; Mac-Gegenprobe. · L
|
||||
- ○ **[180]** Alles Sichtbare auf Ebene/Klasse (11.11., Vorgabe Maintainer): jedes Primitive in Plan/Schnitt/Ansicht (auch abgeleitete: Schatten, Auto-Masse, Koten, Schnitt-/Ansichtsmarken, Raster, Nordpfeil, Stempel, Gelände) hat eine Klasse/Ebene und verschwindet mit ihr; Audit + Test, der Primitives ohne Zuordnung meldet. Regel in CLAUDE.md. · M
|
||||
- ◐ **[180]** Alles Sichtbare auf Ebene/Klasse (11.11., Vorgabe Maintainer). Umgesetzt (11.11.): Audit-Tabelle in
|
||||
`doc/ARCHITEKTUR.md` 3.6; Standard-Klassen der abgeleiteten Darstellung `08 Schatten` (Sonnenschatten Grundriss,
|
||||
Schlagschatten Ansicht), `81 Auto-Bemassung` (Befehl `autodim`, je Kette änderbar), `82 Höhenkoten` (automatische
|
||||
Koten Schnitt/Ansicht), `91 Schnittmarken` (statt `90`) in `standards.rs` („Standards laden", neue Projekte,
|
||||
Musterprojekte; fehlt die Klasse ⇒ sichtbar); Körper/Abzugskörper mit Pflicht-Klasse (`ExtrudedSolid.categoryCode`,
|
||||
Objekt-Info änderbar); Schnitt: Projektionskanten und Raster nach Klasse; Ansicht: Klassen wirken auch ohne
|
||||
Darstellungsmodus (Blatt-Ausschnitte zeigten ausgeblendete Klassen), Öffnungen (samt Wirt), Treppen, Raster, Dachmuster
|
||||
nach Klasse (Nebenwirkung: kein doppeltes Ziegelraster mehr auf dem Hauptdach, Golden Ansicht Süd); CLI `--hide`;
|
||||
Tooltip im Ebenen-Panel (de/en). Tests `plan/derived_class_tests.rs`, `src/plan/derivedCategories.test.ts`. Offen:
|
||||
ausgeblendete Bauteile verdecken im Schnitt weiter die Projektion dahinter (Lücken); 3D nicht nach Klassen geprüft;
|
||||
nicht in der Tauri-App/auf dem Mac geprüft. · M
|
||||
- ◐ **[133]** Musterhaus komplex: Rest. Skalieren-Kopie lässt `position`/Breite unverändert; Vollflächen-/Bildschraffur
|
||||
und Schraffur-Löcher beim Ausbreiten fehlen (`src/export/planToSvgString.ts`, Kern `plan/svg.rs`; wegen paralleler
|
||||
Arbeit an `svg.rs` (Bögen) am 10.11. nicht angefasst). (10.11.: Skalieren skaliert `position`/`width` der Wandöffnungen
|
||||
|
||||
@@ -361,6 +361,44 @@ Etappe 3:
|
||||
„+" übernimmt, TS `standardModelViews`/`adoptModelViewOps`). Stufen zwischen Projekten austauschen geht nur über
|
||||
Projektvorlagen (ganzes Projekt) — ein Import einzelner Ressourcen fehlt.
|
||||
|
||||
### 3.6 Alles Sichtbare auf einer Klasse ([180])
|
||||
|
||||
Regel (CLAUDE.md, „Konventionen"): jedes Primitive in Grundriss, Schnitt und Ansicht gehört zu einer Klasse
|
||||
(`categoryCode`) und verschwindet mit ihr — über den einen Mechanismus Klassen-Sichtbarkeit/Darstellungsmodus
|
||||
(Grundriss `show`/`grey`, Schnitt/Ansicht `invisible`/`norender`/`grey`, Ebenen-Kombinationen und Vorlagen setzen
|
||||
dieselben Codes). Was kein eigenes Element hat, liegt auf einer **Standard-Klasse der abgeleiteten Darstellung**
|
||||
(`standards.rs::DERIVED_CATEGORIES`, TS `src/model/derivedCategories.ts`; „Standards laden" und neue Projekte legen
|
||||
sie an): `08 Schatten`, `81 Auto-Bemassung`, `82 Höhenkoten`, `91 Schnittmarken`. Fehlt eine davon im Projekt,
|
||||
bleibt die Darstellung sichtbar (`standards::derived_visible`, `Ctx::derived_shown`; wie Baurecht unter `01`).
|
||||
Prüfung: `plan/derived_class_tests.rs` (Fixture) und `src/plan/derivedCategories.test.ts` (beide Musterhäuser:
|
||||
alle Klassen aus ⇒ Grundriss jedes Geschosses, Schnitte, Ansichten leer; jede abgeleitete Klasse einzeln).
|
||||
|
||||
| Darstellung | Klasse | Wo |
|
||||
|---|---|---|
|
||||
| Sonnenschatten Grundriss | `08 Schatten` | `domains.rs::extras_of` |
|
||||
| Schlagschatten Ansicht (auch Fenster-Laibungen) | `08 Schatten` (+ Regel „Schatten" [33]) | `elevation/mod.rs` |
|
||||
| Baurecht (Parzelle, Baubereich, Verstösse) | `01 Vermessung` | `extras_of` ([66]) |
|
||||
| Automatische Aussenbemassung | Element, Standard `81 Auto-Bemassung` (je Kette änderbar) | `cmd_draw.rs::autodim_ops` |
|
||||
| Höhenkoten 2D (Element `kote`) | Element | `drawings.rs` |
|
||||
| Automatische Höhenkoten Schnitt/Ansicht | `82 Höhenkoten` (+ Ebene/Modelldarstellung) | `levelMarksEnabled` (TS), `sheet_viewports.rs` |
|
||||
| Schnitt-/Ansichtsmarken im Grundriss | `91 Schnittmarken` (früher `90`) | `context.rs::plan_section_lines` |
|
||||
| Achsraster, Achsblasen (Grundriss, Schnitt, Ansicht) | Element (Raster) | `drawings.rs`, `grid_view.rs::grid_prims_in` |
|
||||
| Nordpfeil, Massstabsbalken, Revisionswolke, Texte | Element | `drawings.rs` |
|
||||
| Plankopf | Blatt-Element (Layout), nicht im Plan | `LayoutSheet` |
|
||||
| Raumstempel, Bodenbelag | Raum | `domains.rs::rooms`, `floor_finishes` |
|
||||
| Treppe: Lauflinie, Stufennummern, Absturzsicherung; Ansicht | Treppe | `stairs.rs`; Ansicht über `ceil_cat` |
|
||||
| Deckenkanten, Untersichten | Decke | `domains.rs::ceilings` |
|
||||
| Storenkasten, Fenster/Türen (auch Ansicht, mit Wirt) | Öffnung (+ Wand/Dach) | `walls.rs`; `elevation/mod.rs` |
|
||||
| Körper, Abzugskörper (Grundriss, Schnitt) | Element (`ExtrudedSolid.categoryCode`, neu) | `domains.rs::solids`, Schnitt `edge_cats` |
|
||||
| Projektionskanten im Schnitt | Bauteil hinter der Ebene | `section/mod.rs::edge_categories` |
|
||||
| Dach-Ansichtsmuster | Dach (nur mit sichtbaren Flächen) | `elevation/patterns.rs` |
|
||||
| Höhenlinien + Beschriftung, Gelände, Baugrube, Netze, Luftbild, Bäume | Element ([181]) | `context.rs`, `trees.rs` |
|
||||
| Kontext-Unterlagen (DXF/PDF) | Element (2D-Zeichnung) | `drawings.rs` |
|
||||
| Grundlinie Schnitt/Ansicht | keine eigene: entfällt, wenn nichts gezeichnet ist | `section/primitives.rs`, `elevation/mod.rs` |
|
||||
|
||||
Offen: Bauzonen sind kein eigener Planinhalt (nur Baurecht-Einstellungen); 3D (render3d-Teile) nicht geprüft; ausgeblendete
|
||||
Bauteile verdecken im Schnitt weiter die Projektion dahinter.
|
||||
|
||||
---
|
||||
|
||||
## 4. Schnitt
|
||||
|
||||
@@ -39,6 +39,8 @@ test("Musterhaus komplex: Geschosse, Ansichten und Blätter ohne Konsolenfehler"
|
||||
const dl = await pending;
|
||||
const bytes = await readFile((await dl.path())!);
|
||||
expect(bytes.subarray(0, 5).toString()).toBe("%PDF-");
|
||||
expect(bytes.length).toBeGreaterThan(100_000);
|
||||
// [180] Seit Schatten, Schnittmarken usw. auf ihrer Klasse liegen, stehen sie nur noch in deren PDF-Ebene statt in
|
||||
// jeder (≈ 86 kB statt > 100 kB).
|
||||
expect(bytes.length).toBeGreaterThan(60_000);
|
||||
if (shots) await writeFile(`${shots}/baueingabe.pdf`, bytes);
|
||||
});
|
||||
@@ -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);
|
||||
|
||||
@@ -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")),
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -4478,6 +4478,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
|
||||
|
||||
@@ -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:
|
||||
@@ -1643,9 +1644,9 @@ mod tests {
|
||||
/// rücken entlang der Linie auf freie Stellen, statt zu fehlen; keine liegt auf dem Hindernis.
|
||||
#[test]
|
||||
fn hoehenlinien_beschriftung_rueckt_vom_hindernis_weg() {
|
||||
let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 10.0, 40.0, 0.0, 10.0, 40.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() };
|
||||
let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 10.0, 40.0, 0.0, 10.0, 40.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), category_code: "02".into(), ..Default::default() };
|
||||
let p = Project { context: Some(vec![ContextObject::TerrainMesh(t)]), ..Default::default() };
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "scale": 100}"#).unwrap();
|
||||
let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "show": ["02"], "scale": 100}"#).unwrap();
|
||||
let c = Ctx::new(&p, &a);
|
||||
let run = |o: &super::super::stamp_place::Obstacles| {
|
||||
let mut out = Vec::new();
|
||||
|
||||
@@ -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(§ion(&p, &all)) && !grid(§ion(&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"));
|
||||
}
|
||||
@@ -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)
|
||||
@@ -1537,7 +1543,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) };
|
||||
@@ -1546,9 +1554,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])));
|
||||
}
|
||||
@@ -1557,12 +1565,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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1741,8 +1749,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())
|
||||
}
|
||||
@@ -2593,6 +2603,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),
|
||||
@@ -3344,6 +3355,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),
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1028,7 +1028,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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -9,7 +9,7 @@ const sq = (x: number, y: number, s: number) => [
|
||||
|
||||
describe("solidVolume", () => {
|
||||
it("Prisma, Kegelstumpf (taper) und Kreis", () => {
|
||||
const base = { id: "s", type: "extrudedSolid" as const, levelId: "eg", points: sq(0, 0, 2), height: 3 };
|
||||
const base = { id: "s", type: "extrudedSolid" as const, categoryCode: "20", levelId: "eg", points: sq(0, 0, 2), height: 3 };
|
||||
expect(solidVolume(base)).toBeCloseTo(12, 9);
|
||||
expect(solidVolume({ ...base, taper: 1 })).toBeCloseTo(4, 9); // Pyramide = A·h/3
|
||||
const r = { ...base, circle: { center: { x: 0, y: 0 }, r: 1 } };
|
||||
@@ -34,8 +34,8 @@ describe("computeKennzahlen", () => {
|
||||
const p: Project = {
|
||||
...sampleProject,
|
||||
extrudedSolids: [
|
||||
{ id: "a", type: "extrudedSolid", levelId: sampleProject.drawingLevels[0].id, points: sq(0, 0, 10), height: 3 } as never,
|
||||
{ id: "b", type: "extrudedSolid", levelId: sampleProject.drawingLevels[0].id, points: sq(0, 0, 1), height: 3, operation: "subtract" } as never,
|
||||
{ id: "a", type: "extrudedSolid", categoryCode: "20", levelId: sampleProject.drawingLevels[0].id, points: sq(0, 0, 10), height: 3 } as never,
|
||||
{ id: "b", type: "extrudedSolid", categoryCode: "20", levelId: sampleProject.drawingLevels[0].id, points: sq(0, 0, 1), height: 3, operation: "subtract" } as never,
|
||||
],
|
||||
};
|
||||
const k = computeKennzahlen(p);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
// Override-Regel ein (auch Standard-Baustein, z. B. --rule "Deckenaufbau weiss") [33];
|
||||
// das Massstab-Kriterium einer Regel (ab/bis 1:n) gilt nach --scale;
|
||||
// --model-view <Name> wählt eine Modelldarstellung (eigene Stufe oder grob/mittel/fein) [173]
|
||||
// --hide <Code|Name,…> blendet Klassen aus (z. B. --hide "Schatten,Auto-Bemassung") [180]
|
||||
// dossier-cli <projekt.obp> ifc [--ebkph] [--ebenen] (IFC mit eBKP-H-Hauptgruppen bzw. Modell-Ebenen als Klassifikation)
|
||||
// --schema 4|2x3: IFC4 (Standard) oder IFC2x3 (Coordination View 2.0)
|
||||
// dossier-cli <projekt.obp> dxf [--binary] [--scale 100] [--dim-unit cm] [--layout]|dwg|ifc|step|obj|stl|glb|gltf|schedule [--openings|--elements|--rooms] [--format json|csv|svg|pdf]|kennzahlen [--sia416] [--ivhb] [--format json|csv|svg|pdf] [--agsf m2] [--gruenflaeche m2] [--agf-basis gf|ngf|nf] [--untergeschosse]|raumprogramm [--import tabelle] [--sheet name|nr] [--mode replace|append] [--tolerance %] [--generate] [--format json|csv|svg|pdf] [--save projekt.obp]|sun [--level EG] [--out datei]
|
||||
@@ -235,6 +236,20 @@ function templateView(project: Project, levelId: string, args: Args, allCodes: S
|
||||
const tpl = templateFor(project, levelId, args);
|
||||
const d = templateDisplay(tpl);
|
||||
const hidden = new Set(d.hiddenCodes);
|
||||
// [180] --hide <Code|Name,…>: Klassen ausblenden (z. B. --hide "Schatten,Auto-Bemassung").
|
||||
for (const w of (args.flags.get("hide") ?? "").split(",").map((x) => x.trim().toLowerCase()).filter(Boolean)) {
|
||||
const find = (ls: Project["layers"]): string | undefined => {
|
||||
for (const l of ls) {
|
||||
if (l.code.toLowerCase() === w || l.name.toLowerCase() === w) return l.code;
|
||||
const c = l.children ? find(l.children) : undefined;
|
||||
if (c) return c;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
const code = find(project.layers);
|
||||
if (!code) fail(`Klasse nicht gefunden: ${w}`);
|
||||
hidden.add(code);
|
||||
}
|
||||
return {
|
||||
tpl,
|
||||
detail: d.detail,
|
||||
|
||||
@@ -13,7 +13,7 @@ function combineSolids(project: typeof sampleProject, a: ExtrudedSolid, b: Extru
|
||||
|
||||
const box = (id: string, x0: number, y0: number, x1: number, y1: number, h: number): ExtrudedSolid => ({
|
||||
id,
|
||||
type: "extrudedSolid",
|
||||
type: "extrudedSolid", categoryCode: "20",
|
||||
levelId: "eg",
|
||||
points: [{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x1, y: y1 }, { x: x0, y: y1 }],
|
||||
height: h,
|
||||
|
||||
@@ -46,7 +46,7 @@ const volume = (m: { positions: number[]; indices: number[] }): number => {
|
||||
const build = (spec: unknown, tol = 0.01) => JSON.parse(mod.build_solid_mesh(JSON.stringify({ spec, tol })));
|
||||
|
||||
const box = (id: string, x0: number, y0: number, x1: number, y1: number, h: number): ExtrudedSolid => ({
|
||||
id, type: "extrudedSolid", levelId: "eg", height: h,
|
||||
id, type: "extrudedSolid", categoryCode: "20", levelId: "eg", height: h,
|
||||
points: [{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x1, y: y1 }, { x: x0, y: y1 }],
|
||||
});
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ function fixtureProject(): Project {
|
||||
const extrudedSolids: ExtrudedSolid[] = [
|
||||
{
|
||||
id: "E1",
|
||||
type: "extrudedSolid",
|
||||
type: "extrudedSolid", categoryCode: "20",
|
||||
levelId: "eg",
|
||||
points: [
|
||||
{ x: 0, y: 0 },
|
||||
|
||||
@@ -81,7 +81,7 @@ function projectWithPolygonExtrusion(pts: { x: number; y: number }[], height = 2
|
||||
const p = baseProject();
|
||||
const solid: ExtrudedSolid = {
|
||||
id: "E1",
|
||||
type: "extrudedSolid",
|
||||
type: "extrudedSolid", categoryCode: "20",
|
||||
levelId: "eg",
|
||||
points: pts,
|
||||
height,
|
||||
@@ -134,7 +134,7 @@ function fixtureProject(): Project {
|
||||
const extrudedSolids: ExtrudedSolid[] = [
|
||||
{
|
||||
id: "E1",
|
||||
type: "extrudedSolid",
|
||||
type: "extrudedSolid", categoryCode: "20",
|
||||
levelId: "eg",
|
||||
points: [
|
||||
{ x: 0, y: 0 },
|
||||
|
||||
@@ -96,7 +96,7 @@ function fixtureProject(): Project {
|
||||
const extrudedSolids: ExtrudedSolid[] = [
|
||||
{
|
||||
id: "E1",
|
||||
type: "extrudedSolid",
|
||||
type: "extrudedSolid", categoryCode: "20",
|
||||
levelId: "eg",
|
||||
points: [
|
||||
{ x: 0, y: 0 },
|
||||
|
||||
@@ -74,7 +74,7 @@ describe("STEP-Export Ende-zu-Ende (truck-WASM)", () => {
|
||||
const p = {
|
||||
...sampleProject,
|
||||
extrudedSolids: [{
|
||||
id: "v", type: "extrudedSolid" as const, levelId: w.floorId, operation: "subtract" as const, height: 0.8, baseOffset: 0.5,
|
||||
id: "v", type: "extrudedSolid" as const, categoryCode: "20", levelId: w.floorId, operation: "subtract" as const, height: 0.8, baseOffset: 0.5,
|
||||
points: [{ x: mx - 0.3, y: my - 1 }, { x: mx + 0.3, y: my - 1 }, { x: mx + 0.3, y: my + 1 }, { x: mx - 0.3, y: my + 1 }],
|
||||
}],
|
||||
};
|
||||
|
||||
@@ -986,6 +986,10 @@ export const de = {
|
||||
"nav.show": "Einblenden",
|
||||
"nav.categoryVisible": "{name} sichtbar",
|
||||
"nav.categorySelect": "{name} als aktive Ebene wählen (Zeichen-Ziel)",
|
||||
"nav.categoryDerived.08": "Abgeleitete Darstellung: Sonnenschatten im Grundriss, Schlagschatten in der Ansicht",
|
||||
"nav.categoryDerived.81": "Abgeleitete Darstellung: automatische Aussenbemassung (je Kette änderbar)",
|
||||
"nav.categoryDerived.82": "Abgeleitete Darstellung: automatische Höhenkoten in Schnitt und Ansicht",
|
||||
"nav.categoryDerived.91": "Abgeleitete Darstellung: Schnitt- und Ansichtsmarken im Grundriss",
|
||||
"nav.categorySettings": "Ebeneneinstellungen für {name}",
|
||||
"nav.drawingLevelsWindow": "Zeichnungsebenen als eigenes Fenster öffnen",
|
||||
|
||||
|
||||
@@ -981,6 +981,10 @@ export const en: Record<TranslationKey, string> = {
|
||||
"nav.show": "Show",
|
||||
"nav.categoryVisible": "{name} visible",
|
||||
"nav.categorySelect": "Make {name} the active layer (drawing target)",
|
||||
"nav.categoryDerived.08": "Derived display: sun shadows in plans, cast shadows in elevations",
|
||||
"nav.categoryDerived.81": "Derived display: automatic exterior dimensions (each chain can be reassigned)",
|
||||
"nav.categoryDerived.82": "Derived display: automatic level marks in sections and elevations",
|
||||
"nav.categoryDerived.91": "Derived display: section and elevation marks in plans",
|
||||
"nav.categorySettings": "Layer settings for {name}",
|
||||
"nav.drawingLevelsWindow": "Open drawing levels as its own window",
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// [180] Klassen der abgeleiteten Darstellung: alles Sichtbare liegt auf einer Klasse, auch was nicht zu einem
|
||||
// Element gehört (Schatten, Schnittmarken, automatische Koten) oder ein Befehl erzeugt (Aussenbemassung).
|
||||
// Die Codes stehen im Kern (`src-tauri/core/src/standards.rs`, `DERIVED_CATEGORIES`; „Standards laden" legt die
|
||||
// Klassen an); hier nur die Codes für die TS-Seite (Gleichheit prüft `derivedCategories.test.ts`).
|
||||
// Fehlt eine Klasse im Projekt, bleibt die Darstellung sichtbar (wie im Kern `standards::derived_visible`).
|
||||
|
||||
import type { LayerCategory } from "./types";
|
||||
import { findCategory } from "./layers";
|
||||
|
||||
/** Sonnenschatten im Grundriss, Schlagschatten in der Ansicht. */
|
||||
export const SHADOW_CATEGORY = "08";
|
||||
/** Automatische Aussenbemassung (Befehl `autodim`). */
|
||||
export const AUTO_DIM_CATEGORY = "81";
|
||||
/** Automatische Höhenkoten in Schnitt und Ansicht. */
|
||||
export const LEVEL_MARK_CATEGORY = "82";
|
||||
/** Schnitt- und Ansichtsmarken im Grundriss. */
|
||||
export const SECTION_MARK_CATEGORY = "91";
|
||||
|
||||
export const DERIVED_CATEGORY_CODES: readonly string[] = [SHADOW_CATEGORY, AUTO_DIM_CATEGORY, LEVEL_MARK_CATEGORY, SECTION_MARK_CATEGORY];
|
||||
|
||||
/** Abgeleitete Darstellung der Klasse `code` sichtbar: Klasse eingeblendet (`shown`) oder im Projekt nicht vorhanden. */
|
||||
export function derivedVisible(layers: LayerCategory[], code: string, shown: (code: string) => boolean): boolean {
|
||||
return shown(code) || !findCategory(layers, code);
|
||||
}
|
||||
@@ -92,7 +92,7 @@ describe("translateProject", () => {
|
||||
it("Extrusion: points + Kreis-Mitte verschieben sich", () => {
|
||||
const solid: ExtrudedSolid = {
|
||||
id: "EX1",
|
||||
type: "extrudedSolid",
|
||||
type: "extrudedSolid", categoryCode: "20",
|
||||
levelId: "eg",
|
||||
points: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 1, y: 1 }],
|
||||
height: 1,
|
||||
|
||||
@@ -88,8 +88,8 @@ export function richProject(): Project {
|
||||
{ type: "image", categoryCode: "03", id: "c4", name: "Luftbild", src: "data:image/png;base64,AAAA", min: { x: 0, y: 0 }, max: { x: 10, y: 10 }, opacity: 0.7, drape: true, filters: { saturation: 0.5, grayscale: 1 } },
|
||||
],
|
||||
extrudedSolids: [
|
||||
{ id: "x1", type: "extrudedSolid", levelId: lvl, points: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 1, y: 1 }], height: 2, baseOffset: 0.1, operation: "subtract", taper: 0.1, cornerRadius: 0.05, chamfer: 0.02 },
|
||||
{ id: "x2", type: "extrudedSolid", levelId: lvl, points: [], height: 1, circle: { center: { x: 3, y: 3 }, r: 0.4 }, brep: { spec: { kind: "box", w: 1, nested: { a: [1, 2] } }, origin: { x: 0, y: 0 }, label: "Quader" } },
|
||||
{ id: "x1", type: "extrudedSolid", categoryCode: "20", levelId: lvl, points: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 1, y: 1 }], height: 2, baseOffset: 0.1, operation: "subtract", taper: 0.1, cornerRadius: 0.05, chamfer: 0.02 },
|
||||
{ id: "x2", type: "extrudedSolid", categoryCode: "20", levelId: lvl, points: [], height: 1, circle: { center: { x: 3, y: 3 }, r: 0.4 }, brep: { spec: { kind: "box", w: 1, nested: { a: [1, 2] } }, origin: { x: 0, y: 0 }, label: "Quader" } },
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
|
||||
@@ -370,6 +370,9 @@ export const sampleProject: Project = {
|
||||
layers: [
|
||||
{ code: "00", name: "Raster", color: "#1a1a1a", lw: 0.13, visible: true, locked: false },
|
||||
{ code: "01", name: "Vermessung", color: "#4a4a4a", lw: 0.18, visible: true, locked: false },
|
||||
// [180] Klassen der abgeleiteten Darstellung (wie „Standards laden", Kern `standards.rs`): Schatten,
|
||||
// Auto-Bemassung, automatische Höhenkoten in Schnitt/Ansicht, Schnitt-/Ansichtsmarken.
|
||||
{ code: "08", name: "Schatten", color: "#707078", lw: 0.13, visible: true, locked: false },
|
||||
// "05 Kontext" bündelt Bestand/Umgebung (manuell gezeichnet ODER importiert,
|
||||
// s. `contextCategories.ts::CONTEXT_PARENT_CATEGORY`) als Kinder statt als
|
||||
// gleichrangige Top-Level-Einträge (Nutzer-Wunsch 2026-08-31).
|
||||
@@ -409,7 +412,10 @@ export const sampleProject: Project = {
|
||||
{ code: "35", name: "Träger", color: "#0a0a0a", lw: 0.25, visible: true, locked: false },
|
||||
{ code: "50", name: "Text", color: "#1a1a1a", lw: 0.13, visible: true, locked: false },
|
||||
{ code: "60", name: "Räume", color: "#4a4a4a", lw: 0.13, visible: true, locked: false },
|
||||
{ code: "81", name: "Auto-Bemassung", color: "#303038", lw: 0.13, visible: true, locked: false },
|
||||
{ code: "82", name: "Höhenkoten", color: "#1a1a1a", lw: 0.13, visible: true, locked: false },
|
||||
{ code: "90", name: "Referenzen", color: "#1a1a1a", lw: 0.13, visible: true, locked: false },
|
||||
{ code: "91", name: "Schnittmarken", color: "#1a1a1a", lw: 0.18, visible: true, locked: false },
|
||||
{ code: "99", name: "Konstruktion", color: "#404040", lw: 0.13, visible: true, locked: false },
|
||||
],
|
||||
// [140] Strichstärken folgen dem Massstab (neue Projekte; bestehende behalten ihre Einstellung).
|
||||
|
||||
@@ -482,9 +482,9 @@ const columns: NonNullable<Project["columns"]> = [
|
||||
|
||||
const extrudedSolids: NonNullable<Project["extrudedSolids"]> = [
|
||||
// Abzugskörper: Durchreiche Küche ↔ Atelier in der EG-Innenwand x = 6.
|
||||
{ id: "void-durchreiche", type: "extrudedSolid", levelId: "eg", points: rect(5.8, 6.6, 6.2, 7.8), height: 0.6, baseOffset: 1.0, operation: "subtract" },
|
||||
{ id: "void-durchreiche", type: "extrudedSolid", levelId: "eg", categoryCode: "20", points: rect(5.8, 6.6, 6.2, 7.8), height: 0.6, baseOffset: 1.0, operation: "subtract" },
|
||||
// Freier Körper: runder Brunnentrog im Garten (Kreisprofil, Fase).
|
||||
{ id: "koerper-brunnen", type: "extrudedSolid", levelId: "ug", points: [], circle: { center: P(4.5, -6.5), r: 0.7 }, height: 0.6, baseOffset: -0.1, chamfer: 0.03 },
|
||||
{ id: "koerper-brunnen", type: "extrudedSolid", levelId: "ug", categoryCode: "20", points: [], circle: { center: P(4.5, -6.5), r: 0.7 }, height: 0.6, baseOffset: -0.1, chamfer: 0.03 },
|
||||
];
|
||||
|
||||
// ═════════════════════════════════════════════════════════════════════════════
|
||||
@@ -870,6 +870,7 @@ export function buildComplexSampleProject(): Project {
|
||||
p = addRooms(p);
|
||||
|
||||
// Aussenbemassung (Massketten je Fassade) in UG, EG, OG.
|
||||
// [180] Die Ketten landen auf der Klasse „81 Auto-Bemassung" (Befehl `autodim`), nicht auf der aktiven.
|
||||
for (const f of ["ug", "eg", "og"]) p = runCmd(p, f, "autodim", {}, "80").project;
|
||||
return p;
|
||||
}
|
||||
@@ -1287,6 +1287,10 @@ export type ExtrudedSolid = {
|
||||
type: "extrudedSolid";
|
||||
/** Geschoss, dessen `baseElevation` die UK des Körpers bestimmt. */
|
||||
levelId: string;
|
||||
/**
|
||||
* [180] Klasse (Ebene/Kategorie) wie bei jedem Bauteil: Sichtbarkeit in Grundriss, Schnitt und Ansicht.
|
||||
*/
|
||||
categoryCode: string;
|
||||
/**
|
||||
* Geschlossenes Profil in der XY-Ebene (Grundriss), ≥3 Punkte. Bei einem
|
||||
* Kreis-Profil (`circle` gesetzt) eine Tessellierung des Kreises (48-Eck) —
|
||||
|
||||
@@ -30,6 +30,7 @@ import type { LayerCategory } from "./host";
|
||||
import type { DisplayMode } from "./types";
|
||||
import { DisplayModeSelect } from "./DisplayModeSelect";
|
||||
import { t } from "../i18n";
|
||||
import { DERIVED_CATEGORY_CODES } from "../model/derivedCategories";
|
||||
|
||||
/** Inhalt des Panels „Ebenen". */
|
||||
export function LayersPanel() {
|
||||
@@ -129,7 +130,11 @@ function CategoryRow({
|
||||
style={style}
|
||||
onClick={() => onSelect(category.code)}
|
||||
onContextMenu={(e) => onContext(category.code, e)}
|
||||
title={t("nav.categorySelect", { name: category.name })}
|
||||
title={
|
||||
DERIVED_CATEGORY_CODES.includes(category.code)
|
||||
? `${t("nav.categorySelect", { name: category.name })}\n${t(`nav.categoryDerived.${category.code}`)}`
|
||||
: t("nav.categorySelect", { name: category.name })
|
||||
}
|
||||
>
|
||||
<button
|
||||
className={`eye${category.visible ? " is-on" : ""}`}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
viewBox -4.2 0 37.045 17.378
|
||||
bytes 196335
|
||||
bytes 194324
|
||||
circle 4
|
||||
g 1
|
||||
line 437
|
||||
line 546
|
||||
path 2
|
||||
polygon 1045
|
||||
polyline 154
|
||||
polyline 44
|
||||
rect 1
|
||||
svg 1
|
||||
text 4
|
||||
hash 673ad0ec9c6ff4d1
|
||||
hash 9ddddce6f17fcd6d
|
||||
@@ -1,11 +1,11 @@
|
||||
viewBox 4.457 0 21.343 17.378
|
||||
bytes 28680
|
||||
bytes 28250
|
||||
circle 4
|
||||
g 1
|
||||
line 39
|
||||
line 37
|
||||
polygon 141
|
||||
polyline 16
|
||||
polyline 14
|
||||
rect 1
|
||||
svg 1
|
||||
text 3
|
||||
hash d2dde45c8a663cfa
|
||||
hash 9cdb25c298a73bb1
|
||||
@@ -0,0 +1,96 @@
|
||||
// [180] Alles Sichtbare liegt auf einer Klasse (Vorgabe Maintainer): Grundriss (alle Geschosse), Schnitte und
|
||||
// Ansichten beider Musterhäuser sind leer, wenn alle Klassen ausgeblendet sind; jede Klasse der abgeleiteten
|
||||
// Darstellung (Schatten, Auto-Bemassung, Höhenkoten, Schnittmarken) nimmt genau ihre Primitive mit.
|
||||
// Kern-Gegenstück mit dem Fixture-Projekt: `src-tauri/core/src/plan/derived_class_tests.rs`.
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { computeSection, generateElevationPlan, generatePlan, generateSectionPlan, levelMarksEnabled } from "../core";
|
||||
import { sampleProject, emptyProject } from "../model/sampleProject";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import { withStandards } from "../model/standards";
|
||||
import { flattenCategories } from "../model/layers";
|
||||
import { AUTO_DIM_CATEGORY, DERIVED_CATEGORY_CODES, LEVEL_MARK_CATEGORY, SECTION_MARK_CATEGORY, SHADOW_CATEGORY } from "../model/derivedCategories";
|
||||
import type { Primitive } from "./generatePlan";
|
||||
import type { Project } from "../model/types";
|
||||
|
||||
const SHOW_ALL = () => ({ render: true, greyed: false, locked: false });
|
||||
const allCodes = (p: Project) => new Set(flattenCategories(p.layers).map((c) => c.code));
|
||||
const without = (s: Set<string>, code: string) => new Set([...s].filter((c) => c !== code));
|
||||
|
||||
const projects: [string, () => Project][] = [
|
||||
["muster", () => sampleProject],
|
||||
["komplex", buildComplexSampleProject],
|
||||
];
|
||||
|
||||
const floorPlan = (p: Project, floor: string, codes: Set<string>): readonly Primitive[] =>
|
||||
generatePlan(p, floor, codes, SHOW_ALL, "mittel", false, false, true, 100).primitives;
|
||||
const elevation = (p: Project, id: string, codes: Set<string>): readonly Primitive[] =>
|
||||
generateElevationPlan(p, p.drawingLevels.find((l) => l.id === id)!, { scaleDenominator: 100, visibleCodes: codes, categoryDisplay: SHOW_ALL })?.primitives ?? [];
|
||||
const describeLeft = (prims: readonly Primitive[]) =>
|
||||
prims.slice(0, 5).map((q) => JSON.stringify(q).slice(0, 160));
|
||||
|
||||
describe("[180] Klassen der abgeleiteten Darstellung", () => {
|
||||
it('„Standards laden“ legt sie an (Codes wie im Kern)', () => {
|
||||
const codes = allCodes(withStandards({ ...emptyProject, layers: [] }));
|
||||
for (const c of DERIVED_CATEGORY_CODES) expect(codes.has(c), c).toBe(true);
|
||||
// Die Musterprojekte haben sie schon.
|
||||
for (const c of DERIVED_CATEGORY_CODES) expect(allCodes(sampleProject).has(c), c).toBe(true);
|
||||
});
|
||||
|
||||
for (const [name, make] of projects) {
|
||||
describe(name, () => {
|
||||
const p = make();
|
||||
const all = allCodes(p);
|
||||
|
||||
for (const lvl of p.drawingLevels.filter((l) => l.kind === "floor")) {
|
||||
it(`Grundriss ${lvl.id}: ohne Klassen leer`, () => {
|
||||
expect(floorPlan(p, lvl.id, all).length).toBeGreaterThan(0);
|
||||
const rest = floorPlan(p, lvl.id, new Set());
|
||||
expect(rest.length, describeLeft(rest).join("\n")).toBe(0);
|
||||
});
|
||||
}
|
||||
|
||||
for (const lvl of p.drawingLevels.filter((l) => l.kind === "section")) {
|
||||
it(`Schnitt ${lvl.id}: ohne Klassen leer`, async () => {
|
||||
const out = (await computeSection(p, lvl))!;
|
||||
const plan = (codes: Set<string>) => generateSectionPlan(out, false, { visibleCodes: codes, categoryDisplay: SHOW_ALL, openings: true, scaleDenominator: 100 }).primitives;
|
||||
expect(plan(all).length).toBeGreaterThan(0);
|
||||
const rest = plan(new Set());
|
||||
expect(rest.length, describeLeft(rest).join("\n")).toBe(0);
|
||||
expect(levelMarksEnabled({ ...lvl, levelMarks: true }, p, (c) => all.has(c))).toBe(true);
|
||||
expect(levelMarksEnabled({ ...lvl, levelMarks: true }, p, (c) => c !== LEVEL_MARK_CATEGORY)).toBe(false);
|
||||
}, 30_000);
|
||||
}
|
||||
|
||||
for (const lvl of p.drawingLevels.filter((l) => l.kind === "elevation")) {
|
||||
it(`Ansicht ${lvl.id}: ohne Klassen leer, Schlagschatten auf „Schatten“`, () => {
|
||||
const shaded = { ...p, drawingLevels: p.drawingLevels.map((l) => (l.id === lvl.id ? { ...l, shadows: true } : l)) };
|
||||
const full = elevation(shaded, lvl.id, all);
|
||||
expect(full.length).toBeGreaterThan(0);
|
||||
const rest = elevation(shaded, lvl.id, new Set());
|
||||
expect(rest.length, describeLeft(rest).join("\n")).toBe(0);
|
||||
const shadows = (v: readonly Primitive[]) => v.filter((q) => q.kind === "polygon" && q.contextObjectId === "@viewShadows").length;
|
||||
expect(shadows(full)).toBeGreaterThan(0);
|
||||
expect(shadows(elevation(shaded, lvl.id, without(all, SHADOW_CATEGORY)))).toBe(0);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
it("komplex EG: Schatten, Auto-Bemassung und Schnittmarken einzeln aus", () => {
|
||||
const p = buildComplexSampleProject();
|
||||
const all = allCodes(p);
|
||||
const full = floorPlan(p, "eg", all);
|
||||
const count = (v: readonly Primitive[], hit: (q: Primitive) => boolean) => v.filter(hit).length;
|
||||
const sun = (q: Primitive) => q.kind === "polygon" && q.contextObjectId === "@sunStudy";
|
||||
const autodim = (q: Primitive) => "drawingId" in q && typeof q.drawingId === "string" && q.drawingId.startsWith("autodim-");
|
||||
const marks = (q: Primitive) => q.kind === "polygon" && !!q.sectionLineId;
|
||||
for (const [code, hit] of [[SHADOW_CATEGORY, sun], [AUTO_DIM_CATEGORY, autodim], [SECTION_MARK_CATEGORY, marks]] as const) {
|
||||
const n = count(full, hit);
|
||||
expect(n, code).toBeGreaterThan(0);
|
||||
const off = floorPlan(p, "eg", without(all, code));
|
||||
expect(count(off, hit), code).toBe(0);
|
||||
}
|
||||
// Die Aussenbemassung trägt ihre Klasse (je Kette änderbar).
|
||||
expect(p.drawings2d.filter((d) => d.id.startsWith("autodim-")).every((d) => d.categoryCode === AUTO_DIM_CATEGORY)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -3,7 +3,7 @@ import type { ExtrudedSolid } from "../model/types";
|
||||
import { extrudedSolidSpec, needsBrepPath } from "./extrudedSolidSpec";
|
||||
|
||||
const sq = [{ x: 0, y: 0 }, { x: 2, y: 0 }, { x: 2, y: 2 }, { x: 0, y: 2 }];
|
||||
const base: ExtrudedSolid = { id: "e1", type: "extrudedSolid", levelId: "eg", points: sq, height: 3 };
|
||||
const base: ExtrudedSolid = { id: "e1", type: "extrudedSolid", categoryCode: "20", levelId: "eg", points: sq, height: 3 };
|
||||
|
||||
describe("extrudedSolidSpec", () => {
|
||||
it("Prisma ohne Besonderheiten bleibt auf dem alten Pfad", () => {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* (cls "section-line"), Endmarken + ein unsichtbares Pick-Band (Polygon mit
|
||||
* `sectionLineId`). Ebenen OHNE Linie erzeugen nichts.
|
||||
*
|
||||
* Sichtbarkeit läuft über die feste Kategorie "90" (Referenzen) — NICHT über
|
||||
* Sichtbarkeit läuft über die Standard-Klasse "91" (Schnittmarken, [180]; früher "90" Referenzen) — NICHT über
|
||||
* das eigene `visible`-Flag der Schnitt-/Ansichtsebene (Nutzer-Feedback: "das
|
||||
* sollten Elemente sein, die sich auf einer Ebene befinden und nur damit
|
||||
* ein-/ausgeblendet werden"). Das Flag ist daher für dieses Symbol wirkungslos.
|
||||
@@ -15,7 +15,7 @@ import { generatePlan } from "./generatePlan";
|
||||
import type { CategoryDisplayResolver } from "./generatePlan";
|
||||
import type { DrawingLevel, Project } from "../model/types";
|
||||
|
||||
const visible = new Set(["20", "35", "90"]);
|
||||
const visible = new Set(["20", "35", "90", "91"]);
|
||||
|
||||
function baseProject(levels: DrawingLevel[]): Project {
|
||||
return {
|
||||
@@ -26,7 +26,10 @@ function baseProject(levels: DrawingLevel[]): Project {
|
||||
components: [],
|
||||
wallTypes: [],
|
||||
drawingLevels: levels,
|
||||
layers: [{ code: "20", name: "Wände", color: "#333", lw: 0.18, visible: true, locked: false }],
|
||||
layers: [
|
||||
{ code: "20", name: "Wände", color: "#333", lw: 0.18, visible: true, locked: false },
|
||||
{ code: "91", name: "Schnittmarken", color: "#1a1a1a", lw: 0.18, visible: true, locked: false },
|
||||
],
|
||||
walls: [],
|
||||
openings: [],
|
||||
ceilings: [],
|
||||
@@ -106,7 +109,7 @@ describe("generatePlan — Schnittführungs-Symbol", () => {
|
||||
expect(prims.some((pr) => pr.kind === "line" && pr.cls === "section-line")).toBe(false);
|
||||
});
|
||||
|
||||
it("zeichnet TROTZDEM, auch wenn die Schnittebene selbst visible=false trägt (nur Kategorie '90' zählt)", () => {
|
||||
it("zeichnet TROTZDEM, auch wenn die Schnittebene selbst visible=false trägt (nur die Klasse '91' zählt)", () => {
|
||||
const p = baseProject([
|
||||
floor,
|
||||
{
|
||||
@@ -123,7 +126,7 @@ describe("generatePlan — Schnittführungs-Symbol", () => {
|
||||
expect(prims.some((pr) => pr.kind === "polygon" && pr.sectionLineId === "s-hidden")).toBe(true);
|
||||
});
|
||||
|
||||
it("zeichnet NICHTS, wenn Kategorie '90' NICHT sichtbar ist (visibleCodes ohne '90')", () => {
|
||||
it("zeichnet NICHTS, wenn die Klasse '91' NICHT sichtbar ist (visibleCodes ohne '91')", () => {
|
||||
const p = baseProject([
|
||||
floor,
|
||||
{
|
||||
@@ -136,11 +139,11 @@ describe("generatePlan — Schnittführungs-Symbol", () => {
|
||||
directionSign: 1,
|
||||
},
|
||||
]);
|
||||
const prims = generatePlan(p, "eg", new Set(["20", "35"])).primitives;
|
||||
const prims = generatePlan(p, "eg", new Set(["20", "35", "90"])).primitives;
|
||||
expect(prims.some((pr) => pr.kind === "polygon" && pr.sectionLineId === "s-cat")).toBe(false);
|
||||
});
|
||||
|
||||
it("dimmt (greyed), wenn categoryDisplay('90') greyed liefert", () => {
|
||||
it("dimmt (greyed), wenn categoryDisplay('91') greyed liefert", () => {
|
||||
const p = baseProject([
|
||||
floor,
|
||||
{
|
||||
@@ -154,7 +157,7 @@ describe("generatePlan — Schnittführungs-Symbol", () => {
|
||||
},
|
||||
]);
|
||||
const categoryDisplay: CategoryDisplayResolver = (code) =>
|
||||
code === "90" ? { render: true, greyed: true, locked: false } : { render: true, greyed: false, locked: false };
|
||||
code === "91" ? { render: true, greyed: true, locked: false } : { render: true, greyed: false, locked: false };
|
||||
const prims = generatePlan(p, "eg", visible, categoryDisplay).primitives;
|
||||
const line = prims.find((pr) => pr.kind === "line" && pr.cls === "section-line") as
|
||||
| { greyed?: boolean }
|
||||
|
||||
@@ -3,20 +3,28 @@
|
||||
// Gebäudes (First/OK Dach), links neben der Zeichnung mit einer kurzen
|
||||
// Bezugslinie zur Geometrie. Symbol = dieselbe SIA-400-Kote wie das 2D-Element
|
||||
// `kote`; gerechnet im Kern (`plan/drawings.rs::level_markers`, Abfrage `levelMarkers`).
|
||||
// Abschaltbar je Ebene (`DrawingLevel.levelMarks`) oder über die Modelldarstellung ([173]).
|
||||
// Abschaltbar je Ebene (`DrawingLevel.levelMarks`), über die Modelldarstellung ([173]) oder die Klasse
|
||||
// „Höhenkoten" ([180]).
|
||||
|
||||
import type { DrawingLevel, Project } from "../model/types";
|
||||
import type { Primitive } from "./generatePlan";
|
||||
import { documentFor } from "../core/document";
|
||||
import { decodePlanBuf } from "./planBuf";
|
||||
import { derivedVisible, LEVEL_MARK_CATEGORY } from "../model/derivedCategories";
|
||||
|
||||
/**
|
||||
* Ob eine Ebene automatische Koten trägt: Ebene > [173] Modelldarstellung der Ebene (`dimensions.levelMarks`,
|
||||
* Rangfolge wie Kern `model_view::Options::level_marks`) > an.
|
||||
*/
|
||||
export function levelMarksEnabled(level: DrawingLevel, project?: Pick<Project, "modelViewOptions">): boolean {
|
||||
export function levelMarksEnabled(
|
||||
level: DrawingLevel,
|
||||
project?: Pick<Project, "modelViewOptions"> & Partial<Pick<Project, "layers">>,
|
||||
shown?: (code: string) => boolean,
|
||||
): boolean {
|
||||
const mv = level.modelViewOptionId ? project?.modelViewOptions?.find((m) => m.id === level.modelViewOptionId) : undefined;
|
||||
return level.levelMarks ?? mv?.dimensions?.levelMarks ?? true;
|
||||
const on = level.levelMarks ?? mv?.dimensions?.levelMarks ?? true;
|
||||
// [180] Die Koten liegen auf der Klasse „Höhenkoten": ausgeblendet ⇒ ohne (`shown`: sichtbar und gezeichnet).
|
||||
return on && (!shown || !project?.layers || derivedVisible(project.layers, LEVEL_MARK_CATEGORY, shown));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,7 +50,7 @@ describe("Schnitt: Gelände und freie Körper", () => {
|
||||
// Kugel mitten auf der Schnittebene: Position aus der Schnittlinie des Beispiels
|
||||
const [px, , pz] = (await import("./toSection")).sectionPlaneFromLevel(section)!.point;
|
||||
const sphere: ExtrudedSolid = {
|
||||
id: "ball", type: "extrudedSolid", levelId: floor.id, height: 2,
|
||||
id: "ball", type: "extrudedSolid", categoryCode: "20", levelId: floor.id, height: 2,
|
||||
points: [{ x: px - 1, y: pz - 1 }, { x: px + 1, y: pz - 1 }, { x: px + 1, y: pz + 1 }, { x: px - 1, y: pz + 1 }],
|
||||
brep: { spec: { kind: "sphere", center: [px, pz, 1], r: 1 }, origin: { x: px - 1, y: pz - 1 } },
|
||||
};
|
||||
@@ -67,7 +67,7 @@ describe("Schnitt: Gelände und freie Körper", () => {
|
||||
const cy = (a.y + b.y) / 2;
|
||||
const r = 2;
|
||||
const ball: ExtrudedSolid = {
|
||||
id: "void-ball", type: "extrudedSolid", levelId: floor.id, height: 2 * r, operation: "subtract",
|
||||
id: "void-ball", type: "extrudedSolid", categoryCode: "20", levelId: floor.id, height: 2 * r, operation: "subtract",
|
||||
points: [{ x: cx - r, y: cy - r }, { x: cx + r, y: cy - r }, { x: cx + r, y: cy + r }, { x: cx - r, y: cy + r }],
|
||||
brep: { spec: { kind: "sphere", center: [cx, cy, 1], r }, origin: { x: cx - r, y: cy - r } },
|
||||
};
|
||||
|
||||
@@ -20,8 +20,8 @@ const base: Project = {
|
||||
{ id: "k1", type: "column", floorId: "eg", categoryCode: "25", position: { x: 20, y: 3 }, profile: { kind: "rect", width: 0.4, depth: 0.4 }, rotation: 0, height: 2.5 },
|
||||
],
|
||||
extrudedSolids: [
|
||||
{ id: "s1", type: "extrudedSolid", levelId: "og", points: [{ x: 30, y: 2 }, { x: 32, y: 2 }, { x: 32, y: 5 }, { x: 30, y: 5 }], height: 1.5, baseOffset: 0.5 },
|
||||
{ id: "v1", type: "extrudedSolid", levelId: "eg", points: [{ x: 40, y: 0 }, { x: 41, y: 0 }, { x: 41, y: 1 }], height: 1, operation: "subtract" },
|
||||
{ id: "s1", type: "extrudedSolid", categoryCode: "20", levelId: "og", points: [{ x: 30, y: 2 }, { x: 32, y: 2 }, { x: 32, y: 5 }, { x: 30, y: 5 }], height: 1.5, baseOffset: 0.5 },
|
||||
{ id: "v1", type: "extrudedSolid", categoryCode: "20", levelId: "eg", points: [{ x: 40, y: 0 }, { x: 41, y: 0 }, { x: 41, y: 1 }], height: 1, operation: "subtract" },
|
||||
],
|
||||
} as Project;
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ async function levelPlan(
|
||||
}
|
||||
if (!raw || raw.primitives.length === 0) return EMPTY;
|
||||
const own = generatePlan(project, level.id, visibleCodes, undefined, detail, false, mono, false, scaleDenominator, forPrint, false, overrideRuleIds);
|
||||
const marks = levelMarksEnabled(level, project) ? levelMarkerPrimitives(project, raw.bounds, raw.primitives) : [];
|
||||
const marks = levelMarksEnabled(level, project, (c) => visibleCodes.has(c)) ? levelMarkerPrimitives(project, raw.bounds, raw.primitives) : [];
|
||||
const b = { ...raw.bounds };
|
||||
const grow = (x: number, y: number) => {
|
||||
b.minX = Math.min(b.minX, x);
|
||||
|
||||
@@ -9,7 +9,7 @@ const sq = (x0: number, y0: number, x1: number, y1: number): Pair[] => [[x0, y0]
|
||||
const area = (r: Pair[]) => Math.abs(r.reduce((s, p, i) => s + p[0] * r[(i + 1) % r.length][1] - r[(i + 1) % r.length][0] * p[1], 0) / 2);
|
||||
|
||||
function withVoid(p: Project, v: Partial<ExtrudedSolid>): Project {
|
||||
const solid: ExtrudedSolid = { id: "void1", type: "extrudedSolid", levelId: p.walls[0].floorId, operation: "subtract", height: 2, points: [], ...v };
|
||||
const solid: ExtrudedSolid = { id: "void1", type: "extrudedSolid", categoryCode: "20", levelId: p.walls[0].floorId, operation: "subtract", height: 2, points: [], ...v };
|
||||
return { ...p, extrudedSolids: [...(p.extrudedSolids ?? []), solid] };
|
||||
}
|
||||
|
||||
|
||||
@@ -346,7 +346,11 @@ export function buildSelectionStyleHost(c: FlatHostOpts) {
|
||||
case "contextObject":
|
||||
applyChange((p) => patchItem(p, "context", id, { categoryCode: code }));
|
||||
break;
|
||||
default: break; // extrudedSolid/door: keine Kategorie am Element
|
||||
// [180] Körper (Extrusion, B-Rep, Abzugskörper) tragen eine Klasse wie jedes Bauteil.
|
||||
case "extrudedSolid":
|
||||
applyChange((p) => patchItem(p, "extrudedSolids", id, { categoryCode: code }));
|
||||
break;
|
||||
default: break; // door: keine Kategorie am Element
|
||||
}
|
||||
},
|
||||
onSetSelectionLevel: (levelId) => {
|
||||
|
||||
@@ -53,7 +53,7 @@ describe("deriveSelection (Kern)", () => {
|
||||
const p = base();
|
||||
const lvl = p.drawingLevels[0].id;
|
||||
p.extrudedSolids = [
|
||||
{ id: "x", type: "extrudedSolid", levelId: lvl, points: [{ x: 0, y: 0 }, { x: 2, y: 0 }, { x: 2, y: 3 }], height: 2 },
|
||||
{ id: "x", type: "extrudedSolid", categoryCode: "20", levelId: lvl, points: [{ x: 0, y: 0 }, { x: 2, y: 0 }, { x: 2, y: 3 }], height: 2 },
|
||||
];
|
||||
const sel = deriveSelection(p, { solids: ["x"] })!;
|
||||
expect(sel.extrudedSolid!.area).toBeCloseTo(3, 12);
|
||||
|
||||
@@ -343,7 +343,7 @@ describe("commitTransform — ExtrudedSolid mit Kreis-Profil (REGRESSION: circle
|
||||
function circleSolid(id: string): ExtrudedSolid {
|
||||
return {
|
||||
id,
|
||||
type: "extrudedSolid",
|
||||
type: "extrudedSolid", categoryCode: "20",
|
||||
levelId: "eg",
|
||||
points: [{ x: -1, y: 0 }, { x: 0, y: 1 }, { x: 1, y: 0 }, { x: 0, y: -1 }], // grobe Tessellierung
|
||||
height: 2,
|
||||
@@ -499,7 +499,7 @@ describe("transformPreview — Vorschau für alle 2D-Formen (Kern, Plan-Primitiv
|
||||
|
||||
describe("commitTransform — B-Rep-Körper (Spezifikation als transform gewickelt)", () => {
|
||||
const body = {
|
||||
id: "b", type: "extrudedSolid", points: [{ x: 0, y: 0 }, { x: 2, y: 0 }, { x: 2, y: 1 }, { x: 0, y: 1 }], height: 3,
|
||||
id: "b", type: "extrudedSolid", categoryCode: "20", points: [{ x: 0, y: 0 }, { x: 2, y: 0 }, { x: 2, y: 1 }, { x: 0, y: 1 }], height: 3,
|
||||
brep: { spec: { kind: "cuboid", min: [0, 0, 0], max: [2, 1, 3] }, origin: { x: 0, y: 0 } },
|
||||
} as unknown as ExtrudedSolid;
|
||||
const p = { ...project([]), extrudedSolids: [body] } as Project;
|
||||
|
||||
@@ -1138,8 +1138,10 @@ function SectionPlanView({
|
||||
// Automatische Höhenkoten links neben der Zeichnung (abschaltbar je Ebene).
|
||||
const marks = useMemo(
|
||||
() =>
|
||||
rawPlan && levelMarksEnabled(level, project) ? levelMarkerPrimitives(project, rawPlan.bounds, rawPlan.primitives) : [],
|
||||
[rawPlan, level, project],
|
||||
rawPlan && levelMarksEnabled(level, project, (c) => visibleCodes.has(c) && categoryDisplay(c).render)
|
||||
? levelMarkerPrimitives(project, rawPlan.bounds, rawPlan.primitives)
|
||||
: [],
|
||||
[rawPlan, level, project, visibleCodes, categoryDisplay],
|
||||
);
|
||||
const withOverlay = useMemo(() => {
|
||||
if (!rawPlan) return rawPlan;
|
||||
|
||||
Reference in new issue
Block a user