@ifc-lite/create 2.7.0 → 2.9.2

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.
Files changed (171) hide show
  1. package/README.md +7 -0
  2. package/dist/ifc-creator-alignment.d.ts +30 -0
  3. package/dist/ifc-creator-alignment.d.ts.map +1 -0
  4. package/dist/ifc-creator-alignment.js +174 -0
  5. package/dist/ifc-creator-alignment.js.map +1 -0
  6. package/dist/ifc-creator-header.d.ts +2 -0
  7. package/dist/ifc-creator-header.d.ts.map +1 -0
  8. package/dist/ifc-creator-header.js +22 -0
  9. package/dist/ifc-creator-header.js.map +1 -0
  10. package/dist/ifc-creator-math.d.ts +15 -5
  11. package/dist/ifc-creator-math.d.ts.map +1 -1
  12. package/dist/ifc-creator-math.js +25 -2
  13. package/dist/ifc-creator-math.js.map +1 -1
  14. package/dist/ifc-creator-relationships.d.ts +43 -0
  15. package/dist/ifc-creator-relationships.d.ts.map +1 -0
  16. package/dist/ifc-creator-relationships.js +38 -0
  17. package/dist/ifc-creator-relationships.js.map +1 -0
  18. package/dist/ifc-creator-styles.d.ts +22 -0
  19. package/dist/ifc-creator-styles.d.ts.map +1 -0
  20. package/dist/ifc-creator-styles.js +50 -0
  21. package/dist/ifc-creator-styles.js.map +1 -0
  22. package/dist/ifc-creator-terrain.d.ts +170 -0
  23. package/dist/ifc-creator-terrain.d.ts.map +1 -0
  24. package/dist/ifc-creator-terrain.js +180 -0
  25. package/dist/ifc-creator-terrain.js.map +1 -0
  26. package/dist/ifc-creator.d.ts +21 -7
  27. package/dist/ifc-creator.d.ts.map +1 -1
  28. package/dist/ifc-creator.js +95 -95
  29. package/dist/ifc-creator.js.map +1 -1
  30. package/dist/in-store/_emit-helpers.d.ts +10 -0
  31. package/dist/in-store/_emit-helpers.d.ts.map +1 -1
  32. package/dist/in-store/_emit-helpers.js +15 -2
  33. package/dist/in-store/_emit-helpers.js.map +1 -1
  34. package/dist/in-store/anchor.d.ts +2 -0
  35. package/dist/in-store/anchor.d.ts.map +1 -1
  36. package/dist/in-store/anchor.js.map +1 -1
  37. package/dist/in-store/apply-style.d.ts +3 -6
  38. package/dist/in-store/apply-style.d.ts.map +1 -1
  39. package/dist/in-store/apply-style.js +3 -77
  40. package/dist/in-store/apply-style.js.map +1 -1
  41. package/dist/in-store/beam.d.ts +2 -0
  42. package/dist/in-store/beam.d.ts.map +1 -1
  43. package/dist/in-store/beam.js +2 -2
  44. package/dist/in-store/beam.js.map +1 -1
  45. package/dist/in-store/column.d.ts +2 -0
  46. package/dist/in-store/column.d.ts.map +1 -1
  47. package/dist/in-store/column.js +4 -2
  48. package/dist/in-store/column.js.map +1 -1
  49. package/dist/in-store/door.d.ts +2 -0
  50. package/dist/in-store/door.d.ts.map +1 -1
  51. package/dist/in-store/door.js +2 -0
  52. package/dist/in-store/door.js.map +1 -1
  53. package/dist/in-store/extract-walls.d.ts +1 -1
  54. package/dist/in-store/extract-walls.d.ts.map +1 -1
  55. package/dist/in-store/extract-walls.js +28 -54
  56. package/dist/in-store/extract-walls.js.map +1 -1
  57. package/dist/in-store/generate-spaces-all.d.ts +6 -2
  58. package/dist/in-store/generate-spaces-all.d.ts.map +1 -1
  59. package/dist/in-store/generate-spaces-all.js +33 -9
  60. package/dist/in-store/generate-spaces-all.js.map +1 -1
  61. package/dist/in-store/generate-spaces.js +1 -1
  62. package/dist/in-store/generate-spaces.js.map +1 -1
  63. package/dist/in-store/member.d.ts +2 -0
  64. package/dist/in-store/member.d.ts.map +1 -1
  65. package/dist/in-store/member.js.map +1 -1
  66. package/dist/in-store/placement-frame.d.ts +8 -0
  67. package/dist/in-store/placement-frame.d.ts.map +1 -1
  68. package/dist/in-store/placement-frame.js.map +1 -1
  69. package/dist/in-store/plate.d.ts +4 -0
  70. package/dist/in-store/plate.d.ts.map +1 -1
  71. package/dist/in-store/plate.js +4 -0
  72. package/dist/in-store/plate.js.map +1 -1
  73. package/dist/in-store/resolve-anchor.d.ts +4 -2
  74. package/dist/in-store/resolve-anchor.d.ts.map +1 -1
  75. package/dist/in-store/resolve-anchor.js +79 -92
  76. package/dist/in-store/resolve-anchor.js.map +1 -1
  77. package/dist/in-store/resolve-source.d.ts +2 -1
  78. package/dist/in-store/resolve-source.d.ts.map +1 -1
  79. package/dist/in-store/resolve-source.js +49 -49
  80. package/dist/in-store/resolve-source.js.map +1 -1
  81. package/dist/in-store/roof.d.ts +4 -0
  82. package/dist/in-store/roof.d.ts.map +1 -1
  83. package/dist/in-store/roof.js +4 -0
  84. package/dist/in-store/roof.js.map +1 -1
  85. package/dist/in-store/slab.d.ts +4 -0
  86. package/dist/in-store/slab.d.ts.map +1 -1
  87. package/dist/in-store/slab.js +6 -2
  88. package/dist/in-store/slab.js.map +1 -1
  89. package/dist/in-store/space.d.ts +4 -0
  90. package/dist/in-store/space.d.ts.map +1 -1
  91. package/dist/in-store/space.js +6 -2
  92. package/dist/in-store/space.js.map +1 -1
  93. package/dist/in-store/spatial-children.d.ts +52 -0
  94. package/dist/in-store/spatial-children.d.ts.map +1 -0
  95. package/dist/in-store/spatial-children.js +112 -0
  96. package/dist/in-store/spatial-children.js.map +1 -0
  97. package/dist/in-store/structural-action.d.ts +85 -0
  98. package/dist/in-store/structural-action.d.ts.map +1 -0
  99. package/dist/in-store/structural-action.js +83 -0
  100. package/dist/in-store/structural-action.js.map +1 -0
  101. package/dist/in-store/structural-analysis-model.d.ts +49 -0
  102. package/dist/in-store/structural-analysis-model.d.ts.map +1 -0
  103. package/dist/in-store/structural-analysis-model.js +29 -0
  104. package/dist/in-store/structural-analysis-model.js.map +1 -0
  105. package/dist/in-store/structural-curve-member.d.ts +90 -0
  106. package/dist/in-store/structural-curve-member.d.ts.map +1 -0
  107. package/dist/in-store/structural-curve-member.js +83 -0
  108. package/dist/in-store/structural-curve-member.js.map +1 -0
  109. package/dist/in-store/structural-load-group.d.ts +61 -0
  110. package/dist/in-store/structural-load-group.d.ts.map +1 -0
  111. package/dist/in-store/structural-load-group.js +38 -0
  112. package/dist/in-store/structural-load-group.js.map +1 -0
  113. package/dist/in-store/structural-point-connection.d.ts +75 -0
  114. package/dist/in-store/structural-point-connection.d.ts.map +1 -0
  115. package/dist/in-store/structural-point-connection.js +41 -0
  116. package/dist/in-store/structural-point-connection.js.map +1 -0
  117. package/dist/in-store/structural-relationships.d.ts +47 -0
  118. package/dist/in-store/structural-relationships.d.ts.map +1 -0
  119. package/dist/in-store/structural-relationships.js +85 -0
  120. package/dist/in-store/structural-relationships.js.map +1 -0
  121. package/dist/in-store/style-entity-reader.d.ts +14 -0
  122. package/dist/in-store/style-entity-reader.d.ts.map +1 -0
  123. package/dist/in-store/style-entity-reader.js +58 -0
  124. package/dist/in-store/style-entity-reader.js.map +1 -0
  125. package/dist/in-store/wall.d.ts +2 -0
  126. package/dist/in-store/wall.d.ts.map +1 -1
  127. package/dist/in-store/wall.js +2 -2
  128. package/dist/in-store/wall.js.map +1 -1
  129. package/dist/in-store/window.d.ts +2 -0
  130. package/dist/in-store/window.d.ts.map +1 -1
  131. package/dist/in-store/window.js +2 -0
  132. package/dist/in-store/window.js.map +1 -1
  133. package/dist/index.d.ts +14 -0
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +13 -0
  136. package/dist/index.js.map +1 -1
  137. package/dist/landxml/alignment-mapping.d.ts +98 -0
  138. package/dist/landxml/alignment-mapping.d.ts.map +1 -0
  139. package/dist/landxml/alignment-mapping.js +282 -0
  140. package/dist/landxml/alignment-mapping.js.map +1 -0
  141. package/dist/landxml/alignment-record.d.ts +18 -0
  142. package/dist/landxml/alignment-record.d.ts.map +1 -0
  143. package/dist/landxml/alignment-record.js +63 -0
  144. package/dist/landxml/alignment-record.js.map +1 -0
  145. package/dist/landxml/coordinate-plausibility.d.ts +54 -0
  146. package/dist/landxml/coordinate-plausibility.d.ts.map +1 -0
  147. package/dist/landxml/coordinate-plausibility.js +59 -0
  148. package/dist/landxml/coordinate-plausibility.js.map +1 -0
  149. package/dist/landxml/landxml-to-ifc.d.ts +45 -0
  150. package/dist/landxml/landxml-to-ifc.d.ts.map +1 -0
  151. package/dist/landxml/landxml-to-ifc.js +197 -0
  152. package/dist/landxml/landxml-to-ifc.js.map +1 -0
  153. package/dist/landxml/refusals.d.ts +41 -0
  154. package/dist/landxml/refusals.d.ts.map +1 -0
  155. package/dist/landxml/refusals.js +118 -0
  156. package/dist/landxml/refusals.js.map +1 -0
  157. package/dist/landxml/result-types.d.ts +73 -0
  158. package/dist/landxml/result-types.d.ts.map +1 -0
  159. package/dist/landxml/result-types.js +5 -0
  160. package/dist/landxml/result-types.js.map +1 -0
  161. package/dist/landxml/source-types.d.ts +169 -0
  162. package/dist/landxml/source-types.d.ts.map +1 -0
  163. package/dist/landxml/source-types.js +5 -0
  164. package/dist/landxml/source-types.js.map +1 -0
  165. package/dist/landxml/writers.d.ts +31 -0
  166. package/dist/landxml/writers.d.ts.map +1 -0
  167. package/dist/landxml/writers.js +143 -0
  168. package/dist/landxml/writers.js.map +1 -0
  169. package/dist/types.d.ts +7 -0
  170. package/dist/types.d.ts.map +1 -1
  171. package/package.json +6 -6
package/README.md CHANGED
@@ -29,6 +29,13 @@ const { content } = creator.toIfc(); // IFC STEP text
29
29
  - Property sets, element quantities, materials, and colors
30
30
  - 4D scheduling entities: IfcWorkSchedule, IfcTask, IfcRelSequence
31
31
  - In-store builders (`addWallToStore`, `addSlabToStore`, ...) that emit elements into an existing parsed model
32
+ - `resolveSpatialAnchor(store, storeyId, view)` reads the live mutation view when
33
+ authoring into an edited model. Pass the same view as the `StoreEditor` so a
34
+ created storey or placement, and deletions or retypes of source anchors, are
35
+ reflected before an element is emitted. Omitting `view` reads the parsed model.
36
+ - `applyStylesInStore` reads styled items and representation chains from the
37
+ editor's live overlay, so a deleted style can be replaced and an authored
38
+ style is found before adding another one to the same representation item.
32
39
  - Loaded-model cost builders (`addCostScheduleToStore`, `addCostItemToStore`, `addCostValueToStore`,
33
40
  `addCostQuantityToStore`) plus relationship helpers for nesting, schedule/object assignment, value lists,
34
41
  and safe removal. They require a `CostAnchor` for schema/owner-history/GUID allocation, accept existing
@@ -0,0 +1,30 @@
1
+ import { type HorizontalSegment } from './landxml/alignment-mapping.js';
2
+ /** The creator hooks this emitter needs. */
3
+ export interface AlignmentContext {
4
+ emit: (type: string, attrs: string) => number;
5
+ newGlobalId: () => string;
6
+ ownerRef: string;
7
+ /** `#<id>` of the `'Axis'` representation subcontext. */
8
+ axisContextRef: string;
9
+ /** `#<id>` of the world placement the alignment hangs from. */
10
+ placementRef: string;
11
+ }
12
+ export interface AlignmentParams {
13
+ Name: string;
14
+ GlobalId?: string;
15
+ /** Station at distance 0, metres — written to the start referent's `Pset_Stationing`. */
16
+ StartStation: number;
17
+ Segments: readonly HorizontalSegment[];
18
+ /** Deterministic GlobalId seed for this alignment's owned entities. */
19
+ guidFor?: (role: string) => string;
20
+ }
21
+ export interface AlignmentResult {
22
+ alignmentId: number;
23
+ horizontalId: number;
24
+ compositeCurveId: number;
25
+ /** `IfcAlignmentSegment` ids in order, including the terminating one. */
26
+ segmentIds: number[];
27
+ referentId: number;
28
+ }
29
+ export declare function emitAlignment(params: AlignmentParams, ctx: AlignmentContext): AlignmentResult;
30
+ //# sourceMappingURL=ifc-creator-alignment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ifc-creator-alignment.d.ts","sourceRoot":"","sources":["../src/ifc-creator-alignment.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAkC,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAExG,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,WAAW,EAAE,MAAM,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,cAAc,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yFAAyF;IACzF,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACvC,uEAAuE;IACvE,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AA6HD,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,gBAAgB,GAAG,eAAe,CA6D7F"}
@@ -0,0 +1,174 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+ /**
5
+ * `IfcAlignment` emitter — horizontal layout only (mapping spec §11).
6
+ *
7
+ * Writes BOTH halves IFC 4.3 defines for an alignment: the semantic layout
8
+ * (`IfcAlignmentHorizontal` nesting `IfcAlignmentSegment`s) and the geometry
9
+ * (`IfcCompositeCurve` of `IfcCurveSegment`s). The structure mirrors what
10
+ * IfcOpenShell 0.8.5's `alignment` API writes for the same input, and each
11
+ * `IfcCurveSegment` follows its `_map_alignment_horizontal_segment` exactly —
12
+ * so the geometry is the one a consumer would derive from the semantics.
13
+ *
14
+ * Parameters arrive already mapped (`landxml/alignment-mapping.ts`): metres,
15
+ * radians counter-clockwise from +X, radii positive for a counter-clockwise
16
+ * turn and `0` for infinite.
17
+ */
18
+ import { esc, num } from './ifc-creator-math.js';
19
+ import { ALIGNMENT_POSITION_TOLERANCE_M } from './landxml/alignment-mapping.js';
20
+ /**
21
+ * Direction and curvature equality for the transition code use the
22
+ * `numpy.allclose` defaults, as IfcOpenShell's
23
+ * `get_curve_segment_transition_code` does. Position does NOT use its 1 mm:
24
+ * authored LandXML joins reproduce only to a few millimetres (lengths and
25
+ * radii are rounded independently of the coordinates), so 1 mm would mark
26
+ * an ordinary join `.DISCONTINUOUS.` in mid-curve, which
27
+ * `IfcCompositeCurve.CurveContinuous` forbids for an open curve (exactly one,
28
+ * the last). Joins are compared at the mapping's own tolerance instead, and
29
+ * a real gap beyond it is refused before anything is written (#5370 review).
30
+ */
31
+ const POSITION_ATOL = ALIGNMENT_POSITION_TOLERANCE_M;
32
+ const allclose = (a, b) => Math.abs(a - b) <= 1e-8 + 1e-5 * Math.abs(b);
33
+ function transitionCode(segment, next) {
34
+ const samePosition = Math.hypot(segment.end[0] - next.start[0], segment.end[1] - next.start[1]) <= POSITION_ATOL;
35
+ if (!samePosition)
36
+ return '.DISCONTINUOUS.';
37
+ const sameGradient = allclose(Math.cos(segment.endDirection), Math.cos(next.direction))
38
+ && allclose(Math.sin(segment.endDirection), Math.sin(next.direction));
39
+ if (!sameGradient)
40
+ return '.CONTINUOUS.';
41
+ return allclose(segment.endCurvature, next.startCurvature) ? '.CONTSAMEGRADIENTSAMECURVATURE.' : '.CONTSAMEGRADIENT.';
42
+ }
43
+ function point2d(ctx, [x, y]) {
44
+ return ctx.emit('IFCCARTESIANPOINT', `(${num(x)},${num(y)})`);
45
+ }
46
+ function placement2d(ctx, at, direction) {
47
+ const location = point2d(ctx, at);
48
+ const ref = ctx.emit('IFCDIRECTION', `(${num(Math.cos(direction))},${num(Math.sin(direction))})`);
49
+ return ctx.emit('IFCAXIS2PLACEMENT2D', `#${location},#${ref}`);
50
+ }
51
+ /** A parent-curve `Position` at the origin along +X, as IfcOpenShell writes it. */
52
+ function originPlacement(ctx) {
53
+ return placement2d(ctx, [0, 0], 0);
54
+ }
55
+ function unitLine(ctx) {
56
+ const origin = point2d(ctx, [0, 0]);
57
+ const dir = ctx.emit('IFCDIRECTION', '(1.,0.)');
58
+ const vector = ctx.emit('IFCVECTOR', `#${dir},1.`);
59
+ return ctx.emit('IFCLINE', `#${origin},#${vector}`);
60
+ }
61
+ /**
62
+ * `IfcCurveSegment` for one horizontal segment — IfcOpenShell's mapping.
63
+ *
64
+ * - LINE: `IfcLine` at the origin; `SegmentLength = L`.
65
+ * - CIRCULARARC: `IfcCircle` of radius `|R|`; `SegmentLength = L · sign(R)` —
66
+ * a negative length traverses the circle clockwise.
67
+ * - CLOTHOID: `IfcClothoid` with `A = L / sqrt(|f|) · sign(f)`, where
68
+ * `f = L/R_end − L/R_start`, and a `SegmentStart` offset so a spiral that
69
+ * does not begin at infinite radius starts at the right point on the curve.
70
+ */
71
+ function curveSegment(ctx, segment, transition) {
72
+ const placement = placement2d(ctx, segment.start, segment.direction);
73
+ const L = segment.length;
74
+ let parent;
75
+ let segmentStart = 0;
76
+ let segmentLength = L;
77
+ if (segment.type === 'LINE') {
78
+ parent = unitLine(ctx);
79
+ }
80
+ else if (segment.type === 'CIRCULARARC') {
81
+ parent = ctx.emit('IFCCIRCLE', `#${originPlacement(ctx)},${num(Math.abs(segment.startRadius))}`);
82
+ segmentLength = L * Math.sign(segment.startRadius);
83
+ }
84
+ else {
85
+ const r0 = segment.startRadius;
86
+ const r1 = segment.endRadius;
87
+ const f = (r1 === 0 ? 0 : L / r1) - (r0 === 0 ? 0 : L / r0);
88
+ const A = (L / Math.sqrt(Math.abs(f))) * Math.sign(f);
89
+ parent = ctx.emit('IFCCLOTHOID', `#${originPlacement(ctx)},${num(A)}`);
90
+ if ((Math.abs(r0) < Math.abs(r1) && r0 !== 0) || r1 === 0) {
91
+ segmentStart = -L - (r1 !== 0 ? (L * r0) / (r1 - r0) : 0);
92
+ }
93
+ else {
94
+ segmentStart = r0 !== 0 ? (L * r1) / (r0 - r1) : 0;
95
+ }
96
+ }
97
+ return ctx.emit('IFCCURVESEGMENT', `${transition},#${placement},IFCLENGTHMEASURE(${num(segmentStart)}),IFCLENGTHMEASURE(${num(segmentLength)}),#${parent}`);
98
+ }
99
+ function designParameters(ctx, segment) {
100
+ return ctx.emit('IFCALIGNMENTHORIZONTALSEGMENT', `$,$,#${point2d(ctx, segment.start)},${num(segment.direction)},${num(segment.startRadius)},`
101
+ + `${num(segment.endRadius)},${num(segment.length)},$,.${segment.type}.`);
102
+ }
103
+ /**
104
+ * The zero-length `LINE` IFC 4.3 requires at the end of every layout, placed at
105
+ * the alignment's end along its end tangent.
106
+ */
107
+ function terminator(last) {
108
+ return {
109
+ sourceId: `${last.sourceId}:end`,
110
+ type: 'LINE',
111
+ start: last.end,
112
+ direction: last.endDirection,
113
+ startRadius: 0,
114
+ endRadius: 0,
115
+ length: 0,
116
+ end: last.end,
117
+ endDirection: last.endDirection,
118
+ startCurvature: 0,
119
+ endCurvature: 0,
120
+ };
121
+ }
122
+ /** `0+123.456` — kilometres and metres, the usual stationing label. */
123
+ function stationLabel(station) {
124
+ const sign = station < 0 ? '-' : '';
125
+ const abs = Math.abs(station);
126
+ const km = Math.floor(abs / 1000);
127
+ const m = (abs - km * 1000).toFixed(3).padStart(7, '0');
128
+ return `${sign}${km}+${m}`;
129
+ }
130
+ export function emitAlignment(params, ctx) {
131
+ if (params.Segments.length === 0) {
132
+ throw new Error('addAlignment: Segments is empty — an alignment needs at least one horizontal segment');
133
+ }
134
+ const guid = (role) => params.guidFor?.(role) ?? ctx.newGlobalId();
135
+ const layout = [...params.Segments, terminator(params.Segments[params.Segments.length - 1])];
136
+ params.Segments.slice(1).forEach((next, index) => {
137
+ const previous = params.Segments[index];
138
+ const gap = Math.hypot(previous.end[0] - next.start[0], previous.end[1] - next.start[1]);
139
+ if (gap > POSITION_ATOL) {
140
+ throw new Error(`addAlignment: segment ${index + 2} starts ${gap.toFixed(3)} m from where segment ${index + 1} ends; `
141
+ + 'an open IfcCompositeCurve may be discontinuous only at its last segment');
142
+ }
143
+ });
144
+ // Geometry: one curve segment per layout segment, the last DISCONTINUOUS —
145
+ // `IfcCompositeCurve.CurveContinuous` requires exactly one for an open curve.
146
+ const curveSegments = layout.map((segment, index) => curveSegment(ctx, segment, index === layout.length - 1 ? '.DISCONTINUOUS.' : transitionCode(segment, layout[index + 1])));
147
+ const compositeCurveId = ctx.emit('IFCCOMPOSITECURVE', `(${curveSegments.map((id) => `#${id}`).join(',')}),.F.`);
148
+ const representation = ctx.emit('IFCSHAPEREPRESENTATION', `${ctx.axisContextRef},'Axis','Curve2D',(#${compositeCurveId})`);
149
+ const shape = ctx.emit('IFCPRODUCTDEFINITIONSHAPE', `$,$,(#${representation})`);
150
+ const alignmentId = ctx.emit('IFCALIGNMENT', `'${params.GlobalId ?? guid('alignment')}',${ctx.ownerRef},'${esc(params.Name)}',$,$,${ctx.placementRef},#${shape},$`);
151
+ // Semantics: horizontal layout nested under the alignment, segments nested
152
+ // in order under the layout.
153
+ const horizontalId = ctx.emit('IFCALIGNMENTHORIZONTAL', `'${guid('horizontal')}',${ctx.ownerRef},$,$,$,$,$`);
154
+ ctx.emit('IFCRELNESTS', `'${guid('nests:layouts')}',${ctx.ownerRef},$,$,#${alignmentId},(#${horizontalId})`);
155
+ const segmentIds = layout.map((segment, index) => ctx.emit('IFCALIGNMENTSEGMENT', `'${guid(`segment:${index}`)}',${ctx.ownerRef},$,$,$,$,$,#${designParameters(ctx, segment)}`));
156
+ ctx.emit('IFCRELNESTS', `'${guid('nests:segments')}',${ctx.ownerRef},$,$,#${horizontalId},(${segmentIds.map((id) => `#${id}`).join(',')})`);
157
+ // Stationing: an IfcReferent at distance 0 along the alignment's own curve.
158
+ const first = params.Segments[0];
159
+ const along = ctx.emit('IFCPOINTBYDISTANCEEXPRESSION', `IFCLENGTHMEASURE(0.),$,$,$,#${compositeCurveId}`);
160
+ const linear = ctx.emit('IFCAXIS2PLACEMENTLINEAR', `#${along},$,$`);
161
+ const at = ctx.emit('IFCCARTESIANPOINT', `(${num(first.start[0])},${num(first.start[1])},0.)`);
162
+ const up = ctx.emit('IFCDIRECTION', '(0.,0.,1.)');
163
+ const ahead = ctx.emit('IFCDIRECTION', `(${num(Math.cos(first.direction))},${num(Math.sin(first.direction))},0.)`);
164
+ const cartesian = ctx.emit('IFCAXIS2PLACEMENT3D', `#${at},#${up},#${ahead}`);
165
+ const placement = ctx.emit('IFCLINEARPLACEMENT', `$,#${linear},#${cartesian}`);
166
+ const referentId = ctx.emit('IFCREFERENT', `'${guid('referent:start')}',${ctx.ownerRef},'${stationLabel(params.StartStation)}',$,$,#${placement},$,.STATION.`);
167
+ const station = ctx.emit('IFCPROPERTYSINGLEVALUE', `'Station',$,IFCLENGTHMEASURE(${num(params.StartStation)}),$`);
168
+ const pset = ctx.emit('IFCPROPERTYSET', `'${guid('pset:stationing')}',${ctx.ownerRef},'Pset_Stationing',$,(#${station})`);
169
+ ctx.emit('IFCRELDEFINESBYPROPERTIES', `'${guid('rel:stationing')}',${ctx.ownerRef},$,$,(#${referentId}),#${pset}`);
170
+ ctx.emit('IFCRELNESTS', `'${guid('nests:referents')}',${ctx.ownerRef},$,$,#${alignmentId},(#${referentId})`);
171
+ ctx.emit('IFCRELPOSITIONS', `'${guid('positions')}',${ctx.ownerRef},$,$,#${referentId},(#${alignmentId})`);
172
+ return { alignmentId, horizontalId, compositeCurveId, segmentIds, referentId };
173
+ }
174
+ //# sourceMappingURL=ifc-creator-alignment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ifc-creator-alignment.js","sourceRoot":"","sources":["../src/ifc-creator-alignment.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,8BAA8B,EAA0B,MAAM,gCAAgC,CAAC;AAgCxG;;;;;;;;;;GAUG;AACH,MAAM,aAAa,GAAG,8BAA8B,CAAC;AACrD,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,CAAS,EAAW,EAAE,CA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GAAG,CAAC,QAAQ,0BAA0B,OAAO,GAAG,CAAC,CAAC;IAC1H,GAAG,CAAC,IAAI,CAAC,2BAA2B,EAAE,IAAI,IAAI,CAAC,gBAAgB,CAAC,KAAK,GAAG,CAAC,QAAQ,UAAU,UAAU,MAAM,IAAI,EAAE,CAAC,CAAC;IACnH,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,IAAI,CAAC,iBAAiB,CAAC,KAAK,GAAG,CAAC,QAAQ,SAAS,WAAW,MAAM,UAAU,GAAG,CAAC,CAAC;IAC7G,GAAG,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,GAAG,CAAC,QAAQ,SAAS,UAAU,MAAM,WAAW,GAAG,CAAC,CAAC;IAE3G,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AACjF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function buildStepHeader(nowMs: number, author: string, organization: string, schema: string): string;
2
+ //# sourceMappingURL=ifc-creator-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ifc-creator-header.d.ts","sourceRoot":"","sources":["../src/ifc-creator-header.ts"],"names":[],"mappings":"AAYA,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAW3G"}
@@ -0,0 +1,22 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+ /**
5
+ * The STEP `HEADER` section `IfcCreator.toIfc()` writes. Split out of
6
+ * `ifc-creator.ts` alongside the other emitter modules; it is a pure function
7
+ * of the creation instant, the author fields and the schema tag.
8
+ */
9
+ import { esc } from './ifc-creator-math.js';
10
+ export function buildStepHeader(nowMs, author, organization, schema) {
11
+ // ISO 8601 time_stamp: keep '-'/':', drop only milliseconds and the 'Z'.
12
+ const now = new Date(nowMs).toISOString().replace(/\.\d{3}Z$/, '');
13
+ const app = 'ifc-lite';
14
+ return `ISO-10303-21;
15
+ HEADER;
16
+ FILE_DESCRIPTION(('${esc('Created by ifc-lite')}'),'2;1');
17
+ FILE_NAME('created.ifc','${now}',('${esc(author)}'),('${esc(organization)}'),'${app}','${app}','');
18
+ FILE_SCHEMA(('${schema}'));
19
+ ENDSEC;
20
+ `;
21
+ }
22
+ //# sourceMappingURL=ifc-creator-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ifc-creator-header.js","sourceRoot":"","sources":["../src/ifc-creator-header.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;GAIG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,MAAc,EAAE,YAAoB,EAAE,MAAc;IACjG,yEAAyE;IACzE,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACnE,MAAM,GAAG,GAAG,UAAU,CAAC;IACvB,OAAO;;qBAEY,GAAG,CAAC,qBAAqB,CAAC;2BACpB,GAAG,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,YAAY,CAAC,OAAO,GAAG,MAAM,GAAG;gBAC5E,MAAM;;CAErB,CAAC;AACF,CAAC"}
@@ -1,13 +1,23 @@
1
- /**
2
- * Pure utility functions and constants used by IfcCreator.
3
- * These have zero coupling to class state — they take inputs and return outputs.
4
- */
5
1
  import type { Point3D, PropertyDef, QuantityDef } from './types.js';
6
2
  /** Escape a string for STEP format */
7
3
  export declare function esc(str: string): string;
8
4
  /** Format a STEP line: #ID=TYPE(args); */
9
5
  export declare function stepLine(id: number, type: string, args: string): string;
10
- /** Serialize a number in STEP format (always with decimal point, no exponent notation) */
6
+ /**
7
+ * Serialize a number as an ISO 10303-21 REAL literal (always with a decimal
8
+ * point in the mantissa).
9
+ *
10
+ * JavaScript's own exponent form (`1e-7`, `1e+21`) has no decimal point, so
11
+ * it is not a legal `real_literal`. Small magnitudes are written as fixed
12
+ * decimal (`toFixed(10)`, which caps precision at ten places, a deliberate
13
+ * trade kept as is). `toFixed` itself switches to exponent form once
14
+ * |v| >= 1e21 (ECMA-262), so those values go through `@ifc-lite/data`'s
15
+ * `formatStepReal`, which writes the STEP exponent form with a mantissa
16
+ * point (`1.E+21`) — the same rule `@ifc-lite/export` uses (#5195).
17
+ *
18
+ * NaN and Infinity have no STEP REAL spelling at all, so they throw rather
19
+ * than reach the file as a `NaN.`/`Infinity.` token.
20
+ */
11
21
  export declare function num(v: number): string;
12
22
  /** Vector length */
13
23
  export declare function vecLen(v: Point3D): number;
@@ -1 +1 @@
1
- {"version":3,"file":"ifc-creator-math.d.ts","sourceRoot":"","sources":["../src/ifc-creator-math.ts"],"names":[],"mappings":"AAIA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAMpE,sCAAsC;AACtC,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvC;AAED,0CAA0C;AAC1C,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED,0FAA0F;AAC1F,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAKrC;AAED,oBAAoB;AACpB,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAEzC;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,aAG5B,CAAC;AAEH,2FAA2F;AAC3F,wBAAgB,OAAO,CAAC,CAAC,EAAE,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SAAS,GAAG,IAAI,GAAG,MAAM,CAE5D;AAED,sDAAsD;AACtD,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAE7D;AAED,0DAA0D;AAC1D,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAE5D;AAED,sDAAsD;AACtD,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAE3D;AAED,sEAAsE;AACtE,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,CAE7C;AAED,kEAAkE;AAClE,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,CAI5D;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAgBhE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAY3D"}
@@ -1,6 +1,11 @@
1
1
  /* This Source Code Form is subject to the terms of the Mozilla Public
2
2
  * License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+ /**
5
+ * Pure utility functions and constants used by IfcCreator.
6
+ * These have zero coupling to class state — they take inputs and return outputs.
7
+ */
8
+ import { formatStepReal } from '@ifc-lite/data';
4
9
  // ============================================================================
5
10
  // Internal helpers
6
11
  // ============================================================================
@@ -12,9 +17,27 @@ export function esc(str) {
12
17
  export function stepLine(id, type, args) {
13
18
  return `#${id}=${type}(${args});`;
14
19
  }
15
- /** Serialize a number in STEP format (always with decimal point, no exponent notation) */
20
+ /**
21
+ * Serialize a number as an ISO 10303-21 REAL literal (always with a decimal
22
+ * point in the mantissa).
23
+ *
24
+ * JavaScript's own exponent form (`1e-7`, `1e+21`) has no decimal point, so
25
+ * it is not a legal `real_literal`. Small magnitudes are written as fixed
26
+ * decimal (`toFixed(10)`, which caps precision at ten places, a deliberate
27
+ * trade kept as is). `toFixed` itself switches to exponent form once
28
+ * |v| >= 1e21 (ECMA-262), so those values go through `@ifc-lite/data`'s
29
+ * `formatStepReal`, which writes the STEP exponent form with a mantissa
30
+ * point (`1.E+21`) — the same rule `@ifc-lite/export` uses (#5195).
31
+ *
32
+ * NaN and Infinity have no STEP REAL spelling at all, so they throw rather
33
+ * than reach the file as a `NaN.`/`Infinity.` token.
34
+ */
16
35
  export function num(v) {
17
- // Exponent notation (e.g. 1e-7) is not valid STEP — use fixed decimal
36
+ if (!Number.isFinite(v)) {
37
+ throw new Error(`num: ${v} is not a finite number and cannot be written as a STEP REAL`);
38
+ }
39
+ if (Math.abs(v) >= 1e21)
40
+ return formatStepReal(v);
18
41
  const s = v.toString();
19
42
  if (s.includes('e') || s.includes('E'))
20
43
  return v.toFixed(10).replace(/0+$/, '0');
@@ -1 +1 @@
1
- {"version":3,"file":"ifc-creator-math.js","sourceRoot":"","sources":["../src/ifc-creator-math.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAS/D,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,sCAAsC;AACtC,MAAM,UAAU,GAAG,CAAC,GAAW;IAC7B,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,QAAQ,CAAC,EAAU,EAAE,IAAY,EAAE,IAAY;IAC7D,OAAO,IAAI,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC;AACpC,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,GAAG,CAAC,CAAS;IAC3B,sEAAsE;IACtE,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;IACvB,IAAI,CAAC,CAAC,QAAQ,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IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACjF,OAAO,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,cAAc,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;IAC/F,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,SAAS,EAAE,CAAC;QAC7B,yEAAyE;QACzE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC;QAC1E,OAAO,GAAG,QAAQ,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;IAC/C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAgB;IACjD,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,mBAAmB,CAAC;QACzB,KAAK,iBAAiB,CAAC;QACvB,KAAK,mBAAmB,CAAC;QACzB,KAAK,mBAAmB;YACtB,OAAO,KAAK,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,KAAK,kBAAkB;YACrB,OAAO,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC;YACE,OAAO,KAAK,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;IACjC,CAAC;AACH,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The `IfcRel*` rows `IfcCreator` writes once, at `toIfc()`.
3
+ *
4
+ * Split out of `ifc-creator.ts` for the same reason as the other emitter
5
+ * modules: this is pure STEP assembly over collections the creator already
6
+ * holds, and it needs nothing from the class but the `emit` hook.
7
+ */
8
+ /** The creator hooks these emitters need. */
9
+ export interface RelationshipContext {
10
+ emit: (type: string, attrs: string) => number;
11
+ newGlobalId: () => string;
12
+ /** `#<id>` of the shared `IfcOwnerHistory`. */
13
+ ownerRef: string;
14
+ }
15
+ export interface SpatialStructure extends RelationshipContext {
16
+ projectId: number;
17
+ siteId: number;
18
+ buildingId: number;
19
+ storeyIds: readonly number[];
20
+ storeyElements: ReadonlyMap<number, readonly number[]>;
21
+ /**
22
+ * Products contained in the site rather than a storey — terrain surfaces and
23
+ * survey annotations, which have no storey to belong to.
24
+ */
25
+ siteElements: readonly number[];
26
+ /**
27
+ * Products aggregated by the project directly — `IfcAlignment`, which IFC 4.3
28
+ * relates to the project rather than containing it in a spatial element.
29
+ */
30
+ projectElements?: readonly number[];
31
+ }
32
+ export declare function emitRelAggregates(relatingId: number, relatedIds: readonly number[], ctx: RelationshipContext): number;
33
+ export declare function emitRelContainedInSpatialStructure(structureId: number, elementIds: readonly number[], ctx: RelationshipContext): number;
34
+ export declare function emitRelFillsElement(openingId: number, fillingId: number, ctx: RelationshipContext): number;
35
+ /**
36
+ * Project → site → building → storeys, then each container's contents.
37
+ *
38
+ * An empty collection writes no row at all: `IfcRelAggregates.RelatedObjects`
39
+ * and `IfcRelContainedInSpatialStructure.RelatedElements` are both `SET [1:?]`,
40
+ * so an empty one is invalid rather than merely useless.
41
+ */
42
+ export declare function emitSpatialRelationships(structure: SpatialStructure): void;
43
+ //# sourceMappingURL=ifc-creator-relationships.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ifc-creator-relationships.d.ts","sourceRoot":"","sources":["../src/ifc-creator-relationships.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH,6CAA6C;AAC7C,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,WAAW,EAAE,MAAM,MAAM,CAAC;IAC1B,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAiB,SAAQ,mBAAmB;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IACvD;;;OAGG;IACH,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC;;;OAGG;IACH,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAMD,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,mBAAmB,GAC1E,MAAM,CAER;AAED,wBAAgB,kCAAkC,CAChD,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,mBAAmB,GAC3E,MAAM,CAKR;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,mBAAmB,GAC7D,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI,CAiB1E"}
@@ -0,0 +1,38 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+ function refs(ids) {
5
+ return ids.map((id) => `#${id}`).join(',');
6
+ }
7
+ export function emitRelAggregates(relatingId, relatedIds, ctx) {
8
+ return ctx.emit('IFCRELAGGREGATES', `'${ctx.newGlobalId()}',${ctx.ownerRef},$,$,#${relatingId},(${refs(relatedIds)})`);
9
+ }
10
+ export function emitRelContainedInSpatialStructure(structureId, elementIds, ctx) {
11
+ return ctx.emit('IFCRELCONTAINEDINSPATIALSTRUCTURE', `'${ctx.newGlobalId()}',${ctx.ownerRef},$,$,(${refs(elementIds)}),#${structureId}`);
12
+ }
13
+ export function emitRelFillsElement(openingId, fillingId, ctx) {
14
+ return ctx.emit('IFCRELFILLSELEMENT', `'${ctx.newGlobalId()}',${ctx.ownerRef},$,$,#${openingId},#${fillingId}`);
15
+ }
16
+ /**
17
+ * Project → site → building → storeys, then each container's contents.
18
+ *
19
+ * An empty collection writes no row at all: `IfcRelAggregates.RelatedObjects`
20
+ * and `IfcRelContainedInSpatialStructure.RelatedElements` are both `SET [1:?]`,
21
+ * so an empty one is invalid rather than merely useless.
22
+ */
23
+ export function emitSpatialRelationships(structure) {
24
+ emitRelAggregates(structure.projectId, [structure.siteId, ...(structure.projectElements ?? [])], structure);
25
+ emitRelAggregates(structure.siteId, [structure.buildingId], structure);
26
+ if (structure.storeyIds.length > 0) {
27
+ emitRelAggregates(structure.buildingId, structure.storeyIds, structure);
28
+ }
29
+ for (const [storeyId, elementIds] of structure.storeyElements) {
30
+ if (elementIds.length > 0) {
31
+ emitRelContainedInSpatialStructure(storeyId, elementIds, structure);
32
+ }
33
+ }
34
+ if (structure.siteElements.length > 0) {
35
+ emitRelContainedInSpatialStructure(structure.siteId, structure.siteElements, structure);
36
+ }
37
+ }
38
+ //# sourceMappingURL=ifc-creator-relationships.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ifc-creator-relationships.js","sourceRoot":"","sources":["../src/ifc-creator-relationships.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAoC/D,SAAS,IAAI,CAAC,GAAsB;IAClC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,UAAkB,EAAE,UAA6B,EAAE,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U,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,kCAAkC,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;IAED,IAAI,SAAS,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,kCAAkC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC"}
@@ -0,0 +1,22 @@
1
+ /** The one creator hook these emitters need. */
2
+ export interface StyleContext {
3
+ emit: (type: string, attrs: string) => number;
4
+ }
5
+ /** A per-element colour assignment, as `IfcCreator` records it. */
6
+ export interface ElementColor {
7
+ name: string;
8
+ rgb: [number, number, number];
9
+ }
10
+ /** A named `IfcSurfaceStyle` with the given RGB colour. */
11
+ export declare function emitColorStyle(name: string, rgb: readonly [number, number, number], ctx: StyleContext): number;
12
+ /** The default `IfcSurfaceStyle` — warm concrete grey (RGB 0.75, 0.73, 0.68). */
13
+ export declare function emitDefaultStyle(ctx: StyleContext): number;
14
+ /**
15
+ * Bind a style to every representation item of every element.
16
+ *
17
+ * Identical colours share one `IfcSurfaceStyle`: without the cache, N elements
18
+ * painted the same colour wrote N identical style trees, which is legal but
19
+ * bloats the file and makes a diff between two exports unreadable.
20
+ */
21
+ export declare function emitStyledItems(elementSolids: ReadonlyMap<number, readonly number[]>, elementColors: ReadonlyMap<number, ElementColor>, defaultStyleId: number, ctx: StyleContext): void;
22
+ //# sourceMappingURL=ifc-creator-styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ifc-creator-styles.d.ts","sourceRoot":"","sources":["../src/ifc-creator-styles.ts"],"names":[],"mappings":"AAcA,gDAAgD;AAChD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CAC/C;AAED,mEAAmE;AACnE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,2DAA2D;AAC3D,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,GAAG,MAAM,CAO9G;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAE1D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,EACrD,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,EAChD,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,YAAY,GAChB,IAAI,CAmBN"}
@@ -0,0 +1,50 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+ /**
5
+ * Surface styling for `IfcCreator`: the default grey, named colour styles, and
6
+ * the `IfcStyledItem` rows that bind them to representation items.
7
+ *
8
+ * Split out of `ifc-creator.ts` alongside the other emitter modules — this is
9
+ * pure STEP assembly over maps the creator already holds.
10
+ */
11
+ import { esc, num } from './ifc-creator-math.js';
12
+ /** A named `IfcSurfaceStyle` with the given RGB colour. */
13
+ export function emitColorStyle(name, rgb, ctx) {
14
+ const colourId = ctx.emit('IFCCOLOURRGB', `$,${num(rgb[0])},${num(rgb[1])},${num(rgb[2])}`);
15
+ const renderingId = ctx.emit('IFCSURFACESTYLERENDERING', `#${colourId},0.,$,$,$,$,IFCNORMALISEDRATIOMEASURE(0.5),IFCSPECULAREXPONENT(64.),.NOTDEFINED.`);
16
+ return ctx.emit('IFCSURFACESTYLE', `'${esc(name)}',.BOTH.,(#${renderingId})`);
17
+ }
18
+ /** The default `IfcSurfaceStyle` — warm concrete grey (RGB 0.75, 0.73, 0.68). */
19
+ export function emitDefaultStyle(ctx) {
20
+ return emitColorStyle('Default', [0.75, 0.73, 0.68], ctx);
21
+ }
22
+ /**
23
+ * Bind a style to every representation item of every element.
24
+ *
25
+ * Identical colours share one `IfcSurfaceStyle`: without the cache, N elements
26
+ * painted the same colour wrote N identical style trees, which is legal but
27
+ * bloats the file and makes a diff between two exports unreadable.
28
+ */
29
+ export function emitStyledItems(elementSolids, elementColors, defaultStyleId, ctx) {
30
+ const styleCache = new Map();
31
+ for (const [elementId, solidIds] of elementSolids) {
32
+ const color = elementColors.get(elementId);
33
+ let styleId = defaultStyleId;
34
+ if (color) {
35
+ const key = `${color.name}|${color.rgb.join(',')}`;
36
+ const cached = styleCache.get(key);
37
+ if (cached !== undefined) {
38
+ styleId = cached;
39
+ }
40
+ else {
41
+ styleId = emitColorStyle(color.name, color.rgb, ctx);
42
+ styleCache.set(key, styleId);
43
+ }
44
+ }
45
+ for (const solidId of solidIds) {
46
+ ctx.emit('IFCSTYLEDITEM', `#${solidId},(#${styleId}),$`);
47
+ }
48
+ }
49
+ }
50
+ //# sourceMappingURL=ifc-creator-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ifc-creator-styles.js","sourceRoot":"","sources":["../src/ifc-creator-styles.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;GAMG;AAEH,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAajD,2DAA2D;AAC3D,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,GAAsC,EAAE,GAAiB;IACpG,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,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