@ifc-lite/export 2.9.4 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/csv-cell.d.ts +101 -0
- package/dist/csv-cell.d.ts.map +1 -0
- package/dist/csv-cell.js +90 -0
- package/dist/csv-cell.js.map +1 -0
- package/dist/declared-property-type.d.ts +19 -8
- package/dist/declared-property-type.d.ts.map +1 -1
- package/dist/declared-property-type.js +31 -9
- package/dist/declared-property-type.js.map +1 -1
- package/dist/demesh-session.d.ts.map +1 -1
- package/dist/demesh-session.js +2 -1
- package/dist/demesh-session.js.map +1 -1
- package/dist/effective-index.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/lod1-generator.d.ts +0 -2
- package/dist/lod1-generator.d.ts.map +1 -1
- package/dist/lod1-generator.js +1 -1
- package/dist/lod1-generator.js.map +1 -1
- package/dist/merged-exporter.d.ts +19 -0
- package/dist/merged-exporter.d.ts.map +1 -1
- package/dist/merged-exporter.js +23 -41
- package/dist/merged-exporter.js.map +1 -1
- package/dist/parquet-exporter.d.ts +1 -3
- package/dist/parquet-exporter.d.ts.map +1 -1
- package/dist/parquet-exporter.js +1 -0
- package/dist/parquet-exporter.js.map +1 -1
- package/dist/property-value-serialization.d.ts +54 -0
- package/dist/property-value-serialization.d.ts.map +1 -0
- package/dist/property-value-serialization.js +134 -0
- package/dist/property-value-serialization.js.map +1 -0
- package/dist/reference-collector.d.ts +20 -0
- package/dist/reference-collector.d.ts.map +1 -1
- package/dist/reference-collector.js +46 -113
- package/dist/reference-collector.js.map +1 -1
- package/dist/schema-converter.d.ts.map +1 -1
- package/dist/schema-converter.js +46 -96
- package/dist/schema-converter.js.map +1 -1
- package/dist/source-ref-bounds.d.ts +3 -3
- package/dist/source-ref-bounds.js +3 -3
- package/dist/step-attribute-mutations.d.ts +49 -0
- package/dist/step-attribute-mutations.d.ts.map +1 -0
- package/dist/step-attribute-mutations.js +172 -0
- package/dist/step-attribute-mutations.js.map +1 -0
- package/dist/step-attribute-serializers.d.ts +41 -0
- package/dist/step-attribute-serializers.d.ts.map +1 -0
- package/dist/step-attribute-serializers.js +74 -0
- package/dist/step-attribute-serializers.js.map +1 -0
- package/dist/step-collection.d.ts +55 -0
- package/dist/step-collection.d.ts.map +1 -0
- package/dist/step-collection.js +126 -0
- package/dist/step-collection.js.map +1 -0
- package/dist/step-export-contexts.d.ts +61 -0
- package/dist/step-export-contexts.d.ts.map +1 -0
- package/dist/step-export-contexts.js +50 -0
- package/dist/step-export-contexts.js.map +1 -0
- package/dist/step-export-types.d.ts +262 -0
- package/dist/step-export-types.d.ts.map +1 -0
- package/dist/step-export-types.js +22 -0
- package/dist/step-export-types.js.map +1 -0
- package/dist/step-exporter.d.ts +23 -354
- package/dist/step-exporter.d.ts.map +1 -1
- package/dist/step-exporter.js +76 -1260
- package/dist/step-exporter.js.map +1 -1
- package/dist/step-geometry-types.d.ts +3 -0
- package/dist/step-geometry-types.d.ts.map +1 -0
- package/dist/step-geometry-types.js +73 -0
- package/dist/step-geometry-types.js.map +1 -0
- package/dist/step-georeferencing.d.ts +0 -10
- package/dist/step-georeferencing.d.ts.map +1 -1
- package/dist/step-georeferencing.js +46 -94
- package/dist/step-georeferencing.js.map +1 -1
- package/dist/step-header.d.ts +53 -0
- package/dist/step-header.d.ts.map +1 -0
- package/dist/step-header.js +63 -0
- package/dist/step-header.js.map +1 -0
- package/dist/step-map-unit.d.ts +90 -0
- package/dist/step-map-unit.d.ts.map +1 -0
- package/dist/step-map-unit.js +277 -0
- package/dist/step-map-unit.js.map +1 -0
- package/dist/step-omission-predicates.d.ts +51 -0
- package/dist/step-omission-predicates.d.ts.map +1 -0
- package/dist/step-omission-predicates.js +268 -0
- package/dist/step-omission-predicates.js.map +1 -0
- package/dist/step-overlay-attribute-overrides.d.ts +32 -0
- package/dist/step-overlay-attribute-overrides.d.ts.map +1 -0
- package/dist/step-overlay-attribute-overrides.js +83 -0
- package/dist/step-overlay-attribute-overrides.js.map +1 -0
- package/dist/step-overlay-entities.d.ts +64 -0
- package/dist/step-overlay-entities.d.ts.map +1 -0
- package/dist/step-overlay-entities.js +119 -0
- package/dist/step-overlay-entities.js.map +1 -0
- package/dist/step-pass-builder.d.ts +45 -0
- package/dist/step-pass-builder.d.ts.map +1 -0
- package/dist/step-pass-builder.js +249 -0
- package/dist/step-pass-builder.js.map +1 -0
- package/dist/step-property-set-collection.d.ts +24 -0
- package/dist/step-property-set-collection.d.ts.map +1 -0
- package/dist/step-property-set-collection.js +286 -0
- package/dist/step-property-set-collection.js.map +1 -0
- package/dist/step-property-set-generators.d.ts +20 -0
- package/dist/step-property-set-generators.d.ts.map +1 -0
- package/dist/step-property-set-generators.js +98 -0
- package/dist/step-property-set-generators.js.map +1 -0
- package/dist/step-property-set-index.d.ts +25 -0
- package/dist/step-property-set-index.d.ts.map +1 -0
- package/dist/step-property-set-index.js +69 -0
- package/dist/step-property-set-index.js.map +1 -0
- package/dist/step-property-set-readers.d.ts +158 -0
- package/dist/step-property-set-readers.d.ts.map +1 -0
- package/dist/step-property-set-readers.js +251 -0
- package/dist/step-property-set-readers.js.map +1 -0
- package/dist/step-property-sets.d.ts +2 -184
- package/dist/step-property-sets.d.ts.map +1 -1
- package/dist/step-property-sets.js +22 -674
- package/dist/step-property-sets.js.map +1 -1
- package/dist/step-serialization.d.ts +33 -52
- package/dist/step-serialization.d.ts.map +1 -1
- package/dist/step-serialization.js +69 -131
- package/dist/step-serialization.js.map +1 -1
- package/dist/step-source-iteration.d.ts +97 -0
- package/dist/step-source-iteration.d.ts.map +1 -0
- package/dist/step-source-iteration.js +178 -0
- package/dist/step-source-iteration.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,90 @@
|
|
|
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 the module-size budget is not a thing to raise.
|
|
11
|
+
*
|
|
12
|
+
* THE RULE THIS MODULE EXISTS TO KEEP: a unit name is compared WHOLE. The
|
|
13
|
+
* defect it was extracted for was a substring test — `normalized.includes('METRE')`
|
|
14
|
+
* — which `MILLIMETRE`, `CENTIMETRE` and `KILOMETRE` all satisfy, so every one
|
|
15
|
+
* of them was written into the file as a plain `.METRE.`. The map unit is the
|
|
16
|
+
* scale of the entire coordinate reference system, so that is a silent 1000x
|
|
17
|
+
* error in the one attribute another team uses to place the model on the
|
|
18
|
+
* earth, and it is invisible in the output: a millimetre request produced
|
|
19
|
+
* bytes identical to a metre request.
|
|
20
|
+
*
|
|
21
|
+
* And a unit this module cannot express is REFUSED, not approximated.
|
|
22
|
+
* `IfcProjectedCRS.MapUnit` is `OPTIONAL IfcNamedUnit` with
|
|
23
|
+
* `IsLengthUnit : NOT(EXISTS(MapUnit)) OR (MapUnit.UnitType = LENGTHUNIT)`, so
|
|
24
|
+
* an absent MapUnit is schema-valid; a MapUnit naming the wrong unit is not
|
|
25
|
+
* merely lossy, it is false, and nothing downstream can tell it from a true
|
|
26
|
+
* one.
|
|
27
|
+
*/
|
|
28
|
+
import type { EffectiveEntityIndex } from './effective-index.js';
|
|
29
|
+
import type { GeorefContext, GeorefLookupContext } from './step-georeferencing.js';
|
|
30
|
+
/**
|
|
31
|
+
* Message for the refusal when a requested map unit is one this exporter
|
|
32
|
+
* cannot express as an `IfcNamedUnit`. `MapUnit` is optional, so it is left
|
|
33
|
+
* absent rather than filled with a unit that is not the one asked for (#3274).
|
|
34
|
+
*/
|
|
35
|
+
export declare function mapUnitUnsupportedWarning(unitName: string): string;
|
|
36
|
+
/** Record a map unit the exporter refused to guess at. */
|
|
37
|
+
export declare function reportMapUnitUnsupported(warnings: string[], unitName: string): void;
|
|
38
|
+
export declare function resolveMapUnitReference(unitName: string, newGeorefLines: string[], effective: EffectiveEntityIndex, ctx: GeorefContext): number | null;
|
|
39
|
+
/**
|
|
40
|
+
* Canonicalize a map-unit label to the spelling the rest of this module
|
|
41
|
+
* compares against: American `METER` to `METRE`, the foot spellings to `FOOT`,
|
|
42
|
+
* the US survey foot to `US SURVEY FOOT`, and an SI prefix kept rather than
|
|
43
|
+
* swallowed. Anything not recognised is returned normalised-but-unchanged, for
|
|
44
|
+
* the caller to REFUSE rather than guess at.
|
|
45
|
+
*
|
|
46
|
+
* The label is NORMALISED and then matched EXACTLY — never substring-matched.
|
|
47
|
+
*
|
|
48
|
+
* What the normalisation accepts:
|
|
49
|
+
* - any case and any separators: `metres`, `Meters`, `MILLI-METRE`;
|
|
50
|
+
* - `METRE` and `METER`, each carrying any `IfcSIPrefix` member;
|
|
51
|
+
* - `FOOT` and `FEET`;
|
|
52
|
+
* - one English plural suffix, stripped once and re-matched exactly;
|
|
53
|
+
* - the US survey foot, glued or separated in any word order.
|
|
54
|
+
*
|
|
55
|
+
* What it REFUSES, by leaving the label alone so `resolveMapUnitReference`
|
|
56
|
+
* returns `null` and `MapUnit` stays `$` with a warning:
|
|
57
|
+
* - a label that merely CONTAINS a unit. `MILLIMETRE`, `CENTIMETRE` and
|
|
58
|
+
* `KILOMETRE` all contain `METRE`, and an `includes('METRE')` test wrote all
|
|
59
|
+
* three into the file as a plain `.METRE.` — a silent 1000x error in the CRS
|
|
60
|
+
* scale (#3274). The foot half of that same test was `includes('FOOT')`, and
|
|
61
|
+
* it was satisfied by `FOOTCANDLE` (an illuminance), `FOOT-POUND` (an
|
|
62
|
+
* energy), `FOOTPRINT`, and by `SQUARE FOOT` and `CUBIC FEET` — an area and
|
|
63
|
+
* a volume written as a LENGTH unit, which is a wrong DIMENSION rather than
|
|
64
|
+
* a wrong magnitude, and no scale factor can be right for it;
|
|
65
|
+
* - a survey foot with no nationality: `SURVEY FOOT`, `CLARKE'S FOOT`,
|
|
66
|
+
* `INDIAN FOOT`, `SEARS FOOT`, `BRITISH FOOT (1936)` are five different
|
|
67
|
+
* ratios, and `includes('FOOT')` gave every one of them the international
|
|
68
|
+
* 0.3048;
|
|
69
|
+
* - `INCH`, `YARD`, `MILE` and anything else this exporter cannot express.
|
|
70
|
+
*
|
|
71
|
+
* Normalising a recognisable spelling onto a table entry is NOT that
|
|
72
|
+
* approximation: the answer is still one exact table hit, so `MILLIMETERS`
|
|
73
|
+
* resolves to `MILLIMETRE` and not to `METRE`.
|
|
74
|
+
*
|
|
75
|
+
* Sibling of `inferMapUnitScaleFromLabel` in
|
|
76
|
+
* packages/parser/src/map-unit-label.ts and `infer_map_unit_scale` in
|
|
77
|
+
* rust/core/src/unit_labels.rs, which apply these same rules on the reading
|
|
78
|
+
* side. This exporter's accepted set is the smaller one — it writes only what
|
|
79
|
+
* it can express as an `IfcNamedUnit` — but no spelling may be accepted here
|
|
80
|
+
* that those refuse, or refused here that those accept as a length.
|
|
81
|
+
*/
|
|
82
|
+
export declare function normalizeMapUnitName(unitName: string): string;
|
|
83
|
+
/**
|
|
84
|
+
* `effective` filters the candidates the same way the georef reads above do:
|
|
85
|
+
* returning a tombstoned unit id hands the caller a `#id` for a line the
|
|
86
|
+
* export never writes. Returning null instead makes `resolveMapUnitReference`
|
|
87
|
+
* synthesise a fresh unit, which is the outcome a deleted unit deserves.
|
|
88
|
+
*/
|
|
89
|
+
export declare function findLengthUnitReference(preferredUnitName: string, effective: EffectiveEntityIndex, ctx: GeorefLookupContext): number | null;
|
|
90
|
+
//# sourceMappingURL=step-map-unit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-map-unit.d.ts","sourceRoot":"","sources":["../src/step-map-unit.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,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;AA8FD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAkB7D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,iBAAiB,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,EAAE,mBAAmB,GAAG,MAAM,GAAG,IAAI,CAwD3I"}
|
|
@@ -0,0 +1,277 @@
|
|
|
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 { toStepReal } from './step-serialization.js';
|
|
5
|
+
/**
|
|
6
|
+
* Message for the refusal when a requested map unit is one this exporter
|
|
7
|
+
* cannot express as an `IfcNamedUnit`. `MapUnit` is optional, so it is left
|
|
8
|
+
* absent rather than filled with a unit that is not the one asked for (#3274).
|
|
9
|
+
*/
|
|
10
|
+
export function mapUnitUnsupportedWarning(unitName) {
|
|
11
|
+
return `Cannot express map unit ${JSON.stringify(unitName)} as an IfcNamedUnit: only metres (with any SI prefix), FOOT and US SURVEY FOOT are supported. IfcProjectedCRS.MapUnit was left unset rather than declared as metres.`;
|
|
12
|
+
}
|
|
13
|
+
/** Record a map unit the exporter refused to guess at. */
|
|
14
|
+
export function reportMapUnitUnsupported(warnings, unitName) {
|
|
15
|
+
const message = mapUnitUnsupportedWarning(unitName);
|
|
16
|
+
warnings.push(message);
|
|
17
|
+
console.warn(`[StepExporter] ${message}`);
|
|
18
|
+
}
|
|
19
|
+
export function resolveMapUnitReference(unitName, newGeorefLines, effective, ctx) {
|
|
20
|
+
const normalized = normalizeMapUnitName(unitName);
|
|
21
|
+
const existing = findLengthUnitReference(normalized, effective, ctx);
|
|
22
|
+
if (existing !== null) {
|
|
23
|
+
return existing;
|
|
24
|
+
}
|
|
25
|
+
// A metre, with or without an SI prefix. `MILLIMETRE` KEEPS its prefix: the
|
|
26
|
+
// map unit is the scale of the entire coordinate reference system, so
|
|
27
|
+
// writing `.METRE.` for a millimetre map is a silent 1000x error in the one
|
|
28
|
+
// attribute another team relies on to place the model (#3274).
|
|
29
|
+
const prefix = siPrefixOf(normalized);
|
|
30
|
+
if (prefix !== undefined) {
|
|
31
|
+
const unitId = ctx.allocateExpressId();
|
|
32
|
+
const prefixToken = prefix === null ? '$' : `.${prefix}.`;
|
|
33
|
+
newGeorefLines.push(`#${unitId}=IFCSIUNIT(*,.LENGTHUNIT.,${prefixToken},.METRE.);`);
|
|
34
|
+
return unitId;
|
|
35
|
+
}
|
|
36
|
+
if (normalized === 'FOOT' || normalized === 'US SURVEY FOOT') {
|
|
37
|
+
const dimId = ctx.allocateExpressId();
|
|
38
|
+
const siUnitId = ctx.allocateExpressId();
|
|
39
|
+
const measureId = ctx.allocateExpressId();
|
|
40
|
+
const convUnitId = ctx.allocateExpressId();
|
|
41
|
+
const factor = normalized === 'US SURVEY FOOT' ? 1200 / 3937 : 0.3048;
|
|
42
|
+
const name = normalized === 'US SURVEY FOOT' ? 'US SURVEY FOOT' : 'FOOT';
|
|
43
|
+
newGeorefLines.push(`#${dimId}=IFCDIMENSIONALEXPONENTS(1,0,0,0,0,0,0);`);
|
|
44
|
+
newGeorefLines.push(`#${siUnitId}=IFCSIUNIT(*,.LENGTHUNIT.,$,.METRE.);`);
|
|
45
|
+
newGeorefLines.push(`#${measureId}=IFCMEASUREWITHUNIT(IFCLENGTHMEASURE(${toStepReal(factor)}),#${siUnitId});`);
|
|
46
|
+
newGeorefLines.push(`#${convUnitId}=IFCCONVERSIONBASEDUNIT(#${dimId},.LENGTHUNIT.,'${name}',#${measureId});`);
|
|
47
|
+
return convUnitId;
|
|
48
|
+
}
|
|
49
|
+
// A unit this exporter cannot express. It must NOT claim to be metres: that
|
|
50
|
+
// is the coordinate reference system's scale, and a wrong one is worse than
|
|
51
|
+
// an absent one. `IfcProjectedCRS.MapUnit` is `OPTIONAL IfcNamedUnit`, and
|
|
52
|
+
// the WHERE rule is `NOT(EXISTS(MapUnit)) OR MapUnit.UnitType = LENGTHUNIT`,
|
|
53
|
+
// so omitting it is schema-valid. Refuse, and let the caller say so in
|
|
54
|
+
// `stats.warnings` the way the two map-conversion refusals do (#3274).
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
/** Every `IfcSIPrefix` member, longest first so `MILLI` cannot shadow `MILLIMICRO`-style
|
|
58
|
+
* compounds and `DECA` cannot shadow `DECI`. */
|
|
59
|
+
const SI_PREFIXES = [
|
|
60
|
+
'FEMTO', 'MICRO', 'HECTO', 'CENTI', 'MILLI',
|
|
61
|
+
'EXA', 'PETA', 'TERA', 'GIGA', 'MEGA', 'KILO', 'DECA', 'DECI', 'NANO', 'PICO', 'ATTO',
|
|
62
|
+
];
|
|
63
|
+
/**
|
|
64
|
+
* The `IfcSIPrefix` token for a normalized metre name — `null` for a bare
|
|
65
|
+
* `METRE`, the prefix for a prefixed one, and `undefined` when the name is not
|
|
66
|
+
* a metre at all.
|
|
67
|
+
*
|
|
68
|
+
* Three-valued deliberately: `null` and `undefined` are the two answers a bare
|
|
69
|
+
* boolean would merge, and merging them is the defect — `MILLIMETRE` reaching
|
|
70
|
+
* the "plain metre" arm is exactly what {@link normalizeMapUnitName}'s old
|
|
71
|
+
* `includes('METRE')` test did.
|
|
72
|
+
*/
|
|
73
|
+
function siPrefixOf(normalized) {
|
|
74
|
+
if (normalized === 'METRE')
|
|
75
|
+
return null;
|
|
76
|
+
for (const prefix of SI_PREFIXES) {
|
|
77
|
+
if (normalized === `${prefix}METRE`)
|
|
78
|
+
return prefix;
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
/** Split a map-unit label into upper-cased alphanumeric tokens. */
|
|
83
|
+
function tokenizeUnitLabel(label) {
|
|
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
|
+
*/
|
|
220
|
+
export function findLengthUnitReference(preferredUnitName, effective, ctx) {
|
|
221
|
+
if (!ctx.entityExtractor)
|
|
222
|
+
return null;
|
|
223
|
+
// An empty label is not a unit name, and it is reachable: the caller guards
|
|
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
|
+
const projectId = (effective.byType.get('IFCPROJECT') ?? []).find((id) => ctx.dataStore.entityIndex.byId.has(id));
|
|
233
|
+
const projectRef = projectId !== undefined ? ctx.dataStore.entityIndex.byId.get(projectId) : undefined;
|
|
234
|
+
const project = projectRef ? ctx.entityExtractor.extractEntity(projectRef) : null;
|
|
235
|
+
const unitAssignmentId = project?.attributes?.[8];
|
|
236
|
+
if (typeof unitAssignmentId !== 'number' || effective.isDeleted(unitAssignmentId))
|
|
237
|
+
return null;
|
|
238
|
+
const unitAssignmentRef = ctx.dataStore.entityIndex.byId.get(unitAssignmentId);
|
|
239
|
+
const unitAssignment = unitAssignmentRef ? ctx.entityExtractor.extractEntity(unitAssignmentRef) : null;
|
|
240
|
+
const units = unitAssignment?.attributes?.[0];
|
|
241
|
+
if (!Array.isArray(units))
|
|
242
|
+
return null;
|
|
243
|
+
for (const unitId of units) {
|
|
244
|
+
if (typeof unitId !== 'number' || effective.isDeleted(unitId))
|
|
245
|
+
continue;
|
|
246
|
+
const unitRef = ctx.dataStore.entityIndex.byId.get(unitId);
|
|
247
|
+
const unit = unitRef ? ctx.entityExtractor.extractEntity(unitRef) : null;
|
|
248
|
+
if (!unit)
|
|
249
|
+
continue;
|
|
250
|
+
const typeName = unit.type.toUpperCase();
|
|
251
|
+
const attrs = unit.attributes ?? [];
|
|
252
|
+
const unitType = typeof attrs[1] === 'string' ? attrs[1].replace(/\./g, '').toUpperCase() : '';
|
|
253
|
+
if (unitType !== 'LENGTHUNIT')
|
|
254
|
+
continue;
|
|
255
|
+
if (typeName === 'IFCSIUNIT') {
|
|
256
|
+
const prefix = typeof attrs[2] === 'string' ? attrs[2].replace(/\./g, '').toUpperCase() : '';
|
|
257
|
+
const name = typeof attrs[3] === 'string' ? attrs[3].replace(/\./g, '').toUpperCase() : '';
|
|
258
|
+
// The prefix is part of the unit, so it is part of the comparison. The
|
|
259
|
+
// old test asked only whether the preferred name was `METRE` and the
|
|
260
|
+
// file's unit was a metre of any prefix, which both missed a reusable
|
|
261
|
+
// `.MILLI.` unit and would have matched one for a plain-metre request
|
|
262
|
+
// had `combined` been read (#3274).
|
|
263
|
+
const combined = prefix ? `${prefix}${name}` : name;
|
|
264
|
+
if (normalizeMapUnitName(combined) === preferredUnitName) {
|
|
265
|
+
return unitId;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (typeName === 'IFCCONVERSIONBASEDUNIT') {
|
|
269
|
+
const name = typeof attrs[2] === 'string' ? normalizeMapUnitName(attrs[2]) : '';
|
|
270
|
+
if (name === preferredUnitName) {
|
|
271
|
+
return unitId;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=step-map-unit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-map-unit.js","sourceRoot":"","sources":["../src/step-map-unit.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AA+B/D,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,CAAC;IAClD,MAAM,QAAQ,GAAG,uBAAuB,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;IACrE,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,QAAQ,CAAC;IAClB,CAAC;I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AAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3F,uEAAuE;YACvE,qEAAqE;YACrE,sEAAsE;YACtE,sEAAsE;YACtE,oCAAoC;YACpC,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;YACpD,IAAI,oBAAoB,CAAC,QAAQ,CAAC,KAAK,iBAAiB,EAAE,CAAC;gBACzD,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QAED,IAAI,QAAQ,KAAK,wBAAwB,EAAE,CAAC;YAC1C,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAChF,IAAI,IAAI,KAAK,iBAAiB,EAAE,CAAC;gBAC/B,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which ids a STEP export may still NAME, once it has decided which ids it is
|
|
3
|
+
* writing.
|
|
4
|
+
*
|
|
5
|
+
* Split out of `step-exporter.ts` for #2475, verbatim apart from the two
|
|
6
|
+
* changes noted below. It runs immediately after `collectModifications` and
|
|
7
|
+
* before the output passes, and that position is not incidental: everything
|
|
8
|
+
* here reads what the collection phase produced -- `pass.modifiedEntities`,
|
|
9
|
+
* `pass.newGeorefLines`, `pass.allowedEntityIds`, `pass.overlayActive` -- and
|
|
10
|
+
* everything the output passes do with omitted references reads what this
|
|
11
|
+
* returns. Calling it earlier gives answers computed from an unpopulated pass.
|
|
12
|
+
*
|
|
13
|
+
* Why not in `step-collection.ts`: that module produces the values these
|
|
14
|
+
* predicates consume and never reads them back, so putting them there would
|
|
15
|
+
* relocate a dependency rather than remove one. That argument was always about
|
|
16
|
+
* `step-collection.ts` specifically, not about these predicates being welded
|
|
17
|
+
* to `export()`.
|
|
18
|
+
*
|
|
19
|
+
* TWO CHANGES FROM THE ORIGINAL, both forced by it becoming a function:
|
|
20
|
+
*
|
|
21
|
+
* 1. The deltaOnly empty short-circuit used to `return` out of `export()`.
|
|
22
|
+
* A free function cannot, so it returns a tagged `'short-circuit'` result
|
|
23
|
+
* the caller returns instead. That rewrite is safe by measurement, not by
|
|
24
|
+
* argument: disabling the branch entirely leaves the suite green and the
|
|
25
|
+
* emitted bytes and stats identical, because for a model with no edits the
|
|
26
|
+
* ordinary path arrives at the same place. See
|
|
27
|
+
* `delta-empty-shortcircuit.test.ts`, which pins the contract and says
|
|
28
|
+
* outright that it does not pin the branch.
|
|
29
|
+
* 2. `this.mutationView` arrives as a parameter.
|
|
30
|
+
*/
|
|
31
|
+
import type { MutablePropertyView } from '@ifc-lite/mutations';
|
|
32
|
+
import type { ExportPass, StepExportOptions, StepExportResult } from './step-export-types.js';
|
|
33
|
+
/**
|
|
34
|
+
* Either the export is already over, or here are the two things the output
|
|
35
|
+
* passes need from it.
|
|
36
|
+
*
|
|
37
|
+
* A tagged union rather than an optional field, so a caller cannot read
|
|
38
|
+
* `isOmittedFromOutput` off a short-circuited result and get `undefined`
|
|
39
|
+
* without the compiler saying so.
|
|
40
|
+
*/
|
|
41
|
+
export type OmissionEvaluation = {
|
|
42
|
+
readonly kind: 'short-circuit';
|
|
43
|
+
readonly result: StepExportResult;
|
|
44
|
+
} | {
|
|
45
|
+
readonly kind: 'continue';
|
|
46
|
+
readonly isOmittedFromOutput: (id: number) => boolean;
|
|
47
|
+
/** A boolean, not a predicate: the precondition both filter sites gate on. */
|
|
48
|
+
readonly mayNameOmittedRefs: boolean;
|
|
49
|
+
};
|
|
50
|
+
export declare function evaluateOmissionPredicates(pass: ExportPass, options: StepExportOptions, applyMutations: boolean, excludeGeometry: boolean, mutationView: MutablePropertyView | null): OmissionEvaluation;
|
|
51
|
+
//# sourceMappingURL=step-omission-predicates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-omission-predicates.d.ts","sourceRoot":"","sources":["../src/step-omission-predicates.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE9F;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,GACrE;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;IACtD,8EAA8E;IAC9E,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;CACtC,CAAC;AAEN,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,iBAAiB,EAC1B,cAAc,EAAE,OAAO,EACvB,eAAe,EAAE,OAAO,EACxB,YAAY,EAAE,mBAAmB,GAAG,IAAI,GACvC,kBAAkB,CA+QpB"}
|