[B5] IFC: Daecher als IfcRoof (Schicht-Meshes wie im 3D, IfcRoofType mit Schichten), Stuetzen als IfcColumn mit Material; Dach-Meshes nach aussen gewunden
- toWalls3d/roofs.ts: Ober-/Unterseite und Stirnflaechen je Dachschicht konsistent nach aussen gewunden (render3d zeichnet Daecher doppelseitig, Bild unveraendert; IFC-Closed-Flag und STL/OBJ-Normalen profitieren) - Bekannt offen: an Walm-/Zeltspitzen trifft die paarweise Gehrung der Unterseite nicht exakt (Restluecke < 0.01 m2), solche Daecher gehen als nicht geschlossenes Face-Set ins IFC - Tests (Wicklung aller Dachformen, IfcRoof/IfcColumn), ifcopenshell gueltig Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
5 files changed
+190
-8
No files matched your search
@@ -449,3 +449,37 @@ describe("Materialschichten über Bauteiltypen", () => {
|
||||
expect(lines(spf, "IFCMATERIAL")).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Dächer und Stützen", () => {
|
||||
const withRoofAndColumn = (): Project => ({
|
||||
...fixtureProject(),
|
||||
roofTypes: [{ id: "rt", name: "Ziegeldach", layers: [{ componentId: "c", thickness: 0.05 }, { componentId: "c", thickness: 0.2 }] }],
|
||||
roofs: [
|
||||
{
|
||||
id: "D1", type: "roof", floorId: "og", categoryCode: "35",
|
||||
outline: [{ x: 0, y: 0 }, { x: 5, y: 0 }, { x: 5, y: 4 }, { x: 0, y: 4 }],
|
||||
shape: "sattel", pitchDeg: 35, overhang: 0.3, ridgeAxis: "x", thickness: 0.25, roofTypeId: "rt",
|
||||
},
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
id: "S1", type: "column", floorId: "eg", categoryCode: "50",
|
||||
position: { x: 2, y: 2 }, profile: { kind: "rect", width: 0.3, depth: 0.3 }, rotation: 0, height: 2.6, componentId: "c",
|
||||
},
|
||||
],
|
||||
});
|
||||
it("Dach → IfcRoof (Satteldach) mit geschlossenem Mesh und IfcRoofType", () => {
|
||||
const spf = exportIfcSpf(withRoofAndColumn());
|
||||
const roof = spf.split("\n").find((l) => l.includes("=IFCROOF("))!;
|
||||
expect(roof).toContain(".GABLE_ROOF.");
|
||||
expect(spf.split("\n").filter((l) => l.includes("=IFCTRIANGULATEDFACESET(") && l.includes(".T."))).not.toHaveLength(0);
|
||||
expect(spf).toMatch(/=IFCROOFTYPE\(.*'Ziegeldach'.*\.GABLE_ROOF\.\);/);
|
||||
});
|
||||
it("Stütze → IfcColumn mit Material", () => {
|
||||
const spf = exportIfcSpf(withRoofAndColumn());
|
||||
const col = spf.split("\n").find((l) => l.includes("=IFCCOLUMN("))!;
|
||||
expect(col).toContain(".COLUMN.");
|
||||
const colId = col.slice(0, col.indexOf("="));
|
||||
expect(spf.split("\n").some((l) => l.includes("=IFCRELASSOCIATESMATERIAL(") && l.includes(`(${colId})`))).toBe(true);
|
||||
});
|
||||
});
|
||||
+74
-1
@@ -30,6 +30,8 @@
|
||||
// Tür/Fenster bleiben als eigenes Objekt IfcDoor/IfcWindow mit eigener Box-
|
||||
// Geometrie erhalten (füllt das ausgeschnittene Loch, "sieht aus wie 3D").
|
||||
// • Extrusion → IfcBuildingElementProxy aus points+height.
|
||||
// • Dach → IfcRoof (Schicht-Meshes wie im 3D), Dachtyp → IfcRoofType mit Schichten.
|
||||
// • Stütze → IfcColumn (Profil-Extrusion), Bauteil → IfcMaterial.
|
||||
// • Raum → IfcSpace (im Geschoss aggregiert) mit Qto_SpaceBaseQuantities und SIA-416-Kategorie.
|
||||
// • Treppe → IfcStair, GEOMETRISCH bewusst vereinfacht auf einen
|
||||
// extrudierten Bounding-Footprint (Lauf-Rechteck bei "straight"; Achsen-
|
||||
@@ -55,6 +57,7 @@ import type {
|
||||
Wall,
|
||||
} from "../model/types";
|
||||
import {
|
||||
columnLabel,
|
||||
getCeilingType,
|
||||
getWallType,
|
||||
openingLabel,
|
||||
@@ -63,6 +66,7 @@ import {
|
||||
import { projectToWorldCoords } from "../model/geoRebase";
|
||||
import {
|
||||
ceilingVerticalExtent,
|
||||
columnVerticalExtent,
|
||||
stairVerticalExtent,
|
||||
wallReferenceOffset,
|
||||
wallVerticalExtent,
|
||||
@@ -71,6 +75,8 @@ import { pickGeometry } from "../plan/toWalls3d";
|
||||
import type { RWall } from "../plan/toWalls3d";
|
||||
import { isWatertight, wallCutMesh } from "../plan/wallMeshCut";
|
||||
import { evaluateRoom } from "../geometry/roomArea";
|
||||
import { columnFootprint } from "../geometry/column";
|
||||
import { emitRoofs } from "../plan/toWalls3d/roofs";
|
||||
|
||||
// ── IFC-GUID (Base64-Kompression, 22 Zeichen) ───────────────────────────────
|
||||
// Standard-Kompressionsalgorithmus (IfcOpenShell guid.compress): das erste
|
||||
@@ -559,7 +565,7 @@ export function exportIfcSpf(projectIn: Project): string {
|
||||
}
|
||||
const elementTypes = new Map<string, ElementTypeRef>();
|
||||
const typeFor = (
|
||||
ifcType: "IFCWALLTYPE" | "IFCSLABTYPE",
|
||||
ifcType: "IFCWALLTYPE" | "IFCSLABTYPE" | "IFCROOFTYPE",
|
||||
predefined: string,
|
||||
t: { id: string; name: string; layers: { componentId: string; thickness: number }[] },
|
||||
): ElementTypeRef => {
|
||||
@@ -818,6 +824,73 @@ export function exportIfcSpf(projectIn: Project): string {
|
||||
);
|
||||
}
|
||||
|
||||
// ── Dächer → IfcRoof ───────────────────────────────────────────────────
|
||||
// Dieselben geschlossenen Schicht-Meshes wie das 3D (`emitRoofs`: Dachflächen je Schicht,
|
||||
// an First/Grat gehrt), zu EINEM Face-Set je Dach vereint. Modell-Koordinaten sind bereits
|
||||
// Z-oben (kein Achsentausch wie bei den Wänden); die Wicklung wird so gewählt, dass das Volumen
|
||||
// positiv ist — nur dann ist das Face-Set als geschlossen markiert.
|
||||
const ROOF_PREDEFINED: Record<string, string> = {
|
||||
flach: "FLAT_ROOF",
|
||||
pult: "SHED_ROOF",
|
||||
sattel: "GABLE_ROOF",
|
||||
walm: "HIP_ROOF",
|
||||
mansarde: "MANSARD_ROOF",
|
||||
zelt: "HIPPED_GABLE_ROOF",
|
||||
};
|
||||
for (const roof of project.roofs ?? []) {
|
||||
const structure = resolveStructure(roof.floorId);
|
||||
const positions: number[] = [];
|
||||
const indices: number[] = [];
|
||||
for (const mesh of emitRoofs({ ...project, roofs: [roof] })) {
|
||||
const base = positions.length / 3;
|
||||
for (let i = 0; i < mesh.positions.length; i += 3) {
|
||||
positions.push(mesh.positions[i], mesh.positions[i + 1], mesh.positions[i + 2] - structure.baseElevation);
|
||||
}
|
||||
for (const ix of mesh.indices) indices.push(base + ix);
|
||||
}
|
||||
if (indices.length === 0) continue;
|
||||
let closed = isWatertight({ positions, indices });
|
||||
if (!closed) {
|
||||
const flipped: number[] = [];
|
||||
for (let i = 0; i < indices.length; i += 3) flipped.push(indices[i], indices[i + 2], indices[i + 1]);
|
||||
if (isWatertight({ positions, indices: flipped })) {
|
||||
indices.splice(0, indices.length, ...flipped);
|
||||
closed = true;
|
||||
}
|
||||
}
|
||||
const { placementId, shapeId } = emitTriangulatedProduct(positions, indices, structure.placementId, closed);
|
||||
const predefined = ROOF_PREDEFINED[roof.shape] ?? "NOTDEFINED";
|
||||
const roofType = roof.roofTypeId ? (project.roofTypes ?? []).find((t) => t.id === roof.roofTypeId) : undefined;
|
||||
const entityId = emitBuildingElement("IFCROOF", ifcGuid(roof.id), roofType?.name ?? "Dach", placementId, shapeId, ENUM(predefined));
|
||||
if (roofType) typeFor("IFCROOFTYPE", predefined, roofType).occurrences.push(entityId);
|
||||
addToContainment(structure.entityId, entityId);
|
||||
}
|
||||
|
||||
// ── Stützen → IfcColumn (Profil-Extrusion, Material = Bauteil) ──────────
|
||||
const materialAssoc = new Map<number, number[]>();
|
||||
for (const col of project.columns ?? []) {
|
||||
const footprint = columnFootprint(col);
|
||||
if (footprint.length < 3) continue;
|
||||
const { zBottom, zTop } = columnVerticalExtent(project, col);
|
||||
if (!(zTop > zBottom)) continue;
|
||||
const structure = resolveStructure(col.floorId);
|
||||
const { placementId, shapeId } = emitBoxProduct(footprint, zBottom - structure.baseElevation, zTop - zBottom, structure.placementId);
|
||||
const entityId = emitBuildingElement("IFCCOLUMN", ifcGuid(col.id), columnLabel(col), placementId, shapeId, ENUM("COLUMN"));
|
||||
addToContainment(structure.entityId, entityId);
|
||||
if (col.componentId) {
|
||||
const mat = materialOf(col.componentId);
|
||||
const list = materialAssoc.get(mat);
|
||||
if (list) list.push(entityId);
|
||||
else materialAssoc.set(mat, [entityId]);
|
||||
}
|
||||
}
|
||||
for (const [mat, ids] of materialAssoc) {
|
||||
w.add(
|
||||
"IFCRELASSOCIATESMATERIAL",
|
||||
`${S(ifcGuid(`material:${mat}`))},#${ownerHistory},$,$,${LIST(ids.map((id) => `#${id}`))},#${mat}`,
|
||||
);
|
||||
}
|
||||
|
||||
// ── Typ-Zuordnung (je Bauteiltyp eine IfcRelDefinesByType) ─────────────
|
||||
for (const [key, ref] of elementTypes) {
|
||||
if (ref.occurrences.length === 0) continue;
|
||||
|
||||
@@ -32,4 +32,13 @@ describe.skipIf(!hasIfcOpenShell)("IFC-Export gegen ifcopenshell", () => {
|
||||
expect(r.out).toContain("0 Befunde");
|
||||
expect(r.status).toBe(0);
|
||||
});
|
||||
it("mit Stütze (Rechteck und rund)", () => {
|
||||
const col = (id: string, profile: { kind: "rect"; width: number; depth: number } | { kind: "round"; radius: number }) => ({
|
||||
id, type: "column" as const, floorId: "eg", categoryCode: "50", position: { x: 1, y: 1 }, profile, rotation: 0.3, height: 2.5,
|
||||
});
|
||||
const p = { ...sampleProject, columns: [col("S1", { kind: "rect", width: 0.3, depth: 0.2 }), col("S2", { kind: "round", radius: 0.15 })] };
|
||||
const r = validate("stuetzen", exportIfcSpf(p));
|
||||
expect(r.out).toContain("0 Befunde");
|
||||
expect(r.status).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user