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
+2
-2
@@ -37,7 +37,7 @@
|
||||
// [154] Bauteile aus 2D-Zeichnung erkennen (Wände, Öffnungen, Räume
|
||||
// ins Geschoss); Bericht als JSON. Z. B. convert plan.dxf p.obp --cmd "erkennen --out e.obp"
|
||||
// dossier-cli <projekt.obp> render --out bild.png [--view iso|perspective|front|back|left|right|top] [--when 2026-06-21T10:00Z]
|
||||
// [--camera Name|id] [--samples 128] [--size 1920x1080] [--cpu] [--blender pfad] [--keep] [211] Rendering mit Blender/Cycles
|
||||
// [--camera Name|id] [--samples 128] [--size 1920x1080] [--cpu] [--excavation] [--blender pfad] [--keep] [211] [227] (--excavation: Baugrube im Bild lassen) Rendering mit Blender/Cycles
|
||||
// dossier-cli <projekt.obp> model3d [--explode 3] [--hide …] [--grey …] [--out modell.json] 3D-Modell fürs Headless-Rendern (render_png)
|
||||
// dossier-cli pointcloud-info <datei.las|laz|e57|ply|xyz|pts> [--voxel 0.05] [--max 2000000]
|
||||
// Punktwolke lesen ([B9]) und Bericht als JSON (ohne Projekt)
|
||||
@@ -784,7 +784,7 @@ async function runRender(project: Project, args: Args): Promise<number> {
|
||||
await loadFileio();
|
||||
const pkg = await buildRenderPackage(
|
||||
project,
|
||||
{ width: Number(m[1]), height: Number(m[2]), samples, when, camera: choice ? choice.camera : { preset: view }, device: args.flags.has("cpu") ? "cpu" : "auto" },
|
||||
{ width: Number(m[1]), height: Number(m[2]), samples, when, camera: choice ? choice.camera : { preset: view }, device: args.flags.has("cpu") ? "cpu" : "auto", backfilled: !args.flags.has("excavation") },
|
||||
localTextureLoader(),
|
||||
);
|
||||
if (pkg.missingTextures.length > 0) process.stderr.write(`Hinweis: ${pkg.missingTextures.length} Bildkarten nicht lesbar (Material erscheint einfarbig)\n`);
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
type RenderOptions,
|
||||
} from "./blenderRender";
|
||||
import { exportGlb } from "./exportMesh";
|
||||
import { meshSceneGroups } from "./meshScene.testutil";
|
||||
import { cameraToView } from "../viewport/cameraView";
|
||||
|
||||
const when = new Date(Date.UTC(2026, 5, 21, 10, 0, 0));
|
||||
@@ -342,3 +343,31 @@ describe("Kamera wählen ([213])", () => {
|
||||
expect(pkg.scene.sun.elevation).toBeLessThan(renderSun(mk, defaultRenderTime(mk)).elevation);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Baugrube im Rendering ausblenden ([227])", () => {
|
||||
const complex = buildComplexSampleProject();
|
||||
const lowest = (groups: ReturnType<typeof meshSceneGroups>, kind: string): number => {
|
||||
let m = Infinity;
|
||||
for (const g of groups) if (g.kind === kind) for (const p of g.prims) for (let i = 1; i < p.positions.length; i += 3) m = Math.min(m, p.positions[i]);
|
||||
return m;
|
||||
};
|
||||
|
||||
it("hinterfüllt: das Gelände ist das gewachsene, ohne Sohle bei −3.35 m; sonst bleibt die Grube", () => {
|
||||
expect(lowest(meshSceneGroups(complex), "terrain")).toBeCloseTo(-3.35, 2);
|
||||
expect(lowest(meshSceneGroups(complex, true), "terrain")).toBeGreaterThan(-3.3);
|
||||
});
|
||||
|
||||
it("Paket: Vorgabe an (scene.backfilled, kleineres/anderes GLB), mit backfilled: false bleibt die Grube", async () => {
|
||||
const on = await buildRenderPackage(complex, opts());
|
||||
const off = await buildRenderPackage(complex, opts({ backfilled: false }));
|
||||
expect(on.scene.backfilled).toBe(true);
|
||||
expect(off.scene.backfilled).toBe(false);
|
||||
const size = (p: typeof on) => p.files.find((f) => f.path === "model.glb")!.bytes.length;
|
||||
expect(size(on)).not.toBe(size(off));
|
||||
});
|
||||
|
||||
it("das normale GLB (Export, Anzeige) behält die Baugrube", () => {
|
||||
expect(exportGlb(complex).length).toBe(exportGlb(complex, { backfilled: false }).length);
|
||||
expect(exportGlb(complex).length).not.toBe(exportGlb(complex, { backfilled: true }).length);
|
||||
});
|
||||
});
|
||||
@@ -82,6 +82,11 @@ export interface RenderOptions {
|
||||
denoise?: boolean;
|
||||
/** `cpu` erzwingt die CPU, sonst GPU wenn vorhanden. */
|
||||
device?: "auto" | "cpu";
|
||||
/**
|
||||
* [227] Baugrube ausblenden: Gelände ohne Aushub, hinterfüllt bis an die Fassade (Standard: an — für Bilder). Nur das Paket;
|
||||
* die 3D-Ansicht im Modell bleibt unberührt (Klasse „07 Baugrube").
|
||||
*/
|
||||
backfilled?: boolean;
|
||||
}
|
||||
|
||||
/** Eintrag der Materialtabelle in `scene.json`. */
|
||||
@@ -124,6 +129,8 @@ export interface RenderScene {
|
||||
samples: number;
|
||||
denoise: boolean;
|
||||
device: "auto" | "cpu";
|
||||
/** [227] Gelände im Paket ohne Baugruben (hinterfüllt); nur Hinweis, der Leser setzt nichts um. */
|
||||
backfilled: boolean;
|
||||
camera: RenderCameraSpec;
|
||||
sun: { azimuth: number; elevation: number; when: string; lat: number; lon: number };
|
||||
materials: RenderMaterial[];
|
||||
@@ -334,7 +341,7 @@ function componentMaterials(project: Project): Map<string, ComponentMaterial> {
|
||||
* Kamera, Sonne. Verlangt das geladene Format-Modul (`await loadFileio()`) und den Kern.
|
||||
*/
|
||||
export async function buildRenderPackage(project: Project, opts: RenderOptions, loadTexture?: TextureLoader): Promise<RenderPackage> {
|
||||
const glb = splitRoofMaterials(exportGlb(project), project);
|
||||
const glb = splitRoofMaterials(exportGlb(project, { backfilled: opts.backfilled ?? true }), project);
|
||||
const files: RenderPackage["files"] = [{ path: "model.glb", bytes: glb }];
|
||||
const materials = glbMaterials(glb);
|
||||
const comp = componentMaterials(project);
|
||||
@@ -377,6 +384,7 @@ export async function buildRenderPackage(project: Project, opts: RenderOptions,
|
||||
samples: Math.max(1, Math.round(opts.samples)),
|
||||
denoise: opts.denoise ?? true,
|
||||
device: opts.device ?? "auto",
|
||||
backfilled: opts.backfilled ?? true,
|
||||
camera: opts.camera,
|
||||
sun: renderSun(project, opts.when),
|
||||
materials,
|
||||
|
||||
@@ -19,11 +19,13 @@ export interface MeshOptions {
|
||||
openingParts?: boolean;
|
||||
/** Gelände und importierte Kontext-Meshes (IFC/DXF) mitnehmen (Standard: ja). */
|
||||
context?: boolean;
|
||||
/** [227] Baugruben weglassen: Gelände ohne Aushub (hinterfüllt, bis an die Fassade geschlossen). Standard: nein. */
|
||||
backfilled?: boolean;
|
||||
}
|
||||
|
||||
/** Ruft eine Rust-Bindung; leeres Ergebnis (kaputter Puffer) wird zum Fehler mit dem Grund. */
|
||||
function write<T extends string | Uint8Array>(project: Project, opts: MeshOptions, byLevel: boolean, run: (m: ReturnType<typeof fileio>, buf: Float64Array, strings: string) => T): T {
|
||||
const args = [(opts.openingParts ?? true) ? 1 : 0, (opts.context ?? true) ? 1 : 0, byLevel ? 1 : 0];
|
||||
const args = [(opts.openingParts ?? true) ? 1 : 0, (opts.context ?? true) ? 1 : 0, byLevel ? 1 : 0, opts.backfilled ? 1 : 0];
|
||||
const [buf, strings] = decodeExportFlat(documentFor(project).queryBin("meshExportData", args));
|
||||
const m = fileio();
|
||||
const out = run(m, buf, strings);
|
||||
|
||||
@@ -13,8 +13,8 @@ export interface SceneGroup {
|
||||
}
|
||||
|
||||
/** Knoten der Mesh-Szene (Welt x, Höhe, y; Wicklung nach aussen im Modell). */
|
||||
export function meshSceneGroups(project: Project): SceneGroup[] {
|
||||
const [b, text] = decodeExportFlat(documentFor(project).queryBin("meshExportData", [1, 1, 0]));
|
||||
export function meshSceneGroups(project: Project, backfilled = false): SceneGroup[] {
|
||||
const [b, text] = decodeExportFlat(documentFor(project).queryBin("meshExportData", [1, 1, 0, backfilled ? 1 : 0]));
|
||||
const s = text.split("\0");
|
||||
let i = 2;
|
||||
i += 1 + b[i] * 7;
|
||||
|
||||
@@ -2541,6 +2541,10 @@ export const de = {
|
||||
"site.meshPoint": "Netzpunkt Nr.",
|
||||
"site.meshPoint.hint": "Nummer des Netzpunkts (1 bis {n}); seine Lage ziehst du im Grundriss am Griff",
|
||||
"site.meshPoint.z": "Höhe des Punkts (m)",
|
||||
"site.ground": "Aufs Gelände setzen",
|
||||
"site.ground.hint": "Setzt jedes Gebäude dieses Netzes auf den tiefsten Geländepunkt unter seinem Grundriss",
|
||||
"site.ground.noTerrain": "Kein Gelände im Projekt",
|
||||
"site.ground.nothing": "Nichts zu versetzen: die Gebäude stehen schon auf dem Gelände oder liegen ausserhalb davon",
|
||||
"site.meshCrop": "Auf Grundstück zuschneiden",
|
||||
"site.meshCrop.hint": "Entfernt alle Dreiecke, deren Schwerpunkt ausserhalb der Parzelle liegt",
|
||||
"site.meshCrop.noParcel": "Zuerst die Parzelle im Baurecht erfassen",
|
||||
@@ -3944,6 +3948,8 @@ export const de = {
|
||||
"render.quality.normal": "Normal (128 Samples)",
|
||||
"render.quality.high": "Hoch (512 Samples)",
|
||||
"render.quality.final": "Final (1536 Samples)",
|
||||
"render.backfilled": "Baugrube ausblenden (hinterfüllt)",
|
||||
"render.backfilled.hint": "Das Gelände im Bild ist ohne Aushub gerechnet und reicht bis an die Fassade. Das 3D im Modell bleibt unverändert (Klasse «07 Baugrube»).",
|
||||
"render.time": "Datum und Uhrzeit der Sonne",
|
||||
"render.sun": "Sonne: Azimut {az}°, Höhe {el}°",
|
||||
"render.sun.night": "Die Sonne steht dann unter dem Horizont; gerendert wird bei Dämmerung (Sonnenhöhe 1°).",
|
||||
|
||||
@@ -2529,6 +2529,10 @@ export const en: Record<TranslationKey, string> = {
|
||||
"site.meshPoint": "Mesh point no.",
|
||||
"site.meshPoint.hint": "Number of the mesh point (1 to {n}); drag its position in the plan by its grip",
|
||||
"site.meshPoint.z": "Point height (m)",
|
||||
"site.ground": "Place on terrain",
|
||||
"site.ground.hint": "Places every building of this mesh on the lowest terrain point under its footprint",
|
||||
"site.ground.noTerrain": "No terrain in the project",
|
||||
"site.ground.nothing": "Nothing to move: the buildings already stand on the terrain or lie outside it",
|
||||
"site.meshCrop": "Crop to parcel",
|
||||
"site.meshCrop.hint": "Removes all triangles whose centroid lies outside the parcel",
|
||||
"site.meshCrop.noParcel": "Enter the parcel under building regulations first",
|
||||
@@ -3930,6 +3934,8 @@ export const en: Record<TranslationKey, string> = {
|
||||
"render.quality.normal": "Normal (128 samples)",
|
||||
"render.quality.high": "High (512 samples)",
|
||||
"render.quality.final": "Final (1536 samples)",
|
||||
"render.backfilled": "Hide excavation (backfilled)",
|
||||
"render.backfilled.hint": "The terrain in the image is computed without the excavation and reaches the facade. The 3D view in the model is unchanged (class \"07 Baugrube\").",
|
||||
"render.time": "Date and time of the sun",
|
||||
"render.sun": "Sun: azimuth {az}°, elevation {el}°",
|
||||
"render.sun.night": "The sun is below the horizon then; the image is rendered at twilight (sun elevation 1°).",
|
||||
|
||||
@@ -41,6 +41,14 @@ export interface GeoFeature {
|
||||
/** Default-Gebäudehöhe (m), wenn keine Höhe aus der Quelle vorliegt. */
|
||||
export const DEFAULT_BUILDING_HEIGHT = 9;
|
||||
|
||||
/** Id-Präfix des extrudierten Gebäudenetzes eines Geo-Imports ([227]: wird beim Hinzufügen aufs Gelände gesetzt). */
|
||||
const GEO_BUILDING_MESH_PREFIX = "geo-building3d";
|
||||
|
||||
/** Ist `o` das Gebäudenetz eines Geo-Imports (Kataster, swisstopo, OSM; {@link buildingsToMesh})? */
|
||||
export function isGeoBuildingMesh(o: ContextObject): boolean {
|
||||
return o.type === "importedMesh" && o.id.startsWith(GEO_BUILDING_MESH_PREFIX);
|
||||
}
|
||||
|
||||
/** Erzeugt eine (kollisionsarme) ID für ein neues Kontext-Objekt. */
|
||||
function contextId(prefix: string): string {
|
||||
return `${prefix}-${Date.now().toString(36)}-${Math.random()
|
||||
@@ -118,7 +126,7 @@ export function buildingsToMesh(
|
||||
const indices = Array.from(r.subarray(1 + nPos));
|
||||
if (positions.length < 9 || indices.length < 3) return null;
|
||||
return {
|
||||
id: contextId("geo-building3d"),
|
||||
id: contextId(GEO_BUILDING_MESH_PREFIX),
|
||||
type: "importedMesh",
|
||||
name: `Gebäude 3D (${sourceLabel})`,
|
||||
categoryCode: GEO_CATEGORY_DEFS.building.code,
|
||||
|
||||
@@ -20,6 +20,15 @@ const p = buildComplexSampleProject();
|
||||
const codes = collectVisibleCodes(p.layers);
|
||||
|
||||
describe("Musterhaus komplex", () => {
|
||||
it("[227] Nachbargebäude stehen auf dem Gelände, nicht auf z = 0", () => {
|
||||
const n = p.context?.find((c) => c.id === "nachbarn");
|
||||
if (n?.type !== "importedMesh") throw new Error("Nachbarn fehlen");
|
||||
const zs = n.positions.filter((_, i) => i % 3 === 2);
|
||||
// Die Höhenlinien reichen bis unter die West- und Ostnachbarn; deren Fuss liegt auf dem Hang (−2.5 … −0.9 m).
|
||||
expect(Math.min(...zs)).toBeLessThan(-1);
|
||||
expect(Math.min(...zs)).toBeGreaterThan(-3.3);
|
||||
});
|
||||
|
||||
it("ist gültig und deterministisch; Datei-Rundreise", () => {
|
||||
expect(validateProject(p)).toEqual([]);
|
||||
const warnings = projectWarnings(p);
|
||||
|
||||
@@ -519,7 +519,7 @@ const terrainZ = (x: number, y: number) => -1.8 + 1.5 * Math.tanh((y - 4 - 0.8 *
|
||||
/** Höhenlinie z als Polylinie y(x) über x = −16 … 32. */
|
||||
function contourAt(z: number): Vec2[] {
|
||||
const pts: Vec2[] = [];
|
||||
for (let x = -16; x <= 32; x += 2) pts.push(P(x, r3(4 + 0.8 * Math.sin(x / 9) + 8 * Math.atanh((z + 1.8) / 1.5))));
|
||||
for (let x = -44; x <= 54; x += 2) pts.push(P(x, r3(4 + 0.8 * Math.sin(x / 9) + 8 * Math.atanh((z + 1.8) / 1.5))));
|
||||
return pts;
|
||||
}
|
||||
const CONTOUR_Z = [-3.25, -3.2, -2.95, -2.7, -2.45, -2.2, -1.95, -1.7, -1.45, -1.2, -0.95, -0.7, -0.45, -0.35];
|
||||
@@ -912,6 +912,8 @@ export function buildComplexSampleProject(): Project {
|
||||
|
||||
// Gelände aus den Höhenlinien (Kern: geglättetes TIN mit Bruchkanten).
|
||||
p = runCmd(p, "ug", "terrain", {}).project;
|
||||
// [227] Nachbargebäude stehen auf dem Gelände (tiefster Punkt unter dem Grundriss), nicht auf z = 0.
|
||||
p = runCmd(p, "ug", "contextToTerrain", { ids: ["nachbarn"] }).project;
|
||||
|
||||
// Freie Körper im Garten: Loft (Pflanzgefäss, quadratisch → gedreht) und Rotationskörper (Sitzrolle).
|
||||
const profiles: Drawing2D[] = [
|
||||
|
||||
@@ -136,6 +136,9 @@ function MeshPointFields({ obj }: { obj: Extract<ContextObject, { positions: num
|
||||
function HeightFields({ obj }: { obj: ContextObject }) {
|
||||
const offsetContextHeight = useStore((s) => s.offsetContextHeight);
|
||||
const setContourHeight = useStore((s) => s.setContourHeight);
|
||||
const groundContextObjects = useStore((s) => s.groundContextObjects);
|
||||
const hasTerrain = useStore((s) => s.project.context?.some((c) => c.type === "terrainMesh") ?? false);
|
||||
const notify = useStore((s) => s.notify);
|
||||
const [dz, setDz] = useState("");
|
||||
if (obj.type === "image") return null;
|
||||
const apply = () => {
|
||||
@@ -157,6 +160,20 @@ function HeightFields({ obj }: { obj: ContextObject }) {
|
||||
onBlur={apply}
|
||||
/>
|
||||
</label>
|
||||
{obj.type === "importedMesh" && (
|
||||
// [227] Kontextgebäude auf den tiefsten Geländepunkt unter dem Grundriss setzen.
|
||||
<button
|
||||
type="button"
|
||||
data-testid="context-ground"
|
||||
disabled={!hasTerrain}
|
||||
title={hasTerrain ? t("site.ground.hint") : t("site.ground.noTerrain")}
|
||||
onClick={() => {
|
||||
if (!groundContextObjects([obj.id])) notify(t("site.ground.nothing"), "info");
|
||||
}}
|
||||
>
|
||||
{t("site.ground")}
|
||||
</button>
|
||||
)}
|
||||
{(obj.type === "terrainMesh" || obj.type === "importedMesh") && <MeshPointFields obj={obj} />}
|
||||
{obj.type === "contourSet" && (
|
||||
<div className="site-prop" data-testid="contour-heights" style={{ display: "block", maxHeight: 180, overflowY: "auto" }}>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
viewBox -25.5 0 81 18.478
|
||||
bytes 209902
|
||||
viewBox -31.5 0 93 18.478
|
||||
bytes 217404
|
||||
circle 4
|
||||
g 1
|
||||
line 503
|
||||
line 505
|
||||
path 3
|
||||
polygon 1031
|
||||
polyline 184
|
||||
polygon 1046
|
||||
polyline 186
|
||||
rect 1
|
||||
svg 1
|
||||
text 4
|
||||
hash d3224b3989291365
|
||||
hash 66efb99a2b49d507
|
||||
@@ -1,5 +1,5 @@
|
||||
viewBox -41.5 0 95 63.6
|
||||
bytes 68382
|
||||
bytes 68330
|
||||
circle 16
|
||||
g 1
|
||||
line 141
|
||||
@@ -10,4 +10,4 @@ rect 1
|
||||
svg 1
|
||||
text 116
|
||||
tspan 25
|
||||
hash daf3fc044edd6954
|
||||
hash 4ff6f95d0f8fb3dd
|
||||
@@ -1,5 +1,5 @@
|
||||
viewBox -41.5 0 95 63.6
|
||||
bytes 108906
|
||||
bytes 108854
|
||||
circle 16
|
||||
g 1
|
||||
line 365
|
||||
@@ -10,4 +10,4 @@ rect 1
|
||||
svg 1
|
||||
text 116
|
||||
tspan 25
|
||||
hash c0d58c87e618c222
|
||||
hash 816aec413091c777
|
||||
@@ -1,75 +1,49 @@
|
||||
meshes [1212]
|
||||
meshes[].color [3] x1212
|
||||
meshes [1963]
|
||||
meshes[].color [3] x1963
|
||||
meshes[].indices [108] x6
|
||||
meshes[].indices [1152] x3
|
||||
meshes[].indices [1224]
|
||||
meshes[].indices [1236]
|
||||
meshes[].indices [1152]
|
||||
meshes[].indices [1248] x3
|
||||
meshes[].indices [12960]
|
||||
meshes[].indices [1326]
|
||||
meshes[].indices [1392]
|
||||
meshes[].indices [144] x55
|
||||
meshes[].indices [154014]
|
||||
meshes[].indices [1584]
|
||||
meshes[].indices [168450]
|
||||
meshes[].indices [1716]
|
||||
meshes[].indices [180]
|
||||
meshes[].indices [204]
|
||||
meshes[].indices [2118]
|
||||
meshes[].indices [2124] x2
|
||||
meshes[].indices [2130]
|
||||
meshes[].indices [2376]
|
||||
meshes[].indices [2676] x2
|
||||
meshes[].indices [31104]
|
||||
meshes[].indices [312]
|
||||
meshes[].indices [348] x6
|
||||
meshes[].indices [36] x1090
|
||||
meshes[].indices [3840]
|
||||
meshes[].indices [36] x1861
|
||||
meshes[].indices [396]
|
||||
meshes[].indices [4086]
|
||||
meshes[].indices [5496]
|
||||
meshes[].indices [564] x4
|
||||
meshes[].indices [564] x2
|
||||
meshes[].indices [60] x9
|
||||
meshes[].indices [648]
|
||||
meshes[].indices [72]
|
||||
meshes[].indices [7332]
|
||||
meshes[].indices [7632]
|
||||
meshes[].indices [84] x2
|
||||
meshes[].indices [9288]
|
||||
meshes[].indices [96] x6
|
||||
meshes[].positions [1044] x6
|
||||
meshes[].positions [1083]
|
||||
meshes[].positions [1086] x2
|
||||
meshes[].positions [1089]
|
||||
meshes[].positions [108] x30
|
||||
meshes[].positions [1188]
|
||||
meshes[].positions [120]
|
||||
meshes[].positions [132]
|
||||
meshes[].positions [1368] x2
|
||||
meshes[].positions [162]
|
||||
meshes[].positions [16428]
|
||||
meshes[].positions [180] x9
|
||||
meshes[].positions [1890] x3
|
||||
meshes[].positions [1908]
|
||||
meshes[].positions [2031]
|
||||
meshes[].positions [216]
|
||||
meshes[].positions [24] x1058
|
||||
meshes[].positions [24] x1829
|
||||
meshes[].positions [252] x2
|
||||
meshes[].positions [264]
|
||||
meshes[].positions [2772]
|
||||
meshes[].positions [288] x10
|
||||
meshes[].positions [324] x7
|
||||
meshes[].positions [3666]
|
||||
meshes[].positions [288] x8
|
||||
meshes[].positions [324] x6
|
||||
meshes[].positions [4128]
|
||||
meshes[].positions [4746]
|
||||
meshes[].positions [576] x3
|
||||
meshes[].positions [618] x2
|
||||
meshes[].positions [663]
|
||||
meshes[].positions [576]
|
||||
meshes[].positions [7050]
|
||||
meshes[].positions [714]
|
||||
meshes[].positions [72] x2
|
||||
meshes[].positions [77523]
|
||||
meshes[].positions [78] x55
|
||||
meshes[].positions [798]
|
||||
meshes[].positions [84735]
|
||||
meshes[].positions [864]
|
||||
roofLayers [59]
|
||||
roofLayers[].color [3] x59
|
||||
@@ -88,17 +62,17 @@ slabs[].outline [26] x5
|
||||
slabs[].outline [270] x5
|
||||
slabs[].outline [4] x49
|
||||
slabs[].outline[] [2] x2748
|
||||
walls [1192]
|
||||
walls [1273]
|
||||
walls[].arcCenter [2] x613
|
||||
walls[].color [3] x1192
|
||||
walls[].end [2] x1192
|
||||
walls[].endCut [4] x831
|
||||
walls[].holes [1] x81
|
||||
walls[].color [3] x1273
|
||||
walls[].end [2] x1273
|
||||
walls[].endCut [4] x869
|
||||
walls[].holes [1] x88
|
||||
walls[].holes [2] x25
|
||||
walls[].holes [3] x8
|
||||
walls[].layers [0] x1192
|
||||
walls[].start [2] x1192
|
||||
walls[].startCut [4] x832
|
||||
walls[].topDrop [2] x89
|
||||
walls[].topPlane [3] x245
|
||||
hash 534b551bfdb4405a
|
||||
walls[].holes [3] x14
|
||||
walls[].layers [0] x1273
|
||||
walls[].start [2] x1273
|
||||
walls[].startCut [4] x873
|
||||
walls[].topDrop [2] x115
|
||||
walls[].topPlane [3] x271
|
||||
hash 6747cdef6a78d1e0
|
||||
@@ -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) => {
|
||||
|
||||
@@ -56,6 +56,8 @@ export const RenderDialogHost = memo(function RenderDialogHost() {
|
||||
// [213] "live" = aktuelle 3D-Ansicht, sonst die Id einer gespeicherten Kamera.
|
||||
const [cameraKey, setCameraKey] = useState("live");
|
||||
const [cameras, setCameras] = useState<RenderCameraChoice[]>([]);
|
||||
// [227] Baugrube im Bild ausblenden (Gelände hinterfüllt); das 3D im Modell bleibt wie es ist.
|
||||
const [backfilled, setBackfilled] = useState(true);
|
||||
const [blenderPath, setPath] = useState("");
|
||||
// Letzte Ausgabezeile von Blender (zeigt z. B. das erstmalige Übersetzen der Metal-Kernel, das Minuten dauern kann).
|
||||
const [lastLine, setLastLine] = useState("");
|
||||
@@ -142,7 +144,7 @@ export const RenderDialogHost = memo(function RenderDialogHost() {
|
||||
// Sonnenzeit der Kamera übernehmen (änderbar).
|
||||
if (choice.sunWhen) setWhen(toInputValue(choice.sunWhen));
|
||||
};
|
||||
const request = () => ({ width: dims.width, height: dims.height, samples, when: date!, camera });
|
||||
const request = () => ({ width: dims.width, height: dims.height, samples, when: date!, camera, backfilled });
|
||||
|
||||
const start = async () => {
|
||||
if (!canStart) return;
|
||||
@@ -303,6 +305,12 @@ export const RenderDialogHost = memo(function RenderDialogHost() {
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
<section className="imp-section">
|
||||
<label>
|
||||
<input type="checkbox" data-testid="render-backfilled" checked={backfilled} disabled={busy} onChange={(e) => setBackfilled(e.target.checked)} /> {t("render.backfilled")}
|
||||
</label>
|
||||
<div className="imp-note">{t("render.backfilled.hint")}</div>
|
||||
</section>
|
||||
{!browserOnly && (
|
||||
<section className="imp-section">
|
||||
<div className="imp-section-title">{t("render.blenderPath")}</div>
|
||||
|
||||
Reference in new issue
Block a user