[271][272][215] Exporte und Rendering folgen Umbaufilter und Variantenkombination der Ansicht
Gemeinsame Ansicht export/exportView.ts (Umbaufilter, Etappe, Kombination der aktiven Ebene) als EIN Weg in IFC, OBJ/STL/glTF, STEP, Blender-Paket und Cycles-Szene (Text der Kern-Abfragen, renovation::view_from_text). Cycles-Szene: Ausgeblendetes fehlt, Umbau-Farben nur auf Wunsch (renovationColors, cycles_scene_styled); Explosionsaxonometrie bekommt die Umbau-Farben, Pick/Explosion folgten dem Filter schon. App: Export-Dialog und Rendering-Dialog zeigen die Ansicht und lassen Hauptvarianten/kein Filter wählen; Häkchen Umbau-Farben im Bild. CLI: --renovation/--phase auch für ifc, obj, stl, glb, gltf, step, render, blend; render --engine cycles --renovation-colors. Tests: Kern export_view_tests.rs, vitest exportView/exportViewState/render, e2e exportView271; Bilder doc/review-272/07-09.
This commit is contained in:
32 files changed
+695
-42
No files matched your search
@@ -24,6 +24,7 @@ import type { Camera, ComponentMaterial, LayoutOrientation, LayoutPaperFormat, P
|
||||
import { projectLatLon, sunPosition } from "../analysis/sun";
|
||||
import { sheetSizeMm } from "../model/layoutModel";
|
||||
import { exportGlb } from "./exportMesh";
|
||||
import type { ExportView } from "./exportView";
|
||||
import { TERRAIN_GRASS_MATERIAL, terrainComponentMaterial, terrainMeshes } from "../materials/terrainMaterial";
|
||||
|
||||
/** Kamera in Modell-Koordinaten (gleiche Form wie `ViewCamera` der 3D-Ansicht, `viewport/cameraBridge.ts`). */
|
||||
@@ -100,6 +101,8 @@ export interface RenderOptions {
|
||||
* die 3D-Ansicht im Modell bleibt unberührt (Klasse „07 Baugrube").
|
||||
*/
|
||||
backfilled?: boolean;
|
||||
/** [271][272] Ansicht der Szene: Umbaufilter und Variantenkombination (Ausgeblendetes fehlt; ohne Angabe Hauptvarianten). */
|
||||
view?: ExportView;
|
||||
}
|
||||
|
||||
/** Eintrag der Materialtabelle in `scene.json`. */
|
||||
@@ -361,7 +364,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, { backfilled: opts.backfilled ?? true }), project);
|
||||
const glb = splitRoofMaterials(exportGlb(project, { backfilled: opts.backfilled ?? true, view: opts.view }), project);
|
||||
const files: RenderPackage["files"] = [{ path: "model.glb", bytes: glb }];
|
||||
const materials = glbMaterials(glb);
|
||||
const comp = componentMaterials(project);
|
||||
|
||||
@@ -37,6 +37,12 @@ export interface CyclesSceneOptions {
|
||||
ground?: boolean;
|
||||
/** Bild-URLs, die geladen werden können (`undefined` = alle). */
|
||||
textures?: string[];
|
||||
/** [271][272] Umbaufilter und Variantenkombination der Ansicht (Ausgeblendetes fehlt; ohne Angabe Hauptvarianten). */
|
||||
renovation?: string;
|
||||
renovationPhase?: string;
|
||||
designOptions?: Record<string, string>;
|
||||
/** [271] Umbau-Farben im Bild (nur mit Filter, der Farben vorsieht; Standard: Materialfarben). */
|
||||
renovationColors?: boolean;
|
||||
}
|
||||
|
||||
/** Antwort des Kerns. */
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
import type { Project } from "../model/types";
|
||||
import { fileio } from "../engine/fileioWasm";
|
||||
import type { ExportView } from "./exportView";
|
||||
import { exportViewText } from "./exportView";
|
||||
import { documentFor } from "../core/document";
|
||||
|
||||
/** IFC-Schema der Ausgabe: IFC4 (Standard) oder IFC2x3 (Coordination View 2.0, TC1). */
|
||||
@@ -34,6 +36,8 @@ export interface IfcExportOptions {
|
||||
* (IfcBuildingElementProxy „Kontext"), am IfcSite. Ohne Angabe nicht: Fachplaner wollen meist nur das Gebäude.
|
||||
*/
|
||||
context?: boolean;
|
||||
/** [271][272] Ansicht der Ausgabe: Umbaufilter und Variantenkombination (ohne Angabe kein Filter, Hauptvarianten). */
|
||||
view?: ExportView;
|
||||
}
|
||||
|
||||
/** Deterministische 22-stellige IFC-GUID aus einem Namen (Rust, `ifc_export::ifc_guid`). */
|
||||
@@ -79,7 +83,7 @@ export function exportIfcSpf(project: Project, options: IfcExportOptions = {}):
|
||||
const now = Date.now();
|
||||
const iso = new Date(now).toISOString().replace(/\.\d+Z$/, "");
|
||||
const args = [Math.floor(now / 1000), options.schema === "IFC2X3" ? 1 : 0, options.ebkph ? 1 : 0, options.layerCodes ? 1 : 0, options.context ? 1 : 0];
|
||||
const [buf, strings] = decodeExportFlat(documentFor(project).queryBin("ifcExportData", args, iso));
|
||||
const [buf, strings] = decodeExportFlat(documentFor(project).queryBin("ifcExportData", args, exportViewText(options.view, { iso })));
|
||||
const m = fileio();
|
||||
const text = m.export_ifc_flat(buf, strings);
|
||||
if (text.length === 0) {
|
||||
|
||||
@@ -12,6 +12,8 @@ import type { Project } from "../model/types";
|
||||
import { fileio } from "../engine/fileioWasm";
|
||||
import { documentFor } from "../core/document";
|
||||
import { decodeExportFlat } from "./exportIfc";
|
||||
import type { ExportView } from "./exportView";
|
||||
import { exportViewText } from "./exportView";
|
||||
|
||||
/** Was in die Szene kommt. Alles standardmässig an (vollständiges 3D-Modell). */
|
||||
export interface MeshOptions {
|
||||
@@ -21,12 +23,14 @@ export interface MeshOptions {
|
||||
context?: boolean;
|
||||
/** [227] Baugruben weglassen: Gelände ohne Aushub (hinterfüllt, bis an die Fassade geschlossen). Standard: nein. */
|
||||
backfilled?: boolean;
|
||||
/** [271][272] Ansicht der Ausgabe: Umbaufilter und Variantenkombination (ohne Angabe kein Filter, Hauptvarianten). */
|
||||
view?: ExportView;
|
||||
}
|
||||
|
||||
/** 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, opts.backfilled ? 1 : 0];
|
||||
const [buf, strings] = decodeExportFlat(documentFor(project).queryBin("meshExportData", args));
|
||||
const [buf, strings] = decodeExportFlat(documentFor(project).queryBin("meshExportData", args, exportViewText(opts.view)));
|
||||
const m = fileio();
|
||||
const out = run(m, buf, strings);
|
||||
if (out.length === 0) {
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
import { exportProjectName, isAnonymous, neutralizeStepText } from "./competitionIdentity";
|
||||
import type { Project } from "../model/types";
|
||||
import type { ExportView } from "./exportView";
|
||||
import { exportViewText } from "./exportView";
|
||||
import { documentFor } from "../core/document";
|
||||
import { exportStepSolids } from "../engine/truckSolid";
|
||||
import type { SolidSpec } from "../engine/truckSolid";
|
||||
@@ -28,8 +30,8 @@ export { wallProfile, wallSpec } from "../plan/wallSpec";
|
||||
const VOID_FALLBACK = new WeakMap<SolidSpec, SolidSpec>();
|
||||
|
||||
/** Alle Bauteile des Projekts als B-Rep-Spezifikationen (Rust-Kern, `solid_specs.rs::project_solid_specs`; kein truck-WASM). */
|
||||
export function projectSolidSpecs(project: Project): SolidSpec[] {
|
||||
const r = documentFor(project).query<{ specs: SolidSpec[]; fallbacks: [number, SolidSpec][] }>("projectSolidSpecs", []);
|
||||
export function projectSolidSpecs(project: Project, view?: ExportView): SolidSpec[] {
|
||||
const r = documentFor(project).query<{ specs: SolidSpec[]; fallbacks: [number, SolidSpec][] }>("projectSolidSpecs", [], exportViewText(view));
|
||||
for (const [i, base] of r.fallbacks) VOID_FALLBACK.set(r.specs[i], base);
|
||||
return r.specs;
|
||||
}
|
||||
@@ -47,8 +49,9 @@ export interface StepExportResult {
|
||||
* Exportiert das Projekt als STEP-Text. Körper, die truck nicht bauen kann (entartete
|
||||
* Profile …), werden einzeln übersprungen statt den ganzen Export zu verwerfen.
|
||||
*/
|
||||
export async function exportProjectStep(project: Project, fileName = ""): Promise<StepExportResult> {
|
||||
const specs = projectSolidSpecs(project);
|
||||
/** [271][272] `view`: Umbaufilter und Variantenkombination der Ansicht (ohne Angabe kein Filter, Hauptvarianten). */
|
||||
export async function exportProjectStep(project: Project, fileName = "", view?: ExportView): Promise<StepExportResult> {
|
||||
const specs = projectSolidSpecs(project, view);
|
||||
const good: SolidSpec[] = [];
|
||||
const skipped: StepExportResult["skipped"] = [];
|
||||
// Erst alle zusammen versuchen (Normalfall); nur bei Fehler einzeln prüfen.
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
// [271][272] Ansicht eines Exports: Umbaufilter und Variantenkombination der aktiven Ebene gelten für IFC, OBJ/STL/glTF,
|
||||
// STEP-Spezifikationen und die Cycles-Szene; ohne Ansicht Hauptvarianten und alles (wie bisher).
|
||||
import { describe, expect, it } from "vitest";
|
||||
import "../engine/fileioWasm.setup";
|
||||
import { buildUmbauSampleProject } from "../model/sampleProjectUmbau";
|
||||
import { buildVariantenSampleProject } from "../model/sampleProjectVarianten";
|
||||
import { exportIfcSpf } from "./exportIfc";
|
||||
import { exportObj } from "./exportMesh";
|
||||
import { projectSolidSpecs } from "./exportStep";
|
||||
import { cyclesSceneInfo } from "./cyclesRender";
|
||||
import { exportViewFields, exportViewLabels, exportViewText, hasExportView, levelExportView } from "./exportView";
|
||||
import type { Project } from "../model/types";
|
||||
|
||||
const count = (text: string, word: string): number => text.split(word).length - 1;
|
||||
|
||||
/** Das Projekt mit Umbaufilter an der Ebene „eg“. */
|
||||
function withFilter(p: Project, filter: string, phase?: string): Project {
|
||||
return { ...p, drawingLevels: p.drawingLevels.map((l) => (l.id === "eg" ? { ...l, renovationFilter: filter, ...(phase ? { renovationPhase: phase } : {}) } : l)) };
|
||||
}
|
||||
|
||||
describe("Ansicht der Ebene", () => {
|
||||
it("liest Umbaufilter, Etappe und Kombination der Ebene", () => {
|
||||
const u = withFilter(buildUmbauSampleProject(), "endzustand", "etappe-1");
|
||||
expect(levelExportView(u, "eg")).toEqual({ renovation: "endzustand", renovationPhase: "etappe-1" });
|
||||
expect(levelExportView(u, "gibt-es-nicht")).toEqual({});
|
||||
expect(levelExportView(u, null)).toEqual({});
|
||||
|
||||
const v = buildVariantenSampleProject();
|
||||
const lv = { ...v, drawingLevels: v.drawingLevels.map((l) => (l.id === "eg" ? { ...l, designOptionCombination: "studie-2" } : l)) };
|
||||
// Benannte Kombination wird zur vollständigen Wahl aufgelöst.
|
||||
expect(levelExportView(lv, "eg").designOptions).toEqual({ dachform: "b", fassade: "b" });
|
||||
expect(hasExportView(levelExportView(lv, "eg"))).toBe(true);
|
||||
expect(hasExportView(levelExportView(v, "eg"))).toBe(false);
|
||||
});
|
||||
|
||||
it("Text für den Kern: leer ohne Wirkung, sonst JSON; Beschriftung", () => {
|
||||
expect(exportViewText(undefined)).toBe("");
|
||||
expect(exportViewText({})).toBe("");
|
||||
expect(exportViewText({}, { iso: "2026-01-01T00:00:00" })).toBe('{"iso":"2026-01-01T00:00:00"}');
|
||||
expect(JSON.parse(exportViewText({ renovation: "endzustand", renovationPhase: "e1", designOptions: { a: "b" } }, { iso: "x" }))).toEqual({
|
||||
iso: "x",
|
||||
renovation: "endzustand",
|
||||
renovationPhase: "e1",
|
||||
designOptions: { a: "b" },
|
||||
});
|
||||
expect(exportViewFields(undefined)).toEqual({});
|
||||
expect(exportViewFields({ renovation: "bestand" })).toEqual({ renovation: "bestand" });
|
||||
|
||||
const v = buildVariantenSampleProject();
|
||||
const labels = exportViewLabels(v, { designOptions: { dachform: "b", fassade: "b" } }, (id) => id);
|
||||
expect(labels.combination).toBe("Studie 2 Satteldach/Bandfenster");
|
||||
expect(labels.renovation).toBeNull();
|
||||
const u = buildUmbauSampleProject();
|
||||
const first = u.renovation?.phases?.[0];
|
||||
expect(exportViewLabels(u, { renovation: "endzustand", renovationPhase: first?.id }, () => "Endzustand").renovation).toBe(`Endzustand (${first?.name})`);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Exporte folgen der Ansicht", () => {
|
||||
it("IFC: Endzustand ohne Abbruch, andere Kombination andere Bauteile", () => {
|
||||
const u = buildUmbauSampleProject();
|
||||
const ganz = exportIfcSpf(u);
|
||||
const endzustand = exportIfcSpf(u, { view: { renovation: "endzustand" } });
|
||||
expect(count(endzustand, "IFCWALL(")).toBeLessThan(count(ganz, "IFCWALL("));
|
||||
// Ohne Ansicht wie bisher (Hauptvarianten, kein Filter).
|
||||
expect(exportIfcSpf(u, { view: {} }).length).toBe(ganz.length);
|
||||
|
||||
const v = buildVariantenSampleProject();
|
||||
const a = exportIfcSpf(v);
|
||||
const b = exportIfcSpf(v, { view: { designOptions: { dachform: "b", fassade: "b" } } });
|
||||
expect(count(a, "IFCROOF(")).not.toBe(count(b, "IFCROOF(") + 1000); // beide lesbar
|
||||
expect(a).not.toBe(b);
|
||||
expect(count(b, "IFCWINDOW(")).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("OBJ und STEP-Körper: gleiche Ansicht, gleiche Auswahl", () => {
|
||||
const u = buildUmbauSampleProject();
|
||||
const objs = (view?: Parameters<typeof exportObj>[1]) => count(exportObj(u, view), "\no ");
|
||||
expect(objs({ view: { renovation: "endzustand" } })).toBeLessThan(objs());
|
||||
const specs = projectSolidSpecs(u).length;
|
||||
expect(projectSolidSpecs(u, { renovation: "endzustand" }).length).toBeLessThan(specs);
|
||||
});
|
||||
|
||||
it("Cycles-Szene: ohne Ausgeblendetes, Kombination, Umbau-Farben nur auf Wunsch", () => {
|
||||
const u = buildUmbauSampleProject();
|
||||
const base = { width: 64, height: 36, samples: 1, context: false };
|
||||
const alle = cyclesSceneInfo(u, base);
|
||||
const end = cyclesSceneInfo(u, { ...base, ...exportViewFields({ renovation: "endzustand" }) });
|
||||
expect(end.triangles).toBeLessThan(alle.triangles);
|
||||
|
||||
const plan = { ...base, renovation: "umbauplan" };
|
||||
expect(cyclesSceneInfo(u, plan).xml).not.toContain("Umbau-");
|
||||
const farbig = cyclesSceneInfo(u, { ...plan, renovationColors: true });
|
||||
expect(farbig.xml).toContain("Umbau-ffd800");
|
||||
expect(farbig.triangles).toBe(cyclesSceneInfo(u, plan).triangles);
|
||||
|
||||
const v = buildVariantenSampleProject();
|
||||
const a = cyclesSceneInfo(v, base);
|
||||
const b = cyclesSceneInfo(v, { ...base, designOptions: { dachform: "b", fassade: "b" } });
|
||||
expect(b.triangles).not.toBe(a.triangles);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,64 @@
|
||||
// [271][272] Ansicht eines Exports: Umbaufilter, Etappe und Variantenkombination, die ein Export bzw. Rendering übernimmt.
|
||||
// EIN Ort für IFC, glTF/OBJ/STL, Blender-Paket und Cycles-Szene — der Kern wertet sie über den Text der Abfrage aus
|
||||
// (`renovation::view_from_text`: `{"renovation", "renovationPhase", "designOptions"}`; ohne Angabe Hauptvarianten, kein Filter).
|
||||
|
||||
import type { Project } from "../model/types";
|
||||
import { combinationLabel, combinationNameFor, combinationSuffix, resolveCombination, storedChoice } from "../model/designOptions";
|
||||
|
||||
export interface ExportView {
|
||||
/** Umbaufilter (Id oder Name; eingebaut `bestand`, `abbruch`, `neubau`, `umbauplan`, `endzustand`). */
|
||||
renovation?: string;
|
||||
/** Etappe („bis n“). */
|
||||
renovationPhase?: string;
|
||||
/** Variantenkombination (Satz-Id → Varianten-Id); fehlende Sätze gelten als Hauptvariante. */
|
||||
designOptions?: Record<string, string>;
|
||||
}
|
||||
|
||||
/** Ansicht der Ebene `levelId` (Umbaufilter und Kombination, wie sie das 3D-Fenster dieser Ebene zeigt); ohne Ebene leer. */
|
||||
export function levelExportView(project: Project, levelId: string | null | undefined): ExportView {
|
||||
const level = project.drawingLevels.find((l) => l.id === levelId);
|
||||
if (!level) return {};
|
||||
const view: ExportView = {};
|
||||
if (level.renovationFilter) {
|
||||
view.renovation = level.renovationFilter;
|
||||
if (level.renovationPhase) view.renovationPhase = level.renovationPhase;
|
||||
}
|
||||
const choice = storedChoice(project, level);
|
||||
if (choice && Object.keys(choice).length > 0) view.designOptions = { ...choice };
|
||||
return view;
|
||||
}
|
||||
|
||||
/** Wirkt die Ansicht (Filter oder gewählte Kombination)? */
|
||||
export function hasExportView(view: ExportView | null | undefined): boolean {
|
||||
return !!view && (!!view.renovation || !!view.designOptions);
|
||||
}
|
||||
|
||||
/** Der Text der Kern-Abfragen (JSON); leer, wenn die Ansicht nichts ändert. `extra` kommt dazu (z. B. `iso` beim IFC). */
|
||||
export function exportViewText(view: ExportView | null | undefined, extra: Record<string, unknown> = {}): string {
|
||||
const body: Record<string, unknown> = { ...extra };
|
||||
if (view?.renovation) {
|
||||
body.renovation = view.renovation;
|
||||
if (view.renovationPhase) body.renovationPhase = view.renovationPhase;
|
||||
}
|
||||
if (view?.designOptions && Object.keys(view.designOptions).length > 0) body.designOptions = view.designOptions;
|
||||
return Object.keys(body).length > 0 ? JSON.stringify(body) : "";
|
||||
}
|
||||
|
||||
/** Felder einer Ansicht für die Optionen der Cycles-Szene (JSON an den Kern). */
|
||||
export function exportViewFields(view: ExportView | null | undefined): Record<string, unknown> {
|
||||
const text = exportViewText(view);
|
||||
return text ? (JSON.parse(text) as Record<string, unknown>) : {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Lesbare Fassung für Dialoge: Filter-Anzeigename (über `filterName`, mit Etappe) und Kombination (Name einer gespeicherten
|
||||
* Kombination, sonst „Satz Variante, …“ der Abweichungen von der Hauptvariante); `null` = nicht gesetzt.
|
||||
*/
|
||||
export function exportViewLabels(project: Project, view: ExportView, filterName: (id: string) => string): { renovation: string | null; combination: string | null } {
|
||||
const phase = view.renovationPhase ? (project.renovation?.phases?.find((p) => p.id === view.renovationPhase)?.name ?? view.renovationPhase) : "";
|
||||
const full = view.designOptions ? resolveCombination(project, view.designOptions) : null;
|
||||
return {
|
||||
renovation: view.renovation ? filterName(view.renovation) + (phase ? ` (${phase})` : "") : null,
|
||||
combination: full ? (combinationNameFor(project, full) ?? (combinationSuffix(project, full) || combinationLabel(project, full))) || null : null,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user