@ifc-lite/export 4.8.0 → 4.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/affected-set.d.ts +9 -0
- package/dist/affected-set.d.ts.map +1 -0
- package/dist/affected-set.js +72 -0
- package/dist/affected-set.js.map +1 -0
- package/dist/declared-property-type.d.ts +7 -0
- package/dist/declared-property-type.d.ts.map +1 -1
- package/dist/declared-property-type.js +26 -0
- package/dist/declared-property-type.js.map +1 -1
- package/dist/edit-ownership.d.ts +7 -0
- package/dist/edit-ownership.d.ts.map +1 -0
- package/dist/edit-ownership.js +95 -0
- package/dist/edit-ownership.js.map +1 -0
- package/dist/entity-subgraph.d.ts +11 -3
- package/dist/entity-subgraph.d.ts.map +1 -1
- package/dist/entity-subgraph.js +54 -11
- package/dist/entity-subgraph.js.map +1 -1
- package/dist/grid-placement-dependents.d.ts +4 -0
- package/dist/grid-placement-dependents.d.ts.map +1 -0
- package/dist/grid-placement-dependents.js +71 -0
- package/dist/grid-placement-dependents.js.map +1 -0
- package/dist/grid-reference-context.d.ts +6 -0
- package/dist/grid-reference-context.d.ts.map +1 -0
- package/dist/grid-reference-context.js +68 -0
- package/dist/grid-reference-context.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/step-coordinate-options.d.ts +35 -0
- package/dist/step-coordinate-options.d.ts.map +1 -0
- package/dist/step-coordinate-options.js +5 -0
- package/dist/step-coordinate-options.js.map +1 -0
- package/dist/step-export-progress.d.ts +4 -0
- package/dist/step-export-progress.d.ts.map +1 -0
- package/dist/step-export-progress.js +9 -0
- package/dist/step-export-progress.js.map +1 -0
- package/dist/step-export-types.d.ts +7 -7
- package/dist/step-export-types.d.ts.map +1 -1
- package/dist/step-export-types.js.map +1 -1
- package/dist/step-exporter.d.ts +1 -0
- package/dist/step-exporter.d.ts.map +1 -1
- package/dist/step-exporter.js +31 -18
- package/dist/step-exporter.js.map +1 -1
- package/dist/step-map-transform.d.ts +7 -0
- package/dist/step-map-transform.d.ts.map +1 -0
- package/dist/step-map-transform.js +89 -0
- package/dist/step-map-transform.js.map +1 -0
- package/dist/step-map-unit-normalization.d.ts +5 -0
- package/dist/step-map-unit-normalization.d.ts.map +1 -0
- package/dist/step-map-unit-normalization.js +194 -0
- package/dist/step-map-unit-normalization.js.map +1 -0
- package/dist/step-map-unit.d.ts +3 -78
- package/dist/step-map-unit.d.ts.map +1 -1
- package/dist/step-map-unit.js +33 -195
- package/dist/step-map-unit.js.map +1 -1
- package/dist/step-native-set-record.d.ts +6 -0
- package/dist/step-native-set-record.d.ts.map +1 -0
- package/dist/step-native-set-record.js +30 -0
- package/dist/step-native-set-record.js.map +1 -0
- package/dist/step-pass-builder.d.ts.map +1 -1
- package/dist/step-pass-builder.js +2 -0
- package/dist/step-pass-builder.js.map +1 -1
- package/dist/step-property-set-collection.d.ts.map +1 -1
- package/dist/step-property-set-collection.js +24 -8
- package/dist/step-property-set-collection.js.map +1 -1
- package/dist/step-property-set-generators.d.ts +8 -2
- package/dist/step-property-set-generators.d.ts.map +1 -1
- package/dist/step-property-set-generators.js +26 -10
- package/dist/step-property-set-generators.js.map +1 -1
- package/dist/step-property-set-readers.d.ts.map +1 -1
- package/dist/step-property-set-readers.js +15 -0
- package/dist/step-property-set-readers.js.map +1 -1
- package/dist/step-property-sets.d.ts +3 -4
- package/dist/step-property-sets.d.ts.map +1 -1
- package/dist/step-property-sets.js +61 -19
- package/dist/step-property-sets.js.map +1 -1
- package/dist/step-type-owned-quantities.d.ts +34 -0
- package/dist/step-type-owned-quantities.d.ts.map +1 -0
- package/dist/step-type-owned-quantities.js +222 -0
- package/dist/step-type-owned-quantities.js.map +1 -0
- package/dist/step-vertical-datum-normalization.d.ts +17 -0
- package/dist/step-vertical-datum-normalization.d.ts.map +1 -0
- package/dist/step-vertical-datum-normalization.js +52 -0
- package/dist/step-vertical-datum-normalization.js.map +1 -0
- package/package.json +9 -8
|
@@ -0,0 +1,194 @@
|
|
|
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
|
+
import { SCHEMA_REGISTRY, SI_PREFIX_MULTIPLIERS } from '@ifc-lite/parser';
|
|
5
|
+
import { readStepSlots, splitTopLevelListItems } from './step-argument-parser.js';
|
|
6
|
+
import { attrIndex, stepSourceSchema } from './subset-entity-reader.js';
|
|
7
|
+
import { resolveExpressBase, toStepReal } from './step-serialization.js';
|
|
8
|
+
import { normalizeVerticalDatumToEgm2008, recordGeoreferencingEdit } from './step-vertical-datum-normalization.js';
|
|
9
|
+
const ref = (token) => token?.match(/^#([0-9]+)$/) ? Number(token.slice(1)) : undefined;
|
|
10
|
+
// Slots keep authored whitespace: `IFCSIUNIT(*, .LENGTHUNIT., $, .METRE.)` is valid STEP.
|
|
11
|
+
const enumeration = (token) => token?.trim().replaceAll('.', '').toUpperCase() ?? '';
|
|
12
|
+
const real = (token) => token !== undefined && /^[+-]?[0-9]+\.[0-9]*(?:E[+-]?[0-9]+)?$/i.test(token) ? Number(token) : NaN;
|
|
13
|
+
const definedTypes = new Map(Object.keys(SCHEMA_REGISTRY.types).map(name => [name.toUpperCase(), name]));
|
|
14
|
+
const maps = new Set(['IFCMAPCONVERSION', 'IFCMAPCONVERSIONSCALED']);
|
|
15
|
+
/** Opt-in coordinate metadata phases on the emitted model, before Rust planning. */
|
|
16
|
+
export function normalizeCoordinateMetadata(pass, options, allocateId) {
|
|
17
|
+
if (options.normalizeMapUnitsToMetres)
|
|
18
|
+
normalizeMapUnitsToMetres(pass, allocateId);
|
|
19
|
+
if (options.normalizeVerticalDatumToEgm2008)
|
|
20
|
+
normalizeVerticalDatumToEgm2008(pass);
|
|
21
|
+
}
|
|
22
|
+
/** Normalize the *emitted* model, after named/positional/created-entity edits.
|
|
23
|
+
* Never rewrite a shared project unit. Each CRS and all its operations change
|
|
24
|
+
* atomically; a refusal leaves that CRS byte-identical and is reported (#6587).
|
|
25
|
+
*/
|
|
26
|
+
function normalizeMapUnitsToMetres(pass, allocateId) {
|
|
27
|
+
const records = new Map();
|
|
28
|
+
const operations = new Map();
|
|
29
|
+
let unreadableOperation = false;
|
|
30
|
+
const schema = stepSourceSchema(pass.sourceSchema);
|
|
31
|
+
for (let index = 0; index < pass.entities.length; index++) {
|
|
32
|
+
const line = pass.entities[index];
|
|
33
|
+
const prefix = /^#([0-9]+)\s*=\s*(\w+)/.exec(line);
|
|
34
|
+
if (!prefix)
|
|
35
|
+
continue;
|
|
36
|
+
const type = prefix[2].toUpperCase();
|
|
37
|
+
const targetSlot = attrIndex(type, 'TargetCRS', schema);
|
|
38
|
+
if (targetSlot < 0 && !['IFCSIUNIT', 'IFCCONVERSIONBASEDUNIT', 'IFCMEASUREWITHUNIT', 'IFCPROJECTEDCRS', 'IFCPROJECT', 'IFCUNITASSIGNMENT', 'IFCWELLKNOWNTEXT'].includes(type))
|
|
39
|
+
continue;
|
|
40
|
+
const record = readStepSlots(line);
|
|
41
|
+
if (!record) {
|
|
42
|
+
if (targetSlot >= 0)
|
|
43
|
+
unreadableOperation = true;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const entry = { id: Number(prefix[1]), index, record };
|
|
47
|
+
records.set(entry.id, entry);
|
|
48
|
+
if (targetSlot >= 0) {
|
|
49
|
+
const target = ref(record.slots[targetSlot]?.trim());
|
|
50
|
+
if (target !== undefined) {
|
|
51
|
+
const list = operations.get(target) ?? [];
|
|
52
|
+
list.push(entry);
|
|
53
|
+
operations.set(target, list);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
let metreId = [...records.values()].find(({ record }) => record.type === 'IFCSIUNIT'
|
|
58
|
+
&& enumeration(record.slots[1]) === 'LENGTHUNIT' && record.slots[2]?.trim() === '$'
|
|
59
|
+
&& enumeration(record.slots[3]) === 'METRE')?.id;
|
|
60
|
+
const warn = (id, reason) => {
|
|
61
|
+
const message = `Cannot normalize IfcProjectedCRS #${id} map units to metres: ${reason}. Its map units and coordinate operations were preserved.`;
|
|
62
|
+
pass.warnings.push(message);
|
|
63
|
+
console.warn(`[StepExporter] ${message}`);
|
|
64
|
+
};
|
|
65
|
+
for (const target of operations.keys()) {
|
|
66
|
+
if (records.get(target)?.record.type !== 'IFCPROJECTEDCRS') {
|
|
67
|
+
warn(target, 'the target is not a retained IfcProjectedCRS');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const crs of records.values()) {
|
|
71
|
+
if (crs.record.type !== 'IFCPROJECTEDCRS')
|
|
72
|
+
continue;
|
|
73
|
+
const consumers = operations.get(crs.id) ?? [];
|
|
74
|
+
if (unreadableOperation) {
|
|
75
|
+
warn(crs.id, 'a retained coordinate operation cannot be parsed safely');
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (!consumers.length)
|
|
79
|
+
continue;
|
|
80
|
+
const name = crs.record.slots[0]?.trim() ?? '';
|
|
81
|
+
if (/^'[A-Z_]+\s*\[/i.test(name)
|
|
82
|
+
|| [...records.values()].some(({ record }) => record.type === 'IFCWELLKNOWNTEXT' && ref(record.slots[1]?.trim()) === crs.id)) {
|
|
83
|
+
warn(crs.id, 'a retained WKT definition may declare its own coordinate units');
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const authoredUnit = crs.record.slots[6]?.trim();
|
|
87
|
+
const unitId = authoredUnit === '$' ? projectUnitForContexts(consumers, records, schema) : ref(authoredUnit);
|
|
88
|
+
const factor = unitId === undefined ? undefined : lengthUnitFactor(unitId, records);
|
|
89
|
+
if (factor === undefined) {
|
|
90
|
+
warn(crs.id, 'the applicable length unit is missing, ambiguous, or unsupported');
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (factor === 1)
|
|
94
|
+
continue;
|
|
95
|
+
if (consumers.some(({ record }) => !maps.has(record.type))) {
|
|
96
|
+
warn(crs.id, 'a retained coordinate operation is not an IfcMapConversion');
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const replacements = new Map();
|
|
100
|
+
for (const operation of consumers) {
|
|
101
|
+
const slots = operation.record.slots.map(token => token.trim());
|
|
102
|
+
const values = [2, 3, 4, 7].map(index => index === 7 && slots[index] === '$' ? 1 : real(slots[index]));
|
|
103
|
+
if (slots.length < 8 || values.some(value => !Number.isFinite(value))
|
|
104
|
+
|| values[3] <= 0 || values.some(value => !Number.isFinite(value * factor))
|
|
105
|
+
|| values[3] * factor <= 0)
|
|
106
|
+
break;
|
|
107
|
+
[2, 3, 4, 7].forEach((index, position) => { slots[index] = toStepReal(values[position] * factor); });
|
|
108
|
+
replacements.set(operation, slots);
|
|
109
|
+
}
|
|
110
|
+
if (replacements.size !== consumers.length) {
|
|
111
|
+
warn(crs.id, 'a coordinate operation has invalid offsets or scale');
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (metreId === undefined) {
|
|
115
|
+
metreId = allocateId();
|
|
116
|
+
pass.entities.push(`#${metreId}=IFCSIUNIT(*,.LENGTHUNIT.,$,.METRE.);`);
|
|
117
|
+
pass.newEntityCount++;
|
|
118
|
+
}
|
|
119
|
+
const slots = crs.record.slots.map(token => token.trim());
|
|
120
|
+
slots[6] = `#${metreId}`;
|
|
121
|
+
replacements.set(crs, slots);
|
|
122
|
+
for (const [entry, updated] of replacements) {
|
|
123
|
+
pass.entities[entry.index] = `${entry.record.prefix}${updated.join(',')}${entry.record.suffix}`;
|
|
124
|
+
recordGeoreferencingEdit(pass, entry.id);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** Bounded, iterative conversion-factor walk; no implicit metre fallback. */
|
|
129
|
+
function lengthUnitFactor(id, records) {
|
|
130
|
+
const visited = new Set();
|
|
131
|
+
let factor = 1;
|
|
132
|
+
let current = id;
|
|
133
|
+
while (current !== undefined && !visited.has(current) && visited.size <= records.size) {
|
|
134
|
+
visited.add(current);
|
|
135
|
+
const record = records.get(current)?.record;
|
|
136
|
+
if (!record || enumeration(record.slots[1]) !== 'LENGTHUNIT')
|
|
137
|
+
return undefined;
|
|
138
|
+
if (record.type === 'IFCSIUNIT') {
|
|
139
|
+
if (enumeration(record.slots[3]) !== 'METRE')
|
|
140
|
+
return undefined;
|
|
141
|
+
const prefix = record.slots[2]?.trim();
|
|
142
|
+
const multiplier = prefix === '$' ? 1 : SI_PREFIX_MULTIPLIERS[enumeration(prefix)];
|
|
143
|
+
const result = factor * multiplier;
|
|
144
|
+
return Number.isFinite(result) && result > 0 ? result : undefined;
|
|
145
|
+
}
|
|
146
|
+
if (record.type !== 'IFCCONVERSIONBASEDUNIT')
|
|
147
|
+
return undefined;
|
|
148
|
+
const measure = records.get(ref(record.slots[3]?.trim()) ?? -1)?.record;
|
|
149
|
+
if (measure?.type !== 'IFCMEASUREWITHUNIT')
|
|
150
|
+
return undefined;
|
|
151
|
+
const value = measure.slots[0]?.trim();
|
|
152
|
+
const typed = /^([A-Z][A-Z0-9_]*)\(([^()]+)\)$/i.exec(value ?? '');
|
|
153
|
+
const base = typed ? resolveExpressBase(definedTypes.get(typed[1].toUpperCase()) ?? typed[1]) : 'REAL';
|
|
154
|
+
const token = typed ? typed[2] : value;
|
|
155
|
+
const scale = base === 'REAL' || base === 'NUMBER' ? real(token)
|
|
156
|
+
: base === 'INTEGER' && token !== undefined && /^[+-]?[0-9]+$/.test(token) ? Number(token) : NaN;
|
|
157
|
+
if (!Number.isFinite(scale) || scale <= 0)
|
|
158
|
+
return undefined;
|
|
159
|
+
factor *= scale;
|
|
160
|
+
if (!Number.isFinite(factor) || factor <= 0)
|
|
161
|
+
return undefined;
|
|
162
|
+
current = ref(measure.slots[1]?.trim());
|
|
163
|
+
}
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
/** Missing MapUnit inherits its SourceCRS project's length unit. Every
|
|
167
|
+
* operation sharing this CRS must resolve to the same declared unit factor.
|
|
168
|
+
* Contexts are matched through IfcProject.RepresentationContexts, not the
|
|
169
|
+
* first project in a federated file. Ambiguous owners are refused.
|
|
170
|
+
*/
|
|
171
|
+
function projectUnitForContexts(consumers, records, schema) {
|
|
172
|
+
let chosen;
|
|
173
|
+
for (const consumer of consumers) {
|
|
174
|
+
const context = ref(consumer.record.slots[0]?.trim());
|
|
175
|
+
const owners = [...records.values()].filter(({ record }) => record.type === 'IFCPROJECT'
|
|
176
|
+
&& splitTopLevelListItems(record.slots[attrIndex('IFCPROJECT', 'RepresentationContexts', schema)]?.trim().slice(1, -1) ?? '')
|
|
177
|
+
.some(token => ref(token.trim()) === context));
|
|
178
|
+
if (context === undefined || owners.length !== 1)
|
|
179
|
+
return undefined;
|
|
180
|
+
const assignment = records.get(ref(owners[0].record.slots[attrIndex('IFCPROJECT', 'UnitsInContext', schema)]?.trim()) ?? -1)?.record;
|
|
181
|
+
if (assignment?.type !== 'IFCUNITASSIGNMENT')
|
|
182
|
+
return undefined;
|
|
183
|
+
const units = splitTopLevelListItems(assignment.slots[0]?.trim().slice(1, -1) ?? '')
|
|
184
|
+
.map(token => ref(token.trim())).filter((id) => id !== undefined
|
|
185
|
+
&& enumeration(records.get(id)?.record.slots[1]) === 'LENGTHUNIT');
|
|
186
|
+
if (units.length !== 1)
|
|
187
|
+
return undefined;
|
|
188
|
+
if (chosen !== undefined && lengthUnitFactor(chosen, records) !== lengthUnitFactor(units[0], records))
|
|
189
|
+
return undefined;
|
|
190
|
+
chosen = units[0];
|
|
191
|
+
}
|
|
192
|
+
return chosen;
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=step-map-unit-normalization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-map-unit-normalization.js","sourceRoot":"","sources":["../src/step-map-unit-normalization.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,OAAO,EAAE,eAAe,EAAE,qBAA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|
@@ -1,31 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Map-unit resolution for the georeferencing phase: the `IfcNamedUnit` an
|
|
3
|
-
* `IfcProjectedCRS.MapUnit` points at, and the reuse-or-synthesise decision
|
|
4
|
-
* behind it.
|
|
5
|
-
*
|
|
6
|
-
* Split out of `step-georeferencing.ts` in #3274 rather than grown in place —
|
|
7
|
-
* the question it answers is a different one from "which georeferencing
|
|
8
|
-
* entities does this export write", it has a second caller in
|
|
9
|
-
* `step-property-sets.ts` (property units reach `findLengthUnitReference`
|
|
10
|
-
* through `findUnitId`), and raising the module-size budget instead would have
|
|
11
|
-
* wanted a per-file justification in the PR; a split does not.
|
|
12
|
-
*
|
|
13
|
-
* THE RULE THIS MODULE EXISTS TO KEEP: a unit name is compared WHOLE. The
|
|
14
|
-
* defect it was extracted for was a substring test — `normalized.includes('METRE')`
|
|
15
|
-
* — which `MILLIMETRE`, `CENTIMETRE` and `KILOMETRE` all satisfy, so every one
|
|
16
|
-
* of them was written into the file as a plain `.METRE.`. The map unit is the
|
|
17
|
-
* scale of the entire coordinate reference system, so that is a silent 1000x
|
|
18
|
-
* error in the one attribute another team uses to place the model on the
|
|
19
|
-
* earth, and it is invisible in the output: a millimetre request produced
|
|
20
|
-
* bytes identical to a metre request.
|
|
21
|
-
*
|
|
22
|
-
* And a unit this module cannot express is REFUSED, not approximated.
|
|
23
|
-
* `IfcProjectedCRS.MapUnit` is `OPTIONAL IfcNamedUnit` with
|
|
24
|
-
* `IsLengthUnit : NOT(EXISTS(MapUnit)) OR (MapUnit.UnitType = LENGTHUNIT)`, so
|
|
25
|
-
* an absent MapUnit is schema-valid; a MapUnit naming the wrong unit is not
|
|
26
|
-
* merely lossy, it is false, and nothing downstream can tell it from a true
|
|
27
|
-
* one.
|
|
28
|
-
*/
|
|
1
|
+
export { normalizeMapUnitName } from '@ifc-lite/parser';
|
|
29
2
|
import type { EffectiveEntityIndex } from './effective-index.js';
|
|
30
3
|
import type { GeorefContext, GeorefLookupContext } from './step-georeferencing.js';
|
|
31
4
|
/**
|
|
@@ -37,55 +10,7 @@ export declare function mapUnitUnsupportedWarning(unitName: string): string;
|
|
|
37
10
|
/** Record a map unit the exporter refused to guess at. */
|
|
38
11
|
export declare function reportMapUnitUnsupported(warnings: string[], unitName: string): void;
|
|
39
12
|
export declare function resolveMapUnitReference(unitName: string, newGeorefLines: string[], effective: EffectiveEntityIndex, ctx: GeorefContext): number | null;
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* compares against: American `METER` to `METRE`, the foot spellings to `FOOT`,
|
|
43
|
-
* the US survey foot to `US SURVEY FOOT`, and an SI prefix kept rather than
|
|
44
|
-
* swallowed. Anything not recognised is returned normalised-but-unchanged, for
|
|
45
|
-
* the caller to REFUSE rather than guess at.
|
|
46
|
-
*
|
|
47
|
-
* The label is NORMALISED and then matched EXACTLY — never substring-matched.
|
|
48
|
-
*
|
|
49
|
-
* What the normalisation accepts:
|
|
50
|
-
* - any case and any separators: `metres`, `Meters`, `MILLI-METRE`;
|
|
51
|
-
* - `METRE` and `METER`, each carrying any `IfcSIPrefix` member;
|
|
52
|
-
* - `FOOT` and `FEET`;
|
|
53
|
-
* - one English plural suffix, stripped once and re-matched exactly;
|
|
54
|
-
* - the US survey foot, glued or separated in any word order.
|
|
55
|
-
*
|
|
56
|
-
* What it REFUSES, by leaving the label alone so `resolveMapUnitReference`
|
|
57
|
-
* returns `null` and `MapUnit` stays `$` with a warning:
|
|
58
|
-
* - a label that merely CONTAINS a unit. `MILLIMETRE`, `CENTIMETRE` and
|
|
59
|
-
* `KILOMETRE` all contain `METRE`, and an `includes('METRE')` test wrote all
|
|
60
|
-
* three into the file as a plain `.METRE.` — a silent 1000x error in the CRS
|
|
61
|
-
* scale (#3274). The foot half of that same test was `includes('FOOT')`, and
|
|
62
|
-
* it was satisfied by `FOOTCANDLE` (an illuminance), `FOOT-POUND` (an
|
|
63
|
-
* energy), `FOOTPRINT`, and by `SQUARE FOOT` and `CUBIC FEET` — an area and
|
|
64
|
-
* a volume written as a LENGTH unit, which is a wrong DIMENSION rather than
|
|
65
|
-
* a wrong magnitude, and no scale factor can be right for it;
|
|
66
|
-
* - a survey foot with no nationality: `SURVEY FOOT`, `CLARKE'S FOOT`,
|
|
67
|
-
* `INDIAN FOOT`, `SEARS FOOT`, `BRITISH FOOT (1936)` are five different
|
|
68
|
-
* ratios, and `includes('FOOT')` gave every one of them the international
|
|
69
|
-
* 0.3048;
|
|
70
|
-
* - `INCH`, `YARD`, `MILE` and anything else this exporter cannot express.
|
|
71
|
-
*
|
|
72
|
-
* Normalising a recognisable spelling onto a table entry is NOT that
|
|
73
|
-
* approximation: the answer is still one exact table hit, so `MILLIMETERS`
|
|
74
|
-
* resolves to `MILLIMETRE` and not to `METRE`.
|
|
75
|
-
*
|
|
76
|
-
* Sibling of `inferMapUnitScaleFromLabel` in
|
|
77
|
-
* packages/parser/src/map-unit-label.ts and `infer_map_unit_scale` in
|
|
78
|
-
* rust/core/src/unit_labels.rs, which apply these same rules on the reading
|
|
79
|
-
* side. This exporter's accepted set is the smaller one — it writes only what
|
|
80
|
-
* it can express as an `IfcNamedUnit` — but no spelling may be accepted here
|
|
81
|
-
* that those refuse, or refused here that those accept as a length.
|
|
82
|
-
*/
|
|
83
|
-
export declare function normalizeMapUnitName(unitName: string): string;
|
|
84
|
-
/**
|
|
85
|
-
* `effective` filters the candidates the same way the georef reads above do:
|
|
86
|
-
* returning a tombstoned unit id hands the caller a `#id` for a line the
|
|
87
|
-
* export never writes. Returning null instead makes `resolveMapUnitReference`
|
|
88
|
-
* synthesise a fresh unit, which is the outcome a deleted unit deserves.
|
|
89
|
-
*/
|
|
13
|
+
/** Existing exporter entry point delegates eligibility and exact label matching
|
|
14
|
+
* to the canonical reader/writer resolver. */
|
|
90
15
|
export declare function findLengthUnitReference(preferredUnitName: string, effective: EffectiveEntityIndex, ctx: GeorefLookupContext): number | null;
|
|
91
16
|
//# sourceMappingURL=step-map-unit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-map-unit.d.ts","sourceRoot":"","sources":["../src/step-map-unit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"step-map-unit.d.ts","sourceRoot":"","sources":["../src/step-map-unit.ts"],"names":[],"mappings":"AAkCA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEnF;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,0DAA0D;AAC1D,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAInF;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAwCtJ;AA2BD;8CAC8C;AAC9C,wBAAgB,uBAAuB,CAAC,iBAAiB,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,EAAE,mBAAmB,GAAG,MAAM,GAAG,IAAI,CAI3I"}
|
package/dist/step-map-unit.js
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* Map-unit resolution for the georeferencing phase: the `IfcNamedUnit` an
|
|
6
|
+
* `IfcProjectedCRS.MapUnit` points at, and the reuse-or-synthesise decision
|
|
7
|
+
* behind it.
|
|
8
|
+
*
|
|
9
|
+
* Split out of `step-georeferencing.ts` in #3274 rather than grown in place —
|
|
10
|
+
* the question it answers is a different one from "which georeferencing
|
|
11
|
+
* entities does this export write", it has a second caller in
|
|
12
|
+
* `step-property-sets.ts` (property units reach `findLengthUnitReference`
|
|
13
|
+
* through `findUnitId`), and raising the module-size budget instead would have
|
|
14
|
+
* wanted a per-file justification in the PR; a split does not.
|
|
15
|
+
*
|
|
16
|
+
* THE RULE THIS MODULE EXISTS TO KEEP: a unit name is compared WHOLE. The
|
|
17
|
+
* defect it was extracted for was a substring test — `normalized.includes('METRE')`
|
|
18
|
+
* — which `MILLIMETRE`, `CENTIMETRE` and `KILOMETRE` all satisfy, so every one
|
|
19
|
+
* of them was written into the file as a plain `.METRE.`. The map unit is the
|
|
20
|
+
* scale of the entire coordinate reference system, so that is a silent 1000x
|
|
21
|
+
* error in the one attribute another team uses to place the model on the
|
|
22
|
+
* earth, and it is invisible in the output: a millimetre request produced
|
|
23
|
+
* bytes identical to a metre request.
|
|
24
|
+
*
|
|
25
|
+
* And a unit this module cannot express is REFUSED, not approximated.
|
|
26
|
+
* `IfcProjectedCRS.MapUnit` is `OPTIONAL IfcNamedUnit` with
|
|
27
|
+
* `IsLengthUnit : NOT(EXISTS(MapUnit)) OR (MapUnit.UnitType = LENGTHUNIT)`, so
|
|
28
|
+
* an absent MapUnit is schema-valid; a MapUnit naming the wrong unit is not
|
|
29
|
+
* merely lossy, it is false, and nothing downstream can tell it from a true
|
|
30
|
+
* one.
|
|
31
|
+
*/
|
|
32
|
+
import { findSourceProjectLengthUnit, normalizeMapUnitName } from '@ifc-lite/parser';
|
|
33
|
+
export { normalizeMapUnitName } from '@ifc-lite/parser';
|
|
4
34
|
import { toStepReal } from './step-serialization.js';
|
|
5
35
|
/**
|
|
6
36
|
* Message for the refusal when a requested map unit is one this exporter
|
|
@@ -79,203 +109,11 @@ function siPrefixOf(normalized) {
|
|
|
79
109
|
}
|
|
80
110
|
return undefined;
|
|
81
111
|
}
|
|
82
|
-
/**
|
|
83
|
-
|
|
84
|
-
return label.toUpperCase().split(/[^A-Z0-9]+/).filter((token) => token.length > 0);
|
|
85
|
-
}
|
|
86
|
-
/** The foot/feet spellings a US-survey qualifier may be attached to. */
|
|
87
|
-
const FOOT_TOKENS = new Set(['FOOT', 'FEET', 'FT']);
|
|
88
|
-
/**
|
|
89
|
-
* Order-insensitive recogniser for the separated US-survey foot spellings —
|
|
90
|
-
* `foot (US survey)`, `SURVEY FEET (US)`, `US survey foot`. The glued
|
|
91
|
-
* spellings (`USSURVEYFOOT`, `FTUS`, …) are in {@link MAP_UNIT_CANONICAL_NAME}
|
|
92
|
-
* and matched exactly there; once an exporter puts separators in, the word
|
|
93
|
-
* order varies and gluing alone cannot see it.
|
|
94
|
-
*
|
|
95
|
-
* Accepts exactly one foot token plus either `US` (or the glued `USSURVEY`)
|
|
96
|
-
* or both `US` and `SURVEY`. A bare `SURVEY FOOT` without `US` is REFUSED:
|
|
97
|
-
* other national survey feet exist and are different ratios — Clarke's foot is
|
|
98
|
-
* 0.3047972654 m, the Indian foot 0.304799514 m — so the qualifier alone does
|
|
99
|
-
* not identify a value. `US FOOT` on its own IS accepted: EPSG 9003 is the
|
|
100
|
-
* only US foot, so the nationality does identify it.
|
|
101
|
-
*
|
|
102
|
-
* The requirement that exactly ONE foot token be present, with nothing else
|
|
103
|
-
* beside the qualifier, is what refuses `SQUARE US SURVEY FOOT` (an area) and
|
|
104
|
-
* `NON-US SURVEY FOOT` (a label that says it is not this unit).
|
|
105
|
-
*
|
|
106
|
-
* Sibling of `isUsSurveyFootTokens` in packages/parser/src/map-unit-label.ts
|
|
107
|
-
* and `is_us_survey_foot_tokens` in rust/core/src/unit_labels.rs — those two
|
|
108
|
-
* answer a metre scale for the georeferencing READER, this one answers the
|
|
109
|
-
* canonical name the STEP writer emits, but the accepted spellings are the
|
|
110
|
-
* same set and must stay the same set.
|
|
111
|
-
*/
|
|
112
|
-
function isUsSurveyFootTokens(tokens) {
|
|
113
|
-
const feet = tokens.filter((token) => FOOT_TOKENS.has(token));
|
|
114
|
-
if (feet.length !== 1)
|
|
115
|
-
return false;
|
|
116
|
-
const rest = tokens.filter((token) => !FOOT_TOKENS.has(token));
|
|
117
|
-
if (rest.length === 1)
|
|
118
|
-
return rest[0] === 'US' || rest[0] === 'USSURVEY';
|
|
119
|
-
return rest.length === 2 && rest.includes('US') && rest.includes('SURVEY');
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Exact-match table from a folded label to the canonical unit name the rest of
|
|
123
|
-
* this module compares against. DERIVED rather than hand-written: the two base
|
|
124
|
-
* spellings crossed with {@link SI_PREFIXES} — the same list {@link siPrefixOf}
|
|
125
|
-
* reads, so the two cannot drift — plus the foot spellings this exporter can
|
|
126
|
-
* write as an `IfcConversionBasedUnit`.
|
|
127
|
-
*
|
|
128
|
-
* A `Map` rather than an object literal so a label like `CONSTRUCTOR` cannot
|
|
129
|
-
* resolve through `Object.prototype`.
|
|
130
|
-
*/
|
|
131
|
-
const MAP_UNIT_CANONICAL_NAME = (() => {
|
|
132
|
-
const table = new Map();
|
|
133
|
-
for (const spelling of ['METRE', 'METER']) {
|
|
134
|
-
table.set(spelling, 'METRE');
|
|
135
|
-
for (const prefix of SI_PREFIXES)
|
|
136
|
-
table.set(`${prefix}${spelling}`, `${prefix}METRE`);
|
|
137
|
-
}
|
|
138
|
-
for (const foot of ['FOOT', 'FEET'])
|
|
139
|
-
table.set(foot, 'FOOT');
|
|
140
|
-
// The US survey foot is a different ratio from the international foot
|
|
141
|
-
// (1200/3937 vs 0.3048) and is spelled several ways in the wild. These are
|
|
142
|
-
// the accepted glued spellings, matched exactly rather than sniffed for; the
|
|
143
|
-
// separated ones go through {@link isUsSurveyFootTokens}.
|
|
144
|
-
for (const alias of ['USSURVEYFOOT', 'USSURVEYFEET', 'USSURVEYFT', 'USFOOT', 'USFEET', 'USFT', 'FTUS']) {
|
|
145
|
-
table.set(alias, 'US SURVEY FOOT');
|
|
146
|
-
}
|
|
147
|
-
return table;
|
|
148
|
-
})();
|
|
149
|
-
/**
|
|
150
|
-
* Canonicalize a map-unit label to the spelling the rest of this module
|
|
151
|
-
* compares against: American `METER` to `METRE`, the foot spellings to `FOOT`,
|
|
152
|
-
* the US survey foot to `US SURVEY FOOT`, and an SI prefix kept rather than
|
|
153
|
-
* swallowed. Anything not recognised is returned normalised-but-unchanged, for
|
|
154
|
-
* the caller to REFUSE rather than guess at.
|
|
155
|
-
*
|
|
156
|
-
* The label is NORMALISED and then matched EXACTLY — never substring-matched.
|
|
157
|
-
*
|
|
158
|
-
* What the normalisation accepts:
|
|
159
|
-
* - any case and any separators: `metres`, `Meters`, `MILLI-METRE`;
|
|
160
|
-
* - `METRE` and `METER`, each carrying any `IfcSIPrefix` member;
|
|
161
|
-
* - `FOOT` and `FEET`;
|
|
162
|
-
* - one English plural suffix, stripped once and re-matched exactly;
|
|
163
|
-
* - the US survey foot, glued or separated in any word order.
|
|
164
|
-
*
|
|
165
|
-
* What it REFUSES, by leaving the label alone so `resolveMapUnitReference`
|
|
166
|
-
* returns `null` and `MapUnit` stays `$` with a warning:
|
|
167
|
-
* - a label that merely CONTAINS a unit. `MILLIMETRE`, `CENTIMETRE` and
|
|
168
|
-
* `KILOMETRE` all contain `METRE`, and an `includes('METRE')` test wrote all
|
|
169
|
-
* three into the file as a plain `.METRE.` — a silent 1000x error in the CRS
|
|
170
|
-
* scale (#3274). The foot half of that same test was `includes('FOOT')`, and
|
|
171
|
-
* it was satisfied by `FOOTCANDLE` (an illuminance), `FOOT-POUND` (an
|
|
172
|
-
* energy), `FOOTPRINT`, and by `SQUARE FOOT` and `CUBIC FEET` — an area and
|
|
173
|
-
* a volume written as a LENGTH unit, which is a wrong DIMENSION rather than
|
|
174
|
-
* a wrong magnitude, and no scale factor can be right for it;
|
|
175
|
-
* - a survey foot with no nationality: `SURVEY FOOT`, `CLARKE'S FOOT`,
|
|
176
|
-
* `INDIAN FOOT`, `SEARS FOOT`, `BRITISH FOOT (1936)` are five different
|
|
177
|
-
* ratios, and `includes('FOOT')` gave every one of them the international
|
|
178
|
-
* 0.3048;
|
|
179
|
-
* - `INCH`, `YARD`, `MILE` and anything else this exporter cannot express.
|
|
180
|
-
*
|
|
181
|
-
* Normalising a recognisable spelling onto a table entry is NOT that
|
|
182
|
-
* approximation: the answer is still one exact table hit, so `MILLIMETERS`
|
|
183
|
-
* resolves to `MILLIMETRE` and not to `METRE`.
|
|
184
|
-
*
|
|
185
|
-
* Sibling of `inferMapUnitScaleFromLabel` in
|
|
186
|
-
* packages/parser/src/map-unit-label.ts and `infer_map_unit_scale` in
|
|
187
|
-
* rust/core/src/unit_labels.rs, which apply these same rules on the reading
|
|
188
|
-
* side. This exporter's accepted set is the smaller one — it writes only what
|
|
189
|
-
* it can express as an `IfcNamedUnit` — but no spelling may be accepted here
|
|
190
|
-
* that those refuse, or refused here that those accept as a length.
|
|
191
|
-
*/
|
|
192
|
-
export function normalizeMapUnitName(unitName) {
|
|
193
|
-
const normalized = unitName.trim().toUpperCase().replace(/\s+/g, ' ');
|
|
194
|
-
const tokens = tokenizeUnitLabel(normalized);
|
|
195
|
-
if (tokens.length === 0)
|
|
196
|
-
return normalized;
|
|
197
|
-
if (isUsSurveyFootTokens(tokens))
|
|
198
|
-
return 'US SURVEY FOOT';
|
|
199
|
-
const key = tokens.join('');
|
|
200
|
-
const exact = MAP_UNIT_CANONICAL_NAME.get(key);
|
|
201
|
-
if (exact !== undefined)
|
|
202
|
-
return exact;
|
|
203
|
-
// One English plural suffix, removed once and re-matched exactly. `ES`
|
|
204
|
-
// covers spellings whose singular is not reachable by dropping a single `S`.
|
|
205
|
-
for (const suffix of ['S', 'ES']) {
|
|
206
|
-
if (!key.endsWith(suffix))
|
|
207
|
-
continue;
|
|
208
|
-
const singular = MAP_UNIT_CANONICAL_NAME.get(key.slice(0, -suffix.length));
|
|
209
|
-
if (singular !== undefined)
|
|
210
|
-
return singular;
|
|
211
|
-
}
|
|
212
|
-
return normalized;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* `effective` filters the candidates the same way the georef reads above do:
|
|
216
|
-
* returning a tombstoned unit id hands the caller a `#id` for a line the
|
|
217
|
-
* export never writes. Returning null instead makes `resolveMapUnitReference`
|
|
218
|
-
* synthesise a fresh unit, which is the outcome a deleted unit deserves.
|
|
219
|
-
*/
|
|
112
|
+
/** Existing exporter entry point delegates eligibility and exact label matching
|
|
113
|
+
* to the canonical reader/writer resolver. */
|
|
220
114
|
export function findLengthUnitReference(preferredUnitName, effective, ctx) {
|
|
221
115
|
if (!ctx.entityExtractor)
|
|
222
116
|
return null;
|
|
223
|
-
|
|
224
|
-
// `crs.mapUnit !== undefined`, not `!== ''`, and `normalizeMapUnitName('')`
|
|
225
|
-
// is `''`. Both comparisons below fold a non-string Name attribute to `''`
|
|
226
|
-
// too, so without this an empty MapUnit binds to whichever unit happens to
|
|
227
|
-
// have a malformed name rather than to nothing.
|
|
228
|
-
if (preferredUnitName === '')
|
|
229
|
-
return null;
|
|
230
|
-
// Only source records carry the bytes `extractEntity` reads, so an
|
|
231
|
-
// overlay-created project is skipped rather than shadowing the file's own.
|
|
232
|
-
// @raw-entity-enumeration-ok the effective project set is filtered to source records because this fallback must decode source STEP bytes
|
|
233
|
-
const projectId = (effective.byType.get('IFCPROJECT') ?? []).find((id) => ctx.dataStore.entityIndex.byId.has(id));
|
|
234
|
-
// @raw-entity-enumeration-ok point lookup for the chosen source project's byte span
|
|
235
|
-
const projectRef = projectId !== undefined ? ctx.dataStore.entityIndex.byId.get(projectId) : undefined;
|
|
236
|
-
const project = projectRef ? ctx.entityExtractor.extractEntity(projectRef) : null;
|
|
237
|
-
const unitAssignmentId = project?.attributes?.[8];
|
|
238
|
-
if (typeof unitAssignmentId !== 'number' || effective.isDeleted(unitAssignmentId))
|
|
239
|
-
return null;
|
|
240
|
-
// @raw-entity-enumeration-ok point lookup for the source UnitAssignment referenced by that project
|
|
241
|
-
const unitAssignmentRef = ctx.dataStore.entityIndex.byId.get(unitAssignmentId);
|
|
242
|
-
const unitAssignment = unitAssignmentRef ? ctx.entityExtractor.extractEntity(unitAssignmentRef) : null;
|
|
243
|
-
const units = unitAssignment?.attributes?.[0];
|
|
244
|
-
if (!Array.isArray(units))
|
|
245
|
-
return null;
|
|
246
|
-
for (const unitId of units) {
|
|
247
|
-
if (typeof unitId !== 'number' || effective.isDeleted(unitId))
|
|
248
|
-
continue;
|
|
249
|
-
// @raw-entity-enumeration-ok point lookup for each referenced source unit after effective deletion filtering
|
|
250
|
-
const unitRef = ctx.dataStore.entityIndex.byId.get(unitId);
|
|
251
|
-
const unit = unitRef ? ctx.entityExtractor.extractEntity(unitRef) : null;
|
|
252
|
-
if (!unit)
|
|
253
|
-
continue;
|
|
254
|
-
const typeName = unit.type.toUpperCase();
|
|
255
|
-
const attrs = unit.attributes ?? [];
|
|
256
|
-
const unitType = typeof attrs[1] === 'string' ? attrs[1].replace(/\./g, '').toUpperCase() : '';
|
|
257
|
-
if (unitType !== 'LENGTHUNIT')
|
|
258
|
-
continue;
|
|
259
|
-
if (typeName === 'IFCSIUNIT') {
|
|
260
|
-
const prefix = typeof attrs[2] === 'string' ? attrs[2].replace(/\./g, '').toUpperCase() : '';
|
|
261
|
-
const name = typeof attrs[3] === 'string' ? attrs[3].replace(/\./g, '').toUpperCase() : '';
|
|
262
|
-
// The prefix is part of the unit, so it is part of the comparison. The
|
|
263
|
-
// old test asked only whether the preferred name was `METRE` and the
|
|
264
|
-
// file's unit was a metre of any prefix, which both missed a reusable
|
|
265
|
-
// `.MILLI.` unit and would have matched one for a plain-metre request
|
|
266
|
-
// had `combined` been read (#3274).
|
|
267
|
-
const combined = prefix ? `${prefix}${name}` : name;
|
|
268
|
-
if (normalizeMapUnitName(combined) === preferredUnitName) {
|
|
269
|
-
return unitId;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
if (typeName === 'IFCCONVERSIONBASEDUNIT') {
|
|
273
|
-
const name = typeof attrs[2] === 'string' ? normalizeMapUnitName(attrs[2]) : '';
|
|
274
|
-
if (name === preferredUnitName) {
|
|
275
|
-
return unitId;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return null;
|
|
117
|
+
return findSourceProjectLengthUnit(preferredUnitName, ctx.dataStore, effective.byType.get('IFCPROJECT') ?? [], id => effective.isDeleted(id));
|
|
280
118
|
}
|
|
281
119
|
//# sourceMappingURL=step-map-unit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-map-unit.js","sourceRoot":"","sources":["../src/step-map-unit.ts"],"names":[],"mappings":"AAAA;;+DAE+D;
|
|
1
|
+
{"version":3,"file":"step-map-unit.js","sourceRoot":"","sources":["../src/step-map-unit.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAgB;IACxD,OAAO,2BAA2B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,sKAAsK,CAAC;AACnO,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,wBAAwB,CAAC,QAAkB,EAAE,QAAgB;IAC3E,MAAM,OAAO,GAAG,yBAAyB,CAAC,QAAQ,CAAC,CAAC;IACpD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,OAAO,CAAC,IAAI,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,QAAgB,EAAE,cAAwB,EAAE,SAA+B,EAAE,GAAkB;IACrI,MAAM,UAAU,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAA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7E,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type IfcEntity } from '@ifc-lite/parser';
|
|
2
|
+
import type { IfcSchemaVersion } from './schema-converter.js';
|
|
3
|
+
import { type PropertySetContext } from './step-property-set-readers.js';
|
|
4
|
+
export declare function nativeSetLine(ctx: PropertySetContext, id: number, sourceSchema: IfcSchemaVersion, attributeMutations?: Map<string, string>, warnings?: string[]): string;
|
|
5
|
+
export declare function decodeNativeSetLine(line: string, id: number): IfcEntity;
|
|
6
|
+
//# sourceMappingURL=step-native-set-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-native-set-record.d.ts","sourceRoot":"","sources":["../src/step-native-set-record.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzF,wBAAgB,aAAa,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAC/F,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAE,MAAM,EAAO,GAAG,MAAM,CAU3E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,CAQvE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
import { EntityExtractor } from '@ifc-lite/parser';
|
|
5
|
+
import { applySourceLineMutationsReported } from './step-attribute-mutations.js';
|
|
6
|
+
import { serializeEntityArgs } from './attribute-real-slots.js';
|
|
7
|
+
import { entityLineText } from './step-property-set-readers.js';
|
|
8
|
+
import { readStepSlots } from './step-argument-parser.js';
|
|
9
|
+
export function nativeSetLine(ctx, id, sourceSchema, attributeMutations, warnings = []) {
|
|
10
|
+
const created = ctx.mutationView?.getNewEntity?.(id);
|
|
11
|
+
const original = created
|
|
12
|
+
? `#${id}=${created.type.toUpperCase()}(${serializeEntityArgs(created.type, created.attributes, sourceSchema)});`
|
|
13
|
+
: entityLineText(ctx, id);
|
|
14
|
+
if (original === null)
|
|
15
|
+
throw new Error(`Type quantity source #${id} is unreadable`);
|
|
16
|
+
// @raw-entity-enumeration-ok original source type for canonical mutation serialization; created records use their authored type above
|
|
17
|
+
return applySourceLineMutationsReported(ctx.applySourceLineMutations, warnings, id, original, created?.type ?? ctx.dataStore.entityIndex.byId.get(id)?.type ?? '', attributeMutations, sourceSchema, ctx.mutationView !== null).text;
|
|
18
|
+
}
|
|
19
|
+
export function decodeNativeSetLine(line, id) {
|
|
20
|
+
const bytes = new TextEncoder().encode(line);
|
|
21
|
+
const record = readStepSlots(line);
|
|
22
|
+
if (!record)
|
|
23
|
+
throw new Error(`Type quantity source #${id} has invalid STEP slots`);
|
|
24
|
+
const entity = new EntityExtractor(bytes).extractEntity({ expressId: id, type: record.type,
|
|
25
|
+
byteOffset: 0, byteLength: bytes.byteLength, lineNumber: 1 });
|
|
26
|
+
if (!entity)
|
|
27
|
+
throw new Error(`Type quantity source #${id} cannot be decoded`);
|
|
28
|
+
return entity;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=step-native-set-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-native-set-record.js","sourceRoot":"","sources":["../src/step-native-set-record.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,OAAO,EAAE,eAAe,EAAkB,MAAM,kBAAkB,CAAC;AAEnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO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