[K3c][K3d] Grundriss-Unterlage unter Schnitt/Ansicht im Kern (planUnderlay.ts gelöscht)
Abfrage planUnderlay liest den Grundriss aus den Plan-Caches, bildet ihn ab, dimmt, entfernt Auswahl-Ids und hängt die Schnittlinie an. Gleichheit gegen TS: 456 Fälle, 142 405 Primitive.
This commit is contained in:
13 files changed
+457
-298
No files matched your search
@@ -54,6 +54,7 @@ export type QueryName =
|
||||
| "drawingLines"
|
||||
| "drawingPrims"
|
||||
| "levelMarkers"
|
||||
| "planUnderlay"
|
||||
| "sectionPlan"
|
||||
| "elevationPlan"
|
||||
| "modelJson";
|
||||
|
||||
+1
-1
@@ -241,7 +241,7 @@ export {
|
||||
export {
|
||||
crossKindOverlayAllowed,
|
||||
planUnderlayPrimitives,
|
||||
} from "../plan/planUnderlay";
|
||||
} from "../plan/generatePlan";
|
||||
|
||||
export {
|
||||
type Bounds,
|
||||
|
||||
@@ -917,7 +917,7 @@ export type DrawingLevel = {
|
||||
/**
|
||||
* Grundriss-Unterlage (nur Schnitt/Ansicht): ID eines Geschosses, dessen
|
||||
* Grundriss AUSGERICHTET unter dem Schnitt/der Ansicht gezeigt wird (Schnitt-
|
||||
* linie waagrecht, Blickrichtung nach oben, s. `plan/planUnderlay.ts`).
|
||||
* linie waagrecht, Blickrichtung nach oben, s. Kern `plan/underlay.rs`).
|
||||
* Fehlt ⇒ keine Unterlage.
|
||||
*/
|
||||
planUnderlayId?: string;
|
||||
|
||||
+71
-11
@@ -20,6 +20,8 @@ import type {
|
||||
ContextImage,
|
||||
ContextObject,
|
||||
Drawing2D,
|
||||
DrawingLevel,
|
||||
DrawingLevelKind,
|
||||
Project,
|
||||
Vec2,
|
||||
} from "../model/types";
|
||||
@@ -446,6 +448,74 @@ const MAX_CHUNK_STORES = 16;
|
||||
|
||||
const DETAIL_CODE: Record<DetailLevel, number> = { grob: 0, mittel: 1, fein: 2 };
|
||||
|
||||
/** Argumente der Kern-Abfrage `planDomains` (auch `planUnderlay`). */
|
||||
function planDomainsArgs(
|
||||
floorId: string,
|
||||
visibleCodes: Set<string>,
|
||||
categoryDisplay: CategoryDisplayResolver,
|
||||
referenceLines: boolean,
|
||||
global: boolean,
|
||||
scale: number,
|
||||
forPrint: boolean,
|
||||
compact: boolean,
|
||||
mono: boolean,
|
||||
sunWhen: number,
|
||||
): Record<string, unknown> {
|
||||
// Sichtbar und gezeichnet bzw. gedimmt: über die sichtbaren Codes (wenige), nicht über alle
|
||||
// Elemente — der Kern zeichnet ein Element genau dann, wenn sein Code in `show` steht.
|
||||
const show: string[] = [];
|
||||
const grey: string[] = [];
|
||||
for (const c of visibleCodes) {
|
||||
const d = categoryDisplay(c);
|
||||
if (!d.render) continue;
|
||||
show.push(c);
|
||||
if (d.greyed) grey.push(c);
|
||||
}
|
||||
return { floor: floorId, show, grey, referenceLines, global, scale, forPrint, compact, mono, sunWhen: Number.isNaN(sunWhen) ? null : sunWhen };
|
||||
}
|
||||
|
||||
/**
|
||||
* Grundriss-Unterlage in Schnitt/Ansicht aus dem Kern (`plan/underlay.rs`, früher `planUnderlay.ts`):
|
||||
* der Grundriss des Geschosses `floorId` (wie `generatePlan` ohne projektglobale Zutaten, aus den
|
||||
* Plan-Caches) AUSGERICHTET unter die Schnitt-/Ansichtsfläche gelegt, deren tiefste Kante bei
|
||||
* `sectionMinY` liegt — Schnittlinie waagrecht, Blickrichtung im Blatt nach oben, u-Achse wie im
|
||||
* Schnitt. Gedimmt, ohne Auswahl-Ids (fremde Projektion), plus die Schnittlinie (strichpunktiert).
|
||||
*/
|
||||
export function planUnderlayPrimitives(
|
||||
project: Project,
|
||||
level: DrawingLevel,
|
||||
floorId: string,
|
||||
sectionMinY: number,
|
||||
visibleCodes: Set<string>,
|
||||
categoryDisplay: CategoryDisplayResolver = SHOW_ALL,
|
||||
detail: DetailLevel = "mittel",
|
||||
showReferenceLines = false,
|
||||
mono = false,
|
||||
scaleDenominator: number = DEFAULT_SCALE_DENOMINATOR,
|
||||
): Primitive[] {
|
||||
const args = planDomainsArgs(floorId, visibleCodes, categoryDisplay, showReferenceLines, false, scaleDenominator, false, false, mono, NaN);
|
||||
const text = JSON.stringify({ ...args, level: { kind: level.kind, linePoints: level.linePoints, directionSign: level.directionSign }, minY: sectionMinY });
|
||||
return decodePlanBuf(documentFor(project).queryBin("planUnderlay", [DETAIL_CODE[detail] ?? 1], text)).prims;
|
||||
}
|
||||
|
||||
/**
|
||||
* Welche Fremd-Art-Ebene darf als Unterlage in welcher aktiven Ebene erscheinen?
|
||||
* Massgebend ist der Koordinatenraum: Geschoss und freie Zeichnung teilen X/Y,
|
||||
* Schnitte/Ansichten messen dagegen Länge×Höhe entlang IHRER Linie. Ein Schnitt
|
||||
* im Grundriss (oder ein Grundriss/eine andere Ansicht im Schnitt) lag darum
|
||||
* nur zufällig irgendwo und überdeckte den eigentlichen Plan (Nutzer-Report
|
||||
* 2026-10-20: Fenster der Ansicht im EG-Grundriss, Raumstempel im Schnitt).
|
||||
* • freie Zeichnung: alles (Kalkierpapier zum Abzeichnen, Nutzer-Wunsch).
|
||||
* • Geschoss: nur freie Zeichnungen (gleicher X/Y-Raum).
|
||||
* • Schnitt/Ansicht: nichts — ein Grundriss kommt dort ausgerichtet über
|
||||
* `DrawingLevel.planUnderlayId` dazu (s. {@link planUnderlayPrimitives}).
|
||||
*/
|
||||
export function crossKindOverlayAllowed(active: DrawingLevelKind, other: DrawingLevelKind): boolean {
|
||||
if (active === "drawing") return true;
|
||||
if (active === "floor") return other === "drawing";
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Grundriss eines Geschosses aus dem Kern: Decken, Dächer, Räume, Wände mit Öffnungen, Treppen,
|
||||
* Stützen, 2D-Zeichnungen, Extrusions-Umrisse und (mit `global`) Schatten, Baurecht, Kontext-Konturen
|
||||
@@ -468,17 +538,7 @@ function planDomains(
|
||||
/** Zeitpunkt der Schattenstudie (Unix-ms, NaN = keiner). */
|
||||
sunWhen: number,
|
||||
): DomainPrims {
|
||||
// Sichtbar und gezeichnet bzw. gedimmt: über die sichtbaren Codes (wenige), nicht über alle
|
||||
// Elemente — der Kern zeichnet ein Element genau dann, wenn sein Code in `show` steht.
|
||||
const show: string[] = [];
|
||||
const grey: string[] = [];
|
||||
for (const c of visibleCodes) {
|
||||
const d = categoryDisplay(c);
|
||||
if (!d.render) continue;
|
||||
show.push(c);
|
||||
if (d.greyed) grey.push(c);
|
||||
}
|
||||
const args = JSON.stringify({ floor: floorId, show, grey, referenceLines, global, scale, forPrint, compact, mono, sunWhen: Number.isNaN(sunWhen) ? null : sunWhen });
|
||||
const args = JSON.stringify(planDomainsArgs(floorId, visibleCodes, categoryDisplay, referenceLines, global, scale, forPrint, compact, mono, sunWhen));
|
||||
const held = chunkStores.get(args);
|
||||
const query = held && held.size ? `${args.slice(0, -1)},"have":[${[...held.keys()].join(",")}]}` : args;
|
||||
const res = readPlanMulti(documentFor(project).queryBin("planDomains", [DETAIL_CODE[detail] ?? 1], query), held);
|
||||
|
||||
@@ -165,3 +165,41 @@ describe("Ebenen ein-/ausblenden (Kataster-Performance)", () => {
|
||||
expect(lineHash(generatePlan(recolored, "L1", vis(["60"])))).not.toBe(first);
|
||||
});
|
||||
});
|
||||
|
||||
// Grundriss-Unterlage unter Schnitt/Ansicht (Kern `plan/underlay.rs`; Rechnung dort getestet).
|
||||
import { crossKindOverlayAllowed, planUnderlayPrimitives } from "./generatePlan";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
|
||||
describe("planUnderlayPrimitives (Kern)", () => {
|
||||
it("Grundriss gedimmt, ohne Auswahl-Ids, unter dem Schnitt, plus Schnittlinie", () => {
|
||||
const sec = sampleProject.drawingLevels.find((l) => l.kind === "section")!;
|
||||
const eg = sampleProject.drawingLevels.find((l) => l.kind === "floor")!;
|
||||
const codes = new Set(sampleProject.layers.map((l) => l.code));
|
||||
const out = planUnderlayPrimitives(sampleProject, sec, eg.id, -0.3, codes);
|
||||
expect(out.length).toBeGreaterThan(10);
|
||||
const last = out[out.length - 1];
|
||||
expect(last.kind === "line" && last.cls).toBe("section-underlay-line");
|
||||
const body = out.slice(0, -1);
|
||||
expect(body.every((p) => (p as { greyed?: boolean }).greyed === true)).toBe(true);
|
||||
expect(body.some((p) => "wallId" in p || "roomId" in p || "drawingId" in p)).toBe(false);
|
||||
let top = -Infinity;
|
||||
for (const p of body) if (p.kind === "polygon") for (const q of p.pts) top = Math.max(top, q.y);
|
||||
expect(top).toBeLessThanOrEqual(-0.3 - 1.5 + 1e-9);
|
||||
// ohne Schnittlinie: nichts
|
||||
expect(planUnderlayPrimitives(sampleProject, { ...sec, linePoints: undefined }, eg.id, 0, codes)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("crossKindOverlayAllowed", () => {
|
||||
it("nur Ebenen im selben Koordinatenraum überlagern sich", () => {
|
||||
expect(crossKindOverlayAllowed("floor", "drawing")).toBe(true);
|
||||
expect(crossKindOverlayAllowed("floor", "section")).toBe(false);
|
||||
expect(crossKindOverlayAllowed("floor", "elevation")).toBe(false);
|
||||
expect(crossKindOverlayAllowed("section", "floor")).toBe(false);
|
||||
expect(crossKindOverlayAllowed("elevation", "section")).toBe(false);
|
||||
expect(crossKindOverlayAllowed("section", "drawing")).toBe(false);
|
||||
// Freie Zeichnung bleibt Kalkierpapier für alles.
|
||||
expect(crossKindOverlayAllowed("drawing", "section")).toBe(true);
|
||||
expect(crossKindOverlayAllowed("drawing", "floor")).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,96 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { DrawingLevel } from "../model/types";
|
||||
import type { Primitive } from "./generatePlan";
|
||||
import {
|
||||
PLAN_UNDERLAY_GAP_M,
|
||||
crossKindOverlayAllowed,
|
||||
mapPlanPoint,
|
||||
planToSectionMap,
|
||||
planUnderlayPrimitives,
|
||||
} from "./planUnderlay";
|
||||
import { sectionPlaneFromLevel, sectionUAxisModel } from "./toSection";
|
||||
|
||||
const level = (p0: { x: number; y: number }, p1: { x: number; y: number }, sign: 1 | -1 = 1): DrawingLevel => ({
|
||||
id: "s",
|
||||
name: "S",
|
||||
kind: "section",
|
||||
visible: true,
|
||||
locked: false,
|
||||
linePoints: [p0, p1],
|
||||
directionSign: sign,
|
||||
});
|
||||
|
||||
const line = (a: { x: number; y: number }, b: { x: number; y: number }): Primitive => ({
|
||||
kind: "line",
|
||||
a,
|
||||
b,
|
||||
cls: "t",
|
||||
weightMm: 0.25,
|
||||
});
|
||||
|
||||
describe("planToSectionMap", () => {
|
||||
it("u stimmt mit der Schnitt-u-Achse überein (Punkt liegt senkrecht unter seiner Projektion)", () => {
|
||||
for (const [lv, p] of [
|
||||
[level({ x: -1, y: 2 }, { x: 12, y: 2 }), { x: 4, y: 7 }],
|
||||
[level({ x: 3, y: 0 }, { x: 3, y: 9 }, -1), { x: 6, y: 2 }],
|
||||
[level({ x: 0, y: 0 }, { x: 5, y: 5 }), { x: 1, y: 3 }],
|
||||
] as const) {
|
||||
const m = planToSectionMap(lv)!;
|
||||
const plane = sectionPlaneFromLevel(lv)!;
|
||||
const uAx = sectionUAxisModel(plane);
|
||||
const len = Math.hypot(uAx.x, uAx.y);
|
||||
const uExpected = ((p.x - plane.point[0]) * uAx.x + (p.y - plane.point[2]) * uAx.y) / len;
|
||||
expect(mapPlanPoint(m, p).x).toBeCloseTo(uExpected, 9);
|
||||
}
|
||||
});
|
||||
|
||||
it("Blickrichtung zeigt im Blatt nach oben, keine Spiegelung", () => {
|
||||
// Linie entlang +x, Blick nach +y (Norden): reine Verschiebung.
|
||||
const m = planToSectionMap(level({ x: -1, y: 2 }, { x: 12, y: 2 }))!;
|
||||
expect(m.theta).toBeCloseTo(0, 12);
|
||||
const q = mapPlanPoint(m, { x: 0, y: 5 });
|
||||
expect(q.x).toBeCloseTo(1, 12);
|
||||
expect(q.y).toBeCloseTo(3, 12); // 3 m hinter der Linie → 3 m nach oben
|
||||
// Umgekehrte Blickrichtung: 180°-Drehung (Determinante +1).
|
||||
const r = planToSectionMap(level({ x: -1, y: 2 }, { x: 12, y: 2 }, -1))!;
|
||||
expect(Math.abs(r.theta)).toBeCloseTo(Math.PI, 12);
|
||||
expect(mapPlanPoint(r, { x: 0, y: 0 }).y).toBeCloseTo(2, 12);
|
||||
});
|
||||
|
||||
it("ohne Linie keine Abbildung", () => {
|
||||
expect(planToSectionMap({ ...level({ x: 0, y: 0 }, { x: 1, y: 0 }), linePoints: undefined })).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("planUnderlayPrimitives", () => {
|
||||
it("legt den Grundriss mit Abstand unter den Schnitt, gedimmt, plus Schnittlinie", () => {
|
||||
const lv = level({ x: -1, y: 2 }, { x: 12, y: 2 });
|
||||
const out = planUnderlayPrimitives(lv, [line({ x: 0, y: 0 }, { x: 11, y: 6 })], -0.3);
|
||||
const mapped = out[0] as Extract<Primitive, { kind: "line" }>;
|
||||
expect(mapped.greyed).toBe(true);
|
||||
// Oberste Grundriss-Kante (y = 6 → w = 4) liegt GAP unter der Schnitt-Unterkante.
|
||||
const top = Math.max(mapped.a.y, mapped.b.y);
|
||||
expect(top).toBeCloseTo(-0.3 - PLAN_UNDERLAY_GAP_M, 9);
|
||||
// u bleibt erhalten (x − (−1)).
|
||||
expect(Math.min(mapped.a.x, mapped.b.x)).toBeCloseTo(1, 9);
|
||||
const cut = out[out.length - 1] as Extract<Primitive, { kind: "line" }>;
|
||||
expect(cut.cls).toBe("section-underlay-line");
|
||||
expect(cut.b.x - cut.a.x).toBeCloseTo(13, 9);
|
||||
// Schnittlinie liegt 4 m unter der obersten Grundriss-Kante (w = 0).
|
||||
expect(cut.a.y).toBeCloseTo(top - 4, 9);
|
||||
});
|
||||
});
|
||||
|
||||
describe("crossKindOverlayAllowed", () => {
|
||||
it("nur Ebenen im selben Koordinatenraum überlagern sich", () => {
|
||||
expect(crossKindOverlayAllowed("floor", "drawing")).toBe(true);
|
||||
expect(crossKindOverlayAllowed("floor", "section")).toBe(false);
|
||||
expect(crossKindOverlayAllowed("floor", "elevation")).toBe(false);
|
||||
expect(crossKindOverlayAllowed("section", "floor")).toBe(false);
|
||||
expect(crossKindOverlayAllowed("elevation", "section")).toBe(false);
|
||||
expect(crossKindOverlayAllowed("section", "drawing")).toBe(false);
|
||||
// Freie Zeichnung bleibt Kalkierpapier für alles.
|
||||
expect(crossKindOverlayAllowed("drawing", "section")).toBe(true);
|
||||
expect(crossKindOverlayAllowed("drawing", "floor")).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,184 +0,0 @@
|
||||
// Grundriss-Unterlage in Schnitt/Ansicht: ein Geschoss-Grundriss wird
|
||||
// AUSGERICHTET unter die Schnitt-/Ansichtsfläche gelegt — wie die klassische
|
||||
// Konstruktion "Ansicht über dem Grundriss". Die Schnittlinie wird dazu
|
||||
// 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`, 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) —
|
||||
// Kreise bleiben Kreise, Bögen behalten ihren Drehsinn.
|
||||
|
||||
import type { DrawingLevel, DrawingLevelKind, Vec2 } from "../model/types";
|
||||
import type { Primitive } from "./generatePlan";
|
||||
|
||||
/** Abstand (Meter) zwischen tiefster Schnitt-/Ansichtskante und Grundriss-Oberkante. */
|
||||
export const PLAN_UNDERLAY_GAP_M = 1.5;
|
||||
|
||||
/** Abbildung Grundriss (Modell x/y) → Schnitt-Blatt (u, Höhe). */
|
||||
export interface PlanToSectionMap {
|
||||
/** Ursprung = Startpunkt der Schnittlinie. */
|
||||
p0: Vec2;
|
||||
/** Horizontale Schnitt-u-Achse im Grundriss (Blickrichtungs-RECHTS). */
|
||||
u: Vec2;
|
||||
/** Blickrichtung im Grundriss (Einheit). */
|
||||
n: Vec2;
|
||||
/** Drehwinkel (Radiant, CCW) der Abbildung. */
|
||||
theta: number;
|
||||
/** Vertikaler Versatz im Blatt. */
|
||||
dy: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut die Abbildung aus der Schnitt-/Ansichtslinie einer Ebene (`null` ohne
|
||||
* Linie). `dy` bleibt 0 — der Aufrufer schiebt den Grundriss danach unter den
|
||||
* Schnitt (s. {@link planUnderlayPrimitives}).
|
||||
*/
|
||||
export function planToSectionMap(level: DrawingLevel): PlanToSectionMap | null {
|
||||
const line = level.linePoints;
|
||||
if (!line) return null;
|
||||
const [p0, p1] = line;
|
||||
const len = Math.hypot(p1.x - p0.x, p1.y - p0.y);
|
||||
if (len < 1e-9) return null;
|
||||
const dx = (p1.x - p0.x) / len;
|
||||
const dy = (p1.y - p0.y) / len;
|
||||
const sign = level.directionSign ?? 1;
|
||||
// Wie `sectionPlaneFromLevel`: Links-Normale der Linie, per directionSign gedreht.
|
||||
const n: Vec2 = { x: -dy * sign, y: dx * sign };
|
||||
// Wie `sectionUAxisModel`: u = (n.y, −n.x) — Blickrichtungs-RECHTS.
|
||||
const u: Vec2 = { x: n.y, y: -n.x };
|
||||
// Bild der x-Achse (1,0) ist (u.x, n.x) → cosθ = u.x, sinθ = n.x.
|
||||
return { p0, u, n, theta: Math.atan2(n.x, u.x), dy: 0 };
|
||||
}
|
||||
|
||||
/** Bildet einen Grundriss-Punkt ins Schnitt-Blatt ab. */
|
||||
export function mapPlanPoint(m: PlanToSectionMap, p: Vec2): Vec2 {
|
||||
const rx = p.x - m.p0.x;
|
||||
const ry = p.y - m.p0.y;
|
||||
return { x: rx * m.u.x + ry * m.u.y, y: rx * m.n.x + ry * m.n.y + m.dy };
|
||||
}
|
||||
|
||||
/**
|
||||
* Bildet ein Plan-Primitiv ab. Achsparallele Rasterbilder lassen sich nicht
|
||||
* drehen und entfallen (`null`) — ausser die Abbildung ist eine reine
|
||||
* Verschiebung.
|
||||
*/
|
||||
export function mapPlanPrimitive(m: PlanToSectionMap, pr: Primitive): Primitive | null {
|
||||
const P = (p: Vec2) => mapPlanPoint(m, p);
|
||||
switch (pr.kind) {
|
||||
case "polygon": {
|
||||
const hatch = pr.hatch.origin || m.theta !== 0
|
||||
? {
|
||||
...pr.hatch,
|
||||
// SVG-Musterwinkel dreht im Uhrzeigersinn (Bildschirm) = −Winkel im Modell.
|
||||
angle: pr.hatch.angle - (m.theta * 180) / Math.PI,
|
||||
origin: pr.hatch.origin ? P(pr.hatch.origin) : undefined,
|
||||
}
|
||||
: pr.hatch;
|
||||
return { ...pr, pts: pr.pts.map(P), hatch };
|
||||
}
|
||||
case "line":
|
||||
// `motif` ist im Strich-lokalen Raum definiert — dreht mit der Linie mit.
|
||||
return { ...pr, a: P(pr.a), b: P(pr.b) };
|
||||
case "arc":
|
||||
return { ...pr, center: P(pr.center), from: P(pr.from), to: P(pr.to) };
|
||||
case "text":
|
||||
return { ...pr, at: P(pr.at) };
|
||||
case "drawingText":
|
||||
return { ...pr, at: P(pr.at), angle: pr.angle + m.theta };
|
||||
case "drawingTextPath":
|
||||
return { ...pr, pathPts: pr.pathPts.map(P) };
|
||||
case "drawingCircle":
|
||||
return { ...pr, center: P(pr.center) };
|
||||
case "drawingArc":
|
||||
return { ...pr, center: P(pr.center), a0: pr.a0 + m.theta, a1: pr.a1 + m.theta };
|
||||
case "drawingImage": {
|
||||
if (Math.abs(m.theta) > 1e-9) return null;
|
||||
const a = P(pr.min);
|
||||
const b = P(pr.max);
|
||||
return {
|
||||
...pr,
|
||||
min: { x: Math.min(a.x, b.x), y: Math.min(a.y, b.y) },
|
||||
max: { x: Math.max(a.x, b.x), y: Math.max(a.y, b.y) },
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Alle Stützpunkte eines Primitivs (für die Höhenlage der Unterlage). */
|
||||
function primitivePoints(pr: Primitive): Vec2[] {
|
||||
switch (pr.kind) {
|
||||
case "polygon": return pr.pts;
|
||||
case "line": return [pr.a, pr.b];
|
||||
case "arc": return [pr.from, pr.to, pr.center];
|
||||
case "text":
|
||||
case "drawingText": return [pr.at];
|
||||
case "drawingTextPath": return pr.pathPts;
|
||||
case "drawingCircle":
|
||||
case "drawingArc":
|
||||
return [{ x: pr.center.x, y: pr.center.y + pr.r }];
|
||||
case "drawingImage": return [pr.min, pr.max];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Legt die Grundriss-Primitive `planPrims` ausgerichtet unter einen Schnitt/
|
||||
* eine Ansicht, deren tiefste Kante bei `sectionMinY` liegt. Die Unterlage ist
|
||||
* gedimmt (Referenz) und trägt zusätzlich die Schnittlinie selbst (strichpunk-
|
||||
* tiert), damit sichtbar ist, wo geschnitten bzw. von wo geblickt wird.
|
||||
*/
|
||||
export function planUnderlayPrimitives(
|
||||
level: DrawingLevel,
|
||||
planPrims: Primitive[],
|
||||
sectionMinY: number,
|
||||
): Primitive[] {
|
||||
const base = planToSectionMap(level);
|
||||
if (!base) return [];
|
||||
const mapped: Primitive[] = [];
|
||||
let maxY = -Infinity;
|
||||
for (const pr of planPrims) {
|
||||
const q = mapPlanPrimitive(base, pr);
|
||||
if (!q) continue;
|
||||
for (const p of primitivePoints(q)) if (p.y > maxY) maxY = p.y;
|
||||
mapped.push(q);
|
||||
}
|
||||
// Schnittlinie (w = 0) liegt immer mit in der Unterlage.
|
||||
if (0 > maxY) maxY = 0;
|
||||
const shift = sectionMinY - PLAN_UNDERLAY_GAP_M - maxY;
|
||||
const out: Primitive[] = [];
|
||||
for (const q of mapped) {
|
||||
const moved = mapPlanPrimitive({ p0: { x: 0, y: 0 }, u: { x: 1, y: 0 }, n: { x: 0, y: 1 }, theta: 0, dy: shift }, q);
|
||||
if (moved) out.push({ ...moved, greyed: true } as Primitive);
|
||||
}
|
||||
const [l0, l1] = level.linePoints!;
|
||||
const len = Math.hypot(l1.x - l0.x, l1.y - l0.y);
|
||||
out.push({
|
||||
kind: "line",
|
||||
a: { x: 0, y: shift },
|
||||
b: { x: len, y: shift },
|
||||
cls: "section-underlay-line",
|
||||
weightMm: 0.25,
|
||||
dash: [3, 0.8, 0.4, 0.8],
|
||||
color: "#8a3b2c",
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Welche Fremd-Art-Ebene darf als Unterlage in welcher aktiven Ebene erscheinen?
|
||||
* Massgebend ist der Koordinatenraum: Geschoss und freie Zeichnung teilen X/Y,
|
||||
* Schnitte/Ansichten messen dagegen Länge×Höhe entlang IHRER Linie. Ein Schnitt
|
||||
* im Grundriss (oder ein Grundriss/eine andere Ansicht im Schnitt) lag darum
|
||||
* nur zufällig irgendwo und überdeckte den eigentlichen Plan (Nutzer-Report
|
||||
* 2026-10-20: Fenster der Ansicht im EG-Grundriss, Raumstempel im Schnitt).
|
||||
* • freie Zeichnung: alles (Kalkierpapier zum Abzeichnen, Nutzer-Wunsch).
|
||||
* • Geschoss: nur freie Zeichnungen (gleicher X/Y-Raum).
|
||||
* • Schnitt/Ansicht: nichts — ein Grundriss kommt dort ausgerichtet über
|
||||
* `DrawingLevel.planUnderlayId` dazu (s. plan/planUnderlay.ts).
|
||||
*/
|
||||
export function crossKindOverlayAllowed(active: DrawingLevelKind, other: DrawingLevelKind): boolean {
|
||||
if (active === "drawing") return true;
|
||||
if (active === "floor") return other === "drawing";
|
||||
return false;
|
||||
}
|
||||
@@ -1120,7 +1120,7 @@ function SectionPlanView({
|
||||
const rawPlan = isElevation ? elevationPlan : sectionPlan;
|
||||
// Grundriss-Unterlage (Nutzer-Wunsch: "in der Ansicht auch mal einen
|
||||
// Grundriss zeigen können"): das in `level.planUnderlayId` gewählte Geschoss
|
||||
// AUSGERICHTET unter dem Schnitt/der Ansicht (s. plan/planUnderlay.ts) —
|
||||
// AUSGERICHTET unter dem Schnitt/der Ansicht (Kern `plan/underlay.rs`) —
|
||||
// nicht mehr jede sichtbare Ebene lose übereinander (die lag in einem
|
||||
// fremden Koordinatenraum und verdeckte den Schnitt).
|
||||
const underlayFloor = project.drawingLevels.find(
|
||||
@@ -1129,18 +1129,19 @@ function SectionPlanView({
|
||||
const sectionMinY = rawPlan?.bounds.minY;
|
||||
const overlayPrimitives = useMemo(() => {
|
||||
if (!underlayFloor || sectionMinY === undefined) return [];
|
||||
const floorPlan = generatePlan(
|
||||
// Der Kern legt den Grundriss (aus seinen Plan-Caches) gedimmt und ohne Auswahl-Ids darunter.
|
||||
return planUnderlayPrimitives(
|
||||
project,
|
||||
level,
|
||||
underlayFloor.id,
|
||||
sectionMinY,
|
||||
visibleCodes,
|
||||
categoryDisplay,
|
||||
detail,
|
||||
referenceLines,
|
||||
mono,
|
||||
false,
|
||||
scaleDenominator,
|
||||
);
|
||||
return planUnderlayPrimitives(level, floorPlan.primitives, sectionMinY).map(stripSelectableIds);
|
||||
}, [underlayFloor, sectionMinY, project, level, visibleCodes, categoryDisplay, detail, referenceLines, mono, scaleDenominator]);
|
||||
// Eigene 2D-Elemente des Schnitts/der Ansicht (Bemassung, Höhenkoten,
|
||||
// Beschriftung, Ergänzungslinien …): liegen in `drawings2d` mit
|
||||
|
||||
Reference in new issue
Block a user