bimdown-cli 0.4.0 → 0.5.1
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 +24 -3
- package/dist/chunk-4SKM4RHY.js +142 -0
- package/dist/chunk-4SKM4RHY.js.map +1 -0
- package/dist/chunk-4YHVOWS4.js +255 -0
- package/dist/chunk-4YHVOWS4.js.map +1 -0
- package/dist/chunk-AYAXRYGP.js +2129 -0
- package/dist/chunk-AYAXRYGP.js.map +1 -0
- package/dist/chunk-EC5MR5ZH.js +648 -0
- package/dist/chunk-EC5MR5ZH.js.map +1 -0
- package/dist/chunk-HS3PO2LB.js +487 -0
- package/dist/chunk-HS3PO2LB.js.map +1 -0
- package/dist/chunk-IQJA3EFO.js +179 -0
- package/dist/chunk-IQJA3EFO.js.map +1 -0
- package/dist/chunk-JY6KWRDB.js +80 -0
- package/dist/chunk-JY6KWRDB.js.map +1 -0
- package/dist/chunk-KWSGJUMZ.js +2501 -0
- package/dist/chunk-KWSGJUMZ.js.map +1 -0
- package/dist/chunk-LWYIPR64.js +35 -0
- package/dist/chunk-LWYIPR64.js.map +1 -0
- package/dist/chunk-OBY3UYCO.js +44 -0
- package/dist/chunk-OBY3UYCO.js.map +1 -0
- package/dist/chunk-XC6WHJRL.js +29 -0
- package/dist/chunk-XC6WHJRL.js.map +1 -0
- package/dist/chunk-XQU52JKB.js +187 -0
- package/dist/chunk-XQU52JKB.js.map +1 -0
- package/dist/clash-load-D3LNQR6G.js +941 -0
- package/dist/clash-load-D3LNQR6G.js.map +1 -0
- package/dist/cli.js +306 -3377
- package/dist/cli.js.map +1 -1
- package/dist/dehydrate-ZHAGOI7Q.js +90 -0
- package/dist/dehydrate-ZHAGOI7Q.js.map +1 -0
- package/dist/diff-T2KOK2WR.js +89 -0
- package/dist/diff-T2KOK2WR.js.map +1 -0
- package/dist/engine-2TPWJVEQ.js +12 -0
- package/dist/engine-2TPWJVEQ.js.map +1 -0
- package/dist/hydrate-V24H7IF3.js +673 -0
- package/dist/hydrate-V24H7IF3.js.map +1 -0
- package/dist/import-ifc-RCZSXDA6.js +5324 -0
- package/dist/import-ifc-RCZSXDA6.js.map +1 -0
- package/dist/info-QC7YXWNX.js +92 -0
- package/dist/info-QC7YXWNX.js.map +1 -0
- package/dist/init-VWDML3UC.js +112 -0
- package/dist/init-VWDML3UC.js.map +1 -0
- package/dist/lib.d.ts +427 -44
- package/dist/lib.js +6482 -225
- package/dist/lib.js.map +1 -1
- package/dist/mep-W4HJI363.js +25 -0
- package/dist/mep-W4HJI363.js.map +1 -0
- package/dist/merge-ESOPDSA5.js +413 -0
- package/dist/merge-ESOPDSA5.js.map +1 -0
- package/dist/publish-3TAXQCUV.js +80 -0
- package/dist/publish-3TAXQCUV.js.map +1 -0
- package/dist/render-UEWYHPN6.js +1807 -0
- package/dist/render-UEWYHPN6.js.map +1 -0
- package/dist/resolve-topology-AQ2RO3W3.js +338 -0
- package/dist/resolve-topology-AQ2RO3W3.js.map +1 -0
- package/dist/spec/csv-schema/annotation/dimension.yaml +77 -0
- package/dist/spec/csv-schema/annotation/tag.yaml +44 -0
- package/dist/spec/csv-schema/annotation/text_note.yaml +52 -0
- package/dist/spec/csv-schema/architecture/ceiling.yaml +8 -1
- package/dist/spec/csv-schema/architecture/column.yaml +5 -1
- package/dist/spec/csv-schema/architecture/curtain_wall.yaml +45 -5
- package/dist/spec/csv-schema/architecture/door.yaml +5 -0
- package/dist/spec/csv-schema/architecture/furniture.yaml +28 -0
- package/dist/spec/csv-schema/architecture/opening.yaml +27 -6
- package/dist/spec/csv-schema/architecture/railing.yaml +35 -0
- package/dist/spec/csv-schema/architecture/roof.yaml +34 -1
- package/dist/spec/csv-schema/architecture/slab.yaml +19 -0
- package/dist/spec/csv-schema/architecture/space.yaml +11 -1
- package/dist/spec/csv-schema/architecture/stair.yaml +49 -0
- package/dist/spec/csv-schema/architecture/stair_landing.yaml +36 -0
- package/dist/spec/csv-schema/architecture/stair_run.yaml +31 -0
- package/dist/spec/csv-schema/architecture/wall.yaml +14 -1
- package/dist/spec/csv-schema/architecture/window.yaml +19 -0
- package/dist/spec/csv-schema/base/element.yaml +20 -11
- package/dist/spec/csv-schema/base/furniture_params.yaml +60 -0
- package/dist/spec/csv-schema/base/hosted_element.yaml +10 -2
- package/dist/spec/csv-schema/base/mep_connectable.yaml +23 -0
- package/dist/spec/csv-schema/base/mep_design.yaml +24 -0
- package/dist/spec/csv-schema/base/mep_insulated.yaml +9 -0
- package/dist/spec/csv-schema/base/mep_system_tag.yaml +12 -0
- package/dist/spec/csv-schema/base/point_element.yaml +1 -0
- package/dist/spec/csv-schema/base/section_profile.yaml +5 -0
- package/dist/spec/csv-schema/base/spatial_line_element.yaml +4 -2
- package/dist/spec/csv-schema/base/structural_section_profile.yaml +50 -0
- package/dist/spec/csv-schema/base/vertical_span.yaml +5 -4
- package/dist/spec/csv-schema/base/wall_bounded.yaml +21 -0
- package/dist/spec/csv-schema/grid.yaml +5 -0
- package/dist/spec/csv-schema/mep/cable_tray.yaml +10 -3
- package/dist/spec/csv-schema/mep/circuit.yaml +70 -0
- package/dist/spec/csv-schema/mep/conduit.yaml +2 -2
- package/dist/spec/csv-schema/mep/connector.yaml +112 -0
- package/dist/spec/csv-schema/mep/duct.yaml +10 -3
- package/dist/spec/csv-schema/mep/equipment.yaml +18 -1
- package/dist/spec/csv-schema/mep/mep_node.yaml +91 -2
- package/dist/spec/csv-schema/mep/mep_system.yaml +21 -0
- package/dist/spec/csv-schema/mep/pipe.yaml +27 -3
- package/dist/spec/csv-schema/mep/terminal.yaml +22 -1
- package/dist/spec/csv-schema/model_group.yaml +40 -0
- package/dist/spec/csv-schema/sheet/sheet.yaml +50 -0
- package/dist/spec/csv-schema/sheet/sheet_viewport.yaml +86 -0
- package/dist/spec/csv-schema/structure/beam.yaml +29 -1
- package/dist/spec/csv-schema/structure/beam_system.yaml +29 -0
- package/dist/spec/csv-schema/structure/brace.yaml +24 -1
- package/dist/spec/csv-schema/structure/foundation.yaml +40 -7
- package/dist/spec/csv-schema/structure/structure_column.yaml +19 -1
- package/dist/spec/csv-schema/structure/structure_slab.yaml +32 -0
- package/dist/spec/csv-schema/structure/structure_wall.yaml +22 -0
- package/dist/spec/csv-schema/types/beam_type.yaml +11 -0
- package/dist/spec/csv-schema/types/ceiling_type.yaml +6 -0
- package/dist/spec/csv-schema/types/column_type.yaml +12 -0
- package/dist/spec/csv-schema/types/curtain_wall_type.yaml +32 -0
- package/dist/spec/csv-schema/types/door_type.yaml +27 -0
- package/dist/spec/csv-schema/types/element_type.yaml +21 -0
- package/dist/spec/csv-schema/types/fenestration.yaml +16 -0
- package/dist/spec/csv-schema/types/foundation_type.yaml +36 -0
- package/dist/spec/csv-schema/types/furniture_type.yaml +11 -0
- package/dist/spec/csv-schema/types/layered_type.yaml +13 -0
- package/dist/spec/csv-schema/types/railing_type.yaml +40 -0
- package/dist/spec/csv-schema/types/roof_type.yaml +7 -0
- package/dist/spec/csv-schema/types/slab_type.yaml +9 -0
- package/dist/spec/csv-schema/types/type_layer.yaml +47 -0
- package/dist/spec/csv-schema/types/wall_type.yaml +6 -0
- package/dist/spec/csv-schema/types/window_type.yaml +31 -0
- package/dist/spec/csv-schema/underlay.yaml +73 -0
- package/dist/spec/csv-schema/view.yaml +36 -0
- package/dist/spec/duckdb-strategy.md +4 -3
- package/dist/spec/geojson-schema/readme.md +380 -0
- package/dist/spec/mep-port-conventions.md +190 -0
- package/dist/spec/migration-guide.md +1 -1
- package/dist/spec/project_metadata.schema.yaml +52 -4
- package/dist/spec/readme.md +356 -97
- package/dist/spec/starter-types/global/beam_type.csv +5 -0
- package/dist/spec/starter-types/global/ceiling_type.csv +3 -0
- package/dist/spec/starter-types/global/column_type.csv +5 -0
- package/dist/spec/starter-types/global/curtain_wall_type.csv +2 -0
- package/dist/spec/starter-types/global/door_type.csv +6 -0
- package/dist/spec/starter-types/global/foundation_type.csv +7 -0
- package/dist/spec/starter-types/global/furniture_type.csv +11 -0
- package/dist/spec/starter-types/global/railing_type.csv +5 -0
- package/dist/spec/starter-types/global/roof_type.csv +3 -0
- package/dist/spec/starter-types/global/slab_type.csv +4 -0
- package/dist/spec/starter-types/global/type_layer.csv +40 -0
- package/dist/spec/starter-types/global/wall_type.csv +8 -0
- package/dist/spec/starter-types/global/window_type.csv +6 -0
- package/dist/spec/svg-schema/readme.md +47 -1
- package/package.json +6 -3
- package/dist/spec/csv-schema/base/mep_connected_segment.yaml +0 -17
- package/dist/spec/csv-schema/base/mep_system.yaml +0 -7
package/dist/lib.d.ts
CHANGED
|
@@ -1,62 +1,154 @@
|
|
|
1
1
|
export { default as Coordinate } from 'jsts/org/locationtech/jts/geom/Coordinate.js';
|
|
2
2
|
export { default as GeometryFactory } from 'jsts/org/locationtech/jts/geom/GeometryFactory.js';
|
|
3
|
+
import * as W from 'web-ifc';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* GeoJSON types, parsing and geometry helpers for BimDown geometry files
|
|
7
|
+
* (no file access: shared with the browser IFC importer; file I/O in geojson.ts).
|
|
8
|
+
*
|
|
9
|
+
* BimDown uses a strict subset of GeoJSON (see spec/geojson-schema/readme.md):
|
|
10
|
+
* - FeatureCollection at the top level
|
|
11
|
+
* - Per Feature: properties.id (matches CSV row) + geometry (Point, LineString, or Polygon)
|
|
12
|
+
* - 2D coords [x, y] for level-anchored elements (walls, slabs, columns, ...)
|
|
13
|
+
* - 3D coords [x, y, z] for spatial elements (beams, ducts, ...)
|
|
14
|
+
*
|
|
15
|
+
* Optional properties carry numeric geometry hints:
|
|
16
|
+
* - base_offset, top_offset (meters): Z offsets for level-anchored elements
|
|
17
|
+
* - arc: { radius, large_arc, sweep } for curved LineStrings
|
|
18
|
+
* - rotation (degrees CCW about +Z) for Point elements
|
|
19
|
+
*/
|
|
20
|
+
type Position = [number, number] | [number, number, number];
|
|
21
|
+
interface PointGeometryJson {
|
|
22
|
+
type: 'Point';
|
|
23
|
+
coordinates: Position;
|
|
24
|
+
}
|
|
25
|
+
interface LineStringGeometryJson {
|
|
26
|
+
type: 'LineString';
|
|
27
|
+
coordinates: Position[];
|
|
28
|
+
}
|
|
29
|
+
interface PolygonGeometryJson {
|
|
30
|
+
type: 'Polygon';
|
|
31
|
+
/** First ring is the outer ring; subsequent rings are holes. */
|
|
32
|
+
coordinates: Position[][];
|
|
33
|
+
}
|
|
34
|
+
type GeoJsonGeometry = PointGeometryJson | LineStringGeometryJson | PolygonGeometryJson;
|
|
35
|
+
interface ArcParams {
|
|
36
|
+
radius: number;
|
|
37
|
+
large_arc: boolean;
|
|
38
|
+
sweep: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface BimDownFeatureProperties {
|
|
6
41
|
id: string;
|
|
7
|
-
|
|
42
|
+
base_offset?: number;
|
|
43
|
+
top_offset?: number;
|
|
44
|
+
arc?: ArcParams;
|
|
45
|
+
rotation?: number;
|
|
46
|
+
/** Any additional AI-emitted hints — preserved on round-trip until normalized away. */
|
|
47
|
+
[key: string]: unknown;
|
|
8
48
|
}
|
|
9
|
-
interface
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
raw: unknown;
|
|
49
|
+
interface BimDownFeature {
|
|
50
|
+
type: 'Feature';
|
|
51
|
+
properties: BimDownFeatureProperties;
|
|
52
|
+
geometry: GeoJsonGeometry;
|
|
14
53
|
}
|
|
15
|
-
|
|
54
|
+
interface BimDownFeatureCollection {
|
|
55
|
+
type: 'FeatureCollection';
|
|
56
|
+
features: BimDownFeature[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Pretty-print a FeatureCollection with one feature per line (compact coords)
|
|
60
|
+
* for human readability and clean diffs.
|
|
61
|
+
*/
|
|
62
|
+
declare function stringifyFeatureCollection(fc: BimDownFeatureCollection): string;
|
|
16
63
|
interface LineGeometry {
|
|
17
64
|
start_x: number;
|
|
18
65
|
start_y: number;
|
|
66
|
+
start_z?: number;
|
|
19
67
|
end_x: number;
|
|
20
68
|
end_y: number;
|
|
69
|
+
end_z?: number;
|
|
21
70
|
length: number;
|
|
22
|
-
|
|
71
|
+
arc?: ArcParams;
|
|
23
72
|
}
|
|
24
|
-
interface
|
|
73
|
+
interface PointGeometry {
|
|
25
74
|
x: number;
|
|
26
75
|
y: number;
|
|
76
|
+
z?: number;
|
|
27
77
|
rotation: number;
|
|
28
|
-
size_x: number;
|
|
29
|
-
size_y: number;
|
|
30
78
|
}
|
|
31
79
|
interface PolygonGeometry {
|
|
32
|
-
|
|
80
|
+
/** Outer ring, 2D, with closing duplicate vertex removed. */
|
|
81
|
+
outer: {
|
|
82
|
+
x: number;
|
|
83
|
+
y: number;
|
|
84
|
+
}[];
|
|
85
|
+
/** Holes, each ring same convention as outer. */
|
|
86
|
+
holes: {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
}[][];
|
|
90
|
+
/** Signed area of the outer ring minus holes (always returned as absolute m²). */
|
|
33
91
|
area: number;
|
|
34
92
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
declare function
|
|
44
|
-
|
|
93
|
+
declare function extractLineGeometry(feature: BimDownFeature): LineGeometry;
|
|
94
|
+
declare function extractPointGeometry(feature: BimDownFeature): PointGeometry;
|
|
95
|
+
declare function extractPolygonGeometry(feature: BimDownFeature): PolygonGeometry;
|
|
96
|
+
declare function featureId(feature: BimDownFeature): string;
|
|
97
|
+
/**
|
|
98
|
+
* Compute axis-aligned bounding box of a geometry. Returns null for empty.
|
|
99
|
+
* Z is included only if all coordinates carry Z.
|
|
100
|
+
*/
|
|
101
|
+
declare function geometryBounds(g: GeoJsonGeometry): {
|
|
102
|
+
minX: number;
|
|
103
|
+
minY: number;
|
|
104
|
+
maxX: number;
|
|
105
|
+
maxY: number;
|
|
106
|
+
minZ?: number;
|
|
107
|
+
maxZ?: number;
|
|
108
|
+
} | null;
|
|
109
|
+
|
|
110
|
+
declare function parseGeoJsonFile(filePath: string): BimDownFeatureCollection;
|
|
45
111
|
|
|
46
112
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
113
|
+
* BimDown geometry toolkit — bridges GeoJSON files and JSTS computational geometry.
|
|
114
|
+
*
|
|
115
|
+
* AI agents and scripts can use this to:
|
|
116
|
+
* - Load all geometry from a BimDown GeoJSON file as JSTS geometries
|
|
117
|
+
* - Perform computational geometry operations (buffer, split, boolean ops)
|
|
118
|
+
* - Write results back to GeoJSON files
|
|
119
|
+
*
|
|
120
|
+
* Example:
|
|
121
|
+
* import { readBimDownGeometry, writeBimDownGeometry, GeometryFactory, Coordinate } from 'bimdown-cli';
|
|
122
|
+
*
|
|
123
|
+
* const slabs = readBimDownGeometry('project/lv-1/slab.geojson');
|
|
124
|
+
* const slab = slabs.get('sl-1'); // JSTS Polygon
|
|
125
|
+
*
|
|
126
|
+
* const factory = new GeometryFactory();
|
|
127
|
+
* const splitLine = factory.createPolygon(factory.createLinearRing([
|
|
128
|
+
* new Coordinate(-1000, -1000), new Coordinate(5, -1000),
|
|
129
|
+
* new Coordinate(5, 1000), new Coordinate(-1000, 1000),
|
|
130
|
+
* new Coordinate(-1000, -1000),
|
|
131
|
+
* ]));
|
|
132
|
+
* const left = slab.intersection(splitLine);
|
|
133
|
+
* const right = slab.difference(splitLine);
|
|
134
|
+
*
|
|
135
|
+
* slabs.delete('sl-1');
|
|
136
|
+
* slabs.set('sl-1a', left);
|
|
137
|
+
* slabs.set('sl-1b', right);
|
|
138
|
+
* writeBimDownGeometry('project/lv-1/slab.geojson', slabs);
|
|
50
139
|
*/
|
|
140
|
+
|
|
51
141
|
interface JstsGeometry {
|
|
52
142
|
getGeometryType(): 'Point' | 'LineString' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon' | 'GeometryCollection' | (string & {});
|
|
53
143
|
getCoordinates(): {
|
|
54
144
|
x: number;
|
|
55
145
|
y: number;
|
|
146
|
+
z?: number;
|
|
56
147
|
}[];
|
|
57
148
|
getCoordinate(): {
|
|
58
149
|
x: number;
|
|
59
150
|
y: number;
|
|
151
|
+
z?: number;
|
|
60
152
|
};
|
|
61
153
|
getEnvelopeInternal(): {
|
|
62
154
|
getMinX(): number;
|
|
@@ -79,31 +171,322 @@ interface JstsGeometry {
|
|
|
79
171
|
type BimDownGeometry = JstsGeometry;
|
|
80
172
|
type GeometryMap = Map<string, BimDownGeometry>;
|
|
81
173
|
/**
|
|
82
|
-
* Convert a
|
|
83
|
-
* Returns null
|
|
174
|
+
* Convert a GeoJSON geometry to a JSTS geometry.
|
|
175
|
+
* Returns null for unsupported types.
|
|
84
176
|
*/
|
|
85
|
-
declare function
|
|
177
|
+
declare function geoJsonToJsts(g: GeoJsonGeometry): BimDownGeometry | null;
|
|
86
178
|
/**
|
|
87
|
-
* Convert a JSTS geometry back to
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* - Polygon → <polygon points="x,y x,y ..." />
|
|
91
|
-
* - Point → <circle cx cy r="0.15" /> (default radius, caller may override attributes)
|
|
92
|
-
* - Multi* / GeometryCollection → emits multiple elements with id suffixes a, b, c, ...
|
|
179
|
+
* Convert a JSTS geometry back to a GeoJSON geometry.
|
|
180
|
+
* Multi* geometries are returned as their first sub-geometry; callers needing
|
|
181
|
+
* a split into multiple Features should use `writeBimDownGeometry`, which handles it.
|
|
93
182
|
*/
|
|
94
|
-
declare function
|
|
183
|
+
declare function jstsToGeoJson(geom: BimDownGeometry): GeoJsonGeometry | null;
|
|
95
184
|
/**
|
|
96
|
-
* Read
|
|
185
|
+
* Read a BimDown GeoJSON file and return a Map of element id → JSTS geometry.
|
|
97
186
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
187
|
+
* Geometry property metadata (arc, rotation, base_offset, …) is dropped on this
|
|
188
|
+
* conversion. For round-trip fidelity with metadata, use `readFeatureCollection`
|
|
189
|
+
* and write back via `writeFeatureCollection`.
|
|
100
190
|
*/
|
|
101
191
|
declare function readBimDownGeometry(filePath: string): GeometryMap;
|
|
102
192
|
/**
|
|
103
|
-
* Write a GeometryMap back
|
|
104
|
-
*
|
|
105
|
-
* wrapper and Y-up coordinate convention.
|
|
193
|
+
* Write a GeometryMap back as a BimDown FeatureCollection.
|
|
194
|
+
* Multi* JSTS results are split into multiple Features with suffixed ids (`<id>a`, `<id>b`, …).
|
|
106
195
|
*/
|
|
107
196
|
declare function writeBimDownGeometry(filePath: string, geometries: GeometryMap): void;
|
|
197
|
+
/** Read a BimDown FeatureCollection preserving all properties. */
|
|
198
|
+
declare function readFeatureCollection(filePath: string): BimDownFeatureCollection;
|
|
199
|
+
/** Write a BimDown FeatureCollection (compact one-line-per-feature formatting). */
|
|
200
|
+
declare function writeFeatureCollection(filePath: string, fc: BimDownFeatureCollection): void;
|
|
201
|
+
|
|
202
|
+
interface TypeLayer {
|
|
203
|
+
id: string;
|
|
204
|
+
seq: number;
|
|
205
|
+
function: string;
|
|
206
|
+
material: string;
|
|
207
|
+
thickness: number;
|
|
208
|
+
conductivity?: number;
|
|
209
|
+
name: string;
|
|
210
|
+
}
|
|
211
|
+
interface ElementType {
|
|
212
|
+
id: string;
|
|
213
|
+
/** Type table, e.g. `wall_type`. */
|
|
214
|
+
table: string;
|
|
215
|
+
row: Record<string, string>;
|
|
216
|
+
/** Layers sorted by `seq` (layered types only; empty otherwise). */
|
|
217
|
+
layers: TypeLayer[];
|
|
218
|
+
}
|
|
219
|
+
interface TypeCatalog {
|
|
220
|
+
types: Map<string, ElementType>;
|
|
221
|
+
}
|
|
222
|
+
/** A layer as it applies to one element: thickness adjusted to the element's
|
|
223
|
+
* effective thickness and its offset from the exterior / top face. */
|
|
224
|
+
interface ResolvedLayer extends TypeLayer {
|
|
225
|
+
/** Distance from the exterior (wall) / top (slab, roof, ceiling) face to the layer's near side. */
|
|
226
|
+
offset: number;
|
|
227
|
+
}
|
|
228
|
+
/** Build a catalog from already-read rows (type tables + type_layer). */
|
|
229
|
+
declare function catalogFromRows(typeRows: {
|
|
230
|
+
table: string;
|
|
231
|
+
rows: Record<string, string>[];
|
|
232
|
+
}[], layerRows: Record<string, string>[]): TypeCatalog;
|
|
233
|
+
/** Load the project's type catalog from global/ (cached until a type file changes). */
|
|
234
|
+
declare function loadCatalog(projectDir: string): TypeCatalog;
|
|
235
|
+
/** Sum of a type's layer thicknesses, or undefined when it has no layers. */
|
|
236
|
+
declare function layerTotal(t: ElementType): number | undefined;
|
|
237
|
+
/** The type's parameter values (non-empty columns other than id/name/description),
|
|
238
|
+
* with thickness derived from the layers when the type leaves it empty. */
|
|
239
|
+
declare function typeValues(t: ElementType): Record<string, string>;
|
|
240
|
+
/** Field names an instance table inherits from its type table (shared by name). */
|
|
241
|
+
declare function typeParamFields(instanceTable: string): string[];
|
|
242
|
+
/** The row with every empty type parameter filled from its type. */
|
|
243
|
+
declare function effectiveRow(instanceTable: string, row: Record<string, string>, catalog: TypeCatalog): Record<string, string>;
|
|
244
|
+
/** effectiveRow for every row, loading the catalog of `projectDir`. */
|
|
245
|
+
declare function effectiveRows(projectDir: string, instanceTable: string, rows: Record<string, string>[]): Record<string, string>[];
|
|
246
|
+
/**
|
|
247
|
+
* Layers of one element, exterior/top first. When the element overrides the
|
|
248
|
+
* type's thickness the core layer (or, without one, the thickest layer) absorbs
|
|
249
|
+
* the difference; if that would leave it non-positive the layers are scaled.
|
|
250
|
+
* Returns null for untyped elements and types without layers.
|
|
251
|
+
*/
|
|
252
|
+
declare function resolvedLayers(instanceTable: string, row: Record<string, string>, catalog: TypeCatalog): ResolvedLayer[] | null;
|
|
253
|
+
interface ElementLayers {
|
|
254
|
+
table: string;
|
|
255
|
+
/** `global` or the level directory (lv-N). */
|
|
256
|
+
level: string;
|
|
257
|
+
id: string;
|
|
258
|
+
typeId: string;
|
|
259
|
+
layers: ResolvedLayer[];
|
|
260
|
+
}
|
|
261
|
+
/** Resolved layers of every typed element in the project (e.g. for IFC material layer sets). */
|
|
262
|
+
declare function projectElementLayers(projectDir: string): ElementLayers[];
|
|
263
|
+
|
|
264
|
+
type Position2 = [number, number];
|
|
265
|
+
type Position3 = [number, number, number];
|
|
266
|
+
type Geometry = {
|
|
267
|
+
type: 'Point';
|
|
268
|
+
coordinates: Position2 | Position3;
|
|
269
|
+
} | {
|
|
270
|
+
type: 'LineString';
|
|
271
|
+
coordinates: (Position2 | Position3)[];
|
|
272
|
+
} | {
|
|
273
|
+
type: 'Polygon';
|
|
274
|
+
coordinates: Position2[][];
|
|
275
|
+
};
|
|
276
|
+
type AttrValue = string | number | null | undefined;
|
|
277
|
+
/** One BimDown element (a CSV row plus, for tables that have one, a GeoJSON feature). */
|
|
278
|
+
interface OutEl {
|
|
279
|
+
table: string;
|
|
280
|
+
id: string;
|
|
281
|
+
/** Source IFC express id (0 for elements the importer adds, e.g. room separators). */
|
|
282
|
+
src: number;
|
|
283
|
+
/** Base level index. */
|
|
284
|
+
level: number;
|
|
285
|
+
/** Lives in global/ (spans more than one level above its base). */
|
|
286
|
+
global?: boolean;
|
|
287
|
+
attrs: Record<string, AttrValue>;
|
|
288
|
+
/** GeoJSON feature properties besides `id` (base_offset, top_offset, arc, rotation, size). */
|
|
289
|
+
props: Record<string, unknown>;
|
|
290
|
+
geometry: Geometry | null;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* MEP topology: `from` / `to` on every duct / pipe / conduit / cable tray end
|
|
295
|
+
* from the IFC port graph (IfcDistributionPort nested in IFC4 or attached by
|
|
296
|
+
* IfcRelConnectsPortToElement in IFC2x3, joined by IfcRelConnectsPorts), and
|
|
297
|
+
* from geometry for elements that have no ports (curve ends on fitting and
|
|
298
|
+
* device bodies, on each other, on another run's side).
|
|
299
|
+
*
|
|
300
|
+
* BimDown's graph is curves between hosts, so connections the port graph
|
|
301
|
+
* makes directly are rebuilt in that shape:
|
|
302
|
+
* - run end ↔ run end: a coupling node where they meet;
|
|
303
|
+
* - run end ↔ another run's side (Revit taps, ports 3…n of a duct): the main
|
|
304
|
+
* is split there and a `tap` node joins the pieces and the branch;
|
|
305
|
+
* - host ↔ host (terminal on an elbow, fitting on fitting, damper on a tee):
|
|
306
|
+
* a short connector run between them.
|
|
307
|
+
* Passive fittings then sit on the intersection of their legs' axes (where
|
|
308
|
+
* the editor draws the elbow / tee) and get their kind (`fitting`) from the
|
|
309
|
+
* IFC PredefinedType, the Revit family / type name, or legs and geometry.
|
|
310
|
+
* Port placements are optional (Solibri-optimised files drop them); the port
|
|
311
|
+
* flow direction (SINK = inlet) decides which end is `from`.
|
|
312
|
+
*/
|
|
313
|
+
|
|
314
|
+
interface MepTopologyReport {
|
|
315
|
+
/** IfcDistributionPorts on imported MEP elements. */
|
|
316
|
+
sourcePorts: number;
|
|
317
|
+
/** IfcRelConnectsPorts between two imported MEP elements. */
|
|
318
|
+
sourceLinks: number;
|
|
319
|
+
/** Of those, links that became connections. */
|
|
320
|
+
linksUsed: number;
|
|
321
|
+
/** Connections found from geometry (elements without ports). */
|
|
322
|
+
inferred: number;
|
|
323
|
+
/** Run ends (after splits and connector runs) / with a host / open. */
|
|
324
|
+
curveEnds: number;
|
|
325
|
+
connectedEnds: number;
|
|
326
|
+
openEnds: number;
|
|
327
|
+
/** Open run ends whose source port has no connection either (true open ends). */
|
|
328
|
+
sourceOpenEnds: number;
|
|
329
|
+
couplings: number;
|
|
330
|
+
taps: number;
|
|
331
|
+
connectors: number;
|
|
332
|
+
/** Passive fittings per recorded kind. */
|
|
333
|
+
fittingKinds: Record<string, number>;
|
|
334
|
+
/** Equipment connectors waiting for their names (internal; see nameEquipmentPorts). */
|
|
335
|
+
pendingPorts?: PendingPort[];
|
|
336
|
+
}
|
|
337
|
+
interface PendingPort {
|
|
338
|
+
conn: OutEl;
|
|
339
|
+
host: OutEl;
|
|
340
|
+
run: OutEl;
|
|
341
|
+
side: 'from' | 'to';
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* A derived-room problem: the polygons are still written (backward compatible),
|
|
346
|
+
* but their areas are wrong.
|
|
347
|
+
* shared — several seeds land in one enclosed area, so the rooms get
|
|
348
|
+
* identical polygons (usually a wall gap or a missing room_separator);
|
|
349
|
+
* the first seed (CSV order) keeps the area, the others are
|
|
350
|
+
* redundant rooms (Revit): area 0
|
|
351
|
+
* contains — the polygon of spaceIds encloses the rooms in `inside`, whose
|
|
352
|
+
* walls don't touch it, so its area double-counts them
|
|
353
|
+
* unbounded — the seed is outside every closed loop; no polygon is generated
|
|
354
|
+
*/
|
|
355
|
+
interface RoomIssue {
|
|
356
|
+
kind: 'shared' | 'contains' | 'unbounded';
|
|
357
|
+
level: string;
|
|
358
|
+
spaceIds: string[];
|
|
359
|
+
/** For `contains`: the enclosed rooms. */
|
|
360
|
+
inside?: string[];
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* IFC → BimDown import. Pure TypeScript over an initialised web-ifc `IfcAPI`
|
|
365
|
+
* (no file system), so the same code runs in the CLI (`bimdown import-ifc`)
|
|
366
|
+
* and in a browser Web Worker. Returns the project files (path → text) and a
|
|
367
|
+
* report: counts per IFC class and BimDown table, what was skipped and why,
|
|
368
|
+
* wall joins, room problems and the derived-vs-IFC room area comparison.
|
|
369
|
+
*
|
|
370
|
+
* Pipeline: open → index relationships → storeys → levels → stream meshes
|
|
371
|
+
* (world space, voids cut) → convert per category → snap / join walls → host
|
|
372
|
+
* doors & windows → spaces + room separators → trace rooms → write files.
|
|
373
|
+
*/
|
|
374
|
+
|
|
375
|
+
type ImportPhase = 'parse' | 'geometry' | 'convert' | 'cleanup' | 'rooms' | 'write';
|
|
376
|
+
interface ImportProgress {
|
|
377
|
+
phase: ImportPhase;
|
|
378
|
+
/** 0..1 over the whole import. */
|
|
379
|
+
fraction: number;
|
|
380
|
+
}
|
|
381
|
+
interface ImportIfcOptions {
|
|
382
|
+
/** Source file name (for the report and project metadata). */
|
|
383
|
+
fileName?: string;
|
|
384
|
+
projectName?: string;
|
|
385
|
+
onProgress?: (p: ImportProgress) => void;
|
|
386
|
+
/** Tables the target project supports; furniture is imported only when listed. */
|
|
387
|
+
tables?: Iterable<string>;
|
|
388
|
+
/** Also return the IFC space outlines (for diagnostics). */
|
|
389
|
+
debug?: boolean;
|
|
390
|
+
}
|
|
391
|
+
interface ClassReport {
|
|
392
|
+
ifcClass: string;
|
|
393
|
+
count: number;
|
|
394
|
+
/** Became BimDown rows of their own (or through their parts, for aggregates). */
|
|
395
|
+
imported: number;
|
|
396
|
+
/** Folded into another element (curtain wall panels, the opening a door fills …). */
|
|
397
|
+
included: number;
|
|
398
|
+
tables: string[];
|
|
399
|
+
skipped: {
|
|
400
|
+
reason: string;
|
|
401
|
+
count: number;
|
|
402
|
+
}[];
|
|
403
|
+
}
|
|
404
|
+
interface ImportReport {
|
|
405
|
+
source: {
|
|
406
|
+
fileName?: string;
|
|
407
|
+
schema: string;
|
|
408
|
+
bytes: number;
|
|
409
|
+
lengthUnitToMeter: number;
|
|
410
|
+
application?: string;
|
|
411
|
+
};
|
|
412
|
+
levels: {
|
|
413
|
+
id: string;
|
|
414
|
+
name: string;
|
|
415
|
+
elevation: number;
|
|
416
|
+
}[];
|
|
417
|
+
/** BimDown rows written per table. */
|
|
418
|
+
counts: Record<string, number>;
|
|
419
|
+
classes: ClassReport[];
|
|
420
|
+
notes: string[];
|
|
421
|
+
joins: {
|
|
422
|
+
snapped: number;
|
|
423
|
+
corners: number;
|
|
424
|
+
tees: number;
|
|
425
|
+
separators: number;
|
|
426
|
+
freeEnds: number;
|
|
427
|
+
};
|
|
428
|
+
rooms: {
|
|
429
|
+
count: number;
|
|
430
|
+
issues: RoomIssue[];
|
|
431
|
+
warnings: string[];
|
|
432
|
+
/** Derived net area vs the IFC space outline, over rooms that closed. */
|
|
433
|
+
area: {
|
|
434
|
+
compared: number;
|
|
435
|
+
meanAbsPct: number;
|
|
436
|
+
medianAbsPct: number;
|
|
437
|
+
maxAbsPct: number;
|
|
438
|
+
within5Pct: number;
|
|
439
|
+
} | null;
|
|
440
|
+
worst: {
|
|
441
|
+
id: string;
|
|
442
|
+
name?: string;
|
|
443
|
+
ifcArea: number;
|
|
444
|
+
netArea: number;
|
|
445
|
+
}[];
|
|
446
|
+
/** Space id → "number name" for the spaces named in `issues`. */
|
|
447
|
+
labels: Record<string, string>;
|
|
448
|
+
};
|
|
449
|
+
/** Plan shift applied to bring a far-away model near the origin (meters). */
|
|
450
|
+
offset: {
|
|
451
|
+
x: number;
|
|
452
|
+
y: number;
|
|
453
|
+
} | null;
|
|
454
|
+
/** MEP connectivity vs the source port graph, and systems written. */
|
|
455
|
+
mep: (MepTopologyReport & {
|
|
456
|
+
systems: number;
|
|
457
|
+
}) | null;
|
|
458
|
+
timings: {
|
|
459
|
+
parseMs: number;
|
|
460
|
+
geometryMs: number;
|
|
461
|
+
convertMs: number;
|
|
462
|
+
cleanupMs: number;
|
|
463
|
+
totalMs: number;
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
interface ImportResult {
|
|
467
|
+
files: Record<string, string>;
|
|
468
|
+
report: ImportReport;
|
|
469
|
+
/** With `debug`: IFC space outlines per space id. */
|
|
470
|
+
debug?: {
|
|
471
|
+
spaces: {
|
|
472
|
+
id: string;
|
|
473
|
+
level: string;
|
|
474
|
+
outline: {
|
|
475
|
+
x: number;
|
|
476
|
+
y: number;
|
|
477
|
+
}[];
|
|
478
|
+
}[];
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
type ImportErrorCode = 'not_ifc' | 'unsupported_format' | 'unsupported_schema' | 'corrupt' | 'empty';
|
|
482
|
+
declare class IfcImportError extends Error {
|
|
483
|
+
readonly code: ImportErrorCode;
|
|
484
|
+
constructor(code: ImportErrorCode, message: string);
|
|
485
|
+
}
|
|
486
|
+
/** Reject what web-ifc can't read before handing it the bytes. */
|
|
487
|
+
declare function sniffIfc(data: Uint8Array): void;
|
|
488
|
+
declare function importIfc(api: W.IfcAPI, data: Uint8Array, opts?: ImportIfcOptions): ImportResult;
|
|
489
|
+
/** Plain-text report (CLI output). */
|
|
490
|
+
declare function formatReport(r: ImportReport): string;
|
|
108
491
|
|
|
109
|
-
export { type BimDownGeometry, type GeometryMap, type
|
|
492
|
+
export { type ArcParams, type BimDownFeature, type BimDownFeatureCollection, type BimDownFeatureProperties, type BimDownGeometry, type ClassReport, type ElementLayers, type ElementType, type GeoJsonGeometry, type GeometryMap, IfcImportError, type ImportErrorCode, type ImportIfcOptions, type ImportPhase, type ImportProgress, type ImportReport, type ImportResult, type LineGeometry, type LineStringGeometryJson, type PointGeometry, type PointGeometryJson, type PolygonGeometry, type PolygonGeometryJson, type Position, type ResolvedLayer, type TypeCatalog, type TypeLayer, catalogFromRows, effectiveRow, effectiveRows, extractLineGeometry, extractPointGeometry, extractPolygonGeometry, featureId, formatReport, geoJsonToJsts, geometryBounds, importIfc, jstsToGeoJson, layerTotal, loadCatalog, parseGeoJsonFile, projectElementLayers, readBimDownGeometry, readFeatureCollection, resolvedLayers, sniffIfc, stringifyFeatureCollection, typeParamFields, typeValues, writeBimDownGeometry, writeFeatureCollection };
|