[B3] IFC-Import als Mesh: STEP-Leser und Geometrie in Rust (fileio), Kontext-Meshes je Bauteil
- src-tauri/fileio/src/ifc_step.rs: ISO-10303-21-Leser (\X2\/\X4\/\X\/\S\, komplexe Instanzen, Fehlererholung, Grenzen), eigener Code. - src-tauri/fileio/src/ifc_import.rs: IfcExtrudedAreaSolid (Arbitrary/Rechteck/Kreis/I/L/U/T/Derived/ Composite, Löcher, Polyline/IndexedPolyCurve/CompositeCurve/TrimmedCurve), FacetedBrep, Shell-/ FaceBasedSurfaceModel, Triangulated-/PolygonalFaceSet, MappedItem, Block, CSG, Boolean (Union ganz, sonst 1. Operand), Platzierungsketten, Einheiten mit Präfix/Umrechnung, Geschoss, Farbe; Unbekanntes wird gezählt, nie Panic. Bindung import_ifc (Float64Array/Uint32Array + JSON-Bericht). - src/io/ifcImport.ts: Fassade, je Bauteil ein ImportedMesh (Ebene = IFC-Klasse, ab 2000 Bauteilen je Klasse+Geschoss), Rückschub aus LV95 bei Standort-Bezug; App: Menü „IFC importieren …“, Import-Dialog und Drag & Drop für .ifc; CLI import-ifc (Bericht als JSON, --out neues Projekt; Plan zeigt jetzt verschachtelte Ebenen-Codes). - Tests: Rust je Geometrietyp + Unsinn; Rundreise mit exportIfcSpf (Bauteile je Klasse, Volumen je Wand/Decke); Gegencheck mit ifcopenshell (scripts/ifc-import-compare.py), optional DOSSIER_IFC_SAMPLES für die buildingSMART-Beispieldateien. - earcutr (ISC) als Abhängigkeit, NOTICE.
This commit is contained in:
16 files changed
+3228
-7
No files matched your search
+47
-2
@@ -9,6 +9,8 @@
|
||||
// dossier-cli <projekt.obp> section <Name> [--out schnitt.svg] (braucht render3d-WASM)
|
||||
// dossier-cli <projekt.obp> elevation <Name> [--out ansicht.svg]
|
||||
// dossier-cli <projekt.obp> dxf|dwg|ifc|step|obj|stl|schedule|kennzahlen|sun [--level EG] [--out datei]
|
||||
// dossier-cli <projekt.obp> import-ifc <datei.ifc> [--out neu.obp] [--group product|class]
|
||||
// IFC als Kontext-Meshes ([B3]); Bericht als JSON auf stdout
|
||||
// dossier-cli <projekt.obp> model3d [--out modell.json] 3D-Modell fürs Headless-Rendern (render_png)
|
||||
// dossier-cli <projekt.obp> mcp MCP-Server (stdio): project_info, query, render_svg, apply_ops, validate
|
||||
// dossier-cli <projekt.obp> bench [--runs 10] Zeitprofil der Ableitungen (ms je Aufruf)
|
||||
@@ -22,6 +24,10 @@ import {
|
||||
buildPlanDxf,
|
||||
buildPlanDwg,
|
||||
loadFileio,
|
||||
readIfc,
|
||||
ifcToImportedMeshes,
|
||||
projectGeoOrigin,
|
||||
ensureContextCategories,
|
||||
projectToWorldCoords,
|
||||
computeSection,
|
||||
exportIfcSpf,
|
||||
@@ -124,7 +130,7 @@ export async function run(argv: string[]): Promise<number> {
|
||||
const [file, command, ...rest] = args.positional;
|
||||
if (!file || !command) {
|
||||
process.stderr.write(
|
||||
"Aufruf: dossier-cli <projekt.obp> <info|validate|migrate|plan|section|elevation|dxf|dwg|ifc|step|obj|stl|schedule|kennzahlen|sun> [Optionen]\n",
|
||||
"Aufruf: dossier-cli <projekt.obp> <info|validate|migrate|plan|section|elevation|dxf|dwg|ifc|import-ifc|step|obj|stl|schedule|kennzahlen|sun> [Optionen]\n",
|
||||
);
|
||||
return 2;
|
||||
}
|
||||
@@ -136,7 +142,15 @@ export async function run(argv: string[]): Promise<number> {
|
||||
await initCore();
|
||||
const project = loadProject(file);
|
||||
const scale = Number(args.flags.get("scale") ?? 100);
|
||||
const allCodes = new Set(project.layers.map((l) => l.code));
|
||||
// Alle Ebenen-Codes inkl. verschachtelter (z. B. „10 Situation" unter „05 Kontext").
|
||||
const allCodes = new Set<string>();
|
||||
const collectCodes = (ls: Project["layers"]): void => {
|
||||
for (const l of ls) {
|
||||
allCodes.add(l.code);
|
||||
if (l.children) collectCodes(l.children);
|
||||
}
|
||||
};
|
||||
collectCodes(project.layers);
|
||||
|
||||
switch (command) {
|
||||
case "info": {
|
||||
@@ -245,6 +259,37 @@ export async function run(argv: string[]): Promise<number> {
|
||||
out(args, r.text, `${project.name || "projekt"}.stp`);
|
||||
return 0;
|
||||
}
|
||||
case "import-ifc": {
|
||||
const src = rest[0];
|
||||
if (!src) fail("import-ifc: IFC-Datei fehlt");
|
||||
let bytes: Uint8Array;
|
||||
try {
|
||||
bytes = new Uint8Array(readFileSync(src));
|
||||
} catch (e) {
|
||||
fail(`Datei nicht lesbar: ${src} (${e instanceof Error ? e.message : String(e)})`);
|
||||
}
|
||||
const { products, report } = await readIfc(bytes);
|
||||
const group = args.flags.get("group");
|
||||
const meshes = ifcToImportedMeshes(products, src.split(/[\\/]/).pop() ?? src, {
|
||||
geoOrigin: projectGeoOrigin(project),
|
||||
group: group === "product" || group === "class" ? group : "auto",
|
||||
});
|
||||
const byClass: Record<string, number> = {};
|
||||
for (const p of products) byClass[p.ifcClass] = (byClass[p.ifcClass] ?? 0) + 1;
|
||||
const triangles = products.reduce((s, p) => s + p.indices.length / 3, 0);
|
||||
process.stdout.write(JSON.stringify({ ...report, byClass, triangles, contextObjects: meshes.length }, null, 2) + "\n");
|
||||
const target = args.flags.get("out");
|
||||
if (target) {
|
||||
const next = applyOps(project, diffToOps(project, {
|
||||
...project,
|
||||
context: [...(project.context ?? []), ...meshes],
|
||||
// Wie in der App (siteSlice): fehlende Kontext-Kategorie als Ebene ergänzen.
|
||||
layers: ensureContextCategories(project.layers, meshes.flatMap((m) => (m.categoryCode ? [m.categoryCode] : []))),
|
||||
}));
|
||||
out(args, serializeProject(next), target);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case "mcp":
|
||||
await serveStdio(file);
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user