[140] Plandarstellung Teil 5: Schnittflächen 1:100 schwarz, dünne Schichten, Raumstempel im L-Raum

- Schnittflächen ab 1:100 (mittel; grob immer) als schwarze Fläche ohne Fugen/Schraffur, nur Umriss:
  Wände, Stützen, Körper im Grundriss, alle geschnittenen Bauteile im Schnitt (style::solid_cut).
  1:50 und „fein" schraffiert; Feld cutHatch an Ebene/Ansichtsvorlage übersteuert das 1:100.
- Dünne Schichten: gemeinsame Regel in plan/style.rs (unter 0.5 mm Papier, ab 1:50, nicht „fein")
  für Wände im Grundriss, Schnitt-Schichten und dünne Dämmung.
- Raumstempel: Anker = Pol der Unzugänglichkeit (room_area::label_point), Platz aus dem Raumumriss
  (rect_in_ring) statt Bounding-Box, Ausweichen im Raum, Breite aus Inter-Schriftmetrik
  (text_layout::text_width_em, stamp_block_size); neue Räume ohne festen Anker.
- Goldens neu, TODO.md nachgeführt.
This commit is contained in:
Claude committed 2026-11-06 15:39:04 +00:00
1 parent 6d41a84511
commit ce631273a6
50 files changed
+829 -268

No files matched your search

-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();
}
out.push(polygon(crate::model3d::column_footprint(col), &fill, stroke, lw, hatch, greyed, None, Pick::Column(&col.id)));
if let Some(d) = range.restyle_dash(zone) {
super::view_range::restyle(out, out_start, d);
@@ -778,7 +846,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)));
}
}
}
@@ -1090,8 +1159,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");
@@ -1108,26 +1178,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() {
@@ -1515,8 +1657,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;
@@ -1572,6 +1715,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));
}
}
+25 -17
View File
@@ -197,20 +197,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;
}
@@ -246,7 +243,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(());
@@ -1219,24 +1217,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.