@ifc-lite/export 4.14.0 → 5.0.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.
Files changed (200) hide show
  1. package/dist/attribute-slot-types.d.ts.map +1 -1
  2. package/dist/attribute-slot-types.js +3 -1
  3. package/dist/attribute-slot-types.js.map +1 -1
  4. package/dist/effective-index-created-rows.d.ts +3 -0
  5. package/dist/effective-index-created-rows.d.ts.map +1 -1
  6. package/dist/effective-index-created-rows.js +16 -5
  7. package/dist/effective-index-created-rows.js.map +1 -1
  8. package/dist/effective-index.d.ts.map +1 -1
  9. package/dist/effective-index.js +2 -1
  10. package/dist/effective-index.js.map +1 -1
  11. package/dist/georef-closure.d.ts +12 -0
  12. package/dist/georef-closure.d.ts.map +1 -1
  13. package/dist/georef-closure.js +3 -1
  14. package/dist/georef-closure.js.map +1 -1
  15. package/dist/ifc5-exporter.d.ts.map +1 -1
  16. package/dist/ifc5-exporter.js +3 -10
  17. package/dist/ifc5-exporter.js.map +1 -1
  18. package/dist/index.d.ts +4 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +4 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/merged-bake.d.ts +32 -0
  23. package/dist/merged-bake.d.ts.map +1 -0
  24. package/dist/merged-bake.js +120 -0
  25. package/dist/merged-bake.js.map +1 -0
  26. package/dist/merged-context.d.ts +49 -6
  27. package/dist/merged-context.d.ts.map +1 -1
  28. package/dist/merged-context.js +165 -53
  29. package/dist/merged-context.js.map +1 -1
  30. package/dist/merged-exporter.d.ts +7 -14
  31. package/dist/merged-exporter.d.ts.map +1 -1
  32. package/dist/merged-exporter.js +43 -111
  33. package/dist/merged-exporter.js.map +1 -1
  34. package/dist/merged-georef-normalize.d.ts +54 -0
  35. package/dist/merged-georef-normalize.d.ts.map +1 -0
  36. package/dist/merged-georef-normalize.js +260 -0
  37. package/dist/merged-georef-normalize.js.map +1 -0
  38. package/dist/merged-project-contexts.d.ts +12 -0
  39. package/dist/merged-project-contexts.d.ts.map +1 -0
  40. package/dist/merged-project-contexts.js +56 -0
  41. package/dist/merged-project-contexts.js.map +1 -0
  42. package/dist/merged-remap.d.ts +2 -0
  43. package/dist/merged-remap.d.ts.map +1 -1
  44. package/dist/merged-remap.js +10 -0
  45. package/dist/merged-remap.js.map +1 -1
  46. package/dist/merged-subcontext.d.ts +22 -0
  47. package/dist/merged-subcontext.d.ts.map +1 -1
  48. package/dist/merged-subcontext.js +14 -18
  49. package/dist/merged-subcontext.js.map +1 -1
  50. package/dist/schema-conversion-loss-report.d.ts +20 -12
  51. package/dist/schema-conversion-loss-report.d.ts.map +1 -1
  52. package/dist/schema-conversion-loss-report.js +153 -24
  53. package/dist/schema-conversion-loss-report.js.map +1 -1
  54. package/dist/schema-converter-attr-maps.d.ts +51 -0
  55. package/dist/schema-converter-attr-maps.d.ts.map +1 -0
  56. package/dist/schema-converter-attr-maps.js +142 -0
  57. package/dist/schema-converter-attr-maps.js.map +1 -0
  58. package/dist/schema-converter-attr-remap.d.ts.map +1 -1
  59. package/dist/schema-converter-attr-remap.js +5 -1
  60. package/dist/schema-converter-attr-remap.js.map +1 -1
  61. package/dist/schema-converter-document-links.d.ts +23 -0
  62. package/dist/schema-converter-document-links.d.ts.map +1 -0
  63. package/dist/schema-converter-document-links.js +146 -0
  64. package/dist/schema-converter-document-links.js.map +1 -0
  65. package/dist/schema-converter-enums.d.ts +10 -1
  66. package/dist/schema-converter-enums.d.ts.map +1 -1
  67. package/dist/schema-converter-enums.js +27 -4
  68. package/dist/schema-converter-enums.js.map +1 -1
  69. package/dist/schema-converter-ifc4-slots.d.ts +4 -3
  70. package/dist/schema-converter-ifc4-slots.d.ts.map +1 -1
  71. package/dist/schema-converter-ifc4-slots.js +4 -3
  72. package/dist/schema-converter-ifc4-slots.js.map +1 -1
  73. package/dist/schema-converter-renames.d.ts +17 -0
  74. package/dist/schema-converter-renames.d.ts.map +1 -1
  75. package/dist/schema-converter-renames.js +34 -2
  76. package/dist/schema-converter-renames.js.map +1 -1
  77. package/dist/schema-converter-retyped.d.ts +17 -0
  78. package/dist/schema-converter-retyped.d.ts.map +1 -0
  79. package/dist/schema-converter-retyped.js +68 -0
  80. package/dist/schema-converter-retyped.js.map +1 -0
  81. package/dist/schema-converter-structural-axes.d.ts +48 -4
  82. package/dist/schema-converter-structural-axes.d.ts.map +1 -1
  83. package/dist/schema-converter-structural-axes.js +348 -29
  84. package/dist/schema-converter-structural-axes.js.map +1 -1
  85. package/dist/schema-converter-structural-carriers.d.ts +76 -0
  86. package/dist/schema-converter-structural-carriers.d.ts.map +1 -0
  87. package/dist/schema-converter-structural-carriers.js +330 -0
  88. package/dist/schema-converter-structural-carriers.js.map +1 -0
  89. package/dist/schema-converter-structural-diagnostics.d.ts +49 -9
  90. package/dist/schema-converter-structural-diagnostics.d.ts.map +1 -1
  91. package/dist/schema-converter-structural-diagnostics.js +152 -17
  92. package/dist/schema-converter-structural-diagnostics.js.map +1 -1
  93. package/dist/schema-converter-structural-links.d.ts +2 -2
  94. package/dist/schema-converter-structural-links.d.ts.map +1 -1
  95. package/dist/schema-converter-structural-links.js +3 -28
  96. package/dist/schema-converter-structural-links.js.map +1 -1
  97. package/dist/schema-converter-structural-source.d.ts +76 -0
  98. package/dist/schema-converter-structural-source.d.ts.map +1 -0
  99. package/dist/schema-converter-structural-source.js +197 -0
  100. package/dist/schema-converter-structural-source.js.map +1 -0
  101. package/dist/schema-converter-structural-thickness.d.ts +33 -0
  102. package/dist/schema-converter-structural-thickness.d.ts.map +1 -0
  103. package/dist/schema-converter-structural-thickness.js +155 -0
  104. package/dist/schema-converter-structural-thickness.js.map +1 -0
  105. package/dist/schema-converter-structural-varying.d.ts +17 -10
  106. package/dist/schema-converter-structural-varying.d.ts.map +1 -1
  107. package/dist/schema-converter-structural-varying.js +66 -50
  108. package/dist/schema-converter-structural-varying.js.map +1 -1
  109. package/dist/schema-converter-structural.d.ts +2 -2
  110. package/dist/schema-converter-structural.d.ts.map +1 -1
  111. package/dist/schema-converter-structural.js +9 -6
  112. package/dist/schema-converter-structural.js.map +1 -1
  113. package/dist/schema-converter-userdefined-label.d.ts +8 -0
  114. package/dist/schema-converter-userdefined-label.d.ts.map +1 -0
  115. package/dist/schema-converter-userdefined-label.js +60 -0
  116. package/dist/schema-converter-userdefined-label.js.map +1 -0
  117. package/dist/schema-converter-userdefined.d.ts +15 -0
  118. package/dist/schema-converter-userdefined.d.ts.map +1 -0
  119. package/dist/schema-converter-userdefined.js +59 -0
  120. package/dist/schema-converter-userdefined.js.map +1 -0
  121. package/dist/schema-converter-value-forms.d.ts +12 -0
  122. package/dist/schema-converter-value-forms.d.ts.map +1 -0
  123. package/dist/schema-converter-value-forms.js +188 -0
  124. package/dist/schema-converter-value-forms.js.map +1 -0
  125. package/dist/schema-converter.d.ts +2 -4
  126. package/dist/schema-converter.d.ts.map +1 -1
  127. package/dist/schema-converter.js +44 -42
  128. package/dist/schema-converter.js.map +1 -1
  129. package/dist/schema-enum-policy.d.ts +5 -1
  130. package/dist/schema-enum-policy.d.ts.map +1 -1
  131. package/dist/schema-enum-policy.js +21 -1
  132. package/dist/schema-enum-policy.js.map +1 -1
  133. package/dist/schema-value-form-policy.d.ts +129 -0
  134. package/dist/schema-value-form-policy.d.ts.map +1 -0
  135. package/dist/schema-value-form-policy.js +222 -0
  136. package/dist/schema-value-form-policy.js.map +1 -0
  137. package/dist/step-collection.d.ts.map +1 -1
  138. package/dist/step-collection.js +2 -0
  139. package/dist/step-collection.js.map +1 -1
  140. package/dist/step-comment-skip.d.ts +8 -0
  141. package/dist/step-comment-skip.d.ts.map +1 -1
  142. package/dist/step-comment-skip.js +28 -0
  143. package/dist/step-comment-skip.js.map +1 -1
  144. package/dist/step-coordinate-options.d.ts +15 -0
  145. package/dist/step-coordinate-options.d.ts.map +1 -1
  146. package/dist/step-coordinate-options.js +13 -1
  147. package/dist/step-coordinate-options.js.map +1 -1
  148. package/dist/step-export-types.d.ts +2 -1
  149. package/dist/step-export-types.d.ts.map +1 -1
  150. package/dist/step-export-types.js.map +1 -1
  151. package/dist/step-exporter.d.ts +0 -6
  152. package/dist/step-exporter.d.ts.map +1 -1
  153. package/dist/step-exporter.js +9 -6
  154. package/dist/step-exporter.js.map +1 -1
  155. package/dist/step-georeferencing.d.ts +2 -0
  156. package/dist/step-georeferencing.d.ts.map +1 -1
  157. package/dist/step-georeferencing.js +122 -46
  158. package/dist/step-georeferencing.js.map +1 -1
  159. package/dist/step-header.d.ts.map +1 -1
  160. package/dist/step-header.js +1 -0
  161. package/dist/step-header.js.map +1 -1
  162. package/dist/step-internal-pset-ids.js +1 -1
  163. package/dist/step-internal-pset-ids.js.map +1 -1
  164. package/dist/step-map-unit.d.ts +8 -1
  165. package/dist/step-map-unit.d.ts.map +1 -1
  166. package/dist/step-map-unit.js +13 -5
  167. package/dist/step-map-unit.js.map +1 -1
  168. package/dist/step-omission-predicates.d.ts.map +1 -1
  169. package/dist/step-omission-predicates.js +1 -0
  170. package/dist/step-omission-predicates.js.map +1 -1
  171. package/dist/step-overlay-entities.d.ts +0 -35
  172. package/dist/step-overlay-entities.d.ts.map +1 -1
  173. package/dist/step-overlay-entities.js +38 -2
  174. package/dist/step-overlay-entities.js.map +1 -1
  175. package/dist/step-pass-builder.d.ts.map +1 -1
  176. package/dist/step-pass-builder.js +12 -6
  177. package/dist/step-pass-builder.js.map +1 -1
  178. package/dist/step-record-frame.d.ts +5 -3
  179. package/dist/step-record-frame.d.ts.map +1 -1
  180. package/dist/step-record-frame.js +12 -8
  181. package/dist/step-record-frame.js.map +1 -1
  182. package/dist/step-ref-scan.d.ts +7 -0
  183. package/dist/step-ref-scan.d.ts.map +1 -1
  184. package/dist/step-ref-scan.js +24 -3
  185. package/dist/step-ref-scan.js.map +1 -1
  186. package/dist/step-serialization.d.ts +12 -0
  187. package/dist/step-serialization.d.ts.map +1 -1
  188. package/dist/step-serialization.js +15 -0
  189. package/dist/step-serialization.js.map +1 -1
  190. package/dist/step-source-iteration.d.ts.map +1 -1
  191. package/dist/step-source-iteration.js +4 -3
  192. package/dist/step-source-iteration.js.map +1 -1
  193. package/dist/unit-normalize.d.ts.map +1 -1
  194. package/dist/unit-normalize.js +4 -3
  195. package/dist/unit-normalize.js.map +1 -1
  196. package/dist/viewer-georef-scale.d.ts +14 -0
  197. package/dist/viewer-georef-scale.d.ts.map +1 -0
  198. package/dist/viewer-georef-scale.js +20 -0
  199. package/dist/viewer-georef-scale.js.map +1 -0
  200. package/package.json +41 -8
@@ -0,0 +1,260 @@
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
+ * Normalize and georeferencing (#10886). A model normalized into the primary's length unit loses its own project
6
+ * unit, so its georeference must not lean on it:
7
+ *
8
+ * - A coordinate operation always targets a CRS (`TargetCRS` is an IfcCoordinateReferenceSystem in IFC4 and IFC4X3),
9
+ * and its offsets are in that CRS's unit (MapUnit, or HeightUnit for a geographic CRS), so they are left as written.
10
+ * - A CRS with no unit there is read as metres, as the viewer reads it (`@ifc-lite/geo` `map-unit.ts`), and is
11
+ * given the merge's one metre unit ({@link MintedRecords}) so every reader agrees.
12
+ * - A context-to-CRS map conversion's Scale carries project-unit distances into map units. Divide it by the
13
+ * length factor unless keeping it as written preserves the viewer's scale (see {@link viewerAxisScales}).
14
+ * A CRS-to-CRS conversion keeps its Scale because its source unit is unchanged.
15
+ *
16
+ * IFC2X3 spells the same georeference as the `ePSet_MapConversion` and `ePSet_ProjectedCRS` property sets (#10915),
17
+ * and they follow the same rule: the offset properties are left as written, a CRS set without a MapUnit is given a
18
+ * `METRE` one, and the Scale property is chosen as above. Their values come from the parser's own reading, the one
19
+ * the viewer places the model by, so the plan never reads a property value itself.
20
+ */
21
+ import { decodeStepStringLiteral } from '@ifc-lite/encoding';
22
+ import { extractGeoreferenceCandidatesOnDemand } from '@ifc-lite/parser';
23
+ import { COORDINATE_OPERATION_STEP_TYPES, MAP_CONVERSION_STEP_TYPES } from './georef-closure.js';
24
+ import { refsIn } from './merged-project-contexts.js';
25
+ import { decodeEntity, getStepAttr } from './merged-subcontext.js';
26
+ import { slotUnset, stepString } from './schema-converter-structural-source.js';
27
+ import { splitTopLevelStepArguments } from './step-argument-parser.js';
28
+ import { namesAnyRecord } from './step-ref-scan.js';
29
+ import { frameArgs, stepRecordFrame, withFrameArgs } from './step-record-frame.js';
30
+ import { computeNormalizeFactor, toStepRealScaled } from './unit-normalize.js';
31
+ import { viewerAxisScales } from './viewer-georef-scale.js';
32
+ /** Records minted as their references are written, at ids past every source model's. */
33
+ export class MintedRecords {
34
+ nextId;
35
+ lines = [];
36
+ metreRef;
37
+ constructor(nextId) {
38
+ this.nextId = nextId;
39
+ }
40
+ /** Every property gets its own identity, even when its text matches another's. */
41
+ addProperty(text) { return this.add(text); }
42
+ /** A single SI unit can be referenced by multiple coordinate reference systems. */
43
+ useMetreUnit() { return this.metreRef ??= this.add(METRE_UNIT); }
44
+ appendTo(lines) {
45
+ for (const line of this.lines)
46
+ lines.push(line);
47
+ }
48
+ add(text) {
49
+ const ref = `#${this.nextId++}`;
50
+ this.lines.push(`${ref}=${text};`);
51
+ return ref;
52
+ }
53
+ }
54
+ /** Plans a new property for the set, replacing its list entry at `at` or appending one. */
55
+ function listEntry(records, setId, text, at) {
56
+ const record = records.get(setId);
57
+ const entries = record?.kind === 'list' ? record.entries.filter(entry => at === undefined || entry.at !== at) : [];
58
+ records.set(setId, { kind: 'list', attr: PSET_PROPERTIES_ATTR, entries: [...entries, { at, text }] });
59
+ }
60
+ /** 0-based index of the CRS's length unit: `IfcProjectedCRS.MapUnit` (IFC4, IFC4X3), `IfcGeographicCRS.HeightUnit`. */
61
+ const CRS_UNIT_ATTR = { IFCPROJECTEDCRS: 6, IFCGEOGRAPHICCRS: 5 };
62
+ /** 0-based index of `IfcMapConversion.Scale`. */
63
+ const SCALE_ATTR = 7;
64
+ /** 0-based `IfcPropertySet.HasProperties`, `IfcPropertySingleValue.Name`, `.Description` and `.Unit`. */
65
+ const PSET_PROPERTIES_ATTR = 4, PROPERTY_NAME_ATTR = 0, PROPERTY_DESCRIPTION_ATTR = 1, PROPERTY_UNIT_ATTR = 3;
66
+ const METRE_UNIT = 'IFCSIUNIT(*,.LENGTHUNIT.,$,.METRE.)';
67
+ /** The ePSet_MapConversion placement properties, by the names the parser reads (`EPSET_TRANSFORM_PROPERTIES`). */
68
+ const EPSET_PLACEMENT = new Set(['Eastings', 'Northings', 'OrthogonalHeight', 'XAxisAbscissa', 'XAxisOrdinate', 'Scale']);
69
+ // @raw-entity-enumeration-ok MergeExporter uses a reparsed effective STEP snapshot, so these are the merged input's current records
70
+ const idsOf = (dataStore, types) => [...types].flatMap(type => dataStore.entityIndex.byType.get(type) ?? []);
71
+ /** A STEP string slot's decoded text, as the parser decodes it, or '' when it is no string. */
72
+ const label = (raw) => { const text = stepString(raw ?? undefined); return text === null ? '' : decodeStepStringLiteral(text); };
73
+ /** The record type of `id`, a deferred property atom included. */
74
+ // @raw-entity-enumeration-ok MergeExporter uses a reparsed effective STEP snapshot, so these are the merged input's current records
75
+ const typeOf = (dataStore, id) => (dataStore.entityIndex.byId.get(id) ?? dataStore.deferredEntityIndex?.get(id))?.type?.toUpperCase();
76
+ /** The normalize advisory for a model's georeference, or null when it carries none. */
77
+ export function georefNormalizeCaveat(name, dataStore, plan) {
78
+ if (idsOf(dataStore, COORDINATE_OPERATION_STEP_TYPES).length === 0 && !plan?.records.size && !plan?.implicitUnit.length
79
+ && !plan?.scaleLeft.length)
80
+ return null;
81
+ const idsIn = (ids) => `${ids.map(id => `#${id}`).join(', ')} (${ids.length === 1 ? 'an id' : 'ids'} in "${name}")`;
82
+ const unkeptIds = plan?.unkept ?? [], implicitIds = plan?.implicitUnit ?? [], leftIds = plan?.scaleLeft ?? [];
83
+ const unkept = unkeptIds.length === 0 ? '' : unkeptIds.length === 1
84
+ ? ` The viewer cannot show its map conversion ${idsIn(unkeptIds)} at its own scale in the merged unit, so its Scale is written as the IFC specification reads it.`
85
+ : ` The viewer cannot show its map conversions ${idsIn(unkeptIds)} at their own scale in the merged unit, so their Scale is written as the IFC specification reads it.`;
86
+ const implicit = implicitIds.length === 0 ? '' : ` The map unit of ePSet_MapConversion ${idsIn(implicitIds)} stays ` +
87
+ 'implicit, with no ePSet_ProjectedCRS or no MapUnit normalize could write; the viewer reads it as metres.';
88
+ const left = leftIds.length === 0 ? '' : ` Normalize could not rewrite the Scale property of ePSet_MapConversion ` +
89
+ `${idsIn(leftIds)}, so the viewer shows it at another scale in the merged unit.`;
90
+ return `Model "${name}" carries georeferencing, whose offsets normalize leaves in the CRS unit (a CRS without one ` +
91
+ `is written in metres). If the model was georeferenced in its own unit, review the merged georeference.${unkept}${implicit}${left}`;
92
+ }
93
+ /**
94
+ * The Scale that keeps the scale the viewer gives a conversion's geometry once its model is normalized: the divided
95
+ * Scale (the spec reading) as it will be written, else undefined to keep it as written; `unkept` when neither keeps it,
96
+ * and `keepsWritten` when the Scale as written keeps it.
97
+ */
98
+ function chooseScale(conversion, mapUnitScale, modelScale, primaryScale) {
99
+ const alone = viewerAxisScales(conversion, mapUnitScale, modelScale);
100
+ const keeps = (scale) => viewerAxisScales({ ...conversion, scale }, mapUnitScale, primaryScale)
101
+ .every((value, axis) => Math.abs(value - alone[axis]) <= 1e-9 * Math.abs(alone[axis])); // relative: scales can be tiny
102
+ // As written: a value that rounds to within 1e-9 of 1 reads as unset in the viewer.
103
+ const divided = Number(toStepRealScaled((conversion.scale ?? 1) / computeNormalizeFactor(modelScale, primaryScale)));
104
+ const keepsWritten = keeps(conversion.scale);
105
+ if (keeps(divided))
106
+ return { scale: divided, unkept: false, keepsWritten };
107
+ return keepsWritten ? { scale: undefined, unkept: false, keepsWritten } : { scale: divided, unkept: true, keepsWritten };
108
+ }
109
+ /** The {@link GeorefNormalizePlan} of a model in length unit `modelScale` normalized into `primaryScale`. */
110
+ export function planGeorefNormalize(dataStore, minted, modelScale, primaryScale) {
111
+ const records = new Map(), unkept = [], implicitUnit = [], scaleLeft = [];
112
+ for (const id of idsOf(dataStore, COORDINATE_OPERATION_STEP_TYPES))
113
+ records.set(id, { kind: 'keep' });
114
+ for (const [type, attr] of Object.entries(CRS_UNIT_ATTR)) {
115
+ for (const id of idsOf(dataStore, [type])) {
116
+ if (!slotUnset(getStepAttr(dataStore, id, attr) ?? '$'))
117
+ continue;
118
+ records.set(id, { kind: 'metre-unit', attr });
119
+ }
120
+ }
121
+ // @raw-entity-enumeration-ok MergeExporter uses a reparsed effective STEP snapshot
122
+ const hasPropertySets = dataStore.entityIndex.byType.has('IFCPROPERTYSET');
123
+ const candidates = hasPropertySets || idsOf(dataStore, MAP_CONVERSION_STEP_TYPES).length
124
+ ? extractGeoreferenceCandidatesOnDemand(dataStore) : null;
125
+ for (const { conversion, targetCRS } of candidates?.mapConversions ?? []) {
126
+ // @raw-entity-enumeration-ok MergeExporter uses a reparsed effective STEP snapshot
127
+ const source = dataStore.entityIndex.byId.get(conversion.sourceCRS);
128
+ if (source?.type !== 'IFCGEOMETRICREPRESENTATIONCONTEXT')
129
+ continue;
130
+ const choice = chooseScale(conversion, targetCRS?.mapUnitScale, modelScale, primaryScale);
131
+ if (choice.scale !== undefined)
132
+ records.set(conversion.id, { kind: 'edit', attr: SCALE_ATTR, value: toStepRealScaled(choice.scale) });
133
+ if (choice.unkept)
134
+ unkept.push(conversion.id);
135
+ }
136
+ // Only the ePSet the viewer uses has offsets in the map unit and axis and Scale ratios to preserve.
137
+ const epset = candidates?.entities.hasGeoreference ? undefined : candidates?.ePSetMapConversion;
138
+ const plan = { records, minted, unkept, implicitUnit, scaleLeft };
139
+ if (epset?.mapConversion) {
140
+ keepEPSetPlacement(dataStore, epset.mapConversion.id, records);
141
+ planViewerEPSet(dataStore, epset.mapConversion, epset.projectedCRS, plan, modelScale, primaryScale);
142
+ }
143
+ return plan;
144
+ }
145
+ /** Copy placement properties so their originals can be rescaled for any other set that uses them. */
146
+ function keepEPSetPlacement(dataStore, setId, records) {
147
+ const list = getStepAttr(dataStore, setId, PSET_PROPERTIES_ATTR);
148
+ if (list === null)
149
+ return;
150
+ for (const [at, ref] of refsIn(list).entries()) {
151
+ const id = Number(ref.slice(1));
152
+ const name = getStepAttr(dataStore, id, PROPERTY_NAME_ATTR);
153
+ if (name !== null && !EPSET_PLACEMENT.has(label(name)))
154
+ continue;
155
+ const copy = recordBody(decodeEntity(dataStore, id));
156
+ // Copies are emitted directly. Keep the original if it needs reference remapping or schema conversion.
157
+ if (name === null || copy === undefined || namesAnyRecord(copy) || typeOf(dataStore, id) !== 'IFCPROPERTYSINGLEVALUE') {
158
+ records.set(id, { kind: 'keep' });
159
+ }
160
+ else {
161
+ listEntry(records, setId, copy, at);
162
+ }
163
+ }
164
+ }
165
+ /** A record's text from its type name to its closing `)`, as the package's record frame reads it, or undefined. */
166
+ function recordBody(text) {
167
+ if (text === null)
168
+ return undefined;
169
+ const frame = stepRecordFrame(text, { allowMissingSemicolon: true });
170
+ return frame ? text.slice(frame.head.typeStart, frame.close + 1) : undefined;
171
+ }
172
+ /**
173
+ * A set's properties with their names and positions in its list, `editable` when a single value without its own
174
+ * Unit; null when the set's property list cannot be read. A property that cannot be read is passed over, as the
175
+ * parser passes it over.
176
+ */
177
+ function propertiesOf(dataStore, setId) {
178
+ const list = getStepAttr(dataStore, setId, PSET_PROPERTIES_ATTR);
179
+ if (list === null)
180
+ return null;
181
+ const properties = [];
182
+ for (const [at, ref] of refsIn(list).entries()) {
183
+ const id = Number(ref.slice(1)), name = getStepAttr(dataStore, id, PROPERTY_NAME_ATTR);
184
+ if (name === null)
185
+ continue;
186
+ const editable = typeOf(dataStore, id) === 'IFCPROPERTYSINGLEVALUE' && slotUnset(getStepAttr(dataStore, id, PROPERTY_UNIT_ATTR) ?? '$');
187
+ properties.push({ at, name: label(name), description: getStepAttr(dataStore, id, PROPERTY_DESCRIPTION_ATTR) ?? '$', editable });
188
+ }
189
+ return properties;
190
+ }
191
+ /** Plans the ePSet the viewer reads, from the parser's `conversion` and `crs` (whose id is the conversion's own when the model has no ePSet_ProjectedCRS). */
192
+ function planViewerEPSet(dataStore, conversion, crs, plan, modelScale, primaryScale) {
193
+ const { records, unkept, implicitUnit, scaleLeft } = plan;
194
+ // Gives the set a new `name` property of `value` (with the replaced one's Description) in place of the last one so
195
+ // named (the one the parser reads), or appended when it has none. The old record is left as it is, for any other
196
+ // set that lists it too. False when the property is no editable single value, or the set cannot be read, and the set
197
+ // is left as it is.
198
+ const write = (setId, name, value) => {
199
+ const of = propertiesOf(dataStore, setId);
200
+ const last = of?.filter(property => property.name === name).at(-1);
201
+ if (!of || (last !== undefined && !last.editable))
202
+ return false;
203
+ listEntry(records, setId, `IFCPROPERTYSINGLEVALUE('${name}',${last?.description ?? '$'},${value},$)`, last?.at);
204
+ return true;
205
+ };
206
+ const hasCrsSet = crs !== undefined && crs.id !== conversion.id;
207
+ const unitExplicit = hasCrsSet && (crs.mapUnit !== undefined || write(crs.id, 'MapUnit', "IFCLABEL('METRE')"));
208
+ if (!unitExplicit)
209
+ implicitUnit.push(conversion.id);
210
+ const choice = chooseScale(conversion, crs?.mapUnitScale, modelScale, primaryScale);
211
+ if (choice.scale === undefined)
212
+ return;
213
+ if (write(conversion.id, 'Scale', `IFCREAL(${toStepRealScaled(choice.scale)})`)) {
214
+ if (choice.unkept)
215
+ unkept.push(conversion.id);
216
+ }
217
+ else if (!choice.keepsWritten)
218
+ scaleLeft.push(conversion.id);
219
+ }
220
+ /**
221
+ * A georeference record of a normalized model, in output ids, as the output unit needs it; undefined for any other
222
+ * record, which the caller rescales as usual.
223
+ */
224
+ export function normalizeGeorefRecord(text, sourceId, plan) {
225
+ const record = plan?.records.get(sourceId);
226
+ if (!plan || record === undefined)
227
+ return undefined;
228
+ if (record.kind === 'keep')
229
+ return text;
230
+ const { attr } = record;
231
+ return withArgs(text, attr, args => {
232
+ if (record.kind === 'edit') {
233
+ args[attr] = record.value;
234
+ return;
235
+ }
236
+ if (record.kind === 'metre-unit') {
237
+ args[attr] = plan.minted.useMetreUnit();
238
+ return;
239
+ }
240
+ const refs = refsIn(args[attr]);
241
+ for (const { at, text } of record.entries) {
242
+ const ref = plan.minted.addProperty(text);
243
+ if (at === undefined)
244
+ refs.push(ref);
245
+ else
246
+ refs[at] = ref;
247
+ }
248
+ args[attr] = `(${refs.join(',')})`;
249
+ });
250
+ }
251
+ /** `text` with its arguments edited by `edit`, or unchanged when it has no argument at `index`. */
252
+ function withArgs(text, index, edit) {
253
+ const frame = stepRecordFrame(text, { allowMissingSemicolon: true });
254
+ const args = frame && splitTopLevelStepArguments(frameArgs(text, frame));
255
+ if (!frame || !args || args.length <= index)
256
+ return text;
257
+ edit(args);
258
+ return withFrameArgs(text, frame, args.join(','));
259
+ }
260
+ //# sourceMappingURL=merged-georef-normalize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merged-georef-normalize.js","sourceRoot":"","sources":["../src/merged-georef-normalize.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,qCAAqC,EAA4D,MAAM,kBAAkB,CAAC;AACnI,OAAO,EAAE,+BAA+B,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EA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YAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAC1C,IAAI,EAAE,KAAK,SAAS;gBAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;;gBAChC,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,mGAAmG;AACnG,SAAS,QAAQ,CAAC,IAAY,EAAE,KAAa,EAAE,IAA8B;IAC3E,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,CAAC;IACrE,MAAM,IAAI,GAAG,KAAK,IAAI,0BAA0B,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IACzE,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC;IACzD,IAAI,CAAC,IAAI,CAAC,CAAC;IACX,OAAO,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACpD,CAAC"}
@@ -0,0 +1,12 @@
1
+ /** 0-based attribute index of `IfcContext.RepresentationContexts` (IfcProject in IFC2X3 and IFC4, IfcProjectLibrary). */
2
+ export declare const PROJECT_REPRESENTATION_CONTEXTS_ATTR = 7;
3
+ /** The `#N` references in an attribute slot of references (`$` has none); its comments are not read. */
4
+ export declare const refsIn: (slot: string) => string[];
5
+ /**
6
+ * List `contextIds` in the merged project's RepresentationContexts (#10798). A compatible later model's IfcProject
7
+ * folds into the primary's, so a top-level context of it that was kept rather than unified (a different frame or
8
+ * georeference, or a second context its own project listed) belongs to no project otherwise. Only
9
+ * ids written to `lines` are listed.
10
+ */
11
+ export declare function listKeptContexts(lines: string[], projectId: number | undefined, contextIds: readonly number[]): void;
12
+ //# sourceMappingURL=merged-project-contexts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merged-project-contexts.d.ts","sourceRoot":"","sources":["../src/merged-project-contexts.ts"],"names":[],"mappings":"AAYA,yHAAyH;AACzH,eAAO,MAAM,oCAAoC,IAAI,CAAC;AAEtD,wGAAwG;AACxG,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,KAAG,MAAM,EAAgE,CAAC;AAE7G;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAiBpH"}
@@ -0,0 +1,56 @@
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 merged IfcProject's RepresentationContexts: a compatible later model's IfcProject folds into the primary's, so
6
+ * the contexts it kept are listed there (#10798).
7
+ */
8
+ import { splitTopLevelStepArguments } from './step-argument-parser.js';
9
+ import { frameArgs, stepRecordFrame, withFrameArgs } from './step-record-frame.js';
10
+ /** 0-based attribute index of `IfcContext.RepresentationContexts` (IfcProject in IFC2X3 and IFC4, IfcProjectLibrary). */
11
+ export const PROJECT_REPRESENTATION_CONTEXTS_ATTR = 7;
12
+ /** The `#N` references in an attribute slot of references (`$` has none); its comments are not read. */
13
+ export const refsIn = (slot) => slot.replace(/\/\*[\s\S]*?\*\//g, '').match(/#\d+/g) ?? [];
14
+ /**
15
+ * List `contextIds` in the merged project's RepresentationContexts (#10798). A compatible later model's IfcProject
16
+ * folds into the primary's, so a top-level context of it that was kept rather than unified (a different frame or
17
+ * georeference, or a second context its own project listed) belongs to no project otherwise. Only
18
+ * ids written to `lines` are listed.
19
+ */
20
+ export function listKeptContexts(lines, projectId, contextIds) {
21
+ if (projectId === undefined || contextIds.length === 0)
22
+ return;
23
+ const wanted = new Set(contextIds), written = [];
24
+ let projectIndex = -1;
25
+ // Stops once the project and every kept context are found.
26
+ for (let index = 0; index < lines.length && (projectIndex < 0 || written.length < wanted.size); index++) {
27
+ const id = leadingId(lines[index]);
28
+ if (id === projectId)
29
+ projectIndex = index;
30
+ else if (wanted.has(id))
31
+ written.push(id);
32
+ }
33
+ if (projectIndex < 0 || written.length === 0)
34
+ return;
35
+ const text = lines[projectIndex], frame = stepRecordFrame(text, { allowMissingSemicolon: true });
36
+ const args = frame && splitTopLevelStepArguments(frameArgs(text, frame));
37
+ if (!frame || !args || args.length <= PROJECT_REPRESENTATION_CONTEXTS_ATTR)
38
+ return;
39
+ // The slot holds references only, so it is rewritten from them: `(#2) /* c */` and `$ /* c */` read as the list.
40
+ args[PROJECT_REPRESENTATION_CONTEXTS_ATTR] = `(${[...refsIn(args[PROJECT_REPRESENTATION_CONTEXTS_ATTR]), ...written.map(id => `#${id}`)].join(',')})`;
41
+ lines[projectIndex] = withFrameArgs(text, frame, args.join(','));
42
+ }
43
+ /** The `#N` a STEP line starts with, or -1; read by char code, as it runs over every line of a merge. */
44
+ function leadingId(line) {
45
+ if (line.charCodeAt(0) !== 35)
46
+ return -1;
47
+ let id = 0, index = 1;
48
+ for (; index < line.length; index++) {
49
+ const digit = line.charCodeAt(index) - 48;
50
+ if (digit < 0 || digit > 9)
51
+ break;
52
+ id = id * 10 + digit;
53
+ }
54
+ return index > 1 ? id : -1;
55
+ }
56
+ //# sourceMappingURL=merged-project-contexts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merged-project-contexts.js","sourceRoot":"","sources":["../src/merged-project-contexts.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;GAGG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,e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ted STEP strings (e.g. a 'Room #205' Name or a 'http://x#42'
7
7
  * URL) are left untouched so string attribute values are not corrupted.
8
+ * A STEP comment is copied as it is too: an apostrophe in it opens no
9
+ * string, so the references after it are still remapped (#10968).
8
10
  */
9
11
  export declare function remapEntityText(entityText: string, offset: number, sharedRemap: ReadonlyMap<number, number>): string;
10
12
  //# sourceMappingURL=merged-remap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"merged-remap.d.ts","sourceRoot":"","sources":["../src/merged-remap.ts"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACvC,MAAM,CAqCR"}
1
+ {"version":3,"file":"merged-remap.d.ts","sourceRoot":"","sources":["../src/merged-remap.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACvC,MAAM,CA6CR"}
@@ -10,6 +10,7 @@
10
10
  * (`merged-empty-containers.ts`, `merged-subcontext.ts`).
11
11
  */
12
12
  import { stepStringLiteralEnd } from '@ifc-lite/encoding';
13
+ import { skipStepComment } from './step-comment-skip.js';
13
14
  /**
14
15
  * Remap all #ID references in a STEP entity line.
15
16
  * Applies offset to all IDs, then overrides with specific remappings.
@@ -17,6 +18,8 @@ import { stepStringLiteralEnd } from '@ifc-lite/encoding';
17
18
  * Only `#<digits>` tokens in code positions are rewritten; tokens inside
18
19
  * single-quoted STEP strings (e.g. a 'Room #205' Name or a 'http://x#42'
19
20
  * URL) are left untouched so string attribute values are not corrupted.
21
+ * A STEP comment is copied as it is too: an apostrophe in it opens no
22
+ * string, so the references after it are still remapped (#10968).
20
23
  */
21
24
  export function remapEntityText(entityText, offset, sharedRemap) {
22
25
  const remapId = (originalId) => {
@@ -31,6 +34,13 @@ export function remapEntityText(entityText, offset, sharedRemap) {
31
34
  let out = '';
32
35
  for (let i = 0; i < entityText.length; i++) {
33
36
  const char = entityText[i];
37
+ // An unclosed `/*` is no comment: read on, as before (#10968).
38
+ if (char === '/' && entityText[i + 1] === '*' && entityText.includes('*/', i + 2)) {
39
+ const stop = skipStepComment(entityText, i);
40
+ out += entityText.slice(i, stop);
41
+ i = stop - 1;
42
+ continue;
43
+ }
34
44
  if (char === "'") {
35
45
  // The literal is copied verbatim. Where it ends is the shared rule: `''`
36
46
  // and a `\S\'` PAGE operand stay inside it (#7589). Unterminated: the rest.
@@ -1 +1 @@
1
- {"version":3,"file":"merged-remap.js","sourceRoot":"","sources":["../src/merged-remap.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;GAOG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,UAAkB,EAClB,MAAc,EACd,WAAwC;IAExC,MAAM,OAAO,GAAG,CAAC,UAAkB,EAAU,EAAE;QAC7C,yEAAyE;QACzE,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,IAAI,QAAQ,EAAE,CAAC;QACxB,CAAC;QACD,eAAe;QACf,OAAO,IAAI,UAAU,GAAG,MAAM,EAAE,CAAC;IACnC,CAAC,CAAC;IAEF,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAE3B,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACjB,yEAAyE;YACzE,4EA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E,IAAI,CAAC,CAAC;YACjC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;YACb,SAAS;QACX,CAAC;QAED,IAAI,IAAI,KAAK,GAAG,IAAI,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;YACzE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACd,OAAO,CAAC,GAAG,UAAU,CAAC,MAAM,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,GAAG;gBAAE,CAAC,EAAE,CAAC;YAClF,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC5D,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;YAC3B,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACV,SAAS;QACX,CAAC;QAED,GAAG,IAAI,IAAI,CAAC;IACd,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -26,6 +26,28 @@
26
26
  * where applicable) rather than on raw array position.
27
27
  */
28
28
  import type { IfcDataStore } from '@ifc-lite/parser';
29
+ export declare function decodeEntity(dataStore: IfcDataStore, expressId: number): string | null;
30
+ /**
31
+ * Extract one 0-based STEP attribute of `expressId`'s entity, or null if
32
+ * unreadable. `merged-context.ts` reads its WCS frames and georeferences
33
+ * through this one too, where null is likewise read as unresolvable.
34
+ *
35
+ * `splitTopLevelStepArguments` returning null (a malformed record, OR —
36
+ * since #4162's per-slot check — a well-formed record whose split it cannot
37
+ * vouch for) is one more way to land here, same as no source bytes or no
38
+ * record frame. `normalizeLabel` already turns a null attribute into `''`,
39
+ * the same key an actually-blank `ContextIdentifier`/`TargetView` gets, so a
40
+ * subcontext this can't read falls back to grouping with other blank-keyed
41
+ * subcontexts rather than being matched on a guessed kind — the failure mode
42
+ * this file's own docstring already treats as acceptable ("left un-remapped
43
+ * — kept as its own entity"). `ContextIdentifier`/`TargetView` are IFC label/
44
+ * enumeration attributes, not binary-typed ones, so #4162's per-slot check
45
+ * gaining binary-literal support does not change what is reachable here in
46
+ * practice — audited alongside the four other `splitTopLevelStepArguments`
47
+ * call sites, unlike `rescaleEntityLengths` (`unit-normalize.ts`), which
48
+ * throws: a length has no safe permissive fallback.
49
+ */
50
+ export declare function getStepAttr(dataStore: IfcDataStore, expressId: number, index: number): string | null;
29
51
  /** Group `ids` (a model's subcontext express ids) by {@link subContextKey}. */
30
52
  export declare function groupSubContextsByKey(dataStore: IfcDataStore, ids: readonly number[]): Map<string, number[]>;
31
53
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"merged-subcontext.d.ts","sourceRoot":"","sources":["../src/merged-subcontext.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAiFrD,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAQ5G;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,0BAA0B,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACzD,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,GACzB,IAAI,CAYN"}
1
+ {"version":3,"file":"merged-subcontext.d.ts","sourceRoot":"","sources":["../src/merged-subcontext.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAYrD,wBAAgB,YAAY,CAAC,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQtF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQpG;AA0BD,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,YAAY,EAAE,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAQ5G;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,0BAA0B,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACzD,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,GACzB,IAAI,CAYN"}
@@ -1,40 +1,35 @@
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
- import { asSourceBytes, STEP_TRIVIA } from '@ifc-lite/parser';
4
+ import { asSourceBytes } from '@ifc-lite/parser';
5
5
  import { splitTopLevelStepArguments } from './step-argument-parser.js';
6
- /**
7
- * `#N=TYPE(...)` record, with STEP trivia (whitespace and/or a
8
- * `/* ... *​/` comment, #3789) tolerated between the type name and `(` —
9
- * same adjacency fix as `entity-extractor.ts`'s `extractEntity`. Without it
10
- * a wrapped record's attribute is silently unreadable here (`getStepAttr`
11
- * returns `null`), which reads identically to a genuinely-absent attribute.
12
- */
13
- const RECORD_RE = new RegExp(`^#\\d+\\s*=\\s*\\w+${STEP_TRIVIA}\\(([\\s\\S]*)\\)\\s*;?\\s*$`);
6
+ import { frameArgs, stepRecordFrame } from './step-record-frame.js';
14
7
  /** 0-based attribute index of `IfcGeometricRepresentationSubContext.ContextIdentifier`. */
15
8
  const CONTEXT_IDENTIFIER_ATTR = 0;
16
9
  /** 0-based attribute index of `IfcGeometricRepresentationSubContext.TargetView`. */
17
10
  const TARGET_VIEW_ATTR = 8;
18
11
  /** 0-based attribute index of `IfcGeometricRepresentationSubContext.UserDefinedTargetView`. */
19
12
  const USER_DEFINED_TARGET_VIEW_ATTR = 9;
20
- function decodeEntity(dataStore, expressId) {
13
+ export function decodeEntity(dataStore, expressId) {
21
14
  const source = dataStore.source;
22
15
  if (!source)
23
16
  return null;
24
- // @raw-entity-enumeration-ok decode one source subcontext's STEP byte span during an overlay-free merge
25
- const ref = dataStore.entityIndex.byId.get(expressId);
17
+ // A property atom parsed with `deferPropertyAtomIndex` lives in the deferred index (#10915).
18
+ // @raw-entity-enumeration-ok decode one record's STEP byte span for the merge's context reads; MergeExporter bakes each edited input through STEP export and reparses it first
19
+ const ref = dataStore.entityIndex.byId.get(expressId) ?? dataStore.deferredEntityIndex?.get(expressId);
26
20
  if (!ref)
27
21
  return null;
28
22
  return asSourceBytes(source).decodeUtf8(ref.byteOffset, ref.byteOffset + ref.byteLength);
29
23
  }
30
24
  /**
31
25
  * Extract one 0-based STEP attribute of `expressId`'s entity, or null if
32
- * unreadable.
26
+ * unreadable. `merged-context.ts` reads its WCS frames and georeferences
27
+ * through this one too, where null is likewise read as unresolvable.
33
28
  *
34
29
  * `splitTopLevelStepArguments` returning null (a malformed record, OR —
35
30
  * since #4162's per-slot check — a well-formed record whose split it cannot
36
31
  * vouch for) is one more way to land here, same as no source bytes or no
37
- * regex match. `normalizeLabel` already turns a null attribute into `''`,
32
+ * record frame. `normalizeLabel` already turns a null attribute into `''`,
38
33
  * the same key an actually-blank `ContextIdentifier`/`TargetView` gets, so a
39
34
  * subcontext this can't read falls back to grouping with other blank-keyed
40
35
  * subcontexts rather than being matched on a guessed kind — the failure mode
@@ -46,12 +41,13 @@ function decodeEntity(dataStore, expressId) {
46
41
  * call sites, unlike `rescaleEntityLengths` (`unit-normalize.ts`), which
47
42
  * throws: a length has no safe permissive fallback.
48
43
  */
49
- function getStepAttr(dataStore, expressId, index) {
44
+ export function getStepAttr(dataStore, expressId, index) {
50
45
  const text = decodeEntity(dataStore, expressId);
51
- const match = text?.match(RECORD_RE);
52
- if (!match)
46
+ // The package's record frame: STEP trivia is allowed wherever a record allows it (around `=`, before `(` and `;`).
47
+ const frame = text == null ? null : stepRecordFrame(text, { allowMissingSemicolon: true });
48
+ if (!frame)
53
49
  return null;
54
- const args = splitTopLevelStepArguments(match[1]);
50
+ const args = splitTopLevelStepArguments(frameArgs(text, frame));
55
51
  const raw = args?.[index];
56
52
  return raw === undefined ? null : raw.trim();
57
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"merged-subcontext.js","sourceRoot":"","sources":["../src/merged-subcontext.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AA+B/D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC,sBAAsB,WAAW,8BAA8B,CAAC,CAAC;AAE9F,2FAA2F;AAC3F,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAClC,oFAAoF;AACpF,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,+FAA+F;AAC/F,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAExC,SAAS,YAAY,CAAC,SAAuB,EAAE,SAAiB;IAC9D,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAChC,IAAI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,gBAAwB,EACxB,WAAgC,EAChC,aAA0B;IAE1B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,KAAK,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,aAAa,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,0BAA0B,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS;QACzC,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM;YAAE,SAAS,CAAC,iDAAiD;QACnF,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;QAC5B,WAAW,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAAC,CAAC;QAClD,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;AACH,CAAC"}
@@ -1,19 +1,19 @@
1
- import type { IfcDataStore } from '@ifc-lite/parser';
1
+ import { type IfcDataStore } from '@ifc-lite/parser';
2
2
  import { type IfcSchemaVersion } from './schema-converter.js';
3
3
  /** How one entity TYPE's data survives a schema conversion. */
4
4
  export type EntityConversionKind =
5
- /** Same type, same attribute list: nothing lost. */
5
+ /** Same type name, nothing lost: the attribute list is unchanged, padded,
6
+ * or reconciled by an attribute map (#10763). */
6
7
  'identity'
7
- /** Different type name (or the same name, source-schema attrs trimmed/padded),
8
- * every source attribute has a same-named or explicitly mapped semantic home
9
- * in the target. */
8
+ /** Different type name, every source attribute has a same-named or
9
+ * explicitly mapped semantic home in the target. */
10
10
  | 'renamed'
11
11
  /** Reconciled with SOME loss. Usually at least one source attribute has no
12
12
  * home in the target schema's shape for this type (see
13
13
  * `droppedAttributes`) — but a same-named type whose attribute lists are
14
- * reordered rather than appended/removed (neither a strict prefix of the
15
- * other, and not in `BY_NAME_ATTR_REMAP_TYPES`) is also `lossy` with an
16
- * EMPTY `droppedAttributes`: every name still exists in the target, but
14
+ * reordered rather than appended/removed, with no attribute map
15
+ * (`schema-converter-attr-maps.ts`, #10763), is also `lossy` with an EMPTY
16
+ * `droppedAttributes`: every name still exists in the target, but
17
17
  * `convertRecord` leaves the positional values untouched under the new
18
18
  * shape, so they land in the wrong slots rather than disappearing. */
19
19
  | 'lossy'
@@ -49,12 +49,17 @@ export interface ConversionLossEntry extends EntityConversionInfo {
49
49
  sourceType: string;
50
50
  count: number;
51
51
  expressIds: readonly number[];
52
+ /** Record-level losses when instances of this type lose different attributes or are written as different types. */
53
+ recordGroups?: readonly (Pick<ConversionLossEntry, 'expressIds' | 'droppedAttributes' | 'count'> & Partial<Pick<ConversionLossEntry, 'targetType'>>)[];
52
54
  }
53
55
  export interface ConversionLossReport {
54
56
  fromSchema: IfcSchemaVersion;
55
57
  toSchema: IfcSchemaVersion;
56
58
  /** Every non-identity, non-plain-`renamed` entry: `lossy`, `proxied` and
57
- * `blocked` types the store actually contains at least one instance of. */
59
+ * `blocked` types the store actually contains at least one instance of.
60
+ * A type whose records lose different attributes, because an IFC2X3 <-> IFC4
61
+ * structural carrier brings some of them back for some records, has one
62
+ * entry with record groups and the union of their lost attributes (#9668). */
58
63
  entries: readonly ConversionLossEntry[];
59
64
  /** True when a full-fidelity export exists (no `blocked` entries) but at
60
65
  * least one type is `lossy` or `proxied`. */
@@ -69,8 +74,11 @@ export interface ConversionLossReport {
69
74
  /**
70
75
  * A complete, per-type loss report for converting every entity `store`
71
76
  * contains from `fromSchema` to `toSchema` — no export attempted, so this
72
- * never throws and always covers the whole file, not just the first record a
73
- * full export would have aborted on.
77
+ * does not throw for a record the export cannot write and always covers the
78
+ * whole file, not just the first record a full export would have aborted on.
79
+ * With source bytes, the report checks whether a narrowed SET actually loses
80
+ * members and excludes values preserved by IFC2X3 ↔ IFC4 structural carriers
81
+ * (#9668). Those carriers describe the default, unedited full export.
74
82
  */
75
- export declare function analyzeConversionLoss(store: Pick<IfcDataStore, 'entityIndex'>, fromSchema: IfcSchemaVersion, toSchema: IfcSchemaVersion): ConversionLossReport;
83
+ export declare function analyzeConversionLoss(store: Pick<IfcDataStore, 'entityIndex'> & Partial<Pick<IfcDataStore, 'source' | 'deferredEntityIndex'>>, fromSchema: IfcSchemaVersion, toSchema: IfcSchemaVersion): ConversionLossReport;
76
84
  //# sourceMappingURL=schema-conversion-loss-report.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-conversion-loss-report.d.ts","sourceRoot":"","sources":["../src/schema-conversion-loss-report.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAC;AAK/B,+DAA+D;AAC/D,MAAM,MAAM,oBAAoB;AAC9B,oDAAoD;AAClD,UAAU;AACZ;;qBAEqB;GACnB,SAAS;AACX;;;;;;;uEAOuE;GACrE,OAAO;AACT;;mDAEmD;GACjD,SAAS;AACX;;;;wBAIwB;GACtB,SAAS,CAAC;AAEd,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,oBAAoB,CAAC;IAC3B;;;mEAG+D;IAC/D,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,gBAAgB,EAC5B,QAAQ,EAAE,gBAAgB,GACzB,oBAAoB,CA8EtB;AAED;sEACsE;AACtE,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B;gFAC4E;IAC5E,OAAO,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACxC;kDAC8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB;mEAC+D;IAC/D,WAAW,EAAE,OAAO,CAAC;IACrB;4EACwE;IACxE,QAAQ,IAAI,MAAM,EAAE,CAAC;CACtB;AAyBD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,EACxC,UAAU,EAAE,gBAAgB,EAC5B,QAAQ,EAAE,gBAAgB,GACzB,oBAAoB,CAqBtB"}
1
+ {"version":3,"file":"schema-conversion-loss-report.d.ts","sourceRoot":"","sources":["../src/schema-conversion-loss-report.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAC;AAM/B,+DAA+D;AAC/D,MAAM,MAAM,oBAAoB;AAC9B;kDACkD;AAChD,UAAU;AACZ;qDACqD;GACnD,SAAS;AACX;;;;;;;uEAOuE;GACrE,OAAO;AACT;;mDAEmD;GACjD,SAAS;AACX;;;;wBAIwB;GACtB,SAAS,CAAC;AAEd,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,oBAAoB,CAAC;IAC3B;;;mEAG+D;IAC/D,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,gBAAgB,EAC5B,QAAQ,EAAE,gBAAgB,GACzB,oBAAoB,CAqFtB;AAED;sEACsE;AACtE,MAAM,WAAW,mBAAoB,SAA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