brepjs-bim 0.1.0 → 0.3.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/README.md +25 -2
- package/dist/brepjs-bim.cjs +984 -459
- package/dist/brepjs-bim.js +987 -464
- package/dist/elementFns/placedGeometry.d.ts +18 -0
- package/dist/identity/ifcGuid.d.ts +1 -0
- package/dist/ifc-writer/geometryWriter.d.ts +4 -1
- package/dist/ifc-writer/ifcWriter.d.ts +5 -1
- package/dist/ifc-writer/railingWriter.d.ts +9 -3
- package/dist/ifcRuntime.d.ts +20 -0
- package/dist/import/placement.d.ts +18 -0
- package/dist/index.d.ts +3 -0
- package/dist/model/bimModel.d.ts +8 -0
- package/dist/model/treeSummary.d.ts +21 -0
- package/dist/specs/profile.d.ts +2 -0
- package/dist/specs/railingSpec.d.ts +6 -0
- package/dist/specs/roofSpec.d.ts +7 -0
- package/package.json +27 -6
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ValidSolid, Result } from 'brepjs';
|
|
2
|
+
import { AnyBimElement } from '../types/bimTypes.js';
|
|
3
|
+
import { BimError } from '../errors/bimError.js';
|
|
4
|
+
/**
|
|
5
|
+
* Returns each element's geometry transformed to its world placement, as fresh
|
|
6
|
+
* caller-owned solids, wrapped in a `Result` (Layer-2 code prefers `Result` over
|
|
7
|
+
* throwing). **Dispose the returned solids** (e.g. via `using` / `[Symbol.dispose]`)
|
|
8
|
+
* when you own their lifetime — they are independent of the model
|
|
9
|
+
* (`BimModel[Symbol.dispose]` frees only the stored, unplaced `.geometry`). On any
|
|
10
|
+
* failure the solids already built for this call are disposed before the error is
|
|
11
|
+
* returned, so no partial array is leaked.
|
|
12
|
+
*
|
|
13
|
+
* Stairs carry no element solid (`.geometry` is null), so flight solids are built
|
|
14
|
+
* from `spec.flights` and placed per flight. Curtain walls return placed panels +
|
|
15
|
+
* mullions. Elements with no solid geometry (doors/windows/ramps/groups/spatial)
|
|
16
|
+
* return an empty array.
|
|
17
|
+
*/
|
|
18
|
+
export declare function placedSolids(el: AnyBimElement): Result<readonly ValidSolid[], BimError>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ValidSolid } from 'brepjs';
|
|
1
2
|
import { IfcWriter } from './ifcWriter.js';
|
|
2
3
|
import { WallSpec } from '../specs/wallSpec.js';
|
|
3
4
|
import { SlabSpec } from '../specs/slabSpec.js';
|
|
@@ -19,7 +20,9 @@ export interface LinearElementRepresentationIds {
|
|
|
19
20
|
}
|
|
20
21
|
export declare function writeWallGeometry(w: IfcWriter, spec: WallSpec, geomSubContextId: number, parentPlacementId: number | null): WallRepresentationIds;
|
|
21
22
|
export declare function writeSlabGeometry(w: IfcWriter, spec: SlabSpec, geomSubContextId: number, parentPlacementId: number | null): SlabRepresentationIds;
|
|
22
|
-
export declare function writeRoofGeometry(w: IfcWriter, spec: RoofSpec, geomSubContextId: number, parentPlacementId: number | null): SlabRepresentationIds
|
|
23
|
+
export declare function writeRoofGeometry(w: IfcWriter, spec: RoofSpec, solid: ValidSolid, geomSubContextId: number, parentPlacementId: number | null): SlabRepresentationIds & {
|
|
24
|
+
usedFallback: boolean;
|
|
25
|
+
};
|
|
23
26
|
export declare function writeProfile(w: IfcWriter, profile: Profile): number;
|
|
24
27
|
export declare function writeBeamGeometry(w: IfcWriter, spec: BeamSpec, geomSubContextId: number, parentPlacementId: number | null): LinearElementRepresentationIds;
|
|
25
28
|
export declare function writeColumnGeometry(w: IfcWriter, spec: ColumnSpec, geomSubContextId: number, parentPlacementId: number | null): LinearElementRepresentationIds;
|
|
@@ -5,10 +5,14 @@ import { IfcSchema } from './schemaVersion.js';
|
|
|
5
5
|
import { Result } from 'brepjs';
|
|
6
6
|
/** Default MVD ViewDefinition declared in the STEP FILE_DESCRIPTION header. */
|
|
7
7
|
export declare const DEFAULT_MVD_VIEW_DEFINITION = "ReferenceView_v1.2";
|
|
8
|
+
export interface IfcHeaderMeta {
|
|
9
|
+
readonly author?: string | undefined;
|
|
10
|
+
readonly organization?: string | undefined;
|
|
11
|
+
}
|
|
8
12
|
export declare class IfcWriter {
|
|
9
13
|
#private;
|
|
10
14
|
private constructor();
|
|
11
|
-
static create(mvdViewDefinition?: string, ifcSchema?: IfcSchema): Promise<Result<IfcWriter, BimError>>;
|
|
15
|
+
static create(mvdViewDefinition?: string, ifcSchema?: IfcSchema, header?: IfcHeaderMeta): Promise<Result<IfcWriter, BimError>>;
|
|
12
16
|
nextId(): number;
|
|
13
17
|
/**
|
|
14
18
|
* Deterministic GlobalId for a writer-minted line, keyed on its express ID.
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
import { ValidSolid } from 'brepjs';
|
|
1
2
|
import { IfcWriter } from './ifcWriter.js';
|
|
2
3
|
import { IfcGuid } from '../identity/ifcGuid.js';
|
|
3
4
|
import { RailingSpec, RailingPredefinedType } from '../specs/railingSpec.js';
|
|
4
5
|
export interface RailingRepresentationIds {
|
|
5
6
|
localPlacementId: number;
|
|
6
7
|
productDefinitionShapeId: number;
|
|
7
|
-
/**
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Express ID of the body representation item (the swept extrusion) for surface
|
|
10
|
+
* styling, or null for a tessellated POSTED railing (no single styleable item).
|
|
11
|
+
*/
|
|
12
|
+
bodyItemId: number | null;
|
|
13
|
+
/** True when tessellation fell back to a degenerate brep. */
|
|
14
|
+
usedFallback: boolean;
|
|
9
15
|
}
|
|
10
|
-
export declare function writeRailingGeometry(w: IfcWriter, spec: RailingSpec, geomSubContextId: number, parentPlacementId: number | null): RailingRepresentationIds;
|
|
16
|
+
export declare function writeRailingGeometry(w: IfcWriter, spec: RailingSpec, solid: ValidSolid, geomSubContextId: number, parentPlacementId: number | null): RailingRepresentationIds;
|
|
11
17
|
export declare function writeRailingEntity(w: IfcWriter, guid: IfcGuid, name: string, predefinedType: RailingPredefinedType, ownerHistoryId: number, localPlacementId: number, productDefinitionShapeId: number): number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IfcAPI } from 'web-ifc';
|
|
2
|
+
/**
|
|
3
|
+
* Override how web-ifc finds its `.wasm` file. Applied by every web-ifc entry
|
|
4
|
+
* point in this package — IFC export ({@link toIfc}), import ({@link fromIfc})
|
|
5
|
+
* and validation. Required when brepjs-bim is bundled into a worker that serves
|
|
6
|
+
* the wasm itself; not needed in Node.
|
|
7
|
+
*/
|
|
8
|
+
export declare function setIfcWasmLocateFile(locate: ((path: string, prefix: string) => string) | undefined): void;
|
|
9
|
+
/**
|
|
10
|
+
* Initialize a web-ifc API instance the way this package always wants it: with
|
|
11
|
+
* the host-provided wasm locator and forced single-threaded.
|
|
12
|
+
*
|
|
13
|
+
* Single-threaded matters in a cross-origin-isolated context (e.g. a page that
|
|
14
|
+
* sets COOP/COEP for another WASM kernel): web-ifc would otherwise load its
|
|
15
|
+
* pthread build and spawn a sub-Worker, which fails when brepjs-bim is itself
|
|
16
|
+
* bundled inside a Web Worker. In Node the flag is a no-op (web-ifc is already
|
|
17
|
+
* single-threaded there), and multithreading only speeds up parsing/geometry,
|
|
18
|
+
* not the one-shot serialize/read this package does.
|
|
19
|
+
*/
|
|
20
|
+
export declare function initIfcApi(api: IfcAPI): Promise<void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MatrixTransform } from 'brepjs';
|
|
1
2
|
import { SpfReader } from './spfReader.js';
|
|
2
3
|
/**
|
|
3
4
|
* Column-major 4x4 transform, matching the layout web-ifc and OCCT use:
|
|
@@ -77,6 +78,23 @@ export declare function composeWorldPlacement(reader: SpfReader, placementExpres
|
|
|
77
78
|
* always a proper rotation.
|
|
78
79
|
*/
|
|
79
80
|
export declare function readAxis2Placement3D(reader: SpfReader, placementExpressId: number, scale: number): Mat4x4 | null;
|
|
81
|
+
/** An (origin, axisX, axisZ) frame in mm — the authoring/display side of a placement. */
|
|
82
|
+
export interface FrameInput {
|
|
83
|
+
readonly origin: Vec3;
|
|
84
|
+
readonly axisX: Vec3;
|
|
85
|
+
readonly axisZ: Vec3;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Builds a row-major MatrixTransform (for brepjs `applyMatrix`) from an
|
|
89
|
+
* (origin, axisX, axisZ) frame, using the SAME IFC orthonormalization as
|
|
90
|
+
* {@link readAxis2Placement3D}: z = normalize(axisZ); x = normalize(axisX
|
|
91
|
+
* projected onto the plane ⊥ z); y = z × x. The basis vectors are the matrix
|
|
92
|
+
* columns, so the row-major linear array is [Xx,Yx,Zx, Xy,Yy,Zy, Xz,Yz,Zz];
|
|
93
|
+
* translation = origin (mm). This is the display-side counterpart to the IFC
|
|
94
|
+
* writer's Axis2Placement3D (Axis=Z, RefDirection=X) so on-screen placement and
|
|
95
|
+
* the IFC export agree.
|
|
96
|
+
*/
|
|
97
|
+
export declare function placementToMatrix(f: FrameInput): MatrixTransform;
|
|
80
98
|
/** Decomposes a column-major matrix into origin (mm) + IFC axes (Z, X). */
|
|
81
99
|
export declare function decomposePlacement(m: Mat4x4): WorldPlacement;
|
|
82
100
|
export declare function identityMatrix(): Mat4x4;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { BimModel } from './model/bimModel.js';
|
|
2
|
+
export type { BimTreeNode, BimTreeSummary } from './model/treeSummary.js';
|
|
3
|
+
export { placedSolids } from './elementFns/placedGeometry.js';
|
|
2
4
|
export { toIfc, toIfcValidated } from './serialize/toIfc.js';
|
|
3
5
|
export type { ValidatedIfcResult } from './serialize/toIfc.js';
|
|
6
|
+
export { setIfcWasmLocateFile } from './ifcRuntime.js';
|
|
4
7
|
export { fromIfc } from './import/fromIfc.js';
|
|
5
8
|
export { disposeImportedModel } from './import/importedModel.js';
|
|
6
9
|
export type { FromIfcOptions } from './import/fromIfc.js';
|
package/dist/model/bimModel.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Result } from 'brepjs';
|
|
|
2
2
|
import { LocalId } from '../identity/localId.js';
|
|
3
3
|
import { BimError } from '../errors/bimError.js';
|
|
4
4
|
import { AnyBimElement, BimElement } from '../types/bimTypes.js';
|
|
5
|
+
import { BimTreeSummary } from './treeSummary.js';
|
|
5
6
|
import { BimRelationship } from '../types/relationships.js';
|
|
6
7
|
import { ClassificationRef } from '../types/classificationTypes.js';
|
|
7
8
|
import { WallSpec } from '../specs/wallSpec.js';
|
|
@@ -129,6 +130,13 @@ export declare class BimModel {
|
|
|
129
130
|
placeIn(elementId: LocalId, containerId: LocalId): void;
|
|
130
131
|
getProject(): BimElement<'PROJECT'> | null;
|
|
131
132
|
getElement(id: LocalId): AnyBimElement | null;
|
|
133
|
+
/**
|
|
134
|
+
* A serializable summary of the model's structure, rooted at the project and
|
|
135
|
+
* walking the IFC spatial hierarchy (AGGREGATES: project → site → building →
|
|
136
|
+
* storey) plus the elements contained in each storey (placeIn). Useful for a
|
|
137
|
+
* read-only tree view of the model across a worker boundary.
|
|
138
|
+
*/
|
|
139
|
+
toTreeSummary(): BimTreeSummary;
|
|
132
140
|
getWalls(): BimElement<'WALL'>[];
|
|
133
141
|
getSlabs(): BimElement<'SLAB'>[];
|
|
134
142
|
getBeams(): BimElement<'BEAM'>[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BimCategory } from '../types/bimTypes.js';
|
|
2
|
+
/**
|
|
3
|
+
* A node in a {@link BimModel}'s spatial/decomposition tree. Fully serializable
|
|
4
|
+
* (plain numbers/strings) so it can be posted across a worker boundary.
|
|
5
|
+
*/
|
|
6
|
+
export interface BimTreeNode {
|
|
7
|
+
/** The element's local id. */
|
|
8
|
+
readonly id: number;
|
|
9
|
+
/** Display label — the element's name, or its category when unnamed. */
|
|
10
|
+
readonly label: string;
|
|
11
|
+
/** The element's IFC category. */
|
|
12
|
+
readonly category: BimCategory;
|
|
13
|
+
readonly children: readonly BimTreeNode[];
|
|
14
|
+
}
|
|
15
|
+
/** A serializable summary of a model's structure, rooted at the project. */
|
|
16
|
+
export interface BimTreeSummary {
|
|
17
|
+
/** The project node and its nested spatial structure + contained elements. */
|
|
18
|
+
readonly root: BimTreeNode | null;
|
|
19
|
+
/** Number of nodes in the tree (the project and everything reachable from it). */
|
|
20
|
+
readonly elementCount: number;
|
|
21
|
+
}
|
package/dist/specs/profile.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type IShapeProfile = {
|
|
|
17
17
|
readonly overallDepth: number;
|
|
18
18
|
readonly flangeThickness: number;
|
|
19
19
|
readonly webThickness: number;
|
|
20
|
+
readonly filletRadius?: number | undefined;
|
|
20
21
|
};
|
|
21
22
|
export type CoreProfile = RectangularProfile | CircularProfile | IShapeProfile;
|
|
22
23
|
export type Profile = CoreProfile | ExtendedProfile;
|
|
@@ -35,6 +36,7 @@ export declare const ProfileSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion
|
|
|
35
36
|
overallDepth: z.ZodNumber;
|
|
36
37
|
flangeThickness: z.ZodNumber;
|
|
37
38
|
webThickness: z.ZodNumber;
|
|
39
|
+
filletRadius: z.ZodOptional<z.ZodNumber>;
|
|
38
40
|
}, z.core.$strip>], "kind">, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
39
41
|
kind: z.ZodLiteral<"L_SHAPE">;
|
|
40
42
|
depth: z.ZodNumber;
|
|
@@ -18,6 +18,12 @@ export interface RailingSpec {
|
|
|
18
18
|
readonly axisZ: [number, number, number];
|
|
19
19
|
readonly predefinedType?: RailingPredefinedType | undefined;
|
|
20
20
|
readonly materialName: string;
|
|
21
|
+
/**
|
|
22
|
+
* Geometric infill style. 'PANEL' (default) is a single swept panel; 'POSTED'
|
|
23
|
+
* is vertical posts plus top & bottom rails. Orthogonal to `predefinedType`
|
|
24
|
+
* (which is the IFC usage role, not a geometry descriptor).
|
|
25
|
+
*/
|
|
26
|
+
readonly infill?: 'PANEL' | 'POSTED' | undefined;
|
|
21
27
|
readonly isExternal?: boolean | undefined;
|
|
22
28
|
readonly fireRating?: string | undefined;
|
|
23
29
|
readonly status?: string | undefined;
|
package/dist/specs/roofSpec.d.ts
CHANGED
|
@@ -16,6 +16,13 @@ export interface RoofSpec {
|
|
|
16
16
|
readonly fireRating?: string | undefined;
|
|
17
17
|
readonly thermalTransmittance?: number | undefined;
|
|
18
18
|
readonly status?: string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Optional roof slope in degrees (0 < pitch < 90). Its PRESENCE opts the roof
|
|
21
|
+
* into shaped geometry built for `predefinedType` (shed/gable/hip/dome); when
|
|
22
|
+
* absent the roof is a flat slab regardless of predefinedType (backward-
|
|
23
|
+
* compatible). Ignored geometrically for DOME_ROOF (a hemisphere).
|
|
24
|
+
*/
|
|
25
|
+
readonly pitch?: number | undefined;
|
|
19
26
|
/**
|
|
20
27
|
* When present, the roof is associated via a layered IfcMaterialLayerSet built
|
|
21
28
|
* from these layers instead of the bare `materialName` IfcMaterial.
|
package/package.json
CHANGED
|
@@ -1,23 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brepjs-bim",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "BIM layer for brepjs — IFC4-aligned parametric building elements",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"bim",
|
|
7
|
+
"ifc",
|
|
8
|
+
"cad",
|
|
9
|
+
"brep"
|
|
10
|
+
],
|
|
6
11
|
"author": "Andy Aragon",
|
|
7
12
|
"license": "Apache-2.0",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/andymai/brepjs",
|
|
16
|
+
"directory": "packages/brepjs-bim"
|
|
17
|
+
},
|
|
8
18
|
"type": "module",
|
|
9
19
|
"sideEffects": false,
|
|
10
|
-
"engines": {
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=24"
|
|
22
|
+
},
|
|
11
23
|
"main": "./dist/brepjs-bim.cjs",
|
|
12
24
|
"module": "./dist/brepjs-bim.js",
|
|
13
25
|
"types": "./dist/index.d.ts",
|
|
14
26
|
"exports": {
|
|
15
27
|
".": {
|
|
16
|
-
"import": {
|
|
17
|
-
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/brepjs-bim.js"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"default": "./dist/brepjs-bim.cjs"
|
|
35
|
+
}
|
|
18
36
|
}
|
|
19
37
|
},
|
|
20
|
-
"files": [
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
21
42
|
"scripts": {
|
|
22
43
|
"build": "vite build",
|
|
23
44
|
"typecheck": "tsc --noEmit",
|