[140][141] Merge Plandarstellung Teil 5 (1:100 schwarz, dünne Schichten, Raumstempel) mit Wandknoten-Resten; Goldens neu, Knoten-Test in Detail fein

This commit is contained in:
Claude committed 2026-11-06 16:21:32 +00:00
commit f29ffde6f8
51 files changed
+831 -270

No files matched your search

+29 -3
View File
@@ -2792,9 +2792,35 @@ Format · [90] Versionsvergleich · [91] Assistent · [92] Speckle.
Palette (Rust + `penSets.test.ts`), `viewportPlan.test.ts` (keine bunten Farben, Farbe auf Wunsch). Goldens
unverändert. Geprüft: cargo test Kern, vitest, tsc, e2e presentationSheet/layoutSheet/publish/viewTemplates,
Präsentationsblatt (Browser) und CLI-Schnitt 1:100 vorher/nachher angesehen.
Offen: Stempel-Breite nur geschätzt (keine Schriftmetrik), L-förmige Räume über die Bounding-Box; Präsentations-
Dialog ohne eigenen Farb-Schalter (nur über die Vorlage); dünne Dämmung im Grundriss nicht behandelt (Wände selten
< 5 cm). Nur Linux/CLI-SVG + Chromium geprüft, nicht in der Tauri-App. · M
(6.11., Teil 5) **Schnittflächen 1:100 schwarz** (Vorgabe Maintainer: „Schraffur-Bauteile im 1:50 zeigen, das
1:100 wird i. d. R. schwarz angezeigt"): ab 1:100 (Detail mittel; „grob" immer) sind geschnittene Wände, Stützen und
Körper im Grundriss und alle geschnittenen Bauteile im Schnitt eine volle schwarze Fläche ohne Schichtfugen und
Schraffur, nur der Umriss (`style::solid_cut`, Grundriss über die Sammelfläche wie „grob", Schnitt: Füllung Tinte,
Umriss der vereinigten Flächen bleibt); Öffnungen unverändert, auch im Modus „Farbig" schwarz. 1:50 und „fein"
schraffiert. Übersteuerbar je Ebene/Ansichtsvorlage: neues Feld `cutHatch` („Schnittflächen 1:100 schraffiert",
`DrawingLevel`/`ViewTemplate`, Vorlagen-Dialog; Schnitt über `levelArg`, Detail des Schnitts neu über
`generateSectionPlan(…, { detail })`). **Dünne Schichten:** eine Regel in `plan/style.rs` (`simplify_thin_layers`,
`is_thin_layer`): unter 0.5 mm Papierdicke (statt 0.25) ab 1:50 in „mittel" (auch „grob"), „fein" und 1:20 zeigen
alle; gilt für Wände im Grundriss (`walls::thin_layer_targets`), Schnitt-Schichten (`section::merge_thin_cuts`) und
dünne Dämmung ohne Muster (`plain_thin_insulation`) — wirkt jetzt v. a. im 1:50 (Putz/Parkett 1–2 cm, Lattung)
und im 1:100 mit `cutHatch`. **Raumstempel:** Anker ohne eigenen `stampAnchor` = Pol der Unzugänglichkeit
(`room_area::label_point`, polylabel; Rechteck/Korridor behält die Mitte), auch für Deckenspiegel, Fang, Griff,
Stempel-Editor (`roomLabelPoint`); neue Räume (Befehl „Raum") setzen keinen festen Anker mehr. Platz aus dem
Raumumriss (`room_area::rect_in_ring`) statt der Bounding-Box; passt der Stempel am Pol nicht (L-Raum), rückt er im
Raum auf einen Rasterpunkt, wo er (mit Luft) ganz drin liegt. Breite aus echter Schriftmetrik
(`text_layout::text_width_em`, Inter-Vorschübe aus `render2d/assets/Inter.ttf`; `stamp_block_size` misst den
gesetzten Block mit Name 12 pt fett / Zusatzzeilen 0.8×); Stufen: Zusatzzeilen weg → Name ohne eigene Grössen →
2 mm → gekürzt. Tests: `duenne_schicht_regel`, `schnittflaechen_schwarz_ab_1_100` (style, Grundriss, Schnitt),
`stempel_anker_pol_der_unzugaenglichkeit`, `rechteck_im_ring`, `schriftmetrik_inter`, `raumstempel_im_l_raum`,
`raumstempel_passt_in_engen_raum`, angepasst `duenne_schichten_*`, `raumstempel_je_massstab` (1:500 „Wohnen" jetzt
2 mm); TS `roomLabelPoint`; TS-Tests mit Schichten/Schraffur rechnen in 1:50 bzw. mit `cutHatch`. Goldens neu
(Grundrisse 1:100 schwarz, 1:50 zusammengefasste Schichten, Stempel-Lage; Schnitte; CLI). Geprüft: cargo test
Kern, vitest, tsc, CLI-SVG Musterhaus komplex EG und Schnitt A-A 1:100/1:50 vorher/nachher in Chromium.
Offen: CLI-SVG (`plan/svg.rs`) setzt alle Stempelzeilen in der Grundgrösse und „sans-serif" (nicht 12 pt/0.8×,
nicht Inter) — Breiten weichen dort von der Messung ab; IFC-Import setzt den Stempel-Anker weiter auf den
Eckenmittelwert; Bodenplatte samt Kies/Magerbeton im Schnitt 1:100 schwarz (kein Materialfilter); Stempel-Editor/
Griff zeigen auf den Pol, auch wenn der Stempel im L-Raum weggerückt ist; Präsentations-Dialog ohne eigenen
Farb-Schalter (nur über die Vorlage). Nur Linux/CLI-SVG + Chromium geprüft, nicht in der Tauri-App. · M
Höhenlinien). Offen: dünne Schichten (Putz, Parkett) laufen in 1:100 zu einem Balken zusammen (Detailgrad sollte
sie zusammenfassen); Achsen laufen in Ansicht/Grundriss durch das Gebäude; Raumstempel farbig statt schwarz im
Druck ohne Schwarz-Weiss; Schatten im EG-Grundriss überdeckt Bemassung; eigene Stempel (`Room.stamp`) behalten in
-1
View File
@@ -533,7 +533,6 @@ fn room_ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
("name", s(&name)),
("boundary", pvs(&boundary)),
("color", category_color(p, code, "#4a4a4a")),
("stampAnchor", pt(e.centroid[0], e.centroid[1])),
("stampDoc", doc),
])],
)
+1 -1
View File
@@ -315,7 +315,7 @@ pub fn run(lk: &Lookup, req: &Request) -> Result<GripResult, String> {
Some(a) if !a.is_null() => xy(a),
_ => {
let ring: Vec<[f64; 2]> = arr(field(rm, "boundary")).iter().map(|p| xy(p).into()).collect();
let c = crate::room_area::evaluate(&ring, 0.0).centroid;
let c = crate::room_area::label_point(&ring);
(c[0], c[1])
}
};
+9
View File
@@ -1807,6 +1807,11 @@ pub struct DrawingLevel {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub sketch: Option<bool>,
/// [140] Schnittflächen (Wände, Stützen, Decken) auch ab 1:100 mit Schichten und Schraffur statt als
/// schwarze Fläche (Poché). Fehlt/aus: ab 1:100 schwarz, 1:50 und Detail „fein" schraffiert.
#[serde(rename = "cutHatch", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub cut_hatch: Option<bool>,
/// Grundriss-Unterlage (nur Schnitt/Ansicht): ID eines Geschosses, dessen
/// Grundriss AUSGERICHTET unter dem Schnitt/der Ansicht gezeigt wird (Schnitt-
/// linie waagrecht, Blickrichtung nach oben, s. Kern `plan/underlay.rs`).
@@ -1902,6 +1907,10 @@ pub struct ViewTemplate {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub sketch: Option<bool>,
/// [140] Schnittflächen ab 1:100 schraffiert statt schwarz (s. `DrawingLevel::cut_hatch`).
#[serde(rename = "cutHatch", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub cut_hatch: Option<bool>,
/// Strichstärken mit dem Massstab skalieren.
#[serde(rename = "scaleLineWeights", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
+1 -1
View File
@@ -343,7 +343,7 @@ fn room_labels(c: &Ctx, soffits: &[Soffit], roofs: &[RoofUnder], out: &mut Vec<P
}
for room in c.p.rooms.as_deref().unwrap_or(&[]).iter().filter(|r| r.floor_id == c.a.floor && c.shown(&r.category_code) && r.boundary.len() >= 3) {
let pts: Vec<[f64; 2]> = room.boundary.iter().map(|v| [v.x, v.y]).collect();
let at = room.stamp_anchor.unwrap_or(pv(crate::room_area::evaluate(&pts, 0.0).centroid));
let at = room.stamp_anchor.unwrap_or(pv(crate::room_area::label_point(&pts)));
let z = soffits.iter().filter(|s| super::pick::point_in_polygon(at.x, at.y, &s.ring)).map(|s| s.z).fold(f64::INFINITY, f64::min);
let mut lines = Vec::new();
let kote = super::drawings::kote_label;
+194 -49
View File
@@ -122,6 +122,12 @@ impl<'a> Ctx<'a> {
self.a.show.contains(code)
}
/// [140] Schnittflächen dieser Ebene schwarz (`style::solid_cut`; Feld `cutHatch` der Ebene).
pub fn solid_cut(&self) -> bool {
let cut_hatch = self.p.floor(&self.a.floor).and_then(|l| l.cut_hatch).unwrap_or(false);
solid_cut(self.a.detail, self.a.scale, cut_hatch)
}
pub fn greyed(&self, code: &str) -> bool {
self.a.grey.contains(code)
}
@@ -614,37 +620,91 @@ fn with_alpha(color: &str, alpha: &str) -> String {
/// [140] Kleinste Stempelschrift (2 mm Papier) für enge Räume.
const ROOM_STAMP_MIN_PT: f64 = 2.0 / PT_MM;
const PT_MM: f64 = 0.3528;
/// Geschätzte Zeichenbreite und Zeilenhöhe je Schrifthöhe (Sans, Ziffern/Kleinbuchstaben).
const STAMP_CHAR_W: f64 = 0.55;
const STAMP_LINE_H: f64 = 1.25;
const PT_MM: f64 = crate::text_layout::PT_TO_MM;
/// [140] Rand um den Stempel: 5 % der Blockgrösse plus 0.5 mm Papier je Seite (Bildschirm-/Druckschrift
/// weicht von Inter ab, z. B. Helvetica schmaler, DejaVu breiter).
const STAMP_MARGIN: f64 = 1.05;
const STAMP_PAD_MM: f64 = 0.5;
/// [140] Raumstempel einpassen: passt der geschätzte Stempel (Zeichen × Zeilen bei `pt`) nicht in den
/// Raum (`room_w` × `room_h`, Meter, Bounding-Box mit 5 % Rand), entfallen erst die Nutzungszeile, dann die
/// Flächenzeile (Zusatzzeilen von hinten), danach sinkt die Schrift auf 2 mm Papier. `name_chars` = Zeichen
/// je Namenszeile. Ergebnis: verbleibende Zusatzzeilen, Schriftgrösse (pt) und — passt selbst der Name in 2 mm
/// nicht in die Breite — die Zeichenzahl, auf die er gekürzt wird (`Some(n)`, n ≥ 2, mit Punkt).
fn fit_room_stamp(name_chars: &[usize], mut extra: Vec<StampLine>, pt: f64, scale: f64, room_w: f64, room_h: f64) -> (Vec<StampLine>, f64, Option<usize>) {
let fits = |extra: &[StampLine], pt: f64| {
let h = pt * PT_MM * scale / 1000.0;
let chars = name_chars.iter().copied().chain(extra.iter().map(|l| l.text.chars().count())).max().unwrap_or(0) as f64;
let rows = (name_chars.len() + extra.len()) as f64;
chars * STAMP_CHAR_W * h <= room_w * 0.95 && rows * STAMP_LINE_H * h <= room_h * 0.95
/// [140] Ausmass des Stempels in Metern bei 1:`scale` (echte Schriftmetrik, `text_layout::stamp_block_size`)
/// samt Rand.
fn stamp_size_m(doc: &RichTextDoc, extra: &[StampLine], pt: f64, scale: f64) -> (f64, f64) {
let rows: Vec<(&str, crate::text_layout::LineAlign)> = extra.iter().map(|l| (l.text.as_str(), crate::text_layout::LineAlign::of(Some(l.align)))).collect();
let (w, h) = crate::text_layout::stamp_block_size(doc, &rows, pt, PT_MM * scale / 1000.0);
let pad = 2.0 * STAMP_PAD_MM * scale / 1000.0;
(w * STAMP_MARGIN + pad, h * STAMP_MARGIN + pad)
}
/// [140] Raumstempel einpassen. `place(breite, höhe)` sucht eine Lage im Raum, an der das Rechteck des
/// Stempels ganz im Raumumriss liegt (auch L-förmige Räume, `room_area::rect_in_ring`), und gibt sie zurück.
/// Passt der Stempel (Breite aus der Schriftmetrik, Höhe aus den Zeilen) bei `pt` nirgends, entfallen erst
/// die Nutzungszeile, dann die Flächenzeile (Zusatzzeilen von hinten), danach sinkt die Schrift auf 2 mm
/// Papier (je Schrift zuerst der Name mit, dann ohne eigene Schriftgrössen; mit kleinerer Schrift dürfen
/// Zusatzzeilen wieder dazu), zuletzt wird der Name gekürzt. Ergebnis: Zusatzzeilen,
/// Schriftgrösse (pt), Ersatz für den Namen (`Some`: ohne Auszeichnungen bzw. gekürzt, „Trep.") und die
/// Lage (`None`: passt nirgends, der Aufrufer behält seinen Anker).
fn fit_room_stamp(doc: &RichTextDoc, extra: Vec<StampLine>, pt: f64, scale: f64, place: &dyn Fn(f64, f64) -> Option<Vec2>) -> (Vec<StampLine>, f64, Option<RichTextDoc>, Option<Vec2>) {
if !(scale > 0.0) || !scale.is_finite() {
return (extra, pt, None, None);
}
let at = |doc: &RichTextDoc, extra: &[StampLine], pt: f64| {
let (w, h) = stamp_size_m(doc, extra, pt, scale);
place(w, h)
};
if !(scale > 0.0) || !(room_w > 0.0) || !(room_h > 0.0) {
return (extra, pt, None);
let text = crate::text_layout::plain_text(doc);
// Name mit eigenen Schriftgrössen (Stempel: Name 12 pt fett) schrumpft nicht mit `pt`: dann ohne
// Auszeichnungen in der Grundschrift (Ersatz `Some`).
let plain = doc_from_text(&text);
let mut steps: Vec<(Option<&RichTextDoc>, f64)> = vec![(None, pt), (Some(&plain), pt)];
if pt > ROOM_STAMP_MIN_PT {
steps.extend([(None, ROOM_STAMP_MIN_PT), (Some(&plain), ROOM_STAMP_MIN_PT)]);
}
while !fits(&extra, pt) && !extra.is_empty() {
extra.pop();
for (variant, pt) in steps {
let mut e = extra.clone();
loop {
if let Some(q) = at(variant.unwrap_or(doc), &e, pt) {
return (e, pt, variant.cloned(), Some(q));
}
if e.pop().is_none() {
break;
}
}
}
if fits(&extra, pt) || pt <= ROOM_STAMP_MIN_PT {
return (extra, pt, None);
let pt = pt.min(ROOM_STAMP_MIN_PT);
let longest = text.split('\n').map(|l| l.chars().count()).max().unwrap_or(0);
for n in (2..longest).rev() {
let d = doc_from_text(&abbreviate(&text, n));
if let Some(q) = at(&d, &[], pt) {
return (Vec::new(), pt, Some(d), Some(q));
}
}
let pt = ROOM_STAMP_MIN_PT;
let h = pt * PT_MM * scale / 1000.0;
let max_chars = (room_w * 0.95 / (STAMP_CHAR_W * h)).floor() as usize;
let longest = name_chars.iter().copied().max().unwrap_or(0);
(extra, pt, (longest > max_chars).then_some(max_chars.max(2)))
(Vec::new(), pt, Some(doc_from_text(&abbreviate(&text, 2))), None)
}
/// [140] Lagen für einen Raumstempel ohne eigenen Anker: zuerst der Pol der Unzugänglichkeit, dann Punkte
/// eines Rasters über dem Raum (nach Abstand zum Pol) — passt der Stempel am Pol nicht (L-Raum, Name breiter
/// als der Flügel um den Pol), rückt er dorthin, wo er ganz im Raum liegt.
fn stamp_candidates(ring: &[[f64; 2]], pole: Vec2) -> Vec<Vec2> {
const N: usize = 24;
let (mut x0, mut y0, mut x1, mut y1) = (f64::INFINITY, f64::INFINITY, f64::NEG_INFINITY, f64::NEG_INFINITY);
for q in ring {
x0 = x0.min(q[0]);
y0 = y0.min(q[1]);
x1 = x1.max(q[0]);
y1 = y1.max(q[1]);
}
let mut out = vec![pole];
if !(x1 > x0 && y1 > y0) {
return out;
}
let mut grid: Vec<Vec2> = (0..N)
.flat_map(|i| (0..N).map(move |j| Vec2 { x: x0 + (x1 - x0) * (i as f64 + 0.5) / N as f64, y: y0 + (y1 - y0) * (j as f64 + 0.5) / N as f64 }))
.filter(|q| crate::room_area::rect_in_ring(ring, q.x, q.y, 0.0, 0.0))
.collect();
let d = |q: &Vec2| (q.x - pole.x) * (q.x - pole.x) + (q.y - pole.y) * (q.y - pole.y);
grid.sort_by(|a, b| d(a).total_cmp(&d(b)));
out.extend(grid);
out
}
/// Namenszeilen auf `n` Zeichen kürzen (n − 1 Zeichen und Punkt), Leerzeichen am Schnitt weg.
@@ -672,7 +732,10 @@ fn rooms(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) {
if c.a.detail == Detail::Grob && !c.a.auto_coarse {
continue;
}
let at = room.stamp_anchor.unwrap_or(pv(res.centroid));
// [140] Ohne eigenen Anker: Pol der Unzugänglichkeit (liegt auch in L-Räumen im Raum); passt der
// Stempel dort nicht, rückt er im Raum dorthin, wo er passt (`stamp_candidates`).
let pole = pv(crate::room_area::label_point(&pts));
let at = room.stamp_anchor.unwrap_or(pole);
let small = c.a.scale >= ROOM_STAMP_SMALL_FROM;
// [140] Übersicht (ab 1:500, automatisch grob): nur der Name.
let overview = c.a.auto_coarse && c.a.scale >= OVERVIEW_FROM;
@@ -692,15 +755,15 @@ fn rooms(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) {
(room.stamp_doc.clone().unwrap_or_else(|| doc_from_text(&room.name)), lines)
}
};
let (x0, x1) = room.boundary.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |a, q| (a.0.min(q.x), a.1.max(q.x)));
let (y0, y1) = room.boundary.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |a, q| (a.0.min(q.y), a.1.max(q.y)));
let name_chars: Vec<usize> = crate::text_layout::plain_text(&doc).split('\n').map(|l| l.chars().count()).collect();
let (extra_lines, base_pt, cut) = fit_room_stamp(&name_chars, extra_lines, if small { ROOM_STAMP_SMALL_PT } else { ROOM_STAMP_PT }, c.a.scale, x1 - x0, y1 - y0);
// Passt der Name selbst in 2 mm nicht: gekürzt (z. B. „Treppenh."), ohne Auszeichnungen.
let doc = match cut {
Some(n) => doc_from_text(&abbreviate(&crate::text_layout::plain_text(&doc), n)),
None => doc,
let candidates = if room.stamp_anchor.is_some() { vec![at] } else { stamp_candidates(&pts, pole) };
// Mit Luft (1.3 × Breite/Höhe) zuerst, damit der Stempel nicht an der Wand klebt; sonst knapp.
let place = |w: f64, h: f64| {
let fit = |k: f64| candidates.iter().copied().find(|q| crate::room_area::rect_in_ring(&pts, q.x, q.y, k * w / 2.0, k * h / 2.0));
fit(1.3).or_else(|| fit(1.0))
};
let (extra_lines, base_pt, name, placed) = fit_room_stamp(&doc, extra_lines, if small { ROOM_STAMP_SMALL_PT } else { ROOM_STAMP_PT }, c.a.scale, &place);
let at = placed.unwrap_or(at);
let doc = name.unwrap_or(doc);
out.push(Primitive::Text { at, doc, extra_lines, base_pt, color: text_color.into(), room_id: Some(room.id.clone()), greyed, opacity: None });
}
}
@@ -742,6 +805,11 @@ pub(super) fn columns(c: &Ctx, out: &mut Vec<Primitive>) {
hatch = h;
}
}
// [140] Geschnittene Stütze ab 1:100 schwarz ohne Schraffur (`style::solid_cut`).
if zone == super::view_range::Zone::Cut && c.solid_cut() {
fill = HATCH_INK.to_string();
hatch = no_hatch();
}
let fp = crate::model3d::column_footprint(col);
// [141] Geschnittene Wände, die in der (geschnittenen) Stütze enden: prioritärere Wand beschneidet
// die Stütze, gleiches Bauteil verschmilzt (Kontur über diesen Schichten fehlt).
@@ -842,7 +910,8 @@ fn solids(c: &Ctx, out: &mut Vec<Primitive>) {
// [G1] Schnittfläche auf Schnitthöhe (Poché); der Umriss darunter bleibt als Projektion.
if zone == super::view_range::Zone::Cut {
if let Some(ring) = body_cut_ring(s, zb, range.cut) {
out.push(polygon(ring, super::section::BODY_FILL, POCHE_STROKE, WALL_FALLBACK_MM, super::section::section_hatch(), None, None, Pick::Solid(&s.id)));
let (fill, hatch) = if c.solid_cut() { (HATCH_INK, no_hatch()) } else { (super::section::BODY_FILL, super::section::section_hatch()) };
out.push(polygon(ring, fill, POCHE_STROKE, WALL_FALLBACK_MM, hatch, None, None, Pick::Solid(&s.id)));
}
}
}
@@ -1154,8 +1223,9 @@ mod tests {
};
assert_eq!(stamp(100.0), (ROOM_STAMP_PT, 2));
assert_eq!(stamp(200.0), (ROOM_STAMP_SMALL_PT, 1));
// [140] 1:500 (mittel → automatisch grob): nur der Name; Stempel in Tinte.
assert_eq!(stamp(500.0), (ROOM_STAMP_SMALL_PT, 0));
// [140] 1:500 (mittel → automatisch grob): nur der Name; Stempel in Tinte. „Wohnen" ist in 7 pt
// (Inter-Metrik 3.9 em ≈ 9.7 mm) breiter als der 9.3 mm breite Raum → 2 mm Schrift.
assert_eq!(stamp(500.0), (ROOM_STAMP_MIN_PT, 0));
let t = serde_json::json!({ "floor": "eg", "show": ["20", "60"], "grey": [], "scale": 100 }).to_string();
let r = plan_domains(&p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap();
assert!(r.rooms.iter().all(|q| !matches!(q, Primitive::Text { color, .. } if color != MONO_INK)), "Stempel in Tinte");
@@ -1172,26 +1242,98 @@ mod tests {
}
/// [140] Enger Raum: erst ohne Nutzungszeile, dann ohne Fläche, dann 2 mm Schrift; grosser Raum unverändert.
/// Breite aus der Schriftmetrik (Inter), Platz aus dem Raumumriss um den Anker.
#[test]
fn raumstempel_passt_in_engen_raum() {
let extra = || vec![StampLine { text: "4.6 m²".into(), align: Align::Center }, StampLine { text: "NNF · Nebennutzfläche".into(), align: Align::Center }];
let name = [8usize]; // „E.04 Bad"
let (e, pt, cut) = fit_room_stamp(&name, extra(), ROOM_STAMP_PT, 100.0, 6.0, 4.0);
assert_eq!((e.len(), pt, cut), (2, ROOM_STAMP_PT, None));
let (e, pt, _) = fit_room_stamp(&name, extra(), ROOM_STAMP_PT, 100.0, 1.8, 2.4);
let name = doc_from_text("E.04 Bad");
let room = |w: f64, h: f64| move |sw: f64, sh: f64| (sw <= w && sh <= h).then_some(Vec2 { x: 0.0, y: 0.0 });
let (e, pt, d, _) = fit_room_stamp(&name, extra(), ROOM_STAMP_PT, 100.0, &room(6.0, 4.0));
assert_eq!((e.len(), pt, d.is_none()), (2, ROOM_STAMP_PT, true));
let (e, pt, _, _) = fit_room_stamp(&name, extra(), ROOM_STAMP_PT, 100.0, &room(1.8, 2.4));
assert_eq!((e.len(), pt), (1, ROOM_STAMP_PT), "ohne Nutzung");
let (e, pt, _) = fit_room_stamp(&name, extra(), ROOM_STAMP_PT, 100.0, 1.8, 0.8);
let (e, pt, _, _) = fit_room_stamp(&name, extra(), ROOM_STAMP_PT, 100.0, &room(1.8, 0.6));
assert_eq!((e.len(), pt), (0, ROOM_STAMP_PT), "nur der Name");
let (e, pt, cut) = fit_room_stamp(&name, extra(), ROOM_STAMP_PT, 100.0, 1.2, 0.8);
assert_eq!((e.len(), cut), (0, None));
let (e, pt, d, at) = fit_room_stamp(&name, extra(), ROOM_STAMP_PT, 100.0, &room(1.2, 0.8));
// In 2 mm passt die Flächenzeile wieder dazu.
assert_eq!((e.len(), d.is_none(), at.is_some()), (1, true, true));
assert!((pt * PT_MM - 2.0).abs() < 1e-9, "2 mm Papier");
// 1:500, „Treppenhaus" in 3 m: auch 2 mm (1 m Schrift) zu breit → gekürzt.
let (_, _, cut) = fit_room_stamp(&[11], vec![], ROOM_STAMP_SMALL_PT, 500.0, 3.0, 4.0);
assert_eq!(cut, Some(5));
// 1:500, „Treppenhaus" in 3 m: auch 2 mm (1 m Schrift) zu breit → gekürzt, so dass es passt.
let (_, _, d, _) = fit_room_stamp(&doc_from_text("Treppenhaus"), vec![], ROOM_STAMP_SMALL_PT, 500.0, &room(3.0, 4.0));
let t = crate::text_layout::plain_text(&d.unwrap());
assert!(t.ends_with('.') && t.len() >= 4 && t.len() <= 7, "{t}");
let (w, _) = stamp_size_m(&doc_from_text(&t), &[], ROOM_STAMP_MIN_PT, 500.0);
assert!(w <= 3.0, "{w}");
// Name mit eigener Grösse (12 pt fett) schrumpft nicht mit der Schrift: in 2 mm ohne Auszeichnung.
let s = RoomStamp { number: Some("E.03".into()), name: "Wohnen/Essen".into(), ..Default::default() };
let (_, _, d, _) = fit_room_stamp(&room_stamp_to_doc(&s), vec![], ROOM_STAMP_PT, 100.0, &room(3.0, 2.0));
assert_eq!(crate::text_layout::plain_text(&d.unwrap()), "E.03 Wohnen/Essen");
// Schmale Zeichen passen besser als breite (echte Metrik statt fester Zeichenbreite).
let (wi, _) = stamp_size_m(&doc_from_text("Lift"), &[], ROOM_STAMP_PT, 100.0);
let (ww, _) = stamp_size_m(&doc_from_text("WMWM"), &[], ROOM_STAMP_PT, 100.0);
assert!(wi < 0.6 * ww, "{wi} {ww}");
assert_eq!(abbreviate("Treppenhaus", 5), "Trep.");
assert_eq!(abbreviate("Bad", 5), "Bad");
}
/// [140] L-förmiger Raum ohne eigenen Anker: Stempel im Raum (Pol der Unzugänglichkeit), nicht am
/// Schwerpunkt ausserhalb; Platz für den Stempel aus dem Flügel, nicht aus der Bounding-Box.
#[test]
fn raumstempel_im_l_raum() {
let mut p = sample();
let rooms = p.rooms.as_mut().unwrap();
let r = rooms.iter_mut().find(|r| r.floor_id == "eg").unwrap();
let l = [(0.0, 0.0), (8.0, 0.0), (8.0, 1.2), (1.2, 1.2), (1.2, 8.0), (0.0, 8.0)];
r.boundary = l.iter().map(|&(x, y)| Vec2 { x: x + 50.0, y: y + 50.0 }).collect();
r.stamp_anchor = None;
r.stamp = None;
let id = r.id.clone();
let t = serde_json::json!({ "floor": "eg", "show": ["20", "60"], "grey": [], "scale": 100 }).to_string();
let out = plan_domains(&p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap();
let (at, extra) = out.rooms.iter().find_map(|q| match q { Primitive::Text { at, room_id: Some(rid), extra_lines, .. } if *rid == id => Some((*at, extra_lines.len())), _ => None }).unwrap();
let ring: Vec<[f64; 2]> = l.iter().map(|&(x, y)| [x + 50.0, y + 50.0]).collect();
assert!(crate::room_area::rect_in_ring(&ring, at.x, at.y, 0.01, 0.01), "Anker im Raum: {at:?}");
// Die Bounding-Box (8 × 8 m) hätte alle Zeilen erlaubt; der 1.2 m breite Flügel weniger.
assert!(extra < 2, "{extra}");
// Langer Name: rückt im Flügel vom Pol weg, bis er ganz im Raum liegt (statt gekürzt zu werden).
p.rooms.as_mut().unwrap().iter_mut().find(|r| r.id == id).unwrap().name = "Wohnen Essen Kochen".into();
let out = plan_domains(&p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap();
let (at, doc) = out.rooms.iter().find_map(|q| match q { Primitive::Text { at, room_id: Some(rid), doc, .. } if *rid == id => Some((*at, doc.clone())), _ => None }).unwrap();
assert_eq!(crate::text_layout::plain_text(&doc), "Wohnen Essen Kochen");
let (w, _) = stamp_size_m(&doc, &[], ROOM_STAMP_PT, 100.0);
assert!(crate::room_area::rect_in_ring(&ring, at.x, at.y, w / 2.0, 0.1), "{at:?} {w}");
}
/// [140] Teil 5: Schnittflächen ab 1:100 schwarz (Wände als Sammelfläche ohne Fugen/Schraffur, Stützen
/// schwarz), 1:50 mit Schichten und Schraffur; Ebene „Schnittflächen schraffiert" übersteuert das 1:100.
#[test]
fn schnittflaechen_schwarz_ab_1_100() {
let mut p = sample();
p.columns = Some(vec![Column { id: "S1".into(), floor_id: "eg".into(), category_code: "20".into(), position: Vec2 { x: 2.0, y: 2.0 }, profile: ColumnProfile::Rect { width: 0.3, depth: 0.3 }, height: 2.6, component_id: p.components.first().map(|c| c.id.clone()), ..Default::default() }]);
let run = |p: &Project, scale: f64| {
let t = serde_json::json!({ "floor": "eg", "show": ["20"], "grey": [], "scale": scale }).to_string();
plan_domains(p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap()
};
let walls = |r: &DomainPrims| {
let hatched = r.walls.iter().filter(|q| matches!(q, Primitive::Polygon { hatch, .. } if hatch.pattern != HatchPattern::None)).count();
let ink = r.walls.iter().filter(|q| matches!(q, Primitive::Polygon { fill, .. } if fill == HATCH_INK)).count();
let joints = r.walls.iter().filter(|q| matches!(q, Primitive::Line { cls, .. } if cls.starts_with("layer-joint"))).count();
(hatched, ink, joints)
};
let col_fill = |r: &DomainPrims| r.columns.iter().find_map(|q| match q { Primitive::Polygon { fill, hatch, column_id: Some(_), .. } => Some((fill.clone(), hatch.pattern)), _ => None }).unwrap();
let r100 = run(&p, 100.0);
let (h, ink, j) = walls(&r100);
assert!(h == 0 && ink > 0 && j == 0, "1:100 schwarz: {h} {ink} {j}");
assert_eq!(col_fill(&r100), (HATCH_INK.to_string(), HatchPattern::None));
let r50 = run(&p, 50.0);
let (h, ink, _) = walls(&r50);
assert!(h > 0 && ink == 0, "1:50 schraffiert: {h} {ink}");
assert_ne!(col_fill(&r50).0, HATCH_INK);
p.drawing_levels.iter_mut().find(|l| l.id == "eg").unwrap().cut_hatch = Some(true);
let (h, ink, _) = walls(&run(&p, 100.0));
assert!(h > 0 && ink == 0, "Ebene schraffiert: {h} {ink}");
}
/// [140] „mittel" ab 1:200 wie „grob" (Wände als Sammelfläche), „fein" bleibt; explizit „grob" ohne Stempel.
#[test]
fn mittel_ab_1_200_automatisch_grob() {
@@ -1579,8 +1721,9 @@ mod tests {
p.ceilings = Some(vec![]);
p.rooms = Some(vec![]);
p.walls[0].bulge = Some(1.0); // Halbkreis (0,0)→(5,0), Mitte (2.5,0), r 2.5, Scheitel oben
// Detail „fein": alle Schichten (mittel fasst ab 1:50 dünne Schichten zusammen, [140]).
let t = serde_json::json!({ "floor": "eg", "show": ["20"], "grey": [], "scale": 50 }).to_string();
let r = plan_domains(&p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap();
let r = plan_domains(&p, &PlanArgs::parse(2.0, &t).unwrap()).unwrap();
let (r_in, r_out) = (2.5 - 0.345 / 2.0, 2.5 + 0.345 / 2.0);
let mut band_area = 0.0;
let mut arcs = 0;
@@ -1636,6 +1779,8 @@ mod tests {
..Default::default()
};
p.extruded_solids = Some(vec![mk("block", 0.0, 2.0, None, None), mk("pyr", 0.0, 2.0, Some(1.0), None), mk("hoch", 1.5, 1.0, None, None), mk("void", 0.0, 2.0, None, Some("subtract"))]);
// [140] Ebene „Schnittflächen schraffiert" (sonst ab 1:100 schwarz, s. unten).
p.drawing_levels.iter_mut().find(|l| l.id == "eg").unwrap().cut_hatch = Some(true);
let cut = super::super::extras::cut_z(&p, "eg");
let base = p.floor("eg").and_then(|f| f.base_elevation).unwrap_or(0.0);
assert!(cut > base && cut < base + 1.5, "Schnitthöhe {cut}");
+56 -22
View File
@@ -83,6 +83,8 @@ pub struct LevelSpec {
pub hidden_lines: bool,
/// Skizzenstil ([67]).
pub sketch: bool,
/// [140] Schnittflächen auch ab 1:100 schraffiert statt schwarz (`style::solid_cut`).
pub cut_hatch: bool,
}
impl LevelSpec {
@@ -98,6 +100,7 @@ impl LevelSpec {
shadows: v.get("shadows").and_then(|b| b.as_bool()).unwrap_or(false),
hidden_lines: v.get("hiddenLines").and_then(|b| b.as_bool()).unwrap_or(false),
sketch: v.get("sketch").and_then(|b| b.as_bool()).unwrap_or(false),
cut_hatch: v.get("cutHatch").and_then(|b| b.as_bool()).unwrap_or(false),
}
}
@@ -2265,10 +2268,6 @@ impl Acc {
}
}
/// [140] Ab diesem Massstab (1:75 und kleiner) gehen dünne geschnittene Schichten in der Nachbarschicht auf
/// (Detail „mittel" ab 1:100 wie die Wände im Grundriss, `walls::thin_layer_targets`); 1:50 zeigt alle.
const THIN_MERGE_FROM: f64 = 75.0;
fn ring_len(r: &[[f64; 2]]) -> f64 {
(0..r.len()).map(|i| { let (a, b) = (r[i], r[(i + 1) % r.len()]); hypot2(b[0] - a[0], b[1] - a[1]) }).sum()
}
@@ -2286,11 +2285,11 @@ fn ring_bbox(r: &[[f64; 2]]) -> [f64; 4] {
r.iter().fold([f64::INFINITY, f64::INFINITY, f64::NEG_INFINITY, f64::NEG_INFINITY], |b, q| [b[0].min(q[0]), b[1].min(q[1]), b[2].max(q[0]), b[3].max(q[1])])
}
/// [140] Dämmschichten (Dämmschlange, Zickzack, Welle) unter [`THIN_INSULATION_PAPER_MM`] Papierdicke ab 1:75
/// [140] Dämmschichten (Dämmschlange, Zickzack, Welle) unter der gemeinsamen Schwelle (`style::is_thin_layer`, 0.5 mm Papier) ab 1:75
/// ohne Muster (nur Füllung und feine Fuge): die Schlange einer 3–4 cm Trittschalldämmung wäre in 1:100 ein
/// dichter Zickzack-Balken. 1:50 (und `scale` 0) zeichnet sie immer.
pub fn plain_thin_insulation(mut cuts: Vec<Cut>, scale: f64) -> Vec<Cut> {
if !(scale >= THIN_MERGE_FROM) || !scale.is_finite() {
if !simplify_thin_layers(Detail::Mittel, scale) {
return cuts;
}
for c in &mut cuts {
@@ -2300,28 +2299,25 @@ pub fn plain_thin_insulation(mut cuts: Vec<Cut>, scale: f64) -> Vec<Cut> {
}
let half = ring_len(&c.pts) / 2.0;
let thick = if half > 0.0 { ring_area(&c.pts) / half } else { 0.0 };
if thick * 1000.0 / scale < THIN_INSULATION_PAPER_MM {
if is_thin_layer(thick, scale) {
h.pattern = HatchPattern::None;
}
}
cuts
}
/// [140] Papierdicke (mm), unter der Dämmschichten ab 1:75 ohne Muster gezeichnet werden.
pub const THIN_INSULATION_PAPER_MM: f64 = 0.5;
/// [140] Dünne Schnitt-Schichten (Putz, Parkett, Trittschall, Folien) bei 1:`scale` zusammenfassen: eine Schicht
/// unter [`walls::THIN_LAYER_PAPER_MM`] Papierdicke (Dicke ≈ Fläche / halber Umfang) übernimmt Füllung und
/// unter 0.5 mm Papierdicke (`style::is_thin_layer`; Dicke ≈ Fläche / halber Umfang) übernimmt Füllung und
/// Schraffur der dickeren Nachbarschicht desselben Bauteils, mit der sie die längste Kante teilt, und wird mit
/// ihr zu einer Fläche vereinigt (keine Fuge dazwischen). Unter 1:75 (oder `scale` 0) unverändert.
pub fn merge_thin_cuts(cuts: &[Cut], scale: f64) -> Vec<Cut> {
if !(scale >= THIN_MERGE_FROM) || !scale.is_finite() {
if !simplify_thin_layers(Detail::Mittel, scale) {
return cuts.to_vec();
}
let n = cuts.len();
let mergeable = |c: &Cut| matches!(c.kind, Kind::Wall | Kind::Slab | Kind::Roof) && c.stair_id.is_none() && c.pts.len() >= 3;
let thick: Vec<f64> = cuts.iter().map(|c| { let half = ring_len(&c.pts) / 2.0; if half > 0.0 { ring_area(&c.pts) / half } else { 0.0 } }).collect();
let thin: Vec<bool> = (0..n).map(|i| mergeable(&cuts[i]) && thick[i] > 0.0 && thick[i] * 1000.0 / scale < super::walls::THIN_LAYER_PAPER_MM).collect();
let thin: Vec<bool> = (0..n).map(|i| mergeable(&cuts[i]) && thick[i] > 0.0 && is_thin_layer(thick[i], scale)).collect();
if !thin.iter().any(|t| *t) {
return cuts.to_vec();
}
@@ -2396,12 +2392,16 @@ pub fn merge_thin_cuts(cuts: &[Cut], scale: f64) -> Vec<Cut> {
/// `generateSectionPlan`: Primitive (u → x, Höhe → y) und Ausmass.
pub fn section_primitives(out: &Output, mono: bool, hidden_lines: bool, vis: &Visibility) -> (Vec<Primitive>, [f64; 4]) {
section_primitives_at(out, mono, hidden_lines, vis, 0.0)
section_primitives_at(out, mono, hidden_lines, vis, 0.0, Detail::Mittel, false)
}
/// [`section_primitives`] beim Massstab 1:`scale` (dünne Schichten zusammengefasst, [`merge_thin_cuts`]).
pub fn section_primitives_at(out: &Output, mono: bool, hidden_lines: bool, vis: &Visibility, scale: f64) -> (Vec<Primitive>, [f64; 4]) {
let merged = plain_thin_insulation(merge_thin_cuts(&out.cuts, scale), scale);
/// [`section_primitives`] beim Massstab 1:`scale` (dünne Schichten zusammengefasst, [`merge_thin_cuts`];
/// Detail „fein" zeigt alle Schichten, `style::simplify_thin_layers`). Ab 1:100 (`style::solid_cut`, ausser
/// `cut_hatch`/„fein") sind die geschnittenen Flächen schwarz ohne Fugen und Schraffur, nur mit dem Umriss.
pub fn section_primitives_at(out: &Output, mono: bool, hidden_lines: bool, vis: &Visibility, scale: f64, detail: Detail, cut_hatch: bool) -> (Vec<Primitive>, [f64; 4]) {
let black = solid_cut(detail, scale, cut_hatch);
let thin_scale = if simplify_thin_layers(detail, scale) && !black { scale } else { 0.0 };
let merged = plain_thin_insulation(merge_thin_cuts(&out.cuts, thin_scale), thin_scale);
let mut prims = Vec::new();
let mut acc = Acc::new();
let shown = |code: &str| vis.visible(code) && vis.render(code);
@@ -2438,7 +2438,9 @@ pub fn section_primitives_at(out: &Output, mono: bool, hidden_lines: bool, vis:
let fill = cp.fill.as_deref().unwrap_or(HATCH_PAPER);
let hatch = cp.hatch.clone().unwrap_or_else(section_hatch);
let solid = hatch.pattern == HatchPattern::Solid;
let (fill, hatch) = if mono {
let (fill, hatch) = if black {
(HATCH_INK.to_string(), no_hatch())
} else if mono {
let mono_fill = if solid { HATCH_INK } else { HATCH_PAPER };
let mono_hatch = if !solid && hatch.pattern != HatchPattern::None { HatchRender { color: SECTION_INK.into(), ..hatch } } else { hatch };
(mono_fill.to_string(), mono_hatch)
@@ -2446,7 +2448,7 @@ pub fn section_primitives_at(out: &Output, mono: bool, hidden_lines: bool, vis:
(fill.to_string(), hatch)
};
let src = cp.source_id.clone();
let mut pr = polygon(pts, &fill, SECTION_INK, SECTION_JOINT_MM, hatch);
let mut pr = if black { polygon(pts, &fill, "none", 0.0, hatch) } else { polygon(pts, &fill, SECTION_INK, SECTION_JOINT_MM, hatch) };
if let Primitive::Polygon { wall_id, ceiling_id, roof_id, stair_id, extruded_solid_id, no_stroke_edges, greyed, .. } = &mut pr {
*wall_id = if cp.kind == Kind::Wall { src.clone() } else { None };
*ceiling_id = if cp.kind == Kind::Slab && cp.stair_id.is_none() { src.clone() } else { None };
@@ -2955,7 +2957,8 @@ pub fn section_plan_buf(p: &Project, args: &[f64], text: &str) -> Result<Vec<u8>
};
let hidden = v.get("hiddenLines").and_then(|b| b.as_bool()).unwrap_or(false);
let scale = v.get("scale").and_then(|s| s.as_f64()).filter(|s| *s > 0.0 && s.is_finite()).unwrap_or(100.0);
let (mut prims, bounds) = section_primitives_at(&out, mono, hidden, &vis, scale);
let detail = Detail::parse(v.get("detail").and_then(|d| d.as_str()).unwrap_or("mittel"));
let (mut prims, bounds) = section_primitives_at(&out, mono, hidden, &vis, scale, detail, level.cut_hatch);
w.post = super::extras::sketch_post(Some(level.sketch), scale);
// Strichstärken nach Massstab ([32]) wie im Grundriss.
super::extras::scale_line_weights(p, scale, &mut prims);
@@ -3142,7 +3145,8 @@ mod tests {
};
// Parkett 1 cm, Unterlagsboden 8 cm, Trittschall 2 cm, Beton 22 cm, Putz 1 cm
let cuts = vec![mk(0.32, 0.33, "#a"), mk(0.24, 0.32, "#b"), mk(0.22, 0.24, "#c"), mk(0.0, 0.22, "#d"), mk(-0.01, 0.0, "#e")];
assert_eq!(merge_thin_cuts(&cuts, 50.0).len(), 5, "1:50: alle Schichten");
assert_eq!(merge_thin_cuts(&cuts, 20.0).len(), 5, "1:20: alle Schichten");
assert_eq!(merge_thin_cuts(&cuts, 50.0).len(), 2, "1:50 (Teil 5): dünne Schichten zusammengefasst");
let m = merge_thin_cuts(&cuts, 100.0);
assert_eq!(m.len(), 2, "{:?}", m.iter().map(|c| (c.fill.clone(), ring_bbox(&c.pts))).collect::<Vec<_>>());
let total: f64 = m.iter().map(|c| ring_area(&c.pts)).sum();
@@ -3159,6 +3163,36 @@ mod tests {
let mut other = cuts.clone();
other[0].source_id = Some("D2".into());
assert!(merge_thin_cuts(&other, 100.0).iter().any(|c| c.fill.as_deref() == Some("#a")));
// [140] Teil 5: Trittschall 4 cm (0.4 mm Papier) geht in 1:100 auf, Unterlagsboden 6.5 cm bleibt.
let cuts = vec![mk(0.30, 0.315, "#a"), mk(0.235, 0.30, "#b"), mk(0.195, 0.235, "#c"), mk(0.0, 0.195, "#d")];
let m = merge_thin_cuts(&cuts, 100.0);
assert_eq!(m.len(), 2);
assert!(m.iter().all(|c| c.fill.as_deref() != Some("#c") && c.fill.as_deref() != Some("#a")));
assert_eq!(merge_thin_cuts(&cuts, 50.0).len(), 3, "1:50: Trittschall (0.8 mm) bleibt, Parkett nicht");
assert_eq!(merge_thin_cuts(&cuts, 20.0).len(), 4);
}
/// [140] Teil 5: Schnitt 1:100 — geschnittene Flächen schwarz ohne Fuge/Schraffur, Umriss bleibt;
/// 1:50, „fein" und `cutHatch` mit Schraffur und Fugen.
#[test]
fn schnittflaechen_schwarz_ab_1_100() {
let p = sample();
let l = level(&p, "schnitt-a");
let out = compute_section(&p, &l, &[]).unwrap().unwrap();
let vis = Visibility::default();
let stat = |scale: f64, detail: Detail, cut_hatch: bool| {
let (prims, _) = section_primitives_at(&out, true, false, &vis, scale, detail, cut_hatch);
let cuts: Vec<_> = prims.iter().filter_map(|q| match q { Primitive::Polygon { fill, hatch, stroke, wall_id, ceiling_id, .. } if wall_id.is_some() || ceiling_id.is_some() => Some((fill.clone(), hatch.pattern, stroke.clone())), _ => None }).collect();
let outline = prims.iter().filter(|q| matches!(q, Primitive::Line { cls, .. } if cls == "section-cut-outline")).count();
(cuts, outline)
};
let (c, o) = stat(100.0, Detail::Mittel, false);
assert!(!c.is_empty() && o > 0);
assert!(c.iter().all(|(f, h, s)| f == HATCH_INK && *h == HatchPattern::None && s == "none"), "{c:?}");
for (scale, detail, ch) in [(50.0, Detail::Mittel, false), (100.0, Detail::Fein, false), (100.0, Detail::Mittel, true)] {
let (c, _) = stat(scale, detail, ch);
assert!(c.iter().any(|(f, h, s)| f != HATCH_INK && *h != HatchPattern::None && s != "none"), "{scale} {detail:?} {ch}");
}
}
/// [140] Trittschall 4 cm: 1:100 (0.4 mm Papier) ohne Zickzack, 1:50 mit; dicke Dämmung bleibt.
@@ -3817,7 +3851,7 @@ mod ts_faelle {
let mut p = Project::default();
// quer: von der Ebene geschnitten und weit nach hinten; nah: 3 m, fern: 10 m hinter der Ebene (höher).
p.walls = vec![wall("quer", (0.0, -1.0), (0.0, 12.0), 2.5), wall("nah", (2.0, 3.0), (6.0, 3.0), 2.5), wall("fern", (2.0, 10.0), (6.0, 10.0), 4.0)];
let lv = |depth: Option<f64>| LevelSpec { sketch: false, kind: "section".into(), line: Some([Vec2 { x: -1.0, y: 0.0 }, Vec2 { x: 8.0, y: 0.0 }]), direction_sign: Some(1.0), depth, shadows: false, hidden_lines: false };
let lv = |depth: Option<f64>| LevelSpec { sketch: false, cut_hatch: false, kind: "section".into(), line: Some([Vec2 { x: -1.0, y: 0.0 }, Vec2 { x: 8.0, y: 0.0 }]), direction_sign: Some(1.0), depth, shadows: false, hidden_lines: false };
let top = |o: &Output| o.visible.iter().map(|e| e.a[1].max(e.b[1])).fold(f64::NEG_INFINITY, f64::max);
let all = compute_section(&p, &lv(None), &[]).unwrap().unwrap();
assert!(top(&all) > 3.9, "ohne Tiefe ist die ferne Wand sichtbar: {}", top(&all));
+59
View File
@@ -65,6 +65,39 @@ impl Detail {
}
}
/// [140] Dünne Schichten (Putz, Parkett, Trittschall, Folien, dünne Dämmung) unter dieser Papierdicke (mm)
/// werden ab [`THIN_FROM_SCALE`] nicht als eigene Schicht mit Fugen gezeichnet: sonst laufen Umriss, Fuge und
/// Schraffur in 1:100 zu einem schwarzen Balken zusammen. Eine Regel für Wände im Grundriss
/// (`walls::thin_layer_targets`) und Schnitt-Schichten (`section::merge_thin_cuts`, `plain_thin_insulation`).
pub const THIN_LAYER_PAPER_MM: f64 = 0.5;
/// [140] Ab diesem Massstab (1:50 und kleiner) werden dünne Schichten vereinfacht (Teil 5: ab 1:100 sind
/// Schnittflächen ohnehin schwarz, [`solid_cut`] — die Regel wirkt v. a. im 1:50); 1:20/1:25 zeigt alle.
pub const THIN_FROM_SCALE: f64 = 50.0;
/// [140] Werden bei Detailgrad `detail` und 1:`scale` dünne Schichten vereinfacht? „fein" zeigt immer alle,
/// ebenso Massstäbe grösser als 1:50 (und ein unbekannter Massstab 0/NaN).
pub fn simplify_thin_layers(detail: Detail, scale: f64) -> bool {
detail != Detail::Fein && scale.is_finite() && scale >= THIN_FROM_SCALE
}
/// [140] Ab diesem Massstab (1:75 und kleiner, also 1:100) sind Schnittflächen schwarz.
pub const SOLID_CUT_FROM: f64 = 75.0;
/// [140] Schnittflächen (Wände, Stützen, Körper im Grundriss; alle geschnittenen Bauteile im Schnitt) als
/// volle schwarze Fläche ohne Schichtfugen und Schraffur, nur mit Umriss (Vorgabe Maintainer: „Schraffur-
/// Bauteile im 1:50 zeigen, das 1:100 wird i. d. R. schwarz angezeigt")? Ab 1:100 ja, Detail „grob" immer;
/// „fein" und `cut_hatch` (Feld der Ebene/Ansichtsvorlage „Schnittflächen schraffiert") behalten die
/// Schichten mit Schraffur.
pub fn solid_cut(detail: Detail, scale: f64, cut_hatch: bool) -> bool {
detail == Detail::Grob || (!cut_hatch && detail != Detail::Fein && scale.is_finite() && scale >= SOLID_CUT_FROM)
}
/// [140] Ist eine Schicht der Dicke `thickness_m` (Meter) bei 1:`scale` auf dem Papier dünn
/// (unter [`THIN_LAYER_PAPER_MM`])? Nur zusammen mit [`simplify_thin_layers`] verwenden.
pub fn is_thin_layer(thickness_m: f64, scale: f64) -> bool {
!(thickness_m * 1000.0 / scale >= THIN_LAYER_PAPER_MM)
}
/// Schraffur-Platzhalter „ohne" (für reine Umriss-/Sammelflächen).
pub fn no_hatch() -> HatchRender {
HatchRender {
@@ -272,3 +305,29 @@ mod tests {
assert_eq!(d.color, HATCH_INK);
}
}
#[cfg(test)]
mod thin_tests {
use super::*;
/// [140] Eine Regel: unter 0.5 mm Papier ist dünn (5 cm in 1:100, 10 cm in 1:200), ab 1:75 ausser „fein".
#[test]
fn duenne_schicht_regel() {
assert!(simplify_thin_layers(Detail::Mittel, 100.0) && simplify_thin_layers(Detail::Grob, 200.0));
assert!(simplify_thin_layers(Detail::Mittel, 50.0), "Teil 5: auch 1:50");
assert!(!simplify_thin_layers(Detail::Mittel, 20.0) && !simplify_thin_layers(Detail::Fein, 100.0));
assert!(!simplify_thin_layers(Detail::Mittel, 0.0) && !simplify_thin_layers(Detail::Mittel, f64::NAN));
assert!(is_thin_layer(0.015, 100.0) && is_thin_layer(0.04, 100.0) && is_thin_layer(0.0499, 100.0));
assert!(!is_thin_layer(0.06, 100.0) && !is_thin_layer(0.05, 100.0));
assert!(is_thin_layer(0.08, 200.0) && !is_thin_layer(0.04, 50.0) && is_thin_layer(0.02, 50.0));
}
/// [140] Schnittflächen: 1:100 schwarz, 1:50 schraffiert; „fein" und `cutHatch` schraffiert, „grob" schwarz.
#[test]
fn schnittflaeche_schwarz_ab_1_100() {
assert!(solid_cut(Detail::Mittel, 100.0, false) && solid_cut(Detail::Mittel, 200.0, false));
assert!(!solid_cut(Detail::Mittel, 50.0, false) && !solid_cut(Detail::Fein, 100.0, false));
assert!(!solid_cut(Detail::Mittel, 100.0, true), "Vorlage: schraffiert");
assert!(solid_cut(Detail::Grob, 50.0, true) && !solid_cut(Detail::Mittel, f64::NAN, false));
}
}
+2 -2
View File
@@ -56,10 +56,10 @@ fn polar(o: (f64, f64), r: f64, deg: f64) -> (f64, f64) {
(o.0 + r * a.cos(), o.1 + r * a.sin())
}
/// Wand- und Stützen-Primitive des Erdgeschosses (1:50, Detail mittel).
/// Wand- und Stützen-Primitive des Erdgeschosses (1:50, Detail fein, alle Schichten).
fn prims(p: &Project) -> Vec<Primitive> {
let t = serde_json::json!({ "floor": "eg", "show": ["20"], "grey": [], "scale": 50 }).to_string();
let d = plan_domains(p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap();
let d = plan_domains(p, &PlanArgs::parse(2.0, &t).unwrap()).unwrap();
d.walls.into_iter().chain(d.columns).collect()
}
+25 -17
View File
@@ -199,20 +199,17 @@ fn v2(x: f64, y: f64) -> Vec2 {
Vec2 { x, y }
}
/// [140] Dünne Schichten unter dieser Papierdicke (mm) gehen im Detailgrad mittel ab 1:100 in der
/// Nachbarschicht auf (Putz, Parkett, Folien): sonst liegen Umriss, Fuge und Schraffur in 1:100 als
/// schwarzer Balken übereinander. In 1:50 und im Detailgrad fein bleiben alle Schichten.
pub const THIN_LAYER_PAPER_MM: f64 = 0.25;
/// Ziel-Schicht je Schicht: dünne Schichten zeigen auf die nächste nicht dünne (bei gleichem Abstand
/// die dickere), alle anderen auf sich selbst. Fugen zwischen Schichten mit gleichem Ziel entfallen.
/// [140] Regel und Schwelle: `style::simplify_thin_layers` / `is_thin_layer` (unter 0.5 mm Papier ab 1:75,
/// nicht im Detail „fein"); die dünne Schicht trägt dann Füllung/Schraffur der Zielschicht.
pub fn thin_layer_targets(thick: &[f64], detail: Detail, scale: f64) -> Vec<usize> {
let n = thick.len();
let ident: Vec<usize> = (0..n).collect();
if detail != Detail::Mittel || !(scale >= 75.0) {
if !simplify_thin_layers(detail, scale) {
return ident;
}
let thin: Vec<bool> = thick.iter().map(|t| !(t * 1000.0 / scale >= THIN_LAYER_PAPER_MM)).collect();
let thin: Vec<bool> = thick.iter().map(|t| is_thin_layer(*t, scale)).collect();
if thin.iter().all(|t| *t) {
return ident;
}
@@ -248,7 +245,8 @@ fn wall_poche(c: &Ctx, out: &mut Vec<Primitive>, e: &EffWall, gaps: &[(f64, f64)
let outline_mm = wall_lw * detail.outline_factor();
let layer_mm = LAYER_JOINT_MM * detail.layer_factor();
let thick: Vec<f64> = wt.layers.iter().map(|l| l.thickness).collect();
let f = crate::plan::wall_poche::wall_poche(&encode_wall_poche(w, &thick, total, ref_off, gaps, cuts, detail == Detail::Grob, view_only, reveals));
// [140] Ab 1:100 (und „grob") schwarze Sammelfläche mit Umriss, ohne Schichten (`style::solid_cut`).
let f = crate::plan::wall_poche::wall_poche(&encode_wall_poche(w, &thick, total, ref_off, gaps, cuts, c.solid_cut(), view_only, reveals));
let target = thin_layer_targets(&thick, detail, c.a.scale);
if f.is_empty() {
return Ok(());
@@ -1308,24 +1306,34 @@ pub(crate) mod tests {
super::super::domains::plan_domains(p, &super::super::domains::PlanArgs::parse(1.0, &t).unwrap()).unwrap().walls
}
/// [140] Dünne Schichten (Putz 2 cm) gehen in 1:100 (mittel) in der Nachbarschicht auf: keine
/// Schichtfuge zwischen Putz und Backstein, das Putzband trägt den Stil des Backsteins. In 1:50
/// und im Detailgrad fein bleiben alle Schichten mit Fugen.
/// [140] Dünne Schichten (Putz 2 cm = 0.4 mm in 1:50) gehen im 1:50 (mittel) in der Nachbarschicht auf:
/// keine Schichtfuge zwischen Putz und Backstein, das Putzband trägt den Stil des Backsteins. Im 1:20
/// und im Detailgrad fein bleiben alle Schichten mit Fugen; 1:100 ist schwarz (keine Fugen, s.
/// `schnittflaechen_schwarz_ab_1_100`), mit „Schnittflächen schraffiert" wieder zusammengefasst.
#[test]
fn duenne_schichten_je_massstab_zusammengefasst() {
let p = pocket_project(DoorTypeKind::Schiebe, None, 1.0);
let joints = |detail: f64, scale: f64| {
let mut p = pocket_project(DoorTypeKind::Schiebe, None, 1.0);
let joints = |p: &Project, detail: f64, scale: f64| {
let t = serde_json::json!({ "floor": "eg", "show": ["20"], "grey": [], "scale": scale }).to_string();
let prims = super::super::domains::plan_domains(&p, &super::super::domains::PlanArgs::parse(detail, &t).unwrap()).unwrap().walls;
let prims = super::super::domains::plan_domains(p, &super::super::domains::PlanArgs::parse(detail, &t).unwrap()).unwrap().walls;
prims.iter().filter(|q| matches!(q, Primitive::Line { cls, .. } if cls == "layer-joint")).count()
};
assert_eq!(joints(1.0, 100.0), 0, "1:100 mittel: Putz ohne Fuge");
assert!(joints(1.0, 50.0) >= 4, "1:50: alle Fugen");
assert!(joints(2.0, 100.0) >= 4, "fein: alle Fugen");
assert_eq!(joints(&p, 1.0, 100.0), 0, "1:100 mittel: schwarz");
assert_eq!(joints(&p, 1.0, 50.0), 0, "1:50 mittel: Putz ohne Fuge");
assert!(joints(&p, 1.0, 20.0) >= 4, "1:20: alle Fugen");
assert!(joints(&p, 2.0, 50.0) >= 4, "fein: alle Fugen");
assert!(joints(&p, 2.0, 100.0) >= 4, "fein 1:100: schraffiert, alle Fugen");
p.drawing_levels[0].cut_hatch = Some(true);
assert_eq!(joints(&p, 1.0, 100.0), 0, "1:100 schraffiert: Putz zusammengefasst");
assert_eq!(thin_layer_targets(&[0.02, 0.12, 0.02], Detail::Mittel, 100.0), vec![1, 1, 1]);
assert_eq!(thin_layer_targets(&[0.02, 0.18, 0.003, 0.16, 0.015], Detail::Mittel, 100.0), vec![1, 1, 1, 3, 3]);
assert_eq!(thin_layer_targets(&[0.01, 0.01], Detail::Mittel, 100.0), vec![0, 1], "nur dünne: unverändert");
assert_eq!(thin_layer_targets(&[0.02, 0.12], Detail::Fein, 100.0), vec![0, 1]);
// [140] Teil 5: Schwelle 0.5 mm Papier — 4 cm Dämmung/Lattung (0.4 mm) geht in 1:100 auf, 6 cm bleibt;
// 1:200 (grob) fasst bis 10 cm zusammen.
assert_eq!(thin_layer_targets(&[0.04, 0.06, 0.18], Detail::Mittel, 100.0), vec![1, 1, 2]);
assert_eq!(thin_layer_targets(&[0.08, 0.18], Detail::Grob, 200.0), vec![1, 1]);
assert_eq!(thin_layer_targets(&[0.04, 0.18], Detail::Mittel, 50.0), vec![0, 1]);
}
fn area(pts: &[Vec2]) -> f64 {
+191
View File
@@ -78,6 +78,167 @@ pub fn balance(rooms: &[(usize, f64)]) -> Balance {
b
}
// ── Stempel-Ankerpunkt ──────────────────────────────────────────────────────
fn ring_inside(x: f64, y: f64, r: &[[f64; 2]]) -> bool {
let n = r.len();
let mut inside = false;
let mut j = n.wrapping_sub(1);
for i in 0..n {
let ([xi, yi], [xj, yj]) = (r[i], r[j]);
if (yi > y) != (yj > y) && x < (xj - xi) * (y - yi) / (yj - yi) + xi {
inside = !inside;
}
j = i;
}
inside
}
fn seg_dist2(x: f64, y: f64, a: [f64; 2], b: [f64; 2]) -> f64 {
let (dx, dy) = (b[0] - a[0], b[1] - a[1]);
let l2 = dx * dx + dy * dy;
let t = if l2 > 0.0 { (((x - a[0]) * dx + (y - a[1]) * dy) / l2).clamp(0.0, 1.0) } else { 0.0 };
let (px, py) = (a[0] + t * dx - x, a[1] + t * dy - y);
px * px + py * py
}
/// Vorzeichenbehafteter Abstand zum Rand (innen positiv).
fn signed_dist(x: f64, y: f64, r: &[[f64; 2]]) -> f64 {
let n = r.len();
let d2 = (0..n).map(|i| seg_dist2(x, y, r[i], r[(i + 1) % n])).fold(f64::INFINITY, f64::min);
let d = d2.sqrt();
if ring_inside(x, y, r) { d } else { -d }
}
/// [140] Ankerpunkt des Raumstempels: Pol der Unzugänglichkeit (der innere Punkt mit dem grössten Abstand
/// zum Rand; Verfahren „polylabel" von Mapbox, Agafonkin 2016, hier eigens umgesetzt): liegt auch in
/// L-förmigen und konkaven Räumen sicher im Raum, wo der Schwerpunkt ausserhalb fallen kann. Ist der
/// Schwerpunkt innen und fast so gut (≥ 90 % des Abstands, z. B. Rechteck, Korridor), bleibt er (ruhige
/// Mitte statt eines beliebigen Punkts auf der Mittelachse). Entartete Ringe → Schwerpunkt.
pub fn label_point(polygon: &[[f64; 2]]) -> [f64; 2] {
let c = evaluate(polygon, 0.0).centroid;
let r: Vec<[f64; 2]> = polygon.iter().copied().filter(|p| p[0].is_finite() && p[1].is_finite()).collect();
if r.len() < 3 || r.len() != polygon.len() {
return c;
}
let (mut x0, mut y0, mut x1, mut y1) = (f64::INFINITY, f64::INFINITY, f64::NEG_INFINITY, f64::NEG_INFINITY);
for p in &r {
x0 = x0.min(p[0]);
y0 = y0.min(p[1]);
x1 = x1.max(p[0]);
y1 = y1.max(p[1]);
}
let (w, h) = (x1 - x0, y1 - y0);
let size = w.min(h);
if !(size > 0.0) {
return c;
}
let precision = (w.max(h) * 1e-3).max(1e-4);
// Zelle: Mitte, halbe Kantenlänge, Abstand der Mitte, obere Schranke innerhalb der Zelle.
#[derive(PartialEq)]
struct Cell(f64, f64, f64, f64, f64);
impl Eq for Cell {}
impl PartialOrd for Cell {
fn partial_cmp(&self, o: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(o))
}
}
impl Ord for Cell {
fn cmp(&self, o: &Self) -> std::cmp::Ordering {
self.4.total_cmp(&o.4)
}
}
let cell = |x: f64, y: f64, h: f64| {
let d = signed_dist(x, y, &r);
Cell(x, y, h, d, d + h * std::f64::consts::SQRT_2)
};
let dc = if c[0].is_finite() && c[1].is_finite() { signed_dist(c[0], c[1], &r) } else { f64::NEG_INFINITY };
let dist2 = |x: f64, y: f64| (x - c[0]) * (x - c[0]) + (y - c[1]) * (y - c[1]);
// Bester Punkt: grösserer Abstand; innerhalb der Genauigkeit näher am Schwerpunkt.
let better = |a: &Cell, b: &(f64, f64, f64)| {
if a.3 > b.2 + precision {
return true;
}
a.3 > b.2 - precision && dist2(a.0, a.1) < dist2(b.0, b.1)
};
let mut best = (c[0], c[1], dc);
let mid = cell(x0 + w / 2.0, y0 + h / 2.0, 0.0);
if better(&mid, &best) {
best = (mid.0, mid.1, mid.3);
}
let mut heap = std::collections::BinaryHeap::new();
let half = size / 2.0;
let mut x = x0;
while x < x1 {
let mut y = y0;
while y < y1 {
heap.push(cell(x + half, y + half, half));
y += size;
}
x += size;
}
let mut budget = 20_000;
while let Some(q) = heap.pop() {
if better(&q, &best) {
best = (q.0, q.1, q.3);
}
budget -= 1;
if budget == 0 {
break;
}
if q.4 - best.2 <= precision {
continue;
}
let h2 = q.2 / 2.0;
for (dx, dy) in [(-1.0, -1.0), (1.0, -1.0), (-1.0, 1.0), (1.0, 1.0)] {
heap.push(cell(q.0 + dx * h2, q.1 + dy * h2, h2));
}
}
if !(best.2 > 0.0) {
return c;
}
// Schwerpunkt innen und fast so gut: Mitte behalten.
if dc >= 0.9 * best.2 {
return c;
}
[best.0, best.1]
}
/// [140] Liegt das achsparallele Rechteck mit Mitte `(cx, cy)` und halber Breite/Höhe `hw`/`hh` ganz im
/// Ring (Mitte innen, keine Kante schneidet das Innere des Rechtecks)? Berührung des Rands zählt als innen.
pub fn rect_in_ring(ring: &[[f64; 2]], cx: f64, cy: f64, hw: f64, hh: f64) -> bool {
if ring.len() < 3 || !ring_inside(cx, cy, ring) {
return false;
}
let e = 1e-9;
let (rx0, rx1, ry0, ry1) = (cx - hw + e, cx + hw - e, cy - hh + e, cy + hh - e);
if !(rx0 < rx1 && ry0 < ry1) {
return true;
}
let n = ring.len();
(0..n).all(|i| {
// Liang–Barsky: schneidet die Kante das offene Rechteck?
let (a, b) = (ring[i], ring[(i + 1) % n]);
let (dx, dy) = (b[0] - a[0], b[1] - a[1]);
let (mut t0, mut t1) = (0.0f64, 1.0f64);
for (p, q) in [(-dx, a[0] - rx0), (dx, rx1 - a[0]), (-dy, a[1] - ry0), (dy, ry1 - a[1])] {
if p == 0.0 {
if q <= 0.0 {
return true;
}
} else {
let t = q / p;
if p < 0.0 {
t0 = t0.max(t);
} else {
t1 = t1.min(t);
}
}
}
t0 >= t1
})
}
#[cfg(test)]
mod tests {
use super::*;
@@ -157,4 +318,34 @@ mod tests {
assert_eq!(rollup(5), &[2]);
assert!(rollup(6).is_empty());
}
/// [140] Stempel-Anker: Rechteck → Mitte; schmales L → im Raum (der Schwerpunkt liegt dort ausserhalb).
#[test]
fn stempel_anker_pol_der_unzugaenglichkeit() {
assert_eq!(label_point(&[[0.0, 0.0], [4.0, 0.0], [4.0, 2.0], [0.0, 2.0]]), [2.0, 1.0]);
let l = [[0.0, 0.0], [6.0, 0.0], [6.0, 1.0], [1.0, 1.0], [1.0, 6.0], [0.0, 6.0]];
let c = evaluate(&l, 0.0).centroid;
assert!(!ring_inside(c[0], c[1], &l), "Schwerpunkt ausserhalb: {c:?}");
let q = label_point(&l);
assert!(ring_inside(q[0], q[1], &l) && signed_dist(q[0], q[1], &l) > 0.45, "{q:?}");
// Breites L (zwei Flügel 4 × 3 m): Pol im grösseren Teil, mit Abstand zur Innenecke.
let l2 = [[0.0, 0.0], [8.0, 0.0], [8.0, 3.0], [3.0, 3.0], [3.0, 7.0], [0.0, 7.0]];
let q = label_point(&l2);
assert!(signed_dist(q[0], q[1], &l2) > 1.45, "{q:?}");
assert_eq!(label_point(&[]), [0.0, 0.0]);
assert_eq!(label_point(&[[0.0, 0.0], [1.0, 1.0], [2.0, 2.0]]), evaluate(&[[0.0, 0.0], [1.0, 1.0], [2.0, 2.0]], 0.0).centroid);
let nan = label_point(&[[0.0, 0.0], [f64::NAN, 1.0], [2.0, 2.0]]);
assert!(nan.len() == 2);
}
#[test]
fn rechteck_im_ring() {
let l = [[0.0, 0.0], [6.0, 0.0], [6.0, 1.0], [1.0, 1.0], [1.0, 6.0], [0.0, 6.0]];
assert!(rect_in_ring(&l, 3.0, 0.5, 2.0, 0.4));
assert!(!rect_in_ring(&l, 1.2, 0.5, 1.0, 0.8), "ragt oben aus dem Flügel");
assert!(!rect_in_ring(&l, 3.0, 3.0, 0.1, 0.1), "Mitte ausserhalb");
assert!(rect_in_ring(&l, 3.0, 0.5, 3.0, 0.5), "berührt den Rand");
// U mit Schlitz: alle Ecken innen, aber der Schlitz quert das Rechteck.
let u = [[0.0, 0.0], [5.0, 0.0], [5.0, 4.0], [2.6, 4.0], [2.6, 1.0], [2.4, 1.0], [2.4, 4.0], [0.0, 4.0]];
assert!(!rect_in_ring(&u, 2.5, 2.5, 2.0, 0.5));
}
}
+1 -1
View File
@@ -200,7 +200,7 @@ pub fn collect_model(p: &Project, level: &str, codes: &HashSet<String>, skip: &H
anchors.push(match &r.stamp_anchor {
Some(a) => (a.x, a.y),
None => {
let c = crate::room_area::evaluate(&r.boundary.iter().map(|p| [p.x, p.y]).collect::<Vec<_>>(), 0.0).centroid;
let c = crate::room_area::label_point(&r.boundary.iter().map(|p| [p.x, p.y]).collect::<Vec<_>>());
(c[0], c[1])
}
});
+73
View File
@@ -550,6 +550,66 @@ pub fn text_frame_corners(doc: &RichTextDoc, at: (f64, f64), height_m: f64, angl
local.map(|(x, y)| (at.0 + x * c - y * s, at.1 + x * s + y * c))
}
// ── Schriftmetrik ───────────────────────────────────────────────────────────
/// [140] Vorschubbreiten (1/1000 em) der Plan-Schrift Inter (Regular, `render2d/assets/Inter.ttf`, Tabelle
/// `hmtx`, mit fontTools ausgelesen; SIL OFL 1.1, s. `NOTICE`) für U+0020–U+007E und U+00A0–U+00FF.
/// Echte Metrik statt der Schätzung [`CHAR_WIDTH_FACTOR`] für Breiten, die passen müssen (Raumstempel).
const INTER_ASCII: [u16; 95] = [
281, 288, 466, 633, 642, 982, 644, 300, 365, 365, 501, 662, 288, 460, 288, 360,
631, 407, 610, 618, 646, 593, 620, 566, 619, 620, 288, 302, 662, 662, 662, 511,
966, 690, 654, 730, 722, 601, 590, 746, 743, 269, 571, 672, 565, 903, 753, 765,
639, 765, 644, 642, 646, 744, 690, 985, 682, 679, 629, 365, 360, 365, 471, 456,
323, 562, 612, 571, 612, 583, 370, 613, 591, 242, 242, 549, 242, 876, 591, 600,
612, 612, 376, 528, 327, 591, 562, 818, 546, 562, 552, 426, 333, 426, 662,
];
const INTER_LATIN1: [u16; 96] = [
281, 288, 571, 611, 725, 550, 270, 568, 591, 914, 454, 583, 662, 560, 666, 478,
456, 662, 442, 446, 323, 586, 603, 288, 268, 304, 482, 583, 802, 847, 882, 511,
690, 690, 690, 690, 690, 690, 994, 730, 601, 601, 601, 601, 269, 269, 269, 269,
735, 753, 765, 765, 765, 765, 765, 662, 765, 744, 744, 744, 744, 679, 636, 616,
562, 562, 562, 562, 562, 562, 917, 571, 583, 583, 583, 583, 242, 242, 242, 242,
583, 591, 600, 600, 600, 600, 600, 662, 600, 591, 591, 591, 591, 562, 612, 562,
];
/// [140] Breite eines Texts in em (Inter Regular, ohne Kerning wie `render2d::vtext`). Zeichen ausserhalb
/// der Tabelle: Gedankenstrich 0.5, Geviertstrich/Ellipse/Euro aus der Schrift, sonst
/// [`CHAR_WIDTH_FACTOR`]; Fett etwa 5 % breiter.
pub fn text_width_em(text: &str, bold: bool) -> f64 {
let w: u32 = text
.chars()
.map(|ch| {
let c = ch as u32;
match c {
0x20..=0x7e => INTER_ASCII[(c - 0x20) as usize] as u32,
0xa0..=0xff => INTER_LATIN1[(c - 0xa0) as usize] as u32,
0x2013 => 500,
0x2014 => 1000,
0x2026 => 864,
0x20ac => 667,
0x2018 | 0x2019 | 0x201a => 261,
0x201c | 0x201d | 0x201e => 455,
_ => (CHAR_WIDTH_FACTOR * 1000.0) as u32,
}
})
.sum();
w as f64 / 1000.0 * if bold { 1.05 } else { 1.0 }
}
/// [140] Ausmass eines Raumstempels ([`stamp_block`]) in Einheiten von `unit_per_pt`: Breite der breitesten
/// Zeile (Summe der Tspans mit echter Metrik, [`text_width_em`]) und Höhe des Blocks (erste Zeile plus
/// Zeilenvorschübe, wie die Zentrierung in [`stamp_block_refs`]).
pub fn stamp_block_size(doc: &RichTextDoc, extra: &[(&str, LineAlign)], base_pt: f64, unit_per_pt: f64) -> (f64, f64) {
let placed = stamp_block(doc, extra, base_pt, unit_per_pt, "#000000", 0.0);
if placed.is_empty() {
return (0.0, 0.0);
}
let w = placed.iter().map(|p| p.line.tspans.iter().map(|t| text_width_em(&t.text, t.bold) * t.font_size).sum::<f64>()).fold(0.0, f64::max);
let base_fs = base_pt * unit_per_pt;
let h = base_fs + placed[1..].iter().map(|p| p.line.line_height).sum::<f64>();
(w, h)
}
#[cfg(test)]
mod tests {
use super::*;
@@ -677,4 +737,17 @@ mod tests {
let r = text_frame_corners(&d, (0.0, 0.0), 0.2, std::f64::consts::FRAC_PI_2, None, 0.9);
assert!((r[0].0 + 0.18).abs() < 1e-12 && r[0].1.abs() < 1e-12);
}
/// [140] Echte Metrik: „Bad" schmaler als „WWW", Leerzeichen schmal; Stempelblock misst Name und Zeilen.
#[test]
fn schriftmetrik_inter() {
assert!((text_width_em("Bad", false) - (0.654 + 0.562 + 0.612)).abs() < 1e-9);
assert!(text_width_em("WWW", false) > 2.9 && text_width_em("iii", false) < 0.75);
assert!(text_width_em("m²", false) > text_width_em("m", false));
assert!(text_width_em("Bad", true) > text_width_em("Bad", false));
let d = doc_from_text("Bad", &Marks::default());
let (w, h) = stamp_block_size(&d, &[("4.60 m²", LineAlign::Center)], 10.0, 1.0);
// Zweite Zeile 8 pt: 4.60 m² ≈ 3.6 em · 8; Höhe 10 + 13.
assert!((h - 23.0).abs() < 1e-9, "{h}");
assert!((w - text_width_em("4.60 m²", false) * 8.0).abs() < 1e-9, "{w}");
}
}
+7
View File
@@ -25,6 +25,13 @@ pub fn room_centroid(pts: &[f64]) -> Vec<f64> {
vec![c[0], c[1]]
}
/// [140] Ring `[x0, y0, …]` → Stempel-Anker `[x, y]` (Pol der Unzugänglichkeit, `room_area::label_point`).
#[wasm_bindgen]
pub fn room_label_point(pts: &[f64]) -> Vec<f64> {
let c = ra::label_point(&pairs(pts));
vec![c[0], c[1]]
}
/// Kategorie-Indizes und Flächen je Raum (gleich lang) →
/// `[6 Flächen je Blatt-Kategorie, 6 Raumzahlen, 3 Flächen NF/NGF/GF, 3 Raumzahlen]`.
/// Ungültige Indizes (NaN, ausserhalb) werden übergangen.
+2 -2
View File
@@ -171,7 +171,7 @@ import { DragOverlay } from "./panels/panelDrag";
import { hostWithMode, PanelHostProvider } from "./panels/host";
import { deriveSelection } from "./state/selectionInfo";
import type { SelectionInfo } from "./state/selectionInfo";
import { centroid as roomCentroid } from "./core";
import { roomLabelPoint } from "./core";
import { docFromText, plainText, DEFAULT_PRESETS } from "./text/richText";
import type { RichTextDoc } from "./text/richText";
import { revealPanel, saveLayout } from "./panels/layout";
@@ -655,7 +655,7 @@ export default function App() {
selectedRoom
? {
roomId: selectedRoom.id,
anchor: selectedRoom.stampAnchor ?? roomCentroid(selectedRoom.boundary),
anchor: selectedRoom.stampAnchor ?? roomLabelPoint(selectedRoom.boundary),
}
: null,
[selectedRoom],
+9 -46
View File
@@ -7,53 +7,16 @@
<text x="2.5" y="2.6725" font-size="0.3528" fill="#111111" font-family="sans-serif" text-anchor="middle">Wohnen</text>
<text x="2.5" y="3.09586" font-size="0.3528" fill="#111111" font-family="sans-serif" text-anchor="middle">17.01 m²</text>
<text x="2.5" y="3.51922" font-size="0.3528" fill="#111111" font-family="sans-serif" text-anchor="middle">HNF · Hauptnutzfläche</text>
<polygon points="-0.1725,4.845 0.8,4.845 0.8,4.825 -0.1525,4.825" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="-0.1525,4.825 0.8,4.825 0.8,4.665 0.0075,4.665" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="0.0075,4.665 0.8,4.665 0.8,4.515 0.1575,4.515" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="0.1575,4.515 0.8,4.515 0.8,4.5 0.1725,4.5" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="-0.1725,4.845 0.8,4.845 0.8,4.5 0.1725,4.5" fill="none" stroke="none"/>
<polygon points="1.7,4.845 3,4.845 3,4.825 1.7,4.825" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="1.7,4.825 3,4.825 3,4.665 1.7,4.665" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<line x1="1.7" y1="4.665" x2="3" y2="4.665" stroke="#1a1a1a" stroke-width="0.013"/>
<polygon points="1.7,4.665 3,4.665 3,4.515 1.7,4.515" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="1.7,4.515 2.34,4.515 2.34,4.5 1.7,4.5" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="2.46,4.515 3,4.515 3,4.5 2.46,4.5" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="1.7,4.845 3,4.845 3,4.5 1.7,4.5" fill="none" stroke="none"/>
<polyline points="2.34,4.5 1.7,4.5 1.7,4.845 3,4.845 3,4.5 2.46,4.5" fill="none" stroke="#1a1a1a" stroke-width="0.025"/>
<polygon points="4,4.845 5.1725,4.845 5.1525,4.825 4,4.825" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="4,4.825 5.1525,4.825 4.9925,4.665 4,4.665" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="4,4.665 4.9925,4.665 4.8425,4.515 4,4.515" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="4,4.515 4.8425,4.515 4.8275,4.5 4,4.5" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="4,4.845 5.1725,4.845 4.8275,4.5 4,4.5" fill="none" stroke="none"/>
<polygon points="5.1725,4.845 5.1725,0.5 5.1525,0.52 5.1525,4.825" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="5.1525,4.825 5.1525,0.52 4.9925,0.68 4.9925,4.665" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="4.9925,4.665 4.9925,0.68 4.8425,0.83 4.8425,4.515" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="4.8425,4.515 4.8425,0.83 4.8275,0.845 4.8275,4.5" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="5.1725,4.845 5.1725,0.5 4.8275,0.845 4.8275,4.5" fill="none" stroke="none"/>
<polygon points="5.1725,0.5 4.4,0.5 4.4,0.52 5.1525,0.52" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="5.1525,0.52 4.4,0.52 4.4,0.68 4.9925,0.68" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polyline points="4,4.665 4.9925,4.665 4.9925,0.68 4.4,0.68" fill="none" stroke="#1a1a1a" stroke-width="0.013"/>
<polygon points="4.9925,0.68 4.4,0.68 4.4,0.83 4.8425,0.83" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="4.8425,0.83 4.4,0.83 4.4,0.845 4.8275,0.845" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="5.1725,0.5 4.4,0.5 4.4,0.845 4.8275,0.845" fill="none" stroke="none"/>
<polygon points="-0.1725,4.845 0.8,4.845 0.8,4.5 0.1725,4.5" fill="#0f0f0f" stroke="none"/>
<polygon points="1.7,4.845 3,4.845 3,4.5 1.7,4.5" fill="#0f0f0f" stroke="#1a1a1a" stroke-width="0.025"/>
<polygon points="4,4.845 5.1725,4.845 4.8275,4.5 4,4.5" fill="#0f0f0f" stroke="none"/>
<polygon points="5.1725,4.845 5.1725,0.5 4.8275,0.845 4.8275,4.5" fill="#0f0f0f" stroke="none"/>
<polygon points="5.1725,0.5 4.4,0.5 4.4,0.845 4.8275,0.845" fill="#0f0f0f" stroke="none"/>
<polygon points="4.8275,0.845 4.8275,4.5 4,4.5 4,4.845 5.1725,4.845 5.1725,0.5 4.4,0.5 4.4,0.845" fill="none" stroke="#1a1a1a" stroke-width="0.025"/>
<polygon points="3,0.5 -0.1725,0.5 -0.1525,0.52 3,0.52" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="3,0.52 -0.1525,0.52 0.0075,0.68 3,0.68" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="3,0.68 0.0075,0.68 0.1575,0.83 3,0.83" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="3,0.83 2.46,0.83 2.46,0.845 3,0.845" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="2.34,0.83 0.1575,0.83 0.1725,0.845 2.34,0.845" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="3,0.5 -0.1725,0.5 0.1725,0.845 3,0.845" fill="none" stroke="none"/>
<polygon points="-0.1725,0.5 -0.1725,4.845 -0.1525,4.825 -0.1525,0.52" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="-0.1525,0.52 -0.1525,4.825 0.0075,4.665 0.0075,0.68" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polyline points="3,0.68 0.0075,0.68 0.0075,4.665 0.8,4.665" fill="none" stroke="#1a1a1a" stroke-width="0.013"/>
<polygon points="0.0075,0.68 0.0075,4.665 0.1575,4.515 0.1575,0.83" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="0.1575,0.83 0.1575,4.515 0.1725,4.5 0.1725,0.845" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="-0.1725,0.5 -0.1725,4.845 0.1725,4.5 0.1725,0.845" fill="none" stroke="none"/>
<polyline points="2.46,0.845 3,0.845 3,0.5 -0.1725,0.5 -0.1725,4.845 0.8,4.845 0.8,4.5 0.1725,4.5 0.1725,0.845 2.34,0.845" fill="none" stroke="#1a1a1a" stroke-width="0.025"/>
<polygon points="2.475,4.5 2.475,0.845 2.46,0.845 2.46,4.5" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="2.46,4.515 2.46,0.83 2.34,0.83 2.34,4.515" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="2.34,4.5 2.34,0.845 2.325,0.845 2.325,4.5" fill="#f0f0f0" stroke="none" stroke-width="0"/>
<polygon points="2.475,4.5 2.475,0.845 2.325,0.845 2.325,4.5" fill="none" stroke="none"/>
<polygon points="3,0.5 -0.1725,0.5 0.1725,0.845 3,0.845" fill="#0f0f0f" stroke="none"/>
<polygon points="-0.1725,0.5 -0.1725,4.845 0.1725,4.5 0.1725,0.845" fill="#0f0f0f" stroke="none"/>
<polygon points="0.1725,0.845 3,0.845 3,0.5 -0.1725,0.5 -0.1725,4.845 0.8,4.845 0.8,4.5 0.1725,4.5" fill="none" stroke="#1a1a1a" stroke-width="0.025"/>
<polygon points="2.475,4.5 2.475,0.845 2.325,0.845 2.325,4.5" fill="#0f0f0f" stroke="none"/>
<line x1="2.475" y1="4.5" x2="2.475" y2="0.845" stroke="#1a1a1a" stroke-width="0.025"/>
<line x1="2.325" y1="0.845" x2="2.325" y2="4.5" stroke="#1a1a1a" stroke-width="0.025"/>
<polygon points="3.2,4.2725 3.2,4.05917 4.2,4.05917 4.2,4.2725" fill="none" stroke="#1a1a1a" stroke-width="0.0126"/>

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

+32 -33
View File
@@ -2,40 +2,39 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0.1 0 6.8 7.58564" width="68mm" height="75.85641mm">
<rect x="0.1" y="0" width="6.8" height="7.58564" fill="#ffffff"/>
<g stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="4">
<polygon points="5.8275,4.78564 5.8275,7.08564 5.9925,7.08564 5.9925,4.78564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="5.8425,1.88564 5.9925,1.88564 5.9925,4.58564 5.8425,4.58564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="5.9925,4.78564 5.9925,7.08564 6.1725,7.08564 6.1725,1.88564 6.1525,1.88564 6.1525,4.48564 6,4.48564 6,4.54564 5.9925,4.54564 5.9925,4.58564 6,4.58564 6,4.78564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="0.8275,1.88564 0.8275,7.08564 1.0075,7.08564 1.0075,4.78564 1,4.78564 1,4.58564 1.0075,4.58564 1.0075,4.54564 1,4.54564 1,4.48564 0.8475,4.48564 0.8475,1.88564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="1.0075,4.78564 1.0075,7.08564 1.1725,7.08564 1.1725,4.78564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="1.0075,1.88564 1.1575,1.88564 1.1575,4.58564 1.0075,4.58564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="3.325,4.78564 3.325,7.08564 3.475,7.08564 3.475,4.78564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="3.34,4.48564 3.46,4.48564 3.46,4.58564 3.34,4.58564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="5.8275,1.88564 5.8425,1.88564 5.8425,4.48564 5.8275,4.48564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="5.9925,1.88564 6.1525,1.88564 6.1525,4.48564 5.9925,4.48564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="0.8475,1.88564 1.0075,1.88564 1.0075,4.48564 0.8475,4.48564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="1.1575,1.88564 1.1725,1.88564 1.1725,4.48564 1.1575,4.48564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="1,4.48564 1.0075,4.48564 1.0075,4.54564 1,4.54564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="1.1575,4.48564 3.34,4.48564 3.34,4.54564 1.1575,4.54564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="3.46,4.48564 5.8425,4.48564 5.8425,4.54564 3.46,4.54564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="5.9925,4.48564 6,4.48564 6,4.54564 5.9925,4.54564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="1.1575,4.54564 3.34,4.54564 3.34,4.58564 1.1575,4.58564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="3.46,4.54564 5.8425,4.54564 5.8425,4.58564 3.46,4.58564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="1,4.58564 6,4.58564 6,4.78564 1,4.78564" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="0.6,0.5 6.4,0.5 6.4,0.73094 0.6,0.73094" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="4.2,5.69897 4.2,5.99364 5.2,5.99364 5.2,5.69897" fill="#f0f0f0" stroke="#1f242c" stroke-width="0.013"/>
<polygon points="5.8275,4.78564 5.8425,4.78564 5.8425,7.08564 5.8275,7.08564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="5.8425,4.78564 5.9925,4.78564 5.9925,7.08564 5.8425,7.08564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="5.8425,1.88564 5.9925,1.88564 5.9925,4.58564 5.8425,4.58564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="6,4.48564 6.1525,4.48564 6.1525,7.08564 6,7.08564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="5.9925,4.78564 6,4.78564 6,7.08564 5.9925,7.08564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="5.9925,4.54564 6,4.54564 6,4.58564 5.9925,4.58564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="6.1525,1.88564 6.1725,1.88564 6.1725,7.08564 6.1525,7.08564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="0.8275,1.88564 0.8475,1.88564 0.8475,7.08564 0.8275,7.08564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="0.8475,4.48564 1,4.48564 1,7.08564 0.8475,7.08564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="1,4.78564 1.0075,4.78564 1.0075,7.08564 1,7.08564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="1,4.54564 1.0075,4.54564 1.0075,4.58564 1,4.58564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="1.0075,4.78564 1.1575,4.78564 1.1575,7.08564 1.0075,7.08564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="1.0075,1.88564 1.1575,1.88564 1.1575,4.58564 1.0075,4.58564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="1.1575,4.78564 1.1725,4.78564 1.1725,7.08564 1.1575,7.08564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="3.325,4.78564 3.34,4.78564 3.34,7.08564 3.325,7.08564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="3.34,4.78564 3.46,4.78564 3.46,7.08564 3.34,7.08564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="3.34,4.48564 3.46,4.48564 3.46,4.58564 3.34,4.58564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="3.46,4.78564 3.475,4.78564 3.475,7.08564 3.46,7.08564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="5.8275,1.88564 5.8425,1.88564 5.8425,4.48564 5.8275,4.48564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="5.9925,1.88564 6.1525,1.88564 6.1525,4.48564 5.9925,4.48564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="0.8475,1.88564 1.0075,1.88564 1.0075,4.48564 0.8475,4.48564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="1.1575,1.88564 1.1725,1.88564 1.1725,4.48564 1.1575,4.48564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="1,4.48564 1.0075,4.48564 1.0075,4.54564 1,4.54564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="1.1575,4.48564 3.34,4.48564 3.34,4.54564 1.1575,4.54564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="3.46,4.48564 5.8425,4.48564 5.8425,4.54564 3.46,4.54564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="5.9925,4.48564 6,4.48564 6,4.54564 5.9925,4.54564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="1.1575,4.54564 3.34,4.54564 3.34,4.58564 1.1575,4.58564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="3.46,4.54564 5.8425,4.54564 5.8425,4.58564 3.46,4.58564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="1,4.58564 6,4.58564 6,4.78564 1,4.78564" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="0.6,0.5 6.4,0.5 6.4,0.73094 0.6,0.73094" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="4.2,5.69897 4.2,5.99364 5.2,5.99364 5.2,5.69897" fill="#0f0f0f" stroke="none" stroke-width="0"/>
<polygon points="0.6,0.5 0.6,0.73094 6.4,0.73094 6.4,0.5" fill="none" stroke="#1f242c" stroke-width="0.025"/>
<line x1="1.0075" y1="7.08564" x2="1.0075" y2="7.08564" stroke="#1f242c" stroke-width="0.025"/>
<polyline points="1.0075,7.08564 1.1725,7.08564 1.1725,4.78564 3.325,4.78564 3.325,7.08564 3.475,7.08564 3.475,4.78564 5.8275,4.78564 5.8275,7.08564 5.9925,7.08564" fill="none" stroke="#1f242c" stroke-width="0.025"/>
<line x1="5.9925" y1="7.08564" x2="5.9925" y2="7.08564" stroke="#1f242c" stroke-width="0.025"/>
<polyline points="5.9925,7.08564 6.1725,7.08564 6.1725,1.88564 5.8275,1.88564 5.8275,4.48564 1.1725,4.48564 1.1725,1.88564 0.8275,1.88564 0.8275,7.08564 1.0075,7.08564" fill="none" stroke="#1f242c" stroke-width="0.025"/>
<line x1="1" y1="4.54564" x2="1" y2="4.54564" stroke="#1f242c" stroke-width="0.025"/>
<line x1="1" y1="4.54564" x2="1.0075" y2="4.54564" stroke="#1f242c" stroke-width="0.025"/>
<line x1="1.0075" y1="4.54564" x2="1.0075" y2="4.54564" stroke="#1f242c" stroke-width="0.025"/>
<line x1="1.0075" y1="4.54564" x2="1" y2="4.54564" stroke="#1f242c" stroke-width="0.025"/>
<line x1="5.9925" y1="4.54564" x2="5.9925" y2="4.54564" stroke="#1f242c" stroke-width="0.025"/>
<line x1="5.9925" y1="4.54564" x2="6" y2="4.54564" stroke="#1f242c" stroke-width="0.025"/>
<line x1="6" y1="4.54564" x2="6" y2="4.54564" stroke="#1f242c" stroke-width="0.025"/>
<line x1="6" y1="4.54564" x2="5.9925" y2="4.54564" stroke="#1f242c" stroke-width="0.025"/>
<polygon points="0.8275,1.88564 0.8275,7.08564 1.1725,7.08564 1.1725,4.78564 3.325,4.78564 3.325,7.08564 3.475,7.08564 3.475,4.78564 5.8275,4.78564 5.8275,7.08564 6.1725,7.08564 6.1725,1.88564 5.8275,1.88564 5.8275,4.48564 1.1725,4.48564 1.1725,1.88564" fill="none" stroke="#1f242c" stroke-width="0.025"/>
<polygon points="4.2,5.69897 4.2,5.99364 5.2,5.99364 5.2,5.69897" fill="none" stroke="#1f242c" stroke-width="0.025"/>
<polyline points="5.8275,7.08564 5.4,7.08564 4,7.08564 3.475,7.08564" fill="none" stroke="#2b3039" stroke-width="0.018"/>
<line x1="3.325" y1="7.08564" x2="1.1725" y2="7.08564" stroke="#2b3039" stroke-width="0.018"/>

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

+1
View File
@@ -81,6 +81,7 @@ export {
SIA_CATEGORIES,
balance,
centroid,
roomLabelPoint,
evaluateRoom,
polygonArea,
roomsToCsv,
+2 -1
View File
@@ -31,7 +31,8 @@ const visiblePolys = (polys: Extract<Plan["primitives"][number], { kind: "polygo
polys.filter((p) => !p.openingId && !(p.stroke === "none" && p.fill === "none" && p.hatch.pattern === "none" && p.hatch.kind !== "gradient"));
describe("DXF-Export (R2018 über acadrust)", () => {
const plan = generatePlan(sampleProject, "eg", allCodes(sampleProject));
// 1:50: Wände mit Schichten und Schraffur (ab 1:100 schwarz, [140]).
const plan = generatePlan(sampleProject, "eg", allCodes(sampleProject), undefined, "mittel", false, false, true, 50);
it("Version R2018, Einheit Meter, alle Kategorie-Ebenen", () => {
const text = buildPlanDxf(plan, sampleProject);
+2 -1
View File
@@ -6,7 +6,8 @@ import { sampleProject as project } from "../model/sampleProject";
describe("planToSvgString hatch", () => {
const floor = project.drawingLevels.find((l) => l.kind === "floor")!;
const codes = new Set(project.layers.map((l) => l.code));
const plan = generatePlan(project, floor.id, codes);
// 1:50: Schraffuren in den Wänden (ab 1:100 schwarz, [140]).
const plan = generatePlan(project, floor.id, codes, undefined, "mittel", false, false, true, 50);
it("Standard und hatch:false sind byte-gleich", () => {
const a = planToSvgString(plan, { scaleDenominator: 100 });
expect(planToSvgString(plan, { scaleDenominator: 100, hatch: false })).toBe(a);
+13 -1
View File
@@ -3,7 +3,7 @@
import { describe, expect, it } from "vitest";
import { core } from "../engine/coreWasm";
import { balance, centroid, evaluateRoom, polygonArea, roomsToCsv, SIA_CATEGORIES, siaLabel } from "./roomArea";
import { balance, centroid, evaluateRoom, polygonArea, roomLabelPoint, roomsToCsv, SIA_CATEGORIES, siaLabel } from "./roomArea";
describe("Kern-Anbindung", () => {
it("Kategorie-Namen und -Reihenfolge stimmen mit dem Rust-Kern überein", () => {
@@ -123,3 +123,15 @@ describe("roomsToCsv() — Bilanzblock mit AGF", () => {
expect(gfLine).toContain("26.00");
});
});
describe("roomLabelPoint", () => {
it("[140] liegt im L-Raum, nicht am Schwerpunkt ausserhalb", () => {
// schmales L: Schwerpunkt (≈ 1.4/1.4) liegt ausserhalb
const l = [{ x: 0, y: 0 }, { x: 6, y: 0 }, { x: 6, y: 1 }, { x: 1, y: 1 }, { x: 1, y: 6 }, { x: 0, y: 6 }];
const c = centroid(l);
expect(c.x > 1 && c.y > 1).toBe(true);
const q = roomLabelPoint(l);
expect((q.x < 1 && q.y > 0 && q.y < 6) || (q.y < 1 && q.x > 0 && q.x < 6)).toBe(true);
expect(roomLabelPoint([{ x: 0, y: 0 }, { x: 4, y: 0 }, { x: 4, y: 2 }, { x: 0, y: 2 }])).toEqual({ x: 2, y: 1 });
});
});
+10
View File
@@ -34,6 +34,16 @@ export function centroid(pts: Vec2[]): Vec2 {
return { x: c[0], y: c[1] };
}
/**
* [140] Ankerpunkt des Raumstempels ohne eigenen Anker: Pol der Unzugänglichkeit (Kern
* `room_area::label_point`) — liegt auch in L-förmigen/konkaven Räumen im Raum, bei
* Rechtecken in der Mitte. Gleicher Punkt wie Plan, Griff und Fang.
*/
export function roomLabelPoint(pts: Vec2[]): Vec2 {
const c = core().room_label_point(new FlatWriter().pts(pts).done());
return { x: c[0], y: c[1] };
}
// ── SIA-416-Kategorie-Hierarchie ─────────────────────────────────────────────
//
// SIA 416 gliedert die Geschossfläche (GF) eines Gebäudes hierarchisch:
+1
View File
@@ -1148,6 +1148,7 @@ export const de = {
"resources.viewTemplates.mono": "Tusche",
"resources.viewTemplates.shadows": "Schatten",
"resources.viewTemplates.hiddenLines": "Verdeckte Kanten",
"resources.viewTemplates.cutHatch": "Schnittflächen 1:100 schraffiert (statt schwarz)",
"resources.viewTemplates.sketch": "Skizzenstil",
"resources.viewTemplates.scaleLineWeights": "Strichstärken skalieren",
"resources.viewTemplates.rangeHint": "Ansichtsbereich (Meter über OKFF): Schnitthöhe, Oberkante und Unterkante der Sichtweite, darunter sichtbar bis.",
+1
View File
@@ -1142,6 +1142,7 @@ export const en: Record<TranslationKey, string> = {
"resources.viewTemplates.mono": "Ink",
"resources.viewTemplates.shadows": "Shadows",
"resources.viewTemplates.hiddenLines": "Hidden lines",
"resources.viewTemplates.cutHatch": "Hatched cut areas at 1:100 (instead of solid black)",
"resources.viewTemplates.sketch": "Sketch style",
"resources.viewTemplates.scaleLineWeights": "Scale line weights",
"resources.viewTemplates.rangeHint": "View range (metres above finished floor): cut plane, top and bottom of the view depth, visible below down to.",
+7
View File
@@ -1118,6 +1118,11 @@ export type DrawingLevel = {
* Wirkt auf Grundriss, Schnitt und Ansicht dieser Ebene; Default aus.
*/
sketch?: boolean;
/**
* [140] Schnittflächen (Wände, Stützen, Decken) auch ab 1:100 mit Schichten und Schraffur statt als
* schwarze Fläche (Poché). Fehlt/aus: ab 1:100 schwarz, 1:50 und Detail „fein" schraffiert.
*/
cutHatch?: boolean;
/**
* Grundriss-Unterlage (nur Schnitt/Ansicht): ID eines Geschosses, dessen
* Grundriss AUSGERICHTET unter dem Schnitt/der Ansicht gezeigt wird (Schnitt-
@@ -3299,6 +3304,8 @@ export type ViewTemplate = {
hiddenLines?: boolean;
/** Skizzenstil ([67]). */
sketch?: boolean;
/** [140] Schnittflächen ab 1:100 schraffiert statt schwarz (s. `DrawingLevel::cut_hatch`). */
cutHatch?: boolean;
/** Strichstärken mit dem Massstab skalieren. */
scaleLineWeights?: boolean;
/** Schnitthöhe über OKFF ([36]). */
@@ -1,11 +1,11 @@
viewBox -4 0 23 18
bytes 317431
bytes 310337
circle 14
g 1
line 3227
polygon 75
polyline 73
line 3226
polygon 21
polyline 68
rect 1
svg 1
text 36
hash 008b41292083538c
hash 45b4d584a3e141d6
@@ -1,11 +1,11 @@
viewBox -4 0 23 18
bytes 323091
bytes 320692
circle 14
g 1
line 3240
line 3227
polygon 75
polyline 84
polyline 73
rect 1
svg 1
text 36
hash 92ee43948feacb35
hash e0545755beab6d46
@@ -1,12 +1,12 @@
viewBox -41.5 0 95 63.6
bytes 112686
bytes 85358
circle 16
g 1
line 338
path 39
polygon 266
polyline 126
line 314
path 18
polygon 104
polyline 110
rect 1
svg 1
text 115
hash 1902777252ac56f7
text 118
hash cef117cef66ccd65
@@ -1,12 +1,12 @@
viewBox -41.5 0 95 63.6
bytes 117858
bytes 113593
circle 16
g 1
line 349
path 45
line 338
path 39
polygon 266
polyline 151
polyline 126
rect 1
svg 1
text 118
hash 41dada4449c225f7
text 121
hash 7e22563a4804f932
@@ -1,12 +1,11 @@
viewBox -4.055 0 25.109 23.11
bytes 366321
bytes 339103
circle 14
g 1
line 3333
path 21
polygon 227
polyline 169
line 3310
polygon 66
polyline 154
rect 1
svg 1
text 89
hash 3e20e7dadb42197b
text 91
hash 46723498044c422b
@@ -1,12 +1,12 @@
viewBox -4.055 0 25.109 23.11
bytes 374960
bytes 369846
circle 14
g 1
line 3350
path 27
line 3333
path 21
polygon 227
polyline 195
polyline 169
rect 1
svg 1
text 91
hash 6e48062b617631c7
hash be529b7ce07ecad8
@@ -1,12 +1,12 @@
viewBox -10.004 0 31.058 26.958
bytes 61136
bytes 52665
circle 14
g 1
line 171
path 13
polygon 105
polyline 77
line 166
path 2
polygon 60
polyline 73
rect 1
svg 1
text 74
hash 29b459e18b552b28
text 75
hash 5819887a677f289a
@@ -1,12 +1,12 @@
viewBox -10.004 0 31.058 26.958
bytes 62056
bytes 61331
circle 14
g 1
line 173
path 15
line 171
path 13
polygon 105
polyline 80
polyline 77
rect 1
svg 1
text 75
hash b317c0dda4bab8ed
hash 1f584745aa154d01
@@ -1,11 +1,11 @@
viewBox 4.457 0 21.343 17.678
bytes 36282
bytes 40531
circle 3
g 1
line 105
polygon 136
polyline 14
line 96
polygon 186
polyline 13
rect 1
svg 1
text 3
hash ff9a1be90fae7d83
hash 2bfa93e2c1d3a9c8
@@ -1,10 +1,10 @@
viewBox -0.672 0 6.345 5.345
bytes 11826
bytes 7890
g 1
line 33
polygon 62
polyline 8
line 32
polygon 30
polyline 4
rect 1
svg 1
text 7
hash 6d3b7926ca1a3a6d
hash bdf6e70cae4a0a08
@@ -1,10 +1,10 @@
viewBox -0.672 0 6.345 5.345
bytes 12491
bytes 11830
g 1
line 34
line 33
polygon 62
polyline 13
polyline 8
rect 1
svg 1
text 7
hash 7378e595c698986f
hash 24dc3848bf391596
@@ -1,10 +1,10 @@
viewBox -0.9 0 6.8 5.8
bytes 5572
bytes 3630
g 1
line 15
polygon 26
polygon 9
polyline 4
rect 1
svg 1
text 4
hash 97d2aa8ea90eafff
hash da75b90e9db14090
@@ -1,10 +1,10 @@
viewBox -0.9 0 6.8 5.8
bytes 5816
bytes 5578
g 1
line 15
polygon 28
polygon 26
polyline 4
rect 1
svg 1
text 4
hash 7ca726f020333afb
hash 860efb50b93e47d9
@@ -1,9 +1,9 @@
viewBox 0.1 0 6.8 7.586
bytes 6662
bytes 6451
g 1
line 31
polygon 23
polyline 6
line 21
polygon 34
polyline 4
rect 1
svg 1
hash 68fbe08143832562
hash bfdb9a52ee2f2f02
+2 -2
View File
@@ -69,9 +69,9 @@ function column(overrides: Partial<Column> = {}): Column {
};
}
/** Grundriss des Geschosses „eg" mit genau dieser Stütze. */
/** Grundriss des Geschosses „eg" mit genau dieser Stütze (1:50 — ab 1:100 ist die Schnittfläche schwarz, [140]). */
function planColumn(p: Project, col: Column): Primitive[] {
return generatePlan({ ...p, columns: [col] }, "eg", new Set(["50"])).primitives;
return generatePlan({ ...p, columns: [col] }, "eg", new Set(["50"]), undefined, "mittel", false, false, true, 50).primitives;
}
function polygonOf(out: Primitive[]): Extract<Primitive, { kind: "polygon" }> {
+1 -1
View File
@@ -44,7 +44,7 @@ function cornerProject(): Project {
},
],
drawingLevels: [
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 },
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0, cutHatch: true },
],
layers: [{ code: "20", name: "Wände", color: "#0a0a0a", lw: 0.5, visible: true, locked: false }],
walls: [
+1 -1
View File
@@ -48,7 +48,7 @@ function tJunctionProject(): Project {
},
],
drawingLevels: [
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 },
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0, cutHatch: true },
],
layers: [{ code: "20", name: "Wände", color: "#0a0a0a", lw: 0.5, visible: true, locked: false }],
walls: [
+3 -3
View File
@@ -30,7 +30,7 @@ function project(): Project {
components: [{ id: "a", name: "A", color: "#d8d2c7", hatchId: "none", joinPriority: 10 }],
wallTypes: [{ id: "aw", name: "AW", layers: [{ componentId: "a", thickness: 0.2 }] }],
drawingLevels: [
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 },
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0, cutHatch: true },
],
layers: [{ code: "20", name: "Wände", color: "#0a0a0a", lw: 0.5, visible: true, locked: false }],
walls: [
@@ -138,7 +138,7 @@ function nonSolidWallProject(): Project {
components: [{ id: "brick", name: "Backstein", color: "#c9a876", hatchId: "diag", joinPriority: 10 }],
wallTypes: [{ id: "aw", name: "AW", layers: [{ componentId: "brick", thickness: 0.3 }] }],
drawingLevels: [
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 },
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0, cutHatch: true },
],
layers: [{ code: "20", name: "Wände", color: "#0a0a0a", lw: 0.5, visible: true, locked: false }],
walls: [wall],
@@ -185,7 +185,7 @@ function ceilingProject(): Project {
components: [{ id: "a", name: "A", color: "#d8d2c7", hatchId: "none", joinPriority: 10 }],
wallTypes: [{ id: "aw", name: "AW", layers: [{ componentId: "a", thickness: 0.2 }] }],
drawingLevels: [
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 },
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0, cutHatch: true },
],
layers: [{ code: "30", name: "Decken", color: "#0a0a0a", lw: 0.5, visible: true, locked: false }],
walls: [],
+4 -2
View File
@@ -257,13 +257,15 @@ describe('GpuChunkCache: Kern-Abschnitte (Plan-Puffer v2, Inhalts-Hash)', () =>
const p = bigSampleProject(8);
const { gl } = makeGl();
const cache = new GpuChunkCache(gl);
const a = generatePlan(p, 'eg', codes(p));
// 1:50: Wände mit Schichten (ab 1:100 eine schwarze Fläche je Wand, [140]) → genug Chunks.
const gen = (q: typeof p) => generatePlan(q, 'eg', codes(q), undefined, 'mittel', false, false, true, 50);
const a = gen(p);
cache.update(a.primitives, 90, 6, a.greyedRanges, a.underlay, a.bufRuns);
const total = cache.lastStats.chunks;
expect(total).toBeGreaterThan(8);
const walls = p.walls.slice();
walls[200] = { ...walls[200], end: { x: walls[200].end.x + 0.05, y: walls[200].end.y } };
const b = generatePlan({ ...p, walls }, 'eg', codes(p));
const b = gen({ ...p, walls });
cache.update(b.primitives, 90, 6, b.greyedRanges, b.underlay, b.bufRuns);
expect(cache.lastStats.recompiled).toBeGreaterThan(0);
expect(cache.lastStats.recompiled).toBeLessThanOrEqual(3);
+2 -1
View File
@@ -55,7 +55,8 @@ describe("Schnitt: Gelände und freie Körper", () => {
brep: { spec: { kind: "sphere", center: [px, pz, 1], r: 1 }, origin: { x: px - 1, y: pz - 1 } },
};
const p: Project = { ...sampleProject, extrudedSolids: [...(sampleProject.extrudedSolids ?? []), sphere] };
const plan = generateSectionPlan((await computeSection(p, section))!);
// 1:50 (ab 1:100 sind Schnittflächen schwarz, [140])
const plan = generateSectionPlan((await computeSection(p, section))!, false, { scaleDenominator: 50 });
expect(plan.primitives.some((q) => q.kind === "polygon" && q.extrudedSolidId === "ball" && q.fill === "#d9dde2")).toBe(true);
}, 30_000);
+1 -1
View File
@@ -53,7 +53,7 @@ describe("planToRenderScene (Kern)", () => {
});
it("Binärszene: Zähler wie die Objekt-Szene", () => {
const plan = generatePlan(sampleProject, "eg", codes);
const plan = generatePlan(sampleProject, "eg", codes, undefined, "mittel", false, false, true, 50);
const s = planToRenderScene(plan);
const b = planSceneBin(plan);
const h = new Uint32Array(b.buffer, b.byteOffset, 12);
+12 -2
View File
@@ -5,7 +5,7 @@
// Sichtbarkeit (UI-Zustand) und die asynchron gebauten truck-Körper hinein. Einheiten: Meter; u entlang
// der Ebene (Blickrichtungs-RECHTS), v = absolute Höhe.
import type { DrawingLevel, Project, Vec2 } from "../model/types";
import type { DetailLevel, DrawingLevel, Project, Vec2 } from "../model/types";
import { flattenCategories, getFloor } from "../model/types";
import { withDocument } from "../core/document";
import { buildSolidMesh } from "../engine/truckSolid";
@@ -113,6 +113,7 @@ export function levelArg(level: DrawingLevel) {
shadows: level.shadows,
hiddenLines: level.hiddenLines,
sketch: level.sketch,
cutHatch: level.cutHatch,
};
}
@@ -123,7 +124,15 @@ export function levelArg(level: DrawingLevel) {
export function generateSectionPlan(
output: SectionOutput,
mono = false,
opts: { hiddenLines?: boolean; visibleCodes?: Set<string>; categoryDisplay?: CategoryDisplayResolver; openings?: boolean; scaleDenominator?: number } = {},
opts: {
hiddenLines?: boolean;
visibleCodes?: Set<string>;
categoryDisplay?: CategoryDisplayResolver;
openings?: boolean;
scaleDenominator?: number;
/** [140] Detailgrad: „fein" zeigt auch ab 1:100 alle dünnen Schichten (Standard „mittel"). */
detail?: DetailLevel;
} = {},
): Plan {
const { project, level } = output;
const text = JSON.stringify({
@@ -131,6 +140,7 @@ export function generateSectionPlan(
hiddenLines: !!opts.hiddenLines,
// Massstabsnenner für die Achsblasen des Rasters ([112]); Default 100.
scale: opts.scaleDenominator ?? 100,
detail: opts.detail,
...visibilityArgs(project, opts.visibleCodes, opts.categoryDisplay),
});
const args = output.bodies.slice();
+1 -1
View File
@@ -44,7 +44,7 @@ export async function viewportLevelPlan(
if (level.kind === "section") {
const out = await computeSection(project, level);
raw = out
? generateSectionPlan(out, mono, { hiddenLines: level.hiddenLines, visibleCodes, openings: true, scaleDenominator })
? generateSectionPlan(out, mono, { hiddenLines: level.hiddenLines, visibleCodes, openings: true, scaleDenominator, detail })
: null;
} else {
raw = generateElevationPlan(project, level, { visibleCodes, scaleDenominator, mono });
+1 -1
View File
@@ -29,7 +29,7 @@ export interface ViewTemplateUi {
}
/** Geschoss-Felder, die eine Vorlage setzt (fehlt das Vorlagen-Feld, bleibt die Ansicht unberührt). */
const LEVEL_KEYS = ["cutHeight", "viewTop", "viewBottom", "viewDepth", "shadows", "hiddenLines", "sketch"] as const;
const LEVEL_KEYS = ["cutHeight", "viewTop", "viewBottom", "viewDepth", "shadows", "hiddenLines", "sketch", "cutHatch"] as const;
/** Teilobjekt für das Geschoss aus den gesetzten Feldern der Vorlage. */
export function levelPatch(t: ViewTemplate): Partial<DrawingLevel> {
+2 -1
View File
@@ -53,7 +53,7 @@ function TemplateDetail({
<NumberField value={tpl[key] ?? dflt} step={0.1} onChange={(v) => patch({ [key]: v })} />
</Optional>
);
const bool = (key: "mono" | "shadows" | "hiddenLines" | "scaleLineWeights" | "sketch", label: string) => (
const bool = (key: "mono" | "shadows" | "hiddenLines" | "scaleLineWeights" | "sketch" | "cutHatch", label: string) => (
<Optional label={label} on={tpl[key] !== undefined} onToggle={(on) => patch({ [key]: on ? false : null })}>
<input type="checkbox" checked={tpl[key] === true} onChange={(e) => patch({ [key]: e.target.checked })} />
</Optional>
@@ -93,6 +93,7 @@ function TemplateDetail({
{bool("hiddenLines", t("resources.viewTemplates.hiddenLines"))}
{bool("scaleLineWeights", t("resources.viewTemplates.scaleLineWeights"))}
{bool("sketch", t("resources.viewTemplates.sketch"))}
{bool("cutHatch", t("resources.viewTemplates.cutHatch"))}
<div className="res-hint">{t("resources.viewTemplates.rangeHint")}</div>
{num("cutHeight", t("resources.viewTemplates.cutHeight"), 1.0)}
{num("viewTop", t("resources.viewTemplates.viewTop"), 2.5)}
+3 -2
View File
@@ -641,7 +641,7 @@ function useCrossKindOverlay(
} else if (l.kind === "section") {
const sOut = sectionOutputs[l.id];
prims = sOut
? generateSectionPlan(sOut, mono, { hiddenLines: l.hiddenLines, visibleCodes, categoryDisplay, scaleDenominator })
? generateSectionPlan(sOut, mono, { hiddenLines: l.hiddenLines, visibleCodes, categoryDisplay, scaleDenominator, detail })
.primitives
: [];
} else {
@@ -1083,9 +1083,10 @@ function SectionPlanView({
categoryDisplay,
openings: true,
scaleDenominator,
detail,
})
: null,
[isElevation, output, mono, level.hiddenLines, visibleCodes, categoryDisplay, inputs, scaleDenominator],
[isElevation, output, mono, level.hiddenLines, visibleCodes, categoryDisplay, inputs, scaleDenominator, detail],
);
const rawPlan = isElevation ? elevationPlan : sectionPlan;
// Grundriss-Unterlage (Nutzer-Wunsch: "in der Ansicht auch mal einen