brepjs-bim 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +191 -0
- package/README.md +100 -0
- package/dist/bcf/bcfRead.d.ts +11 -0
- package/dist/bcf/bcfTypes.d.ts +81 -0
- package/dist/bcf/bcfWrite.d.ts +14 -0
- package/dist/bcf/bcfXml.d.ts +34 -0
- package/dist/bcf/index.d.ts +3 -0
- package/dist/brepjs-bim.cjs +15935 -0
- package/dist/brepjs-bim.js +15822 -0
- package/dist/cobie/cobieExport.d.ts +20 -0
- package/dist/cobie/cobieTypes.d.ts +130 -0
- package/dist/cobie/index.d.ts +2 -0
- package/dist/elementFns/beamFns.d.ts +4 -0
- package/dist/elementFns/columnFns.d.ts +4 -0
- package/dist/elementFns/coveringFns.d.ts +4 -0
- package/dist/elementFns/curtainWallFns.d.ts +32 -0
- package/dist/elementFns/foundationFns.d.ts +5 -0
- package/dist/elementFns/openingFns.d.ts +4 -0
- package/dist/elementFns/profileFns.d.ts +5 -0
- package/dist/elementFns/railingFns.d.ts +4 -0
- package/dist/elementFns/rampFns.d.ts +14 -0
- package/dist/elementFns/roofFns.d.ts +4 -0
- package/dist/elementFns/slabFns.d.ts +4 -0
- package/dist/elementFns/slabOpeningFns.d.ts +4 -0
- package/dist/elementFns/spaceFns.d.ts +4 -0
- package/dist/elementFns/stairFns.d.ts +15 -0
- package/dist/elementFns/wallFns.d.ts +4 -0
- package/dist/errors/bimError.d.ts +39 -0
- package/dist/identity/guidDerivation.d.ts +25 -0
- package/dist/identity/ifcGuid.d.ts +7 -0
- package/dist/identity/localId.d.ts +10 -0
- package/dist/ids/idsCheck.d.ts +22 -0
- package/dist/ids/idsFacets.d.ts +21 -0
- package/dist/ids/idsParser.d.ts +20 -0
- package/dist/ids/idsTypes.d.ts +87 -0
- package/dist/ids/idsXml.d.ts +24 -0
- package/dist/ids/index.d.ts +3 -0
- package/dist/ifc-writer/assemblyWriter.d.ts +26 -0
- package/dist/ifc-writer/classificationWriter.d.ts +18 -0
- package/dist/ifc-writer/connectivityWriter.d.ts +16 -0
- package/dist/ifc-writer/coveringWriter.d.ts +12 -0
- package/dist/ifc-writer/curtainWallWriter.d.ts +23 -0
- package/dist/ifc-writer/entityWriter.d.ts +21 -0
- package/dist/ifc-writer/foundationWriter.d.ts +11 -0
- package/dist/ifc-writer/geometryWriter.d.ts +25 -0
- package/dist/ifc-writer/groupWriter.d.ts +19 -0
- package/dist/ifc-writer/headerWriter.d.ts +31 -0
- package/dist/ifc-writer/ifcWriter.d.ts +27 -0
- package/dist/ifc-writer/materialWriter.d.ts +39 -0
- package/dist/ifc-writer/openingWriter.d.ts +24 -0
- package/dist/ifc-writer/ownerHistoryWriter.d.ts +30 -0
- package/dist/ifc-writer/profileDefWriter.d.ts +3 -0
- package/dist/ifc-writer/proxyWriter.d.ts +17 -0
- package/dist/ifc-writer/psetWriter.d.ts +67 -0
- package/dist/ifc-writer/railingWriter.d.ts +11 -0
- package/dist/ifc-writer/relWriter.d.ts +4 -0
- package/dist/ifc-writer/roofWriter.d.ts +21 -0
- package/dist/ifc-writer/schemaVersion.d.ts +36 -0
- package/dist/ifc-writer/spaceWriter.d.ts +11 -0
- package/dist/ifc-writer/stairWriter.d.ts +49 -0
- package/dist/ifc-writer/styleWriter.d.ts +30 -0
- package/dist/ifc-writer/tessellationWriter.d.ts +42 -0
- package/dist/ifc-writer/typeWriter.d.ts +13 -0
- package/dist/import/dataRead.d.ts +65 -0
- package/dist/import/fromIfc.d.ts +24 -0
- package/dist/import/geometryRead.d.ts +41 -0
- package/dist/import/importedModel.d.ts +95 -0
- package/dist/import/placement.d.ts +89 -0
- package/dist/import/spatialTree.d.ts +35 -0
- package/dist/import/spfReader.d.ts +55 -0
- package/dist/index.d.ts +95 -0
- package/dist/model/bimModel.d.ts +151 -0
- package/dist/psets/psetTemplates.d.ts +41 -0
- package/dist/psets/qtoWeights.d.ts +32 -0
- package/dist/serialize/toIfc.d.ts +19 -0
- package/dist/specs/assemblySpec.d.ts +15 -0
- package/dist/specs/beamSpec.d.ts +34 -0
- package/dist/specs/columnSpec.d.ts +34 -0
- package/dist/specs/coveringSpec.d.ts +33 -0
- package/dist/specs/curtainWallSpec.d.ts +37 -0
- package/dist/specs/foundationSpec.d.ts +50 -0
- package/dist/specs/groupSpec.d.ts +27 -0
- package/dist/specs/materialSpec.d.ts +19 -0
- package/dist/specs/openingSpec.d.ts +42 -0
- package/dist/specs/profile.d.ts +108 -0
- package/dist/specs/profilesExtended.d.ts +86 -0
- package/dist/specs/proxySpec.d.ts +20 -0
- package/dist/specs/railingSpec.d.ts +32 -0
- package/dist/specs/rampSpec.d.ts +26 -0
- package/dist/specs/roofSpec.d.ts +32 -0
- package/dist/specs/slabSpec.d.ts +36 -0
- package/dist/specs/spaceSpec.d.ts +24 -0
- package/dist/specs/spatialSpec.d.ts +24 -0
- package/dist/specs/stairSpec.d.ts +24 -0
- package/dist/specs/styleSpec.d.ts +5 -0
- package/dist/specs/wallSpec.d.ts +33 -0
- package/dist/types/bimTypes.d.ts +49 -0
- package/dist/types/classificationTypes.d.ts +16 -0
- package/dist/types/materialTypes.d.ts +14 -0
- package/dist/types/relationships.d.ts +116 -0
- package/dist/units/units.d.ts +7 -0
- package/dist/validation/geometryValidity.d.ts +20 -0
- package/dist/validation/referentialIntegrity.d.ts +24 -0
- package/dist/validation/roundTrip.d.ts +36 -0
- package/dist/validation/schemaCheck.d.ts +14 -0
- package/dist/validation/severity.d.ts +18 -0
- package/package.json +42 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { SpfReader } from './spfReader.js';
|
|
2
|
+
type Primitive = string | number | boolean;
|
|
3
|
+
/** A read-back property set or element-quantity set keyed by property name. */
|
|
4
|
+
export interface ImportedPset {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
/** `true` when sourced from an IfcElementQuantity rather than an IfcPropertySet. */
|
|
7
|
+
readonly isQuantity: boolean;
|
|
8
|
+
readonly properties: Readonly<Record<string, Primitive>>;
|
|
9
|
+
/** IFC measure/value type code (web-ifc `type`) per property, where known. */
|
|
10
|
+
readonly measureTypes: Readonly<Record<string, number>>;
|
|
11
|
+
}
|
|
12
|
+
export interface ImportedMaterial {
|
|
13
|
+
readonly kind: 'SIMPLE' | 'LAYER_SET';
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly layers?: readonly {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly thicknessMm: number;
|
|
18
|
+
}[] | undefined;
|
|
19
|
+
}
|
|
20
|
+
export interface ImportedClassification {
|
|
21
|
+
readonly system: string;
|
|
22
|
+
readonly code: string;
|
|
23
|
+
readonly description?: string | undefined;
|
|
24
|
+
}
|
|
25
|
+
export interface VoidRelation {
|
|
26
|
+
readonly openingExpressId: number;
|
|
27
|
+
readonly fillerExpressId?: number | undefined;
|
|
28
|
+
}
|
|
29
|
+
export interface ImportedOwnerHistory {
|
|
30
|
+
readonly applicationName: string;
|
|
31
|
+
readonly creationDate?: number | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Reads every property/quantity set associated with an element via
|
|
35
|
+
* IfcRelDefinesByProperties. IfcPropertySet definitions yield
|
|
36
|
+
* `isQuantity: false`; IfcElementQuantity definitions yield `isQuantity: true`.
|
|
37
|
+
* Per-property measure-type codes are captured in {@link ImportedPset.measureTypes}.
|
|
38
|
+
*/
|
|
39
|
+
export declare function readPsets(reader: SpfReader, elementExpressId: number): ImportedPset[];
|
|
40
|
+
/**
|
|
41
|
+
* Reads the material associated with an element via IfcRelAssociatesMaterial.
|
|
42
|
+
* Bare IfcMaterial yields `kind: 'SIMPLE'`; IfcMaterialLayerSet(Usage) yields
|
|
43
|
+
* `kind: 'LAYER_SET'` with the per-layer name and thickness (mm). Returns the
|
|
44
|
+
* first association found, or null.
|
|
45
|
+
*/
|
|
46
|
+
export declare function readMaterial(reader: SpfReader, elementExpressId: number, scale: number): ImportedMaterial | null;
|
|
47
|
+
/**
|
|
48
|
+
* Reads the classification associated with an element via
|
|
49
|
+
* IfcRelAssociatesClassification. The reference's Identification is the code, its
|
|
50
|
+
* ReferencedSource's Name is the system, and its Name is the description.
|
|
51
|
+
* Returns the first association found, or null.
|
|
52
|
+
*/
|
|
53
|
+
export declare function readClassification(reader: SpfReader, elementExpressId: number): ImportedClassification | null;
|
|
54
|
+
/**
|
|
55
|
+
* Reads the openings that void an element via IfcRelVoidsElement, pairing each
|
|
56
|
+
* with the filler element (door/window) supplied through IfcRelFillsElement when
|
|
57
|
+
* present.
|
|
58
|
+
*/
|
|
59
|
+
export declare function readVoids(reader: SpfReader, elementExpressId: number): VoidRelation[];
|
|
60
|
+
/**
|
|
61
|
+
* Reads IfcOwnerHistory metadata: the owning application's full name and the
|
|
62
|
+
* creation timestamp. Returns null if the line or application cannot be read.
|
|
63
|
+
*/
|
|
64
|
+
export declare function readOwnerHistory(reader: SpfReader, ownerHistoryExpressId: number): ImportedOwnerHistory | null;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Result } from 'brepjs';
|
|
2
|
+
import { BimError } from '../errors/bimError.js';
|
|
3
|
+
import { ImportedModel } from './importedModel.js';
|
|
4
|
+
export type { ImportedModel } from './importedModel.js';
|
|
5
|
+
export interface FromIfcOptions {
|
|
6
|
+
/** Activate web-ifc's large-coordinate recentering on open. Default false. */
|
|
7
|
+
readonly coordinateToOrigin?: boolean | undefined;
|
|
8
|
+
/** Skip body-geometry reconstruction for fast metadata-only reads. Default false. */
|
|
9
|
+
readonly skipGeometry?: boolean | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Reads an IFC STEP-SPF byte buffer into an {@link ImportedModel}: schema, unit
|
|
13
|
+
* scale, spatial tree, and one {@link ImportedElement} per physical product
|
|
14
|
+
* (geometry + Psets + material + classification + void/fill relations).
|
|
15
|
+
*
|
|
16
|
+
* Robustness model: every per-element reconstruction is wrapped in try/catch; a
|
|
17
|
+
* failure pushes a diagnostic (severity `error` if the element could not be read
|
|
18
|
+
* at all, `warning`/`info` for partial geometry) and the import continues. Only
|
|
19
|
+
* fatal failures — bad bytes, unsupported schema, WASM open failure — return
|
|
20
|
+
* `err`. Inspect {@link ImportedModel.diagnostics} for per-element quality.
|
|
21
|
+
*
|
|
22
|
+
* The web-ifc model handle is always closed in a `finally` block.
|
|
23
|
+
*/
|
|
24
|
+
export declare function fromIfc(bytes: Uint8Array, options?: FromIfcOptions): Promise<Result<ImportedModel, BimError>>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Result, ValidSolid } from 'brepjs';
|
|
2
|
+
import { BimError } from '../errors/bimError.js';
|
|
3
|
+
import { Profile } from '../specs/profile.js';
|
|
4
|
+
import { ValidationIssue } from '../validation/severity.js';
|
|
5
|
+
import { SpfReader } from './spfReader.js';
|
|
6
|
+
/**
|
|
7
|
+
* Outcome of reconstructing a single product's body geometry.
|
|
8
|
+
*
|
|
9
|
+
* - `SOLID` — a brepjs ValidSolid was rebuilt (parametrically from a swept
|
|
10
|
+
* solid, or by a manifold STL round-trip of a tessellated mesh).
|
|
11
|
+
* - `MESH` — geometry exists but could not be turned into a closed solid;
|
|
12
|
+
* raw triangle data is returned and flagged lossy via `diagnostic`.
|
|
13
|
+
* - `NONE` — the product carries no recognised body representation.
|
|
14
|
+
*/
|
|
15
|
+
export type GeometryResult = {
|
|
16
|
+
readonly kind: 'SOLID';
|
|
17
|
+
readonly solid: ValidSolid;
|
|
18
|
+
readonly lossy: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'MESH';
|
|
21
|
+
readonly vertices: Float32Array;
|
|
22
|
+
readonly indices: Uint32Array;
|
|
23
|
+
readonly diagnostic: string;
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: 'NONE';
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Reconstructs the `Body` (SweptSolid) representation of a product into a brepjs
|
|
29
|
+
* solid, falling back to tessellated mesh import when no parametric path exists.
|
|
30
|
+
*
|
|
31
|
+
* `scale` is metres-per-file-unit (1.0 for METRE files); all reconstructed
|
|
32
|
+
* dimensions are converted to mm via `scale * 1000`. Per-item failures push a
|
|
33
|
+
* diagnostic onto `diagnostics` and yield `NONE` rather than throwing, so a
|
|
34
|
+
* single bad element never aborts a model import.
|
|
35
|
+
*/
|
|
36
|
+
export declare function readBodyGeometry(reader: SpfReader, productExpressId: number, scale: number, diagnostics: ValidationIssue[]): GeometryResult;
|
|
37
|
+
/**
|
|
38
|
+
* Reads an IfcProfileDef into a brepjs Profile (mm). Mirrors the writer's
|
|
39
|
+
* profile-def emission (geometryWriter.writeProfile / profileDefWriter).
|
|
40
|
+
*/
|
|
41
|
+
export declare function readProfileDef(reader: SpfReader, profileExpressId: number, scale: number): Result<Profile, BimError>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ValidSolid } from 'brepjs';
|
|
2
|
+
import { ValidationReport } from '../validation/severity.js';
|
|
3
|
+
import { IfcGuid } from '../identity/ifcGuid.js';
|
|
4
|
+
import { ImportedSchema } from './spfReader.js';
|
|
5
|
+
export type { ImportedSchema } from './spfReader.js';
|
|
6
|
+
/**
|
|
7
|
+
* How faithfully a product's body geometry was reconstructed:
|
|
8
|
+
* - `PARAMETRIC` — rebuilt losslessly from a swept solid (extrude/revolve).
|
|
9
|
+
* - `TESSELLATED_MANIFOLD` — a tessellated mesh was recovered as a closed solid
|
|
10
|
+
* via an STL round-trip; geometrically faithful but topology was re-derived.
|
|
11
|
+
* - `TESSELLATED_LOSSY` — geometry exists only as raw triangles (mesh did not
|
|
12
|
+
* close into a solid); `solid` is null, `meshVertices`/`meshIndices` carry it.
|
|
13
|
+
* - `NONE` — no recognised body representation was found.
|
|
14
|
+
*/
|
|
15
|
+
export type GeometryFidelity = 'PARAMETRIC' | 'TESSELLATED_MANIFOLD' | 'TESSELLATED_LOSSY' | 'NONE';
|
|
16
|
+
export interface ImportedGeometry {
|
|
17
|
+
readonly fidelity: GeometryFidelity;
|
|
18
|
+
/** The reconstructed solid; null when fidelity is `NONE` or `TESSELLATED_LOSSY`. */
|
|
19
|
+
readonly solid: ValidSolid | null;
|
|
20
|
+
/** Raw triangle vertices (interleaved xyz), present only for `TESSELLATED_LOSSY`. */
|
|
21
|
+
readonly meshVertices?: Float32Array | undefined;
|
|
22
|
+
/** Raw triangle indices, present only for `TESSELLATED_LOSSY`. */
|
|
23
|
+
readonly meshIndices?: Uint32Array | undefined;
|
|
24
|
+
}
|
|
25
|
+
export interface ImportedPset {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
/** `true` when sourced from an IfcElementQuantity rather than an IfcPropertySet. */
|
|
28
|
+
readonly isQuantity: boolean;
|
|
29
|
+
readonly properties: Readonly<Record<string, string | number | boolean>>;
|
|
30
|
+
/**
|
|
31
|
+
* Per-property IFC measure-type codes (web-ifc type constants), keyed by the
|
|
32
|
+
* same property name as `properties`. Lets callers distinguish e.g. an
|
|
33
|
+
* IfcThermalTransmittanceMeasure from a plain IfcReal. Absent entries fall back
|
|
34
|
+
* to the value's JS type.
|
|
35
|
+
*/
|
|
36
|
+
readonly measureTypes: Readonly<Record<string, number>>;
|
|
37
|
+
}
|
|
38
|
+
export interface ImportedMaterial {
|
|
39
|
+
readonly kind: 'SIMPLE' | 'LAYER_SET';
|
|
40
|
+
readonly name: string;
|
|
41
|
+
readonly layers?: readonly {
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly thicknessMm: number;
|
|
44
|
+
}[] | undefined;
|
|
45
|
+
}
|
|
46
|
+
export interface ImportedClassification {
|
|
47
|
+
readonly system: string;
|
|
48
|
+
readonly code: string;
|
|
49
|
+
readonly description?: string | undefined;
|
|
50
|
+
}
|
|
51
|
+
export type ImportedElementCategory = 'WALL' | 'SLAB' | 'BEAM' | 'COLUMN' | 'DOOR' | 'WINDOW' | 'OPENING' | 'SPACE' | 'ROOF' | 'CURTAIN_WALL' | 'FOOTING' | 'PILE' | 'STAIR' | 'RAMP' | 'RAILING' | 'COVERING' | 'ELEMENT_ASSEMBLY' | 'PROXY';
|
|
52
|
+
export interface ImportedElement {
|
|
53
|
+
readonly expressId: number;
|
|
54
|
+
readonly guid: IfcGuid;
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly category: ImportedElementCategory;
|
|
57
|
+
readonly predefinedType?: string | undefined;
|
|
58
|
+
readonly storeyExpressId?: number | undefined;
|
|
59
|
+
readonly geometry: ImportedGeometry;
|
|
60
|
+
readonly psets: readonly ImportedPset[];
|
|
61
|
+
readonly material: ImportedMaterial | null;
|
|
62
|
+
readonly classification: ImportedClassification | null;
|
|
63
|
+
/** Express ids of opening elements that void this element. */
|
|
64
|
+
readonly voidedBy: readonly number[];
|
|
65
|
+
/** Express id of the opening this element fills (doors/windows only). */
|
|
66
|
+
readonly fills?: number | undefined;
|
|
67
|
+
}
|
|
68
|
+
export interface ImportedSpatialNode {
|
|
69
|
+
readonly expressId: number;
|
|
70
|
+
readonly guid: IfcGuid;
|
|
71
|
+
readonly name: string;
|
|
72
|
+
readonly category: 'PROJECT' | 'SITE' | 'BUILDING' | 'STOREY';
|
|
73
|
+
readonly elevationMm?: number | undefined;
|
|
74
|
+
readonly children: readonly ImportedSpatialNode[];
|
|
75
|
+
readonly containedElements: readonly number[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Frees every reconstructed solid handle held by an imported model. The
|
|
79
|
+
* geometry are live WASM handles, so callers MUST call this once they are done
|
|
80
|
+
* with the model (it is not reclaimed automatically when the model is GC'd).
|
|
81
|
+
*/
|
|
82
|
+
export declare function disposeImportedModel(model: ImportedModel): void;
|
|
83
|
+
/**
|
|
84
|
+
* The reconstructed model. Holds live WASM solid handles in `elements[].geometry`;
|
|
85
|
+
* call {@link disposeImportedModel} when finished to avoid leaking them.
|
|
86
|
+
*/
|
|
87
|
+
export interface ImportedModel {
|
|
88
|
+
readonly schema: ImportedSchema;
|
|
89
|
+
readonly spatialTree: ImportedSpatialNode | null;
|
|
90
|
+
readonly elements: readonly ImportedElement[];
|
|
91
|
+
/** Express id → ImportedElement for fast lookup. */
|
|
92
|
+
readonly byExpressId: ReadonlyMap<number, ImportedElement>;
|
|
93
|
+
readonly diagnostics: ValidationReport;
|
|
94
|
+
readonly applicationName?: string | undefined;
|
|
95
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { SpfReader } from './spfReader.js';
|
|
2
|
+
/**
|
|
3
|
+
* Column-major 4x4 transform, matching the layout web-ifc and OCCT use:
|
|
4
|
+
* column c, row r lives at index c*4 + r. Columns 0-2 are the basis vectors
|
|
5
|
+
* (axisX, axisY, axisZ); column 3 is the translation; the bottom row is
|
|
6
|
+
* [0,0,0,1].
|
|
7
|
+
*/
|
|
8
|
+
export type Mat4x4 = readonly [
|
|
9
|
+
number,
|
|
10
|
+
number,
|
|
11
|
+
number,
|
|
12
|
+
number,
|
|
13
|
+
number,
|
|
14
|
+
number,
|
|
15
|
+
number,
|
|
16
|
+
number,
|
|
17
|
+
number,
|
|
18
|
+
number,
|
|
19
|
+
number,
|
|
20
|
+
number,
|
|
21
|
+
number,
|
|
22
|
+
number,
|
|
23
|
+
number,
|
|
24
|
+
number
|
|
25
|
+
];
|
|
26
|
+
export type Vec3 = readonly [number, number, number];
|
|
27
|
+
/** A placement decomposed into origin + the two stored IFC axes (Z, X). */
|
|
28
|
+
export interface WorldPlacement {
|
|
29
|
+
/** Translation in millimetres (file units scaled to mm). */
|
|
30
|
+
readonly origin: Vec3;
|
|
31
|
+
/** Local X direction in world space (IFC RefDirection), unit length. */
|
|
32
|
+
readonly axisX: Vec3;
|
|
33
|
+
/** Local Z direction in world space (IFC Axis), unit length. */
|
|
34
|
+
readonly axisZ: Vec3;
|
|
35
|
+
}
|
|
36
|
+
/** Georeferencing offset recovered from IfcMapConversion, in millimetres. */
|
|
37
|
+
export interface Georef {
|
|
38
|
+
readonly eastings: number;
|
|
39
|
+
readonly northings: number;
|
|
40
|
+
readonly orthogonalHeight: number;
|
|
41
|
+
/** Rotation of true north relative to model +X, in radians. */
|
|
42
|
+
readonly rotation: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Metres-per-file-unit length scale read from the IfcUnitAssignment's
|
|
46
|
+
* LENGTHUNIT. Multiply a file-unit length by this to get metres, then by 1000
|
|
47
|
+
* for brepjs millimetres. Returns 1.0 (assume metres) when no length unit is
|
|
48
|
+
* declared.
|
|
49
|
+
*/
|
|
50
|
+
export declare function readLengthScale(reader: SpfReader): number;
|
|
51
|
+
/**
|
|
52
|
+
* Radians-per-file-unit plane-angle scale read from the IfcUnitAssignment's
|
|
53
|
+
* PLANEANGLEUNIT (1 for RADIAN, ~0.0174533 for DEGREE). Defaults to 1 (the IFC
|
|
54
|
+
* default plane-angle unit is the radian).
|
|
55
|
+
*/
|
|
56
|
+
export declare function readPlaneAngleScale(reader: SpfReader): number;
|
|
57
|
+
/**
|
|
58
|
+
* Composes the full IfcLocalPlacement chain rooted at `placementExpressId` into
|
|
59
|
+
* a column-major world matrix, scaling translations to millimetres via `scale`
|
|
60
|
+
* (metres-per-file-unit). Returns null if the placement cannot be resolved.
|
|
61
|
+
*
|
|
62
|
+
* Walks `PlacementRelTo` recursively and pre-multiplies each parent transform,
|
|
63
|
+
* mirroring how the writer nests element → storey → building → site → project.
|
|
64
|
+
* This is independent of the geometry engine, so it is unaffected by the
|
|
65
|
+
* COORDINATE_TO_ORIGIN recenter flag.
|
|
66
|
+
*/
|
|
67
|
+
export declare function composeWorldMatrix(reader: SpfReader, placementExpressId: number, scale: number): Mat4x4 | null;
|
|
68
|
+
/**
|
|
69
|
+
* Composes the placement chain and returns it decomposed into origin + axes,
|
|
70
|
+
* the form spec reconstruction consumes. Returns null on failure.
|
|
71
|
+
*/
|
|
72
|
+
export declare function composeWorldPlacement(reader: SpfReader, placementExpressId: number, scale: number): WorldPlacement | null;
|
|
73
|
+
/**
|
|
74
|
+
* Reads a single IfcAxis2Placement3D into a column-major matrix. Location is
|
|
75
|
+
* scaled to mm; Axis (local Z) and RefDirection (local X) default to +Z/+X and
|
|
76
|
+
* are orthonormalised (local Y = Z Ă— X, local X = Y Ă— Z) so the basis is
|
|
77
|
+
* always a proper rotation.
|
|
78
|
+
*/
|
|
79
|
+
export declare function readAxis2Placement3D(reader: SpfReader, placementExpressId: number, scale: number): Mat4x4 | null;
|
|
80
|
+
/** Decomposes a column-major matrix into origin (mm) + IFC axes (Z, X). */
|
|
81
|
+
export declare function decomposePlacement(m: Mat4x4): WorldPlacement;
|
|
82
|
+
export declare function identityMatrix(): Mat4x4;
|
|
83
|
+
/**
|
|
84
|
+
* Reads the IfcMapConversion georeferencing offset (Eastings/Northings/
|
|
85
|
+
* OrthogonalHeight, scaled to mm) and true-north rotation. Returns null when
|
|
86
|
+
* the model carries no IfcMapConversion. Use this to recenter far-from-origin
|
|
87
|
+
* coordinates: subtract the offset to bring geometry near the origin.
|
|
88
|
+
*/
|
|
89
|
+
export declare function readGeoref(reader: SpfReader, scale: number): Georef | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SpfReader } from './spfReader.js';
|
|
2
|
+
/**
|
|
3
|
+
* A reconstructed spatial-structure node. The tree mirrors the IFC spatial
|
|
4
|
+
* containment hierarchy (`IfcProject → IfcSite → IfcBuilding → IfcBuildingStorey`)
|
|
5
|
+
* rebuilt from `IfcRelAggregates`, with physical elements attached to their
|
|
6
|
+
* storey via `IfcRelContainedInSpatialStructure`.
|
|
7
|
+
*
|
|
8
|
+
* Nodes are addressable by {@link SpatialNode.guid} (the IFC `GlobalId`).
|
|
9
|
+
*/
|
|
10
|
+
export interface SpatialNode {
|
|
11
|
+
readonly expressId: number;
|
|
12
|
+
readonly guid: string;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly category: 'PROJECT' | 'SITE' | 'BUILDING' | 'STOREY';
|
|
15
|
+
/** Storey elevation in mm; present on `STOREY` nodes only. */
|
|
16
|
+
readonly elevation?: number | undefined;
|
|
17
|
+
readonly children: readonly SpatialNode[];
|
|
18
|
+
/** Express ids of elements contained directly in this node. */
|
|
19
|
+
readonly containedElements: readonly number[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Reconstructs the spatial-structure tree from `IfcRelAggregates` and attaches
|
|
23
|
+
* contained elements via `IfcRelContainedInSpatialStructure`. Walks top-down
|
|
24
|
+
* from the single `IfcProject`. Returns `null` when no `IfcProject` is present.
|
|
25
|
+
*
|
|
26
|
+
* @param scale metres-per-file-unit; storey elevations are scaled to mm as
|
|
27
|
+
* `Elevation Ă— scale Ă— 1000` to match the `BimModel` input contract.
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildSpatialTree(reader: SpfReader, scale: number): SpatialNode | null;
|
|
30
|
+
/**
|
|
31
|
+
* Returns a flat map of element express id → containing spatial-structure
|
|
32
|
+
* express id, built from every `IfcRelContainedInSpatialStructure` line. When
|
|
33
|
+
* an element appears in multiple containment relations, the last one wins.
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildElementContainmentMap(reader: SpfReader): Map<number, number>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { FlatMesh, IfcGeometry } from 'web-ifc';
|
|
2
|
+
import { BimError } from '../errors/bimError.js';
|
|
3
|
+
import { Result } from 'brepjs';
|
|
4
|
+
/** Schema strings web-ifc reports and this reader supports. */
|
|
5
|
+
export type ImportedSchema = 'IFC2X3' | 'IFC4' | 'IFC4X3';
|
|
6
|
+
export interface SpfReaderSettings {
|
|
7
|
+
/**
|
|
8
|
+
* Activate web-ifc's built-in large-coordinate recentering on open. Defaults
|
|
9
|
+
* to false; set true for georeferenced models with far-from-origin geometry.
|
|
10
|
+
*/
|
|
11
|
+
readonly coordinateToOrigin?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class SpfReader {
|
|
14
|
+
#private;
|
|
15
|
+
readonly schema: ImportedSchema;
|
|
16
|
+
readonly modelId: number;
|
|
17
|
+
private constructor();
|
|
18
|
+
static create(bytes: Uint8Array, settings?: SpfReaderSettings): Promise<Result<SpfReader, BimError>>;
|
|
19
|
+
/** Always issues CloseModel; safe to call more than once. */
|
|
20
|
+
close(): void;
|
|
21
|
+
[Symbol.dispose](): void;
|
|
22
|
+
/**
|
|
23
|
+
* Raw line object for an express id. With `flatten=false` (default) references
|
|
24
|
+
* appear as `{ type, value }` wrappers and nested entities are not resolved;
|
|
25
|
+
* pass `flatten=true` to recursively inline referenced lines.
|
|
26
|
+
*/
|
|
27
|
+
getLine<T = unknown>(expressId: number, flatten?: boolean): T | null;
|
|
28
|
+
/** Express ids of every line whose type equals `type` (no inherited types). */
|
|
29
|
+
getLinesOfType(type: number): number[];
|
|
30
|
+
/** Express ids of every line in the model. */
|
|
31
|
+
getAllLines(): number[];
|
|
32
|
+
/** IFC type code for an express id. */
|
|
33
|
+
getLineType(expressId: number): number;
|
|
34
|
+
/** Builds web-ifc's internal GUID→expressId index; call before guid lookups. */
|
|
35
|
+
buildGuidMap(): void;
|
|
36
|
+
/** expressId for a GlobalId, or undefined. Requires {@link buildGuidMap} first. */
|
|
37
|
+
expressIdFromGuid(guid: string): number | undefined;
|
|
38
|
+
/** GlobalId for an express id, or undefined. Requires {@link buildGuidMap} first. */
|
|
39
|
+
guidFromExpressId(expressId: number): string | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Composed world transform (column-major 16-float matrix) for a placement
|
|
42
|
+
* express id, resolving the full IfcLocalPlacement chain.
|
|
43
|
+
*/
|
|
44
|
+
getWorldTransform(placementExpressId: number): number[];
|
|
45
|
+
/** Streams placed meshes for the given product express ids. */
|
|
46
|
+
streamMeshes(expressIds: number[], cb: (mesh: FlatMesh, index: number, total: number) => void): void;
|
|
47
|
+
/** Geometry buffers for a geometry express id; caller MUST call `.delete()`. */
|
|
48
|
+
getGeometry(geometryExpressId: number): IfcGeometry;
|
|
49
|
+
/** Reads a Float32Array view of vertex data from a WASM pointer. */
|
|
50
|
+
getVertexArray(ptr: number, size: number): Float32Array;
|
|
51
|
+
/** Reads a Uint32Array view of index data from a WASM pointer. */
|
|
52
|
+
getIndexArray(ptr: number, size: number): Uint32Array;
|
|
53
|
+
/** Decodes IFC STEP string escapes (`\X2\`, `\S\`, `\X\`) in a raw value. */
|
|
54
|
+
decodeText(s: string): string;
|
|
55
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export { BimModel } from './model/bimModel.js';
|
|
2
|
+
export { toIfc, toIfcValidated } from './serialize/toIfc.js';
|
|
3
|
+
export type { ValidatedIfcResult } from './serialize/toIfc.js';
|
|
4
|
+
export { fromIfc } from './import/fromIfc.js';
|
|
5
|
+
export { disposeImportedModel } from './import/importedModel.js';
|
|
6
|
+
export type { FromIfcOptions } from './import/fromIfc.js';
|
|
7
|
+
export { SpfReader } from './import/spfReader.js';
|
|
8
|
+
export type { SpfReaderSettings } from './import/spfReader.js';
|
|
9
|
+
export { parseWallSpec } from './specs/wallSpec.js';
|
|
10
|
+
export { parseSlabSpec } from './specs/slabSpec.js';
|
|
11
|
+
export { parseBeamSpec } from './specs/beamSpec.js';
|
|
12
|
+
export { parseColumnSpec } from './specs/columnSpec.js';
|
|
13
|
+
export { parseProfile, isExtendedProfile } from './specs/profile.js';
|
|
14
|
+
export { extendedProfileToFace, extendedProfileArea } from './specs/profilesExtended.js';
|
|
15
|
+
export { parseSpaceSpec } from './specs/spaceSpec.js';
|
|
16
|
+
export { parseRoofSpec } from './specs/roofSpec.js';
|
|
17
|
+
export { parseCurtainWallSpec } from './specs/curtainWallSpec.js';
|
|
18
|
+
export { parseFootingSpec, parsePileSpec } from './specs/foundationSpec.js';
|
|
19
|
+
export { parseStairSpec, parseStairFlightSpec } from './specs/stairSpec.js';
|
|
20
|
+
export { parseRampSpec, parseRampFlightSpec } from './specs/rampSpec.js';
|
|
21
|
+
export { parseRailingSpec } from './specs/railingSpec.js';
|
|
22
|
+
export { parseCoveringSpec } from './specs/coveringSpec.js';
|
|
23
|
+
export { parseElementAssemblySpec } from './specs/assemblySpec.js';
|
|
24
|
+
export { parseZoneSpec, parseSystemSpec } from './specs/groupSpec.js';
|
|
25
|
+
export { parseSurfaceStyleSpec } from './specs/styleSpec.js';
|
|
26
|
+
export { parseDoorSpec, parseWindowSpec, parseSlabOpeningInput } from './specs/openingSpec.js';
|
|
27
|
+
export { newIfcGuid, isValidIfcGuid } from './identity/ifcGuid.js';
|
|
28
|
+
export { deriveIfcGuid, deriveIfcGuidSync } from './identity/guidDerivation.js';
|
|
29
|
+
export { makeLocalIdCounter } from './identity/localId.js';
|
|
30
|
+
export { checkReferentialIntegrity } from './validation/referentialIntegrity.js';
|
|
31
|
+
export { checkSchema } from './validation/schemaCheck.js';
|
|
32
|
+
export { checkRoundTrip } from './validation/roundTrip.js';
|
|
33
|
+
export { checkGeometryValidity } from './validation/geometryValidity.js';
|
|
34
|
+
export { issue, emptyReport, hasErrors, countBySeverity, } from './validation/severity.js';
|
|
35
|
+
export { writeIfcType } from './ifc-writer/typeWriter.js';
|
|
36
|
+
export { writeZoneEntity, writeSystemEntity, writeRelAssignsToGroup, } from './ifc-writer/groupWriter.js';
|
|
37
|
+
export { IFC_SCHEMAS, DEFAULT_IFC_SCHEMA, fileSchemaString, isIfcSchema, schemaSupports, } from './ifc-writer/schemaVersion.js';
|
|
38
|
+
export { writeElementAssemblyEntity, writeRelAggregatesElements, writeRelNests, } from './ifc-writer/assemblyWriter.js';
|
|
39
|
+
export { writeSurfaceStyle, writeStyledItem, writePresentationLayer, } from './ifc-writer/styleWriter.js';
|
|
40
|
+
export { writeRelConnectsElements, writeRelConnectsPathElements, } from './ifc-writer/connectivityWriter.js';
|
|
41
|
+
export { writeMaterialLayerSet, writeMaterialProfileSet, writeMaterialSimple, } from './ifc-writer/materialWriter.js';
|
|
42
|
+
export { writeClassificationRefs } from './ifc-writer/classificationWriter.js';
|
|
43
|
+
export { PSET_TEMPLATES, PSET_PROPERTY_TYPE_TABLE, measureTypeFor, templateFor, } from './psets/psetTemplates.js';
|
|
44
|
+
export { DEFAULT_UNITS, toLengthMm, toIfcLengthM } from './units/units.js';
|
|
45
|
+
export { specError, ifcError, geometryError, fromBrepError } from './errors/bimError.js';
|
|
46
|
+
export type { WallSpec } from './specs/wallSpec.js';
|
|
47
|
+
export type { SlabSpec, SlabPredefinedType } from './specs/slabSpec.js';
|
|
48
|
+
export type { BeamSpec, BeamPredefinedType } from './specs/beamSpec.js';
|
|
49
|
+
export type { ColumnSpec, ColumnPredefinedType } from './specs/columnSpec.js';
|
|
50
|
+
export type { Profile, CoreProfile, RectangularProfile, CircularProfile, IShapeProfile, } from './specs/profile.js';
|
|
51
|
+
export type { ExtendedProfile, LShapeProfile, TShapeProfile, UShapeProfile, ZShapeProfile, CShapeProfile, AsymmetricIShapeProfile, EllipseProfile, TrapeziumProfile, RectangleHollowProfile, CircleHollowProfile, ArbitraryClosedProfile, ArbitraryProfileWithVoids, } from './specs/profilesExtended.js';
|
|
52
|
+
export type { SpaceSpec, SpacePredefinedType } from './specs/spaceSpec.js';
|
|
53
|
+
export type { RoofSpec, RoofPredefinedType } from './specs/roofSpec.js';
|
|
54
|
+
export type { CurtainWallSpec, CurtainWallPredefinedType } from './specs/curtainWallSpec.js';
|
|
55
|
+
export type { CurtainWallGrid, CurtainWallComponent } from './elementFns/curtainWallFns.js';
|
|
56
|
+
export type { FootingSpec, PileSpec, FootingPredefinedType, PilePredefinedType, PileConstructionType, } from './specs/foundationSpec.js';
|
|
57
|
+
export type { StairSpec, StairFlightSpec, StairPredefinedType, } from './specs/stairSpec.js';
|
|
58
|
+
export type { RampSpec, RampFlightSpec, RampPredefinedType, RampFlightPredefinedType, } from './specs/rampSpec.js';
|
|
59
|
+
export type { RailingSpec, RailingPredefinedType } from './specs/railingSpec.js';
|
|
60
|
+
export type { CoveringSpec, CoveringPredefinedType } from './specs/coveringSpec.js';
|
|
61
|
+
export type { ElementAssemblySpec, AssemblyPredefinedType, AssemblyPlace, } from './specs/assemblySpec.js';
|
|
62
|
+
export type { ZoneSpec, SystemSpec } from './specs/groupSpec.js';
|
|
63
|
+
export type { SurfaceStyleSpec } from './specs/styleSpec.js';
|
|
64
|
+
export type { AssemblyPlaceIfc, ElementAssemblyPredefinedTypeIfc, } from './ifc-writer/assemblyWriter.js';
|
|
65
|
+
export type { PathConnectionTypeIfc } from './ifc-writer/connectivityWriter.js';
|
|
66
|
+
export type { DoorSpec, WindowSpec, SlabOpeningInput } from './specs/openingSpec.js';
|
|
67
|
+
export type { ProxySpec } from './specs/proxySpec.js';
|
|
68
|
+
export type { ProjectSpec, SiteSpec, BuildingSpec, StoreySpec } from './specs/spatialSpec.js';
|
|
69
|
+
export type { BimCategory, BimElement, AnyBimElement, OpeningSpec, WallOpeningSpec, SlabOpeningSpec } from './types/bimTypes.js';
|
|
70
|
+
export { isWallOpening, isSlabOpening } from './types/bimTypes.js';
|
|
71
|
+
export type { BimRelationship, AssociatesMaterialRel, AssociatesClassificationRel, VoidsWallRel, VoidsSlabRel, FillsOpeningRel, SpaceBoundaryRel, NestsRel, ConnectsElementsRel, ConnectsPathElementsRel, CoversElementRel, AssignsToGroupRel, } from './types/relationships.js';
|
|
72
|
+
export type { MaterialLayer } from './types/materialTypes.js';
|
|
73
|
+
export type { MaterialLayerSetSpec, MaterialProfileSpec, MaterialSpec, } from './ifc-writer/materialWriter.js';
|
|
74
|
+
export type { ClassificationRef } from './types/classificationTypes.js';
|
|
75
|
+
export type { PsetCategory, PsetMeasureType, PsetTemplate, PsetPropertyTemplate, } from './psets/psetTemplates.js';
|
|
76
|
+
export { importError } from './errors/bimError.js';
|
|
77
|
+
export type { BimError, BimErrorKind } from './errors/bimError.js';
|
|
78
|
+
export type { ImportedModel, ImportedSchema, ImportedElement, ImportedElementCategory, ImportedGeometry, GeometryFidelity, ImportedPset, ImportedMaterial, ImportedClassification, ImportedSpatialNode, } from './import/importedModel.js';
|
|
79
|
+
export type { IfcGuid } from './identity/ifcGuid.js';
|
|
80
|
+
export type { LocalId, LocalIdCounter } from './identity/localId.js';
|
|
81
|
+
export type { UnitSystem, LengthUnit } from './units/units.js';
|
|
82
|
+
export type { BimModelMeta } from './ifc-writer/headerWriter.js';
|
|
83
|
+
export type { ValidationSeverity, ValidationIssue, ValidationReport, SeverityCounts, } from './validation/severity.js';
|
|
84
|
+
export type { ModelGraph, IntegrityInput } from './validation/referentialIntegrity.js';
|
|
85
|
+
export type { RoundTripReport, EntityCounts } from './validation/roundTrip.js';
|
|
86
|
+
export type { IfcTypeName, TypeWriteResult } from './ifc-writer/typeWriter.js';
|
|
87
|
+
export type { IfcSchema } from './ifc-writer/schemaVersion.js';
|
|
88
|
+
export type { OwnerHistoryAuthor, OwnerHistoryMeta } from './ifc-writer/ownerHistoryWriter.js';
|
|
89
|
+
export { deriveCobieModel, deriveCobieModel as exportCobie, serializeCobieToCsv, serializeCobieToJson, } from './cobie/index.js';
|
|
90
|
+
export type { CobieModel, CobieJson, CobieExportMeta, CobieContactMeta, CobieContactRow, CobieFacilityRow, CobieFloorRow, CobieSpaceRow, CobieZoneRow, CobieTypeRow, CobieComponentRow, CobieSystemRow, CobieAttributeRow, } from './cobie/index.js';
|
|
91
|
+
export { parseIdsXml, checkModelAgainstIds, checkModelAgainstIds as checkIds, } from './ids/index.js';
|
|
92
|
+
export type { IdsDocument, IdsSpecification, IdsFacet, IdsRestriction, IdsCardinality, IdsCheckReport, IdsCheckResult, } from './ids/index.js';
|
|
93
|
+
export { serializeBcfFiles, parseBcfFiles } from './bcf/index.js';
|
|
94
|
+
export type { BcfColoring, BcfComment, BcfComponent, BcfComponents, BcfContainerData, BcfFiles, BcfProject, BcfTopic, BcfVersion, BcfViewpoint, BcfVisibility, } from './bcf/index.js';
|
|
95
|
+
export { bcfError, idsError } from './errors/bimError.js';
|