@ifc-lite/export 4.14.0 → 6.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 (304) hide show
  1. package/dist/anonymize-placement.d.ts.map +1 -1
  2. package/dist/anonymize-placement.js +2 -2
  3. package/dist/anonymize-placement.js.map +1 -1
  4. package/dist/attribute-slot-types.d.ts.map +1 -1
  5. package/dist/attribute-slot-types.js +3 -1
  6. package/dist/attribute-slot-types.js.map +1 -1
  7. package/dist/effective-index-created-rows.d.ts +3 -0
  8. package/dist/effective-index-created-rows.d.ts.map +1 -1
  9. package/dist/effective-index-created-rows.js +16 -5
  10. package/dist/effective-index-created-rows.js.map +1 -1
  11. package/dist/effective-index.d.ts.map +1 -1
  12. package/dist/effective-index.js +2 -1
  13. package/dist/effective-index.js.map +1 -1
  14. package/dist/entity-iteration.d.ts +1 -1
  15. package/dist/entity-iteration.d.ts.map +1 -1
  16. package/dist/entity-iteration.js.map +1 -1
  17. package/dist/generated/ifc2x3-typed-properties.d.ts +11 -0
  18. package/dist/generated/ifc2x3-typed-properties.d.ts.map +1 -0
  19. package/dist/generated/ifc2x3-typed-properties.js +49 -0
  20. package/dist/generated/ifc2x3-typed-properties.js.map +1 -0
  21. package/dist/georef-closure.d.ts +12 -0
  22. package/dist/georef-closure.d.ts.map +1 -1
  23. package/dist/georef-closure.js +3 -1
  24. package/dist/georef-closure.js.map +1 -1
  25. package/dist/ifc5-exporter.d.ts.map +1 -1
  26. package/dist/ifc5-exporter.js +3 -10
  27. package/dist/ifc5-exporter.js.map +1 -1
  28. package/dist/index.d.ts +4 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +4 -0
  31. package/dist/index.js.map +1 -1
  32. package/dist/merged-bake.d.ts +32 -0
  33. package/dist/merged-bake.d.ts.map +1 -0
  34. package/dist/merged-bake.js +120 -0
  35. package/dist/merged-bake.js.map +1 -0
  36. package/dist/merged-context.d.ts +49 -6
  37. package/dist/merged-context.d.ts.map +1 -1
  38. package/dist/merged-context.js +165 -53
  39. package/dist/merged-context.js.map +1 -1
  40. package/dist/merged-exporter.d.ts +7 -14
  41. package/dist/merged-exporter.d.ts.map +1 -1
  42. package/dist/merged-exporter.js +112 -178
  43. package/dist/merged-exporter.js.map +1 -1
  44. package/dist/merged-georef-normalize.d.ts +54 -0
  45. package/dist/merged-georef-normalize.d.ts.map +1 -0
  46. package/dist/merged-georef-normalize.js +260 -0
  47. package/dist/merged-georef-normalize.js.map +1 -0
  48. package/dist/merged-guid.d.ts +5 -7
  49. package/dist/merged-guid.d.ts.map +1 -1
  50. package/dist/merged-guid.js +37 -42
  51. package/dist/merged-guid.js.map +1 -1
  52. package/dist/merged-header.d.ts +6 -0
  53. package/dist/merged-header.d.ts.map +1 -1
  54. package/dist/merged-header.js +6 -0
  55. package/dist/merged-header.js.map +1 -1
  56. package/dist/merged-inverse-claims.d.ts.map +1 -1
  57. package/dist/merged-inverse-claims.js +3 -2
  58. package/dist/merged-inverse-claims.js.map +1 -1
  59. package/dist/merged-planner-guids.d.ts +1 -0
  60. package/dist/merged-planner-guids.d.ts.map +1 -1
  61. package/dist/merged-planner-guids.js +5 -6
  62. package/dist/merged-planner-guids.js.map +1 -1
  63. package/dist/merged-project-contexts.d.ts +12 -0
  64. package/dist/merged-project-contexts.d.ts.map +1 -0
  65. package/dist/merged-project-contexts.js +56 -0
  66. package/dist/merged-project-contexts.js.map +1 -0
  67. package/dist/merged-remap.d.ts +3 -1
  68. package/dist/merged-remap.d.ts.map +1 -1
  69. package/dist/merged-remap.js +15 -1
  70. package/dist/merged-remap.js.map +1 -1
  71. package/dist/merged-subcontext.d.ts +22 -0
  72. package/dist/merged-subcontext.d.ts.map +1 -1
  73. package/dist/merged-subcontext.js +14 -18
  74. package/dist/merged-subcontext.js.map +1 -1
  75. package/dist/schema-calendar-date-values.d.ts +15 -0
  76. package/dist/schema-calendar-date-values.d.ts.map +1 -0
  77. package/dist/schema-calendar-date-values.js +107 -0
  78. package/dist/schema-calendar-date-values.js.map +1 -0
  79. package/dist/schema-calendar-dates.d.ts +11 -0
  80. package/dist/schema-calendar-dates.d.ts.map +1 -0
  81. package/dist/schema-calendar-dates.js +127 -0
  82. package/dist/schema-calendar-dates.js.map +1 -0
  83. package/dist/schema-conversion-loss-description.d.ts +3 -0
  84. package/dist/schema-conversion-loss-description.d.ts.map +1 -0
  85. package/dist/schema-conversion-loss-description.js +23 -0
  86. package/dist/schema-conversion-loss-description.js.map +1 -0
  87. package/dist/schema-conversion-loss-report.d.ts +22 -19
  88. package/dist/schema-conversion-loss-report.d.ts.map +1 -1
  89. package/dist/schema-conversion-loss-report.js +223 -61
  90. package/dist/schema-conversion-loss-report.js.map +1 -1
  91. package/dist/schema-converter-attr-maps.d.ts +63 -0
  92. package/dist/schema-converter-attr-maps.d.ts.map +1 -0
  93. package/dist/schema-converter-attr-maps.js +186 -0
  94. package/dist/schema-converter-attr-maps.js.map +1 -0
  95. package/dist/schema-converter-attr-remap.d.ts +2 -2
  96. package/dist/schema-converter-attr-remap.d.ts.map +1 -1
  97. package/dist/schema-converter-attr-remap.js +9 -5
  98. package/dist/schema-converter-attr-remap.js.map +1 -1
  99. package/dist/schema-converter-document-links.d.ts +23 -0
  100. package/dist/schema-converter-document-links.d.ts.map +1 -0
  101. package/dist/schema-converter-document-links.js +146 -0
  102. package/dist/schema-converter-document-links.js.map +1 -0
  103. package/dist/schema-converter-durations.d.ts +9 -0
  104. package/dist/schema-converter-durations.d.ts.map +1 -0
  105. package/dist/schema-converter-durations.js +60 -0
  106. package/dist/schema-converter-durations.js.map +1 -0
  107. package/dist/schema-converter-enums.d.ts +18 -2
  108. package/dist/schema-converter-enums.d.ts.map +1 -1
  109. package/dist/schema-converter-enums.js +39 -6
  110. package/dist/schema-converter-enums.js.map +1 -1
  111. package/dist/schema-converter-ifc2x3-slots.d.ts +1 -1
  112. package/dist/schema-converter-ifc2x3-slots.d.ts.map +1 -1
  113. package/dist/schema-converter-ifc2x3-slots.js +6 -5
  114. package/dist/schema-converter-ifc2x3-slots.js.map +1 -1
  115. package/dist/schema-converter-ifc4-slots.d.ts +4 -3
  116. package/dist/schema-converter-ifc4-slots.d.ts.map +1 -1
  117. package/dist/schema-converter-ifc4-slots.js +4 -3
  118. package/dist/schema-converter-ifc4-slots.js.map +1 -1
  119. package/dist/schema-converter-ifc4x3-upgrade.d.ts +5 -0
  120. package/dist/schema-converter-ifc4x3-upgrade.d.ts.map +1 -0
  121. package/dist/schema-converter-ifc4x3-upgrade.js +41 -0
  122. package/dist/schema-converter-ifc4x3-upgrade.js.map +1 -0
  123. package/dist/schema-converter-material-referent.d.ts +55 -0
  124. package/dist/schema-converter-material-referent.d.ts.map +1 -0
  125. package/dist/schema-converter-material-referent.js +184 -0
  126. package/dist/schema-converter-material-referent.js.map +1 -0
  127. package/dist/schema-converter-owner-history.d.ts +1 -1
  128. package/dist/schema-converter-owner-history.d.ts.map +1 -1
  129. package/dist/schema-converter-owner-history.js +4 -3
  130. package/dist/schema-converter-owner-history.js.map +1 -1
  131. package/dist/schema-converter-product-proxy.d.ts +0 -23
  132. package/dist/schema-converter-product-proxy.d.ts.map +1 -1
  133. package/dist/schema-converter-product-proxy.js +2 -1
  134. package/dist/schema-converter-product-proxy.js.map +1 -1
  135. package/dist/schema-converter-renames.d.ts +17 -0
  136. package/dist/schema-converter-renames.d.ts.map +1 -1
  137. package/dist/schema-converter-renames.js +34 -2
  138. package/dist/schema-converter-renames.js.map +1 -1
  139. package/dist/schema-converter-retyped.d.ts +17 -0
  140. package/dist/schema-converter-retyped.d.ts.map +1 -0
  141. package/dist/schema-converter-retyped.js +68 -0
  142. package/dist/schema-converter-retyped.js.map +1 -0
  143. package/dist/schema-converter-step-finish.d.ts +4 -0
  144. package/dist/schema-converter-step-finish.d.ts.map +1 -0
  145. package/dist/schema-converter-step-finish.js +27 -0
  146. package/dist/schema-converter-step-finish.js.map +1 -0
  147. package/dist/schema-converter-structural-axes.d.ts +48 -4
  148. package/dist/schema-converter-structural-axes.d.ts.map +1 -1
  149. package/dist/schema-converter-structural-axes.js +350 -31
  150. package/dist/schema-converter-structural-axes.js.map +1 -1
  151. package/dist/schema-converter-structural-carriers.d.ts +78 -0
  152. package/dist/schema-converter-structural-carriers.d.ts.map +1 -0
  153. package/dist/schema-converter-structural-carriers.js +336 -0
  154. package/dist/schema-converter-structural-carriers.js.map +1 -0
  155. package/dist/schema-converter-structural-diagnostics.d.ts +56 -9
  156. package/dist/schema-converter-structural-diagnostics.d.ts.map +1 -1
  157. package/dist/schema-converter-structural-diagnostics.js +170 -17
  158. package/dist/schema-converter-structural-diagnostics.js.map +1 -1
  159. package/dist/schema-converter-structural-links.d.ts +2 -2
  160. package/dist/schema-converter-structural-links.d.ts.map +1 -1
  161. package/dist/schema-converter-structural-links.js +3 -28
  162. package/dist/schema-converter-structural-links.js.map +1 -1
  163. package/dist/schema-converter-structural-source.d.ts +83 -0
  164. package/dist/schema-converter-structural-source.d.ts.map +1 -0
  165. package/dist/schema-converter-structural-source.js +207 -0
  166. package/dist/schema-converter-structural-source.js.map +1 -0
  167. package/dist/schema-converter-structural-thickness.d.ts +33 -0
  168. package/dist/schema-converter-structural-thickness.d.ts.map +1 -0
  169. package/dist/schema-converter-structural-thickness.js +155 -0
  170. package/dist/schema-converter-structural-thickness.js.map +1 -0
  171. package/dist/schema-converter-structural-varying.d.ts +21 -9
  172. package/dist/schema-converter-structural-varying.d.ts.map +1 -1
  173. package/dist/schema-converter-structural-varying.js +83 -54
  174. package/dist/schema-converter-structural-varying.js.map +1 -1
  175. package/dist/schema-converter-structural.d.ts +2 -2
  176. package/dist/schema-converter-structural.d.ts.map +1 -1
  177. package/dist/schema-converter-structural.js +9 -6
  178. package/dist/schema-converter-structural.js.map +1 -1
  179. package/dist/schema-converter-typed-properties.d.ts +30 -0
  180. package/dist/schema-converter-typed-properties.d.ts.map +1 -0
  181. package/dist/schema-converter-typed-properties.js +173 -0
  182. package/dist/schema-converter-typed-properties.js.map +1 -0
  183. package/dist/schema-converter-unrooted-upgrade.d.ts +14 -0
  184. package/dist/schema-converter-unrooted-upgrade.d.ts.map +1 -0
  185. package/dist/schema-converter-unrooted-upgrade.js +228 -0
  186. package/dist/schema-converter-unrooted-upgrade.js.map +1 -0
  187. package/dist/schema-converter-userdefined-label.d.ts +8 -0
  188. package/dist/schema-converter-userdefined-label.d.ts.map +1 -0
  189. package/dist/schema-converter-userdefined-label.js +61 -0
  190. package/dist/schema-converter-userdefined-label.js.map +1 -0
  191. package/dist/schema-converter-userdefined.d.ts +15 -0
  192. package/dist/schema-converter-userdefined.d.ts.map +1 -0
  193. package/dist/schema-converter-userdefined.js +59 -0
  194. package/dist/schema-converter-userdefined.js.map +1 -0
  195. package/dist/schema-converter-value-forms.d.ts +20 -0
  196. package/dist/schema-converter-value-forms.d.ts.map +1 -0
  197. package/dist/schema-converter-value-forms.js +225 -0
  198. package/dist/schema-converter-value-forms.js.map +1 -0
  199. package/dist/schema-converter.d.ts +10 -15
  200. package/dist/schema-converter.d.ts.map +1 -1
  201. package/dist/schema-converter.js +87 -83
  202. package/dist/schema-converter.js.map +1 -1
  203. package/dist/schema-enum-policy.d.ts +5 -1
  204. package/dist/schema-enum-policy.d.ts.map +1 -1
  205. package/dist/schema-enum-policy.js +21 -1
  206. package/dist/schema-enum-policy.js.map +1 -1
  207. package/dist/schema-ifc2x3-placements.d.ts.map +1 -1
  208. package/dist/schema-ifc2x3-placements.js +20 -31
  209. package/dist/schema-ifc2x3-placements.js.map +1 -1
  210. package/dist/schema-ifc2x3-records.d.ts.map +1 -1
  211. package/dist/schema-ifc2x3-records.js +3 -2
  212. package/dist/schema-ifc2x3-records.js.map +1 -1
  213. package/dist/schema-ifc2x3-style-assignments.d.ts +4 -0
  214. package/dist/schema-ifc2x3-style-assignments.d.ts.map +1 -0
  215. package/dist/schema-ifc2x3-style-assignments.js +33 -0
  216. package/dist/schema-ifc2x3-style-assignments.js.map +1 -0
  217. package/dist/schema-structural-varying-effective.d.ts +2 -0
  218. package/dist/schema-structural-varying-effective.d.ts.map +1 -0
  219. package/dist/schema-structural-varying-effective.js +95 -0
  220. package/dist/schema-structural-varying-effective.js.map +1 -0
  221. package/dist/schema-untranslatable.d.ts +22 -13
  222. package/dist/schema-untranslatable.d.ts.map +1 -1
  223. package/dist/schema-untranslatable.js +84 -6
  224. package/dist/schema-untranslatable.js.map +1 -1
  225. package/dist/schema-value-form-policy.d.ts +129 -0
  226. package/dist/schema-value-form-policy.d.ts.map +1 -0
  227. package/dist/schema-value-form-policy.js +255 -0
  228. package/dist/schema-value-form-policy.js.map +1 -0
  229. package/dist/step-argument-parser.d.ts +3 -3
  230. package/dist/step-argument-parser.d.ts.map +1 -1
  231. package/dist/step-argument-parser.js +6 -6
  232. package/dist/step-argument-parser.js.map +1 -1
  233. package/dist/step-collection.d.ts.map +1 -1
  234. package/dist/step-collection.js +2 -0
  235. package/dist/step-collection.js.map +1 -1
  236. package/dist/step-comment-skip.d.ts +8 -0
  237. package/dist/step-comment-skip.d.ts.map +1 -1
  238. package/dist/step-comment-skip.js +30 -0
  239. package/dist/step-comment-skip.js.map +1 -1
  240. package/dist/step-coordinate-options.d.ts +15 -0
  241. package/dist/step-coordinate-options.d.ts.map +1 -1
  242. package/dist/step-coordinate-options.js +13 -1
  243. package/dist/step-coordinate-options.js.map +1 -1
  244. package/dist/step-export-types.d.ts +5 -7
  245. package/dist/step-export-types.d.ts.map +1 -1
  246. package/dist/step-export-types.js.map +1 -1
  247. package/dist/step-exporter.d.ts +0 -6
  248. package/dist/step-exporter.d.ts.map +1 -1
  249. package/dist/step-exporter.js +19 -12
  250. package/dist/step-exporter.js.map +1 -1
  251. package/dist/step-georeferencing.d.ts +2 -0
  252. package/dist/step-georeferencing.d.ts.map +1 -1
  253. package/dist/step-georeferencing.js +126 -63
  254. package/dist/step-georeferencing.js.map +1 -1
  255. package/dist/step-header.d.ts.map +1 -1
  256. package/dist/step-header.js +1 -0
  257. package/dist/step-header.js.map +1 -1
  258. package/dist/step-internal-pset-ids.js +1 -1
  259. package/dist/step-internal-pset-ids.js.map +1 -1
  260. package/dist/step-map-unit-normalization.d.ts.map +1 -1
  261. package/dist/step-map-unit-normalization.js +5 -4
  262. package/dist/step-map-unit-normalization.js.map +1 -1
  263. package/dist/step-map-unit.d.ts +8 -1
  264. package/dist/step-map-unit.d.ts.map +1 -1
  265. package/dist/step-map-unit.js +13 -5
  266. package/dist/step-map-unit.js.map +1 -1
  267. package/dist/step-omission-predicates.d.ts.map +1 -1
  268. package/dist/step-omission-predicates.js +1 -0
  269. package/dist/step-omission-predicates.js.map +1 -1
  270. package/dist/step-overlay-entities.d.ts +0 -35
  271. package/dist/step-overlay-entities.d.ts.map +1 -1
  272. package/dist/step-overlay-entities.js +38 -2
  273. package/dist/step-overlay-entities.js.map +1 -1
  274. package/dist/step-pass-builder.d.ts.map +1 -1
  275. package/dist/step-pass-builder.js +59 -7
  276. package/dist/step-pass-builder.js.map +1 -1
  277. package/dist/step-record-frame.d.ts +5 -3
  278. package/dist/step-record-frame.d.ts.map +1 -1
  279. package/dist/step-record-frame.js +12 -8
  280. package/dist/step-record-frame.js.map +1 -1
  281. package/dist/step-ref-scan.d.ts +12 -0
  282. package/dist/step-ref-scan.d.ts.map +1 -1
  283. package/dist/step-ref-scan.js +24 -3
  284. package/dist/step-ref-scan.js.map +1 -1
  285. package/dist/step-serialization.d.ts +12 -0
  286. package/dist/step-serialization.d.ts.map +1 -1
  287. package/dist/step-serialization.js +15 -0
  288. package/dist/step-serialization.js.map +1 -1
  289. package/dist/step-slot-grammar.d.ts +3 -2
  290. package/dist/step-slot-grammar.d.ts.map +1 -1
  291. package/dist/step-slot-grammar.js +5 -5
  292. package/dist/step-slot-grammar.js.map +1 -1
  293. package/dist/step-source-iteration.d.ts.map +1 -1
  294. package/dist/step-source-iteration.js +6 -9
  295. package/dist/step-source-iteration.js.map +1 -1
  296. package/dist/unit-normalize.d.ts +2 -2
  297. package/dist/unit-normalize.d.ts.map +1 -1
  298. package/dist/unit-normalize.js +23 -13
  299. package/dist/unit-normalize.js.map +1 -1
  300. package/dist/viewer-georef-scale.d.ts +14 -0
  301. package/dist/viewer-georef-scale.d.ts.map +1 -0
  302. package/dist/viewer-georef-scale.js +20 -0
  303. package/dist/viewer-georef-scale.js.map +1 -0
  304. package/package.json +41 -8
@@ -1,28 +1,34 @@
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 { IfcParser, asSourceBytes } from '@ifc-lite/parser';
4
+ import { asSourceBytes } from '@ifc-lite/parser';
5
5
  import { decodeIfcString, stepStringLiteralEnd } from '@ifc-lite/encoding';
6
- import { buildMergedHeader } from './merged-header.js';
6
+ import { buildMergedHeader, finishMergedConversion } from './merged-header.js';
7
7
  import { collectReferencedEntityIds, getVisibleEntityIds, filterHiddenRefsFromRelationshipLine } from './reference-collector.js';
8
8
  import { collectStyleEntities, STYLE_RESCUE_TYPES } from './style-closure.js';
9
9
  import { collectGeoreferencingEntities } from './georef-closure.js';
10
+ import { noteUpgradeSeed, pruneUpgrade } from './schema-converter-unrooted-upgrade.js';
10
11
  import { convertStepLine, needsConversion } from './schema-converter.js';
12
+ import { classifyEntityTypeConversion } from './schema-conversion-loss-report.js';
11
13
  import { StyleFlatten } from './schema-style-flatten.js';
12
14
  import { firstWrittenOwnerHistoryRef, Ifc2x3SlotFill } from './schema-converter-ifc2x3-slots.js';
13
15
  import { Ifc4SlotCheck } from './schema-converter-ifc4-slots.js';
14
16
  import { EnumReconciliation } from './schema-converter-enums.js';
15
17
  import { assembleStepBytes, assembleStepBlob } from './step-file-assembly.js';
18
+ import { decodeTypedPropertyRecord, isTypedPropertyUpgrade } from './schema-converter-typed-properties.js';
16
19
  import { placeObjectsForSchema } from './schema-ifc2x3-placements.js';
17
20
  import { getCompleteEntityIndex, getMaxExpressId } from './entity-iteration.js';
18
- import { StepExporter } from './step-exporter.js';
21
+ import { bakeMutatedModels, mergeWarningLabel, needsBake } from './merged-bake.js';
19
22
  import { rescaleEntityLengths, computeNormalizeFactor } from './unit-normalize.js';
20
- import { planInfrastructureUnify, resolvePrimaryContextState } from './merged-context.js';
23
+ import { planInfrastructureUnify, resolvePrimaryContextState, unitScalesEqual } from './merged-context.js';
24
+ import { MintedRecords, georefNormalizeCaveat, normalizeGeorefRecord, planGeorefNormalize } from './merged-georef-normalize.js';
25
+ import { listKeptContexts } from './merged-project-contexts.js';
21
26
  import { remapEntityText } from './merged-remap.js';
27
+ import { armMergedModel } from './schema-converter-material-referent.js';
22
28
  import { PlannerGuids } from './merged-planner-guids.js';
23
- import { isRelationshipType, mintUniqueGuid, readLeadingGuid, replaceGlobalId, readLocalGuids, } from './merged-guid.js';
29
+ import { canUnifyByGlobalId, canUnifyEmittedRecord, isRootedType, isRelationshipType, mintUniqueGuid, readLeadingGuid, replaceGlobalId, readLocalGuids, } from './merged-guid.js';
24
30
  import { planEmptyContainerDrops, EMPTY_MODEL_VIEW, isSpatialContainerType, isStructureRelation, } from './merged-empty-containers.js';
25
- import { InverseClaims, claimInverses, applyRelMemberStrip, applyInverseFolds } from './merged-inverse-claims.js';
31
+ import { InverseClaims, claimInverses, applyRelMemberStrip } from './merged-inverse-claims.js';
26
32
  /**
27
33
  * UTF-8 decode of `[start, end)` of a model's source, accepting either the raw
28
34
  * bytes or the {@link IfcSourceBytes} accessor (#2183). Replaces the direct
@@ -39,8 +45,10 @@ const SHARED_INFRASTRUCTURE_TYPES = new Set([
39
45
  'IFCGEOMETRICREPRESENTATIONCONTEXT',
40
46
  'IFCGEOMETRICREPRESENTATIONSUBCONTEXT',
41
47
  ]);
42
- /** Relative tolerance for comparing two length unit scale factors. */
43
- const UNIT_SCALE_TOLERANCE = 1e-6;
48
+ function canUnifyConvertedType(type, from, to) {
49
+ const { targetType, kind } = classifyEntityTypeConversion(type, from, to);
50
+ return kind !== 'blocked' && kind !== 'proxied' && canUnifyByGlobalId(type, targetType);
51
+ }
44
52
  /** SI prefix multipliers, for resolving prefixed area/volume units (rarely used). */
45
53
  const SI_PREFIX_MULTIPLIERS = {
46
54
  ATTO: 1e-18, FEMTO: 1e-15, PICO: 1e-12, NANO: 1e-9, MICRO: 1e-6, MILLI: 1e-3,
@@ -49,28 +57,6 @@ const SI_PREFIX_MULTIPLIERS = {
49
57
  };
50
58
  /** Source schemas the IFC4 length registry does not fully cover (see #1475 review). */
51
59
  const NORMALIZE_UNCOVERED_SCHEMAS = new Set(['IFC4X3', 'IFC5']);
52
- /**
53
- * True when a mutation view carries pending edits the exporter would bake.
54
- *
55
- * Keys off the view's *current overlay footprint* (`hasPendingChanges`), not the
56
- * append-only mutation history: the history never shrinks, so an
57
- * edited-then-undone model would keep reporting changes and force a redundant
58
- * re-bake. `hasPendingChanges` is a conservative over-approximation (the safe
59
- * direction here — under-reporting would silently drop edits). Falls back to the
60
- * legacy history/new-entity check for views that predate the method.
61
- */
62
- function viewHasMutations(view) {
63
- if (!view)
64
- return false;
65
- if (typeof view.hasPendingChanges === 'function')
66
- return view.hasPendingChanges();
67
- // Legacy fallback (older MutablePropertyView without hasPendingChanges).
68
- const muts = typeof view.getMutations === 'function' ? view.getMutations() : [];
69
- if (muts.length > 0)
70
- return true;
71
- const created = typeof view.getNewEntities === 'function' ? view.getNewEntities() : [];
72
- return created.length > 0;
73
- }
74
60
  /**
75
61
  * Drop models with no usable source (nothing to emit): a cache-restored or
76
62
  * metadata-only store can reach the merge with an empty `.source`. The emit loop
@@ -135,14 +121,14 @@ export class MergedExporter {
135
121
  const header = buildMergedHeader(options, schema, this.models.length);
136
122
  // Baking edits into source bytes needs the async parser, so the sync path
137
123
  // cannot honour them. Fail loudly rather than silently dropping the edits.
138
- if (this.models.some(m => viewHasMutations(m.mutationView))) {
124
+ if (this.models.some(needsBake)) {
139
125
  throw new Error('MergedExporter.export() cannot apply pending edits — baking needs the async parser. ' +
140
126
  'Use exportAsync() for merged export with mutations.');
141
127
  }
142
128
  const models = withUsableSource(this.models);
143
129
  const setup = this.buildMergeSetup(options, models);
144
130
  const containerDrops = this.planContainerDrops(options, models, setup);
145
- const allEntityLines = [];
131
+ const allEntityLines = [], upgradeSeeds = new Set();
146
132
  // Tracks every GlobalId already emitted → its final express id + unit scale,
147
133
  // so later models can unify against (shared unit) or stay unique from
148
134
  // (federated / different unit) it.
@@ -151,7 +137,7 @@ export class MergedExporter {
151
137
  let federatedModelCount = 0;
152
138
  let normalizedModelCount = 0;
153
139
  const normalizeWarnings = new Set();
154
- const [slotFill, ifc4Slots, enums] = [new Ifc2x3SlotFill(), new Ifc4SlotCheck(), new EnumReconciliation()]; // #4714, #5202, #5365
140
+ const [slotFill, ifc4Slots, enums] = [new Ifc2x3SlotFill(), new Ifc4SlotCheck(), new EnumReconciliation(true, models.map((m) => m.dataStore))]; // #4714, #5202, #5365
155
141
  for (const model of models) {
156
142
  const offset = setup.modelOffsets.get(model.id);
157
143
  const source = model.dataStore.source;
@@ -165,12 +151,12 @@ export class MergedExporter {
165
151
  federatedModelCount++;
166
152
  if (mode.normalized) {
167
153
  normalizedModelCount++;
168
- this.collectNormalizeCaveats(model, normalizeWarnings);
154
+ this.collectNormalizeCaveats(model, normalizeWarnings, mode.georef);
169
155
  }
170
- const plan = this.planModel(model, completeIndex, isFirstModel, mode.compatible, mode.lengthFactor, setup, guidToFinalId);
156
+ const plan = this.planModel(model, completeIndex, isFirstModel, mode.compatible, mode.lengthFactor, setup, guidToFinalId, schema);
171
157
  this.applyContainerDrops(plan, containerDrops?.byModel.get(model.id));
172
158
  this.claimParents(model, plan, visibility, completeIndex, !isFirstModel && mode.compatible, setup);
173
- const written = (id) => (visibility === null || visibility.included.has(id)) && !plan.skipEntityIds.has(id);
159
+ const written = armMergedModel(enums.materials, model.dataStore, (id) => (visibility === null || visibility.included.has(id)) && !plan.skipEntityIds.has(id), offset, plan.sharedRemap);
174
160
  if (schema === 'IFC2X3') {
175
161
  // @raw-entity-enumeration-ok sync merge rejects overlays, so this is an unedited source index
176
162
  slotFill.prefer(firstWrittenOwnerHistoryRef(model.dataStore.entityIndex.byType.get('IFCOWNERHISTORY'), written, offset));
@@ -182,14 +168,20 @@ export class MergedExporter {
182
168
  if (!written(expressId))
183
169
  continue;
184
170
  const line = this.renderEntity(expressId, entityRef, source, offset, plan, sourceSchema, schema, guidToFinalId, mode, visibility?.hiddenProductIds ?? null, completeIndex, visibility?.included ?? null, slotFill, ifc4Slots, enums, styleFlatten);
185
- if (line !== null)
171
+ if (line !== null) {
186
172
  allEntityLines.push(line);
173
+ noteUpgradeSeed(line, upgradeSeeds, sourceSchema, schema);
174
+ }
187
175
  }
188
176
  isFirstModel = false;
189
177
  }
190
- for (const warning of [...slotFill.warnings(), ...ifc4Slots.warnings(), ...enums.warnings(), ...applyInverseFolds(allEntityLines, setup.parentClaims)])
191
- normalizeWarnings.add(warning); // #5774 folds
192
- // Assemble final file as Uint8Array chunks to avoid V8 string length limit
178
+ listKeptContexts(allEntityLines, setup.firstProjectIds.length ? setup.firstProjectIds[0] + setup.firstModelOffset : undefined, setup.keptContexts);
179
+ setup.minted.appendTo(allEntityLines);
180
+ enums.typedProperties.finish(allEntityLines, ifc4Slots, setup.nextAvailableId, enums.structural, Number.MAX_SAFE_INTEGER);
181
+ for (const warning of finishMergedConversion(allEntityLines, slotFill, ifc4Slots, enums, setup.parentClaims))
182
+ normalizeWarnings.add(warning);
183
+ for (const warning of pruneUpgrade(allEntityLines, upgradeSeeds, schema))
184
+ normalizeWarnings.add(warning);
193
185
  if (onProgress)
194
186
  onProgress({ phase: 'assembling', percent: 0.9, entitiesProcessed: allEntityLines.length, entitiesTotal: allEntityLines.length });
195
187
  const content = assembleStepBytes(header, placeObjectsForSchema(schema, allEntityLines)); // #9209
@@ -253,12 +245,12 @@ export class MergedExporter {
253
245
  // Bake each model's pending edits into its source bytes before merging, so
254
246
  // federated export round-trips mutations like single-model export. Models
255
247
  // without edits pass through unchanged (no export/parse cost).
256
- const models = withUsableSource(await this.bakeMutatedModels());
248
+ const baked = await bakeMutatedModels(this.models, schema);
249
+ const models = withUsableSource(baked.models);
257
250
  const setup = this.buildMergeSetup(options, models);
258
251
  const containerDrops = this.planContainerDrops(options, models, setup);
259
- const allEntityLines = [];
252
+ const allEntityLines = [], upgradeSeeds = new Set();
260
253
  const guidToFinalId = new Map();
261
- // First pass: count total entities for progress
262
254
  let totalEntities = 0;
263
255
  for (const model of models) {
264
256
  totalEntities += getCompleteEntityIndex(model.dataStore).size;
@@ -267,9 +259,9 @@ export class MergedExporter {
267
259
  let entitiesProcessed = 0;
268
260
  let federatedModelCount = 0;
269
261
  let normalizedModelCount = 0;
270
- const normalizeWarnings = new Set();
262
+ const normalizeWarnings = new Set(baked.warnings);
271
263
  const YIELD_INTERVAL = 2000;
272
- const [slotFill, ifc4Slots, enums] = [new Ifc2x3SlotFill(), new Ifc4SlotCheck(), new EnumReconciliation()]; // #4714, #5202, #5365
264
+ const [slotFill, ifc4Slots, enums] = [new Ifc2x3SlotFill(), new Ifc4SlotCheck(), new EnumReconciliation(true, models.map((m) => m.dataStore))]; // #4714, #5202, #5365
273
265
  if (onProgress)
274
266
  onProgress({ phase: 'preparing', percent: 0, entitiesProcessed: 0, entitiesTotal: totalEntities });
275
267
  for (const model of models) {
@@ -293,12 +285,12 @@ export class MergedExporter {
293
285
  federatedModelCount++;
294
286
  if (mode.normalized) {
295
287
  normalizedModelCount++;
296
- this.collectNormalizeCaveats(model, normalizeWarnings);
288
+ this.collectNormalizeCaveats(model, normalizeWarnings, mode.georef);
297
289
  }
298
- const plan = this.planModel(model, completeIndex, isFirstModel, mode.compatible, mode.lengthFactor, setup, guidToFinalId);
290
+ const plan = this.planModel(model, completeIndex, isFirstModel, mode.compatible, mode.lengthFactor, setup, guidToFinalId, schema);
299
291
  this.applyContainerDrops(plan, containerDrops?.byModel.get(model.id));
300
292
  this.claimParents(model, plan, visibility, completeIndex, !isFirstModel && mode.compatible, setup);
301
- const written = (id) => (visibility === null || visibility.included.has(id)) && !plan.skipEntityIds.has(id);
293
+ const written = armMergedModel(enums.materials, model.dataStore, (id) => (visibility === null || visibility.included.has(id)) && !plan.skipEntityIds.has(id), offset, plan.sharedRemap);
302
294
  if (schema === 'IFC2X3') {
303
295
  // @raw-entity-enumeration-ok async merge first bakes and reparses edited models into source snapshots
304
296
  slotFill.prefer(firstWrittenOwnerHistoryRef(model.dataStore.entityIndex.byType.get('IFCOWNERHISTORY'), written, offset));
@@ -311,8 +303,10 @@ export class MergedExporter {
311
303
  if (!written(expressId))
312
304
  continue;
313
305
  const line = this.renderEntity(expressId, entityRef, source, offset, plan, sourceSchema, schema, guidToFinalId, mode, visibility?.hiddenProductIds ?? null, completeIndex, visibility?.included ?? null, slotFill, ifc4Slots, enums, styleFlatten);
314
- if (line !== null)
306
+ if (line !== null) {
315
307
  allEntityLines.push(line);
308
+ noteUpgradeSeed(line, upgradeSeeds, sourceSchema, schema);
309
+ }
316
310
  entityCount++;
317
311
  entitiesProcessed++;
318
312
  // Yield to event loop every YIELD_INTERVAL entities
@@ -331,58 +325,19 @@ export class MergedExporter {
331
325
  }
332
326
  isFirstModel = false;
333
327
  }
334
- for (const warning of [...slotFill.warnings(), ...ifc4Slots.warnings(), ...enums.warnings(), ...applyInverseFolds(allEntityLines, setup.parentClaims)])
335
- normalizeWarnings.add(warning); // #5774 folds
336
- // Assembly phase
328
+ listKeptContexts(allEntityLines, setup.firstProjectIds.length ? setup.firstProjectIds[0] + setup.firstModelOffset : undefined, setup.keptContexts);
329
+ setup.minted.appendTo(allEntityLines);
330
+ enums.typedProperties.finish(allEntityLines, ifc4Slots, setup.nextAvailableId, enums.structural, Number.MAX_SAFE_INTEGER);
331
+ for (const warning of finishMergedConversion(allEntityLines, slotFill, ifc4Slots, enums, setup.parentClaims))
332
+ normalizeWarnings.add(warning);
333
+ for (const warning of pruneUpgrade(allEntityLines, upgradeSeeds, schema))
334
+ normalizeWarnings.add(warning);
337
335
  if (onProgress) {
338
336
  onProgress({ phase: 'assembling', percent: 0.9, entitiesProcessed: totalEntities, entitiesTotal: totalEntities });
339
337
  }
340
338
  await new Promise(r => setTimeout(r, 0));
341
339
  return { header, allEntityLines: placeObjectsForSchema(schema, allEntityLines), federatedModelCount, normalizedModelCount, normalizeWarnings, droppedContainerCount: containerDrops?.count ?? 0, totalEntities };
342
340
  }
343
- /**
344
- * Bake each model's pending edits into its source bytes before merging.
345
- *
346
- * A model with a non-empty {@link MergeModelInput.mutationView} is run through
347
- * {@link StepExporter} in its own source schema (mutations applied, geometry +
348
- * quantities kept), and the resulting bytes are re-parsed into a fresh data
349
- * store. The merge pipeline then sees the edited entities as ordinary source,
350
- * so unit-aware federation, GlobalId reconciliation and id offsetting are
351
- * unaffected. Models without edits pass through untouched (no export/parse cost).
352
- */
353
- async bakeMutatedModels() {
354
- const baked = [];
355
- let parser = null;
356
- for (const model of this.models) {
357
- if (!viewHasMutations(model.mutationView)) {
358
- baked.push(model);
359
- continue;
360
- }
361
- const sourceSchema = model.dataStore.schemaVersion || 'IFC4';
362
- // Export in the SOURCE schema so no schema conversion happens here — the
363
- // merge loop still converts to the requested target schema per entity.
364
- const exported = new StepExporter(model.dataStore, model.mutationView).export({
365
- schema: sourceSchema,
366
- applyMutations: true,
367
- includeGeometry: true,
368
- includeQuantities: true,
369
- });
370
- parser = parser ?? new IfcParser();
371
- // slice() yields an exact-length ArrayBuffer-backed copy for the parser.
372
- const reparsed = await parser.parseColumnar(exported.content.slice().buffer, {
373
- disableWorkerScan: true,
374
- });
375
- baked.push({
376
- id: model.id,
377
- name: model.name,
378
- dataStore: reparsed,
379
- // Keep the caller's explicit unit scale (else the original store's) so
380
- // unit-aware federation is unaffected by the bake round-trip.
381
- lengthUnitScale: model.lengthUnitScale ?? model.dataStore.lengthUnitScale,
382
- });
383
- }
384
- return baked;
385
- }
386
341
  /**
387
342
  * Assemble the result stats, including any federation conformance warnings.
388
343
  */
@@ -410,7 +365,7 @@ export class MergedExporter {
410
365
  if (!options.dropEmptyContainers)
411
366
  return null;
412
367
  const claims = new InverseClaims(options.schema || 'IFC4', isStructureRelation);
413
- const guids = new PlannerGuids(scale => this.unitsCompatible(scale, setup.primaryScale), isSpatialContainerType);
368
+ const guids = new PlannerGuids(scale => unitScalesEqual(scale, setup.primaryScale), isSpatialContainerType);
414
369
  const views = models.map((model, index) => {
415
370
  const source = model.dataStore.source;
416
371
  if (!source || source.length === 0)
@@ -424,8 +379,9 @@ export class MergedExporter {
424
379
  const visibility = this.computeIncludedEntityIds(model, options, entities, source);
425
380
  const claimParents = () => {
426
381
  const typeOf = (id) => entities.get(id).type.toUpperCase(); // GlobalId unification the emit pass is sure to repeat (#5937)
382
+ const from = model.dataStore.schemaVersion || 'IFC4', to = options.schema || 'IFC4';
427
383
  const unified = guids.plan({ guids: readLocalGuids(entities, source), typeOf, isFirst: index === 0, compatible: mode.compatible, offset: setup.modelOffsets.get(model.id),
428
- effectiveScale: mode.effectiveScale, isIncluded: id => visibility === null || visibility.included.has(id), keepsGuids: !needsConversion(model.dataStore.schemaVersion || 'IFC4', options.schema || 'IFC4'),
384
+ effectiveScale: mode.effectiveScale, isIncluded: id => visibility === null || visibility.included.has(id), keepsGuids: !needsConversion(from, to), canUnify: type => canUnifyConvertedType(type, from, to),
429
385
  unifiedEarlier: id => sharedRemap.has(id) || (index > 0 && mode.compatible && setup.firstProjectIds.length > 0 && typeOf(id) === 'IFCPROJECT') });
430
386
  const withheld = { sharedRemap: new Map([...sharedRemap, ...unified]), skipEntityIds: new Set(), relMemberStrip: new Map() };
431
387
  this.claimParents(model, withheld, visibility, entities, index > 0 && mode.compatible, setup, claims);
@@ -461,20 +417,18 @@ export class MergedExporter {
461
417
  * Record advisories for a model being normalized. The rescaler derives its
462
418
  * length-attribute map from the IFC4 schema registry, so it may not cover
463
419
  * length attributes introduced by newer schemas (IFC4X3 alignment / linear
464
- * referencing), and it deliberately leaves georeferencing untouched.
420
+ * referencing), and it keeps georeferencing offsets in the CRS unit (#10886).
465
421
  */
466
- collectNormalizeCaveats(model, warnings) {
467
- const schema = (model.dataStore.schemaVersion ?? '').toUpperCase();
422
+ collectNormalizeCaveats(model, warnings, georef) {
423
+ const schema = (model.dataStore.schemaVersion ?? '').toUpperCase(), label = mergeWarningLabel(model, this.models);
468
424
  if (NORMALIZE_UNCOVERED_SCHEMAS.has(schema)) {
469
- warnings.add(`Model "${model.name}" (${schema}) was normalized using the IFC4 length-attribute schema; ` +
425
+ warnings.add(`Model "${label}" (${schema}) was normalized using the IFC4 length-attribute schema; ` +
470
426
  `length values on ${schema}-specific entities (e.g. alignment / linear-referencing segment ` +
471
427
  `lengths and radii) may not have been rescaled. Verify infrastructure geometry.`);
472
428
  }
473
- if (this.findEntitiesByType(model.dataStore, 'IFCMAPCONVERSION').length > 0) {
474
- warnings.add(`Model "${model.name}" carries georeferencing (IfcMapConversion), which normalize leaves ` +
475
- `untouched. If the model was georeferenced in its own unit, review the merged coordinate ` +
476
- `operation.`);
477
- }
429
+ const georefCaveat = georefNormalizeCaveat(label, model.dataStore, georef);
430
+ if (georefCaveat)
431
+ warnings.add(georefCaveat);
478
432
  }
479
433
  /**
480
434
  * Compute the model-independent state shared by export()/exportAsync():
@@ -496,10 +450,12 @@ export class MergedExporter {
496
450
  const firstModelOffset = modelOffsets.get(firstModel.id);
497
451
  const firstModelInfraMap = this.findInfrastructureEntities(firstModel.dataStore);
498
452
  return {
499
- modelOffsets,
453
+ modelOffsets, nextAvailableId,
500
454
  firstModelOffset,
501
455
  firstModelInfraMap,
502
- firstModelContext: resolvePrimaryContextState(firstModel.dataStore, firstModelInfraMap.get('IFCGEOMETRICREPRESENTATIONSUBCONTEXT') ?? [], primaryScale),
456
+ firstModelContext: resolvePrimaryContextState(firstModel.dataStore, firstModelInfraMap.get('IFCGEOMETRICREPRESENTATIONSUBCONTEXT') ?? [], primaryScale, firstModelOffset),
457
+ keptContexts: [],
458
+ minted: new MintedRecords(nextAvailableId),
503
459
  firstProjectIds: this.findEntitiesByType(firstModel.dataStore, 'IFCPROJECT'),
504
460
  spatialLookup: this.buildSpatialLookup(firstModel.dataStore),
505
461
  parentClaims: new InverseClaims(options.schema || 'IFC4'),
@@ -532,7 +488,7 @@ export class MergedExporter {
532
488
  */
533
489
  resolveModelMode(model, isFirstModel, setup) {
534
490
  const modelScale = this.resolveUnitScale(model);
535
- if (isFirstModel || setup.assumeShared || this.unitsCompatible(modelScale, setup.primaryScale)) {
491
+ if (isFirstModel || setup.assumeShared || unitScalesEqual(modelScale, setup.primaryScale)) {
536
492
  return { compatible: true, lengthFactor: 1, areaFactor: 1, volumeFactor: 1, effectiveScale: modelScale, normalized: false };
537
493
  }
538
494
  if (setup.normalize) {
@@ -548,6 +504,7 @@ export class MergedExporter {
548
504
  volumeFactor: computeNormalizeFactor(modelVolume, setup.primaryVolumeScale),
549
505
  effectiveScale: setup.primaryScale,
550
506
  normalized: true,
507
+ georef: planGeorefNormalize(model.dataStore, setup.minted, modelScale, setup.primaryScale),
551
508
  };
552
509
  }
553
510
  // auto: federate the differing-unit model, coordinates untouched.
@@ -631,15 +588,6 @@ export class MergedExporter {
631
588
  return fromStore;
632
589
  return 1.0;
633
590
  }
634
- /** True when two length unit scales are equal within relative tolerance. */
635
- unitsCompatible(a, b) {
636
- if (a === b)
637
- return true;
638
- const max = Math.max(Math.abs(a), Math.abs(b));
639
- if (max === 0)
640
- return true;
641
- return Math.abs(a - b) <= max * UNIT_SCALE_TOLERANCE;
642
- }
643
591
  /**
644
592
  * Resolve the set of express ids to include for a model under visibility
645
593
  * filtering, or `null` when no filtering is requested (include everything).
@@ -685,25 +633,29 @@ export class MergedExporter {
685
633
  * deterministic GlobalId, since the two cannot be the same instance across
686
634
  * different unit spaces.
687
635
  */
688
- planModel(model, completeIndex, isFirstModel, compatible, lengthFactor, setup, guidToFinalId) {
636
+ planModel(model, completeIndex, isFirstModel, compatible, lengthFactor, setup, guidToFinalId, targetSchema) {
689
637
  const source = model.dataStore.source;
690
638
  const sharedRemap = new Map();
691
639
  const skipEntityIds = new Set();
692
- const guidRewrite = new Map();
640
+ const sourceSchema = model.dataStore.schemaVersion || 'IFC4';
693
641
  const relMemberStrip = new Map();
694
642
  // One cheap pass to read each rooted entity's GlobalId (first attribute).
695
643
  const localGuids = readLocalGuids(completeIndex, source);
696
644
  if (!isFirstModel && compatible) {
697
645
  // Remap this model's IfcProject references → first model's IfcProject.
698
646
  const projectIds = this.findEntitiesByType(model.dataStore, 'IFCPROJECT');
699
- if (setup.firstProjectIds.length > 0) {
647
+ const folded = setup.firstProjectIds.length > 0; // a federated (incompatible) model never gets here and keeps its project
648
+ if (folded) {
700
649
  for (const pid of projectIds) {
701
650
  sharedRemap.set(pid, setup.firstProjectIds[0] + setup.firstModelOffset);
702
651
  skipEntityIds.add(pid);
703
652
  }
704
653
  }
705
654
  // Remap and skip duplicate infrastructure (units, contexts) — WCS-gated; scale choice documented on planInfrastructureUnify (merged-context.ts).
706
- planInfrastructureUnify(model.dataStore, this.findInfrastructureEntities(model.dataStore), setup.firstModelInfraMap, setup.firstModelContext, setup.firstModelOffset, setup.assumeShared ? setup.primaryScale : this.resolveUnitScale(model), sharedRemap, skipEntityIds);
655
+ const offset = setup.modelOffsets.get(model.id);
656
+ const kept = planInfrastructureUnify(model.dataStore, this.findInfrastructureEntities(model.dataStore), setup.firstModelInfraMap, setup.firstModelContext, setup.firstModelOffset, setup.assumeShared ? setup.primaryScale : this.resolveUnitScale(model), sharedRemap, skipEntityIds, offset);
657
+ if (folded)
658
+ setup.keptContexts.push(...kept.map(id => id + offset)); // its project folded above
707
659
  // Unify spatial hierarchy: match Site, Building, Storey to first model.
708
660
  // Under normalize, this model's raw elevations are in its own unit, so the
709
661
  // elevation match is done in the primary unit (rawElevation * lengthFactor).
@@ -711,35 +663,24 @@ export class MergedExporter {
711
663
  }
712
664
  if (!isFirstModel) {
713
665
  // GlobalId reconciliation against everything emitted by earlier models.
714
- const pendingMinted = new Set();
715
666
  for (const [id, guid] of localGuids) {
716
667
  if (skipEntityIds.has(id))
717
668
  continue; // already unified/deduped above
718
669
  const prior = guidToFinalId.get(guid);
719
670
  if (prior === undefined)
720
671
  continue; // first occurrence — kept as-is
721
- // Unify (drop + remap refs to the one instance) ONLY when this is a
722
- // physical/spatial root AND both this model and the emitter share the
723
- // primary unit. Two conditions force "keep + re-stamp" instead:
724
- // - Objectified relationships (IfcRel*): same GlobalId does not imply
725
- // the same membership (e.g. a storey-containment listing different
726
- // elements per discipline), so dropping one would orphan elements.
727
- // - The colliding instance was emitted in a different unit space
728
- // (a federated model), so unifying would reinterpret coordinates —
729
- // the very mis-scale this fix prevents, reached transitively.
672
+ // Both roots must share the primary unit. Keep and re-stamp collisions
673
+ // with relationships or generic proxies, which cannot replace a root.
730
674
  const type = (completeIndex.get(id)?.type ?? '').toUpperCase();
731
- const emitterIsPrimaryUnit = this.unitsCompatible(prior.scale, setup.primaryScale);
732
- const canUnify = compatible && emitterIsPrimaryUnit && !isRelationshipType(type);
675
+ const emitterIsPrimaryUnit = unitScalesEqual(prior.scale, setup.primaryScale);
676
+ const canUnify = compatible && emitterIsPrimaryUnit && prior.canUnify && canUnifyConvertedType(type, sourceSchema, targetSchema);
733
677
  if (canUnify) {
734
678
  sharedRemap.set(id, prior.finalId);
735
679
  skipEntityIds.add(id);
736
680
  }
737
- else {
738
- guidRewrite.set(id, mintUniqueGuid(guid, model.id, guidToFinalId, pendingMinted));
739
- }
740
681
  }
741
682
  }
742
- return { sharedRemap, skipEntityIds, guidRewrite, localGuids, relMemberStrip };
683
+ return { sharedRemap, skipEntityIds, modelId: model.id, localGuids, relMemberStrip };
743
684
  }
744
685
  /**
745
686
  * Render one source entity into its final STEP line: apply id offset + shared
@@ -750,7 +691,7 @@ export class MergedExporter {
750
691
  * entity: an untranslatable one becomes an IFCPROXY or throws.
751
692
  */
752
693
  renderEntity(localId, entityRef, source, offset, plan, sourceSchema, targetSchema, guidToFinalId, mode, hiddenProductIds, completeIndex, includedIds, slotFill, ifc4Slots, enums, styles) {
753
- let entityText = decodeRange(source, entityRef.byteOffset, entityRef.byteOffset + entityRef.byteLength);
694
+ let entityText = decodeTypedPropertyRecord(source, entityRef, sourceSchema, targetSchema);
754
695
  // D57 style-assignment flatten, in LOCAL id space (before the remap).
755
696
  if (styles && (entityText = styles.apply(entityText) ?? '') === '')
756
697
  return null;
@@ -805,51 +746,44 @@ export class MergedExporter {
805
746
  if (stripped === null)
806
747
  return null;
807
748
  entityText = stripped;
808
- // Remap ids. Fast path: the first model (offset 0, no remaps) is byte-identical.
809
- let finalText;
810
- if (offset === 0 && plan.sharedRemap.size === 0) {
811
- finalText = entityText;
812
- }
813
- else {
814
- finalText = remapEntityText(entityText, offset, plan.sharedRemap);
815
- }
816
- // Re-stamp the GlobalId for a federated entity whose id collides.
817
- const mintedGuid = plan.guidRewrite.get(localId);
818
- if (mintedGuid !== undefined) {
819
- finalText = replaceGlobalId(finalText, mintedGuid);
749
+ const converting = needsConversion(sourceSchema, targetSchema);
750
+ const remapIds = offset !== 0 || plan.sharedRemap.size !== 0;
751
+ let finalText = remapIds ? remapEntityText(entityText, offset, plan.sharedRemap, converting) : entityText;
752
+ // Normalize in the source schema while its attribute indices still match the record.
753
+ // Only numeric literals and the georeference (#10886) change here.
754
+ const georef = normalizeGeorefRecord(finalText, localId, mode.georef);
755
+ if (georef !== undefined)
756
+ finalText = georef;
757
+ else if (mode.lengthFactor !== 1 || mode.areaFactor !== 1 || mode.volumeFactor !== 1) {
758
+ const type = entityRef.type.toUpperCase();
759
+ const legacySchema = isTypedPropertyUpgrade(type, sourceSchema, targetSchema) ? 'IFC2X3' : undefined;
760
+ finalText = rescaleEntityLengths(finalText, type, mode.lengthFactor, mode.areaFactor, mode.volumeFactor, legacySchema);
820
761
  }
821
- // Normalize units: rescale every length/area/volume-valued datum into the
822
- // primary unit. Done on the SOURCE-schema text (entityRef.type), before any
823
- // schema conversion, so the schema-derived attribute indices line up. Touches
824
- // only numeric literals, so id remaps and the GlobalId re-stamp above are safe.
825
- if (mode.lengthFactor !== 1 || mode.areaFactor !== 1 || mode.volumeFactor !== 1) {
826
- finalText = rescaleEntityLengths(finalText, entityRef.type.toUpperCase(), mode.lengthFactor, mode.areaFactor, mode.volumeFactor);
827
- }
828
- if (needsConversion(sourceSchema, targetSchema)) {
829
- // No `withheldRefIds` passed (6th arg omitted), so `resolveUnrepresentedEntity`
830
- // never takes its `allowOmit` branch here — this call cannot return `null`
831
- // (#4206). The federated pipeline does not yet compute that set in its own
832
- // offset/remapped id space, so it keeps this function's older, unconditional
833
- // "proxy or throw" contract rather than risk a wrong omission in the wrong
834
- // id space; the same LoadConfiguration/AppliedLoad case that would omit in
835
- // `StepExporter` still throws here, unchanged from before this fix.
836
- const converted = convertStepLine(finalText, sourceSchema, targetSchema, undefined, slotFill, undefined, ifc4Slots, enums);
762
+ if (converting) {
763
+ // No `withheldRefIds` (6th arg), so `resolveUnrepresentedEntity` never omits here (#4206): the federated
764
+ // pipeline has no such set in its offset id space, and keeps "proxy or throw" rather than omit in the
765
+ // wrong space. The only `null` is a material record the referent check left out (#10763); any other
766
+ // still throws, as the LoadConfiguration/AppliedLoad case `StepExporter` would omit does.
767
+ const converted = convertStepLine(finalText, sourceSchema, targetSchema, undefined, slotFill, undefined, ifc4Slots, enums, remapIds ? Number.MAX_SAFE_INTEGER : undefined);
837
768
  if (converted === null) {
769
+ if (enums.materials.leftOut(localId + offset))
770
+ return null; // a material record not written (#10763)
838
771
  throw new Error(`Internal error: schema conversion of #${localId + offset}=${entityRef.type} returned null with no withheldRefIds supplied.`);
839
772
  }
840
773
  finalText = converted;
841
774
  }
842
- // Record the emitted GlobalId → final express id + unit scale, for rooted
843
- // entities only. Read it from the FINAL line, not the source: schema
844
- // conversion can replace an unsupported rooted type with an IFCPROXY that
845
- // carries a freshly-minted GlobalId, so the source guid would be stale.
846
- // Emitted entities are not sharedRemap keys, so their final id is
847
- // localId + offset.
848
- if (plan.localGuids.has(localId)) {
849
- const emittedGuid = readLeadingGuid(finalText)
850
- ?? mintedGuid ?? plan.localGuids.get(localId);
851
- if (emittedGuid !== undefined) {
852
- guidToFinalId.set(emittedGuid, { finalId: localId + offset, scale: mode.effectiveScale });
775
+ // Only an actual collision in the final output needs a re-stamp.
776
+ if (plan.localGuids.has(localId) || (converting && isRootedType(entityRef.type))) {
777
+ let emittedGuid = readLeadingGuid(finalText);
778
+ if (emittedGuid !== null) {
779
+ if (guidToFinalId.has(emittedGuid)) {
780
+ emittedGuid = mintUniqueGuid(emittedGuid, plan.modelId, guidToFinalId, new Set());
781
+ finalText = replaceGlobalId(finalText, emittedGuid);
782
+ }
783
+ guidToFinalId.set(emittedGuid, {
784
+ finalId: localId + offset, scale: mode.effectiveScale,
785
+ canUnify: canUnifyEmittedRecord((entityRef.type ?? '').toUpperCase(), converting ? finalText : undefined),
786
+ });
853
787
  }
854
788
  }
855
789
  return finalText;