Merge branch 'worktree-agent-aebf63e662f6398f6' into claude/practical-noether-1hb2s1
# Conflicts: # TODO.md # src-tauri/core/src/plan/context.rs
This commit is contained in:
16 files changed
+1459
-76
No files matched your search
@@ -1,5 +1,5 @@
|
||||
// Kontext-Schicht im Grundriss (generatePlan → addContextContours):
|
||||
// • ImportedMesh (Gebäude) -> Sockelkanten-Fussabdruck (context-line).
|
||||
// • ImportedMesh -> [152] im Geschoss nach Ansichtsbereich: Schnittfläche, Aufsicht (mesh-view), Überkopf gestrichelt.
|
||||
// • TerrainMesh -> nur 2D-Bounding-Box-Umriss (4 Linien).
|
||||
// • Nutzer-Report: importierte Gebäude waren im Plan UNSICHTBAR (nur 3D).
|
||||
|
||||
@@ -37,58 +37,44 @@ function contextLines(p: Project) {
|
||||
);
|
||||
}
|
||||
|
||||
describe("generatePlan — Kontext-Fussabdruck (ImportedMesh)", () => {
|
||||
it("zeichnet die Sockelkanten eines importierten Gebäudes als context-line", () => {
|
||||
// Ein simpler Quader-„Bau": Grundfläche 0..2 × 0..3 bei z=0 (Sockel), Dach
|
||||
// bei z=5. Zwei Sockel-Dreiecke bilden das Boden-Rechteck.
|
||||
const p = projectWith([
|
||||
{
|
||||
id: "B1",
|
||||
type: "importedMesh",
|
||||
name: "Haus",
|
||||
positions: [
|
||||
0, 0, 0, 2, 0, 0, 2, 3, 0, 0, 3, 0, // 0..3: Boden (z=0)
|
||||
1, 1, 5, // 4: Dachspitze (z=5, über der Toleranz)
|
||||
],
|
||||
indices: [
|
||||
0, 1, 2, 0, 2, 3, // Boden (Sockel)
|
||||
0, 1, 4, // Dachdreieck (nur eine Kante 0-1 am Sockel, 4 ist hoch)
|
||||
],
|
||||
},
|
||||
]);
|
||||
const lines = contextLines(p);
|
||||
// Sockelkanten: Rechteck-Umriss 0-1,1-2,2-3,3-0 + Diagonale 0-2 = 5 eindeutige.
|
||||
// Die hohen Dach-Kanten (0-4, 1-4) fallen weg (z=5 > Toleranz).
|
||||
expect(lines.length).toBe(5);
|
||||
// Keine Linie berührt die Dachspitze (1,1) auf z-Höhe — aber XY (1,1) könnte
|
||||
// von der Diagonale getroffen werden; hier prüfen wir, dass keine Kante zu
|
||||
// einem Punkt führt, dessen Original-z über der Toleranz lag: alle Endpunkte
|
||||
// liegen im Boden-Rechteck [0..2]×[0..3].
|
||||
for (const l of lines) {
|
||||
if (l.kind !== "line") continue;
|
||||
for (const pt of [l.a, l.b]) {
|
||||
expect(pt.x).toBeGreaterThanOrEqual(0);
|
||||
expect(pt.x).toBeLessThanOrEqual(2);
|
||||
expect(pt.y).toBeGreaterThanOrEqual(0);
|
||||
expect(pt.y).toBeLessThanOrEqual(3);
|
||||
}
|
||||
}
|
||||
/** [152] Aufsichts-/Überkopf-Linien importierter Netze im Geschoss. */
|
||||
function meshLines(p: Project, codes: Set<string> = visible) {
|
||||
return generatePlan(p, "eg", codes).primitives.filter(
|
||||
(pr) => pr.kind === "line" && (pr as { cls?: string }).cls === "mesh-view",
|
||||
);
|
||||
}
|
||||
|
||||
/** Quader [0..2]×[0..3]×[z0..z1] (12 Dreiecke, Aussennormalen). */
|
||||
function box(z0: number, z1: number) {
|
||||
const positions: number[] = [];
|
||||
for (let k = 0; k < 8; k++) positions.push(k & 1 ? 2 : 0, k & 2 ? 3 : 0, k & 4 ? z1 : z0);
|
||||
const quads = [[0, 2, 3, 1], [4, 5, 7, 6], [0, 1, 5, 4], [2, 6, 7, 3], [0, 4, 6, 2], [1, 3, 7, 5]];
|
||||
const indices = quads.flatMap((q) => [q[0], q[1], q[2], q[0], q[2], q[3]]);
|
||||
return { positions, indices };
|
||||
}
|
||||
|
||||
describe("generatePlan — importierte Netze im Grundriss ([152])", () => {
|
||||
it("ein Gebäude durch die Schnitthöhe wird geschnitten (Poché, anwählbar)", () => {
|
||||
const p = projectWith([{ id: "B1", type: "importedMesh", name: "Haus", ...box(0, 5) }]);
|
||||
const cut = generatePlan(p, "eg", visible).primitives.filter((pr) => pr.kind === "polygon" && pr.contextObjectId === "B1" && pr.fill !== "none");
|
||||
expect(cut).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("entdoppelt geteilte Kanten (kein doppeltes Zeichnen)", () => {
|
||||
// Zwei Sockel-Dreiecke teilen sich die Kante 0-2 -> darf nur EINMAL erscheinen.
|
||||
const p = projectWith([
|
||||
{
|
||||
id: "B1",
|
||||
type: "importedMesh",
|
||||
name: "Haus",
|
||||
positions: [0, 0, 0, 2, 0, 0, 2, 3, 0, 0, 3, 0],
|
||||
indices: [0, 1, 2, 0, 2, 3],
|
||||
},
|
||||
]);
|
||||
const lines = contextLines(p);
|
||||
// 4 Rand + 1 geteilte Diagonale = 5 (nicht 6).
|
||||
expect(lines.length).toBe(5);
|
||||
it("eine Fläche am Boden als Aufsicht, ohne Triangulations-Diagonale", () => {
|
||||
const p = projectWith([{ id: "B1", type: "importedMesh", name: "Platte", positions: [0, 0, 0, 2, 0, 0, 2, 3, 0, 0, 3, 0], indices: [0, 1, 2, 0, 2, 3] }]);
|
||||
expect(meshLines(p)).toHaveLength(4);
|
||||
});
|
||||
|
||||
it("ein Träger über der Schnitthöhe als gestrichelte Überkopf-Linie", () => {
|
||||
const p = projectWith([{ id: "T1", type: "importedMesh", name: "Träger", ...box(2.2, 2.4) }]);
|
||||
const lines = meshLines(p);
|
||||
expect(lines).toHaveLength(4);
|
||||
expect(lines.every((l) => l.kind === "line" && Array.isArray(l.dash))).toBe(true);
|
||||
});
|
||||
|
||||
it("ein Netz des Geschosses darüber erscheint nicht", () => {
|
||||
const p = projectWith([{ id: "O1", type: "importedMesh", name: "OG", ...box(2.6, 5) }]);
|
||||
expect(generatePlan(p, "eg", visible).primitives.filter((pr) => pr.kind === "polygon" && pr.contextObjectId === "O1")).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -258,7 +244,7 @@ describe("generatePlan — Kontext-Objekte: Ebenen-Sichtbarkeit (categoryCode)",
|
||||
const p = projectWith([buildingMesh("B1", "12")]);
|
||||
const visibleWithoutBuildings = new Set<string>(["20"]); // nur Wände sichtbar
|
||||
const lines = generatePlan(p, "eg", visibleWithoutBuildings).primitives.filter(
|
||||
(pr) => pr.kind === "line" && (pr as { cls?: string }).cls === "context-line",
|
||||
(pr) => pr.kind === "line" && (pr as { cls?: string }).cls === "mesh-view",
|
||||
);
|
||||
expect(lines.length).toBe(0);
|
||||
});
|
||||
@@ -267,7 +253,7 @@ describe("generatePlan — Kontext-Objekte: Ebenen-Sichtbarkeit (categoryCode)",
|
||||
const p = projectWith([buildingMesh("B1", "12")]);
|
||||
const visibleWithBuildings = new Set<string>(["12"]);
|
||||
const lines = generatePlan(p, "eg", visibleWithBuildings).primitives.filter(
|
||||
(pr) => pr.kind === "line" && (pr as { cls?: string }).cls === "context-line",
|
||||
(pr) => pr.kind === "line" && (pr as { cls?: string }).cls === "mesh-view",
|
||||
);
|
||||
expect(lines.length).toBeGreaterThan(0);
|
||||
});
|
||||
@@ -276,7 +262,7 @@ describe("generatePlan — Kontext-Objekte: Ebenen-Sichtbarkeit (categoryCode)",
|
||||
const p = projectWith([buildingMesh("B1", undefined)]);
|
||||
const visibleEmpty = new Set<string>(); // schliesst alles Benannte aus
|
||||
const lines = generatePlan(p, "eg", visibleEmpty).primitives.filter(
|
||||
(pr) => pr.kind === "line" && (pr as { cls?: string }).cls === "context-line",
|
||||
(pr) => pr.kind === "line" && (pr as { cls?: string }).cls === "mesh-view",
|
||||
);
|
||||
expect(lines.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user