[K3c] TS-Fassung von Schnitt/Ansicht gelöscht: Fassaden toSection/toElevation, Tests auf den Kern umgestellt, Gleichheitstest entfernt
This commit is contained in:
41 files changed
+320
-5070
No files matched your search
@@ -105,14 +105,14 @@ truck (`trucksolid`) bleibt eigenes WASM-Modul (Panic-Isolation), wird vom Kern
|
||||
Offen: `drawing2d.ts` (950 Zeilen) ist nach diesen Schritten Stil-Auflösung und Verteiler über Formen (Bemassung, Kote,
|
||||
Detailverweis, Massstabsbalken, Block über `scaleGeom`); der Rechenanteil liegt in Rust. Der Verteiler zieht mit dem Modell
|
||||
nach Rust [K4] — vorher würde ein Rust-`Drawing2D` doppelt gepflegt. Danach: [K3c] Schnitt/Ansicht, [K3d] Aufräumen.
|
||||
- ◐ **[K3c] Schnitt und Ansicht** (`toSection`, `toElevation`, `meshSection`) im selben Puffer-Format.
|
||||
- ✅ **[K3c] Schnitt und Ansicht** (`toSection`, `toElevation`, `meshSection`) im selben Puffer-Format (29.10.).
|
||||
✅ Schnitt-Bänder: Dominanz-Subtraktion, Verschmelzung, Rechteck-Vereinigung (`plan_section.rs`, 28.10.).
|
||||
✅ Ansicht: Verdeckungs-Clipping, Punkt-Verdeckung, Schlagschatten, XOR-Umriss (`plan_elevation.rs`, 28.10.).
|
||||
✅ Ansicht: Flächen (Wand-Quader, Decken-Prismen, Dach/Giebel) projizieren + Rückseiten-Culling, Eck-Verlängerung, Öffnungen (Rahmen, Glasfelder, Sprossen, Sims, SIA-Symbol) (`plan_elevation.rs`).
|
||||
✅ Netz-Ebenenschnitt (Körper/Gelände) + Ringe→Flächen (`mesh_section.rs`; behebt nebenbei: rückwärts geschlossene Ringe gingen verloren).
|
||||
✅ Dach-Schnittspur (Cyrus–Beck, lineare Oberkante, Verschmelzen) in `plan_section.rs`.
|
||||
✅ Abzugskörper-Geometrie (`voids.rs`: Polygon minus Schneider mit Schlüsselloch-Stegen, Strecke ausserhalb, Schnitt-Rechtecke); behebt: bei mehreren getrennten Aussparungen wurde nichts abgezogen.
|
||||
◐ (29.10.) Schnitt und Ansicht als Kern-Abfragen `sectionPlan`/`elevationPlan` (`core/src/plan/{section,elevation}.rs`) auf dem
|
||||
✅ (29.10.) Schnitt und Ansicht als Kern-Abfragen `sectionPlan`/`elevationPlan` (`core/src/plan/{section,elevation}.rs`) auf dem
|
||||
Dokument, Ausgabe Plan-Puffer v2 mit Pick-Ids (lazy gelesen wie `generatePlan`): Besitzer-Zuordnung, Schicht-Bänder, Stil,
|
||||
Decken-Terminierung, Dominanz, Treppen, Monolith, Abzugskörper, Gelände, Schnitt-Tiefe, geschnittene Fenster/Türen
|
||||
(`sectionOpenings`), Ansicht mit Eck-Verlängerung, Verdeckung, Schatten, Painter. Der Prismen-Schnitt läuft über
|
||||
@@ -134,9 +134,15 @@ truck (`trucksolid`) bleibt eigenes WASM-Modul (Panic-Isolation), wird vom Kern
|
||||
Der Kern merkt sich die zuletzt vorbereiteten Schnitte (Schlüssel je `computeSection`): Schwarz-Weiss/Sichtbarkeit
|
||||
umschalten 8×8 ~1 ms statt Neurechnen. Offen: Szene mit vielen verdeckten (gestrichelten) Kanten bleibt teuer
|
||||
(16×16 mit verdeckten Kanten ~2,5 s, Strichmuster-Zerlegung in `plan_scene`).
|
||||
Rest in TS (28.10.): Stil-Auflösung (Bauteil, Schraffur, Farbe, Linienstil, Pick-IDs, Painter-Reihenfolge) in `generatePlan*.ts`,
|
||||
`toSection.ts` (Besitzer-Zuordnung, Schichtbänder), `toElevation.ts` (Orchestrierung), `sectionOpenings.ts`, `planUnderlay.ts`,
|
||||
`drawing2d.ts`. Das ist kein Rechenanteil mehr, sondern liest das Modell; es zieht mit [K4] um.
|
||||
TS-Fassung gelöscht (29.10.): `toSection.ts`/`toElevation.ts` sind dünne Fassaden (Ebene, Sichtbarkeit, truck-Körper →
|
||||
Abfrage), `sectionOpenings.ts`, `sectionExtras.ts`, `meshSection.ts`, `generateSectionPlan`/`resolve*SectionStyle` in
|
||||
`generatePlan.ts`, `windowSymbol` (opening.ts), `keyhole`/`voidSectionRects`/`subtractVoidsInSection` (voids.ts) und ihre
|
||||
Bindungen entfernt; die Fälle der alten TS-Einzeltests laufen als Rust-Tests (`plan/section.rs`, `plan_section.rs`,
|
||||
`plan_elevation.rs`, `mesh_section.rs`), die übrigen TS-Tests (Ansicht, Öffnungen, Gelände/Körper, Golden-SVG) gegen den
|
||||
neuen Weg; der Gleichheitstest ist wieder entfernt. Nicht in der Tauri-App angesehen; pkg3d (3D-Live-Schnitt, gleiche
|
||||
render3d-Verdeckung) nicht neu gebaut.
|
||||
Bleibt in TS: `planUnderlay.ts` (legt den TS-Grundriss unter Schnitt/Ansicht; zieht mit `generatePlan`/`drawing2d.ts` um),
|
||||
Bodenhöhen-Koten (`levelMarkers.ts`), das Bauen der truck-Körper (asynchron, eigenes WASM).
|
||||
- ◐ **[K3d] Aufräumen:** TS-Primitive-Erzeugung löschen, SVG/PDF/DXF-Export lesen den Puffer. Hängt an [K4]: Rust braucht das
|
||||
typisierte Modell (Bauteil-Typen, Schraffuren, Linienstile, Kategorien) und einen Plan-Puffer v2 mit Pick-IDs + vollem `Primitive`-Umfang
|
||||
(Text, Schraffur-Optionen, Zickzack/Motiv); die Verbraucher von `Primitive[]` (SVG/PDF/DXF, Auswahl, Overlay) lesen dann den Puffer.
|
||||
|
||||
@@ -1987,3 +1987,94 @@ mod ts_faelle {
|
||||
assert!(bands.iter().all(|b| b.fill.as_deref() == Some("#123456")));
|
||||
}
|
||||
}
|
||||
|
||||
/// Früher `toSection.roof.test.ts` (mehrschichtiges Dach, Nähte deckungsgleicher Teilflächen).
|
||||
#[cfg(test)]
|
||||
mod dach_faelle {
|
||||
use super::*;
|
||||
|
||||
fn project(roof: serde_json::Value, extra: serde_json::Value) -> Project {
|
||||
let mut v = serde_json::json!({
|
||||
"id": "t", "name": "T", "lineStyles": [], "hatches": [], "components": [], "wallTypes": [],
|
||||
"drawingLevels": [], "layers": [], "walls": [], "roofs": [roof]
|
||||
});
|
||||
for (k, x) in extra.as_object().unwrap() {
|
||||
v[k] = x.clone();
|
||||
}
|
||||
serde_json::from_value(v).unwrap()
|
||||
}
|
||||
|
||||
fn roof(over: serde_json::Value) -> serde_json::Value {
|
||||
let mut r = serde_json::json!({
|
||||
"id": "R1", "type": "roof", "floorId": "eg", "categoryCode": "35",
|
||||
"outline": [{"x": -3, "y": 0}, {"x": 3, "y": 0}, {"x": 3, "y": 4}, {"x": -3, "y": 4}],
|
||||
"shape": "sattel", "pitchDeg": 30, "overhang": 0, "ridgeAxis": "x", "baseElevation": 5, "thickness": 0.3
|
||||
});
|
||||
for (k, x) in over.as_object().unwrap() {
|
||||
r[k] = x.clone();
|
||||
}
|
||||
r
|
||||
}
|
||||
|
||||
fn plane(point: [f64; 3], normal: [f64; 3]) -> Plane {
|
||||
Plane { point, normal }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mehrschichtiges_dach_je_schicht_ein_band_aussen_oben() {
|
||||
let p = project(
|
||||
roof(serde_json::json!({ "shape": "flach", "pitchDeg": 0, "roofTypeId": "rt1" })),
|
||||
serde_json::json!({
|
||||
"hatches": [{ "id": "h1", "name": "H", "pattern": "diagonal", "scale": 1, "angle": 45, "color": "#111111" }],
|
||||
"components": [
|
||||
{ "id": "tile", "name": "Ziegel", "color": "#a03a2a", "hatchId": "h1", "joinPriority": 1 },
|
||||
{ "id": "ins", "name": "Dämmung", "color": "#ffffff", "hatchId": "h1", "joinPriority": 2 }
|
||||
],
|
||||
"roofTypes": [{ "id": "rt1", "name": "Aufbau", "layers": [{ "componentId": "tile", "thickness": 0.05 }, { "componentId": "ins", "thickness": 0.25 }] }]
|
||||
}),
|
||||
);
|
||||
let mut cuts = Vec::new();
|
||||
append_roof_sections(&mut cuts, &p, &plane([0.0, 0.0, 0.0], [1.0, 0.0, 0.0]));
|
||||
assert_eq!(cuts.len(), 2);
|
||||
let tops: Vec<f64> = cuts.iter().map(|c| bbox(&c.pts)[3]).collect();
|
||||
assert!((tops[0] - 5.0).abs() < 1e-6 && (tops[1] - 4.95).abs() < 1e-6, "{tops:?}");
|
||||
assert!(cuts.iter().all(|c| c.hatch.as_ref().is_some_and(|h| h.pattern == HatchPattern::Diagonal)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn l_walmdach_deckungsgleiche_teilflaechen_ein_band() {
|
||||
let l = serde_json::json!([{"x": 0, "y": 0}, {"x": 11, "y": 0}, {"x": 11, "y": 4}, {"x": 8, "y": 4}, {"x": 8, "y": 6}, {"x": 0, "y": 6}]);
|
||||
for y in [1.0, 2.0] {
|
||||
let p = project(roof(serde_json::json!({ "outline": l, "shape": "walm" })), serde_json::json!({}));
|
||||
let mut cuts = Vec::new();
|
||||
append_roof_sections(&mut cuts, &p, &plane([0.0, 0.0, y], [0.0, 0.0, 1.0]));
|
||||
assert_eq!(cuts.len(), 3, "Schnitt bei y = {y}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Früher `voids.test.ts` (Schnitt): Abzugskörper = Grundfläche × Höhenbereich, aus den Cut-Bändern
|
||||
/// abgezogen.
|
||||
#[cfg(test)]
|
||||
mod abzug_faelle {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn abzugskoerper_wird_aus_dem_schnittband_gezogen() {
|
||||
let mut p: Project = serde_json::from_str(include_str!("../../tests/fixtures/sample_project.json")).unwrap();
|
||||
let (mx, my) = (2.5, 0.0);
|
||||
let solid: ExtrudedSolid = serde_json::from_value(serde_json::json!({
|
||||
"id": "void1", "type": "extrudedSolid", "levelId": "eg", "operation": "subtract", "height": 1.0, "baseOffset": 0.5,
|
||||
"points": [{"x": mx - 0.3, "y": my - 1.0}, {"x": mx + 0.3, "y": my - 1.0}, {"x": mx + 0.3, "y": my + 1.0}, {"x": mx - 0.3, "y": my + 1.0}]
|
||||
}))
|
||||
.unwrap();
|
||||
p.extruded_solids = Some(vec![solid]);
|
||||
let band = Cut::new(Kind::Wall, 0, vec![[mx - 2.0, 0.0], [mx + 2.0, 0.0], [mx + 2.0, 2.5], [mx - 2.0, 2.5]]);
|
||||
let out = subtract_voids_in_section(vec![band], &p, (0.0, my), (1.0, 0.0));
|
||||
assert_eq!(out.len(), 1);
|
||||
let pts: Vec<(f64, f64)> = out[0].pts.iter().map(|q| (q[0], q[1])).collect();
|
||||
let area = (0..pts.len()).map(|i| { let (a, b) = (pts[i], pts[(i + 1) % pts.len()]); a.0 * b.1 - b.0 * a.1 }).sum::<f64>().abs() / 2.0;
|
||||
assert!((area - (4.0 * 2.5 - 0.6 * 1.0)).abs() < 1e-6, "{area}");
|
||||
assert_eq!(out[0].nse.as_ref().map(|n| n.len()), Some(2), "Schlüsselloch-Stege ungestrichen");
|
||||
}
|
||||
}
|
||||
@@ -316,60 +316,6 @@ fn frame_band(o: &mut Out, w: &WallRef, position: f64, width: f64, frame_width:
|
||||
|
||||
// ── Fenster-Symbol als Einzelaufruf (für die Fassade `windowSymbol`, z. B. im Schnitt) ──────────
|
||||
|
||||
/// Eingabe `[sx, sy, ex, ey, dicke, refOff, position, breite, glasAnzahl, altFluegel (NaN = 1),
|
||||
/// detail, hatTyp, profilbreite, rahmentiefe (NaN), einzug (NaN), einzugInnen, nFluegel,
|
||||
/// (pfosten, auto, breite, pfostenbreite, oeffenbar) × n]`; Ausgabe
|
||||
/// `[1, Rahmen(4 Punkte), nGlas, 4 Zahlen × n, nPfosten, 4 × n, nFluegelRahmen, (nPts, pts…) × n,
|
||||
/// nStoss, (nPts, pts…) × n, nLaibung, (nPts, pts…) × n]` oder leer.
|
||||
pub fn window_symbol_flat(buf: &[f64]) -> Vec<f64> {
|
||||
(|| {
|
||||
let mut r = Reader::new(buf);
|
||||
let (sx, sy, ex, ey, total, ref_off, position, width) =
|
||||
(r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?);
|
||||
let glass = r.num()?;
|
||||
let wings = r.num()?;
|
||||
let detail = match r.num()? as i64 {
|
||||
0 => Detail::Grob,
|
||||
1 => Detail::Mittel,
|
||||
_ => Detail::Fein,
|
||||
};
|
||||
let has_type = r.num()? != 0.0;
|
||||
let (fw, fd, inset) = (r.num()?, r.num()?, r.num()?);
|
||||
let inner = r.num()? != 0.0;
|
||||
let n = r.count()?;
|
||||
let mut sashes = Vec::with_capacity(n);
|
||||
for _ in 0..n {
|
||||
sashes.push(Sash { post: r.num()? != 0.0, auto_width: r.num()? != 0.0, width: r.num()?, post_width: r.num()?, operable: r.num()? != 0.0 });
|
||||
}
|
||||
if ![sx, sy, ex, ey, total, ref_off, position, width].iter().all(|x| x.is_finite()) {
|
||||
return None;
|
||||
}
|
||||
let w = WallRef { start: v(sx, sy), end: v(ex, ey), total, ref_off };
|
||||
let spec = if has_type { Some(WindowSpec { sashes, frame_width: fw, frame_depth: fd, inset_from_face: inset, inset_inner: inner }) } else { None };
|
||||
let s = window_symbol(&w, position, width, glass, spec.as_ref(), wings, detail)?;
|
||||
let mut out = vec![1.0];
|
||||
for p in &s.frame {
|
||||
out.extend([p.x, p.y]);
|
||||
}
|
||||
for list in [&s.glass_lines, &s.mullion_lines] {
|
||||
out.push(list.len() as f64);
|
||||
for (a, b) in list.iter() {
|
||||
out.extend([a.x, a.y, b.x, b.y]);
|
||||
}
|
||||
}
|
||||
for rings in [&s.sash_frames, &s.meeting_marks, &s.jamb_marks] {
|
||||
out.push(rings.len() as f64);
|
||||
for pts in rings.iter() {
|
||||
out.push(pts.len() as f64);
|
||||
for p in pts {
|
||||
out.extend([p.x, p.y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(out)
|
||||
})()
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
@@ -433,7 +379,6 @@ mod tests {
|
||||
let mut c = input(true, 1.0, false, &[]);
|
||||
c[0] = f64::NAN;
|
||||
assert!(plan_opening(&c).is_empty());
|
||||
assert!(window_symbol_flat(&[]).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
//! Bindungen des Netz-Ebenenschnitts (`crate::mesh_section`). Layouts s. dort.
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Schnitt eines Dreiecksnetzes mit einer Ebene; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn mesh_section_cut_flat(positions: &[f64], indices: &[f64], plane: &[f64]) -> Vec<f64> {
|
||||
crate::mesh_section::cut(positions, indices, plane)
|
||||
}
|
||||
|
||||
/// Ringe → Flächen mit Löchern; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn mesh_section_polygons_flat(input: &[f64]) -> Vec<f64> {
|
||||
crate::mesh_section::rings_to_polygons(input)
|
||||
}
|
||||
@@ -20,14 +20,10 @@ mod wall_mesh_cut;
|
||||
mod plan_buf;
|
||||
mod project_format;
|
||||
mod gpu_compile;
|
||||
mod plan_openings;
|
||||
mod delaunay;
|
||||
mod document;
|
||||
mod ops;
|
||||
mod mesh_section;
|
||||
mod plan_elevation;
|
||||
mod plan_misc;
|
||||
mod plan_section;
|
||||
mod voids;
|
||||
mod curves;
|
||||
mod hatch;
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
//! Bindungen der Ansichts-Geometrie (`crate::plan_elevation`). Layouts s. dort.
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Sichtbare Teilstücke von Segmenten gegen nähere Verdecker; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn elevation_clip_segments_flat(occ: &[f64], segs: &[f64]) -> Vec<f64> {
|
||||
crate::plan_elevation::clip_segments(occ, segs)
|
||||
}
|
||||
|
||||
/// Ob Punkte hinter einem näheren Verdecker liegen; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn elevation_occluded_points_flat(occ: &[f64], pts: &[f64]) -> Vec<f64> {
|
||||
crate::plan_elevation::occluded_points(occ, pts)
|
||||
}
|
||||
|
||||
/// Schlagschatten auskragender Flächen auf Fassaden; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn elevation_shadows_flat(walls: &[f64], slabs: &[f64]) -> Vec<f64> {
|
||||
crate::plan_elevation::shadows(walls, slabs)
|
||||
}
|
||||
|
||||
/// XOR-Umrisskanten frontaler Rechteckgruppen; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn elevation_xor_outline_flat(polys: &[f64]) -> Vec<f64> {
|
||||
crate::plan_elevation::xor_outline(polys)
|
||||
}
|
||||
|
||||
/// Sichtbare Wand-, Decken- und Dachflächen in Ansichts-Koordinaten; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn elevation_faces_flat(frame: &[f64], walls: &[f64], slabs: &[f64], roofs: &[f64]) -> Vec<f64> {
|
||||
crate::plan_elevation::faces(frame, walls, slabs, roofs)
|
||||
}
|
||||
|
||||
/// Eck-Verlängerung der Wandenden für die Ansicht; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn elevation_wall_extensions_flat(input: &[f64]) -> Vec<f64> {
|
||||
crate::plan_elevation::wall_extensions(input)
|
||||
}
|
||||
|
||||
/// Projektion und Aufteilung (Glas, Flügel, Sprossen, Bank, Symbol) der Öffnungen; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn elevation_openings_flat(frame: &[f64], input: &[f64]) -> Vec<f64> {
|
||||
crate::plan_elevation::openings(frame, input)
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
//! Bindung des Fenster-Symbols (`crate::plan_openings`, für Schnitt/Ansicht). Layout s. dort. Das
|
||||
//! Öffnungs-Symbol im Grundriss ruft die Plan-Erzeugung im Kern direkt (`plan/walls.rs`).
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Fenster-Symbol (Rahmen, Glas, Flügel, Stulp) einer Öffnung; Unsinn/entartet → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn window_symbol_flat(buf: &[f64]) -> Vec<f64> {
|
||||
crate::plan_openings::window_symbol_flat(buf)
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
//! Bindungen der Schnitt-Bänder (`crate::plan_section`). Layouts s. dort.
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Dominanz-Subtraktion und Verschmelzung der Schnitt-Rechtecke; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn section_dominant_bands_flat(input: &[f64]) -> Vec<f64> {
|
||||
crate::plan_section::dominant_bands(input)
|
||||
}
|
||||
|
||||
/// Aussenringe der Vereinigung achsparalleler Rechtecke; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn section_union_outlines_flat(input: &[f64]) -> Vec<f64> {
|
||||
crate::plan_section::union_outlines(input)
|
||||
}
|
||||
|
||||
/// Spur der senkrechten Schnittebene auf den Dachflächen eines Dachs; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn section_roof_segments_flat(base_x: f64, base_y: f64, u_x: f64, u_y: f64, planes: &[f64]) -> Vec<f64> {
|
||||
crate::plan_section::roof_segments(base_x, base_y, u_x, u_y, planes)
|
||||
}
|
||||
@@ -2,12 +2,6 @@
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Löcher als Schlüsselloch-Stege in den Aussenring; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn voids_keyhole_flat(rings: &[f64]) -> Vec<f64> {
|
||||
crate::voids::keyhole_flat(rings)
|
||||
}
|
||||
|
||||
/// Polygon minus Schneider (mit nicht gestrichenen Kanten); `[-1]` = keine Überschneidung.
|
||||
#[wasm_bindgen]
|
||||
pub fn voids_subtract_rings_flat(pts: &[f64], cutters: &[f64], no_stroke: &[f64]) -> Vec<f64> {
|
||||
@@ -19,9 +13,3 @@ pub fn voids_subtract_rings_flat(pts: &[f64], cutters: &[f64], no_stroke: &[f64]
|
||||
pub fn voids_segment_outside_flat(seg: &[f64], cutters: &[f64]) -> Vec<f64> {
|
||||
crate::voids::segment_outside_flat(seg, cutters)
|
||||
}
|
||||
|
||||
/// Schnitt-Intervalle eines Prismas mit einer senkrechten Ebene; Unsinn → leer.
|
||||
#[wasm_bindgen]
|
||||
pub fn voids_section_rects_flat(pts: &[f64], base_u: &[f64]) -> Vec<f64> {
|
||||
crate::voids::section_rects_flat(pts, base_u)
|
||||
}
|
||||
+2
-2
@@ -7,7 +7,7 @@
|
||||
// dossier-cli <projekt.obp> migrate [--out neu.obp]
|
||||
// dossier-cli <projekt.obp> plan [--level EG] [--scale 100] [--format svg|json] [--out eg.svg]
|
||||
// json = render2d-Szene (planToRenderScene)
|
||||
// dossier-cli <projekt.obp> section <Name> [--out schnitt.svg] (braucht render3d-WASM)
|
||||
// dossier-cli <projekt.obp> section <Name> [--out schnitt.svg] (--format json: render2d-Szene)
|
||||
// dossier-cli <projekt.obp> elevation <Name> [--out ansicht.svg]
|
||||
// dossier-cli <projekt.obp> ifc [--ebkph] [--ebenen] (IFC mit eBKP-H-Hauptgruppen bzw. Modell-Ebenen als Klassifikation)
|
||||
// --schema 4|2x3: IFC4 (Standard) oder IFC2x3 (Coordination View 2.0)
|
||||
@@ -797,7 +797,7 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
await time("planToSvgString", () => planToSvgString(plan, { scaleDenominator: scale }));
|
||||
}
|
||||
await time("projectToModel3d", () => projectToModel3d(project));
|
||||
if (sec) await time("computeSection", () => computeSection(project, sec), Math.max(3, runs / 2));
|
||||
if (sec) await time("Schnitt (Kern)", async () => generateSectionPlan((await computeSection(project, sec))!, false, { visibleCodes: allCodes }), Math.max(3, runs / 2));
|
||||
if (elev) await time("generateElevationPlan", () => generateElevationPlan(project, elev), Math.max(3, runs / 2));
|
||||
if (project.walls.length) {
|
||||
const moved = { ...project, walls: [{ ...project.walls[0], height: (project.walls[0].height ?? 2.6) + 0.1 }, ...project.walls.slice(1)] };
|
||||
|
||||
+4
-4
@@ -294,11 +294,8 @@ export {
|
||||
|
||||
export {
|
||||
type ElevationOptions,
|
||||
type SectionOutput,
|
||||
computeSection,
|
||||
generateElevationPlan,
|
||||
generateSectionPlan,
|
||||
} from "../plan/sectionCore";
|
||||
} from "../plan/toElevation";
|
||||
|
||||
export {
|
||||
planSceneBin,
|
||||
@@ -306,6 +303,9 @@ export {
|
||||
} from "../plan/toRenderScene";
|
||||
|
||||
export {
|
||||
type SectionOutput,
|
||||
computeSection,
|
||||
generateSectionPlan,
|
||||
sameSectionInputs,
|
||||
sameSectionLine,
|
||||
sectionPlaneFromLevel,
|
||||
|
||||
+1
-137
@@ -1,7 +1,6 @@
|
||||
// Geometrie-Helfer für Öffnungen (Fenster/Türen) — reine Funktionen, die eine
|
||||
// `Opening` relativ zu ihrer Wirts-Wand in konkrete Welt-Geometrie auflösen:
|
||||
// • die Öffnungs-Lücke entlang der Wandachse (from/to in Metern),
|
||||
// • die Fenster-Rahmen-/Glaslinien quer über die Lücke (`windowSymbol`, Fassade über den Rust-Kern),
|
||||
// • die vertikale Lage (UK/OK der Öffnung, absolut in Metern).
|
||||
//
|
||||
// Da JEDE Größe aus der aktuellen Wandachse (`wall.start`/`wall.end`) abgeleitet
|
||||
@@ -10,8 +9,7 @@
|
||||
//
|
||||
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import type { Opening, Project, SashDef, Vec2, Wall } from "../model/types";
|
||||
import { core } from "../engine/coreWasm";
|
||||
import type { Opening, Project, Vec2, Wall } from "../model/types";
|
||||
import { getWallType, wallTypeThickness } from "../model/types";
|
||||
import { add, along, leftNormal, normalize, scale, sub } from "../model/geometry";
|
||||
import { wallReferenceOffset, wallVerticalExtent } from "../model/wall";
|
||||
@@ -101,137 +99,3 @@ export function openingCenter(wall: Wall, o: Opening): Vec2 | null {
|
||||
if (!iv) return null;
|
||||
return along(wall.start, wall.end, (iv.from + iv.to) / 2);
|
||||
}
|
||||
|
||||
// ── Fenster-Symbol (Plan) ────────────────────────────────────────────────────
|
||||
|
||||
/** Aufgelöste Fenster-Linien im Grundriss (Weltkoordinaten). */
|
||||
export interface WindowSymbol {
|
||||
/** Rahmen-Rechteck (volle Dicke) als Ecken. */
|
||||
frame: Vec2[];
|
||||
/** Glaslinien-Segmente quer über die Lücke (1–3 parallele Linien). */
|
||||
glassLines: [Vec2, Vec2][];
|
||||
/**
|
||||
* Flügel-/Pfosten-Trennlinien, jeweils von einer Laibungsseite zur anderen
|
||||
* (parallel zu den Laibungslinien, quer zur Öffnungsrichtung). Ist `sashes`
|
||||
* (dritter Parameter von {@link windowSymbol}) gesetzt, ergeben sich die
|
||||
* Positionen aus den Flügel-/Pfostenbreiten (siehe `sashSegments`); sonst
|
||||
* (Alt-Fall) `wingCount − 1` gleichmäßig verteilte Querlinien. Entspricht den
|
||||
* Mittelpfosten in `_make_oeffnung_pieces` des Rhino-Plugins (`oeff_fluegel`).
|
||||
*/
|
||||
mullionLines: [Vec2, Vec2][];
|
||||
/**
|
||||
* Flügelrahmen (Flügelkontur) je ÖFFENBAREM Flügel (Dreh/Kipp/Drehkipp/
|
||||
* Schiebe): ein Rechteck INNERHALB des Blendrahmens (Schachtelung
|
||||
* Blendrahmen → Flügelrahmen → Glas), das den öffenbaren Flügel vom festen
|
||||
* Feld unterscheidet. Feste Flügel (`opening:"fest"`) bekommen KEINEN
|
||||
* Flügelrahmen — dort sitzt das Glas direkt im Blendrahmen. Nur befüllt im
|
||||
* neuen (spec-)Pfad; leer im Alt-Fall (kein `spec`).
|
||||
*/
|
||||
sashFrames: Vec2[][];
|
||||
/**
|
||||
* (Alt-Feld, für Rückwärtskompatibilität der Schnittstelle beibehalten) — im
|
||||
* neuen Pfad leer; die Öffenbarkeit wird jetzt über {@link sashFrames}
|
||||
* ausgedrückt statt über eine Diagonale quer über die Box.
|
||||
*/
|
||||
sashOpeningLines: [Vec2, Vec2][];
|
||||
/**
|
||||
* Stulp-/Flügelstoss-Marken (SIA-„kleines Quadrat mittig", Figur 37/38): je
|
||||
* Flügel-Trennung ein kleines Rechteck-Polygon auf der Glasebene, das den
|
||||
* Anschlag der zwei zusammenstossenden Flügelprofile darstellt. Bei „mittel"
|
||||
* ein Quadrat je Stoss, bei „fein" zwei (die beiden Stulpprofile). „grob":
|
||||
* leer. Zählt zur "Fenster"-Linien-Kategorie (Flügel/Sprossen), NICHT zum
|
||||
* Blendrahmen — separat von {@link jambMarks} steuerbar. Der Aufrufer
|
||||
* zeichnet sie als dünne Umriss-Rechtecke.
|
||||
*/
|
||||
meetingMarks: Vec2[][];
|
||||
/**
|
||||
* Blendrahmen-Querschnittsblöcke an den beiden Laibungs-Enden (ein Block je
|
||||
* Seite, unabhängig von Flügelanzahl/Detailgrad) — Teil des Blendrahmens,
|
||||
* zählt zur "Rahmen"-Linien-Kategorie (im Unterschied zu {@link meetingMarks},
|
||||
* die an inneren Flügelstössen sitzen und zur "Fenster"-Kategorie zählen).
|
||||
*/
|
||||
jambMarks: Vec2[][];
|
||||
}
|
||||
|
||||
/**
|
||||
* Render-Parameter des Fensters für die reiche 2D-Symbolik (aus dem
|
||||
* referenzierten {@link WindowType}): Flügeltabelle, Profilbreite, Rahmentiefe
|
||||
* und Schichteinzug. Fehlt der Spec (kein Typ auflösbar), zeichnet
|
||||
* {@link windowSymbol} das schlichte Alt-Symbol (`o.wingCount`, volle Wanddicke).
|
||||
*/
|
||||
export interface WindowRenderSpec {
|
||||
sashes: SashDef[];
|
||||
/** Sichtbare Profilbreite (Meter) von Blend-/Flügelrahmen in der Öffnungsebene. */
|
||||
frameWidth: number;
|
||||
/** Rahmentiefe quer zur Wand (Meter); fehlt ⇒ {@link DEFAULT_FRAME_DEPTH}. */
|
||||
frameDepth?: number;
|
||||
/** Schichteinzug: Abstand der Rahmen-Vorderkante von {@link insetFace} (Meter). */
|
||||
insetFromFace?: number;
|
||||
/** Bezugsfläche des Schichteinzugs; Default "aussen". */
|
||||
insetFace?: "aussen" | "innen";
|
||||
}
|
||||
|
||||
/**
|
||||
* Löst die Fenster-Symbolik auf: ein Rahmen-Rechteck über die Lücke (volle
|
||||
* Wanddicke) plus 1–3 Glaslinien (dünne parallele Linien in der Wandmitte,
|
||||
* `glassCount` steuert die Anzahl) plus optionale Flügel-/Pfosten-Trennlinien
|
||||
* und Öffnungsandeutungen je Flügel.
|
||||
*
|
||||
* `sashes` (optional) ist die aufgelöste Flügeltabelle (siehe
|
||||
* `sashesOfWindowType`) EINES referenzierten Fenstertyps. Fehlt sie (kein Typ
|
||||
* referenziert/auflösbar), bleibt die Mittelpfosten-Berechnung beim
|
||||
* BISHERIGEN Verhalten — `o.wingCount` gleichmäßig verteilt, KEINE
|
||||
* Öffnungsandeutungen — exakt wie vor dieser Erweiterung (Rückwärtskompatibilität).
|
||||
*
|
||||
* Die Berechnung läuft im Rust-Kern (`src-tauri/core/src/opening_geom.rs`, [K3a]); diese Funktion
|
||||
* ist die Fassade mit unveränderter Signatur.
|
||||
*/
|
||||
export function windowSymbol(
|
||||
project: Project,
|
||||
wall: Wall,
|
||||
o: Opening,
|
||||
glassCount: number,
|
||||
spec?: WindowRenderSpec,
|
||||
detail: "grob" | "mittel" | "fein" = "fein",
|
||||
): WindowSymbol | null {
|
||||
const total = wallTypeThickness(getWallType(project, wall));
|
||||
const b: number[] = [
|
||||
wall.start.x, wall.start.y, wall.end.x, wall.end.y, total, wallReferenceOffset(wall, total),
|
||||
o.position, o.width, glassCount, o.wingCount ?? Number.NaN,
|
||||
detail === "grob" ? 0 : detail === "mittel" ? 1 : 2,
|
||||
spec ? 1 : 0,
|
||||
spec?.frameWidth ?? 0, spec?.frameDepth ?? Number.NaN, spec?.insetFromFace ?? Number.NaN,
|
||||
spec?.insetFace === "innen" ? 1 : 0,
|
||||
spec?.sashes.length ?? 0,
|
||||
];
|
||||
for (const s of spec?.sashes ?? []) {
|
||||
b.push(s.kind === "pfosten" ? 1 : 0, s.autoWidth === false ? 0 : 1, s.width ?? Number.NaN, s.postWidth ?? Number.NaN,
|
||||
s.opening && s.opening !== "fest" ? 1 : 0);
|
||||
}
|
||||
const f = core().window_symbol_flat(Float64Array.from(b));
|
||||
if (f.length === 0) return null;
|
||||
let i = 1;
|
||||
const pt = (): Vec2 => ({ x: f[i++], y: f[i++] });
|
||||
const frame = [pt(), pt(), pt(), pt()];
|
||||
const segs = (): [Vec2, Vec2][] => {
|
||||
const n = f[i++];
|
||||
const out: [Vec2, Vec2][] = [];
|
||||
for (let k = 0; k < n; k++) out.push([pt(), pt()]);
|
||||
return out;
|
||||
};
|
||||
const rings = (): Vec2[][] => {
|
||||
const n = f[i++];
|
||||
const out: Vec2[][] = [];
|
||||
for (let k = 0; k < n; k++) {
|
||||
const m = f[i++];
|
||||
out.push(Array.from({ length: m }, pt));
|
||||
}
|
||||
return out;
|
||||
};
|
||||
const glassLines = segs();
|
||||
const mullionLines = segs();
|
||||
const sashFrames = rings();
|
||||
const meetingMarks = rings();
|
||||
const jambMarks = rings();
|
||||
return { frame, glassLines, mullionLines, sashFrames, sashOpeningLines: [], meetingMarks, jambMarks };
|
||||
}
|
||||
+3
-294
@@ -5,9 +5,8 @@
|
||||
// 3D-Meshes, sondern direkt aus den Parametern (Wandachsen, Schichtaufbau,
|
||||
// Öffnungen) — exakt, schnell, sauber.
|
||||
//
|
||||
// Diese Datei ist nur noch der ORCHESTRATOR: `generatePlan()`/
|
||||
// `generateSectionPlan()` sowie die `resolve*SectionStyle`-Helfer (für den
|
||||
// Schnitt-Pfad, `toSection.ts`). Die Bauteil-Domänen (Decken, Dächer, Räume,
|
||||
// Diese Datei ist nur noch der ORCHESTRATOR `generatePlan()` (Schnitt und Ansicht:
|
||||
// `toSection.ts`/`toElevation.ts`, im Kern). Die Bauteil-Domänen (Decken, Dächer, Räume,
|
||||
// Wände mit Öffnungen, Treppen, Stützen, Extrusionen, Kontext, Schnittführung)
|
||||
// rechnet der Rust-Kern auf dem Projekt-Dokument (`src-tauri/core/src/plan/`,
|
||||
// Abfrage `planDomains`, [K3d]) und liefert fertige `Primitive`. In TS bleiben
|
||||
@@ -17,8 +16,6 @@
|
||||
// leben in `generatePlan/shared.ts`.
|
||||
|
||||
import type {
|
||||
Ceiling,
|
||||
Component,
|
||||
ContextImage,
|
||||
ContextObject,
|
||||
Drawing2D,
|
||||
@@ -26,19 +23,11 @@ import type {
|
||||
OverrideActions,
|
||||
Project,
|
||||
Vec2,
|
||||
Wall,
|
||||
} from "../model/types";
|
||||
import {
|
||||
flattenCategories,
|
||||
getCeilingType,
|
||||
getComponent,
|
||||
getLayerCategory,
|
||||
getWallType,
|
||||
} from "../model/types";
|
||||
import { flattenCategories } from "../model/types";
|
||||
import { documentFor } from "../core/document";
|
||||
import { decodePlanBuf, type DecodedPlanBuf } from "./planBuf";
|
||||
import { effectiveOverrides, hasOverrides } from "../overrides/engine";
|
||||
import type { SectionOutput } from "./toSection";
|
||||
import {
|
||||
HATCH_INK,
|
||||
HATCH_PAPER,
|
||||
@@ -74,91 +63,6 @@ import { layersStyleSig } from "./generatePlan/layerSig";
|
||||
export { HATCH_INK, HATCH_PAPER, resolveBackground, resolveForeground, resolveHatch, resolveHatchId };
|
||||
export type { CategoryDisplayResolver, DetailLevel, HatchRender, Primitive };
|
||||
|
||||
/**
|
||||
* Füllfarbe + Schraffur eines aufgelösten Bauteils, fertig für eine Cut-Poché.
|
||||
*/
|
||||
export interface SectionCutStyle {
|
||||
fill: string;
|
||||
hatch: HatchRender;
|
||||
}
|
||||
|
||||
/**
|
||||
* Löst das tragende Bauteil (höchste `joinPriority`) einer Wand auf und liefert
|
||||
* dessen Poché-Füllung + echte Schraffur für die Schnitt-Poché (mittel/fein).
|
||||
* Die grobe Grundriss-Poché (1:100) folgt dieser Bauteil-Regel NICHT mehr —
|
||||
* sie ist immer vollschwarz, unabhängig vom Bauteil-Pattern (SIA 400 Fig. 36,
|
||||
* s. `addWallPoche`). `null`, wenn Wandtyp oder Bauteil nicht auflösbar sind
|
||||
* (z. B. verwaistes `wallTypeId`); der Aufrufer fällt dann auf die generische
|
||||
* Schnitt-Schraffur zurück.
|
||||
*/
|
||||
export function resolveWallSectionStyle(project: Project, wall: Wall): SectionCutStyle | null {
|
||||
try {
|
||||
const wt = getWallType(project, wall);
|
||||
let best: Component | null = null;
|
||||
for (const layer of wt.layers) {
|
||||
const comp = getComponent(project, layer.componentId);
|
||||
if (!best || comp.joinPriority > best.joinPriority) best = comp;
|
||||
}
|
||||
if (!best) return null;
|
||||
const category = getLayerCategory(project, wall.categoryCode);
|
||||
const wallAngleDeg =
|
||||
(Math.atan2(wall.end.y - wall.start.y, wall.end.x - wall.start.x) * 180) / Math.PI;
|
||||
const hatchId = resolveHatchId(wall.hatchId, wall.hatchSource, category, best.hatchId) ?? best.hatchId;
|
||||
const hatch = resolveHatch(
|
||||
project,
|
||||
hatchId,
|
||||
wallAngleDeg,
|
||||
resolveForeground(best, wall.foreground, category, wall.foregroundSource),
|
||||
);
|
||||
// Poché-Hintergrund neutral (Papier) statt Bauteil-Albedo; Vollmuster → Tinte
|
||||
// (unabhängig von `hatch.color`, das jetzt den aufgelösten Vordergrund tragen
|
||||
// kann, s. {@link resolveHatch}).
|
||||
const solid = hatch.pattern === "solid";
|
||||
return {
|
||||
fill: solid ? HATCH_INK : HATCH_PAPER,
|
||||
hatch,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Löst das erste Bauteil des Deckentyps einer Decke auf — dieselbe Regel wie
|
||||
* `addCeilingPoche` für die normale Deckenpoché — und liefert dessen
|
||||
* Füllfarbe + echte Schraffur für die Schnitt-Poché. `null`, wenn Deckentyp
|
||||
* oder Bauteil nicht auflösbar sind bzw. der Deckentyp keine Schicht trägt.
|
||||
*/
|
||||
export function resolveCeilingSectionStyle(
|
||||
project: Project,
|
||||
ceiling: Ceiling,
|
||||
): SectionCutStyle | null {
|
||||
try {
|
||||
const wt = getCeilingType(project, ceiling);
|
||||
if (wt.layers.length === 0) return null;
|
||||
const comp = getComponent(project, wt.layers[0].componentId);
|
||||
const category = getLayerCategory(project, ceiling.categoryCode);
|
||||
const hatchId =
|
||||
resolveHatchId(ceiling.hatchId, ceiling.hatchSource, category, comp.hatchId) ?? comp.hatchId;
|
||||
const hatch = resolveHatch(
|
||||
project,
|
||||
hatchId,
|
||||
undefined,
|
||||
resolveForeground(comp, ceiling.foreground, category, ceiling.foregroundSource),
|
||||
);
|
||||
// Poché-Hintergrund neutral (Papier) statt Bauteil-Albedo; Vollmuster → Tinte
|
||||
// — dieselbe Neutralisierung wie {@link resolveWallSectionStyle}, damit die
|
||||
// geschnittene Decke nicht als andersfarbige Fläche gegenüber der Wand auffällt.
|
||||
const solid = hatch.pattern === "solid";
|
||||
return {
|
||||
fill: solid ? HATCH_INK : HATCH_PAPER,
|
||||
hatch,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Ein georeferenziertes Hintergrund-Rasterbild (Luftbild) im Grundriss —
|
||||
* Modell-Meter-Rechteck [min..max], das die interaktive Ansicht UNTER der
|
||||
* Geometrie zeichnet (Kontext-Schicht, `ContextImage`). NICHT Teil der
|
||||
@@ -676,201 +580,6 @@ export function generateVisibleLevelsPlan(
|
||||
);
|
||||
}
|
||||
|
||||
// ── Schnitt/Ansicht (abgeleitete Projektion aus render3d::section) ──────────────
|
||||
// Die Rohdaten (Cut-Polygone + sichtbare/verdeckte projizierte Kanten) liefert
|
||||
// der WASM-Extraktor (plan/toSection.ts → section.rs). Hier werden sie 1:1 in
|
||||
// die BESTEHENDEN Plan-Primitive übersetzt — kein neues Primitiv nötig:
|
||||
// • Cut-Polygon → `polygon` (kräftige Poché-Umrisslinie + Schnitt-Schraffur),
|
||||
// • sichtbare Kante → `line` (durchgezogen),
|
||||
// • verdeckte Kante → `line` (gestrichelt).
|
||||
// Damit rendern PlanView (SVG) UND toRenderScene (Engine/WASM-2D) den Schnitt
|
||||
// ohne jede Sonderbehandlung, mit voller Papier-mm-/Parität-Infrastruktur.
|
||||
|
||||
/** Tinte der Schnitt-Poché-Umrisslinie + Schraffur (dunkles Grau). */
|
||||
const SECTION_INK = "#1f242c";
|
||||
/** Tinte der sichtbaren Ansichtskanten. */
|
||||
const SECTION_VISIBLE_INK = "#2b3039";
|
||||
/** Tinte der verdeckten (gestrichelten) Ansichtskanten (etwas heller). */
|
||||
const SECTION_HIDDEN_INK = "#8a929c";
|
||||
/** Strichstärke der Cut-Poché-Umrisslinie (mm Papier, kräftig wie eine Wand). */
|
||||
const SECTION_CUT_OUTLINE_MM = 0.35;
|
||||
/** Strichstärke sichtbarer Ansichtskanten (mm Papier). */
|
||||
const SECTION_VISIBLE_MM = 0.18;
|
||||
/** Strichstärke der Bodenlinie unter dem Schnitt (mm Papier, wie in der Ansicht). */
|
||||
const SECTION_GROUND_MM = 0.5;
|
||||
/** Strichstärke verdeckter Ansichtskanten (mm Papier, dünner). */
|
||||
const SECTION_HIDDEN_MM = 0.13;
|
||||
/** Strichmuster verdeckter Kanten (mm Papier). */
|
||||
const SECTION_HIDDEN_DASH: number[] = [0.12, 0.08];
|
||||
|
||||
/**
|
||||
* Schnitt-Schraffur der Cut-Flächen (diagonale Poché wie ein Wandschnitt) —
|
||||
* Fallback, wenn `toSection.ts` das Quell-Bauteil einer Cut-Fläche NICHT
|
||||
* auflösen konnte (siehe `attachCutStyles`). Vordergrund fest `HATCH_INK`,
|
||||
* damit auch der Fallback monochrom bleibt statt der rohen 3D-Albedo-Farbe.
|
||||
*/
|
||||
const SECTION_HATCH: HatchRender = {
|
||||
pattern: "diagonal",
|
||||
scale: 1,
|
||||
angle: 45,
|
||||
color: HATCH_INK,
|
||||
lineWeight: 0.13,
|
||||
dash: null,
|
||||
};
|
||||
|
||||
/**
|
||||
* Baut aus einem {@link SectionOutput} (render3d::section, (u, v)-Meter) den
|
||||
* Plan eines Schnitts/einer Ansicht. `u` wird zur Plan-X, `v` (absolute Höhe)
|
||||
* zur Plan-Y — die PlanView zeigt Y nach oben, also erscheint der Schnitt
|
||||
* aufrecht. Rein darstellend; kennt das Projekt NICHT direkt — `visibleCodes`/
|
||||
* `categoryDisplay` (optional) filtern/dimmen jedes Cut-Band trotzdem über
|
||||
* `cp.categoryCode` (von `toSection.ts::attachCutStyles` aufgelöst), damit das
|
||||
* Ebenen-Panel auch im Schnitt/in der Ansicht wirkt, wie im Grundriss. Ein
|
||||
* Band ohne `categoryCode` (unauflösbares Bauteil) bleibt immer sichtbar.
|
||||
*/
|
||||
export function generateSectionPlan(
|
||||
output: SectionOutput,
|
||||
mono = false,
|
||||
opts: {
|
||||
hiddenLines?: boolean;
|
||||
visibleCodes?: Set<string>;
|
||||
categoryDisplay?: CategoryDisplayResolver;
|
||||
} = {},
|
||||
): Plan {
|
||||
const primitives: Primitive[] = [];
|
||||
let minX = Infinity,
|
||||
minY = Infinity,
|
||||
maxX = -Infinity,
|
||||
maxY = -Infinity;
|
||||
const acc = (x: number, y: number) => {
|
||||
if (x < minX) minX = x;
|
||||
if (y < minY) minY = y;
|
||||
if (x > maxX) maxX = x;
|
||||
if (y > maxY) maxY = y;
|
||||
};
|
||||
const catDisplay = opts.categoryDisplay ?? SHOW_ALL;
|
||||
|
||||
// Cut-Polygone: gefüllte Poché-Fläche + Schnitt-Schraffur + kräftige
|
||||
// Umrisslinie — wie eine geschnittene Wand im Grundriss. `toSection.ts`
|
||||
// (computeSection) löst je Cut-Polygon bereits das Quell-Bauteil auf und
|
||||
// hängt dessen echte Füllfarbe/Schraffur an (`cp.fill`/`cp.hatch`); fehlt
|
||||
// diese Auflösung (Fallback, z. B. verwaistes Bauteil), greift die generische
|
||||
// Schnitt-Schraffur (`SECTION_HATCH`, HATCH_PAPER-Hintergrund) — NICHT die rohe
|
||||
// Albedo-Farbe aus dem 3D-Modell (Nutzer-Vorgabe 2026-07-04: einheitlich
|
||||
// monochrom, auch im Fallback-Fall).
|
||||
for (const cp of output.cutPolygons) {
|
||||
if (cp.pts.length < 3) continue;
|
||||
// Ebenen-Panel-Sichtbarkeit: nur wenn das Quell-Bauteil aufgelöst werden
|
||||
// konnte (categoryCode gesetzt) — sonst (Fallback) immer zeichnen.
|
||||
if (cp.categoryCode !== undefined) {
|
||||
if (opts.visibleCodes && !opts.visibleCodes.has(cp.categoryCode)) continue;
|
||||
if (!catDisplay(cp.categoryCode).render) continue;
|
||||
}
|
||||
const pts: Vec2[] = cp.pts.map(([u, v]) => {
|
||||
acc(u, v);
|
||||
return { x: u, y: v };
|
||||
});
|
||||
const fill = cp.fill ?? HATCH_PAPER;
|
||||
const hatch = cp.hatch ?? SECTION_HATCH;
|
||||
// Mono: neutrale Poché — Papier statt Bauteilfarbe, Schraffur-Musterlinien →
|
||||
// Tinte. Eine dunkle SIA-Vollpoché ("solid") BLEIBT jedoch dunkel
|
||||
// (Tinte bleibt Tinte, Papier bleibt Papier).
|
||||
const solid = hatch.pattern === "solid";
|
||||
const monoFill = solid ? HATCH_INK : HATCH_PAPER;
|
||||
const monoHatch =
|
||||
solid ? hatch : hatch.pattern !== "none" ? { ...hatch, color: SECTION_INK } : hatch;
|
||||
// Auswahl im Schnitt: das QUELL-Element (via cp.sourceId + component.kind) als
|
||||
// wallId/ceilingId/roofId ans Polygon hängen — so wählt ein Klick auf das
|
||||
// geschnittene Bauteil im Schnitt exakt jene Wand/Decke/Dach im Modell, und
|
||||
// die bestehende PlanView-Pick-/Highlight-Logik greift ohne Sonderfall.
|
||||
const kind = cp.component.kind;
|
||||
const sourceId = cp.sourceId;
|
||||
primitives.push({
|
||||
kind: "polygon",
|
||||
pts,
|
||||
fill: mono ? monoFill : fill,
|
||||
stroke: SECTION_INK,
|
||||
strokeWidthMm: SECTION_CUT_OUTLINE_MM,
|
||||
hatch: mono ? monoHatch : hatch,
|
||||
wallId: kind === "wall" ? sourceId : undefined,
|
||||
ceilingId: kind === "slab" && !cp.stairId ? sourceId : undefined,
|
||||
roofId: kind === "roof" ? sourceId : undefined,
|
||||
stairId: cp.stairId,
|
||||
extrudedSolidId: kind === "body" ? sourceId : undefined,
|
||||
noStrokeEdges: cp.noStrokeEdges,
|
||||
greyed: cp.categoryCode !== undefined && catDisplay(cp.categoryCode).greyed,
|
||||
});
|
||||
}
|
||||
|
||||
// Geländelinie(n): kräftige Linie, über Kategorie filterbar.
|
||||
for (const pr of output.profiles ?? []) {
|
||||
if (pr.categoryCode !== undefined) {
|
||||
if (opts.visibleCodes && !opts.visibleCodes.has(pr.categoryCode)) continue;
|
||||
if (!catDisplay(pr.categoryCode).render) continue;
|
||||
}
|
||||
for (let i = 0; i + 1 < pr.pts.length; i++) {
|
||||
const [a, b] = [pr.pts[i], pr.pts[i + 1]];
|
||||
acc(a[0], a[1]);
|
||||
acc(b[0], b[1]);
|
||||
primitives.push({
|
||||
kind: "line",
|
||||
a: { x: a[0], y: a[1] },
|
||||
b: { x: b[0], y: b[1] },
|
||||
cls: "section-terrain",
|
||||
weightMm: SECTION_GROUND_MM,
|
||||
color: SECTION_INK,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Verdeckte Kanten zuerst (liegen unter den sichtbaren), gestrichelt —
|
||||
// Standard AUS (VW-üblich): sie legen sich sonst als blasses Liniengewirr
|
||||
// über Poché und Ansichtskanten. Zuschaltbar je Schnitt-/Ansichts-Ebene.
|
||||
for (const e of opts.hiddenLines ? output.hiddenEdges : []) {
|
||||
acc(e.a[0], e.a[1]);
|
||||
acc(e.b[0], e.b[1]);
|
||||
primitives.push({
|
||||
kind: "line",
|
||||
a: { x: e.a[0], y: e.a[1] },
|
||||
b: { x: e.b[0], y: e.b[1] },
|
||||
cls: "section-hidden",
|
||||
weightMm: SECTION_HIDDEN_MM,
|
||||
dash: SECTION_HIDDEN_DASH,
|
||||
color: SECTION_HIDDEN_INK,
|
||||
});
|
||||
}
|
||||
|
||||
// Sichtbare Ansichtskanten, durchgezogen.
|
||||
for (const e of output.visibleEdges) {
|
||||
acc(e.a[0], e.a[1]);
|
||||
acc(e.b[0], e.b[1]);
|
||||
primitives.push({
|
||||
kind: "line",
|
||||
a: { x: e.a[0], y: e.a[1] },
|
||||
b: { x: e.b[0], y: e.b[1] },
|
||||
cls: "section-visible",
|
||||
weightMm: SECTION_VISIBLE_MM,
|
||||
color: SECTION_VISIBLE_INK,
|
||||
});
|
||||
}
|
||||
|
||||
// Bodenlinie wie in der Ansicht (toElevation.ts): kräftige Linie über die
|
||||
// volle Breite an der untersten Kante — ohne sie "schwebte" der Schnitt.
|
||||
if (isFinite(minX) && maxX > minX) {
|
||||
primitives.push({
|
||||
kind: "line",
|
||||
a: { x: minX, y: minY },
|
||||
b: { x: maxX, y: minY },
|
||||
cls: "section-ground",
|
||||
weightMm: SECTION_GROUND_MM,
|
||||
color: SECTION_INK,
|
||||
});
|
||||
}
|
||||
|
||||
if (!isFinite(minX)) return { primitives, bounds: { minX: 0, minY: 0, maxX: 1, maxY: 1 } };
|
||||
return { primitives, bounds: { minX, minY, maxX, maxY } };
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-Pass für den Schwarz-Weiss-Modus: ersetzt alle Farb-Informationen der
|
||||
* Plan-Primitive durch einheitliche Tinte/Weiss. Wirkt in-place.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Gemeinsame Grundlage des Grundriss-Generators: das `Primitive`-Vokabular
|
||||
// (das EINZIGE Austauschformat zwischen `generatePlan()`/`generateSectionPlan()`
|
||||
// (das EINZIGE Austauschformat zwischen `generatePlan()`, Schnitt/Ansicht
|
||||
// und den Domänen — unter `generatePlan/` in TS, die meisten im Rust-Kern mit
|
||||
// derselben JSON-Form, `src-tauri/core/src/plan/prim.rs`), die By-Layer/By-Object-
|
||||
// Attribut-Auflösung (`resolve*`) sowie die Papier-mm-/Tinten-Konstanten, die
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
// Ebenen-Panel-Sichtbarkeit im Schnitt/in der Ansicht: generateSectionPlan
|
||||
// filtert/dimmt jedes Cut-Band über `cp.categoryCode` (visibleCodes/
|
||||
// categoryDisplay) — genau wie jedes andere Bauteil im Grundriss. Vorher
|
||||
// wirkte das Ebenen-Panel im Schnitt/in der Ansicht gar nicht (Nutzer-Report).
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { generateSectionPlan } from "./generatePlan";
|
||||
import type { CategoryDisplayResolver } from "./generatePlan";
|
||||
import type { SectionCutPolygon, SectionOutput } from "./toSection";
|
||||
|
||||
function cut(kind: "wall" | "slab" | "roof", categoryCode: string | undefined): SectionCutPolygon {
|
||||
return {
|
||||
component: { kind, index: 0 },
|
||||
color: [0.5, 0.5, 0.5],
|
||||
pts: [
|
||||
[0, 0],
|
||||
[1, 0],
|
||||
[1, 2],
|
||||
[0, 2],
|
||||
],
|
||||
sourceId: "X1",
|
||||
categoryCode,
|
||||
};
|
||||
}
|
||||
|
||||
const SHOW_ALL: CategoryDisplayResolver = () => ({ render: true, greyed: false, locked: false });
|
||||
|
||||
describe("generateSectionPlan — Kategorie-Sichtbarkeit (Ebenen-Panel)", () => {
|
||||
it("lässt ein Band mit kategorie-verstecktem categoryCode weg (visibleCodes ohne den Code)", () => {
|
||||
const output: SectionOutput = {
|
||||
cutPolygons: [cut("wall", "20")],
|
||||
visibleEdges: [],
|
||||
hiddenEdges: [],
|
||||
};
|
||||
const polys = generateSectionPlan(output, false, {
|
||||
visibleCodes: new Set(["30"]), // "20" fehlt
|
||||
categoryDisplay: SHOW_ALL,
|
||||
}).primitives.filter((p) => p.kind === "polygon");
|
||||
expect(polys.length).toBe(0);
|
||||
});
|
||||
|
||||
it("lässt ein Band weg, wenn categoryDisplay(code).render=false liefert", () => {
|
||||
const output: SectionOutput = {
|
||||
cutPolygons: [cut("wall", "20")],
|
||||
visibleEdges: [],
|
||||
hiddenEdges: [],
|
||||
};
|
||||
const hideCat: CategoryDisplayResolver = () => ({ render: false, greyed: false, locked: false });
|
||||
const polys = generateSectionPlan(output, false, {
|
||||
visibleCodes: new Set(["20"]),
|
||||
categoryDisplay: hideCat,
|
||||
}).primitives.filter((p) => p.kind === "polygon");
|
||||
expect(polys.length).toBe(0);
|
||||
});
|
||||
|
||||
it("dimmt (greyed) ein sichtbares Band, wenn categoryDisplay greyed=true liefert", () => {
|
||||
const output: SectionOutput = {
|
||||
cutPolygons: [cut("wall", "20")],
|
||||
visibleEdges: [],
|
||||
hiddenEdges: [],
|
||||
};
|
||||
const greyCat: CategoryDisplayResolver = () => ({ render: true, greyed: true, locked: false });
|
||||
const polys = generateSectionPlan(output, false, {
|
||||
visibleCodes: new Set(["20"]),
|
||||
categoryDisplay: greyCat,
|
||||
}).primitives.filter(
|
||||
(p): p is Extract<typeof p, { kind: "polygon" }> => p.kind === "polygon",
|
||||
);
|
||||
expect(polys[0]?.greyed).toBe(true);
|
||||
});
|
||||
|
||||
it("zeichnet ein Band OHNE categoryCode immer (unauflösbares Bauteil, Fallback)", () => {
|
||||
const output: SectionOutput = {
|
||||
cutPolygons: [cut("wall", undefined)],
|
||||
visibleEdges: [],
|
||||
hiddenEdges: [],
|
||||
};
|
||||
const hideAll: CategoryDisplayResolver = () => ({ render: false, greyed: false, locked: false });
|
||||
const polys = generateSectionPlan(output, false, {
|
||||
visibleCodes: new Set([]),
|
||||
categoryDisplay: hideAll,
|
||||
}).primitives.filter((p) => p.kind === "polygon");
|
||||
expect(polys.length).toBe(1);
|
||||
});
|
||||
|
||||
it("ohne opts (Export-/Print-Pfad) bleibt jedes Band sichtbar wie bisher", () => {
|
||||
const output: SectionOutput = {
|
||||
cutPolygons: [cut("wall", "20")],
|
||||
visibleEdges: [],
|
||||
hiddenEdges: [],
|
||||
};
|
||||
const polys = generateSectionPlan(output).primitives.filter((p) => p.kind === "polygon");
|
||||
expect(polys.length).toBe(1);
|
||||
});
|
||||
});
|
||||
@@ -1,58 +0,0 @@
|
||||
// Auswahl im Schnitt-View: generateSectionPlan hängt jedem Cut-Polygon die
|
||||
// Quell-Element-Id (cp.sourceId) je nach component.kind als wallId/ceilingId/
|
||||
// roofId ans Plan-Polygon — damit ein Klick im Schnitt das Bauteil im Modell
|
||||
// wählt (die bestehende PlanView-Pick-Logik greift dann ohne Sonderfall).
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { generateSectionPlan } from "./generatePlan";
|
||||
import type { SectionCutPolygon, SectionOutput } from "./toSection";
|
||||
|
||||
function cut(kind: "wall" | "slab" | "roof", sourceId: string): SectionCutPolygon {
|
||||
return {
|
||||
component: { kind, index: 0 },
|
||||
color: [0.5, 0.5, 0.5],
|
||||
pts: [
|
||||
[0, 0],
|
||||
[1, 0],
|
||||
[1, 2],
|
||||
[0, 2],
|
||||
],
|
||||
sourceId,
|
||||
};
|
||||
}
|
||||
|
||||
const output: SectionOutput = {
|
||||
cutPolygons: [cut("wall", "W1"), cut("slab", "C1"), cut("roof", "R1")],
|
||||
visibleEdges: [],
|
||||
hiddenEdges: [],
|
||||
};
|
||||
|
||||
describe("generateSectionPlan — Auswahl-Ids am Cut-Polygon", () => {
|
||||
it("schreibt sourceId je component.kind als wallId/ceilingId/roofId", () => {
|
||||
const polys = generateSectionPlan(output).primitives.filter(
|
||||
(p): p is Extract<typeof p, { kind: "polygon" }> => p.kind === "polygon",
|
||||
);
|
||||
const wall = polys.find((p) => p.wallId === "W1");
|
||||
const ceiling = polys.find((p) => p.ceilingId === "C1");
|
||||
const roof = polys.find((p) => p.roofId === "R1");
|
||||
expect(wall).toBeTruthy();
|
||||
expect(ceiling).toBeTruthy();
|
||||
expect(roof).toBeTruthy();
|
||||
// Kanäle schließen sich je Polygon aus (eine Wand trägt keine ceilingId).
|
||||
expect(wall?.ceilingId).toBeUndefined();
|
||||
expect(wall?.roofId).toBeUndefined();
|
||||
expect(ceiling?.wallId).toBeUndefined();
|
||||
});
|
||||
|
||||
it("lässt die Ids weg, wenn cp.sourceId fehlt (unauflösbares Bauteil)", () => {
|
||||
const noId: SectionOutput = {
|
||||
cutPolygons: [{ ...cut("wall", "W1"), sourceId: undefined }],
|
||||
visibleEdges: [],
|
||||
hiddenEdges: [],
|
||||
};
|
||||
const poly = generateSectionPlan(noId).primitives.find(
|
||||
(p): p is Extract<typeof p, { kind: "polygon" }> => p.kind === "polygon",
|
||||
);
|
||||
expect(poly?.wallId).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -1,97 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { cutMeshWithPlane, ringsToPolygons, type Pt2 } from "./meshSection";
|
||||
|
||||
const ringArea = (r: Pt2[]): number => {
|
||||
let a = 0;
|
||||
for (let i = 0; i < r.length; i++) {
|
||||
const p = r[i];
|
||||
const q = r[(i + 1) % r.length];
|
||||
a += p[0] * q[1] - q[0] * p[1];
|
||||
}
|
||||
return a / 2;
|
||||
};
|
||||
|
||||
/** Quader als geschlossenes Netz (12 Dreiecke, aussen orientiert). `inward` kehrt um (Hohlraum). */
|
||||
function box(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, inward = false) {
|
||||
const p = [x0, y0, z0, x1, y0, z0, x1, y1, z0, x0, y1, z0, x0, y0, z1, x1, y0, z1, x1, y1, z1, x0, y1, z1];
|
||||
const f = [0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 0, 1, 5, 0, 5, 4, 1, 2, 6, 1, 6, 5, 2, 3, 7, 2, 7, 6, 3, 0, 4, 3, 4, 7];
|
||||
return { p, f: inward ? f.map((_, i) => f[i - (i % 3) + [0, 2, 1][i % 3]]) : f };
|
||||
}
|
||||
const merge = (a: ReturnType<typeof box>, b: ReturnType<typeof box>) => ({ p: [...a.p, ...b.p], f: [...a.f, ...b.f.map((i) => i + a.p.length / 3)] });
|
||||
|
||||
describe("cutMeshWithPlane", () => {
|
||||
it("senkrechter Schnitt durch einen Quader: ein Ring, Fläche = Breite × Höhe", () => {
|
||||
const b = box(0, 0, 0, 4, 2, 3);
|
||||
const r = cutMeshWithPlane(b.p, b.f, { kind: "vertical", point: { x: 0, y: 1 }, dir: { x: 1, y: 0 } });
|
||||
expect(r.rings).toHaveLength(1);
|
||||
expect(r.lines).toHaveLength(0);
|
||||
expect(Math.abs(ringArea(r.rings[0]))).toBeCloseTo(4 * 3, 9);
|
||||
});
|
||||
|
||||
it("waagrechter Schnitt: Grundriss-Ring (x,y)", () => {
|
||||
const b = box(1, 1, 0, 4, 3, 5);
|
||||
const r = cutMeshWithPlane(b.p, b.f, { kind: "horizontal", z: 2.5 });
|
||||
expect(r.rings).toHaveLength(1);
|
||||
expect(Math.abs(ringArea(r.rings[0]))).toBeCloseTo(3 * 2, 9);
|
||||
});
|
||||
|
||||
it("Ebene exakt auf Ecken/Kanten (Raster!) schliesst trotzdem sauber", () => {
|
||||
const b = box(0, 0, 0, 4, 2, 3);
|
||||
for (const y of [0, 2]) {
|
||||
const r = cutMeshWithPlane(b.p, b.f, { kind: "vertical", point: { x: 0, y }, dir: { x: 1, y: 0 } });
|
||||
expect(r.lines).toHaveLength(0);
|
||||
}
|
||||
const r = cutMeshWithPlane(b.p, b.f, { kind: "horizontal", z: 3 });
|
||||
expect(r.lines).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("Ebene schneidet nicht: leer", () => {
|
||||
const b = box(0, 0, 0, 1, 1, 1);
|
||||
const r = cutMeshWithPlane(b.p, b.f, { kind: "horizontal", z: 10 });
|
||||
expect(r.rings).toEqual([]);
|
||||
expect(r.lines).toEqual([]);
|
||||
});
|
||||
|
||||
it("Hohlkörper: Aussenring + Loch", () => {
|
||||
const m = merge(box(0, 0, 0, 10, 10, 10), box(3, 3, 3, 7, 7, 7, true));
|
||||
const r = cutMeshWithPlane(m.p, m.f, { kind: "horizontal", z: 5 });
|
||||
expect(r.rings).toHaveLength(2);
|
||||
const polys = ringsToPolygons(r.rings);
|
||||
expect(polys).toHaveLength(1);
|
||||
expect(polys[0]).toHaveLength(2);
|
||||
const area = Math.abs(ringArea(polys[0][0])) - Math.abs(ringArea(polys[0][1]));
|
||||
expect(area).toBeCloseTo(100 - 16, 9);
|
||||
});
|
||||
|
||||
it("zwei getrennte Körper: zwei Polygone ohne Löcher", () => {
|
||||
const m = merge(box(0, 0, 0, 2, 2, 2), box(5, 0, 0, 7, 2, 2));
|
||||
const polys = ringsToPolygons(cutMeshWithPlane(m.p, m.f, { kind: "horizontal", z: 1 }).rings);
|
||||
expect(polys).toHaveLength(2);
|
||||
expect(polys.every((p) => p.length === 1)).toBe(true);
|
||||
});
|
||||
|
||||
it("offenes Netz (Gelände): Linienzug statt Ring, Höhe als v", () => {
|
||||
// Zwei Dreiecke, die eine geneigte Fläche z = x bilden (x 0..4, y 0..4).
|
||||
const p = [0, 0, 0, 4, 0, 4, 4, 4, 4, 0, 4, 0];
|
||||
const f = [0, 1, 2, 0, 2, 3];
|
||||
const r = cutMeshWithPlane(p, f, { kind: "vertical", point: { x: 0, y: 2 }, dir: { x: 1, y: 0 } });
|
||||
expect(r.rings).toEqual([]);
|
||||
expect(r.lines).toHaveLength(1);
|
||||
const line = r.lines[0];
|
||||
const first = line[0];
|
||||
const last = line[line.length - 1];
|
||||
expect(Math.min(first[0], last[0])).toBeCloseTo(0, 9);
|
||||
expect(Math.max(first[0], last[0])).toBeCloseTo(4, 9);
|
||||
// v = z = u auf dieser Fläche
|
||||
for (const [u, v] of line) expect(v).toBeCloseTo(u, 9);
|
||||
});
|
||||
|
||||
it("schräge Schnittrichtung", () => {
|
||||
const b = box(0, 0, 0, 2, 2, 2);
|
||||
const s = Math.SQRT1_2;
|
||||
const r = cutMeshWithPlane(b.p, b.f, { kind: "vertical", point: { x: 0, y: 0 }, dir: { x: s, y: s } });
|
||||
expect(r.rings).toHaveLength(1);
|
||||
// Diagonale des Quaders: Länge 2√2, Höhe 2
|
||||
expect(Math.abs(ringArea(r.rings[0]))).toBeCloseTo(2 * Math.SQRT2 * 2, 6);
|
||||
});
|
||||
});
|
||||
@@ -1,96 +0,0 @@
|
||||
// Ebenenschnitt beliebiger Dreiecksnetze (docs/boolean-geometrie-plan.md, Baustein 1 / [G1]).
|
||||
//
|
||||
// Schneidet ein Netz (Modell-Koordinaten x, y, z = Höhe — wie `ImportedMesh`/`TerrainMesh`/truck-
|
||||
// Meshes) mit einer SENKRECHTEN Ebene (Schnitt) oder einer WAAGRECHTEN Ebene (Grundriss auf
|
||||
// Schnitthöhe) und liefert Linienzüge bzw. Ringe in den Ebenen-Koordinaten:
|
||||
// • senkrecht: (u, v) wie die Schnitt-Pipeline (u entlang der Ebene, v = Höhe),
|
||||
// • waagrecht: (x, y).
|
||||
// Geschlossene Netze (Körper) ergeben geschlossene Ringe → Polygone mit Löchern; offene Netze
|
||||
// (Gelände) ergeben offene Linienzüge (Geländelinie im Schnitt).
|
||||
//
|
||||
// Die Rechnung liegt im Rust-Kern (`src-tauri/core/src/mesh_section.rs`, [K3c]); hier nur die
|
||||
// Fassade mit unveränderter Signatur.
|
||||
|
||||
import { core } from "../engine/coreWasm";
|
||||
|
||||
export type Pt2 = [number, number];
|
||||
|
||||
export interface CutResult {
|
||||
/** Geschlossene Ringe (Körper). */
|
||||
rings: Pt2[][];
|
||||
/** Offene Linienzüge (offene Netze, z. B. Gelände). */
|
||||
lines: Pt2[][];
|
||||
}
|
||||
|
||||
/** Ebene durch `point` (Modell x,y) in Richtung `dir` (Einheitsvektor): senkrechter Schnitt. */
|
||||
export interface VerticalPlane {
|
||||
kind: "vertical";
|
||||
point: { x: number; y: number };
|
||||
dir: { x: number; y: number };
|
||||
}
|
||||
/** Waagrechte Ebene auf Höhe `z`. */
|
||||
export interface HorizontalPlane {
|
||||
kind: "horizontal";
|
||||
z: number;
|
||||
}
|
||||
export type CutPlane = VerticalPlane | HorizontalPlane;
|
||||
|
||||
/** Liest `[n, (k, u, v …) × n]` ab `i` (Index wandert mit). */
|
||||
function readRings(f: Float64Array, at: { i: number }): Pt2[][] {
|
||||
const out: Pt2[][] = [];
|
||||
for (let k = 0, n = f[at.i++]; k < n; k++) {
|
||||
const count = f[at.i++];
|
||||
const ring = new Array<Pt2>(count);
|
||||
for (let j = 0; j < count; j++, at.i += 2) ring[j] = [f[at.i], f[at.i + 1]];
|
||||
out.push(ring);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schneidet das Netz mit `plane`. `positions` flach [x,y,z,…], `indices` je 3 ein Dreieck.
|
||||
* Entartete Segmente (Länge ~0) werden verworfen.
|
||||
*/
|
||||
export function cutMeshWithPlane(positions: ArrayLike<number>, indices: ArrayLike<number>, plane: CutPlane): CutResult {
|
||||
const pl =
|
||||
plane.kind === "vertical"
|
||||
? [0, plane.point.x, plane.point.y, plane.dir.x, plane.dir.y]
|
||||
: [1, plane.z];
|
||||
const f = core().mesh_section_cut_flat(Float64Array.from(positions), Float64Array.from(indices), Float64Array.from(pl));
|
||||
if (f.length === 0) return { rings: [], lines: [] };
|
||||
const at = { i: 0 };
|
||||
const rings = readRings(f, at);
|
||||
const lines = readRings(f, at);
|
||||
return { rings, lines };
|
||||
}
|
||||
|
||||
/** Ring mit Löchern (Aussenring zuerst, dann Löcher). */
|
||||
export type RingSet = Pt2[][];
|
||||
|
||||
/**
|
||||
* Ordnet geschlossene Ringe zu Aussenring + Löchern (Schachtelungstiefe gerade = aussen, ungerade =
|
||||
* Loch). Unabhängig vom Umlaufsinn. Aussenringe zuerst-gross; Löcher folgen ihrem Aussenring.
|
||||
*/
|
||||
export function ringsToPolygons(rings: Pt2[][]): RingSet[] {
|
||||
const b: number[] = [rings.length];
|
||||
for (const r of rings) {
|
||||
b.push(r.length);
|
||||
for (const p of r) b.push(p[0], p[1]);
|
||||
}
|
||||
const f = core().mesh_section_polygons_flat(Float64Array.from(b));
|
||||
if (f.length === 0) return [];
|
||||
const at = { i: 1 };
|
||||
const out: RingSet[] = [];
|
||||
for (let k = 0; k < f[0]; k++) {
|
||||
const nr = f[at.i++];
|
||||
const set: RingSet = [];
|
||||
for (let r = 0; r < nr; r++) {
|
||||
const count = f[at.i++];
|
||||
const ring = new Array<Pt2>(count);
|
||||
for (let j = 0; j < count; j++, at.i += 2) ring[j] = [f[at.i], f[at.i + 1]];
|
||||
set.push(ring);
|
||||
}
|
||||
out.push(set);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
// waagrecht gedreht, die Blickrichtung zeigt im Blatt nach OBEN (Betrachter
|
||||
// steht unten, die gesehene Fassade liegt an der Unterkante des Grundrisses),
|
||||
// und die u-Achse stimmt exakt mit der des Schnitts/der Ansicht überein
|
||||
// (`sectionUAxisModel` / `elevationFrame`): ein Punkt im Grundriss liegt also
|
||||
// (`sectionUAxisModel`, im Kern `Plane::u_model` bzw. der Ansichts-Rahmen): ein Punkt im Grundriss liegt also
|
||||
// senkrecht unter seiner Projektion im Schnitt.
|
||||
//
|
||||
// Reine Starrkörper-Abbildung (Drehung + Verschiebung, keine Spiegelung) —
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
// VORÜBERGEHEND ([K3c]): Messung alt (TS) gegen neu (Kern) für Schnitt und Ansicht (nur mit BENCH=1).
|
||||
import { it } from "vitest";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { setWasmBytesProvider } from "../engine/wasmSource";
|
||||
import { computeSection as oldCompute } from "./toSection";
|
||||
import { generateSectionPlan as oldGen } from "./generatePlan";
|
||||
import { sectionOpeningPrimitives } from "./sectionOpenings";
|
||||
import { generateElevationPlan as oldElev } from "./toElevation";
|
||||
import { computeSection as newCompute, generateSectionPlan as newGen, generateElevationPlan as newElev } from "./sectionCore";
|
||||
import { planToRenderScene } from "./toRenderScene";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { flattenCategories } from "../model/types";
|
||||
import type { DrawingLevel, Project } from "../model/types";
|
||||
import { bigSectionProject } from "./sectionParity.testing";
|
||||
|
||||
async function time(f: () => Promise<unknown> | unknown, runs: number): Promise<[number, number]> {
|
||||
await f();
|
||||
const t: number[] = [];
|
||||
for (let i = 0; i < runs; i++) {
|
||||
const t0 = performance.now();
|
||||
await f();
|
||||
t.push(performance.now() - t0);
|
||||
}
|
||||
t.sort((a, b) => a - b);
|
||||
return [t[0], t[Math.floor(t.length / 2)]];
|
||||
}
|
||||
|
||||
const fmt = ([a, b]: [number, number]) => `${a.toFixed(1)}/${b.toFixed(1)}`;
|
||||
|
||||
it.skipIf(!process.env.BENCH)("Messung Schnitt/Ansicht alt gegen neu", async () => {
|
||||
setWasmBytesProvider(async (name) => readFileSync(join(process.cwd(), "src", "engine", name === "trucksolid" ? "pkgTruck/trucksolid_bg.wasm" : "pkg3d/render3d_bg.wasm")));
|
||||
const only = process.env.BENCH_ONLY;
|
||||
const all: Array<[string, Project]> = [["Beispiel", sampleProject], ["big6", bigSectionProject(6)], ["big8", bigSectionProject(8)], ["big16", bigSectionProject(16)]];
|
||||
const cases = all.filter(([n]) => !only || only.split(",").includes(n));
|
||||
const rows: string[] = ["Projekt | Ebene | alt Plan | neu Plan | alt +Szene | neu +Szene (ms min/median)"];
|
||||
for (const [name, p] of cases) {
|
||||
const codes = new Set(flattenCategories(p.layers).map((c) => c.code));
|
||||
const levels = p.drawingLevels.filter((l) => (l.kind === "section" || l.kind === "elevation") && l.linePoints) as DrawingLevel[];
|
||||
const runs = Number(process.env.BENCH_RUNS ?? (name === "big16" ? 1 : name === "Beispiel" ? 20 : 5));
|
||||
for (const l of levels) {
|
||||
if (l.kind === "section") {
|
||||
const oldP = async () => {
|
||||
const o = (await oldCompute(p, l))!;
|
||||
const pl = oldGen(o, false, { hiddenLines: l.hiddenLines, visibleCodes: codes });
|
||||
return { ...pl, primitives: [...pl.primitives, ...sectionOpeningPrimitives(p, l, codes)] };
|
||||
};
|
||||
const newP = async () => newGen((await newCompute(p, l))!, false, { hiddenLines: l.hiddenLines, visibleCodes: codes, openings: true });
|
||||
const skipOld = !!process.env.BENCH_NEW_ONLY;
|
||||
const a = skipOld ? ([NaN, NaN] as [number, number]) : await time(oldP, runs);
|
||||
const b = await time(newP, runs);
|
||||
const c = skipOld ? ([NaN, NaN] as [number, number]) : await time(async () => planToRenderScene(await oldP(), 100), runs);
|
||||
const d = await time(async () => planToRenderScene(await newP(), 100), runs);
|
||||
// Umschalten (Schwarz-Weiss) auf einem vorbereiteten Schnitt: der Kern rechnet nicht neu.
|
||||
const prepared = (await newCompute(p, l))!;
|
||||
let flip = false;
|
||||
const e = await time(() => newGen(prepared, (flip = !flip), { hiddenLines: l.hiddenLines, visibleCodes: codes, openings: true }), runs);
|
||||
rows.push(`${name} | ${l.id} Schnitt | ${fmt(a)} | ${fmt(b)} | ${fmt(c)} | ${fmt(d)} | Umschalten ${fmt(e)}`);
|
||||
process.stderr.write(rows[rows.length - 1] + "\n");
|
||||
} else {
|
||||
const skipOld = !!process.env.BENCH_NEW_ONLY;
|
||||
const a = skipOld ? ([NaN, NaN] as [number, number]) : await time(() => oldElev(p, l), runs);
|
||||
const b = await time(() => newElev(p, l), runs);
|
||||
const c = skipOld ? ([NaN, NaN] as [number, number]) : await time(() => planToRenderScene(oldElev(p, l)!, 100), runs);
|
||||
const d = await time(() => planToRenderScene(newElev(p, l)!, 100), runs);
|
||||
rows.push(`${name} | ${l.id} Ansicht | ${fmt(a)} | ${fmt(b)} | ${fmt(c)} | ${fmt(d)}`);
|
||||
process.stderr.write(rows[rows.length - 1] + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(rows.join("\n"));
|
||||
}, 3_600_000);
|
||||
@@ -1,168 +0,0 @@
|
||||
// Schnitt und Ansicht aus dem Kern ([K3c]): die Abfragen `sectionPlan`/`elevationPlan`
|
||||
// (`src-tauri/core/src/plan/{section,elevation}.rs`) liefern den Plan-Puffer v2 samt Pick-Ids;
|
||||
// TS reicht nur die Ebene, die Sichtbarkeit (UI-Zustand) und — für den Schnitt — die
|
||||
// asynchron gebauten truck-Körper hinein.
|
||||
|
||||
import type { DrawingLevel, Project } from "../model/types";
|
||||
import { flattenCategories, getFloor } from "../model/types";
|
||||
import { documentFor } from "../core/document";
|
||||
import { buildSolidMesh } from "../engine/truckSolid";
|
||||
import { extrudedSolidSpec } from "./extrudedSolidSpec";
|
||||
import { decodePlanBuf } from "./planBuf";
|
||||
import { lazyPlan } from "./planLazy";
|
||||
import type { CategoryDisplayResolver, Plan } from "./generatePlan";
|
||||
|
||||
/** Vorbereitete Eingabe eines Schnitts: Projekt, Ebene und die truck-Körper (flach). */
|
||||
export interface SectionOutput {
|
||||
project: Project;
|
||||
level: DrawingLevel;
|
||||
/** `[mono, openings, key, n, (index, nPos, pos…, nIdx, idx…) × n]`: Platz für die zwei Schalter, der
|
||||
* Schlüssel dieses Schnitts (der Kern merkt sich die zuletzt berechneten, Umschalten von Darstellung
|
||||
* oder Sichtbarkeit rechnet nicht neu), dann die geschnittenen freien Körper. */
|
||||
bodies: Float64Array;
|
||||
}
|
||||
|
||||
/** Schlüssel der vorbereiteten Schnitte (s. `SectionOutput.bodies`). */
|
||||
let sectionKey = 0;
|
||||
|
||||
/** Ob die Ebene eine gültige Schnittlinie trägt (wie `sectionPlaneFromLevel`). */
|
||||
function hasLine(level: DrawingLevel): boolean {
|
||||
const line = level.linePoints;
|
||||
if (!line) return false;
|
||||
return Math.hypot(line[1].x - line[0].x, line[1].y - line[0].y) >= 1e-9;
|
||||
}
|
||||
|
||||
/** Ob ein Körper als Abzugskörper wirkt (s. `voids.ts`). */
|
||||
function isVoid(s: NonNullable<Project["extrudedSolids"]>[number]): boolean {
|
||||
return s.operation === "subtract" && !s.brep && (s.taper ?? 0) < 1e-6 && s.points.length >= 3 && s.height > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bereitet den Schnitt der Ebene vor: baut die Netze der freien Körper (truck, asynchron, mit
|
||||
* Cache). `null`, wenn die Ebene keine gültige Schnittlinie trägt.
|
||||
*/
|
||||
export async function computeSection(project: Project, level: DrawingLevel): Promise<SectionOutput | null> {
|
||||
if (!hasLine(level)) return null;
|
||||
const bodies: number[] = [0, 0, ++sectionKey, 0];
|
||||
const solids = project.extrudedSolids ?? [];
|
||||
for (let index = 0; index < solids.length; index++) {
|
||||
const solid = solids[index];
|
||||
if (solid.operation === "subtract" || isVoid(solid)) continue;
|
||||
let baseZ = 0;
|
||||
try {
|
||||
baseZ = solid.levelId ? (getFloor(project, solid.levelId).baseElevation ?? 0) : 0;
|
||||
} catch {
|
||||
baseZ = 0;
|
||||
}
|
||||
const spec = extrudedSolidSpec(solid, baseZ);
|
||||
if (!spec) continue;
|
||||
let mesh: { positions: ArrayLike<number>; indices: ArrayLike<number> };
|
||||
try {
|
||||
mesh = await buildSolidMesh(spec, 0.01);
|
||||
} catch {
|
||||
continue; // Körper nicht baubar → im Schnitt weglassen, wie im 3D
|
||||
}
|
||||
bodies.push(index, mesh.positions.length);
|
||||
for (let i = 0; i < mesh.positions.length; i++) bodies.push(mesh.positions[i]);
|
||||
bodies.push(mesh.indices.length);
|
||||
for (let i = 0; i < mesh.indices.length; i++) bodies.push(mesh.indices[i]);
|
||||
bodies[3]++;
|
||||
}
|
||||
return { project, level, bodies: Float64Array.from(bodies) };
|
||||
}
|
||||
|
||||
/** Kategorie-Codes, die Schnitt/Ansicht prüfen. */
|
||||
function candidateCodes(project: Project): Set<string> {
|
||||
const codes = new Set<string>();
|
||||
for (const c of flattenCategories(project.layers)) codes.add(c.code);
|
||||
for (const list of [project.walls, project.ceilings, project.roofs, project.stairs, project.openings]) {
|
||||
for (const e of list ?? []) codes.add(e.categoryCode);
|
||||
}
|
||||
for (const c of project.context ?? []) if (c.type === "terrainMesh" && c.categoryCode !== undefined) codes.add(c.categoryCode);
|
||||
return codes;
|
||||
}
|
||||
|
||||
/** Sichtbarkeit (UI-Zustand) als Code-Listen für den Kern. */
|
||||
function visibilityArgs(project: Project, visibleCodes?: Set<string>, categoryDisplay?: CategoryDisplayResolver) {
|
||||
const invisible: string[] = [];
|
||||
const norender: string[] = [];
|
||||
const grey: string[] = [];
|
||||
for (const c of candidateCodes(project)) {
|
||||
if (visibleCodes && !visibleCodes.has(c)) invisible.push(c);
|
||||
if (categoryDisplay) {
|
||||
const d = categoryDisplay(c);
|
||||
if (!d.render) norender.push(c);
|
||||
if (d.greyed) grey.push(c);
|
||||
}
|
||||
}
|
||||
return { hasVis: !!visibleCodes, invisible, hasDisplay: !!categoryDisplay, norender, grey };
|
||||
}
|
||||
|
||||
/** Ebene ohne fremde Felder für den Kern. */
|
||||
function levelArg(level: DrawingLevel) {
|
||||
return {
|
||||
kind: level.kind,
|
||||
linePoints: level.linePoints,
|
||||
directionSign: level.directionSign,
|
||||
depth: level.depth,
|
||||
shadows: level.shadows,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Plan eines Schnitts (Cut-Flächen mit Stil und Pick-Ids, Gelände, sichtbare/verdeckte Kanten,
|
||||
* Bodenlinie). `openings`: geschnittene Fenster/Türen anhängen (nicht im Ausmass).
|
||||
*/
|
||||
export function generateSectionPlan(
|
||||
output: SectionOutput,
|
||||
mono = false,
|
||||
opts: { hiddenLines?: boolean; visibleCodes?: Set<string>; categoryDisplay?: CategoryDisplayResolver; openings?: boolean } = {},
|
||||
): Plan {
|
||||
const { project, level } = output;
|
||||
const text = JSON.stringify({
|
||||
level: levelArg(level),
|
||||
hiddenLines: !!opts.hiddenLines,
|
||||
...visibilityArgs(project, opts.visibleCodes, opts.categoryDisplay),
|
||||
});
|
||||
const args = output.bodies.slice();
|
||||
args[0] = mono ? 1 : 0;
|
||||
args[1] = opts.openings ? 1 : 0;
|
||||
const buf = decodePlanBuf(documentFor(project).queryBin("sectionPlan", args, text));
|
||||
if (buf.groups.length === 0) return { primitives: [], bounds: { minX: 0, minY: 0, maxX: 1, maxY: 1 } };
|
||||
const b = buf.bounds ?? [0, 0, 1, 1];
|
||||
return lazyPlan(
|
||||
{ bounds: { minX: b[0], minY: b[1], maxX: b[2], maxY: b[3] } },
|
||||
buf.groups.map(([from, to]) => ({ buf, from, to })),
|
||||
);
|
||||
}
|
||||
|
||||
/** Optionen des Ansichts-Generators. */
|
||||
export interface ElevationOptions {
|
||||
/** Schlagschatten zeichnen (Default aus `level.shadows`). */
|
||||
shadows?: boolean;
|
||||
/** Schwarz-Weiss-Modus (neutralisierte Füllungen). */
|
||||
mono?: boolean;
|
||||
/**
|
||||
* Ebenen-Panel-Sichtbarkeit: mit beiden Angaben werden Flächen ausgeblendeter Kategorien vor der
|
||||
* Verdeckung entfernt (sie verdecken dann auch nichts); ohne bleibt jede Fläche sichtbar.
|
||||
*/
|
||||
visibleCodes?: Set<string>;
|
||||
categoryDisplay?: CategoryDisplayResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ansichts-Plan einer Ebene (gefüllte Fassadenansicht, Painter fern → nah, Öffnungen, Schatten,
|
||||
* Bodenlinie). `null` ohne Ansichtslinie.
|
||||
*/
|
||||
export function generateElevationPlan(project: Project, level: DrawingLevel, opts: ElevationOptions = {}): Plan | null {
|
||||
if (!hasLine(level)) return null;
|
||||
const shadows = opts.shadows ?? level.shadows ?? false;
|
||||
const text = JSON.stringify({ level: levelArg(level), ...visibilityArgs(project, opts.visibleCodes, opts.categoryDisplay) });
|
||||
const buf = decodePlanBuf(documentFor(project).queryBin("elevationPlan", [opts.mono ? 1 : 0, shadows ? 1 : 0], text));
|
||||
if (buf.groups.length === 0) return null;
|
||||
const b = buf.bounds ?? [0, 0, 1, 1];
|
||||
return lazyPlan(
|
||||
{ bounds: { minX: b[0], minY: b[1], maxX: b[2], maxY: b[3] } },
|
||||
buf.groups.map(([from, to]) => ({ buf, from, to })),
|
||||
);
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
// Gelände und freie Körper im Schnitt ([G1]): echter Lauf über computeSection (render3d- und
|
||||
// truck-WASM aus src/engine/pkg*).
|
||||
// Gelände und freie Körper im Schnitt ([G1]): echter Lauf über computeSection/generateSectionPlan
|
||||
// (Kern, truck-WASM aus src/engine/pkgTruck).
|
||||
import { beforeAll, describe, expect, it } from "vitest";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { setWasmBytesProvider } from "../engine/wasmSource";
|
||||
import { computeSection } from "./toSection";
|
||||
import { generateSectionPlan } from "./generatePlan";
|
||||
import { computeSection, generateSectionPlan } from "./toSection";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import type { ExtrudedSolid, Project, TerrainMesh } from "../model/types";
|
||||
|
||||
@@ -34,15 +33,16 @@ function terrain(): TerrainMesh {
|
||||
describe("Schnitt: Gelände und freie Körper", () => {
|
||||
it("Geländelinie als Linienzug im Schnitt, auf den Gebäudebereich begrenzt", async () => {
|
||||
const p: Project = { ...sampleProject, context: [...(sampleProject.context ?? []), terrain()] };
|
||||
const out = (await computeSection(p, section))!;
|
||||
expect(out.profiles?.length).toBeGreaterThan(0);
|
||||
const pts = out.profiles!.flatMap((x) => x.pts);
|
||||
const plan = generateSectionPlan((await computeSection(p, section))!);
|
||||
const terrainLines = plan.primitives.filter((q) => q.kind === "line" && q.cls === "section-terrain");
|
||||
expect(terrainLines.length).toBeGreaterThan(0);
|
||||
const us = terrainLines.flatMap((q) => (q.kind === "line" ? [q.a.x, q.b.x] : []));
|
||||
// Begrenzung: nicht über das ganze 40-m-Gelände, sondern Inhalt ± Rand
|
||||
const us = out.cutPolygons.flatMap((c) => c.pts.map((q) => q[0]));
|
||||
expect(Math.min(...pts.map((q) => q[0]))).toBeGreaterThanOrEqual(Math.min(...us) - 6.01);
|
||||
expect(Math.max(...pts.map((q) => q[0]))).toBeLessThanOrEqual(Math.max(...us) + 6.01);
|
||||
const plan = generateSectionPlan(out);
|
||||
expect(plan.primitives.some((q) => q.kind === "line" && q.cls === "section-terrain")).toBe(true);
|
||||
const cut = plan.primitives.flatMap((q) =>
|
||||
q.kind === "polygon" ? q.pts.map((r) => r.x) : q.kind === "line" && q.cls === "section-visible" ? [q.a.x, q.b.x] : [],
|
||||
);
|
||||
expect(Math.min(...us)).toBeGreaterThanOrEqual(Math.min(...cut) - 6.01);
|
||||
expect(Math.max(...us)).toBeLessThanOrEqual(Math.max(...cut) + 6.01);
|
||||
}, 30_000);
|
||||
|
||||
it("Kugel (B-Rep) wird als Schnittfläche gefüllt, wenn die Ebene sie trifft", async () => {
|
||||
@@ -55,11 +55,7 @@ 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 out = (await computeSection(p, section))!;
|
||||
const body = out.cutPolygons.filter((c) => c.component.kind === "body");
|
||||
expect(body.length).toBeGreaterThan(0);
|
||||
expect(body[0].sourceId).toBe("ball");
|
||||
const plan = generateSectionPlan(out);
|
||||
expect(plan.primitives.some((q) => q.kind === "polygon" && q.extrudedSolidId === "ball")).toBe(true);
|
||||
const plan = generateSectionPlan((await computeSection(p, section))!);
|
||||
expect(plan.primitives.some((q) => q.kind === "polygon" && q.extrudedSolidId === "ball" && q.fill === "#d9dde2")).toBe(true);
|
||||
}, 30_000);
|
||||
});
|
||||
@@ -1,134 +0,0 @@
|
||||
// Zusätze zum Schnitt, die nicht Wand/Decke/Dach sind (Baustein [G1], meshSection.ts):
|
||||
// • Geländelinie: das Gelände-Netz (`TerrainMesh`) geschnitten → Linienzug im Schnitt,
|
||||
// auf den Bereich des Gebäudes (± Rand) begrenzt.
|
||||
// • Körper: freie Körper (`ExtrudedSolid`, B-Rep) geschnitten → gefüllte Schnittflächen.
|
||||
|
||||
import type { ExtrudedSolid, Project } from "../model/types";
|
||||
import { getFloor } from "../model/types";
|
||||
import { buildSolidMesh } from "../engine/truckSolid";
|
||||
import { extrudedSolidSpec } from "./extrudedSolidSpec";
|
||||
import { isVoidSolid } from "./voids";
|
||||
import { cutMeshWithPlane, ringsToPolygons } from "./meshSection";
|
||||
import type { Pt2 } from "./meshSection";
|
||||
import { keyhole } from "./voids";
|
||||
import type { SectionCutPolygon, SectionOutput, SectionPlaneSpec } from "./toSection";
|
||||
|
||||
type UDir = { x: number; y: number };
|
||||
|
||||
/** Seitenrand (m) der Geländelinie um den Inhalt des Schnitts. */
|
||||
const TERRAIN_MARGIN = 6;
|
||||
/** Neutrale Füllung geschnittener freier Körper (kein Bauteil/Material zugeordnet). */
|
||||
const BODY_FILL = "#d9dde2";
|
||||
const BODY_RGB: [number, number, number] = [0.85, 0.87, 0.89];
|
||||
|
||||
function planeOf(plane: SectionPlaneSpec, dir: UDir) {
|
||||
return { kind: "vertical" as const, point: { x: plane.point[0], y: plane.point[2] }, dir };
|
||||
}
|
||||
|
||||
/** Wertebereich in u über alle Cut-Polygone und Kanten (für die Geländebegrenzung). */
|
||||
function uRange(output: SectionOutput): [number, number] | null {
|
||||
let lo = Infinity;
|
||||
let hi = -Infinity;
|
||||
for (const cp of output.cutPolygons) for (const p of cp.pts) (lo = Math.min(lo, p[0])), (hi = Math.max(hi, p[0]));
|
||||
for (const e of [...output.visibleEdges, ...output.hiddenEdges]) {
|
||||
lo = Math.min(lo, e.a[0], e.b[0]);
|
||||
hi = Math.max(hi, e.a[0], e.b[0]);
|
||||
}
|
||||
return Number.isFinite(lo) ? [lo, hi] : null;
|
||||
}
|
||||
|
||||
/** Schneidet einen Linienzug auf [lo, hi] in u (Segmentweise, interpoliert die Ränder). */
|
||||
function clipLineToU(pts: Pt2[], lo: number, hi: number): Pt2[][] {
|
||||
const out: Pt2[][] = [];
|
||||
let cur: Pt2[] = [];
|
||||
const flush = () => {
|
||||
if (cur.length >= 2) out.push(cur);
|
||||
cur = [];
|
||||
};
|
||||
for (let i = 0; i + 1 < pts.length; i++) {
|
||||
const a = pts[i];
|
||||
const b = pts[i + 1];
|
||||
const [u0, u1] = [a[0], b[0]];
|
||||
if ((u0 < lo && u1 < lo) || (u0 > hi && u1 > hi)) {
|
||||
flush();
|
||||
continue;
|
||||
}
|
||||
const at = (u: number): Pt2 => {
|
||||
const t = u1 === u0 ? 0 : (u - u0) / (u1 - u0);
|
||||
return [u, a[1] + (b[1] - a[1]) * t];
|
||||
};
|
||||
const pa: Pt2 = u0 < lo ? at(lo) : u0 > hi ? at(hi) : a;
|
||||
const pb: Pt2 = u1 < lo ? at(lo) : u1 > hi ? at(hi) : b;
|
||||
if (cur.length === 0) cur.push(pa);
|
||||
cur.push(pb);
|
||||
if (u1 < lo || u1 > hi) flush();
|
||||
}
|
||||
flush();
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Hängt die Geländelinien aller Gelände-Netze an `output.profiles`. */
|
||||
export function appendTerrainProfiles(output: SectionOutput, project: Project, plane: SectionPlaneSpec, uDir: UDir): void {
|
||||
const terrains = (project.context ?? []).filter((c) => c.type === "terrainMesh");
|
||||
if (terrains.length === 0) return;
|
||||
const range = uRange(output);
|
||||
const cut = planeOf(plane, uDir);
|
||||
for (const t of terrains) {
|
||||
if (t.type !== "terrainMesh" || t.positions.length < 9) continue;
|
||||
const { lines } = cutMeshWithPlane(t.positions, t.indices, cut);
|
||||
for (const line of lines) {
|
||||
const parts = range ? clipLineToU(line, range[0] - TERRAIN_MARGIN, range[1] + TERRAIN_MARGIN) : [line];
|
||||
for (const pts of parts) {
|
||||
(output.profiles ??= []).push({ kind: "terrain", id: t.id, categoryCode: t.categoryCode, pts });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Welche Körper im Schnitt erscheinen (freie Körper, keine Abzugskörper). */
|
||||
export function sectionSolids(project: Project): Array<{ index: number; solid: ExtrudedSolid }> {
|
||||
const out: Array<{ index: number; solid: ExtrudedSolid }> = [];
|
||||
(project.extrudedSolids ?? []).forEach((solid, index) => {
|
||||
if (solid.operation === "subtract" || isVoidSolid(solid)) return;
|
||||
out.push({ index, solid });
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Hängt die geschnittenen freien Körper als Cut-Polygone an (truck-Mesh, asynchron). */
|
||||
export async function appendBodySections(output: SectionOutput, project: Project, plane: SectionPlaneSpec, uDir: UDir): Promise<void> {
|
||||
const cut = planeOf(plane, uDir);
|
||||
for (const { index, solid } of sectionSolids(project)) {
|
||||
let baseZ = 0;
|
||||
try {
|
||||
baseZ = solid.levelId ? (getFloor(project, solid.levelId).baseElevation ?? 0) : 0;
|
||||
} catch {
|
||||
baseZ = 0;
|
||||
}
|
||||
const spec = extrudedSolidSpec(solid, baseZ);
|
||||
if (!spec) continue;
|
||||
let mesh: { positions: number[]; indices: number[] };
|
||||
try {
|
||||
mesh = await buildSolidMesh(spec, 0.01);
|
||||
} catch {
|
||||
continue; // Körper nicht baubar → im Schnitt weglassen, wie im 3D
|
||||
}
|
||||
const { rings } = cutMeshWithPlane(mesh.positions, mesh.indices, cut);
|
||||
for (const poly of ringsToPolygons(rings)) {
|
||||
const { pts } = poly.length > 1 ? keyhole(poly as [number, number][][]) : { pts: poly[0] };
|
||||
const cp: SectionCutPolygon = {
|
||||
component: { kind: "body", index },
|
||||
color: BODY_RGB,
|
||||
pts: pts as Array<[number, number]>,
|
||||
fill: BODY_FILL,
|
||||
noStrokeEdges: poly.length > 1 ? holeBridgeEdges(pts.length, poly) : undefined,
|
||||
};
|
||||
output.cutPolygons.push(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Kanten-Indizes der Schlüsselloch-Stege eines Rings mit Löchern. */
|
||||
function holeBridgeEdges(n: number, poly: Pt2[][]): number[] {
|
||||
return keyhole(poly as [number, number][][]).bridges.filter((i) => i < n);
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
// Geschnittene Fenster/Türen im Schnitt (Kern, `core/src/plan/section.rs`), über `generateSectionPlan`
|
||||
// mit `openings: true` wie in der Schnitt-Ansicht.
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import type { DrawingLevel } from "../model/types";
|
||||
import type { Primitive } from "./generatePlan";
|
||||
import { sectionOpeningPrimitives } from "./sectionOpenings";
|
||||
import { computeSection, generateSectionPlan } from "./toSection";
|
||||
|
||||
const section = (x: number): DrawingLevel => ({
|
||||
id: "sx",
|
||||
@@ -15,10 +17,14 @@ const section = (x: number): DrawingLevel => ({
|
||||
directionSign: 1,
|
||||
});
|
||||
|
||||
describe("sectionOpeningPrimitives", () => {
|
||||
it("geschnittenes Fenster: Rahmenprofile an Brüstung/Sturz + Glaslinie, wählbar", () => {
|
||||
const prims = sectionOpeningPrimitives(sampleProject, section(3.5));
|
||||
const own = prims.filter((p) => "openingId" in p && p.openingId === "O1");
|
||||
async function openingPrims(level: DrawingLevel, openings = true): Promise<Primitive[]> {
|
||||
const out = (await computeSection(sampleProject, level))!;
|
||||
return generateSectionPlan(out, false, { openings }).primitives.filter((p) => "openingId" in p && p.openingId);
|
||||
}
|
||||
|
||||
describe("Schnitt: geschnittene Öffnungen", () => {
|
||||
it("geschnittenes Fenster: Rahmenprofile an Brüstung/Sturz + Glaslinie, wählbar", async () => {
|
||||
const own = (await openingPrims(section(3.5))).filter((p) => "openingId" in p && p.openingId === "O1");
|
||||
expect(own.length).toBeGreaterThanOrEqual(4);
|
||||
const glass = own.filter((p): p is Extract<Primitive, { kind: "line" }> => p.kind === "line");
|
||||
expect(glass.length).toBeGreaterThan(0);
|
||||
@@ -28,11 +34,13 @@ describe("sectionOpeningPrimitives", () => {
|
||||
expect(Math.max(...vs)).toBeLessThan(2.1 + 1e-9);
|
||||
});
|
||||
|
||||
it("Schnitt neben dem Fenster: nichts", () => {
|
||||
expect(sectionOpeningPrimitives(sampleProject, section(1.0)).some((p) => "openingId" in p && p.openingId === "O1")).toBe(false);
|
||||
it("Schnitt neben dem Fenster: nichts", async () => {
|
||||
expect((await openingPrims(section(1.0))).some((p) => "openingId" in p && p.openingId === "O1")).toBe(false);
|
||||
});
|
||||
|
||||
it("Ansichten bekommen keine Schnitt-Öffnungen", () => {
|
||||
expect(sectionOpeningPrimitives(sampleProject, { ...section(3.5), kind: "elevation" })).toEqual([]);
|
||||
it("nur auf Wunsch (Export ohne Öffnungen) und nie in Ansichten", async () => {
|
||||
expect(await openingPrims(section(3.5), false)).toEqual([]);
|
||||
const out = (await computeSection(sampleProject, { ...section(3.5), kind: "elevation" }))!;
|
||||
expect(generateSectionPlan(out, false, { openings: true }).primitives.some((p) => "openingId" in p && p.openingId)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,210 +0,0 @@
|
||||
// Geschnittene Fenster/Türen im Schnitt. Der Schnitt-Extraktor (section.rs)
|
||||
// spart in einer geschnittenen Wand nur die Öffnung aus (Brüstung + Sturz als
|
||||
// Poché, dazwischen nichts) — das Fenster selbst fehlte, die Öffnung wirkte wie
|
||||
// ein Loch. Hier entsteht der vertikale Querschnitt des Öffnungselements:
|
||||
// • Fenster: Blendrahmen-Profil unten (auf der Brüstung) und oben (am Sturz)
|
||||
// über die Rahmentiefe + Glaslinie(n) dazwischen. Rahmentiefe/-lage und
|
||||
// Glas-Lage stammen aus DEMSELBEN `windowSymbol` wie der Grundriss — die
|
||||
// Lage in der Wand stimmt also mit dem Grundriss überein.
|
||||
// • Tür: Zargen-Profil am Sturz + geschlossenes Türblatt.
|
||||
// Alles in Schnitt-Koordinaten (u, Höhe), wie `SectionOutput`.
|
||||
|
||||
import type { DrawingLevel, Opening, Project, Vec2, Wall } from "../model/types";
|
||||
import { getWallType, getWindowType, sashesOfWindowType, wallTypeThickness } from "../model/types";
|
||||
import { dot, sub } from "../model/geometry";
|
||||
import { wallReferenceOffset } from "../model/wall";
|
||||
import { openingInterval, openingVerticalExtent, wallAxisFrame, windowSymbol } from "../geometry/opening";
|
||||
import { NO_HATCH, SHOW_ALL, type CategoryDisplayResolver, type Primitive } from "./generatePlan/shared";
|
||||
import { sectionPlaneFromLevel, sectionUAxisModel } from "./toSection";
|
||||
|
||||
const INK = "#1f242c";
|
||||
/** Umriss geschnittener Rahmen-/Blattprofile (mm Papier). */
|
||||
const FRAME_MM = 0.25;
|
||||
/** Glaslinien (mm Papier). */
|
||||
const GLASS_MM = 0.13;
|
||||
/** Default-Rahmentiefe/-profilbreite (m), wie im Grundriss (`opening.ts`). */
|
||||
const DEFAULT_FRAME_DEPTH = 0.07;
|
||||
const DEFAULT_FRAME_WIDTH = 0.06;
|
||||
/** Türblatt-Dicke (m). */
|
||||
const DOOR_LEAF_THICKNESS = 0.04;
|
||||
/** Unter diesem |cos| zwischen Wandnormale und Schnitt-u gilt die Wand als
|
||||
* (fast) parallel zum Schnitt — dort gibt es keinen sinnvollen Querschnitt. */
|
||||
const MIN_CROSS = 0.15;
|
||||
|
||||
const rect = (u0: number, u1: number, v0: number, v1: number): Vec2[] => [
|
||||
{ x: Math.min(u0, u1), y: v0 },
|
||||
{ x: Math.max(u0, u1), y: v0 },
|
||||
{ x: Math.max(u0, u1), y: v1 },
|
||||
{ x: Math.min(u0, u1), y: v1 },
|
||||
];
|
||||
|
||||
/**
|
||||
* Plan-Primitive (u, Höhe) aller Fenster/Türen, deren Wand die Schnittebene der
|
||||
* Ebene `level` IM Bereich der Öffnung kreuzt. Jedes Primitiv trägt die
|
||||
* `openingId` — ein Klick im Schnitt wählt die Öffnung.
|
||||
*/
|
||||
export function sectionOpeningPrimitives(
|
||||
project: Project,
|
||||
level: DrawingLevel,
|
||||
visibleCodes?: Set<string>,
|
||||
categoryDisplay: CategoryDisplayResolver = SHOW_ALL,
|
||||
): Primitive[] {
|
||||
const plane = sectionPlaneFromLevel(level);
|
||||
if (!plane || level.kind !== "section") return [];
|
||||
const uRaw = sectionUAxisModel(plane);
|
||||
const uLen = Math.hypot(uRaw.x, uRaw.y) || 1;
|
||||
const U: Vec2 = { x: uRaw.x / uLen, y: uRaw.y / uLen };
|
||||
const P0: Vec2 = { x: plane.point[0], y: plane.point[2] };
|
||||
const wallsById = new Map(project.walls.map((w) => [w.id, w]));
|
||||
const out: Primitive[] = [];
|
||||
|
||||
for (const o of project.openings ?? []) {
|
||||
if (visibleCodes && !visibleCodes.has(o.categoryCode)) continue;
|
||||
const disp = categoryDisplay(o.categoryCode);
|
||||
if (!disp.render) continue;
|
||||
const wall = wallsById.get(o.hostWallId);
|
||||
if (!wall) continue;
|
||||
if (visibleCodes && !visibleCodes.has(wall.categoryCode)) continue;
|
||||
const cut = crossSection(project, wall, o, P0, U);
|
||||
if (!cut) continue;
|
||||
const prims = o.kind === "window" ? windowCut(project, wall, o, cut) : doorCut(o, cut);
|
||||
for (const p of prims) out.push(disp.greyed ? ({ ...p, greyed: true } as Primitive) : p);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Abbildung "Offset quer zur Wand (n)" → Schnitt-u, falls die Schnittebene die
|
||||
* Wandachse innerhalb der Öffnung kreuzt. */
|
||||
interface CrossSection {
|
||||
/** u eines Punktes mit Wand-Offset `s` (entlang der linken Normalen). */
|
||||
uAt: (s: number) => number;
|
||||
zBottom: number;
|
||||
zTop: number;
|
||||
/** Wand-Offsets der Wandflächen (min/max). */
|
||||
faceMin: number;
|
||||
faceMax: number;
|
||||
}
|
||||
|
||||
function crossSection(project: Project, wall: Wall, o: Opening, P0: Vec2, U: Vec2): CrossSection | null {
|
||||
const iv = openingInterval(wall, o);
|
||||
if (!iv) return null;
|
||||
const { u: a, n } = wallAxisFrame(wall);
|
||||
const un = dot(U, n);
|
||||
if (Math.abs(un) < MIN_CROSS) return null;
|
||||
const rel = sub(P0, wall.start);
|
||||
const n0 = dot(rel, n);
|
||||
const a0 = dot(rel, a);
|
||||
const ua = dot(U, a);
|
||||
// Schnittlinie p(t) = P0 + t·U; Offset quer zur Wand: n0 + t·un.
|
||||
const tAt = (s: number) => (s - n0) / un;
|
||||
// Lage entlang der Achse dort, wo die Schnittlinie die Wandmitte quert.
|
||||
const total = wallTypeThickness(getWallType(project, wall));
|
||||
const refOff = wallReferenceOffset(wall, total);
|
||||
const along = a0 + tAt(refOff) * ua;
|
||||
if (along < iv.from + 1e-4 || along > iv.to - 1e-4) return null;
|
||||
const { zBottom, zTop } = openingVerticalExtent(project, wall, o);
|
||||
if (zTop - zBottom < 1e-3) return null;
|
||||
return {
|
||||
uAt: (s) => tAt(s),
|
||||
zBottom,
|
||||
zTop,
|
||||
faceMin: refOff - total / 2,
|
||||
faceMax: refOff + total / 2,
|
||||
};
|
||||
}
|
||||
|
||||
const profile = (pts: Vec2[], openingId: string): Primitive => ({
|
||||
kind: "polygon",
|
||||
pts,
|
||||
fill: "#ffffff",
|
||||
stroke: INK,
|
||||
strokeWidthMm: FRAME_MM,
|
||||
hatch: NO_HATCH,
|
||||
openingId,
|
||||
});
|
||||
|
||||
const pick = (pts: Vec2[], openingId: string): Primitive => ({
|
||||
kind: "polygon",
|
||||
pts,
|
||||
fill: "none",
|
||||
stroke: "none",
|
||||
strokeWidthMm: 0,
|
||||
hatch: NO_HATCH,
|
||||
openingId,
|
||||
});
|
||||
|
||||
function windowCut(project: Project, wall: Wall, o: Opening, c: CrossSection): Primitive[] {
|
||||
const wt = getWindowType(project, o);
|
||||
const spec = wt
|
||||
? {
|
||||
sashes: sashesOfWindowType(wt),
|
||||
frameWidth: wt.frameWidth ?? DEFAULT_FRAME_WIDTH,
|
||||
frameDepth: wt.frameDepth,
|
||||
insetFromFace: wt.insetFromFace,
|
||||
insetFace: wt.insetFace,
|
||||
}
|
||||
: undefined;
|
||||
const fw = Math.max(0.02, spec?.frameWidth ?? DEFAULT_FRAME_WIDTH);
|
||||
const { n } = wallAxisFrame(wall);
|
||||
const offOf = (p: Vec2) => dot(sub(p, wall.start), n);
|
||||
|
||||
// Rahmenband quer zur Wand aus dem Grundriss-Symbol (gleiche Lage wie dort).
|
||||
let fMin = (c.faceMin + c.faceMax) / 2 - DEFAULT_FRAME_DEPTH / 2;
|
||||
let fMax = fMin + DEFAULT_FRAME_DEPTH;
|
||||
let glass: number[] = [(fMin + fMax) / 2];
|
||||
const sym = windowSymbol(project, wall, o, 1, spec, "mittel");
|
||||
if (sym && spec) {
|
||||
const offs = sym.frame.map(offOf);
|
||||
fMin = Math.min(...offs);
|
||||
fMax = Math.max(...offs);
|
||||
const g = sym.glassLines.map(([p]) => offOf(p));
|
||||
if (g.length > 0) glass = [...new Set(g.map((x) => Math.round(x * 1e6) / 1e6))];
|
||||
}
|
||||
const u0 = c.uAt(fMin);
|
||||
const u1 = c.uAt(fMax);
|
||||
const h = c.zTop - c.zBottom;
|
||||
const fwv = Math.min(fw, h / 3);
|
||||
const out: Primitive[] = [pick(rect(c.uAt(c.faceMin), c.uAt(c.faceMax), c.zBottom, c.zTop), o.id)];
|
||||
out.push(profile(rect(u0, u1, c.zBottom, c.zBottom + fwv), o.id));
|
||||
out.push(profile(rect(u0, u1, c.zTop - fwv, c.zTop), o.id));
|
||||
for (const s of glass) {
|
||||
const u = c.uAt(s);
|
||||
out.push({
|
||||
kind: "line",
|
||||
a: { x: u, y: c.zBottom + fwv },
|
||||
b: { x: u, y: c.zTop - fwv },
|
||||
cls: "section-window-glass",
|
||||
weightMm: GLASS_MM,
|
||||
color: INK,
|
||||
openingId: o.id,
|
||||
});
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function doorCut(o: Opening, c: CrossSection): Primitive[] {
|
||||
const out: Primitive[] = [pick(rect(c.uAt(c.faceMin), c.uAt(c.faceMax), c.zBottom, c.zTop), o.id)];
|
||||
if (o.doorType === "wandoeffnung") return out;
|
||||
const mid = (c.faceMin + c.faceMax) / 2;
|
||||
const fw = Math.min(DEFAULT_FRAME_WIDTH, (c.zTop - c.zBottom) / 4);
|
||||
// Zarge am Sturz über die Rahmentiefe.
|
||||
out.push(
|
||||
profile(
|
||||
rect(c.uAt(mid - DEFAULT_FRAME_DEPTH / 2), c.uAt(mid + DEFAULT_FRAME_DEPTH / 2), c.zTop - fw, c.zTop),
|
||||
o.id,
|
||||
),
|
||||
);
|
||||
// Geschlossenes Türblatt (knapp über Boden bis unter die Zarge).
|
||||
out.push(
|
||||
profile(
|
||||
rect(
|
||||
c.uAt(mid - DOOR_LEAF_THICKNESS / 2),
|
||||
c.uAt(mid + DOOR_LEAF_THICKNESS / 2),
|
||||
c.zBottom + 0.01,
|
||||
c.zTop - fw,
|
||||
),
|
||||
o.id,
|
||||
),
|
||||
);
|
||||
return out;
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
// VORÜBERGEHEND ([K3c]): Zufallsprojekte und Schnitt-/Ansichtsebenen für den Gleichheitstest
|
||||
// alt (TS) gegen neu (Kern). Wird mit dem Test gelöscht.
|
||||
|
||||
import type { DrawingLevel, ExtrudedSolid, Project, TerrainMesh, Wall } from "../model/types";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { bigSampleProject } from "./bigSampleProject.testing";
|
||||
|
||||
export function rng(seed: number): () => number {
|
||||
let x = (seed * 2654435761) >>> 0;
|
||||
return () => (x = (x * 1664525 + 1013904223) % 4294967296) / 4294967296;
|
||||
}
|
||||
|
||||
const pick = <T>(r: () => number, a: readonly T[]): T => a[Math.floor(r() * a.length)];
|
||||
const clone = <T>(v: T): T => JSON.parse(JSON.stringify(v)) as T;
|
||||
const round = (v: number) => Math.round(v * 1e4) / 1e4;
|
||||
|
||||
const HATCHES = ["none", "insulation", "diagonal", "crosshatch", "solid-concrete", "sia-concrete", "sia-brick", "sia-insulation", "missing-hatch"];
|
||||
const COLORS = ["#ff0000", "#00aa33", " #123456 ", "#abc", "#000000"];
|
||||
|
||||
function terrain(r: () => number): TerrainMesh {
|
||||
const n = 12;
|
||||
const positions: number[] = [];
|
||||
const tilt = (r() - 0.5) * 0.3;
|
||||
for (let j = 0; j < n; j++) for (let i = 0; i < n; i++) positions.push(i * 2 - 8, j * 2 - 8, tilt * (i - 5) + (r() - 0.5) * 0.4 - 0.2);
|
||||
const indices: number[] = [];
|
||||
for (let j = 0; j + 1 < n; j++)
|
||||
for (let i = 0; i + 1 < n; i++) {
|
||||
const a = j * n + i;
|
||||
indices.push(a, a + 1, a + n, a + 1, a + n + 1, a + n);
|
||||
}
|
||||
return { id: "terrain" + Math.floor(r() * 100), type: "terrainMesh", name: "Gelände", positions, indices, categoryCode: r() < 0.5 ? "99" : undefined } as TerrainMesh;
|
||||
}
|
||||
|
||||
/** Zufallsprojekt auf Basis des Beispielhauses (Wände, Öffnungen, Dächer, Treppen, Abzugskörper, Overrides …). */
|
||||
export function randomSectionProject(seed: number): Project {
|
||||
const r = rng(seed);
|
||||
const p = clone(sampleProject) as Project;
|
||||
const jit = (v: number, a: number) => round(v + (r() - 0.5) * a);
|
||||
// Wände: verschieben, Typen, Overrides, Terminierung, zusätzliche Wände
|
||||
const extra: Wall[] = [];
|
||||
for (let k = 0; k < Math.floor(r() * 4); k++) {
|
||||
const x0 = jit(2.5, 6), y0 = jit(2, 5);
|
||||
const ang = r() < 0.6 ? (r() < 0.5 ? 0 : Math.PI / 2) : r() * Math.PI;
|
||||
const len = 1 + r() * 4;
|
||||
extra.push({
|
||||
id: `WX${k}`, type: "wall", floorId: r() < 0.7 ? "eg" : "og", categoryCode: r() < 0.8 ? "20" : "22",
|
||||
start: { x: x0, y: y0 }, end: { x: round(x0 + Math.cos(ang) * len), y: round(y0 + Math.sin(ang) * len) },
|
||||
wallTypeId: pick(r, ["aw", "iw", "iw", "aw", "nope"]), height: round(2 + r()),
|
||||
} as Wall);
|
||||
}
|
||||
p.walls = [...p.walls, ...extra].map((w) => {
|
||||
const o: Wall = { ...w };
|
||||
if (r() < 0.2) o.start = { x: jit(o.start.x, 0.4), y: jit(o.start.y, 0.4) };
|
||||
if (r() < 0.2) o.end = { x: jit(o.end.x, 0.4), y: jit(o.end.y, 0.4) };
|
||||
if (r() < 0.15) o.wallTypeId = pick(r, ["aw", "iw"]);
|
||||
if (r() < 0.2) {
|
||||
o.hatchSource = pick(r, ["layer", "object"] as const);
|
||||
if (r() < 0.6) o.hatchId = pick(r, HATCHES);
|
||||
}
|
||||
if (r() < 0.15) { o.foreground = pick(r, COLORS); o.foregroundSource = pick(r, ["layer", "object"] as const); }
|
||||
if (r() < 0.15) { o.background = pick(r, COLORS); o.backgroundSource = pick(r, ["layer", "object"] as const); }
|
||||
if (r() < 0.3) o.sliceTermination = pick(r, ["below", "above", "both"] as const);
|
||||
if (r() < 0.1) o.height = round(1 + r() * 3);
|
||||
return o;
|
||||
});
|
||||
// Öffnungen
|
||||
const ops = [...(p.openings ?? [])];
|
||||
for (let k = 0; k < Math.floor(r() * 5); k++) {
|
||||
const host = pick(r, p.walls);
|
||||
const door = r() < 0.4;
|
||||
ops.push({
|
||||
id: `OX${k}`, type: "opening", hostWallId: host.id, categoryCode: r() < 0.9 ? "21" : "22",
|
||||
kind: door ? "door" : "window",
|
||||
typeId: door ? pick(r, ["door-standard", "door-entry", "nope", undefined]) : pick(r, ["window-standard", "window-double", "nope", undefined]),
|
||||
position: round(r() * 3), width: round(0.5 + r() * 1.5), height: round(0.8 + r() * 1.6), sillHeight: door ? 0 : round(r() * 1.2),
|
||||
...(door && r() < 0.2 ? { doorType: "wandoeffnung" } : {}),
|
||||
...(r() < 0.2 ? { wingCount: 1 + Math.floor(r() * 3) } : {}),
|
||||
} as never);
|
||||
}
|
||||
p.openings = ops.map((o) => (r() < 0.2 ? { ...o, position: jit(o.position, 1), width: Math.max(0.2, jit(o.width, 0.6)) } : o));
|
||||
// Decken
|
||||
p.ceilings = (p.ceilings ?? []).map((c) => ({
|
||||
...c,
|
||||
...(r() < 0.3 ? { thickness: round(0.1 + r() * 0.3) } : {}),
|
||||
...(r() < 0.2 ? { ceilingTypeId: undefined, wallTypeId: pick(r, ["aw", "iw", "nope"]) } : {}),
|
||||
...(r() < 0.2 ? { hatchSource: pick(r, ["layer", "object"] as const), hatchId: pick(r, HATCHES) } : {}),
|
||||
}));
|
||||
if (r() < 0.4) {
|
||||
p.ceilings!.push({ ...p.ceilings![0], id: "CX", floorId: "og", outline: [{ x: -1, y: -1 }, { x: 3, y: -1 }, { x: 3, y: 2 }, { x: -1, y: 2 }] });
|
||||
}
|
||||
// Dächer
|
||||
p.roofs = (p.roofs ?? []).map((rf) => ({
|
||||
...rf,
|
||||
shape: pick(r, ["sattel", "walm", "pult", "flach", "mansarde", "zelt", "sattel"] as const),
|
||||
pitchDeg: round(10 + r() * 40),
|
||||
overhang: round(r() * 0.8),
|
||||
ridgeAxis: pick(r, ["x", "y"] as const),
|
||||
...(r() < 0.5 ? { roofTypeId: "roof-warm" } : {}),
|
||||
...(r() < 0.2 ? { color: pick(r, COLORS) } : {}),
|
||||
...(r() < 0.3 ? { thickness: round(r() * 0.4) } : {}),
|
||||
}));
|
||||
if (r() < 0.3) p.roofs!.push({ ...p.roofs![0], id: "RX", outline: [{ x: 5, y: 0 }, { x: 8, y: 0 }, { x: 8, y: 3 }, { x: 5, y: 3 }], shape: "pult", roofTypeId: undefined });
|
||||
// Treppen
|
||||
p.stairs = (p.stairs ?? []).map((st) => ({
|
||||
...st,
|
||||
typeId: pick(r, ["stair-standard", "stair-massiv", "stair-wange-holz", "stair-aufgesattelt", undefined]),
|
||||
shape: pick(r, ["straight", "straight", "L", "spiral"] as const),
|
||||
...(r() < 0.3 ? { start: { x: jit(st.start.x, 2), y: jit(st.start.y, 2) } } : {}),
|
||||
}));
|
||||
// Abzugskörper und freie Körper
|
||||
const solids: ExtrudedSolid[] = [];
|
||||
for (let k = 0; k < Math.floor(r() * 4); k++) {
|
||||
const cx = jit(2.5, 6), cy = jit(2, 5), w = 0.3 + r() * 1.5, d = 0.3 + r() * 1.5;
|
||||
solids.push({
|
||||
id: `X${k}`, type: "extrudedSolid", levelId: r() < 0.7 ? "eg" : "og",
|
||||
points: [{ x: cx, y: cy }, { x: round(cx + w), y: cy }, { x: round(cx + w), y: round(cy + d) }, { x: cx, y: round(cy + d) }],
|
||||
height: round(0.3 + r() * 2.5), baseOffset: round(r() * 1.5),
|
||||
...(r() < 0.7 ? { operation: "subtract" } : {}),
|
||||
} as ExtrudedSolid);
|
||||
}
|
||||
p.extrudedSolids = solids;
|
||||
if (r() < 0.3) p.context = [terrain(r)];
|
||||
return p;
|
||||
}
|
||||
|
||||
/** Schnitt-/Ansichtsebenen quer durch das Projekt (verschiedene Lagen, Richtungen, Tiefen). */
|
||||
export function sectionLevels(p: Project, seed: number, count: number): DrawingLevel[] {
|
||||
const r = rng(seed * 7 + 1);
|
||||
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
||||
for (const w of p.walls) for (const q of [w.start, w.end]) {
|
||||
minX = Math.min(minX, q.x); maxX = Math.max(maxX, q.x); minY = Math.min(minY, q.y); maxY = Math.max(maxY, q.y);
|
||||
}
|
||||
if (!isFinite(minX)) { minX = 0; minY = 0; maxX = 5; maxY = 4; }
|
||||
const out: DrawingLevel[] = [];
|
||||
for (let k = 0; k < count; k++) {
|
||||
const kind = k % 2 === 0 ? "section" : "elevation";
|
||||
const mode = Math.floor(r() * 3);
|
||||
let a, b;
|
||||
if (mode === 0) {
|
||||
const y = round(minY - 1 + r() * (maxY - minY + 2));
|
||||
a = { x: minX - 1, y }; b = { x: maxX + 1, y };
|
||||
} else if (mode === 1) {
|
||||
const x = round(minX - 1 + r() * (maxX - minX + 2));
|
||||
a = { x, y: minY - 1 }; b = { x, y: maxY + 1 };
|
||||
} else {
|
||||
a = { x: round(minX - 1 + r() * 2), y: round(minY - 1 + r() * (maxY - minY)) };
|
||||
b = { x: round(maxX + 1 - r() * 2), y: round(minY + r() * (maxY - minY + 1)) };
|
||||
}
|
||||
if (r() < 0.5) [a, b] = [b, a];
|
||||
out.push({
|
||||
id: `lvl${k}`, name: `L${k}`, kind, visible: true, locked: false,
|
||||
linePoints: [a, b],
|
||||
directionSign: r() < 0.5 ? 1 : -1,
|
||||
...(r() < 0.25 ? { depth: round(r() * 6) } : {}),
|
||||
...(r() < 0.4 ? { shadows: true } : {}),
|
||||
...(r() < 0.3 ? { hiddenLines: true } : {}),
|
||||
} as DrawingLevel);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Grosses Projekt mit Schnitt-/Ansichtslinien quer über alle Kacheln. */
|
||||
export function bigSectionProject(n: number): Project {
|
||||
const p = bigSampleProject(n);
|
||||
const span = n * 8;
|
||||
const levels: DrawingLevel[] = [
|
||||
{ id: "bs1", name: "S1", kind: "section", visible: true, locked: false, linePoints: [{ x: -2, y: 2 }, { x: span, y: 2 }], directionSign: 1 } as DrawingLevel,
|
||||
{ id: "bs2", name: "S2", kind: "section", visible: true, locked: false, linePoints: [{ x: 3.5, y: -2 }, { x: 3.5, y: span }], directionSign: -1, hiddenLines: true } as DrawingLevel,
|
||||
{ id: "be1", name: "E1", kind: "elevation", visible: true, locked: false, linePoints: [{ x: -2, y: -3 }, { x: span, y: -3 }], directionSign: 1, shadows: true } as DrawingLevel,
|
||||
{ id: "be2", name: "E2", kind: "elevation", visible: true, locked: false, linePoints: [{ x: -3, y: span }, { x: -3, y: -2 }], directionSign: 1 } as DrawingLevel,
|
||||
];
|
||||
return { ...p, drawingLevels: [...p.drawingLevels, ...levels] };
|
||||
}
|
||||
|
||||
/** Kachelt ein Projekt n × n (Wände, Öffnungen, Decken, Dächer, Treppen, Körper), für grosse Zufallsfälle. */
|
||||
export function tileProject(s: Project, n: number, pitch = 9): Project {
|
||||
const sh = (p: { x: number; y: number }, dx: number, dy: number) => ({ x: p.x + dx, y: p.y + dy });
|
||||
const out: Project = { ...s, walls: [], openings: [], ceilings: [], roofs: [], stairs: [], extrudedSolids: [] };
|
||||
for (let i = 0; i < n; i++) {
|
||||
for (let j = 0; j < n; j++) {
|
||||
const [dx, dy, sfx] = [i * pitch, j * pitch, `_${i}_${j}`];
|
||||
for (const w of s.walls) out.walls.push({ ...w, id: w.id + sfx, start: sh(w.start, dx, dy), end: sh(w.end, dx, dy) });
|
||||
for (const o of s.openings ?? []) out.openings!.push({ ...o, id: o.id + sfx, hostWallId: o.hostWallId + sfx });
|
||||
for (const c of s.ceilings ?? []) out.ceilings!.push({ ...c, id: c.id + sfx, outline: c.outline.map((p) => sh(p, dx, dy)) });
|
||||
for (const r of s.roofs ?? []) out.roofs!.push({ ...r, id: r.id + sfx, outline: r.outline.map((p) => sh(p, dx, dy)) });
|
||||
for (const st of s.stairs ?? []) out.stairs!.push({ ...st, id: st.id + sfx, start: sh(st.start, dx, dy) });
|
||||
for (const x of s.extrudedSolids ?? []) out.extrudedSolids!.push({ ...x, id: x.id + sfx, points: x.points.map((p) => sh(p, dx, dy)) });
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
// VORÜBERGEHEND ([K3c]): Gleichheit alte TS-Fassung gegen den Kern (Schnitt/Ansicht). Wird mit
|
||||
// der TS-Fassung gelöscht.
|
||||
import { beforeAll, describe, expect, it } from "vitest";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { setWasmBytesProvider } from "../engine/wasmSource";
|
||||
import { computeSection as oldCompute } from "./toSection";
|
||||
import { generateSectionPlan as oldGen } from "./generatePlan";
|
||||
import { sectionOpeningPrimitives } from "./sectionOpenings";
|
||||
import { computeSection as newCompute, generateSectionPlan as newGen, generateElevationPlan as newElev } from "./sectionCore";
|
||||
import { generateElevationPlan as oldElev, type ElevationOptions } from "./toElevation";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { flattenCategories } from "../model/types";
|
||||
import type { DrawingLevel, Project } from "../model/types";
|
||||
import type { CategoryDisplayResolver, Plan, Primitive } from "./generatePlan";
|
||||
import { planToRenderScene } from "./toRenderScene";
|
||||
import { planToSvgString } from "../export/planToSvgString";
|
||||
import { bigSectionProject, randomSectionProject, rng, sectionLevels, tileProject } from "./sectionParity.testing";
|
||||
|
||||
beforeAll(() => {
|
||||
setWasmBytesProvider(async (name) =>
|
||||
readFileSync(join(process.cwd(), "src", "engine", name === "trucksolid" ? "pkgTruck/trucksolid_bg.wasm" : "pkg3d/render3d_bg.wasm")),
|
||||
);
|
||||
});
|
||||
|
||||
/** Erster Unterschied (Pfad) zweier Werte; Zahlen per Object.is, fehlend = undefined. */
|
||||
function diff(a: unknown, b: unknown, path = ""): string | null {
|
||||
if (typeof a === "number" && typeof b === "number") return Object.is(a, b) ? null : `${path}: ${a} != ${b}`;
|
||||
if (a === b) return null;
|
||||
if (Array.isArray(a) && Array.isArray(b)) {
|
||||
if (a.length !== b.length) return `${path}: Länge ${a.length} != ${b.length}`;
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
const d = diff(a[i], b[i], `${path}[${i}]`);
|
||||
if (d) return d;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (a && b && typeof a === "object" && typeof b === "object") {
|
||||
const ra = a as Record<string, unknown>;
|
||||
const rb = b as Record<string, unknown>;
|
||||
for (const k of new Set([...Object.keys(ra), ...Object.keys(rb)])) {
|
||||
const d = diff(ra[k], rb[k], `${path}.${k}`);
|
||||
if (d) return d;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return `${path}: ${JSON.stringify(a)} != ${JSON.stringify(b)}`;
|
||||
}
|
||||
|
||||
const FALLBACK_HATCH = { pattern: "diagonal", scale: 1, angle: 45, color: "#0f0f0f", lineWeight: 0.13, dash: null };
|
||||
|
||||
/** Alte Ausgabe: render3d-interne Schraffur (Muster als Zahl), die als Plan-Schraffur durchsickerte, wird
|
||||
* zur vorgesehenen Rückfall-Schraffur (Fehler der alten Fassung, s. TODO [K3c]). */
|
||||
function fixOld(p: Primitive, mono: boolean): Primitive {
|
||||
if (p.kind !== "polygon" || typeof (p.hatch as { pattern: unknown }).pattern !== "number") return p;
|
||||
stats.foreignHatch++;
|
||||
return { ...p, hatch: mono ? { ...FALLBACK_HATCH, color: "#1f242c" } : FALLBACK_HATCH, fill: mono ? "#f0f0f0" : p.fill } as Primitive;
|
||||
}
|
||||
|
||||
interface Opts { mono: boolean; hiddenLines?: boolean; visibleCodes?: Set<string>; categoryDisplay?: CategoryDisplayResolver; openings: boolean }
|
||||
|
||||
function optionSets(project: Project, seed: number): Opts[] {
|
||||
const r = rng(seed * 13 + 5);
|
||||
const codes = [...flattenCategories(project.layers).map((c) => c.code), "22", "99"];
|
||||
const vis = new Set(codes.filter(() => r() < 0.75));
|
||||
const grey = new Set(codes.filter(() => r() < 0.3));
|
||||
const hide = new Set(codes.filter(() => r() < 0.15));
|
||||
const disp: CategoryDisplayResolver = (c) => ({ render: !hide.has(c), greyed: grey.has(c), locked: false });
|
||||
return [
|
||||
{ mono: false, openings: false, visibleCodes: new Set(codes) },
|
||||
{ mono: true, openings: true, hiddenLines: true, visibleCodes: vis, categoryDisplay: disp },
|
||||
{ mono: false, openings: true, categoryDisplay: disp },
|
||||
];
|
||||
}
|
||||
|
||||
async function oldPlan(project: Project, level: DrawingLevel, o: Opts): Promise<{ prims: Primitive[]; raw: Primitive[]; bounds: Plan["bounds"] } | null> {
|
||||
const out = await oldCompute(project, level);
|
||||
if (!out) return null;
|
||||
const plan = oldGen(out, o.mono, { hiddenLines: o.hiddenLines, visibleCodes: o.visibleCodes, categoryDisplay: o.categoryDisplay });
|
||||
const ops = o.openings ? sectionOpeningPrimitives(project, level, o.visibleCodes, o.categoryDisplay) : [];
|
||||
return { prims: [...plan.primitives.map((p) => fixOld(p, o.mono)), ...ops], raw: [...plan.primitives, ...ops], bounds: plan.bounds };
|
||||
}
|
||||
|
||||
async function newPlan(project: Project, level: DrawingLevel, o: Opts): Promise<{ prims: Primitive[]; bounds: Plan["bounds"]; plan: Plan } | null> {
|
||||
// Ein vorbereiteter Schnitt je Ebene für alle Optionssätze: prüft auch den Kern-Cache (Umschalten).
|
||||
let out = prepared.get(level);
|
||||
if (out === undefined || out?.project !== project) {
|
||||
out = await newCompute(project, level);
|
||||
prepared.set(level, out);
|
||||
}
|
||||
if (!out) return null;
|
||||
const plan = newGen(out, o.mono, o);
|
||||
return { prims: plan.primitives, bounds: plan.bounds, plan };
|
||||
}
|
||||
|
||||
const prepared = new WeakMap<DrawingLevel, Awaited<ReturnType<typeof newCompute>>>();
|
||||
|
||||
/** Szene (render2d) und SVG wie die Verbraucher: alt als gewöhnlicher Plan, neu aus dem Puffer. */
|
||||
function outputsDiffer(a: { prims: Primitive[]; raw: Primitive[]; bounds: Plan["bounds"] }, b: Plan): string | null {
|
||||
const sa = JSON.stringify(planToRenderScene({ primitives: a.prims, bounds: a.bounds }, 100));
|
||||
const sb = JSON.stringify(planToRenderScene(b, 100));
|
||||
if (sa !== sb) return "Szene verschieden";
|
||||
const va = planToSvgString({ primitives: a.raw, bounds: a.bounds }, { scaleDenominator: 100 });
|
||||
const vb = planToSvgString(b, { scaleDenominator: 100 });
|
||||
return va === vb ? null : "SVG verschieden";
|
||||
}
|
||||
|
||||
async function settle<T>(f: () => Promise<T>): Promise<{ ok: T } | { err: string }> {
|
||||
try {
|
||||
return { ok: await f() };
|
||||
} catch (e) {
|
||||
return { err: String(e) };
|
||||
}
|
||||
}
|
||||
|
||||
/** Vergleicht alt/neu für eine Ebene; liefert Fehlertext oder null. */
|
||||
async function compareSection(project: Project, level: DrawingLevel, o: Opts): Promise<string | null> {
|
||||
const a = await settle(() => oldPlan(project, level, o));
|
||||
const b = await settle(() => newPlan(project, level, o));
|
||||
if ("err" in a || "err" in b) {
|
||||
if ("err" in a && "err" in b) {
|
||||
stats.errors++;
|
||||
return null;
|
||||
}
|
||||
return `Fehler nur auf einer Seite: alt ${"err" in a ? a.err : "ok"}, neu ${"err" in b ? b.err : "ok"}`;
|
||||
}
|
||||
stats.prims += a.ok?.prims.length ?? 0;
|
||||
if (!a.ok || !b.ok) return a.ok === b.ok ? null : "null nur auf einer Seite";
|
||||
return diff({ prims: a.ok.prims, bounds: a.ok.bounds }, { prims: b.ok.prims, bounds: b.ok.bounds }) ?? (FULL ? outputsDiffer(a.ok, b.ok.plan) : null);
|
||||
}
|
||||
|
||||
/** Szene und SVG mitvergleichen (langsamer). */
|
||||
const FULL = process.env.PARITY_FULL !== "0";
|
||||
|
||||
let stats = { levels: 0, prims: 0, errors: 0, foreignHatch: 0, elevations: 0, elevPrims: 0, elevErrors: 0 };
|
||||
|
||||
function elevOptions(project: Project, seed: number): ElevationOptions[] {
|
||||
const [, b, c] = optionSets(project, seed);
|
||||
return [{}, { mono: true, visibleCodes: b.visibleCodes, categoryDisplay: b.categoryDisplay }, { shadows: true, categoryDisplay: c.categoryDisplay }, { shadows: false, visibleCodes: b.visibleCodes }];
|
||||
}
|
||||
|
||||
function compareElevation(project: Project, level: DrawingLevel, o: ElevationOptions): string | null {
|
||||
const run = (f: typeof oldElev) => {
|
||||
try {
|
||||
const pl = f(project, level, o);
|
||||
return { ok: pl ? { prims: pl.primitives, bounds: pl.bounds, plan: pl } : null };
|
||||
} catch (e) {
|
||||
return { err: String(e) };
|
||||
}
|
||||
};
|
||||
const a = run(oldElev);
|
||||
const b = run(newElev);
|
||||
if ("err" in a || "err" in b) {
|
||||
if ("err" in a && "err" in b) {
|
||||
stats.elevErrors++;
|
||||
return null;
|
||||
}
|
||||
return `Fehler nur auf einer Seite: alt ${"err" in a ? a.err : "ok"}, neu ${"err" in b ? b.err : "ok"}`;
|
||||
}
|
||||
stats.elevPrims += a.ok?.prims.length ?? 0;
|
||||
if (!a.ok || !b.ok) return a.ok === b.ok ? null : "null nur auf einer Seite";
|
||||
return diff({ prims: a.ok.prims, bounds: a.ok.bounds }, { prims: b.ok.prims, bounds: b.ok.bounds }) ??
|
||||
(FULL ? outputsDiffer({ prims: a.ok.prims, raw: a.ok.prims, bounds: a.ok.bounds }, b.ok.plan) : null);
|
||||
}
|
||||
|
||||
async function check(project: Project, levels: DrawingLevel[], label: string, seed = 1) {
|
||||
const sets = optionSets(project, seed);
|
||||
for (const level of levels.filter((l) => l.kind === "section")) {
|
||||
for (const [k, o] of sets.entries()) {
|
||||
const d = await compareSection(project, level, o);
|
||||
expect(d, `${label} ${level.id} Optionen ${k}`).toBeNull();
|
||||
stats.levels++;
|
||||
}
|
||||
}
|
||||
for (const level of levels.filter((l) => l.kind === "elevation")) {
|
||||
for (const [k, o] of elevOptions(project, seed).entries()) {
|
||||
const d = compareElevation(project, level, o);
|
||||
expect(d, `${label} ${level.id} Ansicht-Optionen ${k}`).toBeNull();
|
||||
stats.elevations++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe("Schnitt und Ansicht: Kern gleich alter TS-Fassung", () => {
|
||||
it("Beispielprojekt, viele Schnittlinien", async () => {
|
||||
const own = sampleProject.drawingLevels;
|
||||
await check(sampleProject, [...own, ...sectionLevels(sampleProject, 1, 40)], "Beispiel");
|
||||
}, 600_000);
|
||||
|
||||
it("Zufallsprojekte", async () => {
|
||||
const n = Number(process.env.PARITY_N ?? 60);
|
||||
for (let seed = 1; seed <= n; seed++) {
|
||||
const p = randomSectionProject(seed);
|
||||
await check(p, sectionLevels(p, seed, 12), `Saat ${seed}`, seed);
|
||||
}
|
||||
console.log("Gleichheit:", stats);
|
||||
}, 3_600_000);
|
||||
|
||||
it("Gekachelte Zufallsprojekte (4×4)", async () => {
|
||||
for (let seed = 101; seed <= 100 + Number(process.env.PARITY_TILES ?? 6); seed++) {
|
||||
const p = tileProject(randomSectionProject(seed), 4);
|
||||
await check(p, sectionLevels(p, seed, 6), `Kacheln ${seed}`, seed);
|
||||
}
|
||||
}, 3_600_000);
|
||||
|
||||
it("Grosses Projekt (6×6)", async () => {
|
||||
const p = bigSectionProject(6);
|
||||
await check(p, p.drawingLevels, "big6");
|
||||
console.log("Gleichheit (gesamt):", stats);
|
||||
}, 600_000);
|
||||
});
|
||||
@@ -1,87 +1,16 @@
|
||||
/**
|
||||
* Unit-Tests für den Ansichts-Generator (toElevation.ts): Projektion einer
|
||||
* bekannten Fläche auf (u, v)+Tiefe, Rückseiten-Culling, Painter-Reihenfolge
|
||||
* (nähere Fassade NACH der ferneren) und Schlagschatten (nur mit shadows=true).
|
||||
* Alles rein geometrisch auf synthetischen RWall/RSlab-Fixtures bzw. einem
|
||||
* Minimalprojekt — KEIN WASM.
|
||||
* Tests für den Ansichts-Generator (toElevation.ts → Kern `plan/elevation.rs`): Painter-Reihenfolge
|
||||
* (nähere Fassade NACH der ferneren), Schlagschatten (nur mit shadows=true), Sichtbarkeit,
|
||||
* Durchsicht-Clipping, Öffnungen und Dächer — auf Minimalprojekten. Projektion, Culling und
|
||||
* Schatten-Geometrie prüft der Kern selbst (`plan_elevation.rs`).
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import type { Project, Wall } from "../model/types";
|
||||
import type { RModel3d, RSlab, RWall } from "./toWalls3d";
|
||||
import type { SectionPlaneSpec } from "./toSection";
|
||||
import type { CategoryDisplayResolver } from "./generatePlan";
|
||||
import {
|
||||
buildShadows,
|
||||
collectElevationFaces,
|
||||
elevationFrame,
|
||||
generateElevationPlan,
|
||||
} from "./toElevation";
|
||||
|
||||
// Betrachter im Süden (world z = −2), Blick nach +Z (in die Szene). Damit liegt
|
||||
// eine Wand bei z ≈ 0 HINTER der Ebene (depth > 0) und ihre Süd-Langseite zeigt
|
||||
// zum Betrachter (front-facing).
|
||||
const PLANE_SOUTH: SectionPlaneSpec = { point: [-1, 0, -2], normal: [0, 0, 1] };
|
||||
|
||||
function wall(over: Partial<RWall> = {}): RWall {
|
||||
return {
|
||||
start: [0, 0],
|
||||
end: [4, 0],
|
||||
thickness: 0.2,
|
||||
height: 3,
|
||||
baseElevation: 0,
|
||||
color: [0.8, 0.8, 0.8],
|
||||
layers: [],
|
||||
wallId: "W",
|
||||
...over,
|
||||
};
|
||||
}
|
||||
|
||||
describe("toElevation — Projektion + Culling", () => {
|
||||
it("Süd-Langseite einer Wand: erwartetes (u, v)-Rechteck + Tiefe, Rückseite gecullt", () => {
|
||||
const frame = elevationFrame(PLANE_SOUTH);
|
||||
const model: RModel3d = { walls: [wall()], slabs: [], meshes: [], roofLayers: [] };
|
||||
const visible = collectElevationFaces(model, frame);
|
||||
// Genau EINE sichtbare Fläche (die Süd-Langseite); alle anderen sind
|
||||
// Rückseiten oder streifend (Deckel/Boden/Stirnkappen).
|
||||
expect(visible.length).toBe(1);
|
||||
const face = visible[0];
|
||||
expect(face.wallId).toBe("W");
|
||||
const us = face.pts.map((p) => p[0]);
|
||||
const vs = face.pts.map((p) => p[1]);
|
||||
// U (entspiegelt, Blick +z ⇒ rechts = +x) = [1, 0, 0], P.x = −1.
|
||||
expect(Math.min(...us)).toBeCloseTo(1, 6); // x=0 → u=1
|
||||
expect(Math.max(...us)).toBeCloseTo(5, 6); // x=4 → u=5
|
||||
expect(Math.min(...vs)).toBeCloseTo(0, 6);
|
||||
expect(Math.max(...vs)).toBeCloseTo(3, 6);
|
||||
expect(face.depth).toBeCloseTo(1.9, 6); // z ≈ −0.1 − (−2)
|
||||
});
|
||||
|
||||
it("Rückseiten-Culling: eine Wand hinter dem Betrachter erscheint nicht", () => {
|
||||
const frame = elevationFrame(PLANE_SOUTH);
|
||||
const model: RModel3d = { walls: [wall({ start: [0, -5], end: [4, -5] })], slabs: [], meshes: [], roofLayers: [] };
|
||||
expect(collectElevationFaces(model, frame)).toEqual([]);
|
||||
});
|
||||
});
|
||||
import { generateElevationPlan } from "./toElevation";
|
||||
|
||||
describe("toElevation — Painter-Reihenfolge", () => {
|
||||
it("nähere Fassade wird NACH der ferneren emittiert", () => {
|
||||
const frame = elevationFrame(PLANE_SOUTH);
|
||||
const model: RModel3d = {
|
||||
walls: [
|
||||
wall({ wallId: "NEAR", start: [0, 0], end: [4, 0] }), // z ≈ 0 → näher
|
||||
wall({ wallId: "FAR", start: [0, 3], end: [4, 3] }), // z ≈ 3 → ferner
|
||||
],
|
||||
slabs: [],
|
||||
meshes: [],
|
||||
roofLayers: [],
|
||||
};
|
||||
const faces = collectElevationFaces(model, frame);
|
||||
const near = faces.find((f) => f.wallId === "NEAR")!;
|
||||
const far = faces.find((f) => f.wallId === "FAR")!;
|
||||
expect(near.depth).toBeLessThan(far.depth);
|
||||
});
|
||||
|
||||
it("im Plan: nähere Wand-Fläche hat einen höheren Primitiv-Index", () => {
|
||||
const project = elevationProject({ overhang: false });
|
||||
const plan = generateElevationPlan(project, project.drawingLevels[1])!;
|
||||
@@ -99,61 +28,6 @@ describe("toElevation — Painter-Reihenfolge", () => {
|
||||
});
|
||||
|
||||
describe("toElevation — Schlagschatten", () => {
|
||||
it("buildShadows: Überstand vor einer Fassade wirft ein Schatten-Polygon", () => {
|
||||
const frame = elevationFrame(PLANE_SOUTH);
|
||||
// Wandfläche (Fassade) hinter dem Überstand.
|
||||
const wallFaces = collectElevationFaces(
|
||||
{ walls: [wall()], slabs: [], meshes: [], roofLayers: [] },
|
||||
frame,
|
||||
);
|
||||
// Überstand-Slab, der VOR der Wand (näher, z < −0.1) liegt und sie u-seitig
|
||||
// überdeckt.
|
||||
const slab: RSlab = {
|
||||
outline: [
|
||||
[0, -0.6],
|
||||
[4, -0.6],
|
||||
[4, 0.2],
|
||||
[0, 0.2],
|
||||
],
|
||||
zBottom: 2.8,
|
||||
zTop: 3,
|
||||
color: [0.9, 0.9, 0.9],
|
||||
ceilingId: "R",
|
||||
};
|
||||
const slabFaces = collectElevationFaces(
|
||||
{ walls: [], slabs: [slab], meshes: [], roofLayers: [] },
|
||||
frame,
|
||||
);
|
||||
const shadows = buildShadows(wallFaces, slabFaces);
|
||||
expect(shadows.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("buildShadows: kein Überlapp → keine Schatten", () => {
|
||||
const frame = elevationFrame(PLANE_SOUTH);
|
||||
const wallFaces = collectElevationFaces(
|
||||
{ walls: [wall({ start: [0, 0], end: [4, 0] })], slabs: [], meshes: [], roofLayers: [] },
|
||||
frame,
|
||||
);
|
||||
// Slab weit seitlich versetzt (u außerhalb der Wand).
|
||||
const slab: RSlab = {
|
||||
outline: [
|
||||
[20, -0.6],
|
||||
[24, -0.6],
|
||||
[24, 0.2],
|
||||
[20, 0.2],
|
||||
],
|
||||
zBottom: 2.8,
|
||||
zTop: 3,
|
||||
color: [0.9, 0.9, 0.9],
|
||||
ceilingId: "R",
|
||||
};
|
||||
const slabFaces = collectElevationFaces(
|
||||
{ walls: [], slabs: [slab], meshes: [], roofLayers: [] },
|
||||
frame,
|
||||
);
|
||||
expect(buildShadows(wallFaces, slabFaces).length).toBe(0);
|
||||
});
|
||||
|
||||
it("im Plan: shadows=true erzeugt zusätzliche Schatten-Primitive, false exakt keine", () => {
|
||||
const project = elevationProject({ overhang: true });
|
||||
const level = project.drawingLevels[1];
|
||||
|
||||
+23
-1001
File diff suppressed because it is too large.
Load diff
@@ -1,215 +0,0 @@
|
||||
/**
|
||||
* Unit-Tests für die Schnitt-Boolean-Dominanz (toSection): an Wand-Decken-
|
||||
* Übergängen schneidet die STÄRKERE Schicht (höhere `Component.joinPriority`)
|
||||
* die schwächere per achsparalleler Rechteck-Subtraktion weg. Gleiche Priorität
|
||||
* koexistiert (kein Schnitt).
|
||||
*
|
||||
* Getestet über den Rust-Kern (`plan_section.rs`):
|
||||
* `subtractDominantBands` gegen den Nutzer-Testfall — ELEMENTÜBERGREIFEND:
|
||||
* ein Decken-Beton-Band (100) schneidet ein überlappendes Wand-Putz-Band
|
||||
* (10) weg; Beton bleibt voll; gleiche Priorität koexistiert.
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
subtractDominantBands,
|
||||
type Rect,
|
||||
type SectionCutPolygon,
|
||||
} from "./toSection";
|
||||
|
||||
/** Rechteck-Kurzform. */
|
||||
function r(uMin: number, uMax: number, vMin: number, vMax: number): Rect {
|
||||
return { uMin, uMax, vMin, vMax };
|
||||
}
|
||||
|
||||
/** Ein achsparalleles Cut-Band mit joinPriority. */
|
||||
function band(
|
||||
uMin: number,
|
||||
uMax: number,
|
||||
vMin: number,
|
||||
vMax: number,
|
||||
joinPriority: number,
|
||||
tag = "",
|
||||
): SectionCutPolygon {
|
||||
return {
|
||||
component: { kind: "wall", index: 0 },
|
||||
color: [0.5, 0.5, 0.5],
|
||||
pts: [
|
||||
[uMin, vMax],
|
||||
[uMax, vMax],
|
||||
[uMax, vMin],
|
||||
[uMin, vMin],
|
||||
],
|
||||
fill: tag || "#fff",
|
||||
joinPriority,
|
||||
};
|
||||
}
|
||||
|
||||
/** Ein achsparalleles Cut-Band mit joinPriority UND Komponenten-Identität (für die MERGE-Regel). */
|
||||
function cband(
|
||||
uMin: number,
|
||||
uMax: number,
|
||||
vMin: number,
|
||||
vMax: number,
|
||||
joinPriority: number,
|
||||
componentId: string,
|
||||
tag = "",
|
||||
): SectionCutPolygon {
|
||||
return { ...band(uMin, uMax, vMin, vMax, joinPriority, tag), componentId };
|
||||
}
|
||||
|
||||
/** Bounding-Box eines Bands als Rect. */
|
||||
function boxOf(b: SectionCutPolygon): Rect {
|
||||
const us = b.pts.map((p) => p[0]);
|
||||
const vs = b.pts.map((p) => p[1]);
|
||||
return { uMin: Math.min(...us), uMax: Math.max(...us), vMin: Math.min(...vs), vMax: Math.max(...vs) };
|
||||
}
|
||||
|
||||
/** Gesamtfläche einer Band-/Rect-Menge. */
|
||||
function area(items: Array<Rect | SectionCutPolygon>): number {
|
||||
return items.reduce((s, it) => {
|
||||
const b = "pts" in it ? boxOf(it) : it;
|
||||
return s + (b.uMax - b.uMin) * (b.vMax - b.vMin);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
describe("subtractDominantBands: stärkere Schicht schneidet schwächere", () => {
|
||||
it("Nutzer-Testfall ELEMENTÜBERGREIFEND: Decken-Beton(100) schneidet Wand-Putz(10) weg", () => {
|
||||
// Wand-Putz-Band (Element B): schwach, joinPriority 10, u∈[0,2], v∈[0,3].
|
||||
const putz = band(0, 2, 0, 3, 10, "putz");
|
||||
// Decken-Beton-Band (Element A): stark, joinPriority 100, überlappt den
|
||||
// oberen Teil des Putzes: u∈[0,2], v∈[2,4].
|
||||
const beton = band(0, 2, 2, 4, 100, "beton");
|
||||
|
||||
const out = subtractDominantBands([putz, beton]);
|
||||
// Beton bleibt voll erhalten (kein stärkeres Band).
|
||||
const betonOut = out.filter((b) => b.fill === "beton");
|
||||
expect(betonOut).toHaveLength(1);
|
||||
expect(boxOf(betonOut[0])).toEqual(boxOf(beton));
|
||||
|
||||
// Putz ist im Überlappungsbereich v∈[2,3] weggeschnitten → Rest nur v∈[0,2].
|
||||
const putzOut = out.filter((b) => b.fill === "putz");
|
||||
expect(putzOut).toHaveLength(1);
|
||||
expect(boxOf(putzOut[0])).toEqual(r(0, 2, 0, 2));
|
||||
// In der Überlappungsregion existiert KEIN Putz mehr.
|
||||
expect(putzOut[0].pts.every((p) => p[1] <= 2 + 1e-9)).toBe(true);
|
||||
});
|
||||
|
||||
it("gestaffelte Kette Beton100 > Backstein50 > Dämmung20 > Putz10", () => {
|
||||
// Alle vier Bänder überlappen in derselben Region u∈[0,1], gestapelt in v.
|
||||
// Jedes schwächere wird von JEDEM stärkeren geschnitten, wo sie überlappen.
|
||||
const beton = band(0, 1, 3, 4, 100, "beton");
|
||||
const backstein = band(0, 1, 2.5, 3.5, 50, "backstein"); // überlappt Beton in v∈[3,3.5]
|
||||
const daemmung = band(0, 1, 2, 3, 20, "daemmung"); // überlappt Backstein in v∈[2.5,3]
|
||||
const putz = band(0, 1, 0, 3.2, 10, "putz"); // überlappt alle darüber
|
||||
|
||||
const out = subtractDominantBands([beton, backstein, daemmung, putz]);
|
||||
|
||||
// Beton unangetastet.
|
||||
expect(area(out.filter((b) => b.fill === "beton"))).toBeCloseTo(1, 9);
|
||||
// Backstein: [2.5,3.5] minus Beton-Overlap [3,3.5] = [2.5,3] → Fläche 0.5.
|
||||
expect(area(out.filter((b) => b.fill === "backstein"))).toBeCloseTo(0.5, 9);
|
||||
// Dämmung: [2,3] minus Backstein-Overlap [2.5,3] = [2,2.5] → Fläche 0.5.
|
||||
// (Beton [3,4] überlappt Dämmung nicht.)
|
||||
expect(area(out.filter((b) => b.fill === "daemmung"))).toBeCloseTo(0.5, 9);
|
||||
// Putz: [0,3.2] minus Overlap mit ALLEN stärkeren.
|
||||
// Beton[3,4]→[3,3.2], Backstein[2.5,3.5]→[2.5,3.2], Dämmung[2,3]→[2,3] überdecken
|
||||
// zusammen v∈[2,3.2]; Rest = v∈[0,2] → Fläche 2.
|
||||
expect(area(out.filter((b) => b.fill === "putz"))).toBeCloseTo(2, 9);
|
||||
});
|
||||
|
||||
it("gleiche Priorität koexistiert: Betonwand + Betondecke schneiden sich NICHT", () => {
|
||||
const betonWand = band(0, 1, 0, 3, 100, "wand");
|
||||
const betonDecke = band(0, 1, 2, 4, 100, "decke"); // überlappt in v∈[2,3]
|
||||
const out = subtractDominantBands([betonWand, betonDecke]);
|
||||
// Beide voll erhalten (durchgehende Betonfläche).
|
||||
expect(area(out.filter((b) => b.fill === "wand"))).toBeCloseTo(3, 9);
|
||||
expect(area(out.filter((b) => b.fill === "decke"))).toBeCloseTo(2, 9);
|
||||
});
|
||||
|
||||
it("Band ohne joinPriority nimmt an keiner Subtraktion teil", () => {
|
||||
const stark = band(0, 2, 0, 2, 100, "stark");
|
||||
const ohne: SectionCutPolygon = { ...band(0, 2, 0, 2, 0, "ohne"), joinPriority: undefined };
|
||||
const out = subtractDominantBands([stark, ohne]);
|
||||
// Beide unverändert durchgereicht.
|
||||
expect(area(out.filter((b) => b.fill === "stark"))).toBeCloseTo(4, 9);
|
||||
expect(area(out.filter((b) => b.fill === "ohne"))).toBeCloseTo(4, 9);
|
||||
});
|
||||
|
||||
it("vollständig überdecktes schwächeres Band verschwindet", () => {
|
||||
const stark = band(0, 3, 0, 3, 100, "stark");
|
||||
const schwach = band(1, 2, 1, 2, 10, "schwach"); // ganz im starken enthalten
|
||||
const out = subtractDominantBands([stark, schwach]);
|
||||
expect(out.filter((b) => b.fill === "schwach")).toHaveLength(0);
|
||||
expect(area(out.filter((b) => b.fill === "stark"))).toBeCloseTo(9, 9);
|
||||
});
|
||||
});
|
||||
|
||||
describe("subtractDominantBands: MERGE-Regel (gleiche Komponente + Priorität)", () => {
|
||||
it("(a) zwei berührende Bänder gleicher Komponente+Priorität → EIN Körper, keine Innenkante", () => {
|
||||
// Beton-Wand (vertikal) trifft Beton-Decke (deren Schnittband hier u-deckungs-
|
||||
// gleich): gleiche componentId "beton", gleiche joinPriority, Überlappung v∈[2,3].
|
||||
const betonWand = cband(0, 1, 0, 3, 100, "beton", "wand");
|
||||
const betonDecke = cband(0, 1, 2, 4, 100, "beton", "decke"); // überlappt in v∈[2,3]
|
||||
const out = subtractDominantBands([betonWand, betonDecke]);
|
||||
// Zu EINEM Rechteck u∈[0,1], v∈[0,4] verschmolzen → keine innere Trennlinie.
|
||||
expect(out).toHaveLength(1);
|
||||
expect(boxOf(out[0])).toEqual(r(0, 1, 0, 4));
|
||||
expect(out[0].componentId).toBe("beton");
|
||||
expect(area(out)).toBeCloseTo(4, 9);
|
||||
});
|
||||
|
||||
it("(a2) exakt bündig aneinander (Kantenberührung, kein Überlapp) → verschmilzt", () => {
|
||||
// Zwei Backstein-Kerne, die sich nur an v=3 berühren: die Innenkante muss weg.
|
||||
const unten = cband(0, 1, 0, 3, 100, "backstein", "u");
|
||||
const oben = cband(0, 1, 3, 5, 100, "backstein", "o");
|
||||
const out = subtractDominantBands([unten, oben]);
|
||||
expect(out).toHaveLength(1);
|
||||
expect(boxOf(out[0])).toEqual(r(0, 1, 0, 5));
|
||||
});
|
||||
|
||||
it("(b) gleiche Priorität, VERSCHIEDENE Komponenten → bleiben getrennt (coexist)", () => {
|
||||
// Selbe Geometrie wie (a), aber unterschiedliche componentId → kein Merge.
|
||||
const wand = cband(0, 1, 0, 3, 100, "beton-wand", "wand");
|
||||
const decke = cband(0, 1, 2, 4, 100, "beton-decke", "decke");
|
||||
const out = subtractDominantBands([wand, decke]);
|
||||
expect(out).toHaveLength(2);
|
||||
expect(area(out.filter((b) => b.fill === "wand"))).toBeCloseTo(3, 9);
|
||||
expect(area(out.filter((b) => b.fill === "decke"))).toBeCloseTo(2, 9);
|
||||
});
|
||||
|
||||
it("(c) Bänder ohne componentId verschmelzen nie (Dominanz-Tests bit-identisch)", () => {
|
||||
// Wie der bestehende Koexistenz-Test, ohne componentId → weiterhin 2 Bänder.
|
||||
const a = band(0, 1, 0, 3, 100, "a");
|
||||
const b = band(0, 1, 2, 4, 100, "b");
|
||||
const out = subtractDominantBands([a, b]);
|
||||
expect(out).toHaveLength(2);
|
||||
expect(area(out.filter((x) => x.fill === "a"))).toBeCloseTo(3, 9);
|
||||
expect(area(out.filter((x) => x.fill === "b"))).toBeCloseTo(2, 9);
|
||||
});
|
||||
|
||||
it("Merge respektiert die Dominanz: stärkeres Fremd-Band schneidet erst, dann verschmelzen die Reste", () => {
|
||||
// Zwei gleichartige Putz-Bänder (Prio 10) u-deckungsgleich, dazwischen greift
|
||||
// KEIN stärkeres Band -> sie verschmelzen; ein separates starkes Beton-Band
|
||||
// (Prio 100) schneidet vorher ein Stück aus dem oberen Putz.
|
||||
const putzUnten = cband(0, 1, 0, 2, 10, "putz", "pu");
|
||||
const putzOben = cband(0, 1, 2, 4, 10, "putz", "po");
|
||||
const beton = cband(0, 1, 3, 5, 100, "beton", "beton"); // schneidet Putz-Oben v∈[3,4] weg
|
||||
const out = subtractDominantBands([putzUnten, putzOben, beton]);
|
||||
// Putz: unten[0,2] + oben-Rest[2,3] verschmelzen zu [0,3] → EIN Band, Fläche 3.
|
||||
const putz = out.filter((b) => b.componentId === "putz");
|
||||
expect(putz).toHaveLength(1);
|
||||
expect(boxOf(putz[0])).toEqual(r(0, 1, 0, 3));
|
||||
// Beton unangetastet.
|
||||
expect(area(out.filter((b) => b.componentId === "beton"))).toBeCloseTo(2, 9);
|
||||
});
|
||||
|
||||
it("Teil-/Eck-Überlappung gleicher Komponente verschmilzt NICHT (Union wäre L-förmig)", () => {
|
||||
// Nicht achs-deckungsgleich, nur Eck-Überlapp → Bounding-Box würde leere
|
||||
// Fläche abdecken, darum bleiben beide getrennt.
|
||||
const a = cband(0, 2, 0, 2, 100, "x", "a");
|
||||
const b = cband(1, 3, 1, 3, 100, "x", "b");
|
||||
const out = subtractDominantBands([a, b]);
|
||||
expect(out).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
@@ -1,71 +0,0 @@
|
||||
// Schnitt-Tiefe (DrawingLevel.depth): filterByDepth blendet Ansichtskanten aus,
|
||||
// deren Quell-Wand weiter als `depth` hinter der Schnittebene (Blickrichtung)
|
||||
// liegt. Owner-Distanz-Näherung (Wand-Mitte) — reiner TS-Datenpfad, ohne WASM.
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { filterByDepth } from "./toSection";
|
||||
import type { SectionOutput, SectionPlaneSpec } from "./toSection";
|
||||
import type { Project, Wall } from "../model/types";
|
||||
|
||||
// Zwei Wände auf verschiedenen Tiefen: W_near bei y=1, W_far bei y=8.
|
||||
function makeWall(id: string, y: number): Wall {
|
||||
return {
|
||||
id,
|
||||
type: "wall",
|
||||
floorId: "eg",
|
||||
categoryCode: "20",
|
||||
wallTypeId: "wt",
|
||||
start: { x: 0, y },
|
||||
end: { x: 4, y },
|
||||
height: 2.6,
|
||||
} as unknown as Wall;
|
||||
}
|
||||
|
||||
const project = {
|
||||
id: "p",
|
||||
name: "T",
|
||||
walls: [makeWall("W_near", 1), makeWall("W_far", 8)],
|
||||
ceilings: [],
|
||||
roofs: [],
|
||||
openings: [],
|
||||
components: [],
|
||||
wallTypes: [],
|
||||
drawingLevels: [{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false }],
|
||||
} as unknown as Project;
|
||||
|
||||
// Schnittebene bei y=0, Blickrichtung +y (in die Szene). wallSegmentOwners
|
||||
// nummeriert die Wände in project.walls-Reihenfolge: index 0 = W_near, 1 = W_far.
|
||||
const plane: SectionPlaneSpec = { point: [0, 0, 0], normal: [0, 0, 1] };
|
||||
|
||||
function edge(index: number) {
|
||||
return { component: { kind: "wall" as const, index }, a: [0, 0] as [number, number], b: [1, 1] as [number, number] };
|
||||
}
|
||||
|
||||
describe("filterByDepth", () => {
|
||||
it("behält nahe Kanten, verwirft Kanten hinter der Tiefengrenze", () => {
|
||||
const out: SectionOutput = {
|
||||
cutPolygons: [],
|
||||
visibleEdges: [edge(0), edge(1)],
|
||||
hiddenEdges: [edge(1)],
|
||||
};
|
||||
filterByDepth(out, project, plane, 4); // Tiefe 4 m: W_near (1) bleibt, W_far (8) fällt weg.
|
||||
expect(out.visibleEdges.map((e) => e.component.index)).toEqual([0]);
|
||||
expect(out.hiddenEdges).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("behält alles, wenn die Tiefe alle Bauteile umfasst", () => {
|
||||
const out: SectionOutput = {
|
||||
cutPolygons: [],
|
||||
visibleEdges: [edge(0), edge(1)],
|
||||
hiddenEdges: [],
|
||||
};
|
||||
filterByDepth(out, project, plane, 20);
|
||||
expect(out.visibleEdges).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("depth <= 0 ist ein No-op", () => {
|
||||
const out: SectionOutput = { cutPolygons: [], visibleEdges: [edge(0), edge(1)], hiddenEdges: [] };
|
||||
filterByDepth(out, project, plane, 0);
|
||||
expect(out.visibleEdges).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
@@ -1,73 +0,0 @@
|
||||
/**
|
||||
* `splitWallLayers`/`splitSlabLayers` — Attribut-Override (By-Layer/By-Object)
|
||||
* bei MEHRSCHICHTIGEM Wand-/Deckentyp im Schnitt. Vorher wurde `owner.foreground`/
|
||||
* `hatchId`/`hatchSource`/`background`/`backgroundSource` hier komplett ignoriert
|
||||
* (nur der einschichtige Pfad über resolveWallSectionStyle/resolveCeilingSectionStyle
|
||||
* respektierte den Override) — Regressionsschutz für den Nachzieh-Fix
|
||||
* (2D-Vervollständigung, Fund D).
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { getCeilingType, getWallType } from "../model/types";
|
||||
import { splitWallLayers, splitSlabLayers, type SectionCutPolygon } from "./toSection";
|
||||
|
||||
const cp: SectionCutPolygon = {
|
||||
component: { kind: "wall", index: 0 },
|
||||
color: [0.5, 0.5, 0.5],
|
||||
pts: [
|
||||
[0, 0],
|
||||
[1, 0],
|
||||
[1, 2],
|
||||
[0, 2],
|
||||
],
|
||||
};
|
||||
|
||||
describe("splitWallLayers — Attribut-Override greift auf ALLE Schichten", () => {
|
||||
const wall = sampleProject.walls.find((w) => w.id === "W1")!; // wallTypeId "aw", 4 Schichten
|
||||
const wt = getWallType(sampleProject, wall);
|
||||
|
||||
it("Testvoraussetzung: Wandtyp ist tatsächlich mehrschichtig", () => {
|
||||
expect(wt.layers.length).toBeGreaterThan(1);
|
||||
});
|
||||
|
||||
it("ohne Override: Füllung bleibt SIA-neutral, nicht die Override-Testfarbe", () => {
|
||||
const bands = splitWallLayers(cp, sampleProject, wt, wall, { x: 1, y: 0 });
|
||||
expect(bands.length).toBe(wt.layers.length);
|
||||
for (const b of bands) {
|
||||
expect(typeof b.fill).toBe("string");
|
||||
expect(b.fill).not.toBe("#ff00ff");
|
||||
}
|
||||
});
|
||||
|
||||
it("mit explizitem background-Override: JEDE Schicht bekommt die Override-Farbe", () => {
|
||||
const overridden = { ...wall, background: "#ff00ff" };
|
||||
const bands = splitWallLayers(cp, sampleProject, wt, overridden, { x: 1, y: 0 });
|
||||
expect(bands.length).toBe(wt.layers.length);
|
||||
for (const b of bands) expect(b.fill).toBe("#ff00ff");
|
||||
});
|
||||
});
|
||||
|
||||
describe("splitSlabLayers — Attribut-Override greift auf ALLE Schichten", () => {
|
||||
const ceiling = (sampleProject.ceilings ?? []).find((c) => c.id === "C1")!; // ceilingTypeId "dg-massiv"
|
||||
const wt = getCeilingType(sampleProject, ceiling);
|
||||
|
||||
it("Testvoraussetzung: Deckentyp ist tatsächlich mehrschichtig", () => {
|
||||
expect(wt.layers.length).toBeGreaterThan(1);
|
||||
});
|
||||
|
||||
it("mit explizitem background-Override: JEDE Schicht bekommt die Override-Farbe", () => {
|
||||
const overridden = { ...ceiling, background: "#00ffff" };
|
||||
const bands = splitSlabLayers(cp, sampleProject, wt, overridden);
|
||||
expect(bands.length).toBe(wt.layers.length);
|
||||
for (const b of bands) expect(b.fill).toBe("#00ffff");
|
||||
});
|
||||
|
||||
it("mit backgroundSource:'layer': category.color wird für ALLE Schichten übernommen", () => {
|
||||
const category = sampleProject.layers.find((l) => l.code === ceiling.categoryCode)!;
|
||||
const overridden = { ...ceiling, backgroundSource: "layer" as const };
|
||||
const bands = splitSlabLayers(cp, sampleProject, wt, overridden);
|
||||
expect(bands.length).toBe(wt.layers.length);
|
||||
for (const b of bands) expect(b.fill).toBe(category.color);
|
||||
});
|
||||
});
|
||||
@@ -1,42 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { SectionCutPolygon } from "./toSection";
|
||||
import { mergeMonolithCuts, unionRectOutlines } from "./toSection";
|
||||
|
||||
const band = (index: number, u0: number, u1: number, v0: number, v1: number): SectionCutPolygon => ({
|
||||
component: { kind: "slab", index },
|
||||
color: [1, 1, 1],
|
||||
pts: [[u0, v0], [u1, v0], [u1, v1], [u0, v1]],
|
||||
});
|
||||
|
||||
describe("unionRectOutlines", () => {
|
||||
it("drei überlappende Tritte → ein Sägezahn-Umriss", () => {
|
||||
const rings = unionRectOutlines([
|
||||
{ uMin: 0, uMax: 0.3, vMin: 0, vMax: 0.2 },
|
||||
{ uMin: 0.3, uMax: 0.6, vMin: 0.05, vMax: 0.4 },
|
||||
{ uMin: 0.6, uMax: 0.9, vMin: 0.25, vMax: 0.6 },
|
||||
]);
|
||||
expect(rings.length).toBe(1);
|
||||
// Fläche = Summe minus nichts (keine Überlappung in der Fläche, nur Kanten).
|
||||
const area = rings[0].reduce((a, p, i, r) => {
|
||||
const q = r[(i + 1) % r.length];
|
||||
return a + (p[0] * q[1] - q[0] * p[1]) / 2;
|
||||
}, 0);
|
||||
expect(area).toBeCloseTo(0.3 * 0.2 + 0.3 * 0.35 + 0.3 * 0.35, 9);
|
||||
});
|
||||
it("getrennte Flächen → getrennte Ringe", () => {
|
||||
expect(unionRectOutlines([
|
||||
{ uMin: 0, uMax: 1, vMin: 0, vMax: 1 },
|
||||
{ uMin: 2, uMax: 3, vMin: 0, vMax: 1 },
|
||||
]).length).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("mergeMonolithCuts", () => {
|
||||
it("vereint nur Bänder derselben Gruppe", () => {
|
||||
const cuts = [band(0, 0, 1, 2.4, 2.6), band(5, 0, 0.3, 0, 0.2), band(6, 0.3, 0.6, 0.05, 0.4)];
|
||||
const out = mergeMonolithCuts(cuts, (i) => (i >= 5 ? "ST1" : undefined));
|
||||
expect(out.length).toBe(2);
|
||||
expect(out[0]).toBe(cuts[0]);
|
||||
expect(out[1].pts.length).toBe(8); // zwei versetzte Rechtecke → 8 Ecken
|
||||
});
|
||||
});
|
||||
@@ -1,72 +1,20 @@
|
||||
/**
|
||||
* Unit-Tests für die Aussen/Innen-Orientierung der mehrschichtigen Wand-Bänder
|
||||
* im SCHNITT (toSection): die Schicht-Bänder müssen der GRUNDRISS-Konvention
|
||||
* folgen (layers[0] = Aussenseite auf der `−leftNormal`-Weltseite der Achse), so
|
||||
* dass die Dämmung aussen und der Backstein innen liegt und zwei gegenüber-
|
||||
* liegende Wände im Schnitt SPIEGELVERKEHRT erscheinen (nicht identisch).
|
||||
*
|
||||
* Getestet ohne WASM: die Orientierungs-Hilfsfunktionen (`sectionUAxisModel`,
|
||||
* `wallLayersReversedInU`) und `splitWallLayers` mit einem synthetischen
|
||||
* Schnittrechteck gegen den echten „aw"-Wandtyp des Sample-Projekts.
|
||||
* u-Achse der Schnittebene (`sectionUAxisModel`, `sectionPlaneFromLevel`): Blickrichtungs-RECHTS wie
|
||||
* im Kern-Schnitt. Die Aussen/Innen-Lage der Schicht-Bänder prüft der Kern
|
||||
* (`core/src/plan/section.rs`, `schichten_aussen_aussen_und_override_auf_allen_schichten`).
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
sectionPlaneFromLevel,
|
||||
sectionUAxisModel,
|
||||
wallLayersReversedInU,
|
||||
splitWallLayers,
|
||||
type SectionCutPolygon,
|
||||
} from "./toSection";
|
||||
import { sectionPlaneFromLevel, sectionUAxisModel } from "./toSection";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { getWallType } from "../model/types";
|
||||
import type { Wall } from "../model/types";
|
||||
|
||||
/** Wand aus dem Sample-Projekt per ID. */
|
||||
function wall(id: string): Wall {
|
||||
const w = sampleProject.walls.find((x) => x.id === id);
|
||||
if (!w) throw new Error(`Wand ${id} fehlt im Sample-Projekt`);
|
||||
return w;
|
||||
}
|
||||
|
||||
/** Achsparalleles Schnittrechteck (u, v): uMin..uMax × 0..2.6 m. */
|
||||
function rect(uMin: number, uMax: number): SectionCutPolygon {
|
||||
return {
|
||||
component: { kind: "wall", index: 0 },
|
||||
color: [0.5, 0.5, 0.5],
|
||||
pts: [
|
||||
[uMin, 2.6],
|
||||
[uMax, 2.6],
|
||||
[uMax, 0],
|
||||
[uMin, 0],
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
/** Bänder nach uLeft (linke Kante) aufsteigend, mit ihrer u-Breite. */
|
||||
function bandsByU(polys: SectionCutPolygon[]): Array<{ uLeft: number; width: number }> {
|
||||
return polys
|
||||
.map((p) => {
|
||||
const us = p.pts.map((pt) => pt[0]);
|
||||
// Auf mm runden — glättet die Float-Akkumulation für stabile Vergleiche.
|
||||
const width = Math.round((Math.max(...us) - Math.min(...us)) * 1e6) / 1e6;
|
||||
return { uLeft: Math.min(...us), width };
|
||||
})
|
||||
.sort((a, b) => a.uLeft - b.uLeft);
|
||||
}
|
||||
|
||||
// Schnitt A: horizontale Linie y=2 (x −1…6), quer durch W2 (x=5) und W4 (x=0).
|
||||
const planeA = sectionPlaneFromLevel(
|
||||
sampleProject.drawingLevels.find((l) => l.id === "schnitt-a")!,
|
||||
)!;
|
||||
|
||||
// „aw" = [render-ext(0.02) · insulation(0.16) · brick(0.15) · render-int(0.015)].
|
||||
const aw = getWallType(sampleProject, wall("W2"));
|
||||
const RENDER_EXT_T = 0.02; // Aussenputz — layers[0], die Aussenseite
|
||||
const RENDER_INT_T = 0.015; // Innenputz — letzte Schicht, die Innenseite
|
||||
|
||||
describe("Schnitt-u-Weltachse", () => {
|
||||
it("entspricht der WASM-Konvention u = cross(up, normal) → Grundriss (Nz, −Nx)", () => {
|
||||
it("entspricht der Kern-Konvention u = cross(up, normal) → Grundriss (Nz, −Nx)", () => {
|
||||
// Schnitt A: Ebenennormale world = (0,0,1) → uWorld model = (1, 0) —
|
||||
// Betrachter-RECHTS (Entspiegelung: Blick nach Norden ⇒ Osten rechts).
|
||||
expect(planeA.normal[0]).toBeCloseTo(0, 9);
|
||||
@@ -77,59 +25,3 @@ describe("Schnitt-u-Weltachse", () => {
|
||||
expect(u.y).toBeCloseTo(0, 9);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Wand-Aufbaurichtung vs. Schnitt-u-Achse", () => {
|
||||
const uWorld = sectionUAxisModel(planeA);
|
||||
|
||||
it("W2 (Aussenseite +x) gespiegelt, W4 (Aussenseite −x) nicht — entspiegelte u-Achse", () => {
|
||||
// Beide Wände gehören zum CCW-Umriss; die linke Normale zeigt nach innen.
|
||||
// Gegenüberliegende Wände ⇒ genau eine der beiden wird gespiegelt. (Mit
|
||||
// der Entspiegelung der u-Achse tauschen die Rollen gegenüber früher —
|
||||
// Geometrie UND Bandreihenfolge kippen zusammen, die Aussenseite bleibt
|
||||
// in der Zeichnung physisch aussen.)
|
||||
expect(wallLayersReversedInU(wall("W2"), uWorld)).toBe(true);
|
||||
expect(wallLayersReversedInU(wall("W4"), uWorld)).toBe(false);
|
||||
});
|
||||
|
||||
it("degenerierte Wand (Länge 0) bleibt unverändert (kein Spiegeln)", () => {
|
||||
const dot: Wall = { ...wall("W2"), end: { ...wall("W2").start } };
|
||||
expect(wallLayersReversedInU(dot, uWorld)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("splitWallLayers: Aussenputz auf der Aussenseite, Wände spiegelverkehrt", () => {
|
||||
const uWorld = sectionUAxisModel(planeA);
|
||||
const cp = rect(0, 0.345); // volle Wanddicke, Skala 1:1
|
||||
|
||||
it("W2: gespiegelt — Aussenputz an uMax, Innenputz an uMin", () => {
|
||||
const bands = bandsByU(splitWallLayers(cp, sampleProject, aw, wall("W2"), uWorld));
|
||||
expect(bands).toHaveLength(4);
|
||||
// Entspiegelte u-Achse: W2s Aussenseite (+x) liegt jetzt bei uMax.
|
||||
expect(bands[0].width).toBeCloseTo(RENDER_INT_T, 6);
|
||||
expect(bands[3].width).toBeCloseTo(RENDER_EXT_T, 6);
|
||||
});
|
||||
|
||||
it("W4: Aussenputz (layers[0]) an uMin, Innenputz an uMax", () => {
|
||||
const bands = bandsByU(splitWallLayers(cp, sampleProject, aw, wall("W4"), uWorld));
|
||||
expect(bands).toHaveLength(4);
|
||||
expect(bands[0].width).toBeCloseTo(RENDER_EXT_T, 6);
|
||||
expect(bands[3].width).toBeCloseTo(RENDER_INT_T, 6);
|
||||
});
|
||||
|
||||
it("propagiert sourceId (Quell-Element) auf ALLE Schicht-Bänder", () => {
|
||||
const cpWithId: SectionCutPolygon = { ...cp, sourceId: "W2" };
|
||||
const bands = splitWallLayers(cpWithId, sampleProject, aw, wall("W2"), uWorld);
|
||||
expect(bands.length).toBeGreaterThan(1);
|
||||
expect(bands.every((b) => b.sourceId === "W2")).toBe(true);
|
||||
});
|
||||
|
||||
it("W2 und W4 liegen spiegelverkehrt (nicht identisch)", () => {
|
||||
const b2 = bandsByU(splitWallLayers(cp, sampleProject, aw, wall("W2"), uWorld));
|
||||
const b4 = bandsByU(splitWallLayers(cp, sampleProject, aw, wall("W4"), uWorld));
|
||||
// Reihenfolge der Bandbreiten von uMin→uMax ist exakt umgekehrt.
|
||||
const w2 = b2.map((b) => b.width);
|
||||
const w4 = b4.map((b) => b.width);
|
||||
expect(w2).not.toEqual(w4);
|
||||
expect(w2).toEqual([...w4].reverse());
|
||||
});
|
||||
});
|
||||
@@ -1,169 +0,0 @@
|
||||
// Dach im Vertikalschnitt: appendRoofSections schneidet die Schnittebene
|
||||
// analytisch mit den Dachflächen (der Rust-Extraktor kennt nur Wände/Decken).
|
||||
// Geprüft werden u-Intervalle, Oberkanten-Verlauf (linear je Fläche), die
|
||||
// vertikale Dicke (lotrechte Dicke / cos(Neigung)) und die Schicht-Bänder.
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { appendRoofSections } from "./toSection";
|
||||
import type { SectionOutput, SectionPlaneSpec } from "./toSection";
|
||||
import type { Project, Roof } from "../model/types";
|
||||
|
||||
const RECT: Roof["outline"] = [
|
||||
{ x: -3, y: 0 },
|
||||
{ x: 3, y: 0 },
|
||||
{ x: 3, y: 4 },
|
||||
{ x: -3, y: 4 },
|
||||
];
|
||||
|
||||
function roof(over: Partial<Roof> = {}): Roof {
|
||||
return {
|
||||
id: "R1",
|
||||
type: "roof",
|
||||
floorId: "eg",
|
||||
categoryCode: "35",
|
||||
outline: RECT,
|
||||
shape: "sattel",
|
||||
pitchDeg: 30,
|
||||
overhang: 0,
|
||||
ridgeAxis: "x",
|
||||
baseElevation: 5, // explizit — kein Geschoss-Lookup nötig
|
||||
thickness: 0.3,
|
||||
...over,
|
||||
};
|
||||
}
|
||||
|
||||
function project(r: Roof, extra: Partial<Project> = {}): Project {
|
||||
return {
|
||||
id: "t",
|
||||
name: "T",
|
||||
lineStyles: [],
|
||||
hatches: [],
|
||||
components: [],
|
||||
wallTypes: [],
|
||||
drawingLevels: [],
|
||||
layers: [],
|
||||
walls: [],
|
||||
roofs: [r],
|
||||
...extra,
|
||||
} as unknown as Project;
|
||||
}
|
||||
|
||||
/** Schnittebene: Blick entlang +x (Osten), Spur x=0 — Betrachter-RECHTS =
|
||||
* Süden, u fällt also mit Modell-y (entspiegelte u-Achse). */
|
||||
const PLANE: SectionPlaneSpec = { point: [0, 0, 0], normal: [1, 0, 0] };
|
||||
|
||||
const emptyOutput = (): SectionOutput => ({ cutPolygons: [], visibleEdges: [], hiddenEdges: [] });
|
||||
|
||||
describe("appendRoofSections", () => {
|
||||
it("Flachdach: EIN Rechteck-Band, Oberkante = Traufhöhe, Höhe = Dicke", () => {
|
||||
const out = emptyOutput();
|
||||
appendRoofSections(out, project(roof({ shape: "flach", pitchDeg: 0 })), PLANE);
|
||||
expect(out.cutPolygons.length).toBe(1);
|
||||
const cp = out.cutPolygons[0];
|
||||
expect(cp.component).toEqual({ kind: "roof", index: 0 });
|
||||
// u-Intervall = Tiefe 0..4 → u −4..0 (u = −Modell-y); Oberkante 5,
|
||||
// Unterkante 5 − 0.3 (cosθ = 1).
|
||||
const us = cp.pts.map((p) => p[0]).sort((a, b) => a - b);
|
||||
expect(us[0]).toBeCloseTo(-4, 6);
|
||||
expect(us[3]).toBeCloseTo(0, 6);
|
||||
const vs = cp.pts.map((p) => p[1]).sort((a, b) => a - b);
|
||||
expect(vs[3]).toBeCloseTo(5, 6);
|
||||
expect(vs[0]).toBeCloseTo(5 - 0.3, 6);
|
||||
});
|
||||
|
||||
it("Satteldach quer zum First: zwei Bänder (steigend/fallend) mit Neigungs-Dicke", () => {
|
||||
const out = emptyOutput();
|
||||
appendRoofSections(out, project(roof()), PLANE);
|
||||
expect(out.cutPolygons.length).toBe(2);
|
||||
const tan30 = Math.tan((30 * Math.PI) / 180);
|
||||
const cos30 = Math.cos((30 * Math.PI) / 180);
|
||||
const ridgeZ = 5 + 2 * tan30; // First bei halber Tiefe (y=2 → u=−2)
|
||||
// Alle Oberkanten-Werte je Band: an u=0/−4 Traufe (5), an u=−2 First.
|
||||
const topAt = (cp: (typeof out.cutPolygons)[number], u: number): number =>
|
||||
Math.max(...cp.pts.filter((p) => Math.abs(p[0] - u) < 1e-6).map((p) => p[1]));
|
||||
const bands = out.cutPolygons;
|
||||
const front = bands.find((b) => b.pts.some((p) => Math.abs(p[0]) < 1e-6));
|
||||
const back = bands.find((b) => b.pts.some((p) => Math.abs(p[0] + 4) < 1e-6));
|
||||
expect(front).toBeDefined();
|
||||
expect(back).toBeDefined();
|
||||
expect(topAt(front!, 0)).toBeCloseTo(5, 5);
|
||||
expect(topAt(front!, -2)).toBeCloseTo(ridgeZ, 5);
|
||||
expect(topAt(back!, -4)).toBeCloseTo(5, 5);
|
||||
expect(topAt(back!, -2)).toBeCloseTo(ridgeZ, 5);
|
||||
// Vertikale Banddicke = lotrechte Dicke / cos(Neigung).
|
||||
const vAt = (cp: (typeof out.cutPolygons)[number], u: number): number[] =>
|
||||
cp.pts.filter((p) => Math.abs(p[0] - u) < 1e-6).map((p) => p[1]);
|
||||
const [hi, lo] = vAt(front!, 0).sort((a, b) => b - a);
|
||||
expect(hi - lo).toBeCloseTo(0.3 / cos30, 5);
|
||||
});
|
||||
|
||||
it("Schnittspur ausserhalb des Dachs: keine Bänder", () => {
|
||||
const out = emptyOutput();
|
||||
// Spur x=0 — Dach komplett rechts davon (x 10..16).
|
||||
const far = roof({
|
||||
outline: [
|
||||
{ x: 10, y: 0 },
|
||||
{ x: 16, y: 0 },
|
||||
{ x: 16, y: 4 },
|
||||
{ x: 10, y: 4 },
|
||||
],
|
||||
});
|
||||
appendRoofSections(out, project(far), PLANE);
|
||||
expect(out.cutPolygons.length).toBe(0);
|
||||
});
|
||||
|
||||
it("mehrschichtiges Dach (roofTypeId): je Schicht ein Band pro Fläche, aussen oben", () => {
|
||||
const p = project(roof({ shape: "flach", pitchDeg: 0, roofTypeId: "rt1" }), {
|
||||
hatches: [
|
||||
{ id: "h1", name: "H", pattern: "diagonal", scale: 1, angle: 45, color: "#111111" },
|
||||
],
|
||||
components: [
|
||||
{ id: "tile", name: "Ziegel", color: "#a03a2a", hatchId: "h1", joinPriority: 1 },
|
||||
{ id: "ins", name: "Dämmung", color: "#ffffff", hatchId: "h1", joinPriority: 2 },
|
||||
],
|
||||
roofTypes: [
|
||||
{
|
||||
id: "rt1",
|
||||
name: "Aufbau",
|
||||
layers: [
|
||||
{ componentId: "tile", thickness: 0.05 },
|
||||
{ componentId: "ins", thickness: 0.25 },
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
const out = emptyOutput();
|
||||
appendRoofSections(out, p, PLANE);
|
||||
expect(out.cutPolygons.length).toBe(2); // 1 Fläche × 2 Schichten
|
||||
const tops = out.cutPolygons.map((cp) => Math.max(...cp.pts.map((q) => q[1])));
|
||||
// Eindeckung oben (OK 5), Dämmung darunter (OK 5 − 0.05).
|
||||
expect(Math.max(...tops)).toBeCloseTo(5, 6);
|
||||
expect(Math.min(...tops)).toBeCloseTo(4.95, 6);
|
||||
// Schicht-Stile sind aufgelöst (Schraffur des Bauteils).
|
||||
expect(out.cutPolygons.every((cp) => cp.hatch?.pattern === "diagonal")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("appendRoofSections — Nähte deckungsgleicher Teilflächen", () => {
|
||||
it("L-Walmdach, Schnitt längs durch die Süd-Schräge: deckungsgleiche Teilflächen werden ein Band", () => {
|
||||
const L: Roof["outline"] = [
|
||||
{ x: 0, y: 0 }, { x: 11, y: 0 }, { x: 11, y: 4 }, { x: 8, y: 4 }, { x: 8, y: 6 }, { x: 0, y: 6 },
|
||||
];
|
||||
// Schnitt entlang x bei y=1: Blick +y (Norden), u = x. Süd-Schräge besteht aus zwei Teilflächen EINER Ebene.
|
||||
const plane: SectionPlaneSpec = { point: [0, 0, 1], normal: [0, 0, 1] };
|
||||
const out = emptyOutput();
|
||||
appendRoofSections(out, project(roof({ outline: L, shape: "walm" })), plane);
|
||||
// Walm-Ost, Süd-Schräge (zwei Teilflächen einer Ebene → EIN Band), Walm-West = 3 Bänder.
|
||||
const roofPolys = out.cutPolygons.filter((c) => c.component.kind === "roof");
|
||||
expect(roofPolys.length).toBe(3);
|
||||
});
|
||||
it("Schnitt genau auf der Höhenlinie (y=2): überlappende gleich hohe Bänder werden EIN Band", () => {
|
||||
const L: Roof["outline"] = [
|
||||
{ x: 0, y: 0 }, { x: 11, y: 0 }, { x: 11, y: 4 }, { x: 8, y: 4 }, { x: 8, y: 6 }, { x: 0, y: 6 },
|
||||
];
|
||||
const plane: SectionPlaneSpec = { point: [0, 0, 2], normal: [0, 0, 1] };
|
||||
const out = emptyOutput();
|
||||
appendRoofSections(out, project(roof({ outline: L, shape: "walm" })), plane);
|
||||
expect(out.cutPolygons.filter((c) => c.component.kind === "roof").length).toBe(3);
|
||||
});
|
||||
});
|
||||
@@ -1,106 +0,0 @@
|
||||
// Decken-Terminierung im 2D-Schnitt (applyWallTermination) — der Spiegel von
|
||||
// terminateOrSubtractSpans (3D): Wände mit sliceTermination "below" enden an
|
||||
// der Decken-Unterkante, "above" beginnen an der Oberkante; "both"/undefined
|
||||
// bleibt bei der reinen Prioritäts-Subtraktion (unverändert hier).
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { applyWallTermination } from "./toSection";
|
||||
import type { SectionCutPolygon } from "./toSection";
|
||||
import type { Wall } from "../model/types";
|
||||
|
||||
const rect = (
|
||||
uMin: number,
|
||||
uMax: number,
|
||||
vMin: number,
|
||||
vMax: number,
|
||||
): Array<[number, number]> => [
|
||||
[uMin, vMax],
|
||||
[uMax, vMax],
|
||||
[uMax, vMin],
|
||||
[uMin, vMin],
|
||||
];
|
||||
|
||||
const wallBand = (joinPriority: number | undefined, pts = rect(0, 0.3, 0, 2.6)): SectionCutPolygon => ({
|
||||
component: { kind: "wall", index: 0 },
|
||||
color: [0.8, 0.8, 0.8],
|
||||
pts,
|
||||
joinPriority,
|
||||
});
|
||||
|
||||
const slabBand = (joinPriority: number, vMin: number, vMax: number, uMin = -2, uMax = 2): SectionCutPolygon => ({
|
||||
component: { kind: "slab", index: 0 },
|
||||
color: [0.9, 0.9, 0.9],
|
||||
pts: rect(uMin, uMax, vMin, vMax),
|
||||
joinPriority,
|
||||
});
|
||||
|
||||
const wall = (sliceTermination?: Wall["sliceTermination"]): Wall =>
|
||||
({
|
||||
id: "W1",
|
||||
start: { x: 0, y: 0 },
|
||||
end: { x: 5, y: 0 },
|
||||
height: 2.6,
|
||||
wallTypeId: "wt",
|
||||
floorId: "eg",
|
||||
categoryCode: "21",
|
||||
sliceTermination,
|
||||
}) as Wall;
|
||||
|
||||
const bbox = (cp: SectionCutPolygon) => {
|
||||
const vs = cp.pts.map((p) => p[1]);
|
||||
return { vMin: Math.min(...vs), vMax: Math.max(...vs) };
|
||||
};
|
||||
|
||||
describe("applyWallTermination — 2D-Schnitt = 3D-Terminierung", () => {
|
||||
it("'below': Wand-Band endet an der Unterkante der dominanten Decke", () => {
|
||||
const bands = [wallBand(50), slabBand(100, 2.2, 2.5)];
|
||||
const out = applyWallTermination(bands, [wall("below")]);
|
||||
const wb = out.find((b) => b.component.kind === "wall")!;
|
||||
expect(bbox(wb).vMax).toBeCloseTo(2.2, 9);
|
||||
expect(bbox(wb).vMin).toBeCloseTo(0, 9);
|
||||
});
|
||||
|
||||
it("'above': Wand-Band beginnt an der Oberkante der dominanten Decke", () => {
|
||||
const bands = [wallBand(50), slabBand(100, 2.2, 2.5)];
|
||||
const out = applyWallTermination(bands, [wall("above")]);
|
||||
const wb = out.find((b) => b.component.kind === "wall")!;
|
||||
expect(bbox(wb).vMin).toBeCloseTo(2.5, 9);
|
||||
expect(bbox(wb).vMax).toBeCloseTo(2.6, 9);
|
||||
});
|
||||
|
||||
it("'both'/undefined: Band bleibt unverändert (Prioritäts-Subtraktion regelt)", () => {
|
||||
const bands = [wallBand(50), slabBand(100, 2.2, 2.5)];
|
||||
for (const term of ["both", undefined] as const) {
|
||||
const out = applyWallTermination(bands, [wall(term)]);
|
||||
const wb = out.find((b) => b.component.kind === "wall")!;
|
||||
expect(wb.pts).toEqual(rect(0, 0.3, 0, 2.6));
|
||||
}
|
||||
});
|
||||
|
||||
it("nur STRIKT dominante Decken terminieren (schwächere/gleiche nicht)", () => {
|
||||
for (const prio of [50, 10]) {
|
||||
const bands = [wallBand(50), slabBand(prio, 2.2, 2.5)];
|
||||
const out = applyWallTermination(bands, [wall("below")]);
|
||||
const wb = out.find((b) => b.component.kind === "wall")!;
|
||||
expect(bbox(wb).vMax).toBeCloseTo(2.6, 9);
|
||||
}
|
||||
});
|
||||
|
||||
it("ohne u-Überlapp keine Terminierung; Band unter der Decken-UK verschwindet nicht", () => {
|
||||
// Decke liegt in u komplett rechts neben der Wand.
|
||||
const far = [wallBand(50), slabBand(100, 2.2, 2.5, 5, 8)];
|
||||
const outFar = applyWallTermination(far, [wall("below")]);
|
||||
expect(bbox(outFar.find((b) => b.component.kind === "wall")!).vMax).toBeCloseTo(2.6, 9);
|
||||
|
||||
// Decke UNTER dem Wandfuss ⇒ 'below'-Clip entfernt das ganze Band.
|
||||
const under = [wallBand(50), slabBand(100, -0.5, -0.2)];
|
||||
const outUnder = applyWallTermination(under, [wall("below")]);
|
||||
expect(outUnder.some((b) => b.component.kind === "wall")).toBe(false);
|
||||
});
|
||||
|
||||
it("Bänder ohne joinPriority (unauflösbares Bauteil) bleiben unangetastet", () => {
|
||||
const bands = [wallBand(undefined), slabBand(100, 2.2, 2.5)];
|
||||
const out = applyWallTermination(bands, [wall("below")]);
|
||||
expect(out.find((b) => b.component.kind === "wall")!.pts).toEqual(rect(0, 0.3, 0, 2.6));
|
||||
});
|
||||
});
|
||||
+134
-1086
File diff suppressed because it is too large.
Load diff
@@ -1392,12 +1392,12 @@ describe("Per-Schicht-Decken-Dominanz Wand/Decke (3D-Entsprechung der Schnitt-Bo
|
||||
// render-int x=4.8350 (INNEN) -> überdeckt -> Decken-z-Schnitt
|
||||
// Die Decke schneidet ein Band also nur dort, wo ihre Outline die Footprint-
|
||||
// Mittellinie DIESES Bandes überdeckt (geometrischer Überlapp wie
|
||||
// toSection.ts::subtractDominantBands) — NICHT mehr per wandweitem BBox-Test.
|
||||
// Schnitt-Dominanz im Kern (plan_section.rs)) — NICHT mehr per wandweitem BBox-Test.
|
||||
// (Frühere Tests erwarteten hier „ALLE Schichten geschnitten"; das kodierte das
|
||||
// falsche BBox-Verhalten und ist die Ursache des 3D-Kranzes. Korrigiert.)
|
||||
it("Decke schneidet nur die von ihrer Outline überdeckten (inneren) Bänder; Dämmung/Aussenputz laufen durch; Beton spaltet den Backstein PER SCHICHT", () => {
|
||||
const w2 = projectToWalls3d(sampleProject).filter((w) => w.wallId === "W2");
|
||||
// PER-SCHICHT-Decken-Dominanz (identisch zu toSection.ts::subtractDominantBands):
|
||||
// PER-SCHICHT-Decken-Dominanz (identisch zu Schnitt-Dominanz im Kern (plan_section.rs)):
|
||||
// jede Deckenschicht (screed 30 / insulation 20 / concrete 100) schneidet nur
|
||||
// Wandbänder mit STRIKT niedrigerer Priorität in IHREM z-Band. Der Backstein (50)
|
||||
// wird also NUR von der Beton-Schicht (100, z-Band [2.3,2.5]) gekappt und läuft
|
||||
@@ -1949,7 +1949,7 @@ describe("Wand-Joins im 3D (L-/T-Stösse, identisch zum 2D-Grundriss/Schnitt)",
|
||||
it("Joins wirken NUR im layered-3D-Pfad, nicht im Schnitt-Pfad (layered=false unverändert)", () => {
|
||||
// Der Schnitt-Pfad (computeSection, layeredWalls:false) darf KEINE Join-Cuts
|
||||
// bekommen: W2 bleibt eine Voll-Box über die ganze Dicke, ungehrt (Achse
|
||||
// 0..4), damit toSection.ts::subtractDominantBands seine eigene Dominanz auf
|
||||
// 0..4), damit Schnitt-Dominanz im Kern (plan_section.rs) seine eigene Dominanz auf
|
||||
// Rohgeometrie anwendet.
|
||||
const w2 = projectToWalls3d(sampleProject, false).filter((w) => w.wallId === "W2");
|
||||
expect(w2.length).toBe(1); // Voll-Box, keine Schicht-Bänder
|
||||
|
||||
@@ -110,12 +110,8 @@ export function roofMeshes(project: Project, onlyRoofId?: string): RMesh[] {
|
||||
/**
|
||||
* Optionen für {@link projectToModel3d}. `layeredWalls` steuert, ob eine
|
||||
* mehrschichtige Wand als eigene Box je Materiallage (Default, 3D-Viewer) oder
|
||||
* als EINE Voll-Box über die ganze Dicke emittiert wird. Der Schnitt-Pfad
|
||||
* (`computeSection`) setzt `false`, damit die Cut-Polygone 1:1 zur Wand liegen
|
||||
* (die Schicht-Zerlegung macht dort `splitWallLayers` TS-seitig) — sonst
|
||||
* verschöben die per-Lage vervielfachten Boxen die `ComponentRef.index`
|
||||
* gegenüber `wallSegmentOwners` und die materialspezifische Schnitt-Schraffur
|
||||
* ginge verloren.
|
||||
* als EINE Voll-Box über die ganze Dicke emittiert wird (so rechnen auch Schnitt
|
||||
* und Ansicht im Kern, `core/src/plan/{section,elevation}.rs`).
|
||||
*/
|
||||
export interface Model3dOptions {
|
||||
layeredWalls?: boolean;
|
||||
|
||||
+1
-17
@@ -3,7 +3,7 @@ import type { Pair } from "../geometry/polygonBool";
|
||||
import { generatePlan } from "./generatePlan";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import type { ExtrudedSolid, Project } from "../model/types";
|
||||
import { keyhole, segmentOutside, subtractRings, subtractVoidsInSection, voidPrisms, voidSectionRects } from "./voids";
|
||||
import { segmentOutside, subtractRings } from "./voids";
|
||||
|
||||
const sq = (x0: number, y0: number, x1: number, y1: number): Pair[] => [[x0, y0], [x1, y0], [x1, y1], [x0, y1]];
|
||||
const area = (r: Pair[]) => Math.abs(r.reduce((s, p, i) => s + p[0] * r[(i + 1) % r.length][1] - r[(i + 1) % r.length][0] * p[1], 0) / 2);
|
||||
@@ -40,10 +40,6 @@ describe("Abzugskoerper — Polygon-Kern", () => {
|
||||
const edges = r[0].noStrokeEdges.map((i) => [r[0].pts[i], r[0].pts[(i + 1) % r[0].pts.length]]);
|
||||
expect(edges.every(([a, b]) => a[0] === 4 && b[0] === 4)).toBe(true);
|
||||
});
|
||||
it("keyhole haengt mehrere Loecher ein", () => {
|
||||
const k = keyhole([sq(0, 0, 10, 2), sq(1, 0.5, 2, 1.5).reverse(), sq(5, 0.5, 6, 1.5).reverse()]);
|
||||
expect(k.bridges).toHaveLength(4);
|
||||
});
|
||||
it("segmentOutside: Linie durch Quadrat in zwei Teile", () => {
|
||||
const parts = segmentOutside({ x: 0, y: 0.5 }, { x: 4, y: 0.5 }, [sq(1, 0, 2, 1)]);
|
||||
expect(parts.map(([a, b]) => [a, b])).toEqual([[0, 0.25], [0.5, 1]]);
|
||||
@@ -77,16 +73,4 @@ describe("Abzugskoerper — Grundriss und Schnitt", () => {
|
||||
const p = withVoid(sampleProject, { points: box, baseOffset: 1.5, height: 0.5 });
|
||||
expect(wallPolys(p).length).toBe(wallPolys(sampleProject).length);
|
||||
});
|
||||
it("Schnitt: Rechtecke aus Grundflaeche x Hoehenbereich, Abzug aus Cut-Polygonen", () => {
|
||||
const p = withVoid(sampleProject, { points: box, baseOffset: 0.5, height: 1 });
|
||||
const [v] = voidPrisms(p);
|
||||
const rects = voidSectionRects(v, { x: 0, y: my }, { x: 1, y: 0 });
|
||||
expect(rects).toHaveLength(1);
|
||||
expect(rects[0][0][0]).toBeCloseTo(mx - 0.3, 9);
|
||||
expect(rects[0][2][1]).toBeCloseTo(v.z1, 9);
|
||||
const cuts = [{ pts: sq(mx - 2, 0, mx + 2, 2.5) as Array<[number, number]> }];
|
||||
const out = subtractVoidsInSection(cuts, p, { x: 0, y: my }, { x: 1, y: 0 });
|
||||
expect(out).toHaveLength(1);
|
||||
expect(area(out[0].pts)).toBeCloseTo(4 * 2.5 - 0.6 * 1, 6);
|
||||
});
|
||||
});
|
||||
+2
-72
@@ -4,7 +4,8 @@
|
||||
//
|
||||
// • Grundriss: Poché-Polygone der getroffenen Bauteile minus Körper-Grundfläche, sofern der
|
||||
// Körper die Schnitthöhe (Wände/Stützen) bzw. die Platte (Decken) durchdringt.
|
||||
// • Schnitt: Cut-Polygone minus Körper-Schnitt (Grundfläche ∩ Schnittspur × Höhenbereich).
|
||||
// • Schnitt: Cut-Polygone minus Körper-Schnitt (Grundfläche ∩ Schnittspur × Höhenbereich), im Kern
|
||||
// (`core/src/plan/section.rs`).
|
||||
// • 3D/STEP: Boolean-Differenz (truck, Mesh-CSG-Fallback), s. `toWalls3d/voids3d.ts`
|
||||
// bzw. `exportStep.ts`.
|
||||
//
|
||||
@@ -74,21 +75,6 @@ function encodeRings(rings: Pair[][]): Float64Array {
|
||||
return Float64Array.from(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Löcher per Steg in den Aussenring einhängen (Schlüsselloch). Liefert die Punkte und die
|
||||
* Indizes der Stegkanten (Kante i = pts[i] → pts[i+1]).
|
||||
*/
|
||||
export function keyhole(poly: Pair[][]): { pts: Pair[]; bridges: number[] } {
|
||||
const f = core().voids_keyhole_flat(encodeRings(poly));
|
||||
const n = f[0];
|
||||
const pts = new Array<Pair>(n);
|
||||
for (let i = 0; i < n; i++) pts[i] = [f[1 + 2 * i], f[2 + 2 * i]];
|
||||
const nb = f[1 + 2 * n];
|
||||
const bridges = new Array<number>(nb);
|
||||
for (let i = 0; i < nb; i++) bridges[i] = f[2 + 2 * n + i];
|
||||
return { pts, bridges };
|
||||
}
|
||||
|
||||
/**
|
||||
* Polygon (Ring `pts`, optional nicht gestrichene Kanten) minus Schneider. Liefert die
|
||||
* Rest-Polygone mit übertragenen `noStrokeEdges` (eine Kante bleibt ungestrichen, wenn sie
|
||||
@@ -202,62 +188,6 @@ export function subtractVoidsInPlan(prims: Primitive[], project: Project, cutZ:
|
||||
return true;
|
||||
}
|
||||
|
||||
// ── Schnitt ──────────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Schnitt-Rechtecke (u, v) eines Abzugskörpers mit der senkrechten Ebene durch `base` in
|
||||
* Richtung `uDir` (Einheitsvektor; u = Abstand entlang uDir ab `base`).
|
||||
*/
|
||||
export function voidSectionRects(v: VoidPrism, base: Vec2, uDir: Vec2): Pair[][] {
|
||||
const f = core().voids_section_rects_flat(
|
||||
Float64Array.from([v.pts.length, ...v.pts.flatMap((p) => [p.x, p.y])]),
|
||||
Float64Array.from([base.x, base.y, uDir.x, uDir.y]),
|
||||
);
|
||||
const rects: Pair[][] = [];
|
||||
for (let k = 0; k < (f[0] ?? 0); k++) {
|
||||
const u0 = f[1 + 2 * k];
|
||||
const u1 = f[2 + 2 * k];
|
||||
rects.push([
|
||||
[u0, v.z0],
|
||||
[u1, v.z0],
|
||||
[u1, v.z1],
|
||||
[u0, v.z1],
|
||||
]);
|
||||
}
|
||||
return rects;
|
||||
}
|
||||
|
||||
/** Minimal-Form eines Schnitt-Polygons (s. `SectionCutPolygon` in toSection.ts). */
|
||||
interface CutPolyLike {
|
||||
pts: Array<[number, number]>;
|
||||
noStrokeEdges?: number[];
|
||||
}
|
||||
|
||||
/** Zieht die Abzugskörper von den Cut-Polygonen eines Schnitts ab (neue Liste). */
|
||||
export function subtractVoidsInSection<T extends CutPolyLike>(
|
||||
cuts: T[],
|
||||
project: Project,
|
||||
base: Vec2,
|
||||
uDir: Vec2,
|
||||
): T[] {
|
||||
const voids = voidPrisms(project);
|
||||
if (voids.length === 0) return cuts;
|
||||
const rects = voids.flatMap((v) => voidSectionRects(v, base, uDir));
|
||||
if (rects.length === 0) return cuts;
|
||||
const out: T[] = [];
|
||||
for (const cp of cuts) {
|
||||
const rest = subtractRings(cp.pts as Pair[], rects, cp.noStrokeEdges ?? []);
|
||||
if (rest === null) {
|
||||
out.push(cp);
|
||||
continue;
|
||||
}
|
||||
for (const r of rest) {
|
||||
out.push({ ...cp, pts: r.pts as Array<[number, number]>, noStrokeEdges: r.noStrokeEdges.length ? r.noStrokeEdges : undefined });
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// ── 3D / B-Rep ───────────────────────────────────────────────────────────────
|
||||
|
||||
export type Box2 = { x0: number; y0: number; x1: number; y1: number };
|
||||
|
||||
Reference in new issue
Block a user