Archived
Schnitt: Treppe als ein Koerper (Monolith-Gruppe: keine Naehte zwischen Tritten, Cut-Flaechen vereint), gerade Betontreppen im Schnitt, Beton-Podest als Platte
This commit is contained in:
1 parent
50bff03b51
commit
8ed5650f11
10 files changed
+231
-9
No files matched your search
@@ -72,6 +72,7 @@ fn l_wall_scene() -> (Vec<WallInput>, Vec<SlabInput>) {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
let slabs = vec![SlabInput {
|
let slabs = vec![SlabInput {
|
||||||
|
monolith: None,
|
||||||
outline: vec![[-0.5, -0.5], [3.5, -0.5], [3.5, 3.5], [-0.5, 3.5]],
|
outline: vec![[-0.5, -0.5], [3.5, -0.5], [3.5, 3.5], [-0.5, 3.5]],
|
||||||
z_bottom: -0.2,
|
z_bottom: -0.2,
|
||||||
z_top: 0.0,
|
z_top: 0.0,
|
||||||
|
|||||||
@@ -792,6 +792,7 @@ mod tests {
|
|||||||
/// Quadratischer Decken-Umriss (CCW) mit Kantenlaenge `s`, Ecke im Ursprung.
|
/// Quadratischer Decken-Umriss (CCW) mit Kantenlaenge `s`, Ecke im Ursprung.
|
||||||
fn square_slab(s: f32, z_bottom: f32, z_top: f32) -> SlabInput {
|
fn square_slab(s: f32, z_bottom: f32, z_top: f32) -> SlabInput {
|
||||||
SlabInput {
|
SlabInput {
|
||||||
|
monolith: None,
|
||||||
outline: vec![[0.0, 0.0], [s, 0.0], [s, s], [0.0, s]],
|
outline: vec![[0.0, 0.0], [s, 0.0], [s, s], [0.0, s]],
|
||||||
z_bottom,
|
z_bottom,
|
||||||
z_top,
|
z_top,
|
||||||
@@ -850,6 +851,7 @@ mod tests {
|
|||||||
// Zentriertes Quadrat um den Ursprung: jede Mantel-Normale muss vom
|
// Zentriertes Quadrat um den Ursprung: jede Mantel-Normale muss vom
|
||||||
// Zentrum weg zeigen.
|
// Zentrum weg zeigen.
|
||||||
let slab = SlabInput {
|
let slab = SlabInput {
|
||||||
|
monolith: None,
|
||||||
outline: vec![[-2.0, -2.0], [2.0, -2.0], [2.0, 2.0], [-2.0, 2.0]],
|
outline: vec![[-2.0, -2.0], [2.0, -2.0], [2.0, 2.0], [-2.0, 2.0]],
|
||||||
z_bottom: 0.0,
|
z_bottom: 0.0,
|
||||||
z_top: 0.3,
|
z_top: 0.3,
|
||||||
@@ -884,7 +886,7 @@ mod tests {
|
|||||||
fn entarteter_slab_erzeugt_nichts() {
|
fn entarteter_slab_erzeugt_nichts() {
|
||||||
let mut mesh = Mesh::default();
|
let mut mesh = Mesh::default();
|
||||||
// <3 Ecken.
|
// <3 Ecken.
|
||||||
extrude_slab(&mut mesh, &SlabInput { outline: vec![[0.0, 0.0], [1.0, 0.0]], z_bottom: 0.0, z_top: 0.2, color: [0.8, 0.8, 0.8], hatch: None, cut: None });
|
extrude_slab(&mut mesh, &SlabInput { outline: vec![[0.0, 0.0], [1.0, 0.0]], z_bottom: 0.0, z_top: 0.2, color: [0.8, 0.8, 0.8], hatch: None, cut: None, monolith: None });
|
||||||
assert_eq!(mesh.vertex_count(), 0);
|
assert_eq!(mesh.vertex_count(), 0);
|
||||||
// Nullhoehe.
|
// Nullhoehe.
|
||||||
extrude_slab(&mut mesh, &square_slab(4.0, 2.6, 2.6));
|
extrude_slab(&mut mesh, &square_slab(4.0, 2.6, 2.6));
|
||||||
|
|||||||
@@ -340,6 +340,8 @@ struct Prism {
|
|||||||
/// `WallInput`/`SlabInput`-Eingabe (`cut`) uebernommen und an jedes erzeugte
|
/// `WallInput`/`SlabInput`-Eingabe (`cut`) uebernommen und an jedes erzeugte
|
||||||
/// `CutPolygon` weitergereicht.
|
/// `CutPolygon` weitergereicht.
|
||||||
cut: Option<CutBandMeta>,
|
cut: Option<CutBandMeta>,
|
||||||
|
/// Monolith-Gruppe (siehe `SlabInput::monolith`); Waende: immer `None`.
|
||||||
|
monolith: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wandachse + Oeffnungen, wie sie fuer die Oeffnungs-Zuordnung bei Cut-
|
/// Wandachse + Oeffnungen, wie sie fuer die Oeffnungs-Zuordnung bei Cut-
|
||||||
@@ -430,6 +432,7 @@ fn wall_prism(index: usize, wall: &WallInput) -> Option<Prism> {
|
|||||||
openings: wall.openings.clone(),
|
openings: wall.openings.clone(),
|
||||||
}),
|
}),
|
||||||
cut: wall.cut.clone(),
|
cut: wall.cut.clone(),
|
||||||
|
monolith: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,6 +456,7 @@ fn slab_prism(index: usize, slab: &SlabInput) -> Option<Prism> {
|
|||||||
hatch: slab.hatch,
|
hatch: slab.hatch,
|
||||||
wall_axis: None,
|
wall_axis: None,
|
||||||
cut: slab.cut.clone(),
|
cut: slab.cut.clone(),
|
||||||
|
monolith: slab.monolith.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,6 +590,8 @@ struct PrismBounds {
|
|||||||
/// Groesste Tiefe des Fussabdrucks. `<= EPS` heisst: das Bauteil liegt
|
/// Groesste Tiefe des Fussabdrucks. `<= EPS` heisst: das Bauteil liegt
|
||||||
/// komplett VOR der Ebene (hinter dem Betrachter) und verdeckt nichts.
|
/// komplett VOR der Ebene (hinter dem Betrachter) und verdeckt nichts.
|
||||||
depth_max: f32,
|
depth_max: f32,
|
||||||
|
/// Monolith-Gruppe des Prismas (siehe `SlabInput::monolith`).
|
||||||
|
monolith: Option<String>,
|
||||||
z0: f32,
|
z0: f32,
|
||||||
z1: f32,
|
z1: f32,
|
||||||
opening_voids: Vec<(f32, f32, f32, f32)>,
|
opening_voids: Vec<(f32, f32, f32, f32)>,
|
||||||
@@ -639,6 +645,7 @@ fn prism_bounds(plane: &SectionPlane, prism: &Prism) -> PrismBounds {
|
|||||||
u_max,
|
u_max,
|
||||||
depth_min,
|
depth_min,
|
||||||
depth_max,
|
depth_max,
|
||||||
|
monolith: prism.monolith.clone(),
|
||||||
z0: prism.z0,
|
z0: prism.z0,
|
||||||
z1: prism.z1,
|
z1: prism.z1,
|
||||||
opening_voids,
|
opening_voids,
|
||||||
@@ -803,8 +810,10 @@ fn blocked_intervals(
|
|||||||
bias: HeightBias,
|
bias: HeightBias,
|
||||||
bounds: &[PrismBounds],
|
bounds: &[PrismBounds],
|
||||||
exclude: Option<ComponentRef>,
|
exclude: Option<ComponentRef>,
|
||||||
|
owner: (ComponentRef, Option<&str>),
|
||||||
) -> Vec<(f32, f32)> {
|
) -> Vec<(f32, f32)> {
|
||||||
let mut ivs = Vec::new();
|
let mut ivs = Vec::new();
|
||||||
|
let (owner_ref, owner_group) = owner;
|
||||||
for b in bounds {
|
for b in bounds {
|
||||||
if let Some(ex) = exclude {
|
if let Some(ex) = exclude {
|
||||||
if ex.kind == b.kind && ex.index == b.index {
|
if ex.kind == b.kind && ex.index == b.index {
|
||||||
@@ -821,7 +830,15 @@ fn blocked_intervals(
|
|||||||
}
|
}
|
||||||
let ru = height_in_range(u0, u1, b.u_min, b.u_max, HeightBias::Vertical);
|
let ru = height_in_range(u0, u1, b.u_min, b.u_max, HeightBias::Vertical);
|
||||||
let rv = height_in_range(v0, v1, b.z0, b.z1, bias);
|
let rv = height_in_range(v0, v1, b.z0, b.z1, bias);
|
||||||
let rd = linear_greater_than(d0, d1, b.depth_min + EPS);
|
// Gleiche Monolith-Gruppe (z. B. Tritte EINER Treppe), anderes Prisma:
|
||||||
|
// verdeckt auch bei GLEICHER Tiefe — die Naht zwischen zwei Tritten auf
|
||||||
|
// derselben Seitenflaeche ist keine sichtbare Kante (sonst "gestapelte
|
||||||
|
// Kistchen" statt Saegezahn im Schnitt).
|
||||||
|
let same_group = owner_group.is_some()
|
||||||
|
&& b.monolith.as_deref() == owner_group
|
||||||
|
&& !(b.kind == owner_ref.kind && b.index == owner_ref.index);
|
||||||
|
let threshold = if same_group { b.depth_min - EPS } else { b.depth_min + EPS };
|
||||||
|
let rd = linear_greater_than(d0, d1, threshold);
|
||||||
let Some(solid) = intersect_ranges(intersect_ranges(ru, rv), rd) else {
|
let Some(solid) = intersect_ranges(intersect_ranges(ru, rv), rd) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
@@ -959,7 +976,18 @@ fn compute_view_edges(
|
|||||||
let d1 = plane.depth(cb);
|
let d1 = plane.depth(cb);
|
||||||
|
|
||||||
let exclude = if self_exclude { Some(cref) } else { None };
|
let exclude = if self_exclude { Some(cref) } else { None };
|
||||||
let blocked = blocked_intervals(u0, u1, v0, v1, d0, d1, bias, &bounds, exclude);
|
let blocked = blocked_intervals(
|
||||||
|
u0,
|
||||||
|
u1,
|
||||||
|
v0,
|
||||||
|
v1,
|
||||||
|
d0,
|
||||||
|
d1,
|
||||||
|
bias,
|
||||||
|
&bounds,
|
||||||
|
exclude,
|
||||||
|
(cref, prism.monolith.as_deref()),
|
||||||
|
);
|
||||||
for &(s, e) in &blocked {
|
for &(s, e) in &blocked {
|
||||||
hidden.push(SectionEdge {
|
hidden.push(SectionEdge {
|
||||||
component: cref,
|
component: cref,
|
||||||
@@ -1099,6 +1127,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
let slabs = vec![SlabInput {
|
let slabs = vec![SlabInput {
|
||||||
|
monolith: None,
|
||||||
outline: vec![[-0.5, -0.5], [3.5, -0.5], [3.5, 3.5], [-0.5, 3.5]],
|
outline: vec![[-0.5, -0.5], [3.5, -0.5], [3.5, 3.5], [-0.5, 3.5]],
|
||||||
z_bottom: -0.2,
|
z_bottom: -0.2,
|
||||||
z_top: 0.0,
|
z_top: 0.0,
|
||||||
|
|||||||
@@ -388,6 +388,7 @@ mod tests {
|
|||||||
// Decken-Slab, deren Umriss die Wand an der Schnittstelle (x=1.5) ueberdeckt,
|
// Decken-Slab, deren Umriss die Wand an der Schnittstelle (x=1.5) ueberdeckt,
|
||||||
// z in [2.0, 2.4]; Prio 100 (Beton laeuft durch, schneidet die Wand).
|
// z in [2.0, 2.4]; Prio 100 (Beton laeuft durch, schneidet die Wand).
|
||||||
let slab = SlabInput {
|
let slab = SlabInput {
|
||||||
|
monolith: None,
|
||||||
outline: vec![[-1.0, -1.0], [4.0, -1.0], [4.0, 1.0], [-1.0, 1.0]],
|
outline: vec![[-1.0, -1.0], [4.0, -1.0], [4.0, 1.0], [-1.0, 1.0]],
|
||||||
z_bottom: 2.0,
|
z_bottom: 2.0,
|
||||||
z_top: 2.4,
|
z_top: 2.4,
|
||||||
@@ -461,6 +462,7 @@ mod tests {
|
|||||||
// Estrich-Slab (Prio 30, Muster 3 crosshatch), z in [1.0,1.06], deckt die
|
// Estrich-Slab (Prio 30, Muster 3 crosshatch), z in [1.0,1.06], deckt die
|
||||||
// Wand in u ab (Umriss ueber y in [-1,1]).
|
// Wand in u ab (Umriss ueber y in [-1,1]).
|
||||||
let screed = SlabInput {
|
let screed = SlabInput {
|
||||||
|
monolith: None,
|
||||||
outline: vec![[-1.0, -1.0], [4.0, -1.0], [4.0, 1.0], [-1.0, 1.0]],
|
outline: vec![[-1.0, -1.0], [4.0, -1.0], [4.0, 1.0], [-1.0, 1.0]],
|
||||||
z_bottom: 1.0,
|
z_bottom: 1.0,
|
||||||
z_top: 1.06,
|
z_top: 1.06,
|
||||||
@@ -475,6 +477,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
// Daemmung-Slab (Prio 20, Muster 4), z in [0.96,1.0], gleiche u-Deckung.
|
// Daemmung-Slab (Prio 20, Muster 4), z in [0.96,1.0], gleiche u-Deckung.
|
||||||
let insulation = SlabInput {
|
let insulation = SlabInput {
|
||||||
|
monolith: None,
|
||||||
outline: vec![[-1.0, -1.0], [4.0, -1.0], [4.0, 1.0], [-1.0, 1.0]],
|
outline: vec![[-1.0, -1.0], [4.0, -1.0], [4.0, 1.0], [-1.0, 1.0]],
|
||||||
z_bottom: 0.96,
|
z_bottom: 0.96,
|
||||||
z_top: 1.0,
|
z_top: 1.0,
|
||||||
|
|||||||
@@ -266,6 +266,13 @@ pub struct SlabInput {
|
|||||||
/// `CutBandMeta`/`WallInput::cut`).
|
/// `CutBandMeta`/`WallInput::cut`).
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub cut: Option<CutBandMeta>,
|
pub cut: Option<CutBandMeta>,
|
||||||
|
/// Gruppe eines aus mehreren Prismen zusammengesetzten, MONOLITHISCHEN
|
||||||
|
/// Bauteils (z. B. die Tritt-Prismen EINER massiven/Beton-Treppe). Im
|
||||||
|
/// Schnitt/in der Ansicht verdecken sich Prismen derselben Gruppe auch bei
|
||||||
|
/// GLEICHER Tiefe gegenseitig — die inneren Nähte zwischen den Tritten
|
||||||
|
/// verschwinden, sichtbar bleibt der Umriss (Sägezahn). `None` = Einzelteil.
|
||||||
|
#[serde(default)]
|
||||||
|
pub monolith: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EINE Dachflächen-Schicht für den 3D-Live-Schnitt (`crate::roof_cut`).
|
/// EINE Dachflächen-Schicht für den 3D-Live-Schnitt (`crate::roof_cut`).
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
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
|
||||||
|
});
|
||||||
|
});
|
||||||
+115
-1
@@ -1182,7 +1182,8 @@ export async function computeSection(
|
|||||||
// Cut-Polygone 1:1 zu `wallSegmentOwners` (Öffnungs-Segmentierung) liegen und
|
// Cut-Polygone 1:1 zu `wallSegmentOwners` (Öffnungs-Segmentierung) liegen und
|
||||||
// `splitWallLayers` die materialspezifischen Schnitt-Bänder korrekt aus dem
|
// `splitWallLayers` die materialspezifischen Schnitt-Bänder korrekt aus dem
|
||||||
// EINEN Wandrechteck erzeugt. Der 3D-Viewer bekommt weiter per-Schicht-Boxen.
|
// EINEN Wandrechteck erzeugt. Der 3D-Viewer bekommt weiter per-Schicht-Boxen.
|
||||||
const modelJson = JSON.stringify(projectToModel3d(project, { layeredWalls: false }));
|
const model = projectToModel3d(project, { layeredWalls: false, forSection: true });
|
||||||
|
const modelJson = JSON.stringify(model);
|
||||||
const json = mod.cut_section_json(
|
const json = mod.cut_section_json(
|
||||||
modelJson,
|
modelJson,
|
||||||
plane.point[0],
|
plane.point[0],
|
||||||
@@ -1209,6 +1210,10 @@ export async function computeSection(
|
|||||||
// Dächer TS-seitig ergänzen (der Rust-Extraktor kennt nur Wände + Decken).
|
// Dächer TS-seitig ergänzen (der Rust-Extraktor kennt nur Wände + Decken).
|
||||||
appendRoofSections(output, project, plane);
|
appendRoofSections(output, project, plane);
|
||||||
attachCutStyles(output, project, plane);
|
attachCutStyles(output, project, plane);
|
||||||
|
// Monolithische Bauteile aus mehreren Prismen (Treppen-Tritte): ihre Schnitt-
|
||||||
|
// Rechtecke zu EINEM Umriss vereinen — sonst je Tritt ein eigenes,
|
||||||
|
// überlappendes Schraffur-Rechteck mit Kontur ("gestapelte Kistchen").
|
||||||
|
output.cutPolygons = mergeMonolithCuts(output.cutPolygons, (i) => model.slabs[i]?.monolith);
|
||||||
// Schnitt-Tiefe: Kanten weiter als `level.depth` hinter der Ebene ausblenden.
|
// Schnitt-Tiefe: Kanten weiter als `level.depth` hinter der Ebene ausblenden.
|
||||||
if (level.depth !== undefined) filterByDepth(output, project, plane, level.depth);
|
if (level.depth !== undefined) filterByDepth(output, project, plane, level.depth);
|
||||||
return output;
|
return output;
|
||||||
@@ -1257,3 +1262,112 @@ export function sameSectionLine(a: DrawingLevel, b: DrawingLevel): boolean {
|
|||||||
!!a.shadows === !!b.shadows
|
!!a.shadows === !!b.shadows
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vereint die Cut-Polygone je Monolith-Gruppe (nur Decken-/Slab-Prismen mit
|
||||||
|
* gesetzter Gruppe, s. `RSlab.monolith`) zu orthogonalen Umriss-Polygonen.
|
||||||
|
* Stil/Herkunft übernimmt das erste Band der Gruppe. Löcher im Umriss werden
|
||||||
|
* nicht dargestellt (bei Treppen nicht vorkommend).
|
||||||
|
*/
|
||||||
|
export function mergeMonolithCuts(
|
||||||
|
cuts: SectionCutPolygon[],
|
||||||
|
groupOfSlab: (index: number) => string | undefined,
|
||||||
|
): SectionCutPolygon[] {
|
||||||
|
const groups = new Map<string, SectionCutPolygon[]>();
|
||||||
|
const out: SectionCutPolygon[] = [];
|
||||||
|
for (const cp of cuts) {
|
||||||
|
const g = cp.component.kind === "slab" ? groupOfSlab(cp.component.index) : undefined;
|
||||||
|
if (!g) {
|
||||||
|
out.push(cp);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const list = groups.get(g);
|
||||||
|
if (list) list.push(cp);
|
||||||
|
else groups.set(g, [cp]);
|
||||||
|
}
|
||||||
|
for (const list of groups.values()) {
|
||||||
|
if (list.length === 1) {
|
||||||
|
out.push(list[0]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const rects = list.map((cp) => rectOfBand(cp)).filter((r): r is Rect => r !== null);
|
||||||
|
if (rects.length !== list.length) {
|
||||||
|
out.push(...list); // nicht-rechteckige Bänder: unverändert lassen
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (const ring of unionRectOutlines(rects)) {
|
||||||
|
out.push({ ...list[0], pts: ring });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Äussere Umrisse der Vereinigung achsparalleler Rechtecke (Raster über alle
|
||||||
|
* Kanten-Koordinaten, Randkanten verketten). Liefert je zusammenhängender
|
||||||
|
* Fläche den Aussenring (CCW); Innenringe (Löcher) entfallen.
|
||||||
|
*/
|
||||||
|
export function unionRectOutlines(rects: Rect[]): Array<Array<[number, number]>> {
|
||||||
|
const xs = [...new Set(rects.flatMap((r) => [r.uMin, r.uMax]))].sort((a, b) => a - b);
|
||||||
|
const ys = [...new Set(rects.flatMap((r) => [r.vMin, r.vMax]))].sort((a, b) => a - b);
|
||||||
|
const nx = xs.length - 1;
|
||||||
|
const ny = ys.length - 1;
|
||||||
|
if (nx < 1 || ny < 1) return [];
|
||||||
|
const filled = (i: number, j: number): boolean => {
|
||||||
|
if (i < 0 || j < 0 || i >= nx || j >= ny) return false;
|
||||||
|
const cx = (xs[i] + xs[i + 1]) / 2;
|
||||||
|
const cy = (ys[j] + ys[j + 1]) / 2;
|
||||||
|
return rects.some((r) => cx > r.uMin && cx < r.uMax && cy > r.vMin && cy < r.vMax);
|
||||||
|
};
|
||||||
|
const cell: boolean[][] = [];
|
||||||
|
for (let i = 0; i < nx; i++) {
|
||||||
|
cell.push([]);
|
||||||
|
for (let j = 0; j < ny; j++) cell[i].push(filled(i, j));
|
||||||
|
}
|
||||||
|
const at = (i: number, j: number) => i >= 0 && j >= 0 && i < nx && j < ny && cell[i][j];
|
||||||
|
// Gerichtete Randkanten (Fläche links → CCW), als Gitterpunkt-Paare.
|
||||||
|
const next = new Map<string, [number, number]>();
|
||||||
|
const key = (i: number, j: number) => `${i},${j}`;
|
||||||
|
for (let i = 0; i < nx; i++) {
|
||||||
|
for (let j = 0; j < ny; j++) {
|
||||||
|
if (!cell[i][j]) continue;
|
||||||
|
if (!at(i, j - 1)) next.set(key(i, j), [i + 1, j]); // unten, nach rechts
|
||||||
|
if (!at(i + 1, j)) next.set(key(i + 1, j), [i + 1, j + 1]); // rechts, nach oben
|
||||||
|
if (!at(i, j + 1)) next.set(key(i + 1, j + 1), [i, j + 1]); // oben, nach links
|
||||||
|
if (!at(i - 1, j)) next.set(key(i, j + 1), [i, j]); // links, nach unten
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const rings: Array<Array<[number, number]>> = [];
|
||||||
|
const used = new Set<string>();
|
||||||
|
for (const start of next.keys()) {
|
||||||
|
if (used.has(start)) continue;
|
||||||
|
const ring: Array<[number, number]> = [];
|
||||||
|
let k = start;
|
||||||
|
while (!used.has(k)) {
|
||||||
|
used.add(k);
|
||||||
|
const [i, j] = k.split(",").map(Number);
|
||||||
|
ring.push([xs[i], ys[j]]);
|
||||||
|
const n = next.get(k);
|
||||||
|
if (!n) break;
|
||||||
|
k = key(n[0], n[1]);
|
||||||
|
}
|
||||||
|
// Kollineare Zwischenpunkte entfernen.
|
||||||
|
const simple = ring.filter((p, idx) => {
|
||||||
|
const a = ring[(idx + ring.length - 1) % ring.length];
|
||||||
|
const b = ring[(idx + 1) % ring.length];
|
||||||
|
return !((a[0] === p[0] && p[0] === b[0]) || (a[1] === p[1] && p[1] === b[1]));
|
||||||
|
});
|
||||||
|
if (simple.length >= 4 && signedArea(simple) > 0) rings.push(simple);
|
||||||
|
}
|
||||||
|
return rings;
|
||||||
|
}
|
||||||
|
|
||||||
|
function signedArea(ring: Array<[number, number]>): number {
|
||||||
|
let a = 0;
|
||||||
|
for (let i = 0; i < ring.length; i++) {
|
||||||
|
const [x0, y0] = ring[i];
|
||||||
|
const [x1, y1] = ring[(i + 1) % ring.length];
|
||||||
|
a += x0 * y1 - x1 * y0;
|
||||||
|
}
|
||||||
|
return a / 2;
|
||||||
|
}
|
||||||
@@ -197,6 +197,8 @@ export interface Model3dOptions {
|
|||||||
* Fehlt es, gilt "fein" (= volle Details).
|
* Fehlt es, gilt "fein" (= volle Details).
|
||||||
*/
|
*/
|
||||||
detail?: DetailLevel;
|
detail?: DetailLevel;
|
||||||
|
/** Schnitt-Eingabe: Treppen immer als Tritt-Prismen (s. `emitStairs` `forSection`). */
|
||||||
|
forSection?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Das volle 3D-Modell: Wände (mit Öffnungen) + Deckenplatten + Kontext-Meshes. */
|
/** Das volle 3D-Modell: Wände (mit Öffnungen) + Deckenplatten + Kontext-Meshes. */
|
||||||
@@ -207,7 +209,7 @@ export function projectToModel3d(project: Project, opts: Model3dOptions = {}): R
|
|||||||
walls: projectToWalls3d(project, layered),
|
walls: projectToWalls3d(project, layered),
|
||||||
// Decken + Treppen (Treppentritte als extrudierte Slabs) — so wird die Treppe
|
// Decken + Treppen (Treppentritte als extrudierte Slabs) — so wird die Treppe
|
||||||
// auch im WASM/wgpu-Renderer sichtbar (der three.js-Pfad rendert sie separat).
|
// auch im WASM/wgpu-Renderer sichtbar (der three.js-Pfad rendert sie separat).
|
||||||
slabs: [...emitSlabs(project), ...emitStairs(project)],
|
slabs: [...emitSlabs(project), ...emitStairs(project, { forSection: opts.forSection })],
|
||||||
// Kontext-Meshes (Terrain/Import) + Fenster-/Tür-Glasscheiben (eigenes Mesh
|
// Kontext-Meshes (Terrain/Import) + Fenster-/Tür-Glasscheiben (eigenes Mesh
|
||||||
// je Scheibe) + Rahmen-/Sprossen-Riegel typisierter Öffnungen (Zarge/
|
// je Scheibe) + Rahmen-/Sprossen-Riegel typisierter Öffnungen (Zarge/
|
||||||
// Blendrahmen/Kämpfer/Mittelpfosten, s. emitOpeningFrames) + glatte Beton-
|
// Blendrahmen/Kämpfer/Mittelpfosten, s. emitOpeningFrames) + glatte Beton-
|
||||||
|
|||||||
@@ -285,6 +285,12 @@ export interface RSlab {
|
|||||||
hatch?: RHatch;
|
hatch?: RHatch;
|
||||||
/** Schnitt-Verschneidungs-/Linienstil-Metadaten dieser Decken-Schicht (siehe {@link RCutMeta}). */
|
/** Schnitt-Verschneidungs-/Linienstil-Metadaten dieser Decken-Schicht (siehe {@link RCutMeta}). */
|
||||||
cut?: RCutMeta;
|
cut?: RCutMeta;
|
||||||
|
/**
|
||||||
|
* Monolith-Gruppe (z. B. Treppen-ID einer massiven/Beton-Treppe): Prismen
|
||||||
|
* derselben Gruppe verdecken sich im Schnitt auch bei gleicher Tiefe —
|
||||||
|
* render3d `SlabInput::monolith`.
|
||||||
|
*/
|
||||||
|
monolith?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Art eines rohen Kontext-Meshes (bestimmt in render3d die Default-Einfärbung). */
|
/** Art eines rohen Kontext-Meshes (bestimmt in render3d die Default-Einfärbung). */
|
||||||
|
|||||||
@@ -137,7 +137,15 @@ function closedRiserOutline(
|
|||||||
* `ceilingId` trägt hier die Treppen-Id (nur TS-seitiges Tagging; render3d ignoriert
|
* `ceilingId` trägt hier die Treppen-Id (nur TS-seitiges Tagging; render3d ignoriert
|
||||||
* das Feld, und der Pick läuft separat über `pickGeometry`).
|
* das Feld, und der Pick läuft separat über `pickGeometry`).
|
||||||
*/
|
*/
|
||||||
export function emitStairs(project: Project): RSlab[] {
|
export function emitStairs(
|
||||||
|
project: Project,
|
||||||
|
/**
|
||||||
|
* `forSection`: auch gerade Betontreppen als Tritt-Prismen liefern (deren
|
||||||
|
* glatte Laufplatte ist im 3D ein Mesh, das der Schnitt-Extraktor nicht
|
||||||
|
* schneiden kann — ohne diese Näherung fehlte die Treppe im Schnitt ganz).
|
||||||
|
*/
|
||||||
|
opts: { forSection?: boolean } = {},
|
||||||
|
): RSlab[] {
|
||||||
const out: RSlab[] = [];
|
const out: RSlab[] = [];
|
||||||
for (const stair of project.stairs ?? []) {
|
for (const stair of project.stairs ?? []) {
|
||||||
const { zBottom, zTop } = stairVerticalExtent(project, stair);
|
const { zBottom, zTop } = stairVerticalExtent(project, stair);
|
||||||
@@ -148,10 +156,13 @@ export function emitStairs(project: Project): RSlab[] {
|
|||||||
const structure = st?.structure ?? "massiv";
|
const structure = st?.structure ?? "massiv";
|
||||||
// Gerade Betontreppe: die GLATTE Laufplatte kommt als echtes Mesh
|
// Gerade Betontreppe: die GLATTE Laufplatte kommt als echtes Mesh
|
||||||
// (emitStairMeshes) — hier keine Slab-Näherung emittieren (sonst doppelt).
|
// (emitStairMeshes) — hier keine Slab-Näherung emittieren (sonst doppelt).
|
||||||
if (structure === "beton" && stair.shape === "straight") continue;
|
if (structure === "beton" && stair.shape === "straight" && !opts.forSection) continue;
|
||||||
const treadThickness = st?.treadThickness ?? 0.04;
|
const treadThickness = st?.treadThickness ?? 0.04;
|
||||||
const riser = geo.riserHeight;
|
const riser = geo.riserHeight;
|
||||||
const open = structure !== "massiv";
|
const open = structure !== "massiv";
|
||||||
|
// Massiv/Beton = EIN Körper: die Tritt-Prismen verschmelzen im Schnitt
|
||||||
|
// (keine Nähte zwischen den Tritten, s. render3d `SlabInput::monolith`).
|
||||||
|
const monolith = structure === "massiv" || structure === "beton" ? stair.id : undefined;
|
||||||
const nosing = open ? st?.nosing ?? 0 : 0;
|
const nosing = open ? st?.nosing ?? 0 : 0;
|
||||||
const neighborPts = geo.treads.map((t) => t.pts);
|
const neighborPts = geo.treads.map((t) => t.pts);
|
||||||
for (let k = 0; k < geo.treads.length; k++) {
|
for (let k = 0; k < geo.treads.length; k++) {
|
||||||
@@ -172,6 +183,7 @@ export function emitStairs(project: Project): RSlab[] {
|
|||||||
zTop: top,
|
zTop: top,
|
||||||
color: STAIR_RGB,
|
color: STAIR_RGB,
|
||||||
ceilingId: stair.id,
|
ceilingId: stair.id,
|
||||||
|
monolith,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (open && st?.closedRisers) {
|
if (open && st?.closedRisers) {
|
||||||
@@ -188,12 +200,16 @@ export function emitStairs(project: Project): RSlab[] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (geo.landing && geo.landing.length >= 3) {
|
if (geo.landing && geo.landing.length >= 3) {
|
||||||
|
const landingTop = zBottom + totalRise * 0.5;
|
||||||
out.push({
|
out.push({
|
||||||
outline: geo.landing.map((p) => [p.x, p.y] as RVec2),
|
outline: geo.landing.map((p) => [p.x, p.y] as RVec2),
|
||||||
zBottom,
|
// Betontreppe: Podest als Platte (wie die Laufplatte), kein Vollblock
|
||||||
zTop: zBottom + totalRise * 0.5,
|
// bis zum Boden; massiv bleibt Vollkörper.
|
||||||
|
zBottom: structure === "beton" ? Math.max(zBottom, landingTop - riser - CONCRETE_WAIST) : zBottom,
|
||||||
|
zTop: landingTop,
|
||||||
color: STAIR_RGB,
|
color: STAIR_RGB,
|
||||||
ceilingId: stair.id,
|
ceilingId: stair.id,
|
||||||
|
monolith,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user