@ifc-lite/create 2.4.0 → 2.6.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/ifc-creator-cost.d.ts +118 -0
- package/dist/ifc-creator-cost.d.ts.map +1 -0
- package/dist/ifc-creator-cost.js +337 -0
- package/dist/ifc-creator-cost.js.map +1 -0
- package/dist/ifc-creator-definitions.d.ts +21 -0
- package/dist/ifc-creator-definitions.d.ts.map +1 -0
- package/dist/ifc-creator-definitions.js +56 -0
- package/dist/ifc-creator-definitions.js.map +1 -0
- package/dist/ifc-creator-math.d.ts +29 -1
- package/dist/ifc-creator-math.d.ts.map +1 -1
- package/dist/ifc-creator-math.js +78 -0
- package/dist/ifc-creator-math.js.map +1 -1
- package/dist/ifc-creator-scheduling.d.ts +27 -0
- package/dist/ifc-creator-scheduling.d.ts.map +1 -0
- package/dist/ifc-creator-scheduling.js +131 -0
- package/dist/ifc-creator-scheduling.js.map +1 -0
- package/dist/ifc-creator.d.ts +46 -8
- package/dist/ifc-creator.d.ts.map +1 -1
- package/dist/ifc-creator.js +121 -126
- package/dist/ifc-creator.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/types-cost.d.ts +134 -0
- package/dist/types-cost.d.ts.map +1 -0
- package/dist/types-cost.js +5 -0
- package/dist/types-cost.js.map +1 -0
- package/dist/types-scheduling.d.ts +169 -0
- package/dist/types-scheduling.d.ts.map +1 -0
- package/dist/types-scheduling.js +5 -0
- package/dist/types-scheduling.js.map +1 -0
- package/dist/types.d.ts +8 -96
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { CostItemParams, CostQuantityParams, CostScheduleParams, CostTypedValue, CostValueParams, SIUnitParams } from './types-cost.js';
|
|
2
|
+
/** Allocate an express id, emit `#id=TYPE(attrs);`, and return the id. */
|
|
3
|
+
export type EmitEntity = (type: string, attrs: string) => number;
|
|
4
|
+
/** The schemas cost entities can be authored in (IFC2X3 is refused up front). */
|
|
5
|
+
export type CostSchema = 'IFC2X3' | 'IFC4' | 'IFC4X3';
|
|
6
|
+
/**
|
|
7
|
+
* Serialize a finite number as an exact STEP REAL.
|
|
8
|
+
*
|
|
9
|
+
* The shared `num()` expands exponent notation through `toFixed(10)`, which
|
|
10
|
+
* is fine for geometry but turns 1e-11 into 0 and leaves 1e21 in JS exponent
|
|
11
|
+
* form. A cost amount has no tolerance for either, and ISO 10303-21 REAL
|
|
12
|
+
* allows an exponent (`1.E-11`), so the shortest round-trip digits from
|
|
13
|
+
* `toString()` are kept and only rewritten into STEP's spelling.
|
|
14
|
+
*/
|
|
15
|
+
export declare function stepReal(v: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* Refuse IFC2X3 cost authoring by name, loudly.
|
|
18
|
+
*
|
|
19
|
+
* IFC2X3 lays IfcCostSchedule / IfcCostItem / IfcCostValue out differently
|
|
20
|
+
* (IfcCostSchedule carries an `ID` and IfcDateAndTime references where IFC4
|
|
21
|
+
* carries `Identification` and IfcDateTime strings; IfcCostValue has
|
|
22
|
+
* `CostType` where IFC4 has `Category`, and no `Components` at all). Writing
|
|
23
|
+
* the IFC4 layout into an IFC2X3 file would produce records that parse and are
|
|
24
|
+
* wrong. A no-op — or a method that returned an id having written nothing —
|
|
25
|
+
* would look like success at the call site, so this throws instead.
|
|
26
|
+
*/
|
|
27
|
+
export declare function assertCostSchema(schema: string, method: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Serialize a typed IFC value as a named SELECT branch.
|
|
30
|
+
*
|
|
31
|
+
* The branch comes from the caller, never from the shape of the number: 12 is
|
|
32
|
+
* a valid IfcMonetaryMeasure, IfcAreaMeasure, IfcCountMeasure and IfcInteger,
|
|
33
|
+
* and picking one by inspecting the value would silently retype the file.
|
|
34
|
+
*/
|
|
35
|
+
export declare function typedValue(value: CostTypedValue, schema: CostSchema, context: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Emit an IfcMonetaryUnit.
|
|
38
|
+
*
|
|
39
|
+
* The currency is written exactly as given. There is no default and no
|
|
40
|
+
* normalisation: an unstated currency must stay unstated, so callers that have
|
|
41
|
+
* none simply do not call this.
|
|
42
|
+
*/
|
|
43
|
+
export declare function emitMonetaryUnit(currency: string, emit: EmitEntity): number;
|
|
44
|
+
/**
|
|
45
|
+
* Emit an IfcSIUnit. [0] Dimensions, [1] UnitType, [2] Prefix, [3] Name.
|
|
46
|
+
*
|
|
47
|
+
* All three are ENUMERATION literals and `Name` is mandatory, so an unknown or
|
|
48
|
+
* empty string is refused rather than written as `.WHATEVER.` or `$` (the
|
|
49
|
+
* sandbox passes these straight through from untyped script input).
|
|
50
|
+
*/
|
|
51
|
+
export declare function emitSIUnit(params: SIUnitParams, emit: EmitEntity): number;
|
|
52
|
+
/**
|
|
53
|
+
* Emit an IfcMeasureWithUnit — the value/unit pair behind a cost rate's
|
|
54
|
+
* UnitBasis and behind an AppliedValue expressed as an entity rather than a
|
|
55
|
+
* literal. [0] ValueComponent (IfcValue SELECT), [1] UnitComponent.
|
|
56
|
+
*/
|
|
57
|
+
export declare function emitMeasureWithUnit(value: CostTypedValue, unitId: number, schema: CostSchema, emit: EmitEntity): number;
|
|
58
|
+
/**
|
|
59
|
+
* Emit an IfcPhysicalSimpleQuantity.
|
|
60
|
+
*
|
|
61
|
+
* The value attribute is a DEFINED TYPE (`IfcQuantityArea.AreaValue` is an
|
|
62
|
+
* `IfcAreaMeasure`), not a SELECT, so it is written as a bare number — the
|
|
63
|
+
* opposite of `IfcCostValue.AppliedValue`. Naming a branch here would be as
|
|
64
|
+
* wrong as omitting one there.
|
|
65
|
+
*
|
|
66
|
+
* The rules are schema-dependent: IfcCountMeasure is NUMBER in IFC4 but
|
|
67
|
+
* INTEGER in IFC4X3, IfcQuantityNumber only exists from IFC4X3, and every kind
|
|
68
|
+
* except IfcQuantityNumber carries a `WR: <Value> >= 0` rule.
|
|
69
|
+
*
|
|
70
|
+
* [0] Name, [1] Description, [2] Unit, [3] <Kind>Value, [4] Formula.
|
|
71
|
+
*/
|
|
72
|
+
export declare function emitPhysicalQuantity(params: CostQuantityParams, schema: CostSchema, emit: EmitEntity): number;
|
|
73
|
+
/**
|
|
74
|
+
* Emit an IfcCostValue.
|
|
75
|
+
*
|
|
76
|
+
* `AppliedValue` (a literal typed measure) and `AppliedValueRef` (an
|
|
77
|
+
* IfcMeasureWithUnit) are the two branches of one SELECT, so at most one may
|
|
78
|
+
* be given. Neither is synthesised from `Components`, and `Components` is
|
|
79
|
+
* never synthesised from either: which form the source used is part of what
|
|
80
|
+
* the file says.
|
|
81
|
+
*
|
|
82
|
+
* [0] Name, [1] Description, [2] AppliedValue, [3] UnitBasis,
|
|
83
|
+
* [4] ApplicableDate, [5] FixedUntilDate, [6] Category, [7] Condition,
|
|
84
|
+
* [8] ArithmeticOperator, [9] Components.
|
|
85
|
+
*/
|
|
86
|
+
export declare function emitCostValue(params: CostValueParams, schema: CostSchema, emit: EmitEntity): number;
|
|
87
|
+
/**
|
|
88
|
+
* Emit an IfcCostItem.
|
|
89
|
+
*
|
|
90
|
+
* [0] GlobalId, [1] OwnerHistory, [2] Name, [3] Description, [4] ObjectType,
|
|
91
|
+
* [5] Identification, [6] PredefinedType, [7] CostValues, [8] CostQuantities.
|
|
92
|
+
*/
|
|
93
|
+
export declare function emitCostItem(params: CostItemParams, globalId: string, ownerRef: string, emit: EmitEntity): number;
|
|
94
|
+
/**
|
|
95
|
+
* Emit an IfcRelAssignsToProduct — binds objects (here, IfcCostItems) to the
|
|
96
|
+
* product they price.
|
|
97
|
+
*
|
|
98
|
+
* DIRECTION IS NOT SYMMETRIC. The PRODUCT is `RelatingProduct` (index 6) and
|
|
99
|
+
* the cost items are `RelatedObjects` (index 4). Swapping them yields a
|
|
100
|
+
* relationship that is still well-formed STEP and says the opposite thing —
|
|
101
|
+
* which is why the cost read model type-checks both ends and flags
|
|
102
|
+
* `InvalidReferences` rather than trusting the shape.
|
|
103
|
+
*
|
|
104
|
+
* [0] GlobalId, [1] OwnerHistory, [2] Name, [3] Description,
|
|
105
|
+
* [4] RelatedObjects, [5] RelatedObjectsType, [6] RelatingProduct.
|
|
106
|
+
*/
|
|
107
|
+
export declare function emitRelAssignsToProduct(relatingProductId: number, relatedObjectIds: number[], newGlobalId: () => string, ownerRef: string, emit: EmitEntity): number;
|
|
108
|
+
/**
|
|
109
|
+
* Emit an IfcCostSchedule.
|
|
110
|
+
*
|
|
111
|
+
* [0] GlobalId, [1] OwnerHistory, [2] Name, [3] Description, [4] ObjectType,
|
|
112
|
+
* [5] Identification, [6] PredefinedType, [7] Status, [8] SubmittedOn,
|
|
113
|
+
* [9] UpdateDate. SubmittedOn / UpdateDate are IfcDateTime STRINGS in IFC4 —
|
|
114
|
+
* the IFC2X3 IfcDateAndTime entity references live at different indices, which
|
|
115
|
+
* is one of the reasons `assertCostSchema` refuses that schema outright.
|
|
116
|
+
*/
|
|
117
|
+
export declare function emitCostSchedule(params: CostScheduleParams, globalId: string, ownerRef: string, emit: EmitEntity): number;
|
|
118
|
+
//# sourceMappingURL=ifc-creator-cost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifc-creator-cost.d.ts","sourceRoot":"","sources":["../src/ifc-creator-cost.ts"],"names":[],"mappings":"AA0CA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,YAAY,EACb,MAAM,iBAAiB,CAAC;AAEzB,0EAA0E;AAC1E,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAEjE,iFAAiF;AACjF,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEtD;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAO1C;AAqCD;;;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;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,UAAU,GACf,MAAM,CAOR"}
|
|
@@ -0,0 +1,337 @@
|
|
|
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 shared STEP builder behind every 5D / cost entity `IfcCreator` authors —
|
|
6
|
+
* IfcCostSchedule, IfcCostItem, IfcCostValue, the units and measures they
|
|
7
|
+
* reference, and the IfcPhysicalSimpleQuantity a cost item is derived from.
|
|
8
|
+
*
|
|
9
|
+
* Split out of `ifc-creator.ts` so that file stays under its recorded
|
|
10
|
+
* module-size budget (see `scripts/module-size-allowlist.txt`), the same way
|
|
11
|
+
* `ifc-creator-scheduling.ts` is. The dependency on the creator is narrowed to
|
|
12
|
+
* the one `EmitEntity` callback: it allocates the next express id, writes the
|
|
13
|
+
* `#N=TYPE(attrs);` line, and returns the id — so nothing here reaches into
|
|
14
|
+
* the creator's private state, and every cost entity in a file goes through
|
|
15
|
+
* exactly one set of emitters whether the caller reached it directly or
|
|
16
|
+
* through another cost method.
|
|
17
|
+
*
|
|
18
|
+
* WHAT THIS FILE IS CAREFUL ABOUT
|
|
19
|
+
*
|
|
20
|
+
* 1. TYPED SELECT VALUES. `IfcCostValue.AppliedValue` (IfcAppliedValueSelect)
|
|
21
|
+
* and `IfcMeasureWithUnit.ValueComponent` (IfcValue) are SELECTs. STEP
|
|
22
|
+
* names the branch — `IFCMONETARYMEASURE(1234.56)` — and a bare `1234.56`
|
|
23
|
+
* in the same slot is still well-formed STEP that means something else.
|
|
24
|
+
* `typedValue()` is the only way a number reaches either attribute.
|
|
25
|
+
*
|
|
26
|
+
* 2. UNIT BASIS. `IfcCostValue.UnitBasis` is the quantity a rate is quoted
|
|
27
|
+
* per, so it divides. Writing it as anything but the caller's own
|
|
28
|
+
* IfcMeasureWithUnit moves the amount by orders of magnitude, not by a
|
|
29
|
+
* rounding step.
|
|
30
|
+
*
|
|
31
|
+
* 3. CURRENCY IS NEVER INVENTED. There is no default. A file whose author did
|
|
32
|
+
* not state a currency is written without an IfcMonetaryUnit, and reads
|
|
33
|
+
* back with no currency — which is a different (and honest) answer from a
|
|
34
|
+
* guessed one.
|
|
35
|
+
*
|
|
36
|
+
* 4. ABSENT IS NOT EMPTY. An optional LIST attribute the caller omitted is
|
|
37
|
+
* written `$`. An empty array is a caller error (EXPRESS declares these
|
|
38
|
+
* lists `[1:?]`) and is refused loudly rather than degraded to `$`.
|
|
39
|
+
*/
|
|
40
|
+
import { esc, optStr, optEnum, refList } from './ifc-creator-math.js';
|
|
41
|
+
/**
|
|
42
|
+
* Serialize a finite number as an exact STEP REAL.
|
|
43
|
+
*
|
|
44
|
+
* The shared `num()` expands exponent notation through `toFixed(10)`, which
|
|
45
|
+
* is fine for geometry but turns 1e-11 into 0 and leaves 1e21 in JS exponent
|
|
46
|
+
* form. A cost amount has no tolerance for either, and ISO 10303-21 REAL
|
|
47
|
+
* allows an exponent (`1.E-11`), so the shortest round-trip digits from
|
|
48
|
+
* `toString()` are kept and only rewritten into STEP's spelling.
|
|
49
|
+
*/
|
|
50
|
+
export function stepReal(v) {
|
|
51
|
+
const s = v.toString();
|
|
52
|
+
const e = s.search(/e/i);
|
|
53
|
+
if (e < 0)
|
|
54
|
+
return s.includes('.') ? s : `${s}.`;
|
|
55
|
+
const mantissa = s.slice(0, e);
|
|
56
|
+
const exponent = s.slice(e + 1).replace(/^\+/, '');
|
|
57
|
+
return `${mantissa.includes('.') ? mantissa : `${mantissa}.`}E${exponent}`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Runtime allow-lists for every closed vocabulary a cost method writes. The
|
|
61
|
+
* TypeScript unions only bind typed callers; the sandbox hands these methods
|
|
62
|
+
* untyped script input, and an unchecked string becomes `IFCBOGUSMEASURE(1.)`
|
|
63
|
+
* or `.BOGUS.` — well-formed STEP naming nothing in the schema.
|
|
64
|
+
*/
|
|
65
|
+
const MEASURE_TYPES = new Set([
|
|
66
|
+
'IfcMonetaryMeasure', 'IfcAreaMeasure', 'IfcVolumeMeasure', 'IfcLengthMeasure',
|
|
67
|
+
'IfcMassMeasure', 'IfcTimeMeasure', 'IfcCountMeasure', 'IfcNumericMeasure',
|
|
68
|
+
'IfcRatioMeasure', 'IfcReal', 'IfcInteger',
|
|
69
|
+
]);
|
|
70
|
+
const QUANTITY_KINDS = new Set([
|
|
71
|
+
'IfcQuantityLength', 'IfcQuantityArea', 'IfcQuantityVolume', 'IfcQuantityWeight',
|
|
72
|
+
'IfcQuantityTime', 'IfcQuantityCount', 'IfcQuantityNumber',
|
|
73
|
+
]);
|
|
74
|
+
const ARITHMETIC_OPERATORS = new Set(['ADD', 'DIVIDE', 'MULTIPLY', 'SUBTRACT']);
|
|
75
|
+
const COST_SCHEDULE_TYPES = new Set([
|
|
76
|
+
'BUDGET', 'COSTPLAN', 'ESTIMATE', 'TENDER', 'PRICEDBILLOFQUANTITIES',
|
|
77
|
+
'UNPRICEDBILLOFQUANTITIES', 'SCHEDULEOFRATES', 'USERDEFINED', 'NOTDEFINED',
|
|
78
|
+
]);
|
|
79
|
+
const COST_ITEM_TYPES = new Set(['USERDEFINED', 'NOTDEFINED']);
|
|
80
|
+
/** Refuse a value outside its closed vocabulary; `undefined` (absent) passes. */
|
|
81
|
+
function assertOneOf(value, allowed, what, context) {
|
|
82
|
+
if (value === undefined)
|
|
83
|
+
return;
|
|
84
|
+
if (typeof value !== 'string' || !allowed.has(value)) {
|
|
85
|
+
throw new Error(`${context}: ${what} '${String(value)}' is not one of ${[...allowed].join(', ')}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** EXPRESS INTEGER-valued measures: IfcInteger always, IfcCountMeasure from IFC4X3 on. */
|
|
89
|
+
function isIntegerMeasure(type, schema) {
|
|
90
|
+
return type === 'IfcInteger' || (type === 'IfcCountMeasure' && schema === 'IFC4X3');
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Refuse IFC2X3 cost authoring by name, loudly.
|
|
94
|
+
*
|
|
95
|
+
* IFC2X3 lays IfcCostSchedule / IfcCostItem / IfcCostValue out differently
|
|
96
|
+
* (IfcCostSchedule carries an `ID` and IfcDateAndTime references where IFC4
|
|
97
|
+
* carries `Identification` and IfcDateTime strings; IfcCostValue has
|
|
98
|
+
* `CostType` where IFC4 has `Category`, and no `Components` at all). Writing
|
|
99
|
+
* the IFC4 layout into an IFC2X3 file would produce records that parse and are
|
|
100
|
+
* wrong. A no-op — or a method that returned an id having written nothing —
|
|
101
|
+
* would look like success at the call site, so this throws instead.
|
|
102
|
+
*/
|
|
103
|
+
export function assertCostSchema(schema, method) {
|
|
104
|
+
if (schema === 'IFC2X3') {
|
|
105
|
+
throw new Error(`${method} is not supported for IFC2X3: the IFC2X3 cost entities have a different `
|
|
106
|
+
+ 'attribute layout. Create the IfcCreator with Schema "IFC4" or "IFC4X3".');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Serialize a typed IFC value as a named SELECT branch.
|
|
111
|
+
*
|
|
112
|
+
* The branch comes from the caller, never from the shape of the number: 12 is
|
|
113
|
+
* a valid IfcMonetaryMeasure, IfcAreaMeasure, IfcCountMeasure and IfcInteger,
|
|
114
|
+
* and picking one by inspecting the value would silently retype the file.
|
|
115
|
+
*/
|
|
116
|
+
export function typedValue(value, schema, context) {
|
|
117
|
+
if (value === undefined || value === null)
|
|
118
|
+
throw new Error(`${context}: a typed value is required`);
|
|
119
|
+
assertOneOf(value.Type, MEASURE_TYPES, 'Type', context);
|
|
120
|
+
if (!Number.isFinite(value.Value)) {
|
|
121
|
+
throw new Error(`${context}: ${value.Type} value must be a finite number`);
|
|
122
|
+
}
|
|
123
|
+
// Rounding would silently change the caller's number: an INTEGER measure
|
|
124
|
+
// given a fraction is a caller error, not something to fix up.
|
|
125
|
+
if (isIntegerMeasure(value.Type, schema)) {
|
|
126
|
+
if (!Number.isInteger(value.Value)) {
|
|
127
|
+
throw new Error(`${context}: ${value.Type} value must be an integer in ${schema}, got ${value.Value}`);
|
|
128
|
+
}
|
|
129
|
+
return `${value.Type.toUpperCase()}(${value.Value.toString()})`;
|
|
130
|
+
}
|
|
131
|
+
return `${value.Type.toUpperCase()}(${stepReal(value.Value)})`;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Serialize an optional LIST-of-reference attribute.
|
|
135
|
+
*
|
|
136
|
+
* `undefined` is absent and becomes `$`. An empty array is NOT absent: the
|
|
137
|
+
* EXPRESS declaration is `[1:?]`, so `()` would be a malformed list that the
|
|
138
|
+
* reader reports as INVALID_LIST. Refusing here keeps the two states distinct
|
|
139
|
+
* end to end.
|
|
140
|
+
*/
|
|
141
|
+
function optRefList(ids, attribute, context) {
|
|
142
|
+
if (ids === undefined)
|
|
143
|
+
return '$';
|
|
144
|
+
if (ids.length === 0) {
|
|
145
|
+
throw new Error(`${context}: ${attribute} must name at least one entity. Omit the field entirely `
|
|
146
|
+
+ 'to write it as absent — an empty list is a malformed IFC list, not "no value".');
|
|
147
|
+
}
|
|
148
|
+
for (const id of ids) {
|
|
149
|
+
if (!Number.isInteger(id) || id <= 0) {
|
|
150
|
+
throw new Error(`${context}: ${attribute} contains '${id}', which is not an express id`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return refList(ids);
|
|
154
|
+
}
|
|
155
|
+
/** Require a positive integer express id for a single-reference attribute. */
|
|
156
|
+
function requireRef(id, attribute, context) {
|
|
157
|
+
if (!Number.isInteger(id) || id <= 0) {
|
|
158
|
+
throw new Error(`${context}: ${attribute} must be an express id, got '${id}'`);
|
|
159
|
+
}
|
|
160
|
+
return `#${id}`;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Emit an IfcMonetaryUnit.
|
|
164
|
+
*
|
|
165
|
+
* The currency is written exactly as given. There is no default and no
|
|
166
|
+
* normalisation: an unstated currency must stay unstated, so callers that have
|
|
167
|
+
* none simply do not call this.
|
|
168
|
+
*/
|
|
169
|
+
export function emitMonetaryUnit(currency, emit) {
|
|
170
|
+
if (typeof currency !== 'string' || currency.trim().length === 0) {
|
|
171
|
+
throw new Error('addIfcMonetaryUnit: Currency must be a non-empty string (there is no default currency)');
|
|
172
|
+
}
|
|
173
|
+
// IFC4 IfcMonetaryUnit: [0] Currency (IfcLabel).
|
|
174
|
+
return emit('IFCMONETARYUNIT', `'${esc(currency)}'`);
|
|
175
|
+
}
|
|
176
|
+
const SI_PREFIXES = new Set([
|
|
177
|
+
'ATTO', 'CENTI', 'DECA', 'DECI', 'EXA', 'FEMTO', 'GIGA', 'HECTO',
|
|
178
|
+
'KILO', 'MEGA', 'MICRO', 'MILLI', 'NANO', 'PETA', 'PICO', 'TERA',
|
|
179
|
+
]);
|
|
180
|
+
/** The one IfcSIUnitName each authorable UnitType is dimensionally consistent with. */
|
|
181
|
+
const SI_NAME_FOR_UNIT_TYPE = {
|
|
182
|
+
LENGTHUNIT: 'METRE',
|
|
183
|
+
AREAUNIT: 'SQUARE_METRE',
|
|
184
|
+
VOLUMEUNIT: 'CUBIC_METRE',
|
|
185
|
+
MASSUNIT: 'GRAM',
|
|
186
|
+
TIMEUNIT: 'SECOND',
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Emit an IfcSIUnit. [0] Dimensions, [1] UnitType, [2] Prefix, [3] Name.
|
|
190
|
+
*
|
|
191
|
+
* All three are ENUMERATION literals and `Name` is mandatory, so an unknown or
|
|
192
|
+
* empty string is refused rather than written as `.WHATEVER.` or `$` (the
|
|
193
|
+
* sandbox passes these straight through from untyped script input).
|
|
194
|
+
*/
|
|
195
|
+
export function emitSIUnit(params, emit) {
|
|
196
|
+
const expected = SI_NAME_FOR_UNIT_TYPE[params.UnitType];
|
|
197
|
+
if (expected === undefined) {
|
|
198
|
+
throw new Error(`addIfcSIUnit: UnitType must be one of ${Object.keys(SI_NAME_FOR_UNIT_TYPE).join(', ')}, got '${params.UnitType}'`);
|
|
199
|
+
}
|
|
200
|
+
if (params.Name !== expected) {
|
|
201
|
+
throw new Error(`addIfcSIUnit: a ${params.UnitType} must be named '${expected}', got '${params.Name}'`);
|
|
202
|
+
}
|
|
203
|
+
if (params.Prefix !== undefined && !SI_PREFIXES.has(params.Prefix)) {
|
|
204
|
+
throw new Error(`addIfcSIUnit: Prefix '${params.Prefix}' is not an IfcSIPrefix`);
|
|
205
|
+
}
|
|
206
|
+
return emit('IFCSIUNIT', `*,${optEnum(params.UnitType)},${optEnum(params.Prefix)},${optEnum(params.Name)}`);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Emit an IfcMeasureWithUnit — the value/unit pair behind a cost rate's
|
|
210
|
+
* UnitBasis and behind an AppliedValue expressed as an entity rather than a
|
|
211
|
+
* literal. [0] ValueComponent (IfcValue SELECT), [1] UnitComponent.
|
|
212
|
+
*/
|
|
213
|
+
export function emitMeasureWithUnit(value, unitId, schema, emit) {
|
|
214
|
+
const unitRef = requireRef(unitId, 'UnitComponent', 'addIfcMeasureWithUnit');
|
|
215
|
+
return emit('IFCMEASUREWITHUNIT', `${typedValue(value, schema, 'addIfcMeasureWithUnit')},${unitRef}`);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Emit an IfcPhysicalSimpleQuantity.
|
|
219
|
+
*
|
|
220
|
+
* The value attribute is a DEFINED TYPE (`IfcQuantityArea.AreaValue` is an
|
|
221
|
+
* `IfcAreaMeasure`), not a SELECT, so it is written as a bare number — the
|
|
222
|
+
* opposite of `IfcCostValue.AppliedValue`. Naming a branch here would be as
|
|
223
|
+
* wrong as omitting one there.
|
|
224
|
+
*
|
|
225
|
+
* The rules are schema-dependent: IfcCountMeasure is NUMBER in IFC4 but
|
|
226
|
+
* INTEGER in IFC4X3, IfcQuantityNumber only exists from IFC4X3, and every kind
|
|
227
|
+
* except IfcQuantityNumber carries a `WR: <Value> >= 0` rule.
|
|
228
|
+
*
|
|
229
|
+
* [0] Name, [1] Description, [2] Unit, [3] <Kind>Value, [4] Formula.
|
|
230
|
+
*/
|
|
231
|
+
export function emitPhysicalQuantity(params, schema, emit) {
|
|
232
|
+
assertOneOf(params.Kind, QUANTITY_KINDS, 'Kind', 'addIfcPhysicalQuantity');
|
|
233
|
+
const context = `addIfcPhysicalQuantity: ${params.Kind} '${params.Name}'`;
|
|
234
|
+
if (params.Kind === 'IfcQuantityNumber' && schema !== 'IFC4X3') {
|
|
235
|
+
throw new Error(`${context} does not exist in ${schema}; IfcQuantityNumber requires Schema "IFC4X3"`);
|
|
236
|
+
}
|
|
237
|
+
if (!Number.isFinite(params.Value)) {
|
|
238
|
+
throw new Error(`${context} value must be a finite number`);
|
|
239
|
+
}
|
|
240
|
+
if (params.Kind === 'IfcQuantityCount' && schema === 'IFC4X3' && !Number.isInteger(params.Value)) {
|
|
241
|
+
throw new Error(`${context} value must be a finite integer in IFC4X3 (IfcCountMeasure is INTEGER)`);
|
|
242
|
+
}
|
|
243
|
+
if (params.Kind !== 'IfcQuantityNumber' && params.Value < 0) {
|
|
244
|
+
throw new Error(`${context} value must be non-negative, got ${params.Value}`);
|
|
245
|
+
}
|
|
246
|
+
const unitRef = params.Unit === undefined
|
|
247
|
+
? '$'
|
|
248
|
+
: requireRef(params.Unit, 'Unit', 'addIfcPhysicalQuantity');
|
|
249
|
+
// An IFC4X3 count is INTEGER, so it takes no trailing `.` (that spells a REAL).
|
|
250
|
+
const value = params.Kind === 'IfcQuantityCount' && schema === 'IFC4X3'
|
|
251
|
+
? params.Value.toString()
|
|
252
|
+
: stepReal(params.Value);
|
|
253
|
+
return emit(params.Kind.toUpperCase(), `'${esc(params.Name)}',${optStr(params.Description)},${unitRef},${value},${optStr(params.Formula)}`);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Emit an IfcCostValue.
|
|
257
|
+
*
|
|
258
|
+
* `AppliedValue` (a literal typed measure) and `AppliedValueRef` (an
|
|
259
|
+
* IfcMeasureWithUnit) are the two branches of one SELECT, so at most one may
|
|
260
|
+
* be given. Neither is synthesised from `Components`, and `Components` is
|
|
261
|
+
* never synthesised from either: which form the source used is part of what
|
|
262
|
+
* the file says.
|
|
263
|
+
*
|
|
264
|
+
* [0] Name, [1] Description, [2] AppliedValue, [3] UnitBasis,
|
|
265
|
+
* [4] ApplicableDate, [5] FixedUntilDate, [6] Category, [7] Condition,
|
|
266
|
+
* [8] ArithmeticOperator, [9] Components.
|
|
267
|
+
*/
|
|
268
|
+
export function emitCostValue(params, schema, emit) {
|
|
269
|
+
assertOneOf(params.ArithmeticOperator, ARITHMETIC_OPERATORS, 'ArithmeticOperator', 'addIfcCostValue');
|
|
270
|
+
if (params.AppliedValue !== undefined && params.AppliedValueRef !== undefined) {
|
|
271
|
+
throw new Error('addIfcCostValue: AppliedValue and AppliedValueRef are the two branches of one SELECT — give at most one');
|
|
272
|
+
}
|
|
273
|
+
let applied = '$';
|
|
274
|
+
if (params.AppliedValue !== undefined) {
|
|
275
|
+
applied = typedValue(params.AppliedValue, schema, 'addIfcCostValue');
|
|
276
|
+
}
|
|
277
|
+
else if (params.AppliedValueRef !== undefined) {
|
|
278
|
+
applied = requireRef(params.AppliedValueRef, 'AppliedValueRef', 'addIfcCostValue');
|
|
279
|
+
}
|
|
280
|
+
const unitBasis = params.UnitBasis === undefined
|
|
281
|
+
? '$'
|
|
282
|
+
: requireRef(params.UnitBasis, 'UnitBasis', 'addIfcCostValue');
|
|
283
|
+
return emit('IFCCOSTVALUE', `${optStr(params.Name)},${optStr(params.Description)},${applied},${unitBasis},`
|
|
284
|
+
+ `${optStr(params.ApplicableDate)},${optStr(params.FixedUntilDate)},`
|
|
285
|
+
+ `${optStr(params.Category)},${optStr(params.Condition)},`
|
|
286
|
+
+ `${optEnum(params.ArithmeticOperator)},`
|
|
287
|
+
+ `${optRefList(params.Components, 'Components', 'addIfcCostValue')}`);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Emit an IfcCostItem.
|
|
291
|
+
*
|
|
292
|
+
* [0] GlobalId, [1] OwnerHistory, [2] Name, [3] Description, [4] ObjectType,
|
|
293
|
+
* [5] Identification, [6] PredefinedType, [7] CostValues, [8] CostQuantities.
|
|
294
|
+
*/
|
|
295
|
+
export function emitCostItem(params, globalId, ownerRef, emit) {
|
|
296
|
+
assertOneOf(params.PredefinedType, COST_ITEM_TYPES, 'PredefinedType', 'addIfcCostItem');
|
|
297
|
+
return emit('IFCCOSTITEM', `'${globalId}',${ownerRef},'${esc(params.Name)}',${optStr(params.Description)},`
|
|
298
|
+
+ `${optStr(params.ObjectType)},${optStr(params.Identification)},`
|
|
299
|
+
+ `${optEnum(params.PredefinedType)},`
|
|
300
|
+
+ `${optRefList(params.CostValues, 'CostValues', 'addIfcCostItem')},`
|
|
301
|
+
+ `${optRefList(params.CostQuantities, 'CostQuantities', 'addIfcCostItem')}`);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Emit an IfcRelAssignsToProduct — binds objects (here, IfcCostItems) to the
|
|
305
|
+
* product they price.
|
|
306
|
+
*
|
|
307
|
+
* DIRECTION IS NOT SYMMETRIC. The PRODUCT is `RelatingProduct` (index 6) and
|
|
308
|
+
* the cost items are `RelatedObjects` (index 4). Swapping them yields a
|
|
309
|
+
* relationship that is still well-formed STEP and says the opposite thing —
|
|
310
|
+
* which is why the cost read model type-checks both ends and flags
|
|
311
|
+
* `InvalidReferences` rather than trusting the shape.
|
|
312
|
+
*
|
|
313
|
+
* [0] GlobalId, [1] OwnerHistory, [2] Name, [3] Description,
|
|
314
|
+
* [4] RelatedObjects, [5] RelatedObjectsType, [6] RelatingProduct.
|
|
315
|
+
*/
|
|
316
|
+
export function emitRelAssignsToProduct(relatingProductId, relatedObjectIds, newGlobalId, ownerRef, emit) {
|
|
317
|
+
const refs = optRefList(relatedObjectIds, 'relatedObjectIds', 'addIfcRelAssignsToProduct');
|
|
318
|
+
const productRef = requireRef(relatingProductId, 'relatingProductId', 'addIfcRelAssignsToProduct');
|
|
319
|
+
return emit('IFCRELASSIGNSTOPRODUCT', `'${newGlobalId()}',${ownerRef},$,$,${refs},$,${productRef}`);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Emit an IfcCostSchedule.
|
|
323
|
+
*
|
|
324
|
+
* [0] GlobalId, [1] OwnerHistory, [2] Name, [3] Description, [4] ObjectType,
|
|
325
|
+
* [5] Identification, [6] PredefinedType, [7] Status, [8] SubmittedOn,
|
|
326
|
+
* [9] UpdateDate. SubmittedOn / UpdateDate are IfcDateTime STRINGS in IFC4 —
|
|
327
|
+
* the IFC2X3 IfcDateAndTime entity references live at different indices, which
|
|
328
|
+
* is one of the reasons `assertCostSchema` refuses that schema outright.
|
|
329
|
+
*/
|
|
330
|
+
export function emitCostSchedule(params, globalId, ownerRef, emit) {
|
|
331
|
+
assertOneOf(params.PredefinedType, COST_SCHEDULE_TYPES, 'PredefinedType', 'addIfcCostSchedule');
|
|
332
|
+
return emit('IFCCOSTSCHEDULE', `'${globalId}',${ownerRef},'${esc(params.Name)}',${optStr(params.Description)},`
|
|
333
|
+
+ `${optStr(params.ObjectType)},${optStr(params.Identification)},`
|
|
334
|
+
+ `${optEnum(params.PredefinedType)},${optStr(params.Status)},`
|
|
335
|
+
+ `${optStr(params.SubmittedOn)},${optStr(params.UpdateDate)}`);
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=ifc-creator-cost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifc-creator-cost.js","sourceRoot":"","sources":["../src/ifc-creator-cost.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,O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AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB,CACrC,iBAAyB,EACzB,gBAA0B,EAC1B,WAAyB,EACzB,QAAgB,EAChB,IAAgB;IAEhB,MAAM,IAAI,GAAG,UAAU,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,2BAA2B,CAAC,CAAC;IAC3F,MAAM,UAAU,GAAG,UAAU,CAAC,iBAAiB,EAAE,mBAAmB,EAAE,2BAA2B,CAAC,CAAC;IACnG,OAAO,IAAI,CAAC,wBAAwB,EAClC,IAAI,WAAW,EAAE,KAAK,QAAQ,QAAQ,IAAI,MAAM,UAAU,EAAE,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAA0B,EAC1B,QAAgB,EAChB,QAAgB,EAChB,IAAgB;IAEhB,WAAW,CAAC,MAAM,CAAC,cAAc,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CAAC;IAChG,OAAO,IAAI,CAAC,iBAAiB,EAC3B,IAAI,QAAQ,KAAK,QAAQ,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG;UAC9E,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG;UAChE,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG;UAC7D,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EmitEntity } from './ifc-creator-cost.js';
|
|
2
|
+
import type { PropertySetDef, QuantitySetDef } from './types.js';
|
|
3
|
+
/** The creator hooks these emitters need. */
|
|
4
|
+
export interface DefinitionContext {
|
|
5
|
+
emit: EmitEntity;
|
|
6
|
+
newGlobalId: () => string;
|
|
7
|
+
ownerRef: string;
|
|
8
|
+
/** Renders a trailing IFC4/IFC4X3-only attribute, or nothing under IFC2X3. */
|
|
9
|
+
ifc4Only: (value: string) => string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Emit an IfcPropertySet, its IfcPropertySingleValue properties, and the
|
|
13
|
+
* IfcRelDefinesByProperties binding it to `elementId`. Returns the pset id.
|
|
14
|
+
*/
|
|
15
|
+
export declare function emitPropertySet(elementId: number, pset: PropertySetDef, context: DefinitionContext): number;
|
|
16
|
+
/**
|
|
17
|
+
* Emit an IfcElementQuantity, its IfcPhysicalSimpleQuantity members, and the
|
|
18
|
+
* IfcRelDefinesByProperties binding it to `elementId`. Returns the qset id.
|
|
19
|
+
*/
|
|
20
|
+
export declare function emitElementQuantity(elementId: number, qset: QuantitySetDef, context: DefinitionContext): number;
|
|
21
|
+
//# sourceMappingURL=ifc-creator-definitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifc-creator-definitions.d.ts","sourceRoot":"","sources":["../src/ifc-creator-definitions.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAejE,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,EAAE,MAAM,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACrC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,iBAAiB,GACzB,MAAM,CAUR;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,iBAAiB,GACzB,MAAM,CAWR"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* STEP emission for the two IfcRelDefinesByProperties payloads `IfcCreator`
|
|
6
|
+
* attaches to an element: IfcPropertySet and IfcElementQuantity, each with the
|
|
7
|
+
* IfcPropertySingleValue / IfcPhysicalSimpleQuantity entities it owns.
|
|
8
|
+
*
|
|
9
|
+
* Split out of `ifc-creator.ts` so that file stays under its recorded
|
|
10
|
+
* module-size budget (`scripts/module-size-allowlist.txt`), the same way
|
|
11
|
+
* `ifc-creator-scheduling.ts` and `ifc-creator-cost.ts` are. The dependency on
|
|
12
|
+
* the creator is narrowed to three callbacks — allocate-and-write an entity,
|
|
13
|
+
* mint a GlobalId, and render the trailing IFC4-only attribute — so nothing
|
|
14
|
+
* here reaches into the creator's private state. Behaviour is unchanged from
|
|
15
|
+
* when these bodies lived on the class.
|
|
16
|
+
*/
|
|
17
|
+
import { esc, quantityValueField, serializePropertyValue } from './ifc-creator-math.js';
|
|
18
|
+
/**
|
|
19
|
+
* Refuse an empty or sparse array before anything is emitted. Both aggregates
|
|
20
|
+
* are `SET [1:?]`, so `[]` would write a schema-invalid `()`; and `map`
|
|
21
|
+
* skips holes while `join` renders them as empty refs, so `new Array(1)`
|
|
22
|
+
* would write the same instead of failing like the pre-split `for...of` loop.
|
|
23
|
+
*/
|
|
24
|
+
function assertDense(items, what) {
|
|
25
|
+
if (!Array.isArray(items) || items.length === 0)
|
|
26
|
+
throw new Error(`${what} must contain at least one entry`);
|
|
27
|
+
for (let i = 0; i < items.length; i++) {
|
|
28
|
+
if (!(i in items) || items[i] == null)
|
|
29
|
+
throw new Error(`${what}[${i}] is missing`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Emit an IfcPropertySet, its IfcPropertySingleValue properties, and the
|
|
34
|
+
* IfcRelDefinesByProperties binding it to `elementId`. Returns the pset id.
|
|
35
|
+
*/
|
|
36
|
+
export function emitPropertySet(elementId, pset, context) {
|
|
37
|
+
assertDense(pset.Properties, `addIfcPropertySet '${pset.Name}': Properties`);
|
|
38
|
+
const propIds = pset.Properties.map(prop => context.emit('IFCPROPERTYSINGLEVALUE', `'${esc(prop.Name)}',$,${serializePropertyValue(prop)},$`));
|
|
39
|
+
const refs = propIds.map(id => `#${id}`).join(',');
|
|
40
|
+
const psetId = context.emit('IFCPROPERTYSET', `'${context.newGlobalId()}',${context.ownerRef},'${esc(pset.Name)}',$,(${refs})`);
|
|
41
|
+
context.emit('IFCRELDEFINESBYPROPERTIES', `'${context.newGlobalId()}',${context.ownerRef},$,$,(#${elementId}),#${psetId}`);
|
|
42
|
+
return psetId;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Emit an IfcElementQuantity, its IfcPhysicalSimpleQuantity members, and the
|
|
46
|
+
* IfcRelDefinesByProperties binding it to `elementId`. Returns the qset id.
|
|
47
|
+
*/
|
|
48
|
+
export function emitElementQuantity(elementId, qset, context) {
|
|
49
|
+
assertDense(qset.Quantities, `addIfcElementQuantity '${qset.Name}': Quantities`);
|
|
50
|
+
const qtyIds = qset.Quantities.map(qty => context.emit(qty.Kind.toUpperCase(), `'${esc(qty.Name)}',$,${quantityValueField(qty)}${context.ifc4Only('$')}`));
|
|
51
|
+
const refs = qtyIds.map(id => `#${id}`).join(',');
|
|
52
|
+
const qsetId = context.emit('IFCELEMENTQUANTITY', `'${context.newGlobalId()}',${context.ownerRef},'${esc(qset.Name)}',$,$,(${refs})`);
|
|
53
|
+
context.emit('IFCRELDEFINESBYPROPERTIES', `'${context.newGlobalId()}',${context.ownerRef},$,$,(#${elementId}),#${qsetId}`);
|
|
54
|
+
return qsetId;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=ifc-creator-definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifc-creator-definitions.js","sourceRoot":"","sources":["../src/ifc-creator-definitions.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,GAAG,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAIxF;;;;;GAKG;AACH,SAAS,WAAW,CAAC,KAAyB,EAAE,IAAY;IAC1D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,kCAAkC,CAAC,CAAC;IAC5G,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,CAAC;IACrF,CAAC;AACH,CAAC;AAWD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,SAAiB,EACjB,IAAoB,EACpB,OAA0B;IAE1B,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,sBAAsB,IAAI,CAAC,IAAI,eAAe,CAAC,CAAC;IAC7E,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CACzC,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,sBAAsB,CAAC,IAAI,CAAC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AAQ,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC;IACtF,OAAO,CAAC,IAAI,CAAC,2BAA2B,EACtC,IAAI,OAAO,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,QAAQ,UAAU,SAAS,MAAM,MAAM,EAAE,CAAC,CAAC;IACnF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Pure utility functions and constants used by IfcCreator.
|
|
3
3
|
* These have zero coupling to class state — they take inputs and return outputs.
|
|
4
4
|
*/
|
|
5
|
-
import type { Point3D } from './types.js';
|
|
5
|
+
import type { Point3D, PropertyDef, QuantityDef } from './types.js';
|
|
6
6
|
/** Escape a string for STEP format */
|
|
7
7
|
export declare function esc(str: string): string;
|
|
8
8
|
/** Format a STEP line: #ID=TYPE(args); */
|
|
@@ -41,4 +41,32 @@ export declare function assertPositiveFinite(values: Record<string, number>, con
|
|
|
41
41
|
export declare function assertFinitePoint3(points: Record<string, Point3D>, context: string): void;
|
|
42
42
|
/** Cross product */
|
|
43
43
|
export declare function vecCross(a: Point3D, b: Point3D): Point3D;
|
|
44
|
+
/** Emit an optional STEP string: `'value'` when present, `$` otherwise. */
|
|
45
|
+
export declare function optStr(v: string | undefined | null): string;
|
|
46
|
+
/** Emit an optional STEP enum: `.VALUE.` when present, `$` otherwise. */
|
|
47
|
+
export declare function optEnum(v: string | undefined | null): string;
|
|
48
|
+
/** Emit an optional STEP boolean: `.T.`/`.F.`/`$`. */
|
|
49
|
+
export declare function optBool(v: boolean | undefined | null): string;
|
|
50
|
+
/** Emit an optional STEP real number; `$` when absent. */
|
|
51
|
+
export declare function optReal(v: number | undefined | null): string;
|
|
52
|
+
/** Emit an optional STEP integer; `$` when absent. */
|
|
53
|
+
export declare function optInt(v: number | undefined | null): string;
|
|
54
|
+
/** Emit a STEP entity-reference list `(#1,#2)`, or `$` when empty. */
|
|
55
|
+
export declare function refList(ids: number[]): string;
|
|
56
|
+
/** Emit a STEP integer list `(1,2)`, or `$` when absent/empty. */
|
|
57
|
+
export declare function intList(values: number[] | undefined): string;
|
|
58
|
+
/**
|
|
59
|
+
* Serialize an IfcPropertySingleValue NominalValue as a named SELECT branch.
|
|
60
|
+
*
|
|
61
|
+
* Moved here from `IfcCreator` (it never touched class state) so that file
|
|
62
|
+
* stays inside its recorded module-size budget.
|
|
63
|
+
*/
|
|
64
|
+
export declare function serializePropertyValue(prop: PropertyDef): string;
|
|
65
|
+
/**
|
|
66
|
+
* Serialize the `Unit, <Kind>Value` pair of an IfcPhysicalSimpleQuantity.
|
|
67
|
+
*
|
|
68
|
+
* Moved here from `IfcCreator` for the same reason as
|
|
69
|
+
* {@link serializePropertyValue}.
|
|
70
|
+
*/
|
|
71
|
+
export declare function quantityValueField(qty: QuantityDef): string;
|
|
44
72
|
//# sourceMappingURL=ifc-creator-math.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ifc-creator-math.d.ts","sourceRoot":"","sources":["../src/ifc-creator-math.ts"],"names":[],"mappings":"AAIA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ifc-creator-math.d.ts","sourceRoot":"","sources":["../src/ifc-creator-math.ts"],"names":[],"mappings":"AAIA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAMpE,sCAAsC;AACtC,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvC;AAED,0CAA0C;AAC1C,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvE;AAED,0FAA0F;AAC1F,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAKrC;AAED,oBAA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