Merge [227] Kontextgebäude aufs Gelände, Baugrube im Rendering
This commit is contained in:
29 files changed
+461
-83
No files matched your search
@@ -56,6 +56,7 @@ const store = createStore<RootState>((api) => ({
|
||||
project: ProjectSlice["project"];
|
||||
activeLevelId: string;
|
||||
applyChange: ProjectSlice["applyChange"];
|
||||
groupChanges: HistorySlice["groupChanges"];
|
||||
}
|
||||
>,
|
||||
),
|
||||
|
||||
@@ -175,3 +175,44 @@ describe("Zufallsfolgen der umgestellten Aktionen", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// [227] Gebäude eines Geo-Imports (Kataster/swisstopo/OSM) stehen nach dem Hinzufügen auf dem Gelände — ein Undo-Schritt.
|
||||
describe("Geo-Import setzt Gebäude aufs Gelände", () => {
|
||||
const terrain = {
|
||||
type: "terrainMesh" as const,
|
||||
id: "gel",
|
||||
categoryCode: "02",
|
||||
name: "Gelände",
|
||||
positions: [-50, -50, -5, 50, -50, 5, 50, 50, 5, -50, 50, -5],
|
||||
indices: [0, 1, 2, 0, 2, 3],
|
||||
};
|
||||
const building = (id: string) => ({
|
||||
type: "importedMesh" as const,
|
||||
id,
|
||||
categoryCode: "12",
|
||||
name: "Gebäude",
|
||||
positions: [10, 0, 0, 20, 0, 0, 20, 6, 0, 10, 6, 0, 10, 0, 8, 20, 0, 8, 20, 6, 8, 10, 6, 8],
|
||||
indices: [0, 1, 2, 0, 2, 3, 4, 6, 5, 4, 7, 6, 0, 1, 5, 0, 5, 4, 1, 2, 6, 1, 6, 5],
|
||||
});
|
||||
const minZ = (id: string) => {
|
||||
const m = st().project.context?.find((c) => c.id === id);
|
||||
if (m?.type !== "importedMesh") throw new Error("kein Netz");
|
||||
return Math.min(...m.positions.filter((_, i) => i % 3 === 2));
|
||||
};
|
||||
|
||||
it("geo-building3d wird versetzt, ein anderer importierter Körper nicht; Undo stellt alles zurück", () => {
|
||||
st().addContextObjects([terrain]);
|
||||
st().clearHistory();
|
||||
st().addContextObjects([building("geo-building3d-x"), building("ifc-koerper")]);
|
||||
expect(minZ("geo-building3d-x")).toBeCloseTo(1, 9);
|
||||
expect(minZ("ifc-koerper")).toBe(0);
|
||||
expect(st().undoDepth).toBe(1);
|
||||
// Knopf "Aufs Gelände setzen" für das andere Netz.
|
||||
expect(st().groundContextObjects(["ifc-koerper"])).toBe(true);
|
||||
expect(minZ("ifc-koerper")).toBeCloseTo(1, 9);
|
||||
expect(st().groundContextObjects(["ifc-koerper"])).toBe(false);
|
||||
st().undo();
|
||||
st().undo();
|
||||
expect(st().project.context?.some((c) => c.id.startsWith("geo-building3d"))).toBe(false);
|
||||
});
|
||||
});
|
||||
+24
-6
@@ -10,7 +10,7 @@
|
||||
|
||||
import { generateTerrainFromContours, resmoothGridTerrain, type TerrainOptions } from "../model/terrain";
|
||||
import type { ContextObject, Drawing2D, Project, Vec2 } from "../model/types";
|
||||
import type { ImportedLine } from "../io/geoContext";
|
||||
import { isGeoBuildingMesh, type ImportedLine } from "../io/geoContext";
|
||||
import { documentFor } from "../core/document";
|
||||
import { transformOps } from "../tools/transform";
|
||||
import { addItems, fieldOps, patchItem, removeItems } from "../core/opsBuild";
|
||||
@@ -28,6 +28,11 @@ export interface SiteSlice {
|
||||
* Umrisse des Standort-Imports) als einzelne 2D-Zeichnungen auf der aktiven Ebene; ein Undo-Schritt.
|
||||
*/
|
||||
addContextObjects: (objs: ContextObject[], lines?: ImportedLine[]) => void;
|
||||
/**
|
||||
* [227] Setzt Kontextgebäude (importierte Netze) aufs Gelände: jedes Gebäude des Netzes auf den tiefsten Geländepunkt
|
||||
* unter seinem Grundriss (Kern `context_ground.rs`). true = mindestens ein Netz wurde versetzt.
|
||||
*/
|
||||
groundContextObjects: (ids: string[]) => boolean;
|
||||
/** Entfernt ein Kontext-Objekt per ID (No-op bei unbekannter ID). */
|
||||
removeContextObject: (id: string) => void;
|
||||
/** Entfernt mehrere Kontext-Objekte in EINEM Schritt (z. B. eine ganze
|
||||
@@ -83,6 +88,7 @@ type SiteSliceDeps = {
|
||||
project: Project;
|
||||
activeLevelId: string;
|
||||
applyChange: (ops: readonly CoreOp[] | ((p: Project) => readonly CoreOp[]), coalesceKey?: string) => void;
|
||||
groupChanges: (fn: () => void, key?: string) => void;
|
||||
};
|
||||
|
||||
export function createSiteSlice(
|
||||
@@ -103,11 +109,16 @@ export function createSiteSlice(
|
||||
const codes = [...added, ...drawings]
|
||||
.map((o) => o.categoryCode)
|
||||
.filter((c): c is string => !!c);
|
||||
get().applyChange((p) => [
|
||||
...addItems("context", added),
|
||||
...addItems("drawings2d", drawings),
|
||||
...fieldOps(p, "layers", ensureContextCategories(p.layers, codes)),
|
||||
]);
|
||||
// [227] Importierte Gebäude (Kataster/swisstopo/OSM) stehen auf dem Gelände, nicht auf z = 0 — im selben Undo-Schritt.
|
||||
const buildings = added.filter(isGeoBuildingMesh).map((o) => o.id);
|
||||
get().groupChanges(() => {
|
||||
get().applyChange((p) => [
|
||||
...addItems("context", added),
|
||||
...addItems("drawings2d", drawings),
|
||||
...fieldOps(p, "layers", ensureContextCategories(p.layers, codes)),
|
||||
]);
|
||||
if (buildings.length) get().groundContextObjects(buildings);
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -115,6 +126,13 @@ export function createSiteSlice(
|
||||
|
||||
addContextObjects: (objs, lines) => addToContext(objs, lines),
|
||||
|
||||
groundContextObjects: (ids) => {
|
||||
const ops = documentFor(get().project).cmdOps({ cmd: "contextToTerrain", ids });
|
||||
if (ops.length === 0) return false;
|
||||
get().applyChange(ops);
|
||||
return true;
|
||||
},
|
||||
|
||||
removeContextObject: (id) => get().applyChange((p) => removeItems(p, "context", [id])),
|
||||
|
||||
removeContextObjects: (ids) => {
|
||||
|
||||
Reference in new issue
Block a user