Merge branch 'worktree-agent-a15a9b043f135b799' into claude/practical-noether-1hb2s1
This commit is contained in:
15 files changed
+1003
-59
No files matched your search
@@ -3540,11 +3540,30 @@ Format · [90] Versionsvergleich · [91] Assistent · [92] Speckle.
|
||||
EG 5/5 Wände, 3/3 Öffnungen, Tür mit Anschlag/Aufschlag; OG 4/4; Musterhaus komplex (UG/EG/OG/DG) Wände 45/57 exakt (79 %),
|
||||
Achsen-Abdeckung 96 % (Rest v. a. kollineare Wände über einen T-Stoss, die als eine Wand erkannt werden; Fundament-/
|
||||
Stützmauern), Öffnungen 35/46 (76 %). Geprüft: cargo test Kern, WASM (Linux, `--no-opt`), tsc, vitest (Goldens
|
||||
unverändert), CLI + Chromium-Bilder (Musterhaus, komplex EG/OG). **Offen:** Schiebe-/Hebeschiebetüren werden Fenster
|
||||
(Symbol ohne Bogen), Türen mit Futter/Zarge breiter als der Bogen bleiben Durchbruch + „Türbogen ohne Lücke“, Türen in
|
||||
Bogenwänden, Stösse von Bogenwänden untereinander, schräg anstossende Enden in einer Wandfläche, Stützen/Treppen/Decken,
|
||||
Blöcke (INSERT) werden schon beim Import aufgelöst (Tür-Blöcke als Linien), Brüstungs-/Sturzhöhen nicht aus 2D ableitbar;
|
||||
nur Linux-Container, nicht in der Tauri-App geklickt (kein Knopf in der Werkzeugleiste, nur Befehlszeile).
|
||||
unverändert), CLI + Chromium-Bilder (Musterhaus, komplex EG/OG). **Offen:** Stösse von Bogenwänden untereinander,
|
||||
schräg anstossende Enden in einer Wandfläche, Treppen/Decken, Fenster über der Schnitthöhe (Wand im Plan ohne Lücke,
|
||||
nur Fenstersymbol im Band: 5 der 6 fehlenden Öffnungen im Musterhaus komplex), Wanddurchbruch mit Schwellen-Rechteck
|
||||
wird Fenster, Schiebetüren in Bogenwänden, Blöcke (INSERT) werden schon beim Import aufgelöst (Tür-Blöcke als Linien),
|
||||
Brüstungs-/Sturzhöhen nicht aus 2D ableitbar; nur Linux-Container, nicht in der Tauri-App geklickt.
|
||||
- ✅ **Nachtrag 7.11.:** **Schiebe-/Hebeschiebetüren** (`RKind::Slide`): Pfeil in der Lücke (Linie parallel zur Wand im
|
||||
Band oder bis 30 cm davor, mit Spitze aus je einem Strich links und rechts, 10–60°, 5–40 cm — ein Dämmungs-Zickzack an
|
||||
der Laibung zählt nicht) → Schiebetür, ab 1.4 m oder mit versetzten Flügeln Hebeschiebetür; ohne Pfeil zwei versetzte
|
||||
Flügel (Liniengruppen im Band auf verschiedener Lage, je 30–80 % der Lücke, ab dem einen bzw. bis zum anderen Pfosten)
|
||||
ab 1.4 m → Hebeschiebetür. Türtyp `schiebe`/`hebeschiebe` aus dem Projekt, sonst neu („Schiebetür (erkannt)“, i18n).
|
||||
**Zarge/Futter:** Türbogen bis 30 cm in der Lücke, Blatt endet höchstens 30 cm vor dem Gegenpfosten (zweiflüglig: vor
|
||||
der Mitte) → Tür mit der Lückenbreite, Anschlag am nahen Pfosten (vorher Durchbruch + „Türbogen ohne Lücke“). **Türen
|
||||
in Bogenwänden:** Türbogen am Pfosten einer Bogenwand-Lücke (Radius = Sehne) → Tür, Aufschlag innen/aussen.
|
||||
**Stützen:** geschlossene Rechtecke (rechte Winkel) und Kreise (auch in Sehnen zerlegt) 15–60 cm mit Füllung/Schraffur
|
||||
oder auf einem Stützen-Layer (Stütze, Säule, Pfeiler, COL …), frei stehend (keine fremde Linie ≤ 1 cm am Umriss) →
|
||||
Stütze (Kategorie 25, sonst 50; Höhe = Geschosshöhe, Drehung aus dem Rechteck); ihre Umrisse fallen für die Wandpaare
|
||||
weg. Zähler/Meldung/Bericht mit Schiebetüren und Stützen, Vorschau (Flügel + Pfeil, Stütze mit Kreuz). **Knopf** „Bauteile
|
||||
aus Zeichnung erkennen“ in der Werkzeug-Palette, Gruppe Ändern (`panels/ToolsPanel.tsx`, Symbol `CommandIcon`).
|
||||
Tests: Rust +7 (Schiebetür vor der Wand, Hebeschiebetür mit/ohne Pfeil + Fenster bleiben Fenster, Zarge, Tür in
|
||||
Bogenwand, Stützen frei/anliegend/zu gross/ungefüllt, Stützen aus dem Projekt + Ops, Schiebetür-Typ neu); vitest Befehl
|
||||
(Schiebetür + Stütze), Rundreise vergleicht Schiebetüren als eigene Art und Stützen. **Quote Musterhaus komplex:**
|
||||
Öffnungen 35/46 (76 %) → 40/46 (87 %) (alle 5 Schiebe-/Hebeschiebetüren), Drehtüren mit Anschlag/Aufschlag 15/15,
|
||||
Stützen 1/1 (UG; Carport-Pfosten 12 cm unter 15 cm), Wände unverändert 45/57 (Achsen 96 %). Geprüft: cargo test Kern,
|
||||
WASM `--no-opt`, tsc, vitest, CLI + Chromium-Bild EG vorher/nachher; nur Linux-Container, Knopf nicht in Tauri geklickt.
|
||||
- ◐ **[68] Baugrube / Geländebearbeitung.** (30.10.) Kontext-Objekt `excavation` (Rust-Modell, `ContextObject`):
|
||||
Sohle (`outline`, `bottom` m ±0.00), Böschung `slope` (Standard 45°, je Kante `edgeSlopes`), Schüttung `fillSlope`
|
||||
(33.7°), Bermen `bermWidth`/`bermHeight`. Neues Gelände = clamp(t, b − d·tan β, b + H(d)) mit d = Abstand zum
|
||||
@@ -4065,6 +4084,15 @@ Code-Übernahme Lizenz der Abhängigkeiten prüfen, Pflicht [51].
|
||||
Reihenfolge, Ebenen, Strichstärken, True-Color, Koordinaten ≤ 5e-7 m (Rundung des alten Writers auf 6 Stellen;
|
||||
neu volle f64). Neu: 2D-Texte als TEXT (fehlten bisher), CLI exportiert georeferenziert wie die App.
|
||||
Gegencheck ezdxf (`scripts/validate-dxf.py`, Test übersprungen ohne `pip install ezdxf`): 0 Auditor-Fehler.
|
||||
- ✅ **Georeferenzierter Export: alle Entitäten in LV95** (7.11., Befund aus [154]): Baugrube (Kontext `excavation`,
|
||||
Ebene CONTEXT) und Parzelle/Baulinien (`siteRules`, Ebene SYMBOLS) blieben beim Export mit `geoAnchor` (App, CLI `dxf`/`dwg`)
|
||||
lokal und lagen nach dem Import 2.7 Mio. m neben dem Gebäude. Ursache: die Projekt-Verschiebung (`geo_translate.rs`,
|
||||
`translatePatch`/`translateOps`; auch „Neuer Bezugspunkt“) nahm Baugrube und Baurecht nicht mit (Baugrube bekam sogar ein
|
||||
leeres `positions`); `geo_rebase.rs` (IFC) vergass Baurecht und Bäume. Jetzt Baugrube (Umriss), Baurecht (Parzelle,
|
||||
Baulinien, Feld-Op `siteRules`) und Bäume überall. Test `export/exportDxf.georef.test.ts`: Musterhaus komplex je Geschoss
|
||||
bei 1:50, DXF alle Punkt-Codes (10/11/13/14: Linien, Polylinien, Bögen, Texte, INSERT + ATTRIB, Bemassung, HATCH, Kontext)
|
||||
und DWG (libredwg) im LV95-Rahmen ± 200 m, Rundreise Export → Import gemeinsam in einem Rahmen; Rust je 1 Test.
|
||||
Linksbündige TEXT tragen im DWG den Ausrichtungspunkt (0, 0) wie AutoCAD (`(11 0 0 0)`, ohne Wirkung). Nur Linux-Container.
|
||||
- ✅ **Binär-DXF-Export** (28.10.): `export_dxf_binary` (acadrust `DxfWriter::new_binary`, R2018 UTF-8),
|
||||
Dialog-Format „DXF binär“, CLI `dxf --binary`. Rundreise acadrust + ezdxf (gleiche Entitäten/Ebenen wie
|
||||
ASCII, 0 Auditor-Fehler, kleiner als der Text). Offen: in AutoCAD/BricsCAD selbst nicht geöffnet.
|
||||
|
||||
@@ -16,13 +16,18 @@
|
||||
//! = rechts = aussen, wie [B4]).
|
||||
//! 5. **Öffnungen**: was auf der Achse weder von Wandstücken noch vom Band einer kreuzenden Wand gedeckt
|
||||
//! ist (≥ 30 cm): Türbogen (50–130°, Zentrum an einem Pfosten, Radius = Breite bzw. halbe Breite bei zwei
|
||||
//! Bögen) → Tür mit Anschlag und Aufschlagseite; Linien parallel zur Wand im Band → Fenster; sonst
|
||||
//! Wanddurchbruch.
|
||||
//! Bögen) → Tür mit Anschlag und Aufschlagseite (auch mit Zarge/Futter: Bogen kleiner als die Lücke);
|
||||
//! Pfeil oder versetzte Flügel ohne Bogen → Schiebe-/Hebeschiebetür; Linien parallel zur Wand im Band →
|
||||
//! Fenster; sonst Wanddurchbruch.
|
||||
//! 6. **Räume**: Zellen der Wandachsen (`kernel2d::detect_rooms`, lichter Umriss), Name aus dem grössten Text
|
||||
//! darin, SIA-Kategorie (HNF …) und Flächenangabe („17.01 m²“, Abweichung > 5 % → unklar).
|
||||
//!
|
||||
//! Konzentrische Bögen im Abstand 5–60 cm werden Bogenwände (ohne Öffnungen und Stösse). Ergebnis als Ops
|
||||
//! (ein Undo-Schritt, [`ops`]), Vorschau ([`preview`]) und Bericht ([`report`], erkannt / unklar mit Grund).
|
||||
//! Vorab **Stützen**: kleine geschlossene Rechtecke/Kreise 15–60 cm mit Füllung oder auf einem Stützen-Layer,
|
||||
//! frei stehend; ihre Umrisse zählen nicht als Wandlinien.
|
||||
//!
|
||||
//! Konzentrische Bögen im Abstand 5–60 cm werden Bogenwände (Lücken: Tür mit Bogen am Pfosten, Fenster,
|
||||
//! Durchbruch). Ergebnis als Ops (ein Undo-Schritt, [`ops`]), Vorschau ([`preview`]) und Bericht ([`report`],
|
||||
//! erkannt / unklar mit Grund).
|
||||
|
||||
use crate::cmd_create::{add_op, category_color, has_category, obj, pv, pvs, s, s_of, Ctx, V};
|
||||
use crate::cmd_transform::{IdGen, Shapes};
|
||||
@@ -51,6 +56,8 @@ const GAP_FREE: f64 = 1.5;
|
||||
const GAP_MAX: f64 = 4.0;
|
||||
/// Kleinste Öffnung.
|
||||
const MIN_OPENING: f64 = 0.3;
|
||||
/// Schiebetür ab dieser Breite eine Hebeschiebetür (typisch ≥ 1.4 m).
|
||||
const SLIDE_WIDE: f64 = 1.4;
|
||||
/// Schutz vor quadratischem Aufwand.
|
||||
const MAX_SEGS: usize = 60_000;
|
||||
const MAX_ARCS: usize = 6_000;
|
||||
@@ -93,6 +100,23 @@ pub struct FillIn {
|
||||
pub hatch: Option<String>,
|
||||
}
|
||||
|
||||
/// Stützen-Kandidat: kleiner geschlossener Umriss (Rechteck oder Kreis, Seiten 15–60 cm), wie [`collect`] ihn
|
||||
/// liest. Ob er eine Stütze wird (gefüllt oder Stützen-Layer, frei stehend), entscheidet [`analyze`].
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ColIn {
|
||||
/// Mitte.
|
||||
pub c: V,
|
||||
/// Breite (entlang `rot`) und Tiefe; Kreis: beide = Durchmesser.
|
||||
pub w: f64,
|
||||
pub d: f64,
|
||||
pub rot: f64,
|
||||
pub round: bool,
|
||||
/// Umriss (Kreis: Polygon).
|
||||
pub ring: Vec<V>,
|
||||
pub filled: bool,
|
||||
pub layer: usize,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct Input {
|
||||
/// Layer-Namen (Kategorie-Namen; beim DXF-Import = DXF-Layer).
|
||||
@@ -101,6 +125,7 @@ pub struct Input {
|
||||
pub arcs: Vec<ArcIn>,
|
||||
pub texts: Vec<TextIn>,
|
||||
pub fills: Vec<FillIn>,
|
||||
pub cols: Vec<ColIn>,
|
||||
}
|
||||
|
||||
impl Input {
|
||||
@@ -132,6 +157,8 @@ pub struct RWall {
|
||||
pub enum RKind {
|
||||
/// Tür: Scharnier am Ende (sonst am Anfang), Blatt rechts der Wandrichtung, Flügelzahl.
|
||||
Door { hinge_end: bool, swing_right: bool, leaves: u8 },
|
||||
/// Schiebetür (Pfeil oder versetzte Flügel, kein Bogen); `lift` = Hebeschiebetür (breit, Flügel versetzt).
|
||||
Slide { lift: bool },
|
||||
Window,
|
||||
Void,
|
||||
}
|
||||
@@ -153,6 +180,16 @@ pub struct RRoom {
|
||||
pub area_text: Option<f64>,
|
||||
}
|
||||
|
||||
/// Stütze: Mitte, Querschnitt (Rechteck `w` × `d`, gedreht um `rot`; Kreis: Durchmesser `w`).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct RColumn {
|
||||
pub c: V,
|
||||
pub w: f64,
|
||||
pub d: f64,
|
||||
pub rot: f64,
|
||||
pub round: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Unclear {
|
||||
pub code: &'static str,
|
||||
@@ -164,6 +201,7 @@ pub struct Recognition {
|
||||
pub walls: Vec<RWall>,
|
||||
pub openings: Vec<ROpening>,
|
||||
pub rooms: Vec<RRoom>,
|
||||
pub columns: Vec<RColumn>,
|
||||
pub unclear: Vec<Unclear>,
|
||||
/// Nur Linien auf Wand-Layern verwendet.
|
||||
pub layer_filter: bool,
|
||||
@@ -383,6 +421,13 @@ pub fn collect(p: &Project, level: &str, ids: &[String]) -> Input {
|
||||
inp.fills.push(FillIn { ring, layer, hatch: hatch.clone() });
|
||||
}
|
||||
};
|
||||
let col = |inp: &mut Input, ring: &[V]| {
|
||||
if let Some(mut c) = column_of(ring) {
|
||||
c.filled = filled;
|
||||
c.layer = layer;
|
||||
inp.cols.push(c);
|
||||
}
|
||||
};
|
||||
match &d.geom {
|
||||
Drawing2DGeom::Line { a, b } => inp.segs.push(Seg { a: (a.x, a.y), b: (b.x, b.y), layer }),
|
||||
Drawing2DGeom::Polyline { pts, closed, bulge, .. } if bulge.as_ref().is_none_or(|b| b.iter().all(|x| !(x.abs() > 1e-9))) => {
|
||||
@@ -392,7 +437,9 @@ pub fn collect(p: &Project, level: &str, ids: &[String]) -> Input {
|
||||
}
|
||||
fit_arcs(&v, layer, &mut inp.segs, &mut inp.arcs);
|
||||
if *closed {
|
||||
fill(&mut inp, pts.iter().map(|q| (q.x, q.y)).collect());
|
||||
let ring: Vec<V> = pts.iter().map(|q| (q.x, q.y)).collect();
|
||||
col(&mut inp, &ring);
|
||||
fill(&mut inp, ring);
|
||||
}
|
||||
}
|
||||
Drawing2DGeom::Polyline { pts, closed, bulge, .. } => {
|
||||
@@ -415,6 +462,7 @@ pub fn collect(p: &Project, level: &str, ids: &[String]) -> Input {
|
||||
for i in 0..4 {
|
||||
inp.segs.push(Seg { a: c[i], b: c[(i + 1) % 4], layer });
|
||||
}
|
||||
col(&mut inp, &c);
|
||||
fill(&mut inp, c.to_vec());
|
||||
}
|
||||
Drawing2DGeom::Arc { center, r, a0, a1 } => {
|
||||
@@ -429,6 +477,8 @@ pub fn collect(p: &Project, level: &str, ids: &[String]) -> Input {
|
||||
Drawing2DGeom::Circle { center, r } => {
|
||||
if r.is_finite() && *r > 1e-6 {
|
||||
inp.arcs.push(ArcIn { c: (center.x, center.y), r: *r, a0: 0.0, sweep: 2.0 * PI, layer });
|
||||
let ring: Vec<V> = (0..32).map(|i| add((center.x, center.y), (r * cos(PI * i as f64 / 16.0), r * sin(PI * i as f64 / 16.0)))).collect();
|
||||
col(&mut inp, &ring);
|
||||
}
|
||||
}
|
||||
Drawing2DGeom::Text { at, text, height, angle, .. } => {
|
||||
@@ -440,9 +490,160 @@ pub fn collect(p: &Project, level: &str, ids: &[String]) -> Input {
|
||||
inp.segs.retain(|s| fin(s.a) && fin(s.b) && len(sub(s.b, s.a)) > 1e-4);
|
||||
inp.arcs.retain(|a| fin(a.c) && a.r.is_finite() && a.a0.is_finite());
|
||||
inp.texts.retain(|t| fin(t.at) && !t.text.trim().is_empty());
|
||||
inp.cols.retain(|c| fin(c.c) && c.ring.iter().all(|p| fin(*p)));
|
||||
inp
|
||||
}
|
||||
|
||||
// ── Stützen ──────────────────────────────────────────────────────────────────
|
||||
|
||||
/// Querschnitt einer Stütze (Seite bzw. Durchmesser).
|
||||
const COL_MIN: f64 = 0.15;
|
||||
const COL_MAX: f64 = 0.60;
|
||||
const COL_WORDS: [&str; 6] = ["stütz", "stuetz", "column", "säule", "saeule", "pfeiler"];
|
||||
|
||||
/// Layer mit Stützen-Namen („Stützen“, „S-COLS“ …)?
|
||||
pub fn column_layer(name: &str) -> bool {
|
||||
let l = name.to_lowercase();
|
||||
COL_WORDS.iter().any(|w| l.contains(w)) || l.split(|c: char| !c.is_alphanumeric()).any(|w| w == "col" || w == "cols")
|
||||
}
|
||||
|
||||
/// Kleiner geschlossener Umriss → Stützen-Kandidat: Rechteck (4 Ecken, rechte Winkel ± 0.6°, Seiten 15–60 cm)
|
||||
/// oder Kreis (≥ 8 Ecken, alle ± 3 mm auf einem Kreis, Ø 15–60 cm).
|
||||
fn column_of(ring: &[V]) -> Option<ColIn> {
|
||||
let mut p: Vec<V> = Vec::with_capacity(ring.len());
|
||||
for &q in ring {
|
||||
if !fin(q) {
|
||||
return None;
|
||||
}
|
||||
if p.last().is_none_or(|l| len(sub(q, *l)) > 1e-6) {
|
||||
p.push(q);
|
||||
}
|
||||
}
|
||||
while p.len() > 1 && len(sub(p[0], p[p.len() - 1])) <= 1e-6 {
|
||||
p.pop();
|
||||
}
|
||||
let n = p.len();
|
||||
let in_range = |x: f64| (COL_MIN - 1e-9..=COL_MAX + 1e-9).contains(&x);
|
||||
let mk = |c: V, w: f64, d: f64, rot: f64, round: bool| ColIn { c, w, d, rot, round, ring: p.clone(), filled: false, layer: 0 };
|
||||
if n == 4 {
|
||||
let e: Vec<V> = (0..4).map(|i| sub(p[(i + 1) % 4], p[i])).collect();
|
||||
let l: Vec<f64> = e.iter().map(|v| len(*v)).collect();
|
||||
if l.iter().any(|x| *x < 1e-6) || (l[0] - l[2]).abs() > 0.003 || (l[1] - l[3]).abs() > 0.003 {
|
||||
return None;
|
||||
}
|
||||
if (0..4).any(|i| (dot(e[i], e[(i + 1) % 4]) / (l[i] * l[(i + 1) % 4])).abs() > 0.01) {
|
||||
return None;
|
||||
}
|
||||
let (w, d) = ((l[0] + l[2]) / 2.0, (l[1] + l[3]) / 2.0);
|
||||
if !in_range(w) || !in_range(d) {
|
||||
return None;
|
||||
}
|
||||
let c = mul(add(add(p[0], p[1]), add(p[2], p[3])), 0.25);
|
||||
return Some(mk(c, w, d, atan2(e[0].1, e[0].0), false));
|
||||
}
|
||||
if n >= 8 {
|
||||
let c = mul(p.iter().fold((0.0, 0.0), |s, q| add(s, *q)), 1.0 / n as f64);
|
||||
let r = p.iter().map(|q| len(sub(*q, c))).sum::<f64>() / n as f64;
|
||||
if p.iter().all(|q| (len(sub(*q, c)) - r).abs() <= 0.003) && in_range(2.0 * r) {
|
||||
return Some(mk(c, 2.0 * r, 2.0 * r, 0.0, true));
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Abstand Punkt – Strecke.
|
||||
fn dist_seg(p: V, a: V, b: V) -> f64 {
|
||||
let d = sub(b, a);
|
||||
let l2 = dot(d, d);
|
||||
let t = if l2 > 0.0 { (dot(sub(p, a), d) / l2).clamp(0.0, 1.0) } else { 0.0 };
|
||||
len(sub(p, add(a, mul(d, t))))
|
||||
}
|
||||
|
||||
/// Abstand zweier Strecken (0 bei Schnitt).
|
||||
fn dist_segs(a: V, b: V, c: V, d: V) -> f64 {
|
||||
let (r, s) = (sub(b, a), sub(d, c));
|
||||
let den = cross(r, s);
|
||||
if den.abs() > 1e-15 {
|
||||
let t = cross(sub(c, a), s) / den;
|
||||
let u = cross(sub(c, a), r) / den;
|
||||
if (0.0..=1.0).contains(&t) && (0.0..=1.0).contains(&u) {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
dist_seg(a, c, d).min(dist_seg(b, c, d)).min(dist_seg(c, a, b)).min(dist_seg(d, a, b))
|
||||
}
|
||||
|
||||
/// Abstand eines Punkts zum Umriss eines Stützen-Kandidaten.
|
||||
fn ring_dist(c: &ColIn, p: V) -> f64 {
|
||||
if c.round {
|
||||
return (len(sub(p, c.c)) - c.w / 2.0).abs();
|
||||
}
|
||||
let n = c.ring.len();
|
||||
(0..n).map(|i| dist_seg(p, c.ring[i], c.ring[(i + 1) % n])).fold(f64::INFINITY, f64::min)
|
||||
}
|
||||
|
||||
/// Stützen: Kandidaten mit Füllung oder auf einem Stützen-Layer, die frei stehen (keine fremde Linie näher als
|
||||
/// 1 cm am Umriss; Linien auf dem Umriss — Füllung, doppelte Kontur — und ganz innen zählen nicht). Doppelte
|
||||
/// (gleiche Mitte) einmal. Rückgabe: Stützen und je Linie/Bogen, ob sie zu einer Stütze gehört (fällt für die
|
||||
/// Wände weg).
|
||||
fn columns(inp: &Input) -> (Vec<RColumn>, Vec<bool>, Vec<bool>) {
|
||||
let mut seg_used = vec![false; inp.segs.len()];
|
||||
let mut arc_used = vec![false; inp.arcs.len()];
|
||||
let mut out: Vec<RColumn> = Vec::new();
|
||||
if inp.cols.len() > MAX_ARCS || inp.segs.len() > MAX_SEGS {
|
||||
return (out, seg_used, arc_used);
|
||||
}
|
||||
let on_ring = |c: &ColIn, p: V| ring_dist(c, p) <= 0.003;
|
||||
for c in &inp.cols {
|
||||
let size = |x: f64| (COL_MIN - 1e-9..=COL_MAX + 1e-9).contains(&x);
|
||||
if !size(c.w) || !size(c.d) || c.ring.len() < 3 {
|
||||
continue;
|
||||
}
|
||||
if !(c.filled || inp.layers.get(c.layer).is_some_and(|l| column_layer(l))) || out.iter().any(|o| len(sub(o.c, c.c)) <= 0.01) {
|
||||
continue;
|
||||
}
|
||||
let reach = c.w.max(c.d) * 0.75 + 0.02;
|
||||
let mut mine = Vec::new();
|
||||
let mut free = true;
|
||||
for (i, s) in inp.segs.iter().enumerate() {
|
||||
if on_ring(c, s.a) && on_ring(c, s.b) && on_ring(c, mul(add(s.a, s.b), 0.5)) {
|
||||
mine.push(i);
|
||||
continue;
|
||||
}
|
||||
// Schnell weg, was weit entfernt ist.
|
||||
if dist_seg(c.c, s.a, s.b) > reach {
|
||||
continue;
|
||||
}
|
||||
let n = c.ring.len();
|
||||
let d = if c.round {
|
||||
(dist_seg(c.c, s.a, s.b) - c.w / 2.0).abs().min(ring_dist(c, s.a)).min(ring_dist(c, s.b))
|
||||
} else {
|
||||
(0..n).map(|k| dist_segs(s.a, s.b, c.ring[k], c.ring[(k + 1) % n])).fold(f64::INFINITY, f64::min)
|
||||
};
|
||||
// Linie ganz innen (Kreuz, Schraffur-Strich) stört nicht; anliegend oder kreuzend schon.
|
||||
let inside = point_in(&c.ring, s.a) && point_in(&c.ring, s.b) && ring_dist(c, s.a) > 0.003 && ring_dist(c, s.b) > 0.003;
|
||||
if d < 0.01 && !inside {
|
||||
free = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if !free {
|
||||
continue;
|
||||
}
|
||||
for i in mine {
|
||||
seg_used[i] = true;
|
||||
}
|
||||
for (k, a) in inp.arcs.iter().enumerate() {
|
||||
if c.round && len(sub(a.c, c.c)) <= 0.005 && (a.r - c.w / 2.0).abs() <= 0.005 {
|
||||
arc_used[k] = true;
|
||||
}
|
||||
}
|
||||
let r6 = |x: f64| (x * 1e6).round() / 1e6;
|
||||
out.push(RColumn { c: (r6(c.c.0), r6(c.c.1)), w: r6(c.w), d: r6(c.d), rot: c.rot, round: c.round });
|
||||
}
|
||||
(out, seg_used, arc_used)
|
||||
}
|
||||
|
||||
// ── 1. Linien bündeln ────────────────────────────────────────────────────────
|
||||
|
||||
/// Linie im Rahmen ihres Richtungs-Bündels.
|
||||
@@ -788,13 +989,28 @@ fn door_arcs_at(cx: &Ctx2, b: &Band, g0: f64, g1: f64) -> Vec<(usize, bool, bool
|
||||
}
|
||||
let at_start = (sc - g0).abs() <= 0.15;
|
||||
let at_end = (sc - g1).abs() <= 0.15;
|
||||
if !(at_start || at_end) {
|
||||
continue;
|
||||
}
|
||||
let full = (a.r - w).abs() <= 0.12 * w + 0.05;
|
||||
let half = (a.r - w / 2.0).abs() <= 0.06 * w + 0.05;
|
||||
if full || half {
|
||||
if (at_start || at_end) && (full || half) {
|
||||
out.push((k, at_start && (!at_end || (sc - g0).abs() <= (sc - g1).abs()), full));
|
||||
continue;
|
||||
}
|
||||
// Zarge/Futter: Lücke (Rohbau) breiter als der Bogen. Scharnier bis 30 cm in der Lücke, das Blatt endet
|
||||
// höchstens 30 cm vor dem Gegenpfosten (zweiflüglig: vor der Mitte) und nicht über ihn hinaus.
|
||||
let (o0, o1) = (sc - g0, g1 - sc);
|
||||
let mid = (g0 + g1) / 2.0;
|
||||
for (from_start, off, rest_full, rest_half) in [(true, o0, g1 - (sc + a.r), mid - (sc + a.r)), (false, o1, (sc - a.r) - g0, (sc - a.r) - mid)] {
|
||||
if !(-0.05..=0.3).contains(&off) {
|
||||
continue;
|
||||
}
|
||||
if a.r >= 0.5 * w && (-0.05..=0.3).contains(&rest_full) {
|
||||
out.push((k, from_start, true));
|
||||
break;
|
||||
}
|
||||
if a.r >= 0.25 * w && a.r < 0.5 * w && (-0.05..=0.15).contains(&rest_half) {
|
||||
out.push((k, from_start, false));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
@@ -821,8 +1037,93 @@ fn window_lines_at(cx: &Ctx2, b: &Band, g0: f64, g1: f64) -> usize {
|
||||
.count()
|
||||
}
|
||||
|
||||
/// Schiebetür-Hinweise in der Lücke `[g0, g1]`: (Pfeil, versetzte Flügel).
|
||||
///
|
||||
/// Pfeil: Linie parallel zur Wand (im Band oder bis 30 cm davor, 20–110 % der Lückenbreite, zu ≥ 80 % über der
|
||||
/// Lücke) mit einer Spitze — je ein kurzer Strich (5–40 cm, höchstens halb so lang, beide ähnlich lang) links und
|
||||
/// rechts ab einem Ende, 10–60° zur Linie (Dämmungs-Zickzack an der Laibung ist keine Spitze).
|
||||
/// Versetzte Flügel: zwei Gruppen paralleler Linien im Band auf verschiedener Lage quer (≥ 1 cm), die eine ab
|
||||
/// dem ersten, die andere bis zum zweiten Pfosten (± 10 cm), je 30–80 % der Lücke, zusammen ohne Lücke.
|
||||
fn slide_at(cx: &Ctx2, b: &Band, g0: f64, g1: f64) -> (bool, bool) {
|
||||
let w = g1 - g0;
|
||||
let sin_tol = PAR_TOL.sin();
|
||||
let (cos10, cos60) = (cos(10f64.to_radians()), cos(60f64.to_radians()));
|
||||
let par = |p: V, q: V| {
|
||||
let d = sub(q, p);
|
||||
let l = len(d);
|
||||
l > 1e-6 && cross(mul(d, 1.0 / l), b.u).abs() <= sin_tol
|
||||
};
|
||||
// Spitze am Ende `e`: je ein Strich links und rechts der Linie, ähnlich lang (± 30 %).
|
||||
let head = |e: V, back: V, shaft: f64| {
|
||||
let mut sides: [Vec<f64>; 2] = [Vec::new(), Vec::new()];
|
||||
for &(x, y) in &cx.all {
|
||||
let (from, to) = if len(sub(x, e)) <= 0.005 {
|
||||
(x, y)
|
||||
} else if len(sub(y, e)) <= 0.005 {
|
||||
(y, x)
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
let d = sub(to, from);
|
||||
let hl = len(d);
|
||||
if !(0.05..=0.4).contains(&hl) || hl > 0.5 * shaft {
|
||||
continue;
|
||||
}
|
||||
let c = dot(d, back) / hl;
|
||||
if c >= cos60 && c <= cos10 {
|
||||
sides[usize::from(cross(back, d) > 0.0)].push(hl);
|
||||
}
|
||||
}
|
||||
sides[0].iter().any(|a| sides[1].iter().any(|b| (a - b).abs() <= 0.3 * a.max(*b)))
|
||||
};
|
||||
let mut arrow = false;
|
||||
let mut groups: Vec<(f64, Vec<(f64, f64)>)> = Vec::new();
|
||||
for &(p, q) in &cx.all {
|
||||
if !par(p, q) {
|
||||
continue;
|
||||
}
|
||||
let ((s0, n0), (s1, n1)) = (b.st(p), b.st(q));
|
||||
let n = (n0 + n1) / 2.0;
|
||||
let l = (s1 - s0).abs();
|
||||
let ov = s0.max(s1).min(g1) - s0.min(s1).max(g0);
|
||||
if !arrow && n.abs() <= b.t / 2.0 + 0.3 && l >= 0.2 * w && l <= 1.1 * w && ov >= 0.8 * l {
|
||||
let dir = mul(sub(q, p), 1.0 / len(sub(q, p)));
|
||||
arrow = head(q, mul(dir, -1.0), l) || head(p, dir, l);
|
||||
}
|
||||
if n.abs() < b.t / 2.0 - 0.005 && ov >= 0.1 * w && l <= w + 0.4 {
|
||||
let iv = (s0.min(s1).max(g0), s0.max(s1).min(g1));
|
||||
match groups.iter_mut().find(|g| (g.0 - n).abs() <= 0.003) {
|
||||
Some(g) => g.1.push(iv),
|
||||
None => groups.push((n, vec![iv])),
|
||||
}
|
||||
}
|
||||
}
|
||||
let leaves: Vec<(f64, f64, f64)> = groups
|
||||
.into_iter()
|
||||
.filter_map(|(n, iv)| {
|
||||
let u = union(iv);
|
||||
(u.len() == 1 && (0.3..=0.8).contains(&((u[0].1 - u[0].0) / w))).then_some((n, u[0].0, u[0].1))
|
||||
})
|
||||
.collect();
|
||||
let staggered = leaves.iter().any(|a| {
|
||||
(a.1 - g0).abs() <= 0.1 && leaves.iter().any(|c| (c.2 - g1).abs() <= 0.1 && (a.0 - c.0).abs() >= 0.01 && a.2 >= c.1 - 0.05)
|
||||
});
|
||||
(arrow, staggered)
|
||||
}
|
||||
|
||||
/// Schiebetür in der Lücke? `Some(lift)`: mit Pfeil (Hebeschiebetür, wenn die Flügel versetzt sind oder die
|
||||
/// Lücke ≥ 1.4 m breit ist), ohne Pfeil nur mit versetzten Flügeln ab 1.4 m (Hebeschiebetür).
|
||||
fn slide_kind(cx: &Ctx2, b: &Band, g0: f64, g1: f64) -> Option<bool> {
|
||||
let wide = g1 - g0 >= SLIDE_WIDE - 1e-9;
|
||||
match slide_at(cx, b, g0, g1) {
|
||||
(true, staggered) => Some(staggered || wide),
|
||||
(false, true) if wide => Some(true),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn evidence(cx: &Ctx2, b: &Band, g0: f64, g1: f64) -> bool {
|
||||
!door_arcs_at(cx, b, g0, g1).is_empty() || window_lines_at(cx, b, g0, g1) > 0
|
||||
!door_arcs_at(cx, b, g0, g1).is_empty() || window_lines_at(cx, b, g0, g1) > 0 || slide_at(cx, b, g0, g1).0
|
||||
}
|
||||
|
||||
// ── 3. Läufe ─────────────────────────────────────────────────────────────────
|
||||
@@ -1104,7 +1405,7 @@ fn join_arcs(ws: &mut [W], arcs: &mut [ArcW]) {
|
||||
/// der Achse): konzentrische Bögen im Band → Fenster, sonst Wanddurchbruch. Rückgabe: Wände und Öffnungen
|
||||
/// (Index der Wand, Lage, Breite, Art).
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn merge_arc_walls(inp: &Input, arcs: Vec<ArcW>, used: &[bool]) -> (Vec<ArcW>, Vec<(usize, f64, f64, RKind)>) {
|
||||
fn merge_arc_walls(inp: &Input, arcs: Vec<ArcW>, used: &[bool], door_arcs: &[usize], taken: &mut [bool]) -> (Vec<ArcW>, Vec<(usize, f64, f64, RKind)>) {
|
||||
let mut groups: Vec<Vec<ArcW>> = Vec::new();
|
||||
for a in arcs {
|
||||
match groups.iter_mut().find(|g| len(sub(g[0].c, a.c)) <= 0.01 && (g[0].r - a.r).abs() <= 0.005 && (g[0].t - a.t).abs() <= 0.006) {
|
||||
@@ -1125,7 +1426,7 @@ fn merge_arc_walls(inp: &Input, arcs: Vec<ArcW>, used: &[bool]) -> (Vec<ArcW>, V
|
||||
})
|
||||
};
|
||||
let mut walls = Vec::new();
|
||||
let mut openings = Vec::new();
|
||||
let mut raw: Vec<(usize, f64, f64)> = Vec::new();
|
||||
for mut g in groups {
|
||||
g.sort_by(|a, b| a.a0.total_cmp(&b.a0));
|
||||
// Beim grössten Zwischenraum beginnen (Kreis).
|
||||
@@ -1135,13 +1436,9 @@ fn merge_arc_walls(inp: &Input, arcs: Vec<ArcW>, used: &[bool]) -> (Vec<ArcW>, V
|
||||
g.rotate_left(start);
|
||||
let mut cur = g[0].clone();
|
||||
let mut gaps: Vec<(f64, f64)> = Vec::new();
|
||||
let flush = |cur: &ArcW, gaps: &mut Vec<(f64, f64)>, walls: &mut Vec<ArcW>, openings: &mut Vec<(usize, f64, f64, RKind)>| {
|
||||
let flush = |cur: &ArcW, gaps: &mut Vec<(f64, f64)>, walls: &mut Vec<ArcW>, raw: &mut Vec<(usize, f64, f64)>| {
|
||||
let k = walls.len();
|
||||
for (g0, g1) in gaps.drain(..) {
|
||||
let kind = if window_in(cur, g0, g1) { RKind::Window } else { RKind::Void };
|
||||
let r6 = |x: f64| (x * 1e6).round() / 1e6;
|
||||
openings.push((k, r6((g0 - cur.a0) * cur.r), r6((g1 - g0) * cur.r), kind));
|
||||
}
|
||||
raw.extend(gaps.drain(..).map(|(g0, g1)| (k, g0, g1)));
|
||||
walls.push(cur.clone());
|
||||
};
|
||||
for a in g.into_iter().skip(1) {
|
||||
@@ -1158,11 +1455,40 @@ fn merge_arc_walls(inp: &Input, arcs: Vec<ArcW>, used: &[bool]) -> (Vec<ArcW>, V
|
||||
cur.filled |= a.filled;
|
||||
cur.material = cur.material.or(a.material);
|
||||
} else {
|
||||
flush(&cur, &mut gaps, &mut walls, &mut openings);
|
||||
flush(&cur, &mut gaps, &mut walls, &mut raw);
|
||||
cur = a;
|
||||
}
|
||||
}
|
||||
flush(&cur, &mut gaps, &mut walls, &mut openings);
|
||||
flush(&cur, &mut gaps, &mut walls, &mut raw);
|
||||
}
|
||||
// Lücken: Türbogen am Pfosten (Zentrum im Band ± 15 cm an einem Pfosten, Radius = Sehne) → Tür, sonst
|
||||
// Fensterbogen → Fenster, sonst Durchbruch. Wand gegen den Uhrzeigersinn: links = innen (zum Mittelpunkt).
|
||||
let mut openings = Vec::new();
|
||||
for (k, g0, g1) in raw {
|
||||
let w = &walls[k];
|
||||
let (p0, p1) = (w.at(g0), w.at(g1));
|
||||
let chord = len(sub(p1, p0));
|
||||
let door = door_arcs.iter().copied().find_map(|i| {
|
||||
let a = &inp.arcs[i];
|
||||
if taken[i] || (len(sub(a.c, w.c)) - w.r).abs() > w.t / 2.0 + 0.15 || (a.r - chord).abs() > 0.12 * chord + 0.05 {
|
||||
return None;
|
||||
}
|
||||
let (d0, d1) = (len(sub(a.c, p0)), len(sub(a.c, p1)));
|
||||
if d0.min(d1) > 0.15 {
|
||||
return None;
|
||||
}
|
||||
Some((i, d1 < d0, len(sub(arc_mid(a), w.c)) > w.r))
|
||||
});
|
||||
let kind = match door {
|
||||
Some((i, hinge_end, swing_right)) => {
|
||||
taken[i] = true;
|
||||
RKind::Door { hinge_end, swing_right, leaves: 1 }
|
||||
}
|
||||
None if window_in(w, g0, g1) => RKind::Window,
|
||||
None => RKind::Void,
|
||||
};
|
||||
let r6 = |x: f64| (x * 1e6).round() / 1e6;
|
||||
openings.push((k, r6((g0 - w.a0) * w.r), r6((g1 - g0) * w.r), kind));
|
||||
}
|
||||
(walls, openings)
|
||||
}
|
||||
@@ -1339,6 +1665,19 @@ pub fn analyze(inp: &Input) -> Recognition {
|
||||
rec.flag("tooMany", inp.segs.first().map_or((0.0, 0.0), |s| s.a));
|
||||
return rec;
|
||||
}
|
||||
// Stützen zuerst: ihre Umrisse sind keine Wandlinien (ein Quadrat 30 × 30 wäre sonst ein Wandstück).
|
||||
let (cols, seg_col, arc_col) = columns(inp);
|
||||
rec.columns = cols;
|
||||
let rest;
|
||||
let inp = if rec.columns.is_empty() {
|
||||
inp
|
||||
} else {
|
||||
let mut r = inp.clone();
|
||||
r.segs = inp.segs.iter().zip(&seg_col).filter(|(_, u)| !**u).map(|(s, _)| s.clone()).collect();
|
||||
r.arcs = inp.arcs.iter().zip(&arc_col).filter(|(_, u)| !**u).map(|(a, _)| a.clone()).collect();
|
||||
rest = r;
|
||||
&rest
|
||||
};
|
||||
let wallish: Vec<bool> = inp.layers.iter().map(|l| wallish_layer(l)).collect();
|
||||
let n_wallish = inp.segs.iter().filter(|s| wallish[s.layer]).count() + inp.arcs.iter().filter(|a| wallish[a.layer]).count();
|
||||
rec.layer_filter = n_wallish >= 4;
|
||||
@@ -1454,6 +1793,8 @@ pub fn analyze(inp: &Input) -> Recognition {
|
||||
rec.flag("doorHalf", mid);
|
||||
}
|
||||
RKind::Door { hinge_end: !at_start, swing_right: nm < 0.0, leaves }
|
||||
} else if let Some(lift) = slide_kind(&cx, &b, g0, g1) {
|
||||
RKind::Slide { lift }
|
||||
} else if window_lines_at(&cx, &b, g0, g1) > 0 {
|
||||
RKind::Window
|
||||
} else if wdt > GAP_FREE + 1e-6 {
|
||||
@@ -1466,15 +1807,14 @@ pub fn analyze(inp: &Input) -> Recognition {
|
||||
rec.openings.push(ROpening { wall: wi, pos: r6(g0), width: r6(wdt), kind });
|
||||
}
|
||||
}
|
||||
rec.walls = ws.iter().map(|w| RWall { a: w.a, b: w.b, bulge: None, t: w.t, material: w.material, filled: w.filled }).collect();
|
||||
arc_ws.retain(|a| a.sweep > 1e-6 && a.sweep * a.r >= 0.1);
|
||||
let (arc_ws, arc_openings) = merge_arc_walls(inp, arc_ws, &arc_used, &cx.door_arcs, &mut arc_taken);
|
||||
for &k in &cx.door_arcs {
|
||||
if !arc_taken[k] {
|
||||
rec.flag("doorArc", inp.arcs[k].c);
|
||||
}
|
||||
}
|
||||
|
||||
rec.walls = ws.iter().map(|w| RWall { a: w.a, b: w.b, bulge: None, t: w.t, material: w.material, filled: w.filled }).collect();
|
||||
arc_ws.retain(|a| a.sweep > 1e-6 && a.sweep * a.r >= 0.1);
|
||||
let (arc_ws, arc_openings) = merge_arc_walls(inp, arc_ws, &arc_used);
|
||||
let base = rec.walls.len();
|
||||
rec.walls.extend(arc_ws.iter().map(ArcW::wall));
|
||||
rec.openings.extend(arc_openings.into_iter().map(|(k, pos, width, kind)| ROpening { wall: base + k, pos, width, kind }));
|
||||
@@ -1554,6 +1894,27 @@ fn door_type(p: &Project, leaves: u8) -> Option<String> {
|
||||
.map(|d| d.id.clone())
|
||||
}
|
||||
|
||||
/// Schiebetür-Typ (`schiebe`, Hebeschiebetür `hebeschiebe`): vorhanden oder neu (Name aus der Anfrage).
|
||||
fn slide_type(p: &Project, v: &Value, lift: bool, made: &mut Vec<(bool, String, Value)>, ids: &mut IdGen) -> String {
|
||||
use crate::model::DoorTypeKind;
|
||||
let want = if lift { DoorTypeKind::Hebeschiebe } else { DoorTypeKind::Schiebe };
|
||||
if let Some(d) = p.door_types.iter().flatten().find(|d| d.kind == want) {
|
||||
return d.id.clone();
|
||||
}
|
||||
if let Some(m) = made.iter().find(|m| m.0 == lift) {
|
||||
return m.1.clone();
|
||||
}
|
||||
let id = ids.next("DT");
|
||||
let (key, def) = if lift { ("liftSlideTypeName", "Hebeschiebetür (erkannt)") } else { ("slideTypeName", "Schiebetür (erkannt)") };
|
||||
let name = v.get(key).and_then(Value::as_str).filter(|s| !s.is_empty()).unwrap_or(def);
|
||||
let t = json!({
|
||||
"id": id, "name": name, "kind": if lift { "hebeschiebe" } else { "schiebe" },
|
||||
"leafCount": if lift { 2 } else { 1 }, "leafStyle": if lift { "glas" } else { "glatt" }, "frameThickness": 0.05,
|
||||
});
|
||||
made.push((lift, id.clone(), t));
|
||||
id
|
||||
}
|
||||
|
||||
fn cat(p: &Project, code: &str, ctx: &Ctx) -> String {
|
||||
if has_category(p, code) { code.to_string() } else { ctx.cat.to_string() }
|
||||
}
|
||||
@@ -1585,6 +1946,7 @@ pub fn ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
|
||||
let sill = 0.9f64.min((height - 0.6).max(0.0));
|
||||
let win_h = 1.2f64.min(height - sill - 0.1).max(0.3);
|
||||
let window_type = p.window_types.as_ref().and_then(|l| l.first()).map(|w| w.id.clone());
|
||||
let mut made_doors = Vec::new();
|
||||
let mut openings = Vec::new();
|
||||
for o in &rec.openings {
|
||||
let mut f = vec![("id", s(&ids.next("O"))), ("type", s("opening")), ("hostWallId", s(&wall_ids[o.wall])), ("categoryCode", s(&ocat))];
|
||||
@@ -1598,6 +1960,11 @@ pub fn ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
|
||||
f.push(("swing", s(if swing_right { "right" } else { "left" })));
|
||||
f.push(("hinge", s(if hinge_end { "end" } else { "start" })));
|
||||
}
|
||||
RKind::Slide { lift } => {
|
||||
f.push(("kind", s("door")));
|
||||
f.push(("typeId", s(&slide_type(p, v, lift, &mut made_doors, ids))));
|
||||
f.extend([("position", js_num(o.pos)), ("width", js_num(o.width)), ("height", js_num(door_h)), ("sillHeight", js_num(0.0))]);
|
||||
}
|
||||
RKind::Window => {
|
||||
f.push(("kind", s("window")));
|
||||
if let Some(t) = &window_type {
|
||||
@@ -1632,10 +1999,36 @@ pub fn ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
|
||||
("stampDoc", doc),
|
||||
]));
|
||||
}
|
||||
// Stützen: Kategorie „25“ (Stützen), sonst „50“ (Tragwerk), sonst die aktive; Höhe = Geschosshöhe.
|
||||
let ccat = if has_category(p, "25") { "25".to_string() } else { cat(p, "50", ctx) };
|
||||
let columns: Vec<Value> = rec
|
||||
.columns
|
||||
.iter()
|
||||
.map(|c| {
|
||||
let profile = if c.round {
|
||||
json!({"kind": "round", "radius": js_num(c.w / 2.0)})
|
||||
} else {
|
||||
json!({"kind": "rect", "width": js_num(c.w), "depth": js_num(c.d)})
|
||||
};
|
||||
obj(vec![
|
||||
("id", s(&ids.next("C"))),
|
||||
("type", s("column")),
|
||||
("floorId", s(ctx.level)),
|
||||
("categoryCode", s(&ccat)),
|
||||
("position", pv(c.c)),
|
||||
("profile", profile),
|
||||
("rotation", js_num(c.rot)),
|
||||
("height", js_num(height)),
|
||||
])
|
||||
})
|
||||
.collect();
|
||||
let mut out = Vec::new();
|
||||
if !made.is_empty() {
|
||||
out.extend(add_op("wallTypes", made.into_iter().map(|m| m.3).collect()));
|
||||
}
|
||||
if !made_doors.is_empty() {
|
||||
out.extend(add_op("doorTypes", made_doors.into_iter().map(|m| m.2).collect()));
|
||||
}
|
||||
out.extend(add_op("walls", walls));
|
||||
if !openings.is_empty() {
|
||||
out.extend(add_op("openings", openings));
|
||||
@@ -1643,18 +2036,22 @@ pub fn ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
|
||||
if !rooms.is_empty() {
|
||||
out.extend(add_op("rooms", rooms));
|
||||
}
|
||||
if !columns.is_empty() {
|
||||
out.extend(add_op("columns", columns));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Zähler `[Wände, Türen, Fenster, Durchbrüche, Räume, unklar]`.
|
||||
pub fn counts(r: &Recognition) -> [usize; 6] {
|
||||
/// Zähler `[Wände, Türen (mit Schiebetüren), Fenster, Durchbrüche, Räume, unklar, Stützen]`.
|
||||
pub fn counts(r: &Recognition) -> [usize; 7] {
|
||||
[
|
||||
r.walls.len(),
|
||||
r.count(|k| matches!(k, RKind::Door { .. })),
|
||||
r.count(|k| matches!(k, RKind::Door { .. } | RKind::Slide { .. })),
|
||||
r.count(|k| matches!(k, RKind::Window)),
|
||||
r.count(|k| matches!(k, RKind::Void)),
|
||||
r.rooms.len(),
|
||||
r.unclear.len(),
|
||||
r.columns.len(),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1703,6 +2100,16 @@ pub fn preview(p: &Project, v: &Value, ctx: &Ctx, out: &mut Shapes, info: &mut V
|
||||
leaf(s0, 1.0, o.width, out);
|
||||
}
|
||||
}
|
||||
RKind::Slide { .. } => {
|
||||
// Zwei versetzte Flügel und ein Pfeil.
|
||||
let m = (s0 + s1) / 2.0;
|
||||
out.line(at(s0, h / 3.0), at(m + 0.03, h / 3.0));
|
||||
out.line(at(m - 0.03, -h / 3.0), at(s1, -h / 3.0));
|
||||
let k = (s1 - s0) / 4.0;
|
||||
out.line(at(m + k, 0.0), at(m - k, 0.0));
|
||||
out.line(at(m - k, 0.0), at(m - k + 0.1, h / 4.0));
|
||||
out.line(at(m - k, 0.0), at(m - k + 0.1, -h / 4.0));
|
||||
}
|
||||
RKind::Window => {
|
||||
out.line(at(s0, h / 3.0), at(s1, h / 3.0));
|
||||
out.line(at(s0, -h / 3.0), at(s1, -h / 3.0));
|
||||
@@ -1716,6 +2123,18 @@ pub fn preview(p: &Project, v: &Value, ctx: &Ctx, out: &mut Shapes, info: &mut V
|
||||
for room in &r.rooms {
|
||||
out.poly(&room.ring);
|
||||
}
|
||||
for c in &r.columns {
|
||||
if c.round {
|
||||
let ring: Vec<V> = (0..24).map(|i| add(c.c, (c.w / 2.0 * cos(PI * i as f64 / 12.0), c.w / 2.0 * sin(PI * i as f64 / 12.0)))).collect();
|
||||
out.poly(&ring);
|
||||
} else {
|
||||
let (u, n) = ((cos(c.rot), sin(c.rot)), (-sin(c.rot), cos(c.rot)));
|
||||
let at = |a: f64, b: f64| add(add(c.c, mul(u, a * c.w / 2.0)), mul(n, b * c.d / 2.0));
|
||||
out.poly(&[at(-1.0, -1.0), at(1.0, -1.0), at(1.0, 1.0), at(-1.0, 1.0)]);
|
||||
out.line(at(-1.0, -1.0), at(1.0, 1.0));
|
||||
out.line(at(-1.0, 1.0), at(1.0, -1.0));
|
||||
}
|
||||
}
|
||||
for u in &r.unclear {
|
||||
let k = 0.15;
|
||||
out.line((u.at.0 - k, u.at.1 - k), (u.at.0 + k, u.at.1 + k));
|
||||
@@ -1737,7 +2156,8 @@ pub fn report(p: &Project, v: &Value) -> Value {
|
||||
thick.sort_by(f64::total_cmp);
|
||||
thick.dedup();
|
||||
json!({
|
||||
"walls": c[0], "doors": c[1], "windows": c[2], "voids": c[3], "rooms": c[4],
|
||||
"walls": c[0], "doors": c[1], "windows": c[2], "voids": c[3], "rooms": c[4], "columns": c[6],
|
||||
"slidingDoors": r.count(|k| matches!(k, RKind::Slide { .. })),
|
||||
"arcWalls": arcs, "filledWalls": filled, "unnamedRooms": unnamed,
|
||||
"thicknesses": thick.iter().map(|t| js_num(*t)).collect::<Vec<_>>(),
|
||||
"layerFilter": r.layer_filter,
|
||||
|
||||
@@ -412,7 +412,7 @@ fn auswahl_vorschau_und_bericht() {
|
||||
assert_eq!(n, 1);
|
||||
let pv = crate::cmd_create::preview(&root, &p, &req(json!({})), &[]);
|
||||
assert!(pv.ok);
|
||||
assert_eq!(pv.info, vec![5.0, 1.0, 0.0, 0.0, 2.0, 1.0]);
|
||||
assert_eq!(pv.info, vec![5.0, 1.0, 0.0, 0.0, 2.0, 1.0, 0.0]);
|
||||
let rep = report(&p, &json!({"q": "recognize", "level": "eg", "src": "imp"}));
|
||||
assert_eq!(rep["walls"], 5);
|
||||
assert_eq!(rep["doors"], 1);
|
||||
@@ -484,3 +484,230 @@ fn tessellierter_erker() {
|
||||
assert!(arcs.is_empty());
|
||||
assert_eq!(segs.len(), 8);
|
||||
}
|
||||
|
||||
// ── Schiebetüren, Zarge/Futter, Türen in Bogenwänden, Stützen (7.11.) ───────
|
||||
|
||||
impl B {
|
||||
/// Pfeil von `from` nach `to` mit zwei Spitzen-Strichen (24°, 13 cm) am Ziel.
|
||||
fn arrow(&mut self, layer: &str, from: V, to: V) -> &mut B {
|
||||
let d = sub(from, to);
|
||||
let u = mul(d, 1.0 / len(d));
|
||||
let (c, s) = (24f64.to_radians().cos(), 24f64.to_radians().sin());
|
||||
let h1 = (u.0 * c - u.1 * s, u.0 * s + u.1 * c);
|
||||
let h2 = (u.0 * c + u.1 * s, -u.0 * s + u.1 * c);
|
||||
self.line(layer, from, to).line(layer, to, add(to, mul(h1, 0.13))).line(layer, to, add(to, mul(h2, 0.13)))
|
||||
}
|
||||
/// Stütze als Kandidat (wie `collect` sie aus einem geschlossenen Umriss liest) samt Umriss.
|
||||
fn column(&mut self, layer: &str, c: V, w: f64, d: f64, round: bool, filled: bool) -> &mut B {
|
||||
let l = self.inp.layer(layer);
|
||||
let ring: Vec<V> = if round {
|
||||
(0..32)
|
||||
.map(|i| {
|
||||
let a = 2.0 * PI * i as f64 / 32.0;
|
||||
(c.0 + w / 2.0 * a.cos(), c.1 + w / 2.0 * a.sin())
|
||||
})
|
||||
.collect()
|
||||
} else {
|
||||
vec![(c.0 - w / 2.0, c.1 - d / 2.0), (c.0 + w / 2.0, c.1 - d / 2.0), (c.0 + w / 2.0, c.1 + d / 2.0), (c.0 - w / 2.0, c.1 + d / 2.0)]
|
||||
};
|
||||
if round {
|
||||
self.inp.arcs.push(ArcIn { c, r: w / 2.0, a0: 0.0, sweep: 2.0 * PI, layer: l });
|
||||
} else {
|
||||
self.ring(layer, &ring);
|
||||
}
|
||||
self.inp.cols.push(ColIn { c, w, d, rot: 0.0, round, ring, filled, layer: l });
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Weltkoordinaten (x) der Pfosten einer Öffnung in einer Wand entlang x.
|
||||
fn xs_of(r: &Recognition, o: &ROpening) -> (f64, f64) {
|
||||
let w = &r.walls[o.wall];
|
||||
let u = mul(sub(w.b, w.a), 1.0 / len(sub(w.b, w.a)));
|
||||
let p0 = add(w.a, mul(u, o.pos));
|
||||
let p1 = add(w.a, mul(u, o.pos + o.width));
|
||||
(p0.0.min(p1.0), p0.0.max(p1.0))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schiebetuer_vor_der_wand_mit_pfeil() {
|
||||
// Lücke 2.0–2.9 (90 cm), Blatt vor der Wand (+y), Rahmen im Band, Pfeil in Schieberichtung.
|
||||
let mut b = wall_with_gaps(&[(2.0, 2.9)]);
|
||||
b.rect("Türen", 1.95, 0.16, 2.95, 0.20).rect("Türen", 2.04, -0.03, 2.86, 0.03);
|
||||
b.arrow("Türen", (2.675, 0.27), (2.225, 0.27));
|
||||
let r = analyze(&b.inp);
|
||||
assert_eq!(r.openings.len(), 1, "{:?}", r.openings);
|
||||
assert_eq!(r.openings[0].kind, RKind::Slide { lift: false });
|
||||
let (x0, x1) = xs_of(&r, &r.openings[0]);
|
||||
assert!((x0 - 2.0).abs() < EPS && (x1 - 2.9).abs() < EPS);
|
||||
assert!(r.unclear.is_empty(), "{:?}", r.unclear);
|
||||
}
|
||||
|
||||
/// Hebeschiebetür 3 m (Lücke 1.0–4.0): zwei Flügel versetzt im Band, je mit Glaslinie, Rahmen.
|
||||
fn lift_slide(arrow: bool) -> B {
|
||||
let mut b = wall_with_gaps(&[(1.0, 4.0)]);
|
||||
b.rect("Fenster", 1.0, -0.007, 2.53, 0.041).line("Fenster", (1.0, 0.017), (2.53, 0.017));
|
||||
b.rect("Fenster", 2.47, 0.049, 4.0, 0.097).line("Fenster", (2.47, 0.073), (4.0, 0.073));
|
||||
b.rect("Fenster", 1.0, -0.015, 4.0, 0.085);
|
||||
if arrow {
|
||||
b.arrow("Fenster", (3.55, 0.137), (2.2, 0.137));
|
||||
}
|
||||
b
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hebeschiebetuer_mit_versetzten_fluegeln() {
|
||||
for arrow in [true, false] {
|
||||
let r = analyze(&lift_slide(arrow).inp);
|
||||
assert_eq!(r.walls.len(), 1, "Pfeil {arrow}: {:#?}", r.walls);
|
||||
assert_eq!(r.openings.len(), 1, "Pfeil {arrow}: {:?}", r.openings);
|
||||
assert_eq!(r.openings[0].kind, RKind::Slide { lift: true }, "Pfeil {arrow}");
|
||||
let (x0, x1) = xs_of(&r, &r.openings[0]);
|
||||
assert!((x0 - 1.0).abs() < EPS && (x1 - 4.0).abs() < EPS);
|
||||
}
|
||||
// Schmal (1.2 m) und ohne Pfeil: zweiflügliges Fenster mit versetzten Flügeln bleibt Fenster.
|
||||
let mut b = wall_with_gaps(&[(1.0, 2.2)]);
|
||||
b.rect("Fenster", 1.0, -0.007, 1.63, 0.041).rect("Fenster", 1.57, 0.049, 2.2, 0.097);
|
||||
let r = analyze(&b.inp);
|
||||
assert_eq!(r.openings.len(), 1);
|
||||
assert_eq!(r.openings[0].kind, RKind::Window);
|
||||
// Gewöhnliches Fenster (Rahmen + Glas über die ganze Breite, gleiche Lage) bleibt Fenster.
|
||||
let mut b = wall_with_gaps(&[(1.0, 2.8)]);
|
||||
b.rect("Fenster", 1.0, -0.04, 2.8, 0.04).line("Fenster", (1.0, 0.0), (2.8, 0.0));
|
||||
let r = analyze(&b.inp);
|
||||
assert_eq!(r.openings[0].kind, RKind::Window);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tuer_mit_zarge_breiter_als_bogen() {
|
||||
// Rohbaulücke 1.0–2.0 (1 m), Zarge 10 cm: Scharnier bei x = 1.1, Blatt 80 cm, Aufschlag nach −y.
|
||||
let mut b = wall_with_gaps(&[(1.0, 2.0)]);
|
||||
b.rect("Türen", 1.0, -0.15, 1.1, 0.15).rect("Türen", 1.9, -0.15, 2.0, 0.15);
|
||||
b.arc("Türen", (1.1, -0.12), 0.8, 270.0, 90.0).line("Türen", (1.1, -0.12), (1.1, -0.92));
|
||||
let r = analyze(&b.inp);
|
||||
assert_eq!(r.openings.len(), 1, "{:?} {:?}", r.openings, r.unclear);
|
||||
let o = &r.openings[0];
|
||||
let RKind::Door { hinge_end, swing_right, leaves: 1 } = o.kind else { panic!("{o:?}") };
|
||||
// Tür mit Lückenbreite, Anschlag am linken Pfosten.
|
||||
let (x0, x1) = xs_of(&r, o);
|
||||
assert!((x0 - 1.0).abs() < EPS && (x1 - 2.0).abs() < EPS, "{x0} {x1}");
|
||||
let w = &r.walls[0];
|
||||
let u = mul(sub(w.b, w.a), 1.0 / len(sub(w.b, w.a)));
|
||||
let hinge = add(w.a, mul(u, if hinge_end { o.pos + o.width } else { o.pos }));
|
||||
assert!((hinge.0 - 1.0).abs() < EPS, "{hinge:?}");
|
||||
let side = if swing_right { -1.0 } else { 1.0 };
|
||||
assert!(mul((-u.1, u.0), side).1 < 0.0);
|
||||
assert!(r.unclear.is_empty(), "{:?}", r.unclear);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tuer_in_bogenwand() {
|
||||
// Bogenwand r = 5 (30 cm), 0°–90° mit Lücke 30°–40° (≈ 0.87 m); Tür: Scharnier am Pfosten bei 30°,
|
||||
// Blatt schlägt nach innen (zum Mittelpunkt) auf.
|
||||
let (ri, ro) = (4.85, 5.15);
|
||||
let mut b = B::new();
|
||||
for (r0, a0, sw) in [(ri, 0.0, 30.0), (ro, 0.0, 30.0), (ri, 40.0, 50.0), (ro, 40.0, 50.0)] {
|
||||
b.arc("Wand", (0.0, 0.0), r0, a0, sw);
|
||||
}
|
||||
let a30 = 30f64.to_radians();
|
||||
let a40 = 40f64.to_radians();
|
||||
let hinge = (5.0 * a30.cos(), 5.0 * a30.sin());
|
||||
let other = (5.0 * a40.cos(), 5.0 * a40.sin());
|
||||
let w = len(sub(other, hinge));
|
||||
// Offenstellung: senkrecht zur Sehne nach innen.
|
||||
let ch = mul(sub(other, hinge), 1.0 / w);
|
||||
let inward = (-ch.1, ch.0);
|
||||
let open = add(hinge, mul(inward, w));
|
||||
let a_closed = atan2(ch.1, ch.0).to_degrees();
|
||||
b.arc("Tür", hinge, w, a_closed, 90.0).line("Tür", hinge, open);
|
||||
let r = analyze(&b.inp);
|
||||
assert_eq!(r.walls.len(), 1, "{:#?}", r.walls);
|
||||
assert_eq!(r.openings.len(), 1, "{:?} {:?}", r.openings, r.unclear);
|
||||
let o = &r.openings[0];
|
||||
let RKind::Door { hinge_end, swing_right, leaves: 1 } = o.kind else { panic!("{o:?}") };
|
||||
// Wand gegen den Uhrzeigersinn ab 0°: Scharnier am Lückenanfang, Aufschlag links (= innen).
|
||||
assert!(!hinge_end && !swing_right, "{o:?}");
|
||||
assert!((o.pos - 5.0 * a30).abs() < 1e-6 && (o.width - 5.0 * (a40 - a30)).abs() < 1e-6, "{o:?}");
|
||||
assert!(r.unclear.is_empty(), "{:?}", r.unclear);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stuetzen_aus_kleinen_gefuellten_umrissen() {
|
||||
let mut b = l_house();
|
||||
// Freistehend: Rechteck 30 × 30 gefüllt, Kreis Ø 25 gefüllt, Rechteck 40 × 20 auf Stützen-Layer (ohne Füllung).
|
||||
b.column("Beton", (3.0, 3.0), 0.3, 0.3, false, true);
|
||||
b.column("Beton", (9.0, 3.0), 0.25, 0.25, true, true);
|
||||
b.column("Stützen", (3.0, 8.0), 0.4, 0.2, false, false);
|
||||
// Nicht: ungefüllt auf fremdem Layer (Möbel), zu gross, an einer Wand anliegend.
|
||||
b.column("Möbel", (4.0, 4.0), 0.4, 0.4, false, false);
|
||||
b.column("Beton", (9.0, 4.5), 0.8, 0.8, false, true);
|
||||
b.column("Beton", (6.075 + 0.15, 2.0), 0.3, 0.3, false, true);
|
||||
let r = analyze(&b.inp);
|
||||
// Wände wie ohne Stützen.
|
||||
assert_eq!(r.walls.len(), 8, "{:#?}", r.walls);
|
||||
assert_eq!(r.columns.len(), 3, "{:#?}", r.columns);
|
||||
let at = |c: V| r.columns.iter().find(|x| near(x.c, c, 1e-9)).unwrap_or_else(|| panic!("{c:?}: {:?}", r.columns));
|
||||
let a = at((3.0, 3.0));
|
||||
assert!(!a.round && (a.w - 0.3).abs() < EPS && (a.d - 0.3).abs() < EPS);
|
||||
let k = at((9.0, 3.0));
|
||||
assert!(k.round && (k.w - 0.25).abs() < EPS);
|
||||
let s = at((3.0, 8.0));
|
||||
assert!((s.w - 0.4).abs() < EPS && (s.d - 0.2).abs() < EPS);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stuetzen_aus_dem_projekt_und_ops() {
|
||||
let mut d = small_house();
|
||||
d.push(json!({"id": "c1", "type": "drawing2d", "levelId": "imp", "categoryCode": "103", "fillColor": "#000000",
|
||||
"geom": {"shape": "rect", "min": {"x": 3.5, "y": 1.85}, "max": {"x": 3.8, "y": 2.15}}}));
|
||||
d.push(json!({"id": "c2", "type": "drawing2d", "levelId": "imp", "categoryCode": "103", "fillColor": "#000000",
|
||||
"geom": {"shape": "circle", "center": {"x": 1.2, "y": 3.0}, "r": 0.15}}));
|
||||
// Gedrehtes Quadrat 30 × 30 (45°) als Polylinie.
|
||||
let h = 0.15 * 2f64.sqrt();
|
||||
let mut c3 = dl("c3", "103", poly(&[(4.0, 3.0 - h), (4.0 + h, 3.0), (4.0, 3.0 + h), (4.0 - h, 3.0)]));
|
||||
c3["hatchId"] = json!("x");
|
||||
d.push(c3);
|
||||
let (p, root) = project(d);
|
||||
let ops = crate::cmd_create::ops(&root, &p, &req(json!({}))).unwrap();
|
||||
assert_eq!(added(&ops, "walls").len(), 5);
|
||||
let cols = added(&ops, "columns");
|
||||
assert_eq!(cols.len(), 3, "{cols:#?}");
|
||||
for c in &cols {
|
||||
let col: crate::model::Column = serde_json::from_value(c.clone()).unwrap();
|
||||
assert_eq!(col.floor_id, "eg");
|
||||
assert!((col.height - 2.8).abs() < 1e-9);
|
||||
}
|
||||
let round = cols.iter().find(|c| c["profile"]["kind"] == "round").unwrap();
|
||||
assert!((round["profile"]["radius"].as_f64().unwrap() - 0.15).abs() < 1e-9);
|
||||
assert!((round["position"]["x"].as_f64().unwrap() - 1.2).abs() < 1e-9);
|
||||
let rot = cols.iter().find(|c| (c["position"]["x"].as_f64().unwrap() - 4.0).abs() < 1e-9).unwrap();
|
||||
assert!((rot["profile"]["width"].as_f64().unwrap() - 0.3).abs() < 1e-9);
|
||||
let a = rot["rotation"].as_f64().unwrap().rem_euclid(PI / 2.0);
|
||||
assert!((a - PI / 4.0).abs() < 1e-9, "{a}");
|
||||
let rep = report(&p, &json!({"q": "recognize", "level": "eg", "src": "imp"}));
|
||||
assert_eq!(rep["columns"], 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schiebetuer_ops_mit_typ() {
|
||||
// Ohne Schiebetür-Typ im Projekt: neuer Türtyp „schiebe“ (Name aus der Anfrage).
|
||||
let mut d = small_house();
|
||||
d.retain(|x| x["id"] != "arc");
|
||||
let lines = [((1.0, 0.17), (1.9, 0.17)), ((1.9, 0.17), (1.9, 0.21)), ((1.9, 0.21), (1.0, 0.21)), ((1.0, 0.21), (1.0, 0.17)), ((1.675, 0.3), (1.225, 0.3)), ((1.225, 0.3), (1.34, 0.25)), ((1.225, 0.3), (1.34, 0.35))];
|
||||
for (i, (a, b)) in lines.iter().enumerate() {
|
||||
d.push(dl(&format!("s{i}"), "102", json!({"shape": "line", "a": {"x": a.0, "y": a.1}, "b": {"x": b.0, "y": b.1}})));
|
||||
}
|
||||
let (p, root) = project(d);
|
||||
let ops = crate::cmd_create::ops(&root, &p, &req(json!({"slideTypeName": "Schiebetür (erkannt)"}))).unwrap();
|
||||
let types = added(&ops, "doorTypes");
|
||||
assert_eq!(types.len(), 1, "{types:?}");
|
||||
let t: crate::model::DoorType = serde_json::from_value(types[0].clone()).unwrap();
|
||||
assert_eq!(t.kind, crate::model::DoorTypeKind::Schiebe);
|
||||
assert_eq!(t.name, "Schiebetür (erkannt)");
|
||||
let o = &added(&ops, "openings")[0];
|
||||
assert_eq!(o["kind"], "door");
|
||||
assert_eq!(o["typeId"], types[0]["id"]);
|
||||
let rep = report(&p, &json!({"q": "recognize", "level": "eg", "src": "imp"}));
|
||||
assert_eq!(rep["doors"], 1);
|
||||
assert_eq!(rep["slidingDoors"], 1);
|
||||
}
|
||||
@@ -81,7 +81,8 @@ fn shift_positions(pos: &mut [f64], dx: f64, dy: f64) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Verschiebt sämtliche Modell-Koordinaten (`translateProject`), auch die Innenhöfe der Dächer.
|
||||
/// Verschiebt sämtliche Modell-Koordinaten (`translateProject`), auch die Innenhöfe der Dächer, Bäume und
|
||||
/// das Baurecht (Parzelle, Baulinien).
|
||||
pub fn translate_project(p: &Project, dx: f64, dy: f64) -> Project {
|
||||
if dx == 0.0 && dy == 0.0 {
|
||||
return p.clone();
|
||||
@@ -114,6 +115,16 @@ pub fn translate_project(p: &Project, dx: f64, dy: f64) -> Project {
|
||||
for c in out.columns.iter_mut().flatten() {
|
||||
c.position = shift(c.position, dx, dy);
|
||||
}
|
||||
for t in out.trees.iter_mut().flatten() {
|
||||
t.position = shift(t.position, dx, dy);
|
||||
}
|
||||
if let Some(r) = &mut out.site_rules {
|
||||
shift_all(&mut r.parcel, dx, dy);
|
||||
for l in r.building_lines.iter_mut().flatten() {
|
||||
l.a = shift(l.a, dx, dy);
|
||||
l.b = shift(l.b, dx, dy);
|
||||
}
|
||||
}
|
||||
for s in out.extruded_solids.iter_mut().flatten() {
|
||||
shift_all(&mut s.points, dx, dy);
|
||||
if let Some(c) = &mut s.circle {
|
||||
@@ -191,6 +202,23 @@ mod tests {
|
||||
assert_eq!(r.holes.as_ref().unwrap()[0][2], Vec2 { x: 12.0, y: -3.0 });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn baurecht_baeume_und_baugrube_wandern_mit() {
|
||||
// Befund [154]: Parzelle/Baulinien blieben in Welt-Exporten lokal.
|
||||
let mut p: Project = serde_json::from_str(include_str!("../tests/fixtures/sample_project.json")).unwrap();
|
||||
p.site_rules = Some(SiteRules {
|
||||
parcel: vec![Vec2 { x: -1.0, y: -1.0 }, Vec2 { x: 5.0, y: -1.0 }, Vec2 { x: 5.0, y: 4.0 }],
|
||||
building_lines: Some(vec![SiteRulesBuildingLines { a: Vec2 { x: 0.0, y: 3.0 }, b: Vec2 { x: 4.0, y: 3.0 }, ..Default::default() }]),
|
||||
..Default::default()
|
||||
});
|
||||
p.trees = Some(vec![Tree { id: "t".into(), position: Vec2 { x: 1.0, y: 1.0 }, ..Default::default() }]);
|
||||
let t = translate_project(&p, 10.0, -5.0);
|
||||
let s = t.site_rules.as_ref().unwrap();
|
||||
assert_eq!(s.parcel[2], Vec2 { x: 15.0, y: -1.0 });
|
||||
assert_eq!(s.building_lines.as_ref().unwrap()[0].a, Vec2 { x: 10.0, y: -2.0 });
|
||||
assert_eq!(t.trees.as_ref().unwrap()[0].position, Vec2 { x: 11.0, y: -4.0 });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lv95_bern() {
|
||||
// Bezugspunkt Bern (alte Sternwarte): 46°57'08.66" N, 7°26'22.50" E.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Verschiebung des ganzen Projekts um einen festen Vektor ([K4] S3, vorher `translateProject` in
|
||||
//! `src/model/geoRebase.ts`; Befehl „Neuer Bezugspunkt", Welt-Koordinaten für DXF/IFC-Export): reine
|
||||
//! Translation aller Modell-Koordinaten (Wände, Decken, Dächer, Treppen, Räume, Stützen, Extrusionen,
|
||||
//! 2D-Zeichnungen, Kontext-Schicht, Schnitt-/Ansichtslinien, Geo-Anker). Richtungsvektoren und Winkel
|
||||
//! 2D-Zeichnungen, Kontext-Schicht inkl. Baugrube, Bäume, Schnitt-/Ansichtslinien, Baurecht, Geo-Anker). Richtungsvektoren und Winkel
|
||||
//! bleiben, Höhen (z) auch. Rechnung auf der rohen Projekt-Wurzel (`serde_json`).
|
||||
//!
|
||||
//! Wie in TS bestehen verschobene Punkte nur aus `x`/`y` (weitere Felder eines Punkts entfallen).
|
||||
@@ -104,7 +104,7 @@ fn shift_contour(c: &Value, dx: f64, dy: f64) -> Value {
|
||||
Value::Object(m)
|
||||
}
|
||||
|
||||
/// Kontext-Objekt: Konturen-Satz, Bild (min/max) oder Mesh (`positions` = flache `[x, y, z]`-Tripel, nur x/y).
|
||||
/// Kontext-Objekt: Konturen-Satz, Bild (min/max), Baugrube (Umriss) oder Mesh (`positions` = flache `[x, y, z]`-Tripel, nur x/y).
|
||||
fn shift_context(o: &Value, dx: f64, dy: f64) -> Value {
|
||||
let mut m = obj(o);
|
||||
match o.get("type").and_then(Value::as_str) {
|
||||
@@ -113,6 +113,8 @@ fn shift_context(o: &Value, dx: f64, dy: f64) -> Value {
|
||||
set(&mut m, "contours", Some(Value::Array(cs)));
|
||||
}
|
||||
Some("image") => shift_pts_fields(&mut m, &["min", "max"], dx, dy, &[]),
|
||||
// Baugrube ([68]): Sohle-Umriss (Böschungen/Bermen sind Abstände, keine Lage).
|
||||
Some("excavation") => shift_pts_fields(&mut m, &[], dx, dy, &["outline"]),
|
||||
_ => {
|
||||
let mut pos: Vec<Value> = o.get("positions").and_then(Value::as_array).cloned().unwrap_or_default();
|
||||
let mut i = 0;
|
||||
@@ -228,6 +230,27 @@ pub fn translate_anchor(root: &Map<String, Value>, dx: f64, dy: f64) -> Option<V
|
||||
Some(Value::Object(m))
|
||||
}
|
||||
|
||||
/// Baurecht verschoben (`siteRules.parcel`, `buildingLines[].a/b`; Grenzabstände/Höhen bleiben), `None` ohne.
|
||||
pub fn translate_site_rules(root: &Map<String, Value>, dx: f64, dy: f64) -> Option<Value> {
|
||||
let r = root.get("siteRules").filter(|v| truthy(Some(v)))?;
|
||||
let mut m = obj(r);
|
||||
if m.contains_key("parcel") {
|
||||
shift_pts_fields(&mut m, &[], dx, dy, &["parcel"]);
|
||||
}
|
||||
if let Some(Value::Array(ls)) = r.get("buildingLines") {
|
||||
let n: Vec<Value> = ls
|
||||
.iter()
|
||||
.map(|l| {
|
||||
let mut lm = obj(l);
|
||||
shift_pts_fields(&mut lm, &["a", "b"], dx, dy, &[]);
|
||||
Value::Object(lm)
|
||||
})
|
||||
.collect();
|
||||
m.insert("buildingLines".into(), Value::Array(n));
|
||||
}
|
||||
Some(Value::Object(m))
|
||||
}
|
||||
|
||||
/// Patch für `{...project, ...patch}`: verschobene Listen und Geo-Anker (`translateProject`). Leer bei `dx = dy = 0`.
|
||||
pub fn project_patch(root: &Map<String, Value>, dx: f64, dy: f64) -> Map<String, Value> {
|
||||
let mut out = Map::new();
|
||||
@@ -238,6 +261,9 @@ pub fn project_patch(root: &Map<String, Value>, dx: f64, dy: f64) -> Map<String,
|
||||
if let Some(a) = translate_anchor(root, dx, dy) {
|
||||
out.insert("geoAnchor".into(), a);
|
||||
}
|
||||
if let Some(r) = translate_site_rules(root, dx, dy) {
|
||||
out.insert("siteRules".into(), r);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
@@ -255,6 +281,9 @@ pub fn translate_ops(root: &Map<String, Value>, dx: f64, dy: f64) -> Vec<Value>
|
||||
if let Some(a) = translate_anchor(root, dx, dy) {
|
||||
ops.push(json!({"kind": "setField", "key": "geoAnchor", "value": a}));
|
||||
}
|
||||
if let Some(r) = translate_site_rules(root, dx, dy) {
|
||||
ops.push(json!({"kind": "setField", "key": "siteRules", "value": r}));
|
||||
}
|
||||
ops
|
||||
}
|
||||
|
||||
@@ -304,6 +333,25 @@ mod tests {
|
||||
assert!(project_patch(&p, 0.0, 0.0).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn baugrube_und_baurecht_wandern_mit() {
|
||||
// Befund [154]: Baugrube (Kontext `excavation`) und Parzelle/Baulinien (`siteRules`) blieben beim
|
||||
// georeferenzierten DXF-Export lokal und lagen nach dem Import neben dem Gebäude.
|
||||
let p = root(json!({
|
||||
"context": [{"id": "b", "type": "excavation", "outline": [{"x": 0, "y": 0}, {"x": 2, "y": 0}, {"x": 2, "y": 1}], "bottom": -3}],
|
||||
"siteRules": {"parcel": [{"x": -1, "y": -1}, {"x": 5, "y": -1}, {"x": 5, "y": 4}], "defaultSetback": 5, "buildingLines": [{"a": {"x": 0, "y": 3}, "b": {"x": 4, "y": 3}}]},
|
||||
}));
|
||||
let patch = project_patch(&p, 100.0, 200.0);
|
||||
assert_eq!(patch["context"][0]["outline"][1], json!({"x": 102.0, "y": 200.0}));
|
||||
assert!(patch["context"][0].get("positions").is_none());
|
||||
assert_eq!(patch["context"][0]["bottom"], -3);
|
||||
assert_eq!(patch["siteRules"]["parcel"][0], json!({"x": 99.0, "y": 199.0}));
|
||||
assert_eq!(patch["siteRules"]["buildingLines"][0]["b"], json!({"x": 104.0, "y": 203.0}));
|
||||
assert_eq!(patch["siteRules"]["defaultSetback"], 5);
|
||||
let ops = translate_ops(&p, 1.0, 1.0);
|
||||
assert!(ops.iter().any(|o| o["kind"] == "setField" && o["key"] == "siteRules" && o["value"]["parcel"][0] == json!({"x": 0.0, "y": 0.0})));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ops_ohne_unveraenderte_ebenen() {
|
||||
let p = root(json!({
|
||||
|
||||
@@ -82,13 +82,41 @@ describe("recognizeCommand", () => {
|
||||
|
||||
it("Bericht-Text zählt unklare Stellen je Grund", () => {
|
||||
const txt = reportText({
|
||||
walls: 1, doors: 0, windows: 0, voids: 0, rooms: 0, arcWalls: 0, filledWalls: 0, unnamedRooms: 0, thicknesses: [0.3], layerFilter: true,
|
||||
walls: 1, doors: 0, slidingDoors: 0, windows: 0, voids: 0, rooms: 0, columns: 0, arcWalls: 0, filledWalls: 0, unnamedRooms: 0, thicknesses: [0.3], layerFilter: true,
|
||||
unclear: [{ code: "doorArc", x: 0, y: 0 }, { code: "doorArc", x: 1, y: 0 }, { code: "gapWide", x: 0, y: 0 }],
|
||||
});
|
||||
expect(txt).toContain("2×");
|
||||
expect(txt).toContain("1×");
|
||||
});
|
||||
|
||||
it("Schiebetür (Blatt vor der Wand + Pfeil statt Bogen) und Stütze: Türtyp mit Namen aus i18n, Stütze im Geschoss", () => {
|
||||
const line = (id: string, a: [number, number], b: [number, number]): Drawing2D =>
|
||||
({ id, type: "drawing2d", levelId: "imp", categoryCode: "102", geom: { shape: "line", a: { x: a[0], y: a[1] }, b: { x: b[0], y: b[1] } } }) as Drawing2D;
|
||||
const base = project();
|
||||
const p: Project = {
|
||||
...base,
|
||||
drawings2d: [
|
||||
...base.drawings2d.filter((d) => d.id !== "arc"),
|
||||
poly("blatt", "102", [[1, 0.17], [1.9, 0.17], [1.9, 0.21], [1, 0.21]]),
|
||||
line("pfeil", [1.675, 0.3], [1.225, 0.3]),
|
||||
line("spitze1", [1.225, 0.3], [1.34, 0.25]),
|
||||
line("spitze2", [1.225, 0.3], [1.34, 0.35]),
|
||||
{ ...poly("stuetze", "102", [[3.5, 1.85], [3.8, 1.85], [3.8, 2.15], [3.5, 2.15]]), fillColor: "#000000" } as Drawing2D,
|
||||
],
|
||||
};
|
||||
const ctx = ctxOf(p);
|
||||
const start = recognizeCommand.autoRun!(ctx);
|
||||
expect(start.notice?.params).toMatchObject({ walls: 5, doors: 1, sliding: 1, columns: 1 });
|
||||
const [, r] = recognizeCommand.onConfirm(recognizeCommand.init(), ctx);
|
||||
const next = r.commit!(p);
|
||||
const door = next.openings?.find((o) => o.kind === "door");
|
||||
const type = next.doorTypes?.find((t) => t.id === door?.typeId);
|
||||
expect(type?.kind).toBe("schiebe");
|
||||
expect(type?.name).toBe("Schiebetür (erkannt)");
|
||||
expect(next.columns?.length).toBe(1);
|
||||
expect(next.columns?.[0]).toMatchObject({ floorId: "eg", position: { x: 3.65, y: 2 }, profile: { kind: "rect", width: 0.3, depth: 0.3 }, height: 2.8 });
|
||||
});
|
||||
|
||||
it("ohne Zeichnung: Vorbedingung meldet, nichts erkannt → kein Commit", () => {
|
||||
const p = { ...project(), drawings2d: [] };
|
||||
expect(recognizeCommand.precondition!(ctxOf(p))).toBe("cmd.recognize.noDrawing");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// [154] Bauteile aus Zeichnung erkennen: aus den 2D-Linien eines Grundrisses (DXF/DWG-Import aus ArchiCAD,
|
||||
// Vectorworks, AutoCAD) Wände, Öffnungen und Räume. Quelle: die gewählten 2D-Elemente, sonst die Zeichnung des
|
||||
// Vectorworks, AutoCAD) Wände, Öffnungen (Dreh-, Schiebe-, Hebeschiebetüren, Fenster, Durchbrüche), Stützen und Räume. Quelle: die gewählten 2D-Elemente, sonst die Zeichnung des
|
||||
// aktiven Geschosses, sonst die erste Ebene mit Zeichnung (Option E schaltet durch). Beim Start zeigt die Vorschau
|
||||
// alles Erkannte (Wandbänder, Türen/Fenster/Durchbrüche, Räume, unklare Stellen als Kreuz), die Meldung zählt;
|
||||
// B zeigt den Bericht (unklar, mit Grund). Enter übernimmt als EIN Undo-Schritt ins aktive Geschoss (Höhe =
|
||||
@@ -38,6 +38,8 @@ function optionsOf(s: RecognizeState, ctx: CommandContext): RecognizeOptions {
|
||||
wallTypeId: ctx.activeWallTypeId,
|
||||
typeName: t("cmd.recognize.typeName"),
|
||||
roomName: t("cmd.recognize.roomName"),
|
||||
slideTypeName: t("cmd.recognize.slideTypeName"),
|
||||
liftSlideTypeName: t("cmd.recognize.liftSlideTypeName"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -65,6 +67,8 @@ const countParams = (r: RecognizeReport) => ({
|
||||
doors: r.doors,
|
||||
windows: r.windows,
|
||||
voids: r.voids,
|
||||
sliding: r.slidingDoors,
|
||||
columns: r.columns,
|
||||
rooms: r.rooms,
|
||||
unclear: r.unclear.length,
|
||||
});
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
// Georeferenzierter DXF-/DWG-Export ([154]-Befund, 7.11.): ALLE Entitäten liegen im selben Rahmen (LV95).
|
||||
// Vorher blieben die Baugrube (Kontext `excavation`, Ebene CONTEXT) und Parzelle/Baulinien (`siteRules`,
|
||||
// Ebene SYMBOLS) in lokalen Koordinaten, weil die Projekt-Verschiebung sie nicht mitnahm — nach dem Import
|
||||
// lagen sie Hunderte Kilometer neben dem Gebäude. Geprüft am Musterhaus komplex (Kataster, Raster, Bemassung,
|
||||
// Blöcke/INSERT mit ATTRIB, Texte, Schraffur bei 1:50, Kontext), je Geschoss: DXF (Gruppen-Codes), DWG
|
||||
// (libredwg) und die Rundreise durch den eigenen Import.
|
||||
|
||||
import "../engine/fileioWasm.setup";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildPlanDwg, buildPlanDxf } from "./exportDxf";
|
||||
import { libreDwgReader, nums, readDxf } from "./cadReadBack.testutil";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import { generatePlan } from "../plan/generatePlan";
|
||||
import { flattenCategories } from "../model/types";
|
||||
import type { Project } from "../model/types";
|
||||
import { projectGeoOrigin, projectToWorldCoords } from "../model/geoRebase";
|
||||
import { parseDxf } from "../io/dxfParser";
|
||||
import { ProjectDocument } from "../core/document";
|
||||
|
||||
const allCodes = (p: Project) => new Set(flattenCategories(p.layers).map((l) => l.code));
|
||||
|
||||
const project = buildComplexSampleProject();
|
||||
const origin = projectGeoOrigin(project)!;
|
||||
const world = projectToWorldCoords(project);
|
||||
const floors = project.drawingLevels.filter((l) => l.kind === "floor");
|
||||
/** Rahmen um das Grundstück (Kataster der Nachbarn reicht ≈ 55 m weit). */
|
||||
const R = 200;
|
||||
const inFrame = (x: number, y: number) => Math.abs(x - origin.e) < R && Math.abs(y - origin.n) < R;
|
||||
|
||||
describe("Georeferenzierter Export: alle Entitäten im LV95-Rahmen", () => {
|
||||
it("Baugrube und Baurecht wandern mit dem Projekt", () => {
|
||||
const ex = world.context?.find((c) => c.type === "excavation");
|
||||
expect(ex && "outline" in ex && ex.outline.every((p) => inFrame(p.x, p.y))).toBe(true);
|
||||
expect(ex && "positions" in ex).toBe(false);
|
||||
expect(world.siteRules!.parcel.every((p) => inFrame(p.x, p.y))).toBe(true);
|
||||
expect(world.siteRules!.buildingLines!.every((l) => inFrame(l.a.x, l.a.y) && inFrame(l.b.x, l.b.y))).toBe(true);
|
||||
});
|
||||
|
||||
for (const lvl of floors) {
|
||||
it(`${lvl.name}: DXF (alle Punkt-Codes) und DWG (libredwg)`, async () => {
|
||||
// 1:50: Wände mit Schraffur (HATCH) statt schwarzer Füllung.
|
||||
const plan = generatePlan(world, lvl.id, allCodes(world), undefined, "mittel", false, false, true, 50);
|
||||
const dxf = readDxf(buildPlanDxf(plan, world, { scaleDenominator: 50, levelId: lvl.id }));
|
||||
const bad: string[] = [];
|
||||
// Punkt-Codes der Modellbereichs-Entitäten (10/11/13/14 x, 20/21/23/24 y): Endpunkte, Ecken, Einfügepunkte,
|
||||
// Textlagen, Bemassungs-Definitionspunkte, Schraffur-Ränder.
|
||||
for (const e of dxf.entities) {
|
||||
for (const [cx, cy] of [[10, 20], [11, 21], [13, 23], [14, 24]]) {
|
||||
const xs = nums(e, cx);
|
||||
const ys = nums(e, cy);
|
||||
for (let i = 0; i < Math.min(xs.length, ys.length); i++) {
|
||||
// HATCH: Seed-/Musterbasispunkt (0, 0) ist kein Lagepunkt.
|
||||
if (e.type === "HATCH" && xs[i] === 0 && ys[i] === 0) continue;
|
||||
if (!inFrame(xs[i], ys[i])) bad.push(`${e.layer}/${e.type} ${cx}: ${xs[i]}, ${ys[i]}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
expect(bad.slice(0, 5)).toEqual([]);
|
||||
expect(dxf.entities.some((e) => e.type === "INSERT")).toBe(true);
|
||||
|
||||
const db = (await libreDwgReader())(buildPlanDwg(plan, world, { scaleDenominator: 50, levelId: lvl.id }));
|
||||
// TEXT links/Grundlinie: der Ausrichtungspunkt ist nicht gespeichert und lautet (0, 0) wie bei AutoCAD
|
||||
// (`(11 0 0 0)`); er gilt nur bei Mitte/rechts — dort steht er im Rahmen (endPoint geprüft).
|
||||
const unset = (e: { type: string }, p?: { x: number; y: number }) => e.type === "TEXT" && p?.x === 0 && p?.y === 0;
|
||||
const dwgBad = db.entities.flatMap((e) =>
|
||||
[e.startPoint, unset(e, e.endPoint) ? undefined : e.endPoint, e.center, ...(e.vertices ?? [])]
|
||||
.filter((p) => p && !inFrame(p.x, p.y))
|
||||
.map((p) => `${e.layer}/${e.type}: ${p!.x}, ${p!.y}`),
|
||||
);
|
||||
expect(dwgBad.slice(0, 5)).toEqual([]);
|
||||
});
|
||||
}
|
||||
|
||||
it("Rundreise Export → Import: alle importierten Zeichnungen im selben Rahmen", () => {
|
||||
const plan = generatePlan(world, "eg", allCodes(world));
|
||||
const parsed = parseDxf(buildPlanDxf(plan, world, { levelId: "eg" }));
|
||||
const base: Project = {
|
||||
...project,
|
||||
geoAnchor: undefined,
|
||||
siteRules: undefined,
|
||||
walls: [],
|
||||
openings: [],
|
||||
rooms: [],
|
||||
drawings2d: [],
|
||||
stairs: [],
|
||||
ceilings: [],
|
||||
roofs: [],
|
||||
columns: [],
|
||||
context: [],
|
||||
};
|
||||
const doc = new ProjectDocument(base);
|
||||
const r = doc.importDrawing(
|
||||
base,
|
||||
parsed.src,
|
||||
{
|
||||
target: { kind: "new", name: "Import" },
|
||||
categoryMode: "byLayer",
|
||||
activeCategoryCode: "20",
|
||||
importMeshes: false,
|
||||
levelNameTemplate: "Import {n}",
|
||||
parentName: "Import",
|
||||
dashStyleTemplate: "{pattern}",
|
||||
},
|
||||
0,
|
||||
);
|
||||
doc.close();
|
||||
if ("problems" in r) throw new Error(r.problems.join("; "));
|
||||
// Alle Punkte der importierten Zeichnungen (wie immer der Import sie verschiebt: gemeinsam).
|
||||
const xs: number[] = [];
|
||||
const ys: number[] = [];
|
||||
for (const d of r.project.drawings2d) {
|
||||
for (const m of JSON.stringify(d.geom).matchAll(/\{"x":(-?[\d.e+-]+),"y":(-?[\d.e+-]+)\}/g)) {
|
||||
xs.push(Number(m[1]));
|
||||
ys.push(Number(m[2]));
|
||||
}
|
||||
}
|
||||
expect(xs.length).toBeGreaterThan(1000);
|
||||
const span = (v: number[]) => v.reduce((a, b) => Math.max(a, b), -Infinity) - v.reduce((a, b) => Math.min(a, b), Infinity);
|
||||
expect(span(xs)).toBeLessThan(2 * R);
|
||||
expect(span(ys)).toBeLessThan(2 * R);
|
||||
});
|
||||
});
|
||||
+5
-3
@@ -1969,9 +1969,11 @@ export const de = {
|
||||
"cmd.recognize.report": "Bericht",
|
||||
"cmd.recognize.typeName": "Wand {cm} cm (erkannt)",
|
||||
"cmd.recognize.roomName": "Raum {n}",
|
||||
"cmd.recognize.hud": "{walls} Wände · {doors} Türen · {windows} Fenster · {voids} Durchbrüche · {rooms} Räume · {unclear} unklar",
|
||||
"cmd.recognize.summary": "Erkannt: {walls} Wände, {doors} Türen, {windows} Fenster, {voids} Durchbrüche, {rooms} Räume; unklar: {unclear}. Enter übernimmt, B zeigt den Bericht.",
|
||||
"cmd.recognize.done": "Übernommen: {walls} Wände, {doors} Türen, {windows} Fenster, {voids} Durchbrüche, {rooms} Räume (ein Rückgängig-Schritt).",
|
||||
"cmd.recognize.hud": "{walls} Wände · {doors} Türen · {windows} Fenster · {voids} Durchbrüche · {columns} Stützen · {rooms} Räume · {unclear} unklar",
|
||||
"cmd.recognize.summary": "Erkannt: {walls} Wände, {doors} Türen ({sliding} Schiebetüren), {windows} Fenster, {voids} Durchbrüche, {columns} Stützen, {rooms} Räume; unklar: {unclear}. Enter übernimmt, B zeigt den Bericht.",
|
||||
"cmd.recognize.done": "Übernommen: {walls} Wände, {doors} Türen, {windows} Fenster, {voids} Durchbrüche, {columns} Stützen, {rooms} Räume (ein Rückgängig-Schritt).",
|
||||
"cmd.recognize.slideTypeName": "Schiebetür (erkannt)",
|
||||
"cmd.recognize.liftSlideTypeName": "Hebeschiebetür (erkannt)",
|
||||
"cmd.recognize.nothing": "Keine Wände erkannt (parallele Linien im Abstand 5–60 cm).",
|
||||
"cmd.recognize.noDrawing": "Keine 2D-Zeichnung vorhanden – zuerst einen Grundriss (DXF/DWG) importieren.",
|
||||
"cmd.recognize.reportNotice": "{text}",
|
||||
|
||||
+5
-3
@@ -1958,9 +1958,11 @@ export const en: Record<TranslationKey, string> = {
|
||||
"cmd.recognize.report": "Report",
|
||||
"cmd.recognize.typeName": "Wall {cm} cm (recognized)",
|
||||
"cmd.recognize.roomName": "Room {n}",
|
||||
"cmd.recognize.hud": "{walls} walls · {doors} doors · {windows} windows · {voids} openings · {rooms} rooms · {unclear} unclear",
|
||||
"cmd.recognize.summary": "Recognized: {walls} walls, {doors} doors, {windows} windows, {voids} wall openings, {rooms} rooms; unclear: {unclear}. Enter accepts, B shows the report.",
|
||||
"cmd.recognize.done": "Added: {walls} walls, {doors} doors, {windows} windows, {voids} wall openings, {rooms} rooms (one undo step).",
|
||||
"cmd.recognize.hud": "{walls} walls · {doors} doors · {windows} windows · {voids} openings · {columns} columns · {rooms} rooms · {unclear} unclear",
|
||||
"cmd.recognize.summary": "Recognized: {walls} walls, {doors} doors ({sliding} sliding), {windows} windows, {voids} wall openings, {columns} columns, {rooms} rooms; unclear: {unclear}. Enter accepts, B shows the report.",
|
||||
"cmd.recognize.done": "Added: {walls} walls, {doors} doors, {windows} windows, {voids} wall openings, {columns} columns, {rooms} rooms (one undo step).",
|
||||
"cmd.recognize.slideTypeName": "Sliding door (recognized)",
|
||||
"cmd.recognize.liftSlideTypeName": "Lift-and-slide door (recognized)",
|
||||
"cmd.recognize.nothing": "No walls recognized (parallel lines 5–60 cm apart).",
|
||||
"cmd.recognize.noDrawing": "No 2D drawing – import a floor plan (DXF/DWG) first.",
|
||||
"cmd.recognize.reportNotice": "{text}",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// [154] Rundreise: eigener DXF-Export eines Geschosses → DXF-Import (Layer als Kategorien, neue Zeichnungsebene)
|
||||
// → „Bauteile aus Zeichnung erkennen“ → Wände/Öffnungen mit dem Original vergleichen (Quote auf der Konsole).
|
||||
// Wände: Achse (beide Richtungen, ±1 cm) und Dicke (±1 mm); Öffnungen: Art und Pfosten (±2 cm), Türen zusätzlich
|
||||
// Scharnierpunkt und Aufschlagseite. Mit `DOSSIER_RECOGNIZE_OUT=<ordner>` werden Import und Ergebnis als .obp
|
||||
// Wände: Achse (beide Richtungen, ±1 cm) und Dicke (±1 mm); Öffnungen: Art (Schiebe-/Hebeschiebetür eigene Art) und
|
||||
// Pfosten (±2 cm), Drehtüren zusätzlich Scharnierpunkt und Aufschlagseite; Stützen (15–60 cm): Mitte (±2 cm). Mit `DOSSIER_RECOGNIZE_OUT=<ordner>` werden Import und Ergebnis als .obp
|
||||
// geschrieben (Bilder für den Bericht).
|
||||
|
||||
import { writeFileSync } from "node:fs";
|
||||
@@ -27,7 +27,7 @@ const thickness = (p: Project, w: Wall) => (p.wallTypes.find((t) => t.id === w.w
|
||||
const dist = (a: Vec2, b: Vec2) => Math.hypot(a.x - b.x, a.y - b.y);
|
||||
|
||||
interface Jambs {
|
||||
kind: "door" | "window" | "void";
|
||||
kind: "door" | "slide" | "window" | "void";
|
||||
a: Vec2;
|
||||
b: Vec2;
|
||||
/** Tür: Scharnierpunkt und Aufschlagseite (Einheitsvektor quer zur Wand). */
|
||||
@@ -46,8 +46,10 @@ function jambs(p: Project, o: Opening): Jambs | null {
|
||||
arc
|
||||
? { x: arc.center.x + arc.r * Math.cos(arc.a0 + Math.sign(arc.sweep) * (s / arc.r)), y: arc.center.y + arc.r * Math.sin(arc.a0 + Math.sign(arc.sweep) * (s / arc.r)) }
|
||||
: { x: w.start.x + u.x * s, y: w.start.y + u.y * s };
|
||||
const voidish = o.kind === "door" && (o.doorType === "wandoeffnung" || p.doorTypes?.find((t) => t.id === o.typeId)?.kind === "wandoeffnung");
|
||||
const kind = voidish ? "void" : o.kind;
|
||||
const typeKind = o.kind === "door" ? p.doorTypes?.find((t) => t.id === o.typeId)?.kind : undefined;
|
||||
const voidish = o.kind === "door" && (o.doorType === "wandoeffnung" || typeKind === "wandoeffnung");
|
||||
const slide = typeKind === "schiebe" || typeKind === "hebeschiebe";
|
||||
const kind = voidish ? "void" : slide ? "slide" : o.kind;
|
||||
const j: Jambs = { kind, a: at(o.position), b: at(o.position + o.width) };
|
||||
if (kind === "door") {
|
||||
j.hinge = at(o.position + (o.hinge === "end" ? o.width : 0));
|
||||
@@ -63,6 +65,7 @@ interface Quote {
|
||||
axis: number;
|
||||
openings: [number, number];
|
||||
doors: [number, number];
|
||||
columns: [number, number];
|
||||
report: RecognizeReport;
|
||||
imported: Project;
|
||||
result: Project;
|
||||
@@ -135,15 +138,20 @@ function roundtrip(orig: Project, levelId: string): Quote {
|
||||
const doorOk = od.filter((x) =>
|
||||
no.some((y) => same(x, y) && dist(x.hinge!, y.hinge!) < 0.02 && dist(x.side!, y.side!) < 1e-6),
|
||||
).length;
|
||||
return { walls: [wallOk, ow.length], axis: axisAll ? axisOk / axisAll : 1, openings: [openOk, oo.length], doors: [doorOk, od.length], report, imported, result };
|
||||
// Stützen mit Querschnitt 15–60 cm (kleinere, z. B. Carport-Pfosten 12 cm, sind keine Kandidaten).
|
||||
const size = (x: number) => x >= 0.15 - 1e-9 && x <= 0.6 + 1e-9;
|
||||
const oc = (orig.columns ?? []).filter((c) => c.floorId === levelId && (c.profile.kind === "round" ? size(2 * c.profile.radius) : size(c.profile.width) && size(c.profile.depth)));
|
||||
const nc = (result.columns ?? []).filter((c) => c.floorId === levelId);
|
||||
const colOk = oc.filter((c) => nc.some((n) => dist(c.position, n.position) < 0.02)).length;
|
||||
return { walls: [wallOk, ow.length], axis: axisAll ? axisOk / axisAll : 1, openings: [openOk, oo.length], doors: [doorOk, od.length], columns: [colOk, oc.length], report, imported, result };
|
||||
}
|
||||
|
||||
const pct = ([a, b]: [number, number]) => `${a}/${b} (${b ? Math.round((100 * a) / b) : 100} %)`;
|
||||
|
||||
function log(name: string, q: Quote) {
|
||||
console.log(
|
||||
`[154] ${name}: Wände ${pct(q.walls)} (Achsen ${Math.round(q.axis * 100)} %), Öffnungen ${pct(q.openings)}, Türen mit Anschlag/Aufschlag ${pct(q.doors)}; ` +
|
||||
`erkannt ${q.report.walls} Wände, ${q.report.doors} Türen, ${q.report.windows} Fenster, ${q.report.voids} Durchbrüche, ${q.report.rooms} Räume, unklar ${q.report.unclear.length} (${[...new Set(q.report.unclear.map((u) => u.code))].join(", ")})`,
|
||||
`[154] ${name}: Wände ${pct(q.walls)} (Achsen ${Math.round(q.axis * 100)} %), Öffnungen ${pct(q.openings)}, Türen mit Anschlag/Aufschlag ${pct(q.doors)}, Stützen ${pct(q.columns)}; ` +
|
||||
`erkannt ${q.report.walls} Wände, ${q.report.doors} Türen (${q.report.slidingDoors} Schiebetüren), ${q.report.windows} Fenster, ${q.report.voids} Durchbrüche, ${q.report.columns} Stützen, ${q.report.rooms} Räume, unklar ${q.report.unclear.length} (${[...new Set(q.report.unclear.map((u) => u.code))].join(", ")})`,
|
||||
);
|
||||
if (OUT) {
|
||||
writeFileSync(join(OUT, `${name}-import.obp`), serializeProject(q.imported));
|
||||
@@ -177,7 +185,7 @@ describe("[154] Rundreise DXF-Export → Import → Bauteile erkennen", () => {
|
||||
it("Musterhaus komplex: Quote je Geschoss", () => {
|
||||
const p = buildComplexSampleProject();
|
||||
const floors = p.drawingLevels.filter((l) => l.kind === "floor" && p.walls.some((w) => w.floorId === l.id));
|
||||
let [w, wn, o, on, ax] = [0, 0, 0, 0, 0];
|
||||
let [w, wn, o, on, ax, c, cn] = [0, 0, 0, 0, 0, 0, 0];
|
||||
for (const l of floors) {
|
||||
const q = roundtrip(p, l.id);
|
||||
log(`komplex-${l.id}`, q);
|
||||
@@ -186,9 +194,14 @@ describe("[154] Rundreise DXF-Export → Import → Bauteile erkennen", () => {
|
||||
wn += q.walls[1];
|
||||
o += q.openings[0];
|
||||
on += q.openings[1];
|
||||
c += q.columns[0];
|
||||
cn += q.columns[1];
|
||||
}
|
||||
console.log(`[154] Musterhaus komplex gesamt: Wände ${pct([w, wn])} (Achsen ${Math.round(ax * 100)} %), Öffnungen ${pct([o, on])}`);
|
||||
console.log(`[154] Musterhaus komplex gesamt: Wände ${pct([w, wn])} (Achsen ${Math.round(ax * 100)} %), Öffnungen ${pct([o, on])}, Stützen ${pct([c, cn])}`);
|
||||
expect(wn).toBeGreaterThan(0);
|
||||
expect(w / wn).toBeGreaterThan(0.6);
|
||||
// 7.11.: Schiebe-/Hebeschiebetüren (5) und die Stütze im UG werden erkannt (vorher Fenster bzw. nichts).
|
||||
expect(o / on).toBeGreaterThan(0.85);
|
||||
expect(c).toBe(cn);
|
||||
}, 120_000);
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
// [154] Bauteile aus Zeichnung erkennen — dünne Fassade über den Kern (`src-tauri/core/src/drawing_recognize.rs`):
|
||||
// aus den 2D-Linien eines Grundrisses (DXF/DWG-Import) Wände, Öffnungen und Räume. Erkennung, Vorschau, Bericht
|
||||
// aus den 2D-Linien eines Grundrisses (DXF/DWG-Import) Wände, Öffnungen (auch Schiebetüren), Stützen und Räume. Erkennung, Vorschau, Bericht
|
||||
// und Ops rechnet der Kern; hier nur die Anfrage (Quell-Ebene, Auswahl, Namensvorlagen, Ziel-Geschoss).
|
||||
|
||||
import type { Project } from "../model/types";
|
||||
@@ -16,10 +16,15 @@ export interface RecognizeUnclear {
|
||||
/** Bericht der Erkennung (Abfrage `recognize`). */
|
||||
export interface RecognizeReport {
|
||||
walls: number;
|
||||
/** Türen einschliesslich Schiebe-/Hebeschiebetüren. */
|
||||
doors: number;
|
||||
/** Davon Schiebe- und Hebeschiebetüren (Pfeil oder versetzte Flügel, kein Bogen). */
|
||||
slidingDoors: number;
|
||||
windows: number;
|
||||
voids: number;
|
||||
rooms: number;
|
||||
/** Stützen (kleine gefüllte Rechtecke/Kreise 15–60 cm oder auf einem Stützen-Layer, frei stehend). */
|
||||
columns: number;
|
||||
arcWalls: number;
|
||||
/** Wände mit Füllung/Schraffur zwischen den Linien. */
|
||||
filledWalls: number;
|
||||
@@ -48,6 +53,9 @@ export interface RecognizeOptions {
|
||||
typeName?: string;
|
||||
/** Namensvorlage unbenannter Räume, `{n}` = laufende Nummer. */
|
||||
roomName?: string;
|
||||
/** Name eines neuen Schiebe- bzw. Hebeschiebetür-Typs (falls das Projekt keinen hat). */
|
||||
slideTypeName?: string;
|
||||
liftSlideTypeName?: string;
|
||||
}
|
||||
|
||||
let seq = 0;
|
||||
@@ -59,6 +67,8 @@ function request(o: RecognizeOptions): Record<string, unknown> {
|
||||
ids: o.ids && o.ids.length > 0 ? [...o.ids] : [],
|
||||
typeName: o.typeName ?? "",
|
||||
roomName: o.roomName ?? "",
|
||||
slideTypeName: o.slideTypeName ?? "",
|
||||
liftSlideTypeName: o.liftSlideTypeName ?? "",
|
||||
ctx: { level: o.levelId, floorHeight: o.floorHeight ?? null, cat: o.categoryCode ?? "20", wallType: o.wallTypeId ?? "" },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -24,8 +24,9 @@ import type { Project } from "./types";
|
||||
/**
|
||||
* Verschiebt SÄMTLICHE Modell-Koordinaten eines Projekts um den festen Vektor
|
||||
* (dx,dy) — Wände, Decken, Dächer, Öffnungen-Host (folgt automatisch der Wand),
|
||||
* Treppen, Räume, Stützen, Extrusionen, freie 2D-Geometrie, Kontext-Schicht
|
||||
* (Import/Terrain/Konturen), Schnitt-/Ansichtslinien sowie den Geo-Anker
|
||||
* Treppen, Räume, Stützen, Bäume, Extrusionen, freie 2D-Geometrie, Kontext-Schicht
|
||||
* (Import/Terrain/Konturen/Baugrube), Schnitt-/Ansichtslinien, Baurecht (Parzelle,
|
||||
* Baulinien; bis 7.11. vergessen, [154]) sowie den Geo-Anker
|
||||
* (`geoAnchor.model`, damit der LV95-Bezug exakt erhalten bleibt). Richtungs-
|
||||
* Vektoren (z. B. `Stair.dir`) und Winkel-Felder bleiben unangetastet — eine
|
||||
* reine Translation ändert keine Orientierung. Unveränderte Teile behalten ihre Identität;
|
||||
|
||||
@@ -380,7 +380,7 @@ const TOOLS_2D: ToolId[] = [
|
||||
];
|
||||
const TOOLS_3D: ToolId[] = ["wall", "ceiling", "window", "door", "stair", "room"];
|
||||
const COMMANDS_3D = ["column", "tree", "circlestotrees", "ceilingopening", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "sectionline", "viewline", "autodim", "excavation"];
|
||||
const COMMANDS_EDIT = ["move", "copy", "array", "rotate", "mirror", "offset", "multiline", "trim", "break", "split", "extend", "fillet", "chamfer", "join", "defblock", "measure"];
|
||||
const COMMANDS_EDIT = ["move", "copy", "array", "rotate", "mirror", "offset", "multiline", "trim", "break", "split", "extend", "fillet", "chamfer", "join", "defblock", "measure", "erkennen"];
|
||||
|
||||
type ToolsView = "list" | "icons";
|
||||
const VIEW_STORAGE_KEY = "dossier.toolsPanel.view";
|
||||
|
||||
@@ -106,6 +106,17 @@ export const CommandIcon = memo(function CommandIcon({ name }: { name: string })
|
||||
<line x1="2.5" y1="12" x2="13.5" y2="12" />
|
||||
</svg>
|
||||
);
|
||||
case "erkennen":
|
||||
// Bauteile aus Zeichnung erkennen ([154]): Linienpaar (Wand) mit Türbogen, Lupe.
|
||||
return (
|
||||
<svg {...common}>
|
||||
<line x1="1.5" y1="4" x2="10" y2="4" />
|
||||
<line x1="1.5" y1="7" x2="5" y2="7" />
|
||||
<path d="M5 7 A4 4 0 0 1 9 3" strokeDasharray="1.4 1.2" />
|
||||
<circle cx="10.5" cy="10.5" r="2.8" />
|
||||
<line x1="12.5" y1="12.5" x2="14.5" y2="14.5" />
|
||||
</svg>
|
||||
);
|
||||
case "trim":
|
||||
// Schere (Stutzen).
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user