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,20 @@
|
|
|
1
|
+
import { BimModel } from '../model/bimModel.js';
|
|
2
|
+
import { CobieModel, CobieExportMeta, CobieJson } from './cobieTypes.js';
|
|
3
|
+
/**
|
|
4
|
+
* Derives a {@link CobieModel} from an in-memory {@link BimModel}, reading only
|
|
5
|
+
* its public getters. The derivation is a single O(N) pass that mirrors the
|
|
6
|
+
* spatial-tree and type-layer conventions of {@link toIfc} so that COBie
|
|
7
|
+
* Component/Type names line up with the exported IFC.
|
|
8
|
+
*
|
|
9
|
+
* Optional element categories from later phases (ZONE, SYSTEM) are picked up
|
|
10
|
+
* generically when present; their absence is not an error.
|
|
11
|
+
*/
|
|
12
|
+
export declare function deriveCobieModel(model: BimModel, meta?: CobieExportMeta): CobieModel;
|
|
13
|
+
/**
|
|
14
|
+
* Serializes a {@link CobieModel} to CSV — one sheet per COBie table, keyed by
|
|
15
|
+
* sheet name. Each sheet is a CRLF-delimited RFC 4180 document with a header row
|
|
16
|
+
* followed by one row per record.
|
|
17
|
+
*/
|
|
18
|
+
export declare function serializeCobieToCsv(model: CobieModel): Map<string, string>;
|
|
19
|
+
/** Serializes a {@link CobieModel} to a JSON object — one array per sheet. */
|
|
20
|
+
export declare function serializeCobieToJson(model: CobieModel): CobieJson;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COBie (Construction-Operations Building information exchange) table row types.
|
|
3
|
+
*
|
|
4
|
+
* Each interface models one COBie sheet. Column names follow the COBie 2.4
|
|
5
|
+
* spreadsheet schema (camelCased). Rows are derived from a {@link BimModel} by
|
|
6
|
+
* {@link deriveCobieModel}; the resulting {@link CobieModel} is a pure value
|
|
7
|
+
* object that can be serialized to CSV or JSON.
|
|
8
|
+
*
|
|
9
|
+
* Several required-but-not-yet-modelled COBie columns (CreatedBy, CreatedOn,
|
|
10
|
+
* Category) are emitted as empty strings rather than omitted, because COBie
|
|
11
|
+
* validators expect the columns to be present. The fields that brepjs-bim can
|
|
12
|
+
* populate from a {@link BimModel} carry real data.
|
|
13
|
+
*/
|
|
14
|
+
/** Minimal contact metadata used to populate the COBie Contact sheet. */
|
|
15
|
+
export interface CobieContactMeta {
|
|
16
|
+
readonly email?: string | undefined;
|
|
17
|
+
readonly givenName?: string | undefined;
|
|
18
|
+
readonly familyName?: string | undefined;
|
|
19
|
+
readonly organizationName?: string | undefined;
|
|
20
|
+
readonly company?: string | undefined;
|
|
21
|
+
readonly phone?: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
/** Optional metadata consumed by {@link deriveCobieModel}. */
|
|
24
|
+
export interface CobieExportMeta {
|
|
25
|
+
readonly contact?: CobieContactMeta | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface CobieContactRow {
|
|
28
|
+
/** COBie Contact key — the contact's email address. */
|
|
29
|
+
readonly email: string;
|
|
30
|
+
readonly givenName: string;
|
|
31
|
+
readonly familyName: string;
|
|
32
|
+
readonly company: string;
|
|
33
|
+
readonly phone: string;
|
|
34
|
+
}
|
|
35
|
+
export interface CobieFacilityRow {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly createdBy: string;
|
|
38
|
+
readonly category: string;
|
|
39
|
+
readonly projectName: string;
|
|
40
|
+
readonly siteName: string;
|
|
41
|
+
readonly description: string;
|
|
42
|
+
/** IfcProject GlobalId. */
|
|
43
|
+
readonly externalIdentifier: string;
|
|
44
|
+
}
|
|
45
|
+
export interface CobieFloorRow {
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly createdBy: string;
|
|
48
|
+
readonly category: string;
|
|
49
|
+
readonly description: string;
|
|
50
|
+
readonly elevation: number;
|
|
51
|
+
/** IfcBuildingStorey GlobalId. */
|
|
52
|
+
readonly externalIdentifier: string;
|
|
53
|
+
}
|
|
54
|
+
export interface CobieSpaceRow {
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly createdBy: string;
|
|
57
|
+
readonly category: string;
|
|
58
|
+
/** Name of the Floor this space sits on (resolved via the spatial tree). */
|
|
59
|
+
readonly floorName: string;
|
|
60
|
+
readonly description: string;
|
|
61
|
+
readonly roomTag: string;
|
|
62
|
+
/** IfcSpace GlobalId. */
|
|
63
|
+
readonly externalIdentifier: string;
|
|
64
|
+
}
|
|
65
|
+
export interface CobieZoneRow {
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly createdBy: string;
|
|
68
|
+
readonly category: string;
|
|
69
|
+
/** Name of a space that is a member of this zone. */
|
|
70
|
+
readonly spaceName: string;
|
|
71
|
+
readonly externalIdentifier: string;
|
|
72
|
+
}
|
|
73
|
+
export interface CobieTypeRow {
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly createdBy: string;
|
|
76
|
+
readonly category: string;
|
|
77
|
+
readonly description: string;
|
|
78
|
+
readonly assetType: string;
|
|
79
|
+
}
|
|
80
|
+
export interface CobieComponentRow {
|
|
81
|
+
readonly name: string;
|
|
82
|
+
readonly createdBy: string;
|
|
83
|
+
/** Name of the Type row this component is an occurrence of. */
|
|
84
|
+
readonly typeName: string;
|
|
85
|
+
/** Name of the Space this component is contained in, when resolvable. */
|
|
86
|
+
readonly space: string;
|
|
87
|
+
readonly description: string;
|
|
88
|
+
/** Element GlobalId. */
|
|
89
|
+
readonly externalIdentifier: string;
|
|
90
|
+
}
|
|
91
|
+
export interface CobieSystemRow {
|
|
92
|
+
readonly name: string;
|
|
93
|
+
readonly createdBy: string;
|
|
94
|
+
readonly category: string;
|
|
95
|
+
/** Name of a component that is a member of this system. */
|
|
96
|
+
readonly componentNames: string;
|
|
97
|
+
readonly externalIdentifier: string;
|
|
98
|
+
}
|
|
99
|
+
export interface CobieAttributeRow {
|
|
100
|
+
readonly name: string;
|
|
101
|
+
readonly createdBy: string;
|
|
102
|
+
/** Name of the sheet row this attribute belongs to (e.g. a component name). */
|
|
103
|
+
readonly sheetName: string;
|
|
104
|
+
readonly rowName: string;
|
|
105
|
+
readonly value: string;
|
|
106
|
+
}
|
|
107
|
+
/** All populated COBie sheets derived from a model. */
|
|
108
|
+
export interface CobieModel {
|
|
109
|
+
readonly contact: readonly CobieContactRow[];
|
|
110
|
+
readonly facility: readonly CobieFacilityRow[];
|
|
111
|
+
readonly floor: readonly CobieFloorRow[];
|
|
112
|
+
readonly space: readonly CobieSpaceRow[];
|
|
113
|
+
readonly zone: readonly CobieZoneRow[];
|
|
114
|
+
readonly type: readonly CobieTypeRow[];
|
|
115
|
+
readonly component: readonly CobieComponentRow[];
|
|
116
|
+
readonly system: readonly CobieSystemRow[];
|
|
117
|
+
readonly attribute: readonly CobieAttributeRow[];
|
|
118
|
+
}
|
|
119
|
+
/** JSON serialization of a {@link CobieModel} — one array per sheet name. */
|
|
120
|
+
export interface CobieJson {
|
|
121
|
+
readonly Contact: readonly CobieContactRow[];
|
|
122
|
+
readonly Facility: readonly CobieFacilityRow[];
|
|
123
|
+
readonly Floor: readonly CobieFloorRow[];
|
|
124
|
+
readonly Space: readonly CobieSpaceRow[];
|
|
125
|
+
readonly Zone: readonly CobieZoneRow[];
|
|
126
|
+
readonly Type: readonly CobieTypeRow[];
|
|
127
|
+
readonly Component: readonly CobieComponentRow[];
|
|
128
|
+
readonly System: readonly CobieSystemRow[];
|
|
129
|
+
readonly Attribute: readonly CobieAttributeRow[];
|
|
130
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { deriveCobieModel, serializeCobieToCsv, serializeCobieToJson } from './cobieExport.js';
|
|
2
|
+
export type { CobieModel, CobieJson, CobieExportMeta, CobieContactMeta, CobieContactRow, CobieFacilityRow, CobieFloorRow, CobieSpaceRow, CobieZoneRow, CobieTypeRow, CobieComponentRow, CobieSystemRow, CobieAttributeRow, } from './cobieTypes.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ValidSolid, Result } from 'brepjs';
|
|
2
|
+
import { CurtainWallSpec } from '../specs/curtainWallSpec.js';
|
|
3
|
+
import { BimError } from '../errors/bimError.js';
|
|
4
|
+
/**
|
|
5
|
+
* A placed box component of the curtain wall. `origin` is the corner of the box
|
|
6
|
+
* in the wall's local frame (X across the wall, Y through its depth, Z up);
|
|
7
|
+
* `size` is its extent along each local axis (all mm). The owning IfcPlate /
|
|
8
|
+
* IfcMember placement carries `origin`; `solid` is the local-origin template
|
|
9
|
+
* geometry (corner at 0,0,0).
|
|
10
|
+
*/
|
|
11
|
+
export interface CurtainWallComponent {
|
|
12
|
+
readonly origin: [number, number, number];
|
|
13
|
+
readonly size: [number, number, number];
|
|
14
|
+
readonly solid: ValidSolid;
|
|
15
|
+
}
|
|
16
|
+
/** A curtain wall decomposed into glazing panels (plates) and mullions (members). */
|
|
17
|
+
export interface CurtainWallGrid {
|
|
18
|
+
readonly panels: readonly CurtainWallComponent[];
|
|
19
|
+
readonly mullions: readonly CurtainWallComponent[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Decomposes a curtain wall spec into its panel (plate) and mullion (member)
|
|
23
|
+
* geometry. Mullions run along every vertical grid line (columns + 1 of them)
|
|
24
|
+
* and every horizontal grid line (rows + 1); panels fill the cells between
|
|
25
|
+
* adjacent mullions. The mullion section is centred on each grid line.
|
|
26
|
+
*
|
|
27
|
+
* Geometry is laid out in the wall's local frame: X across the wall, Z up, Y
|
|
28
|
+
* through the depth. Each component's local-origin solid is returned alongside
|
|
29
|
+
* its placement origin so the IFC writer can emit one IfcLocalPlacement per
|
|
30
|
+
* component.
|
|
31
|
+
*/
|
|
32
|
+
export declare function curtainWallToGrid(spec: CurtainWallSpec): Result<CurtainWallGrid, BimError>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ValidSolid, Result } from 'brepjs';
|
|
2
|
+
import { FootingSpec, PileSpec } from '../specs/foundationSpec.js';
|
|
3
|
+
import { BimError } from '../errors/bimError.js';
|
|
4
|
+
export declare function footingToSolid(spec: FootingSpec): Result<ValidSolid, BimError>;
|
|
5
|
+
export declare function pileToSolid(spec: PileSpec): Result<ValidSolid, BimError>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Result } from 'brepjs';
|
|
2
|
+
import { Profile } from '../specs/profile.js';
|
|
3
|
+
import { BimError } from '../errors/bimError.js';
|
|
4
|
+
export declare function profileCrossSectionArea(profile: Profile): number;
|
|
5
|
+
export declare function profileToPolygon(profile: Profile, circleSegments?: number): Result<Array<[number, number, number]>, BimError>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ValidSolid, Result } from 'brepjs';
|
|
2
|
+
import { RampFlightSpec } from '../specs/rampSpec.js';
|
|
3
|
+
import { BimError } from '../errors/bimError.js';
|
|
4
|
+
export interface RampFlightSolid {
|
|
5
|
+
readonly solid: ValidSolid;
|
|
6
|
+
/**
|
|
7
|
+
* True — the ramp flight is a simplified inclined-slab solid (a sloped prism),
|
|
8
|
+
* not a fully detailed ramp with landings/nosings/edge details. Callers should
|
|
9
|
+
* surface a SIMPLIFIED_GEOMETRY note. The solid is valid and non-degenerate.
|
|
10
|
+
*/
|
|
11
|
+
readonly geometrySimplified: true;
|
|
12
|
+
}
|
|
13
|
+
export declare function rampFlightToSolid(spec: RampFlightSpec): Result<RampFlightSolid, BimError>;
|
|
14
|
+
export declare function rampFlightVolume(spec: RampFlightSpec): number;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ValidSolid, Result } from 'brepjs';
|
|
2
|
+
import { SlabOpeningSpec } from '../types/bimTypes.js';
|
|
3
|
+
import { BimError } from '../errors/bimError.js';
|
|
4
|
+
export declare function slabOpeningToSolid(spec: SlabOpeningSpec, slabThickness: number): Result<ValidSolid, BimError>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ValidSolid, Result } from 'brepjs';
|
|
2
|
+
import { StairFlightSpec } from '../specs/stairSpec.js';
|
|
3
|
+
import { BimError } from '../errors/bimError.js';
|
|
4
|
+
export interface StairFlightSolid {
|
|
5
|
+
readonly solid: ValidSolid;
|
|
6
|
+
/**
|
|
7
|
+
* False — stair flights are built as real stepped solids (tread/riser
|
|
8
|
+
* sawtooth swept across the width), not a simplified bounding box. Present so
|
|
9
|
+
* callers can surface a SIMPLIFIED_GEOMETRY note uniformly across element
|
|
10
|
+
* kinds; the ramp builder sets this true.
|
|
11
|
+
*/
|
|
12
|
+
readonly geometrySimplified: false;
|
|
13
|
+
}
|
|
14
|
+
export declare function stairFlightToSolid(spec: StairFlightSpec): Result<StairFlightSolid, BimError>;
|
|
15
|
+
export declare function stairFlightVolume(spec: StairFlightSpec): number;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BrepError } from 'brepjs';
|
|
2
|
+
export type BimErrorKind = 'BIM_SPEC' | 'BIM_IFC' | 'BIM_GEOMETRY' | 'BIM_IMPORT' | 'BIM_BCF' | 'BIM_IDS';
|
|
3
|
+
export interface BimError {
|
|
4
|
+
readonly kind: BimErrorKind;
|
|
5
|
+
readonly code: string;
|
|
6
|
+
readonly message: string;
|
|
7
|
+
readonly cause?: unknown;
|
|
8
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
9
|
+
}
|
|
10
|
+
export declare function specError(code: string, message: string, cause?: unknown): BimError;
|
|
11
|
+
export declare function ifcError(code: string, message: string, cause?: unknown): BimError;
|
|
12
|
+
export declare function geometryError(code: string, message: string, cause?: unknown): BimError;
|
|
13
|
+
/**
|
|
14
|
+
* IFC-import error factory. Codes used by the reader subsystem:
|
|
15
|
+
* - `OPEN_MODEL_FAILED` — web-ifc returned an invalid model id on OpenModel
|
|
16
|
+
* - `SCHEMA_UNSUPPORTED` — schema string not in `['IFC2X3', 'IFC4', 'IFC4X3']`
|
|
17
|
+
* - `UNSUPPORTED_PROFILE` — profile entity type not in the supported set
|
|
18
|
+
* - `GEOMETRY_RECONSTRUCTION_FAILED` — parametric reconstruction threw
|
|
19
|
+
* - `TESSELLATION_NOT_MANIFOLD` — STL round-trip did not produce a closed solid
|
|
20
|
+
* - `PLACEMENT_READ_FAILED` — placement chain produced a degenerate matrix
|
|
21
|
+
* - `UNIT_ASSIGNMENT_MISSING` — no IfcUnitAssignment found (assume metres, warn)
|
|
22
|
+
*/
|
|
23
|
+
export declare function importError(code: string, message: string, cause?: unknown): BimError;
|
|
24
|
+
/**
|
|
25
|
+
* BCF (BIM Collaboration Format) error factory. Codes used by the BCF subsystem:
|
|
26
|
+
* - `BCF_PARSE_FAILED` — an XML file could not be parsed into the BCF data model
|
|
27
|
+
* - `BCF_VERSION_UNSUPPORTED` — `bcf.version` declares a version other than 3.0
|
|
28
|
+
* - `BCF_MISSING_FILE` — a required container file (`bcf.version`, `project.bcfp`) is absent
|
|
29
|
+
*/
|
|
30
|
+
export declare function bcfError(code: string, message: string, cause?: unknown): BimError;
|
|
31
|
+
/**
|
|
32
|
+
* IDS (Information Delivery Specification) error factory. Codes used by the IDS
|
|
33
|
+
* subsystem:
|
|
34
|
+
* - `IDS_PARSE_FAILED` — the IDS XML could not be parsed into a document tree
|
|
35
|
+
* - `IDS_INVALID_SCHEMA` — the root element is not `<ids>` or has no specifications
|
|
36
|
+
* - `IDS_UNSUPPORTED_VERSION` — the document declares an IDS version this subset rejects
|
|
37
|
+
*/
|
|
38
|
+
export declare function idsError(code: string, message: string, cause?: unknown): BimError;
|
|
39
|
+
export declare function fromBrepError(inner: BrepError, code: string, message: string): BimError;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IfcGuid } from './ifcGuid.js';
|
|
2
|
+
/**
|
|
3
|
+
* Synchronously derives a stable IFC GlobalId from an arbitrary stable key.
|
|
4
|
+
* Re-running with the same key always yields the same GUID, so serializing an
|
|
5
|
+
* identical model twice produces byte-for-byte identical GlobalIds. Distinct
|
|
6
|
+
* keys yield distinct, format-valid (22-char) GlobalIds.
|
|
7
|
+
*/
|
|
8
|
+
export declare function deriveIfcGuidSync(stableKey: string): IfcGuid;
|
|
9
|
+
/**
|
|
10
|
+
* Async wrapper over {@link deriveIfcGuidSync} for callers that prefer a Promise
|
|
11
|
+
* surface. The derivation itself is synchronous and deterministic.
|
|
12
|
+
*/
|
|
13
|
+
export declare function deriveIfcGuid(stableKey: string): Promise<IfcGuid>;
|
|
14
|
+
/**
|
|
15
|
+
* `"elem:{modelScope}:{category}:{localId}"` — stable key for a model element
|
|
16
|
+
* occurrence. `modelScope` is a per-model identifier (the project GlobalId/id) so
|
|
17
|
+
* two distinct models that add elements in the same order do NOT produce colliding
|
|
18
|
+
* GlobalIds, as required for COBie/BCF/federation (global uniqueness, not merely
|
|
19
|
+
* re-export stability within one model).
|
|
20
|
+
*/
|
|
21
|
+
export declare function makeElementKey(modelScope: string, category: string, localId: number): string;
|
|
22
|
+
/** `"rel:{modelScope}:{kind}:{localId}"` — model-scoped stable key for a relationship. */
|
|
23
|
+
export declare function makeRelKey(modelScope: string, kind: string, localId: number): string;
|
|
24
|
+
/** `"line:{modelScope}:{expressId}"` — model-scoped stable key for a writer-minted line. */
|
|
25
|
+
export declare function makeLineKey(modelScope: string, expressId: number): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const __localIdBrand: unique symbol;
|
|
2
|
+
export type LocalId = number & {
|
|
3
|
+
readonly [__localIdBrand]: true;
|
|
4
|
+
};
|
|
5
|
+
export interface LocalIdCounter {
|
|
6
|
+
next(): LocalId;
|
|
7
|
+
current(): LocalId;
|
|
8
|
+
}
|
|
9
|
+
export declare function makeLocalIdCounter(start?: number): LocalIdCounter;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ImportedModel } from '../import/importedModel.js';
|
|
2
|
+
import { IdsCheckReport, IdsDocument } from './idsTypes.js';
|
|
3
|
+
/**
|
|
4
|
+
* Checks an imported model against an IDS document, returning a per-specification
|
|
5
|
+
* pass/fail report keyed by the specification name. The check is synchronous,
|
|
6
|
+
* never throws, and surfaces all problems as {@link ValidationIssue}s.
|
|
7
|
+
*
|
|
8
|
+
* For each specification the applicability facets select the matching elements,
|
|
9
|
+
* then the requirement facets are evaluated against each applicable element per
|
|
10
|
+
* the spec's cardinality:
|
|
11
|
+
* - `required` — every applicable element must satisfy all requirements
|
|
12
|
+
* (a failure is an `error`).
|
|
13
|
+
* - `optional` — requirement failures are reported as `info` and never fail.
|
|
14
|
+
* - `prohibited` — an applicable element that *does* satisfy the requirements is
|
|
15
|
+
* a violation (`error`).
|
|
16
|
+
*
|
|
17
|
+
* Unsupported facet features (the `PartOf` facet, numeric-bound restrictions,
|
|
18
|
+
* and invalid `xs:pattern` dialects) are recorded in
|
|
19
|
+
* {@link IdsCheckReport.unsupportedFacets} and the affected requirement is
|
|
20
|
+
* skipped rather than failing the element.
|
|
21
|
+
*/
|
|
22
|
+
export declare function checkModelAgainstIds(model: ImportedModel, ids: IdsDocument): IdsCheckReport;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ImportedElement, ImportedElementCategory } from '../import/importedModel.js';
|
|
2
|
+
import { IdsRestriction } from './idsTypes.js';
|
|
3
|
+
/** Returns the categories an entity-name restriction can resolve to. */
|
|
4
|
+
export declare function categoriesForRestriction(name: IdsRestriction): ReadonlySet<ImportedElementCategory>;
|
|
5
|
+
/** Tests whether a candidate string satisfies an IDS value restriction. */
|
|
6
|
+
export declare function matchesRestriction(candidate: string, restriction: IdsRestriction): boolean;
|
|
7
|
+
export declare function isValidPattern(pattern: string): boolean;
|
|
8
|
+
/** True when the element's category matches the entity name (and predefined type). */
|
|
9
|
+
export declare function evalEntityFacet(element: ImportedElement, name: IdsRestriction, predefinedType: IdsRestriction | undefined): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* True when the element exposes the named property in the named pset, optionally
|
|
12
|
+
* with a value matching `value`. Reads from both IfcPropertySet-derived psets and
|
|
13
|
+
* IfcElementQuantity-derived ones.
|
|
14
|
+
*/
|
|
15
|
+
export declare function evalPropertyFacet(element: ImportedElement, psetName: IdsRestriction, baseName: IdsRestriction, value: IdsRestriction | undefined): boolean;
|
|
16
|
+
/** True when an element attribute (Name/PredefinedType) matches the facet. */
|
|
17
|
+
export declare function evalAttributeFacet(element: ImportedElement, name: IdsRestriction, value: IdsRestriction | undefined): boolean;
|
|
18
|
+
/** True when the element's classification system/value match the facet. */
|
|
19
|
+
export declare function evalClassificationFacet(element: ImportedElement, system: IdsRestriction | undefined, value: IdsRestriction | undefined): boolean;
|
|
20
|
+
/** True when the element's material name matches the facet value. */
|
|
21
|
+
export declare function evalMaterialFacet(element: ImportedElement, value: IdsRestriction | undefined): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Result } from 'brepjs';
|
|
2
|
+
import { BimError } from '../errors/bimError.js';
|
|
3
|
+
import { IdsDocument } from './idsTypes.js';
|
|
4
|
+
/**
|
|
5
|
+
* Parses an IDS 1.0 XML document string into a typed {@link IdsDocument}.
|
|
6
|
+
*
|
|
7
|
+
* Supported structure: `<ids><info><title/></info><specifications>` with one or
|
|
8
|
+
* more `<specification>` carrying `<applicability>` and `<requirements>`. Inside
|
|
9
|
+
* those, the facets `entity`, `attribute`, `property`, `classification`,
|
|
10
|
+
* `material`, and `partOf` are recognised. Each value field accepts either a
|
|
11
|
+
* `<simpleValue>` or an `<xs:restriction>` with `<xs:enumeration>` or
|
|
12
|
+
* `<xs:pattern>` children.
|
|
13
|
+
*
|
|
14
|
+
* Cardinality is read from the specification's `minOccurs`/`maxOccurs` (or the
|
|
15
|
+
* `cardinality` attribute when present): `prohibited` when `maxOccurs="0"`,
|
|
16
|
+
* `optional` when `minOccurs="0"`, otherwise `required`.
|
|
17
|
+
*
|
|
18
|
+
* Never throws — malformed XML or a missing root returns `err(idsError(...))`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseIdsXml(xml: string): Result<IdsDocument, BimError>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ValidationIssue } from '../validation/severity.js';
|
|
2
|
+
/**
|
|
3
|
+
* A value constraint on an IDS facet field. IDS expresses these either as a
|
|
4
|
+
* literal `<simpleValue>` or as an `<xs:restriction>` carrying an enumeration or
|
|
5
|
+
* a pattern. The numeric bound dialect (`xs:minInclusive` etc.) is intentionally
|
|
6
|
+
* not modelled — facets that use it fall through to a `pattern`-less restriction
|
|
7
|
+
* and are reported as unsupported by the checker.
|
|
8
|
+
*/
|
|
9
|
+
export type IdsRestriction = {
|
|
10
|
+
readonly kind: 'simple';
|
|
11
|
+
readonly value: string;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'enumeration';
|
|
14
|
+
readonly values: readonly string[];
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: 'pattern';
|
|
17
|
+
readonly pattern: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The IDS facet kinds this subset understands. `PartOf` is parsed but always
|
|
21
|
+
* reported as unsupported by the checker (spatial-tree resolution is out of
|
|
22
|
+
* scope); every other kind is fully evaluated.
|
|
23
|
+
*/
|
|
24
|
+
export type IdsFacet = {
|
|
25
|
+
readonly kind: 'Entity';
|
|
26
|
+
readonly name: IdsRestriction;
|
|
27
|
+
readonly predefinedType?: IdsRestriction | undefined;
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: 'Attribute';
|
|
30
|
+
readonly name: IdsRestriction;
|
|
31
|
+
readonly value?: IdsRestriction | undefined;
|
|
32
|
+
} | {
|
|
33
|
+
readonly kind: 'Property';
|
|
34
|
+
readonly psetName: IdsRestriction;
|
|
35
|
+
readonly baseName: IdsRestriction;
|
|
36
|
+
readonly value?: IdsRestriction | undefined;
|
|
37
|
+
} | {
|
|
38
|
+
readonly kind: 'Classification';
|
|
39
|
+
readonly system?: IdsRestriction | undefined;
|
|
40
|
+
readonly value?: IdsRestriction | undefined;
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: 'Material';
|
|
43
|
+
readonly value?: IdsRestriction | undefined;
|
|
44
|
+
} | {
|
|
45
|
+
readonly kind: 'PartOf';
|
|
46
|
+
readonly relation?: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
export type IdsCardinality = 'required' | 'optional' | 'prohibited';
|
|
49
|
+
export interface IdsSpecification {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly ifcVersion: readonly string[];
|
|
52
|
+
/**
|
|
53
|
+
* Cardinality of the *requirements* against applicable elements:
|
|
54
|
+
* - `required` — every applicable element must satisfy all requirement facets.
|
|
55
|
+
* - `optional` — requirements are informational; failures are reported as
|
|
56
|
+
* warnings and do not fail the spec.
|
|
57
|
+
* - `prohibited` — applicable elements must *not* satisfy the requirements.
|
|
58
|
+
*/
|
|
59
|
+
readonly cardinality: IdsCardinality;
|
|
60
|
+
readonly applicability: readonly IdsFacet[];
|
|
61
|
+
readonly requirements: readonly IdsFacet[];
|
|
62
|
+
}
|
|
63
|
+
export interface IdsDocument {
|
|
64
|
+
readonly title: string;
|
|
65
|
+
readonly specifications: readonly IdsSpecification[];
|
|
66
|
+
}
|
|
67
|
+
export interface IdsCheckResult {
|
|
68
|
+
readonly specificationName: string;
|
|
69
|
+
readonly pass: boolean;
|
|
70
|
+
/** Number of model elements matched by the applicability facets. */
|
|
71
|
+
readonly applicableCount: number;
|
|
72
|
+
/** Applicable elements that satisfied the cardinality contract. */
|
|
73
|
+
readonly passedCount: number;
|
|
74
|
+
/** Applicable elements that violated the cardinality contract. */
|
|
75
|
+
readonly failedCount: number;
|
|
76
|
+
readonly issues: readonly ValidationIssue[];
|
|
77
|
+
}
|
|
78
|
+
export interface IdsCheckReport {
|
|
79
|
+
readonly pass: boolean;
|
|
80
|
+
readonly results: readonly IdsCheckResult[];
|
|
81
|
+
/**
|
|
82
|
+
* Human-readable identifiers of facet features that were encountered but not
|
|
83
|
+
* evaluated (e.g. `PartOf in 'spec name'`). Their presence never aborts the
|
|
84
|
+
* check; the affected requirement is skipped with a warning.
|
|
85
|
+
*/
|
|
86
|
+
readonly unsupportedFacets: readonly string[];
|
|
87
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A zero-dependency XML element tree, sufficient for the IDS 1.0 subset this
|
|
3
|
+
* module parses. Node 24's build does not expose a global `DOMParser`, and the
|
|
4
|
+
* workspace ships no XML dependency, so a small hand-written tokenizer is used.
|
|
5
|
+
*
|
|
6
|
+
* Scope of support: elements, attributes (single/double quoted), text content,
|
|
7
|
+
* self-closing tags, comments, the XML declaration, and CDATA. Namespace
|
|
8
|
+
* prefixes are stripped from tag names (`ids:specification` → `specification`)
|
|
9
|
+
* so namespaced and default-namespace IDS files parse identically. DOCTYPE and
|
|
10
|
+
* external entities are not processed — there is no entity expansion, so XXE is
|
|
11
|
+
* not reachable.
|
|
12
|
+
*/
|
|
13
|
+
export interface XmlElement {
|
|
14
|
+
readonly tag: string;
|
|
15
|
+
readonly attributes: Readonly<Record<string, string>>;
|
|
16
|
+
readonly children: readonly XmlElement[];
|
|
17
|
+
/** Concatenated direct text content with entities decoded and trimmed. */
|
|
18
|
+
readonly text: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function parseXml(input: string): XmlElement;
|
|
21
|
+
/** Returns the message of an {@link XmlParseError}, or rethrows other errors. */
|
|
22
|
+
export declare function isXmlParseError(e: unknown): e is Error;
|
|
23
|
+
export declare function childrenNamed(el: XmlElement, tag: string): readonly XmlElement[];
|
|
24
|
+
export declare function firstChild(el: XmlElement, tag: string): XmlElement | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IfcWriter } from './ifcWriter.js';
|
|
2
|
+
import { IfcGuid } from '../identity/ifcGuid.js';
|
|
3
|
+
/** IfcAssemblyPlaceEnum values; SITE for in-place assemblies, FACTORY for prefabricated. */
|
|
4
|
+
export type AssemblyPlaceIfc = 'SITE' | 'FACTORY' | 'NOTDEFINED';
|
|
5
|
+
/** IfcElementAssemblyTypeEnum values (IFC4). */
|
|
6
|
+
export type ElementAssemblyPredefinedTypeIfc = 'ACCESSORY_ASSEMBLY' | 'ARCH' | 'BEAM_GRID' | 'BRACED_FRAME' | 'GIRDER' | 'REINFORCEMENT_UNIT' | 'RIGID_FRAME' | 'SLAB_FIELD' | 'TRUSS' | 'USERDEFINED' | 'NOTDEFINED';
|
|
7
|
+
/**
|
|
8
|
+
* Emits an IfcElementAssembly grouping container. The assembly itself carries no
|
|
9
|
+
* own geometry by default — parts contribute geometry and are linked via
|
|
10
|
+
* {@link writeRelAggregatesElements} (or {@link writeRelNests} for ordered nesting).
|
|
11
|
+
* Pass `productDefinitionShapeId` only when the assembly has an explicit envelope.
|
|
12
|
+
*/
|
|
13
|
+
export declare function writeElementAssemblyEntity(w: IfcWriter, guid: IfcGuid, name: string, predefinedType: ElementAssemblyPredefinedTypeIfc, ownerHistoryId: number, localPlacementId: number | null, productDefinitionShapeId: number | null, assemblyPlace?: AssemblyPlaceIfc): number;
|
|
14
|
+
/**
|
|
15
|
+
* Links child elements to an assembly via IfcRelAggregates. Use this for the
|
|
16
|
+
* element-level (non-spatial) decomposition of an IfcElementAssembly into parts.
|
|
17
|
+
* `relatedObjectIds` must be non-empty; an empty set is a no-op.
|
|
18
|
+
*/
|
|
19
|
+
export declare function writeRelAggregatesElements(w: IfcWriter, guid: IfcGuid, ownerHistoryId: number, relatingObjectId: number, relatedObjectIds: readonly number[]): void;
|
|
20
|
+
/**
|
|
21
|
+
* Links ordered child elements to a parent via IfcRelNests. Unlike
|
|
22
|
+
* IfcRelAggregates, IfcRelNests preserves the order of `relatedObjectIds`,
|
|
23
|
+
* which is the correct relationship for ordered members (e.g. stair/ramp
|
|
24
|
+
* flights within their assembly). An empty set is a no-op.
|
|
25
|
+
*/
|
|
26
|
+
export declare function writeRelNests(w: IfcWriter, guid: IfcGuid, ownerHistoryId: number, relatingObjectId: number, relatedObjectIds: readonly number[]): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IfcWriter } from './ifcWriter.js';
|
|
2
|
+
import { ClassificationRef } from '../types/classificationTypes.js';
|
|
3
|
+
export type { ClassificationRef } from '../types/classificationTypes.js';
|
|
4
|
+
/**
|
|
5
|
+
* Writes the IFC classification entities for a set of references and associates
|
|
6
|
+
* each to its elements.
|
|
7
|
+
*
|
|
8
|
+
* For every distinct classification system a single `IfcClassification` is
|
|
9
|
+
* emitted (deduplicated by system name within this call). Each reference yields
|
|
10
|
+
* one `IfcClassificationReference` pointing at that system, plus one
|
|
11
|
+
* `IfcRelAssociatesClassification` linking the reference to its related objects.
|
|
12
|
+
* The rel's GlobalId is derived deterministically from the reference's
|
|
13
|
+
* system/code so re-exports stay byte-stable.
|
|
14
|
+
*
|
|
15
|
+
* @param refs maps each classification reference to the express IDs of the IFC
|
|
16
|
+
* elements it classifies.
|
|
17
|
+
*/
|
|
18
|
+
export declare function writeClassificationRefs(w: IfcWriter, ownerHistoryId: number, refs: ReadonlyMap<ClassificationRef, readonly number[]>): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IfcWriter } from './ifcWriter.js';
|
|
2
|
+
import { IfcGuid } from '../identity/ifcGuid.js';
|
|
3
|
+
/** IfcConnectionTypeEnum values used by IfcRelConnectsPathElements path ends. */
|
|
4
|
+
export type PathConnectionTypeIfc = 'ATSTART' | 'ATEND' | 'ATPATH' | 'NOTDEFINED';
|
|
5
|
+
/**
|
|
6
|
+
* Emits an IfcRelConnectsElements recording a physical connection between two
|
|
7
|
+
* elements. `description` optionally annotates the connection; geometry of the
|
|
8
|
+
* connection is left null (logical connectivity only).
|
|
9
|
+
*/
|
|
10
|
+
export declare function writeRelConnectsElements(w: IfcWriter, guid: IfcGuid, ownerHistoryId: number, relatingElementId: number, relatedElementId: number, description?: string | null): void;
|
|
11
|
+
/**
|
|
12
|
+
* Emits an IfcRelConnectsPathElements recording a connection between two
|
|
13
|
+
* path-based elements (e.g. walls, beams) at specified path ends. Priority
|
|
14
|
+
* arrays are emitted empty; connection geometry is left null.
|
|
15
|
+
*/
|
|
16
|
+
export declare function writeRelConnectsPathElements(w: IfcWriter, guid: IfcGuid, ownerHistoryId: number, relatingElementId: number, relatedElementId: number, relatingConnectionType: PathConnectionTypeIfc, relatedConnectionType: PathConnectionTypeIfc, description?: string | null): void;
|