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

This commit is contained in:
Claude committed 2026-11-09 15:58:58 +00:00
commit eff3002892
13 files changed
+455 -111

No files matched your search

+4
View File
@@ -58,6 +58,10 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `*
Extrusion pro Abschnitt in einer SweptSolid-Darstellung, Menge = Summe (`column_pieces_quantities`); ein
Abschnitt bleibt `COLUMN` (10). Offen: Längsschnitt ohne Anschlag-Nasen/Schichteinzug; Muster bei ungeraden Maschen;
Schnitt genau in einer Wand-Stirnfläche: Lücke in der Projektionskante über den Streifen. · M
- ◐ **[166]** Dämm-Striche (EPS/XPS, „Dämmstoffe (SIA-Linien)") quer zur Wand. 9.11.: Szene/PDF und CLI-/Druck-SVG/DXF
lasen den Schraffur-Winkel um 90° verschieden (Standard 0°↔90° hin und her); jetzt alle über `hatch::build_hatch_runs`
(DXF 90° − Winkel), Standard 0°, Laden stellt 90° zurück, Bogenwand-Nasen polar; Test `plan/hatch_dir_tests.rs`.
Offen: render3d-Live-Schnitt und Mac nicht angesehen. · S
- ◐ **[145]** Texte beim Zoomen synchron. Falls der Mac noch nachläuft: Raumstempel nativ zeichnen (vtext kann nur
einzeilig/linksbündig, eine Schrift, kein Fett). 9.11.: `clampInside` nur noch im Kern (`grip_clamp_inside`,
Fassade `clampInside` in `src/core`); die Öffnungs-Vorschau beim Setzen zeigt die geklemmte/gerückte Lage
+3 -1
View File
@@ -532,7 +532,9 @@ node dist-cli/dossier-cli.mjs :musterhaus-komplex migrate --out mk.obp # als D
node dist-cli/dossier-cli.mjs mk.obp ifc --out mk.ifc
```
Ohne `--hatch` enthält das SVG nur die Grundfüllung, keine Schraffurlinien. Das SVG öffnet man im
Ohne `--hatch` enthält das SVG nur die Grundfüllung, keine Schraffurlinien. Mit `--hatch` kommen die Linien aus
demselben Generator wie Bildschirm und PDF (`hatch::build_hatch_runs`); Schraffur-Winkel wie die SVG-Kachel:
0° = Musterlinie senkrecht, relativ zur Wand also quer zur Wandachse (Dämm-Striche: Winkel 0, [166]). Das SVG öffnet man im
Browser oder rastert es mit Playwright (im Container liegt Chromium unter `/opt/pw-browsers`):
```js
+5 -2
View File
@@ -546,10 +546,13 @@ fn hatch_families(h: &Hatch) -> Vec<(f64, f64)> {
if !spacing.is_finite() {
return Vec::new();
}
let angle = (h.angle * PI) / 180.0;
// [166] Lesart wie Szene/SVG-Kachel (`hatch::build_hatch_runs`): Winkel 0 = Musterlinie senkrecht, die
// Drehung im Bildschirm-Uhrzeigersinn → Linienrichtung im Modell (y nach oben, DXF) = 90° − Winkel.
// Vorher Winkel = Linienrichtung: 0°/90°-Scharen (Dämm-Striche, Glas) lagen um 90° verdreht.
let angle = (PI / 2.0 - (h.angle * PI) / 180.0).rem_euclid(PI);
let mut out = vec![(angle, spacing)];
if h.pattern == Pattern::Crosshatch {
out.push((angle + PI / 2.0, spacing));
out.push(((angle + PI / 2.0).rem_euclid(PI), spacing));
}
out
}
+374
View File
@@ -0,0 +1,374 @@
//! [166] Richtung der Dämm-Strichschraffur („Dämmstoffe (SIA-Linien)", EPS/XPS): die Striche stehen
//! immer quer (90°) zur Schicht — im Grundriss zur lokalen Wandachse (gerade Wand beliebig gedreht,
//! Bogenwand radial, Ecke/Gehrung, Y, T, kollinear, Wand an/durch Stütze), im Schnitt zur Schicht
//! (Wand senkrecht, Decke waagrecht, Dach geneigt). Geprüft werden die tatsächlich gezeichneten
//! Schraffurlinien aller drei Ausgaben des Plan-Puffers: render2d-Szene (Bildschirm und PDF-Export
//! `sceneToPrintSvg`), CLI-SVG (`plan/svg.rs`) und Druck-SVG der Layout-Blätter (`plan/print_svg.rs`).
//! Vorher lief die Schaar je nach Ausgabe längs oder quer: die Szene (Kern-Generator wie die SVG-
//! `<pattern>`-Kachel: Winkel 0 = Linie senkrecht) und die beiden SVG-Ausgaben (eigene Linienschar:
//! Winkel 0 = Linie waagrecht) lasen den Schraffur-Winkel um 90° verschieden.
use super::buf::{View, Writer};
use super::domains::{plan_domains, PlanArgs};
use super::parts::Part;
use super::prim::Primitive;
use super::wall_join_tests::{add_arc_deg, add_column, add_wall, polar};
use crate::hatch::V2;
use crate::model::*;
/// Schraffur der harten Dämmung genau wie in den Standards.
const EPS_HATCH: &str = "std-h-daemmstoffe-sia";
fn layer(c: &str, t: f64) -> Layer {
Layer { component_id: c.into(), thickness: t, ..Default::default() }
}
/// Testprojekt: nur die Dämmschicht schraffiert (Standard-Schraffur), alle anderen Schichten leer.
/// Wandtypen `aw` (Putz/EPS/Backstein/Putz), `dw` (symmetrisch Putz/EPS/Putz), `bw` (Beton).
fn base() -> Project {
let mut p = Project::default();
let std_h = crate::standards::hatches().into_iter().find(|h| h["id"] == EPS_HATCH).expect("Standard-Schraffur");
p.hatches.push(serde_json::from_value(std_h).unwrap());
p.hatches.push(serde_json::from_value(serde_json::json!({"id": "none", "name": "none", "pattern": "none", "scale": 1, "angle": 0, "color": "#1a1a1a"})).unwrap());
for (id, prio, hatch) in [("render", 10.0, "none"), ("eps", 20.0, EPS_HATCH), ("brick", 50.0, "none"), ("concrete", 100.0, "none")] {
p.components.push(Component { id: id.into(), join_priority: prio, hatch_id: hatch.into(), ..Default::default() });
}
p.wall_types.push(WallType { id: "aw".into(), layers: vec![layer("render", 0.02), layer("eps", 0.16), layer("brick", 0.15), layer("render", 0.015)], ..Default::default() });
p.wall_types.push(WallType { id: "dw".into(), layers: vec![layer("render", 0.015), layer("eps", 0.12), layer("render", 0.015)], ..Default::default() });
p.wall_types.push(WallType { id: "bw".into(), layers: vec![layer("concrete", 0.2)], ..Default::default() });
p.drawing_levels.push(DrawingLevel { id: "eg".into(), kind: DrawingLevelKind::Floor, floor_height: Some(2.6), ..Default::default() });
p
}
/// Richtung (Einheitsvektor) der lokalen Schichtachse am Punkt `m` eines Bandes.
type Axis = Box<dyn Fn(V2) -> V2>;
/// Gezeichneter Lauf (Linie/Polylinie) in Modell-Metern.
type Seg = Vec<V2>;
fn unit(x: f64, y: f64) -> V2 {
let l = x.hypot(y);
V2 { x: x / l, y: y / l }
}
fn wall_axis(w: &Wall) -> Axis {
match crate::wall_arc::WallArc::of_wall(w) {
// Bogen: Tangente = senkrecht zum Radius.
Some(a) => {
let c = a.center;
Box::new(move |m: V2| unit(-(m.y - c.y), m.x - c.x))
}
None => {
let u = unit(w.end.x - w.start.x, w.end.y - w.start.y);
Box::new(move |_| u)
}
}
}
fn inside(pts: &[V2], q: V2) -> bool {
let n = pts.len();
let mut c = false;
let mut j = n - 1;
for i in 0..n {
let (a, b) = (pts[i], pts[j]);
if (a.y > q.y) != (b.y > q.y) && q.x < (b.x - a.x) * (q.y - a.y) / (b.y - a.y) + a.x {
c = !c;
}
j = i;
}
c
}
fn edge_dist(pts: &[V2], q: V2) -> f64 {
let n = pts.len();
(0..n)
.map(|i| {
let (a, b) = (pts[i], pts[(i + 1) % n]);
let (dx, dy) = (b.x - a.x, b.y - a.y);
let l2 = dx * dx + dy * dy;
let t = if l2 > 0.0 { (((q.x - a.x) * dx + (q.y - a.y) * dy) / l2).clamp(0.0, 1.0) } else { 0.0 };
(q.x - a.x - t * dx).hypot(q.y - a.y - t * dy)
})
.fold(f64::INFINITY, f64::min)
}
/// Prüft jede Linie, die in einem gestrichelten Band liegt: Winkel zur lokalen Achse = 90° ± 1°.
/// Jedes Band muss mindestens eine geprüfte Linie haben (sonst fehlt die Schraffur).
fn check(bands: &[(Vec<V2>, Axis)], runs: &[Seg], what: &str) {
let mut hits = vec![0usize; bands.len()];
// Je Teilstrecke: Umrisse (auch als Polylinie) liegen auf dem Bandrand und fallen weg.
for (a, b) in runs.iter().flat_map(|r| r.windows(2).map(|w| (w[0], w[1]))) {
let len = (b.x - a.x).hypot(b.y - a.y);
// Sehr kurze Stücke (Spitze einer Gehrung) tragen Rundungsfehler der Ausgabe (0.001 mm).
if len < 0.02 {
continue;
}
let m = V2 { x: (a.x + b.x) / 2.0, y: (a.y + b.y) / 2.0 };
let mut ks = (0..bands.len()).filter(|&j| inside(&bands[j].0, m));
// Genau ein Band (überlappende Bänder, z. B. Decke über dem Wandkopf im Schnitt, sind mehrdeutig).
let (Some(k), None) = (ks.next(), ks.next()) else { continue };
if edge_dist(&bands[k].0, m) <= 2e-3 {
continue;
}
let u = (bands[k].1)(m);
let d = unit(b.x - a.x, b.y - a.y);
let cos = (d.x * u.x + d.y * u.y).abs();
let deg = cos.clamp(0.0, 1.0).acos().to_degrees();
assert!((deg - 90.0).abs() <= 1.0, "{what}: Dämm-Strich {deg:.2}° zur Schichtachse statt 90° (Linie {a:?} → {b:?})");
hits[k] += 1;
}
for (k, h) in hits.iter().enumerate() {
// Schmale Restflächen (unter 2 cm, z. B. ein Schichtrest neben der Decke) tragen nur zu kurze Striche.
let pts = &bands[k].0;
let n = pts.len();
let area = (0..n).map(|i| pts[i].x * pts[(i + 1) % n].y - pts[(i + 1) % n].x * pts[i].y).sum::<f64>().abs() / 2.0;
let perim: f64 = (0..n).map(|i| (pts[(i + 1) % n].x - pts[i].x).hypot(pts[(i + 1) % n].y - pts[i].y)).sum();
if 2.0 * area / perim < 0.02 {
continue;
}
assert!(*h > 0, "{what}: Band {k} ohne geprüfte Schraffurlinie ({:?}…)", bands[k].0.first());
}
}
/// Die drei Ausgaben eines Plan-Puffers: Linien der Szene, des CLI-SVG und des Druck-SVG.
fn rendered(prims: &[Primitive], scale: f64) -> Vec<(&'static str, Vec<Seg>)> {
let mut w = Writer::new(true);
w.group(prims);
let bytes = w.finish();
let parts = || {
let view = View::parse(&bytes).unwrap();
let n = view.len();
vec![Part::new(view, 0, n).unwrap()]
};
let (mut x0, mut y0, mut x1, mut y1) = (f64::INFINITY, f64::INFINITY, f64::NEG_INFINITY, f64::NEG_INFINITY);
for q in prims {
if let Primitive::Polygon { pts, .. } = q {
for p in pts {
(x0, y0, x1, y1) = (x0.min(p.x), y0.min(p.y), x1.max(p.x), y1.max(p.y));
}
}
}
// render2d-Szene: Schraffurläufe als Polylinien.
let scene = super::scene::build_scene(&mut parts(), &[]).unwrap();
let s: Vec<Seg> = scene.polylines.iter().map(|r| r.pts.clone()).collect();
// CLI-SVG: y gespiegelt (`top − y`).
let o = super::svg::SvgOptions { scale_denominator: scale, margin_m: 0.0, min_x: x0, min_y: y0, max_x: x1, max_y: y1, hatch: true, line_ends: Default::default() };
let svg = super::svg::plan_svg(&mut parts(), &o).unwrap();
let attr = |l: &str, k: &str| -> Option<String> { l.split(&format!(" {k}=\"")).nth(1).and_then(|r| r.split('"').next()).map(String::from) };
let pts_of = |s: &str| -> Vec<(f64, f64)> {
s.split(' ').filter_map(|q| q.split_once(',')).map(|(a, b)| (a.parse().unwrap(), b.parse().unwrap())).collect()
};
let mut v: Vec<Seg> = Vec::new();
let from_svg = |x: f64, y: f64| V2 { x, y: y1 - y };
for l in svg.lines() {
if l.starts_with("<line") {
let n = |k| attr(l, k).unwrap().parse::<f64>().unwrap();
v.push(vec![from_svg(n("x1"), n("y1")), from_svg(n("x2"), n("y2"))]);
} else if l.starts_with("<polyline") {
v.push(pts_of(&attr(l, "points").unwrap()).into_iter().map(|(x, y)| from_svg(x, y)).collect());
}
}
// Druck-SVG (Papier-mm, y nach unten, Blatt = Ausmass): Anweisungen `E`, Ebene, Tag, Name/Wert….
let k = 1000.0 / scale;
let po = super::print_svg::PrintOptions { scale_denominator: scale, page_w: (x1 - x0) * k, page_h: (y1 - y0) * k, bounds: [x0, y0, x1, y1] };
let ops = super::print_svg::print_svg_ops(&mut parts(), &po).unwrap();
let from_paper = |x: f64, y: f64| V2 { x: x0 + x / k, y: y1 - y / k };
let mut pr: Vec<Seg> = Vec::new();
for rec in ops.split('\u{1e}') {
let f: Vec<&str> = rec.split('\u{1f}').collect();
if f.len() < 3 || f[0] != "E" {
continue;
}
let get = |k: &str| f[3..].chunks(2).find(|c| c.len() == 2 && c[0] == k).map(|c| c[1]);
match f[2] {
"line" => {
let n = |k| get(k).unwrap().parse::<f64>().unwrap();
pr.push(vec![from_paper(n("x1"), n("y1")), from_paper(n("x2"), n("y2"))]);
}
"polyline" => pr.push(pts_of(get("points").unwrap()).into_iter().map(|(x, y)| from_paper(x, y)).collect()),
_ => {}
}
}
vec![("Szene", s), ("CLI-SVG", v), ("Druck-SVG", pr)]
}
/// Grundriss bei 1:`scale` (Detail fein): Dämm-Bänder (Polygone mit Strichschraffur) und ihre Wandachse.
/// Liefert die Zahl der Bänder an Öffnungen (Anschlag-Nasen).
fn plan_case(p: &Project, scale: f64, what: &str) -> usize {
let t = serde_json::json!({ "floor": "eg", "show": ["20"], "grey": [], "scale": scale }).to_string();
let d = plan_domains(p, &PlanArgs::parse(2.0, &t).unwrap()).unwrap();
let prims: Vec<Primitive> = d.walls.into_iter().chain(d.columns).collect();
let mut bands: Vec<(Vec<V2>, Axis)> = Vec::new();
let mut at_openings = 0;
for q in &prims {
if let Primitive::Polygon { pts, hatch, wall_id: Some(id), opening_id, .. } = q {
if hatch.pattern == HatchPattern::Diagonal {
at_openings += usize::from(opening_id.is_some());
let w = p.walls.iter().find(|w| &w.id == id).unwrap();
bands.push((pts.iter().map(|q| V2 { x: q.x, y: q.y }).collect(), wall_axis(w)));
}
}
}
assert!(!bands.is_empty(), "{what}: keine Dämm-Bänder");
for (out, segs) in rendered(&prims, scale) {
check(&bands, &segs, &format!("{what} 1:{scale} {out}"));
}
at_openings
}
/// Fenster mit Anschlag (Wandnase je Schicht) in der Wand `wall`.
fn add_window(p: &mut Project, wall: &str, position: f64) {
// Wie die Fenster im Musterhaus komplex: Rahmen 18 cm hinter der Aussenfläche, Anschlag 5 cm.
let wt = serde_json::json!({"id": "fe", "name": "Fenster", "kind": "dreh", "wingCount": 1, "frameThickness": 0.08, "frameDepth": 0.08, "frameWidth": 0.08,
"insetFromFace": 0.18, "insetFace": "aussen", "rebateDepth": 0.05,
"frameDetail": {"frameSides": {"left": 0.08, "right": 0.08, "top": 0.1, "bottom": 0.12}, "rebates": {"left": 0.05, "right": 0.05, "top": 0.05, "bottom": 0.02}}});
p.window_types.get_or_insert_with(Vec::new).push(serde_json::from_value(wt).unwrap());
let id = format!("O{}", p.openings.as_ref().map_or(0, |o| o.len()) + 1);
p.openings.get_or_insert_with(Vec::new).push(Opening { id, host_wall_id: wall.into(), kind: ElementKind::Window, type_id: Some("fe".into()), category_code: "20".into(), position, width: 1.2, height: 1.4, ..Default::default() });
}
/// Alle Wandfälle im Grundriss, 1:50 und 1:20.
#[test]
fn daemm_striche_quer_zur_wand_im_grundriss() {
let rect = |w: f64, d: f64| ColumnProfile::Rect { width: w, depth: d };
let mut cases: Vec<(String, Project)> = Vec::new();
// Gerade Wände, beliebig gedreht (auch rückwärts gezeichnet).
for deg in [0.0, 17.0, 45.0, 90.0, 133.0, 180.0, 211.0, 270.0, 333.0] {
let mut p = base();
add_wall(&mut p, "aw", (0.0, 0.0), polar((0.0, 0.0), 3.0, deg));
cases.push((format!("gerade {deg}°"), p));
}
// Bogenwände (Gegen- und Uhrzeigersinn, Halbkreis).
for (a0, a1) in [(0.0, 90.0), (90.0, 0.0), (200.0, 380.0), (-30.0, 150.0)] {
let mut p = base();
add_arc_deg(&mut p, "aw", (0.0, 0.0), 2.5, a0, a1);
cases.push((format!("Bogen {a0}°→{a1}°"), p));
}
// Ecken (Gehrung) 90°, 135°, 60°, in zwei Drehlagen.
for (turn, rot) in [(90.0, 0.0), (135.0, 0.0), (60.0, 0.0), (90.0, 30.0), (135.0, 200.0), (60.0, 110.0)] {
let mut p = base();
let o = polar((0.0, 0.0), 3.0, rot);
add_wall(&mut p, "aw", (0.0, 0.0), o);
add_wall(&mut p, "aw", o, polar(o, 3.0, rot + 180.0 - turn));
cases.push((format!("Ecke {turn}° gedreht {rot}°"), p));
}
// Y-Knoten und T-Stoss.
{
let mut p = base();
for deg in [10.0, 130.0, 250.0] {
add_wall(&mut p, "dw", (0.0, 0.0), polar((0.0, 0.0), 3.0, deg));
}
cases.push(("Y".into(), p));
let mut p = base();
add_wall(&mut p, "aw", (-3.0, 0.0), (3.0, 0.0));
add_wall(&mut p, "dw", (0.0, 0.0), (0.0, -3.0));
cases.push(("T".into(), p));
// Gebogener Ast am Y.
let mut p = base();
add_wall(&mut p, "dw", (0.0, 0.0), polar((0.0, 0.0), 3.0, 0.0));
add_wall(&mut p, "dw", (0.0, 0.0), polar((0.0, 0.0), 3.0, 120.0));
super::wall_join_tests::add_arc(&mut p, "dw", (0.0, 0.0), polar((0.0, 0.0), 3.0, 240.0), 0.2);
cases.push(("Y mit Bogen".into(), p));
}
// Kollineare Wände gleichen Typs (Stossfuge), schräg.
{
let mut p = base();
add_wall(&mut p, "aw", (0.0, 0.0), polar((0.0, 0.0), 3.0, 25.0));
add_wall(&mut p, "aw", polar((0.0, 0.0), 3.0, 25.0), polar((0.0, 0.0), 6.0, 25.0));
cases.push(("kollinear".into(), p));
}
// Wand an Stütze (endet an der Kontur), Wand durch Stütze (Streifen), runde Stütze, schräg.
{
let mut p = base();
add_wall(&mut p, "aw", (0.0, 0.0), (3.0, 0.0));
add_column(&mut p, "C", (3.1, 0.0), rect(0.3, 0.4), Some("concrete"));
cases.push(("Wand an Stütze".into(), p));
let mut p = base();
add_wall(&mut p, "aw", (0.0, 0.0), (6.0, 0.0));
add_column(&mut p, "C", (3.0, -0.05), rect(0.3, 0.3), Some("concrete"));
cases.push(("Wand durch Stütze".into(), p));
let mut p = base();
add_wall(&mut p, "aw", (0.0, 0.0), polar((0.0, 0.0), 6.0, 35.0));
let c = polar((0.0, 0.0), 3.0, 35.0);
add_column(&mut p, "C", c, ColumnProfile::Round { radius: 0.25 }, Some("concrete"));
cases.push(("schräge Wand durch runde Stütze".into(), p));
}
for (what, p) in &cases {
for scale in [50.0, 20.0] {
plan_case(p, scale, what);
}
}
// Fenster mit Anschlag: die Wandnasen (Schichtstücke in der Leibung) schraffiert wie ihre Wand, auch in
// der Bogenwand (radial).
for (what, arc) in [("Fenster in schräger Wand", false), ("Fenster in Bogenwand", true)] {
let mut p = base();
if arc {
add_arc_deg(&mut p, "aw", (0.0, 0.0), 3.0, 200.0, 340.0);
} else {
add_wall(&mut p, "aw", (0.0, 0.0), polar((0.0, 0.0), 5.0, 30.0));
}
add_window(&mut p, "W1", 1.8);
for scale in [50.0, 20.0] {
assert!(plan_case(&p, scale, what) > 0, "{what}: keine Nasen-Stücke");
}
}
}
/// Schnitt: Wand (senkrechte Schichten), Decke (waagrecht) und geneigtes Dach mit EPS — die Striche
/// stehen quer zur Schicht (Achse = lange Kante des Schicht-Bandes).
#[test]
fn daemm_striche_quer_zur_schicht_im_schnitt() {
use super::overrides::RuleView;
use super::section::{compute_section, section_primitives_at, CutRules, LevelSpec, Visibility};
let mut p = base();
add_wall(&mut p, "aw", (0.0, 0.0), (6.0, 0.0));
add_wall(&mut p, "aw", (0.0, 4.0), (6.0, 4.0));
p.ceiling_types = Some(vec![CeilingType { id: "ct".into(), name: "Decke".into(), layers: vec![layer("render", 0.08), layer("eps", 0.12), layer("concrete", 0.22)], ..Default::default() }]);
p.ceilings = Some(vec![Ceiling {
id: "D1".into(),
r#type: "ceiling".into(),
floor_id: "eg".into(),
category_code: "25".into(),
outline: vec![Vec2 { x: 0.0, y: 0.0 }, Vec2 { x: 6.0, y: 0.0 }, Vec2 { x: 6.0, y: 4.0 }, Vec2 { x: 0.0, y: 4.0 }],
ceiling_type_id: Some("ct".into()),
..Default::default()
}]);
p.roof_types = Some(vec![RoofType { id: "rt".into(), name: "Dach".into(), layers: vec![layer("eps", 0.18), layer("concrete", 0.2)], ..Default::default() }]);
p.roofs = Some(vec![serde_json::from_value(serde_json::json!({
"id": "R1", "type": "roof", "floorId": "eg", "categoryCode": "35", "roofTypeId": "rt",
"outline": [{"x": -0.5, "y": -0.5}, {"x": 6.5, "y": -0.5}, {"x": 6.5, "y": 4.5}, {"x": -0.5, "y": 4.5}],
"shape": "sattel", "pitchDeg": 35, "overhang": 0, "ridgeAxis": "x", "baseElevation": 3.2, "thickness": 0.38
}))
.unwrap()]);
for (scale, x) in [(50.0, 3.0), (20.0, 2.2)] {
// Schnittlinie quer zu den Wänden (Blick in +x).
let l = LevelSpec { kind: "section".into(), line: Some([Vec2 { x, y: -2.0 }, Vec2 { x, y: 6.0 }]), cut_hatch: true, ..Default::default() };
let out = compute_section(&p, &l, &[]).unwrap().unwrap();
let (prims, _) = section_primitives_at(&out, false, false, &Visibility::default(), scale, super::style::Detail::Fein, true, &CutRules::of(&p, &out, RuleView::at(scale, None)));
let mut bands: Vec<(Vec<V2>, Axis)> = Vec::new();
let mut kinds = std::collections::HashSet::new();
for q in &prims {
if let Primitive::Polygon { pts, hatch, wall_id, ceiling_id, roof_id, .. } = q {
if hatch.pattern != HatchPattern::Diagonal {
continue;
}
let kind = if wall_id.is_some() { "Wand" } else if ceiling_id.is_some() { "Decke" } else if roof_id.is_some() { "Dach" } else { "?" };
kinds.insert(kind);
// Schichtachse: Wand senkrecht, Decke waagrecht, Dach = längste Kante des Bandes (Neigung).
let n = pts.len();
let (i, _) = (0..n).map(|i| (i, (pts[(i + 1) % n].x - pts[i].x).hypot(pts[(i + 1) % n].y - pts[i].y))).fold((0, -1.0), |a, b| if b.1 > a.1 { b } else { a });
let u = match kind {
"Wand" => unit(0.0, 1.0),
"Decke" => unit(1.0, 0.0),
_ => unit(pts[(i + 1) % n].x - pts[i].x, pts[(i + 1) % n].y - pts[i].y),
};
bands.push((pts.iter().map(|q| V2 { x: q.x, y: q.y }).collect(), Box::new(move |_| u)));
}
}
assert!(kinds.contains("Wand") && kinds.contains("Decke") && kinds.contains("Dach"), "1:{scale}: Schnitt trifft {kinds:?}");
for (o, segs) in rendered(&prims, scale) {
check(&bands, &segs, &format!("Schnitt 1:{scale} {o}"));
}
}
}
+2
View File
@@ -41,3 +41,5 @@ pub mod mesh_plan;
pub(crate) mod wall_columns;
#[cfg(test)]
pub(crate) mod wall_join_tests;
#[cfg(test)]
mod hatch_dir_tests;
+5 -96
View File
@@ -292,85 +292,6 @@ fn push_dash(v: &mut Vec<(&'static str, String)>, dash: Option<&[f64]>) {
}
}
/// Parallele Linien im Winkel/Abstand, aufs Polygon geklippt (`fillParallel`).
fn fill_parallel(poly: &[V2], angle: f64, spacing: f64, out: &mut Vec<(V2, V2)>) {
if poly.len() < 3 || spacing <= 0.0 {
return;
}
let dir = V2 { x: jsnum::cos(angle), y: jsnum::sin(angle) };
let nrm = V2 { x: -dir.y, y: dir.x };
let mut t_min = f64::INFINITY;
let mut t_max = f64::NEG_INFINITY;
for p in poly {
let t = p.x * nrm.x + p.y * nrm.y;
if t < t_min {
t_min = t;
}
if t > t_max {
t_max = t;
}
}
let mut t = (t_min / spacing).ceil() * spacing;
while t <= t_max {
let mut xs: Vec<f64> = Vec::new();
let n = poly.len();
let mut j = n - 1;
for i in 0..n {
let a = poly[j];
let b = poly[i];
j = i;
let ta = a.x * nrm.x + a.y * nrm.y;
let tb = b.x * nrm.x + b.y * nrm.y;
if ta == tb {
continue;
}
let f = (t - ta) / (tb - ta);
if f < 0.0 || f > 1.0 {
continue;
}
let px = a.x + (b.x - a.x) * f;
let py = a.y + (b.y - a.y) * f;
xs.push(px * dir.x + py * dir.y);
}
if xs.len() >= 2 {
// `xs.sort((u, v) => u - v)`: stabil; NaN zählt als gleich.
xs.sort_by(|u, v| (u - v).partial_cmp(&0.0).unwrap_or(std::cmp::Ordering::Equal));
let mut k = 0;
while k + 1 < xs.len() {
let (u0, u1) = (xs[k], xs[k + 1]);
k += 2;
if u1 - u0 < 1e-6 {
continue;
}
out.push((V2 { x: nrm.x * t + dir.x * u0, y: nrm.y * t + dir.y * u0 }, V2 { x: nrm.x * t + dir.x * u1, y: nrm.y * t + dir.y * u1 }));
}
}
t += spacing;
}
}
/// Muster, die der Kern-Generator als Linien/Polylinien erzeugt (Schichtmuster, Streu-/Punktmuster, Doppellinien).
pub(super) fn is_generated(p: Pattern) -> bool {
matches!(
p,
Pattern::Insulation | Pattern::InsulationHard | Pattern::InsulationWave | Pattern::Timber | Pattern::Earth | Pattern::Gravel | Pattern::Stone | Pattern::Dots | Pattern::WoodBased | Pattern::Wood | Pattern::Barrier
)
}
/// Schraffurlinien in Papier-mm (`hatchLines`).
pub(super) fn hatch_lines(poly_mm: &[V2], h: &Hatch, mm_per_m: f64) -> Vec<(V2, V2)> {
let unit_mm = (1.0 / 90.0) * mm_per_m;
let tile_mm = 8.0 * h.scale * unit_mm;
let spacing = jsnum::max(0.5, tile_mm);
let angle = (h.angle * PI) / 180.0;
let mut segs = Vec::new();
fill_parallel(poly_mm, angle, spacing, &mut segs);
if h.pattern == Pattern::Crosshatch {
fill_parallel(poly_mm, angle + PI / 2.0, spacing, &mut segs);
}
segs
}
/// Strichmuster der Schraffurlinien in Papier-mm: dieselben Modell-Längen wie Szene/Chunk-Pfad
/// (`hatch::hatch_dash` × `DASH_MM_TO_M`), nur auf das Blatt (`mm_per_m`) abgebildet.
pub(super) fn hatch_dash_paper(h: &Hatch, mm_per_m: f64) -> Vec<f64> {
@@ -464,8 +385,11 @@ fn entry(out: &mut Out, view: &View, i: usize, hatches: &[(i32, Hatch, i32)], m:
let (a, b) = (run[0], run[run.len() - 1]);
out.el(1, "line", &line_attrs(m.at(a.x, a.y), m.at(b.x, b.y), &hatch_color, pen, Some(&hdash)));
}
} else if is_generated(h.pattern) {
// Schicht-/Streumuster ([109]): dieselben Linien wie Szene und Chunk-Pfad (Kern-Generator).
} else {
// Alle Vektor-Schraffuren aus dem Kern-Generator: dieselben Linien wie Szene, PDF-Export und
// Chunk-Pfad ([109] Schicht-/Streumuster; [166] auch Geraden-/Kreuzschar und Motiv: die
// frühere eigene Linienschar las den Winkel um 90° verdreht — Dämm-Striche längs statt quer —
// und kannte die polare Schraffur der Bogenwand nicht).
for run in hatch::build_hatch_runs(&pts, &h) {
let p: Vec<V2> = run.iter().map(|q| m.at(q.x, q.y)).collect();
match p.len() {
@@ -474,11 +398,6 @@ fn entry(out: &mut Out, view: &View, i: usize, hatches: &[(i32, Hatch, i32)], m:
_ => out.el(1, "polyline", &polyline_attrs(&p, &hatch_color, pen, Some(&hdash))),
}
}
} else {
// Strichmuster der Schraffur (null und [] gleich: keins).
for (a, b) in hatch_lines(&pts_mm, &h, k) {
out.el(1, "line", &line_attrs(a, b, &hatch_color, pen, Some(&hdash)));
}
}
if stroke_mm > 0.0 {
poly_outline(out, &pts_mm, &nse, &stroke, stroke_mm);
@@ -826,16 +745,6 @@ mod tests {
assert!(y0 < 140.0 && y1 > 140.0 && (y1 - y0 - 10.0 * PT_TO_MM * 1.3).abs() < 1e-3);
}
#[test]
fn schraffur_parallel_geklippt() {
let sq = [V2 { x: 0.0, y: 0.0 }, V2 { x: 10.0, y: 0.0 }, V2 { x: 10.0, y: 10.0 }, V2 { x: 0.0, y: 10.0 }];
let mut segs = Vec::new();
fill_parallel(&sq, 0.0, 2.0, &mut segs);
// Waagrechte Linien bei y = 0, 2, …, 10 über die volle Breite.
assert_eq!(segs.len(), 6);
assert!(segs.iter().all(|(a, b)| (b.x - a.x - 10.0).abs() < 1e-9 || (a.x - b.x - 10.0).abs() < 1e-9));
}
/// [146] Nicht gestrichene Kanten (`noStrokeEdges`) bleiben im Druck-SVG ohne Strich: Füllung ohne
/// Umriss, die übrigen Kanten als offener Linienzug.
#[test]
+4 -5
View File
@@ -8,7 +8,7 @@
use crate::js_fmt::js_number;
use crate::hatch::{self, Pattern, V2};
use crate::jsnum;
use crate::plan::print_svg::{hatch_dash_paper, hatch_lines, is_generated, quantize_pen};
use crate::plan::print_svg::{hatch_dash_paper, quantize_pen};
use crate::plan::buf::{whole, F_COLOR, F_DASH_LIST, F_GREYED, F_OPACITY, T_ARC, T_CIRCLE, T_DRAWING_ARC, T_DRAWING_TEXT, T_LINE, T_POLYGON, T_TEXT};
use crate::plan::line_ends::LineEnds;
use crate::plan::parts::Part;
@@ -309,11 +309,10 @@ pub fn plan_svg(parts: &mut [Part], o: &SvgOptions) -> Option<String> {
let mut runs: Vec<Vec<V2>> = Vec::new();
if h.random {
runs.extend(hatch::build_random_hatch_runs(&pts, &h, None).into_iter().filter(|r| r.len() >= 2).map(|r| vec![r[0], r[r.len() - 1]]));
} else if is_generated(h.pattern) {
runs.extend(hatch::build_hatch_runs(&pts, &h));
} else {
let pts_mm: Vec<V2> = pts.iter().map(|q| V2 { x: q.x * k, y: q.y * k }).collect();
runs.extend(hatch_lines(&pts_mm, &h, k).into_iter().map(|(a, b)| vec![V2 { x: a.x / k, y: a.y / k }, V2 { x: b.x / k, y: b.y / k }]));
// [166] Alle Vektor-Schraffuren aus dem Kern-Generator wie Szene/PDF (Winkel-Lesart
// der SVG-Kachel, polare Schraffur der Bogenwand).
runs.extend(hatch::build_hatch_runs(&pts, &h));
}
for run in runs {
match run.len() {
+17
View File
@@ -946,6 +946,7 @@ pub fn plan_walls(c: &Ctx, reference_lines: bool, out: &mut Vec<Primitive>, boun
Some(u) => {
let mut tmp = Vec::new();
opening_symbol(c, &mut tmp, wv, o, color, c.greyed(&o.category_code), detail, olw, wall_line)?;
polar_layer_pieces(u, &mut tmp);
bend_prims(u, tmp, out);
}
None => opening_symbol(c, out, w, o, color, c.greyed(&o.category_code), detail, olw, wall_line)?,
@@ -1256,6 +1257,22 @@ fn bend_poly(u: &Unroll, pts: &[Vec2], ns: &[f64]) -> (Vec<Vec2>, Vec<f64>) {
/// Grundriss-Primitive der abgewickelten Ersatzwand biegen ([T2]): Flächen über die Bogenkanten
/// zerlegt, Linien mit konstantem Querversatz als Bögen (≤ 90° je Stück, Gegenuhrzeigersinn, wie
/// es Bildschirm, SVG und DXF erwarten), übrige Linien gerade.
/// [166] Schichtstücke an Öffnungen einer Bogenwand (Anschlag-Nasen, je Wandschicht): polare Schraffur wie
/// die Wandbänder (`wall_poche`, Laufrichtung 180° im Gegenuhrzeigersinn) — sonst stand das Muster nach dem
/// Biegen im Winkel der abgewickelten Ersatzwand (Dämm-Striche senkrecht im Blatt statt radial).
fn polar_layer_pieces(u: &Unroll, prims: &mut [Primitive]) {
for q in prims {
if let Primitive::Polygon { hatch, wall_id: Some(_), .. } = q {
if hatch.polar.is_none() && !matches!(hatch.pattern, HatchPattern::None | HatchPattern::Solid) {
if u.arc.sigma() > 0.0 {
hatch.angle -= 180.0;
}
hatch.polar = Some([u.arc.center.x, u.arc.center.y, u.arc.r]);
}
}
}
}
fn bend_prims(u: &Unroll, prims: Vec<Primitive>, out: &mut Vec<Primitive>) {
for mut p in prims {
match &mut p {
+30
View File
@@ -359,6 +359,19 @@ fn migrate_line_weights(mut raw: Map<String, Value>) -> Map<String, Value> {
raw
}
/// [166] Standard-Schraffur „Dämmstoffe (SIA-Linien)" (EPS/XPS) mit Winkel 90° relativ zur Wand (Standards
/// vom 5. bis 9.11.): 90° zeichnet die Striche längs der Wand (Bildschirm, PDF), gemeint war quer = 0°. Beim
/// Laden zurückgestellt — unabhängig von der Formatversion (Dateien dieser Tage tragen schon Format 5).
fn repair_insulation_hatch_angle(obj: &mut Map<String, Value>) {
let Some(Value::Array(hatches)) = obj.get_mut("hatches") else { return };
for h in hatches.iter_mut().filter_map(Value::as_object_mut) {
let std = h.get("id").and_then(Value::as_str) == Some("std-h-daemmstoffe-sia");
if std && h.get("pattern").and_then(Value::as_str) == Some("diagonal") && h.get("angle").and_then(Value::as_f64) == Some(90.0) && h.get("relativeToWall").and_then(Value::as_bool) == Some(true) {
h.insert("angle".into(), 0.into());
}
}
}
/// Wie [`parse_project_file`], für ein bereits geparstes Objekt.
pub fn parse_project_object(raw: Value, now_ms: f64) -> Parsed {
let Value::Object(mut obj) = raw else { return Parsed::Err("Die Datei enthält kein Dossier-Projekt.".into()) };
@@ -399,6 +412,7 @@ pub fn parse_project_object(raw: Value, now_ms: f64) -> Parsed {
};
}
obj.insert("formatVersion".into(), PROJECT_FORMAT_VERSION.into());
repair_insulation_hatch_angle(&mut obj);
for key in DEFAULT_ARRAYS {
match obj.get(key) {
@@ -676,6 +690,22 @@ mod tests {
assert_eq!(p["overrideRules"][0]["actions"], json!({"linetypeId":"hair","lineweight":0.13}));
}
/// [166] EPS/XPS-Schraffur mit Winkel 90° (Standards 5.–9.11.) wird beim Laden auf 0° (Striche quer zur
/// Wand) zurückgestellt; eigene Schraffuren und andere Winkel bleiben.
#[test]
fn daemmstoffe_winkel_90_wird_quer() {
let h = |id: &str, angle: f64| json!({"id": id, "name": "D", "pattern": "diagonal", "scale": 0.39, "angle": angle, "relativeToWall": true, "color": "#1a1a1a"});
let v = json!({"formatVersion": 5, "id":"p","name":"N","walls":[],"layers":[],"drawingLevels":[],"lineStyles":[],"components":[],"wallTypes":[],
"hatches": [h("std-h-daemmstoffe-sia", 90.0), h("eigen", 90.0)]});
let Parsed::Ok { project, .. } = parse_project_object(v, 0.0) else { panic!() };
let angles: Vec<f64> = project["hatches"].as_array().unwrap().iter().map(|h| h["angle"].as_f64().unwrap()).collect();
assert_eq!(angles, vec![0.0, 90.0]);
let v = json!({"formatVersion": 5, "id":"p","name":"N","walls":[],"layers":[],"drawingLevels":[],"lineStyles":[],"components":[],"wallTypes":[],
"hatches": [h("std-h-daemmstoffe-sia", 45.0)]});
let Parsed::Ok { project, .. } = parse_project_object(v, 0.0) else { panic!() };
assert_eq!(project["hatches"][0]["angle"], 45.0);
}
#[test]
fn staerke_anhang_im_namen() {
assert_eq!(strip_weight_suffix("Volllinie 0.13"), "Volllinie");
+6 -4
View File
@@ -108,8 +108,10 @@ pub fn hatches() -> Vec<Value> {
layer("std-h-daemmung-weich", "SIA Dämmung weich", "insulation", 1.0, 0.1),
layer("std-h-daemmung-holzfaser", "SIA Dämmung Holzfaser", "insulation", 1.4, 0.1),
// Fig. 34 Dämmstoffe (Fig. 37/38): Parallelen quer zur Schicht über die ganze Dicke — für harte
// Dämmung (EPS/XPS), damit sie sich von der weichen unterscheidet.
lines("std-h-daemmstoffe-sia", "Dämmstoffe (SIA-Linien)", "diagonal", 0.035, 90.0, true, 0.1, ""),
// Dämmung (EPS/XPS), damit sie sich von der weichen unterscheidet. Winkel 0 relativ zur Wand =
// Striche QUER zur Wandachse (Musterlinie läuft wie in der SVG-Kachel senkrecht zur Achse 0°; 90° wäre
// längs wie Glas). [166]: 90° zeichnete nur das CLI-/Druck-SVG quer, Bildschirm und PDF längs.
lines("std-h-daemmstoffe-sia", "Dämmstoffe (SIA-Linien)", "diagonal", 0.035, 0.0, true, 0.1, ""),
// Fig. 34 Mörtel, Gips, Verputz: leer (Farbe violett nur bei farbiger Darstellung). Estrich ist Mörtel.
empty("std-h-gips", "SIA Gips"),
empty("std-h-putz", "SIA Putz"),
@@ -801,7 +803,7 @@ mod tests {
assert_eq!((of("std-c-backstein").pattern, of("std-c-backstein").angle), (P::Diagonal, 45.0));
assert_eq!((of("std-c-kalksandstein").pattern, of("std-c-kalksandstein").angle), (P::Diagonal, 135.0));
assert!((spacing("std-c-backstein") - spacing("std-c-kalksandstein")).abs() < 1e-9);
// Weiche Dämmung: Dämmschlange (Holzfaser weiter); harte Dämmung: SIA-Parallelen quer zur Schicht (90° zur Wand, Maintainer 5.11.).
// Weiche Dämmung: Dämmschlange (Holzfaser weiter); harte Dämmung: SIA-Parallelen quer zur Schicht (Striche 90° zur Wand = Schraffur-Winkel 0 relativ zur Wand, [166]).
for c in ["std-c-mineralwolle", "std-c-steinwolle", "std-c-trittschall"] {
let h = of(c);
assert_eq!((h.id.as_str(), h.pattern, h.scale, h.relative_to_wall), ("std-h-daemmung-weich", P::Insulation, 1.0, Some(true)), "{c}");
@@ -809,7 +811,7 @@ mod tests {
assert_eq!((of("std-c-holzfaser").pattern, of("std-c-holzfaser").scale), (P::Insulation, 1.4));
for c in ["std-c-eps", "std-c-xps"] {
let h = of(c);
assert_eq!((h.id.as_str(), h.pattern, h.angle, h.relative_to_wall), ("std-h-daemmstoffe-sia", P::Diagonal, 90.0, Some(true)), "{c}");
assert_eq!((h.id.as_str(), h.pattern, h.angle, h.relative_to_wall), ("std-h-daemmstoffe-sia", P::Diagonal, 0.0, Some(true)), "{c}");
}
// Mörtel, Gips, Verputz (und Estrich) leer; Metall leer, Stahl schwarz.
for c in ["std-c-innenputz", "std-c-aussenputz", "std-c-gipskarton", "std-c-zementestrich", "std-c-aluminium"] {
+2 -1
View File
@@ -54,7 +54,8 @@ describe("buildPlanDxf — Verlauf-Schraffur", () => {
expect(countEntities(dxf, "LINE")).toBe(0); // keine einzelnen Schraffurlinien mehr
expect(countEntities(dxf, "LWPOLYLINE")).toBe(1); // der Umriss
const h = readDxf(dxf).entities.find((e) => e.type === "HATCH")!;
expect(nums(h, 53).map((a) => Math.round(a))).toEqual([0, 90]);
// [166] Winkel 0 wie Bildschirm/SVG-Kachel: erste Schar senkrecht (90°), zweite waagrecht.
expect(nums(h, 53).map((a) => Math.round(a))).toEqual([90, 0]);
});
it("gradient: eine Gradient-HATCH (LINEAR, zwei Farben, Winkel) plus Umriss, keine Musterlinien", () => {
+2 -1
View File
@@ -46,7 +46,8 @@ describe("Standard-Bibliothek ([100]–[102])", () => {
expect(hatchOf("Aussenputz").pattern).toBe("none");
expect(hatchOf("Beton").pattern).toBe("crosshatch");
expect(hatchOf("EPS").pattern).toBe("diagonal");
expect(hatchOf("EPS").angle).toBe(90);
// [166] Winkel 0 relativ zur Wand = Striche quer zur Wandachse (90° wäre längs).
expect(hatchOf("EPS").angle).toBe(0);
expect(hatchOf("Holzwerkstoff (OSB/Spanplatte)").pattern).toBe("woodBased");
expect(hatchOf("Keramikplatten").pattern).toBe("crosshatch");
expect(hatchOf("Faserzementplatten").pattern).toBe("diagonal");
+1 -1
View File
@@ -61,4 +61,4 @@ walls[].start [2] x1489
walls[].startCut [4] x1164
walls[].topDrop [2] x103
walls[].topPlane [3] x259
hash e3ce72592786c6f1
hash 0401db08722c5c30