@ifc-lite/export 6.0.0 → 7.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.
- package/README.md +42 -20
- package/dist/anonymize-types.d.ts +2 -0
- package/dist/anonymize-types.d.ts.map +1 -1
- package/dist/declared-property-type.d.ts +2 -110
- package/dist/declared-property-type.d.ts.map +1 -1
- package/dist/declared-property-type.js +15 -0
- package/dist/declared-property-type.js.map +1 -1
- package/dist/energy-artifact.d.ts +6 -0
- package/dist/energy-artifact.d.ts.map +1 -0
- package/dist/energy-artifact.js +33 -0
- package/dist/energy-artifact.js.map +1 -0
- package/dist/generated/ifc4-required-slots.d.ts +4 -1
- package/dist/generated/ifc4-required-slots.d.ts.map +1 -1
- package/dist/generated/ifc4-required-slots.js +704 -0
- package/dist/generated/ifc4-required-slots.js.map +1 -1
- package/dist/geometry-diagnostics.d.ts +14 -0
- package/dist/geometry-diagnostics.d.ts.map +1 -0
- package/dist/geometry-diagnostics.js +29 -0
- package/dist/geometry-diagnostics.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/merged-exporter.d.ts +1 -4
- package/dist/merged-exporter.d.ts.map +1 -1
- package/dist/merged-exporter.js +39 -23
- package/dist/merged-exporter.js.map +1 -1
- package/dist/merged-header.d.ts +2 -1
- package/dist/merged-header.d.ts.map +1 -1
- package/dist/merged-header.js +8 -0
- package/dist/merged-header.js.map +1 -1
- package/dist/merged-inherited-units.d.ts +8 -0
- package/dist/merged-inherited-units.d.ts.map +1 -0
- package/dist/merged-inherited-units.js +117 -0
- package/dist/merged-inherited-units.js.map +1 -0
- package/dist/merged-inverse-claims.d.ts +5 -6
- package/dist/merged-inverse-claims.d.ts.map +1 -1
- package/dist/merged-inverse-claims.js +29 -10
- package/dist/merged-inverse-claims.js.map +1 -1
- package/dist/merged-profile-units.d.ts +9 -0
- package/dist/merged-profile-units.d.ts.map +1 -0
- package/dist/merged-profile-units.js +44 -0
- package/dist/merged-profile-units.js.map +1 -0
- package/dist/related-entities.d.ts.map +1 -1
- package/dist/related-entities.js +11 -9
- package/dist/related-entities.js.map +1 -1
- package/dist/rust-artifact.d.ts +4 -0
- package/dist/rust-artifact.d.ts.map +1 -0
- package/dist/rust-artifact.js +15 -0
- package/dist/rust-artifact.js.map +1 -0
- package/dist/schema-calendar-date-values.d.ts +1 -0
- package/dist/schema-calendar-date-values.d.ts.map +1 -1
- package/dist/schema-calendar-date-values.js +4 -4
- package/dist/schema-calendar-date-values.js.map +1 -1
- package/dist/schema-calendar-dates.d.ts +16 -1
- package/dist/schema-calendar-dates.d.ts.map +1 -1
- package/dist/schema-calendar-dates.js +118 -19
- package/dist/schema-calendar-dates.js.map +1 -1
- package/dist/schema-conversion-loss-description.d.ts.map +1 -1
- package/dist/schema-conversion-loss-description.js +3 -0
- package/dist/schema-conversion-loss-description.js.map +1 -1
- package/dist/schema-conversion-loss-report.d.ts.map +1 -1
- package/dist/schema-conversion-loss-report.js +25 -36
- package/dist/schema-conversion-loss-report.js.map +1 -1
- package/dist/schema-conversion-loss-varying.d.ts +11 -0
- package/dist/schema-conversion-loss-varying.d.ts.map +1 -0
- package/dist/schema-conversion-loss-varying.js +44 -0
- package/dist/schema-conversion-loss-varying.js.map +1 -0
- package/dist/schema-converter-attr-maps.d.ts +6 -5
- package/dist/schema-converter-attr-maps.d.ts.map +1 -1
- package/dist/schema-converter-attr-maps.js +8 -6
- package/dist/schema-converter-attr-maps.js.map +1 -1
- package/dist/schema-converter-durations.d.ts +0 -3
- package/dist/schema-converter-durations.d.ts.map +1 -1
- package/dist/schema-converter-durations.js +0 -18
- package/dist/schema-converter-durations.js.map +1 -1
- package/dist/schema-converter-enums.d.ts +6 -3
- package/dist/schema-converter-enums.d.ts.map +1 -1
- package/dist/schema-converter-enums.js +25 -9
- package/dist/schema-converter-enums.js.map +1 -1
- package/dist/schema-converter-ifc4-slots.d.ts +10 -5
- package/dist/schema-converter-ifc4-slots.d.ts.map +1 -1
- package/dist/schema-converter-ifc4-slots.js +17 -20
- package/dist/schema-converter-ifc4-slots.js.map +1 -1
- package/dist/schema-converter-ifc4x3-upgrade.d.ts +5 -4
- package/dist/schema-converter-ifc4x3-upgrade.d.ts.map +1 -1
- package/dist/schema-converter-ifc4x3-upgrade.js +15 -8
- package/dist/schema-converter-ifc4x3-upgrade.js.map +1 -1
- package/dist/schema-converter-material-referent.d.ts +3 -0
- package/dist/schema-converter-material-referent.d.ts.map +1 -1
- package/dist/schema-converter-material-referent.js +24 -6
- package/dist/schema-converter-material-referent.js.map +1 -1
- package/dist/schema-converter-space-boundary.d.ts +47 -0
- package/dist/schema-converter-space-boundary.d.ts.map +1 -0
- package/dist/schema-converter-space-boundary.js +108 -0
- package/dist/schema-converter-space-boundary.js.map +1 -0
- package/dist/schema-converter-step-finish.d.ts.map +1 -1
- package/dist/schema-converter-step-finish.js +3 -2
- package/dist/schema-converter-step-finish.js.map +1 -1
- package/dist/schema-converter-structural-diagnostics.d.ts +6 -0
- package/dist/schema-converter-structural-diagnostics.d.ts.map +1 -1
- package/dist/schema-converter-structural-diagnostics.js +19 -4
- package/dist/schema-converter-structural-diagnostics.js.map +1 -1
- package/dist/schema-converter-structural-source.d.ts +3 -0
- package/dist/schema-converter-structural-source.d.ts.map +1 -1
- package/dist/schema-converter-structural-source.js.map +1 -1
- package/dist/schema-converter-structural-varying.d.ts +10 -2
- package/dist/schema-converter-structural-varying.d.ts.map +1 -1
- package/dist/schema-converter-structural-varying.js +28 -11
- package/dist/schema-converter-structural-varying.js.map +1 -1
- package/dist/schema-converter-structural.d.ts +3 -0
- package/dist/schema-converter-structural.d.ts.map +1 -1
- package/dist/schema-converter-structural.js +13 -5
- package/dist/schema-converter-structural.js.map +1 -1
- package/dist/schema-converter-typed-properties.js +1 -2
- package/dist/schema-converter-typed-properties.js.map +1 -1
- package/dist/schema-converter-unrooted-upgrade.d.ts +23 -6
- package/dist/schema-converter-unrooted-upgrade.d.ts.map +1 -1
- package/dist/schema-converter-unrooted-upgrade.js +62 -12
- package/dist/schema-converter-unrooted-upgrade.js.map +1 -1
- package/dist/schema-converter-value-forms.d.ts +28 -5
- package/dist/schema-converter-value-forms.d.ts.map +1 -1
- package/dist/schema-converter-value-forms.js +32 -19
- package/dist/schema-converter-value-forms.js.map +1 -1
- package/dist/schema-converter.d.ts +3 -4
- package/dist/schema-converter.d.ts.map +1 -1
- package/dist/schema-converter.js +25 -24
- package/dist/schema-converter.js.map +1 -1
- package/dist/schema-project-time-unit.d.ts +8 -0
- package/dist/schema-project-time-unit.d.ts.map +1 -0
- package/dist/schema-project-time-unit.js +123 -0
- package/dist/schema-project-time-unit.js.map +1 -0
- package/dist/schema-structural-varying-constant.d.ts +16 -0
- package/dist/schema-structural-varying-constant.d.ts.map +1 -0
- package/dist/schema-structural-varying-constant.js +36 -0
- package/dist/schema-structural-varying-constant.js.map +1 -0
- package/dist/schema-structural-varying-effective.d.ts +1 -1
- package/dist/schema-structural-varying-effective.d.ts.map +1 -1
- package/dist/schema-structural-varying-effective.js +12 -22
- package/dist/schema-structural-varying-effective.js.map +1 -1
- package/dist/schema-untranslatable.d.ts.map +1 -1
- package/dist/schema-untranslatable.js +5 -2
- package/dist/schema-untranslatable.js.map +1 -1
- package/dist/schema-work-control-durations.d.ts +13 -0
- package/dist/schema-work-control-durations.d.ts.map +1 -0
- package/dist/schema-work-control-durations.js +74 -0
- package/dist/schema-work-control-durations.js.map +1 -0
- package/dist/step-export-types.d.ts +3 -0
- 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.map +1 -1
- package/dist/step-exporter.js +2 -0
- package/dist/step-exporter.js.map +1 -1
- package/dist/step-omission-predicates.d.ts.map +1 -1
- package/dist/step-omission-predicates.js +3 -1
- package/dist/step-omission-predicates.js.map +1 -1
- package/dist/step-outer-args.d.ts +1 -1
- package/dist/step-outer-args.d.ts.map +1 -1
- package/dist/step-outer-args.js +10 -3
- package/dist/step-outer-args.js.map +1 -1
- package/dist/step-overlay-entities.d.ts.map +1 -1
- package/dist/step-overlay-entities.js +9 -0
- package/dist/step-overlay-entities.js.map +1 -1
- package/dist/step-pass-builder.d.ts.map +1 -1
- package/dist/step-pass-builder.js +21 -5
- package/dist/step-pass-builder.js.map +1 -1
- package/dist/step-property-set-readers.d.ts +4 -4
- package/dist/step-property-set-readers.d.ts.map +1 -1
- package/dist/step-property-set-readers.js +13 -13
- package/dist/step-property-set-readers.js.map +1 -1
- package/dist/step-retype-type-link.d.ts +7 -0
- package/dist/step-retype-type-link.d.ts.map +1 -0
- package/dist/step-retype-type-link.js +95 -0
- package/dist/step-retype-type-link.js.map +1 -0
- package/dist/step-source-iteration.d.ts.map +1 -1
- package/dist/step-source-iteration.js +10 -0
- package/dist/step-source-iteration.js.map +1 -1
- package/dist/step-subset-relations.d.ts +131 -0
- package/dist/step-subset-relations.d.ts.map +1 -0
- package/dist/step-subset-relations.js +342 -0
- package/dist/step-subset-relations.js.map +1 -0
- package/dist/step-subset-spatial-ancestors.d.ts +26 -0
- package/dist/step-subset-spatial-ancestors.d.ts.map +1 -0
- package/dist/step-subset-spatial-ancestors.js +103 -0
- package/dist/step-subset-spatial-ancestors.js.map +1 -0
- package/dist/step-subset-storey.d.ts +21 -0
- package/dist/step-subset-storey.d.ts.map +1 -0
- package/dist/step-subset-storey.js +319 -0
- package/dist/step-subset-storey.js.map +1 -0
- package/dist/step-subset.d.ts +68 -0
- package/dist/step-subset.d.ts.map +1 -0
- package/dist/step-subset.js +388 -0
- package/dist/step-subset.js.map +1 -0
- package/dist/unit-normalize.d.ts +14 -13
- package/dist/unit-normalize.d.ts.map +1 -1
- package/dist/unit-normalize.js +103 -85
- package/dist/unit-normalize.js.map +1 -1
- package/dist/xlsx-limits.d.ts +12 -0
- package/dist/xlsx-limits.d.ts.map +1 -0
- package/dist/xlsx-limits.js +48 -0
- package/dist/xlsx-limits.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
+
/**
|
|
5
|
+
* The storey selector of `selectSubsetSeeds`: resolve a storey token (GUID /
|
|
6
|
+
* name / expressId) to the storey, then to its members (see `storeyMembers`).
|
|
7
|
+
*/
|
|
8
|
+
import { IfcTypeEnumFromString, isSpatialStructureType, walkPlacementChain } from '@ifc-lite/data';
|
|
9
|
+
import { decodeStepStringLiteral } from '@ifc-lite/encoding';
|
|
10
|
+
import { expandTypes } from '@ifc-lite/parser';
|
|
11
|
+
import { slotRef, stepString } from './schema-converter-structural-source.js';
|
|
12
|
+
import { refsOutsideStrings, splitTopLevelArgs, STRUCTURE_RELATION_ATTRS, SubsetSelectionError } from './step-subset-relations.js';
|
|
13
|
+
import { structureParents } from './step-subset-spatial-ancestors.js';
|
|
14
|
+
const OBJECT_PLACEMENT = 5;
|
|
15
|
+
const PLACEMENT_TYPES = new Set(['IFCLOCALPLACEMENT', 'IFCGRIDPLACEMENT', 'IFCLINEARPLACEMENT']);
|
|
16
|
+
/** Map placements that have a PlacementRelTo slot to their parent placement. */
|
|
17
|
+
function placementParents(parsed, schemaVersion) {
|
|
18
|
+
const parents = new Map();
|
|
19
|
+
for (const inst of parsed.instances.values()) {
|
|
20
|
+
if (!PLACEMENT_TYPES.has(inst.type))
|
|
21
|
+
continue;
|
|
22
|
+
if (inst.type !== 'IFCLOCALPLACEMENT' && !schemaVersion?.toUpperCase().startsWith('IFC4X3')) {
|
|
23
|
+
parents.set(inst.id, null);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
// PlacementRelTo is the first attribute; comments around it are trivia.
|
|
27
|
+
parents.set(inst.id, slotRef(splitTopLevelArgs(inst.body)?.[0]));
|
|
28
|
+
}
|
|
29
|
+
return parents;
|
|
30
|
+
}
|
|
31
|
+
/** Every product whose ObjectPlacement chains up through `storeyPlacementId`. */
|
|
32
|
+
export function productsUnderPlacement(storeyPlacementId, parsed, schemaVersion) {
|
|
33
|
+
const parents = placementParents(parsed, schemaVersion);
|
|
34
|
+
const productTypes = new Set(expandTypes(['IFCPRODUCT'], schemaVersion));
|
|
35
|
+
const under = new Set();
|
|
36
|
+
// Whether each placement seen so far chains up through the storey's: shared
|
|
37
|
+
// ancestry is walked once, so the pass stays linear in the placement count.
|
|
38
|
+
const chainsUp = new Map();
|
|
39
|
+
for (const pid of parents.keys()) {
|
|
40
|
+
// The shared walker (#7791): a visited set, no depth cap, so a chain of any
|
|
41
|
+
// length resolves instead of being dropped past an arbitrary guard.
|
|
42
|
+
const walked = walkPlacementChain(pid, (id) => parents.get(id) ?? null, {
|
|
43
|
+
stopAt: (id) => id === storeyPlacementId || chainsUp.has(id),
|
|
44
|
+
});
|
|
45
|
+
const last = walked.ids[walked.ids.length - 1];
|
|
46
|
+
const reaches = walked.end === 'stopped' && (last === storeyPlacementId || chainsUp.get(last) === true);
|
|
47
|
+
for (const id of walked.ids)
|
|
48
|
+
if (id !== storeyPlacementId)
|
|
49
|
+
chainsUp.set(id, reaches);
|
|
50
|
+
if (reaches)
|
|
51
|
+
under.add(pid);
|
|
52
|
+
}
|
|
53
|
+
const seeds = new Set();
|
|
54
|
+
for (const inst of parsed.instances.values()) {
|
|
55
|
+
if (!productTypes.has(inst.type))
|
|
56
|
+
continue;
|
|
57
|
+
const placement = slotRef(splitTopLevelArgs(inst.body)?.[OBJECT_PLACEMENT]);
|
|
58
|
+
if (placement !== null && under.has(placement))
|
|
59
|
+
seeds.add(inst.id);
|
|
60
|
+
}
|
|
61
|
+
return seeds;
|
|
62
|
+
}
|
|
63
|
+
/** IfcBuildingStorey attribute positions: Name, then LongName (after ObjectPlacement, Representation). */
|
|
64
|
+
const NAME = 2;
|
|
65
|
+
const LONG_NAME = 7;
|
|
66
|
+
/** A storey record's decoded string attribute at `index`, or null when it is not a string. */
|
|
67
|
+
function storeyText(body, index) {
|
|
68
|
+
const text = stepString(splitTopLevelArgs(body)?.[index]);
|
|
69
|
+
if (text === null)
|
|
70
|
+
return null;
|
|
71
|
+
// Recover raw UTF-8 from the subset parser's byte-preserving Latin-1 view
|
|
72
|
+
// before interpreting STEP escapes, which can themselves produce Unicode.
|
|
73
|
+
let literal = text;
|
|
74
|
+
if (/[\u0080-\u00ff]/.test(text)) {
|
|
75
|
+
try {
|
|
76
|
+
const utf8 = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
|
|
77
|
+
literal = utf8.decode(Uint8Array.from(text, (c) => c.charCodeAt(0)));
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
if (!(err instanceof TypeError))
|
|
81
|
+
throw err;
|
|
82
|
+
// Invalid UTF-8: keep the literal's original Latin-1 characters.
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return decodeStepStringLiteral(literal);
|
|
86
|
+
}
|
|
87
|
+
/** Resolve a --storey selector (GUID / name / expressId) to the storey and its placement. */
|
|
88
|
+
export function resolveStorey(token, parsed) {
|
|
89
|
+
let storeyId;
|
|
90
|
+
const t = token.trim();
|
|
91
|
+
// Exact match on the decoded Name, then on LongName (Revit writes '02' as
|
|
92
|
+
// Name and 'Level 2' as LongName); never on Description or ObjectType text.
|
|
93
|
+
// Two storeys sharing the matched value are refused.
|
|
94
|
+
const byName = () => {
|
|
95
|
+
const storeys = [...parsed.instances.values()].filter((inst) => inst.type === 'IFCBUILDINGSTOREY');
|
|
96
|
+
for (const index of [NAME, LONG_NAME]) {
|
|
97
|
+
const hits = storeys.filter((inst) => storeyText(inst.body, index) === token).map((inst) => inst.id);
|
|
98
|
+
if (hits.length > 1)
|
|
99
|
+
throw new SubsetSelectionError('invalid', `${hits.length} storeys are named '${token}' (#${hits.join(', #')}); pass a GlobalId or #id.`);
|
|
100
|
+
if (hits.length === 1)
|
|
101
|
+
return hits[0];
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
};
|
|
105
|
+
if (/^#\d+$/.test(t)) {
|
|
106
|
+
storeyId = parseInt(t.slice(1), 10);
|
|
107
|
+
}
|
|
108
|
+
else if (parsed.guidToId.has(t)) {
|
|
109
|
+
storeyId = parsed.guidToId.get(t);
|
|
110
|
+
}
|
|
111
|
+
else if (/^\d+$/.test(t)) {
|
|
112
|
+
// Storeys are often NAMED '0', '1', ...: a bare number that is not a
|
|
113
|
+
// storey's express id is tried as a name before it is reported.
|
|
114
|
+
const id = parseInt(t, 10);
|
|
115
|
+
const isStoreyId = parsed.instances.get(id)?.type === 'IFCBUILDINGSTOREY';
|
|
116
|
+
let named;
|
|
117
|
+
try {
|
|
118
|
+
named = byName();
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
// For a token that is itself a storey id, report the id/name ambiguity
|
|
122
|
+
// instead of the bare duplicate-name error.
|
|
123
|
+
if (!(err instanceof SubsetSelectionError) || !isStoreyId)
|
|
124
|
+
throw err;
|
|
125
|
+
throw new SubsetSelectionError('invalid', `'${t}' is storey #${id} and the Name of other storeys; pass #${id} or a GlobalId.`);
|
|
126
|
+
}
|
|
127
|
+
if (isStoreyId && named !== undefined && named !== id) {
|
|
128
|
+
throw new SubsetSelectionError('invalid', `'${t}' is storey #${id} and the Name of storey #${named}; pass #${id} or a GlobalId.`);
|
|
129
|
+
}
|
|
130
|
+
storeyId = isStoreyId ? id : named ?? id;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
storeyId = byName();
|
|
134
|
+
}
|
|
135
|
+
if (storeyId === undefined)
|
|
136
|
+
throw new SubsetSelectionError('not-found', `Storey not found: ${token}`);
|
|
137
|
+
const storey = parsed.instances.get(storeyId);
|
|
138
|
+
if (!storey)
|
|
139
|
+
throw new SubsetSelectionError('not-found', `Storey not found: ${token} (no #${storeyId})`);
|
|
140
|
+
if (storey.type !== 'IFCBUILDINGSTOREY') {
|
|
141
|
+
throw new SubsetSelectionError('invalid', `#${storeyId} is ${storey.type}, not an IfcBuildingStorey`);
|
|
142
|
+
}
|
|
143
|
+
const placement = slotRef(splitTopLevelArgs(storey.body)?.[OBJECT_PLACEMENT]);
|
|
144
|
+
const placementType = placement === null ? undefined : parsed.instances.get(placement)?.type;
|
|
145
|
+
const placementId = placement !== null && placementType !== undefined && PLACEMENT_TYPES.has(placementType)
|
|
146
|
+
? placement : undefined;
|
|
147
|
+
// No placement is allowed (IFC permits a storey whose elements are placed
|
|
148
|
+
// independently); membership then comes from containment alone.
|
|
149
|
+
return { storeyId, placementId };
|
|
150
|
+
}
|
|
151
|
+
function isMissingStorey(error) {
|
|
152
|
+
return error instanceof SubsetSelectionError && error.kind === 'not-found';
|
|
153
|
+
}
|
|
154
|
+
export function resolveStoreyArgument(token, parsed, splitLists) {
|
|
155
|
+
try {
|
|
156
|
+
return [resolveStorey(token, parsed)];
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
if (!splitLists || !token.includes(',') || !isMissingStorey(error))
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
return token.split(',').filter((part) => part.trim()).map((part) => {
|
|
163
|
+
try {
|
|
164
|
+
return resolveStorey(part, parsed);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
if (part === part.trim() || !isMissingStorey(error))
|
|
168
|
+
throw error;
|
|
169
|
+
return resolveStorey(part.trim(), parsed);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
const PART_WHOLE_RELATIONS = new Set(['IFCRELAGGREGATES', 'IFCRELNESTS']);
|
|
174
|
+
const HOST_RELATIONS = new Set(['IFCRELVOIDSELEMENT', 'IFCRELFILLSELEMENT', 'IFCRELPROJECTSELEMENT', ...PART_WHOLE_RELATIONS]);
|
|
175
|
+
/**
|
|
176
|
+
* Opening -> host element (IfcRelVoidsElement), projection -> host
|
|
177
|
+
* (IfcRelProjectsElement), filler -> opening
|
|
178
|
+
* (IfcRelFillsElement), part -> whole (IfcRelAggregates / IfcRelNests under a
|
|
179
|
+
* non-spatial whole). All five share the six-attribute shape with the relating
|
|
180
|
+
* object at index 4 and the related set at index 5. Relation records that do
|
|
181
|
+
* not split into six attributes are skipped.
|
|
182
|
+
*/
|
|
183
|
+
function hostOf(parsed) {
|
|
184
|
+
const out = new Map();
|
|
185
|
+
for (const inst of parsed.instances.values()) {
|
|
186
|
+
if (!HOST_RELATIONS.has(inst.type))
|
|
187
|
+
continue;
|
|
188
|
+
const args = splitTopLevelArgs(inst.body);
|
|
189
|
+
if (!args || args.length !== STRUCTURE_RELATION_ATTRS)
|
|
190
|
+
continue;
|
|
191
|
+
const whole = slotRef(args[4]);
|
|
192
|
+
if (whole === null)
|
|
193
|
+
continue;
|
|
194
|
+
if (PART_WHOLE_RELATIONS.has(inst.type) && isSpatialStructureType(IfcTypeEnumFromString(parsed.instances.get(whole)?.type ?? '')))
|
|
195
|
+
continue;
|
|
196
|
+
for (const part of refsOutsideStrings(args[5]))
|
|
197
|
+
out.set(part, whole);
|
|
198
|
+
}
|
|
199
|
+
return out;
|
|
200
|
+
}
|
|
201
|
+
/** The relations that make a spatial element own another; a reference does not. */
|
|
202
|
+
const OWNERSHIP = new Set(['IFCRELCONTAINEDINSPATIALSTRUCTURE', 'IFCRELAGGREGATES']);
|
|
203
|
+
/**
|
|
204
|
+
* The nearest storeys above `id` in the spatial tree (containment and spatial
|
|
205
|
+
* aggregation, as `structureParents` reads them). The walk stops at the first
|
|
206
|
+
* storey on each path and keeps a visited set, so a cyclic or deep file
|
|
207
|
+
* terminates.
|
|
208
|
+
*/
|
|
209
|
+
function owningStoreys(id, parents, parsed) {
|
|
210
|
+
const found = new Set();
|
|
211
|
+
const visited = new Set([id]);
|
|
212
|
+
const stack = [...(parents.get(id) ?? [])];
|
|
213
|
+
while (stack.length > 0) {
|
|
214
|
+
const next = stack.pop();
|
|
215
|
+
if (visited.has(next))
|
|
216
|
+
continue;
|
|
217
|
+
visited.add(next);
|
|
218
|
+
if (parsed.instances.get(next)?.type === 'IFCBUILDINGSTOREY')
|
|
219
|
+
found.add(next);
|
|
220
|
+
else
|
|
221
|
+
stack.push(...(parents.get(next) ?? []));
|
|
222
|
+
}
|
|
223
|
+
return found;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* A storey's products: every element whose nearest storey in the spatial tree
|
|
227
|
+
* is this one (contained in it, or in a space or zone it aggregates), wherever
|
|
228
|
+
* it is placed; plus, for elements the spatial tree assigns to no storey, those
|
|
229
|
+
* whose placement chains through the storey's. Explicit ownership keeps
|
|
230
|
+
* assigned products separate even when storeys share a placement. A reference
|
|
231
|
+
* (IfcRelReferencedInSpatialStructure) is not ownership. A containment record
|
|
232
|
+
* that cannot be read leaves its element unowned, so the placement decides.
|
|
233
|
+
* Spatial-structure records other than IfcSpace are never products.
|
|
234
|
+
*/
|
|
235
|
+
export function storeyMembers(storeyId, placementId, parsed, schemaVersion) {
|
|
236
|
+
const parents = structureParents(parsed.instances, OWNERSHIP);
|
|
237
|
+
const hosts = hostOf(parsed);
|
|
238
|
+
const owners = new Map();
|
|
239
|
+
// An opening, filler or assembly part has no spatial owner of its own; it
|
|
240
|
+
// takes its host's or whole's, so it travels with that element.
|
|
241
|
+
const ownersOf = (id) => {
|
|
242
|
+
const cached = owners.get(id);
|
|
243
|
+
if (cached)
|
|
244
|
+
return cached;
|
|
245
|
+
const visited = new Set();
|
|
246
|
+
let at = id;
|
|
247
|
+
let found = new Set();
|
|
248
|
+
while (at !== undefined && !visited.has(at)) {
|
|
249
|
+
visited.add(at);
|
|
250
|
+
found = owningStoreys(at, parents, parsed);
|
|
251
|
+
if (found.size > 0)
|
|
252
|
+
break;
|
|
253
|
+
at = hosts.get(at);
|
|
254
|
+
}
|
|
255
|
+
owners.set(id, found);
|
|
256
|
+
return found;
|
|
257
|
+
};
|
|
258
|
+
// A storey the selected one aggregates (a mezzanine, a split level) is part of it.
|
|
259
|
+
const within = new Map();
|
|
260
|
+
const isWithin = (storey) => {
|
|
261
|
+
const cached = within.get(storey);
|
|
262
|
+
if (cached !== undefined)
|
|
263
|
+
return cached;
|
|
264
|
+
const visited = new Set();
|
|
265
|
+
const stack = [storey];
|
|
266
|
+
let found = false;
|
|
267
|
+
while (stack.length > 0 && !found) {
|
|
268
|
+
const next = stack.pop();
|
|
269
|
+
if (visited.has(next))
|
|
270
|
+
continue;
|
|
271
|
+
visited.add(next);
|
|
272
|
+
if (next === storeyId)
|
|
273
|
+
found = true;
|
|
274
|
+
else
|
|
275
|
+
stack.push(...(parents.get(next) ?? []));
|
|
276
|
+
}
|
|
277
|
+
within.set(storey, found);
|
|
278
|
+
return found;
|
|
279
|
+
};
|
|
280
|
+
const ownedHere = (owner) => [...owner].some(isWithin);
|
|
281
|
+
const isCandidate = (id) => {
|
|
282
|
+
const type = parsed.instances.get(id)?.type;
|
|
283
|
+
if (type === undefined || PLACEMENT_TYPES.has(type))
|
|
284
|
+
return false;
|
|
285
|
+
return type === 'IFCSPACE' || !isSpatialStructureType(IfcTypeEnumFromString(type));
|
|
286
|
+
};
|
|
287
|
+
const out = new Set();
|
|
288
|
+
// Spatial children, and openings/fillers/parts that inherit an owner, wherever placed.
|
|
289
|
+
const consider = (id) => {
|
|
290
|
+
if (!out.has(id) && isCandidate(id) && ownedHere(ownersOf(id)))
|
|
291
|
+
out.add(id);
|
|
292
|
+
};
|
|
293
|
+
for (const id of parents.keys())
|
|
294
|
+
consider(id);
|
|
295
|
+
for (const id of hosts.keys())
|
|
296
|
+
consider(id);
|
|
297
|
+
const placed = placementId === undefined ? [] : productsUnderPlacement(placementId, parsed, schemaVersion);
|
|
298
|
+
for (const id of placed) {
|
|
299
|
+
if (out.has(id) || !isCandidate(id))
|
|
300
|
+
continue;
|
|
301
|
+
const owner = ownersOf(id);
|
|
302
|
+
if (owner.size === 0 && !hosts.has(id))
|
|
303
|
+
out.add(id);
|
|
304
|
+
}
|
|
305
|
+
// Unowned parts, openings and fillers of an element the placement pass took
|
|
306
|
+
// come with it, wherever they are placed (fixpoint: parts of parts).
|
|
307
|
+
let grew = true;
|
|
308
|
+
while (grew) {
|
|
309
|
+
grew = false;
|
|
310
|
+
for (const [part, host] of hosts) {
|
|
311
|
+
if (out.has(part) || !out.has(host) || !isCandidate(part) || ownersOf(part).size > 0)
|
|
312
|
+
continue;
|
|
313
|
+
out.add(part);
|
|
314
|
+
grew = true;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return [...out];
|
|
318
|
+
}
|
|
319
|
+
//# sourceMappingURL=step-subset-storey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-subset-storey.js","sourceRoot":"","sources":["../src/step-subset-storey.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D;;;GAGG;AACH,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACnI,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,oBAAoB,CAAC,CAAC,CAAC;AAEjG,gFAAgF;AAChF,SAAS,gBAAgB,CAAC,MAAkB,EAAE,aAAsB;IAClE,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;IACjD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,S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
2
|
+
export { SubsetSelectionError } from './step-subset-relations.js';
|
|
3
|
+
export type { StepRecord, Subset } from './step-subset-relations.js';
|
|
4
|
+
export interface ParsedStep {
|
|
5
|
+
header: string;
|
|
6
|
+
instances: Map<number, StepRecord>;
|
|
7
|
+
/** 22-char GlobalId → expressId, for rooted entities. */
|
|
8
|
+
guidToId: Map<string, number>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* String-aware STEP DATA tokenizer. Splits the data section into instances at
|
|
12
|
+
* the `;` that terminates each `#id = TYPE(...)`, ignoring `;`/`#`/`(` inside
|
|
13
|
+
* STEP string literals (`'...'`, where `''` is an escaped quote). A regex split
|
|
14
|
+
* mis-fires on names containing `;` or `#` (common in Revit exports), so this
|
|
15
|
+
* scans character by character instead.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseStep(text: string): ParsedStep;
|
|
18
|
+
/** Resolve one selector token to an expressId (`#42`, `42`, or a GlobalId).
|
|
19
|
+
* An `#id` / bare id is validated against the model too, so a typo'd or stale
|
|
20
|
+
* id fails loudly instead of silently selecting nothing. */
|
|
21
|
+
export declare function resolveToId(token: string, parsed: ParsedStep): number;
|
|
22
|
+
/**
|
|
23
|
+
* Forward reference closure: every instance transitively referenced by
|
|
24
|
+
* `seeds`.
|
|
25
|
+
*
|
|
26
|
+
* Uses `refsOutsideStrings`, not a raw `/#(\d+)/g` scan, because a record's
|
|
27
|
+
* Name/Description is free TEXT and Revit writes `#`-shaped substrings into
|
|
28
|
+
* it (`'Chair pairs with #71'`). A raw regex reads that as a reference to
|
|
29
|
+
* entity 71 and pulls it — and its own closure — into the extraction even
|
|
30
|
+
* though it was never selected. See #4148.
|
|
31
|
+
*
|
|
32
|
+
* An id NAMED but never DEFINED is not added, or a rewritten SET would emit
|
|
33
|
+
* it as a dangling `#id` (#4128).
|
|
34
|
+
*/
|
|
35
|
+
export declare function forwardClosure(seeds: Iterable<number>, parsed: ParsedStep, into: Set<number>): void;
|
|
36
|
+
/**
|
|
37
|
+
* Assemble the subset: the closure of `seedProducts` + context roots
|
|
38
|
+
* (project/units/contexts + the backward closure of spatial ancestors, not
|
|
39
|
+
* the whole skeleton) + spatial-structure relations, each rewritten down to
|
|
40
|
+
* its kept members (so no dangling references).
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildSubset(seedProducts: Set<number>, parsed: ParsedStep): Subset;
|
|
43
|
+
/** Serialize the subset back into a valid STEP file (sorted, header preserved). */
|
|
44
|
+
export declare function serializeSubset({ keep, rewritten }: Subset, parsed: ParsedStep): string;
|
|
45
|
+
/** Selectors for {@link selectSubsetSeeds}; every selector is unioned. */
|
|
46
|
+
export interface SubsetSelectors {
|
|
47
|
+
/** `#42`, `42`, or a 22-char GlobalId. Each must resolve, or it throws. */
|
|
48
|
+
products?: readonly string[];
|
|
49
|
+
/** IFC type names; subtypes are included (`IfcWall` selects `IfcWallStandardCase`). */
|
|
50
|
+
types?: readonly string[];
|
|
51
|
+
/** Storey GlobalId, `#id`/id, or name: the storey and its members (see `storeyMembers`). */
|
|
52
|
+
storeys?: readonly string[];
|
|
53
|
+
/** Throw `SubsetSelectionError('invalid')` for any type or storey that selects nothing. */
|
|
54
|
+
requireEachMatch?: boolean;
|
|
55
|
+
/** The file's schema, when known: subtypes are expanded for it alone rather than for the union of all schemas. */
|
|
56
|
+
schemaVersion?: string;
|
|
57
|
+
/** Accept comma-delimited storey lists after trying each whole argument. */
|
|
58
|
+
splitStoreyLists?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Resolve selectors to seed product ids. A product or storey token that names
|
|
62
|
+
* nothing throws; a type that matches nothing just adds nothing, so the caller
|
|
63
|
+
* decides how to word an empty selection.
|
|
64
|
+
*
|
|
65
|
+
* An explicit schema overrides FILE_SCHEMA. Without either, types expand across bundled schemas.
|
|
66
|
+
*/
|
|
67
|
+
export declare function selectSubsetSeeds(parsed: ParsedStep, selectors: SubsetSelectors): Set<number>;
|
|
68
|
+
//# sourceMappingURL=step-subset.d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