[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
@@ -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)
|
||||
}
|
||||
Reference in new issue
Block a user