@ifc-lite/flow-nodes 0.2.0 → 0.5.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 +1 -0
- package/dist/apply-table-node.d.ts.map +1 -1
- package/dist/apply-table-node.js +7 -6
- package/dist/apply-table-node.js.map +1 -1
- package/dist/aps-client.d.ts +55 -0
- package/dist/aps-client.d.ts.map +1 -0
- package/dist/aps-client.js +194 -0
- package/dist/aps-client.js.map +1 -0
- package/dist/aps-nodes.d.ts +3 -0
- package/dist/aps-nodes.d.ts.map +1 -0
- package/dist/aps-nodes.js +192 -0
- package/dist/aps-nodes.js.map +1 -0
- package/dist/aps-table.d.ts +24 -0
- package/dist/aps-table.d.ts.map +1 -0
- package/dist/aps-table.js +123 -0
- package/dist/aps-table.js.map +1 -0
- package/dist/base64.d.ts +8 -0
- package/dist/base64.d.ts.map +1 -0
- package/dist/base64.js +59 -0
- package/dist/base64.js.map +1 -0
- package/dist/bcf-client.d.ts +36 -0
- package/dist/bcf-client.d.ts.map +1 -0
- package/dist/bcf-client.js +108 -0
- package/dist/bcf-client.js.map +1 -0
- package/dist/bcf-nodes.d.ts +3 -0
- package/dist/bcf-nodes.d.ts.map +1 -0
- package/dist/bcf-nodes.js +181 -0
- package/dist/bcf-nodes.js.map +1 -0
- package/dist/csv-nodes.d.ts.map +1 -1
- package/dist/csv-nodes.js +3 -4
- package/dist/csv-nodes.js.map +1 -1
- package/dist/documents-fetch.d.ts +23 -0
- package/dist/documents-fetch.d.ts.map +1 -0
- package/dist/documents-fetch.js +48 -0
- package/dist/documents-fetch.js.map +1 -0
- package/dist/documents-nodes.d.ts +5 -0
- package/dist/documents-nodes.d.ts.map +1 -0
- package/dist/documents-nodes.js +167 -0
- package/dist/documents-nodes.js.map +1 -0
- package/dist/host.d.ts +28 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js.map +1 -1
- package/dist/http-request-node.d.ts +9 -0
- package/dist/http-request-node.d.ts.map +1 -0
- package/dist/http-request-node.js +109 -0
- package/dist/http-request-node.js.map +1 -0
- package/dist/index.d.ts +20 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -5
- package/dist/index.js.map +1 -1
- package/dist/model-nodes.d.ts.map +1 -1
- package/dist/model-nodes.js +11 -6
- package/dist/model-nodes.js.map +1 -1
- package/dist/open-model-node.d.ts +3 -0
- package/dist/open-model-node.d.ts.map +1 -0
- package/dist/open-model-node.js +47 -0
- package/dist/open-model-node.js.map +1 -0
- package/dist/script-node.d.ts.map +1 -1
- package/dist/script-node.js +55 -21
- package/dist/script-node.js.map +1 -1
- package/dist/secrets.d.ts +88 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +202 -0
- package/dist/secrets.js.map +1 -0
- package/dist/speckle/client.d.ts +52 -0
- package/dist/speckle/client.d.ts.map +1 -0
- package/dist/speckle/client.js +153 -0
- package/dist/speckle/client.js.map +1 -0
- package/dist/speckle/geometry.d.ts +37 -0
- package/dist/speckle/geometry.d.ts.map +1 -0
- package/dist/speckle/geometry.js +126 -0
- package/dist/speckle/geometry.js.map +1 -0
- package/dist/speckle/mapping.d.ts +62 -0
- package/dist/speckle/mapping.d.ts.map +1 -0
- package/dist/speckle/mapping.js +208 -0
- package/dist/speckle/mapping.js.map +1 -0
- package/dist/speckle/parameters.d.ts +49 -0
- package/dist/speckle/parameters.d.ts.map +1 -0
- package/dist/speckle/parameters.js +95 -0
- package/dist/speckle/parameters.js.map +1 -0
- package/dist/speckle/refusals.d.ts +45 -0
- package/dist/speckle/refusals.d.ts.map +1 -0
- package/dist/speckle/refusals.js +40 -0
- package/dist/speckle/refusals.js.map +1 -0
- package/dist/speckle/units.d.ts +13 -0
- package/dist/speckle/units.d.ts.map +1 -0
- package/dist/speckle/units.js +59 -0
- package/dist/speckle/units.js.map +1 -0
- package/dist/speckle/url.d.ts +35 -0
- package/dist/speckle/url.d.ts.map +1 -0
- package/dist/speckle/url.js +48 -0
- package/dist/speckle/url.js.map +1 -0
- package/dist/speckle-receive-node.d.ts +9 -0
- package/dist/speckle-receive-node.d.ts.map +1 -0
- package/dist/speckle-receive-node.js +180 -0
- package/dist/speckle-receive-node.js.map +1 -0
- package/dist/xlsx-io.d.ts.map +1 -1
- package/dist/xlsx-io.js +3 -3
- package/dist/xlsx-io.js.map +1 -1
- package/dist/xlsx-nodes.d.ts.map +1 -1
- package/dist/xlsx-nodes.js +1 -40
- package/dist/xlsx-nodes.js.map +1 -1
- package/package.json +11 -9
- package/dist/strict-cell.d.ts +0 -20
- package/dist/strict-cell.d.ts.map +0 -1
- package/dist/strict-cell.js +0 -33
- package/dist/strict-cell.js.map +0 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Speckle object graph → planned IFC elements (mapping v1). Pure: no I/O,
|
|
3
|
+
* no model access. See docs/architecture/speckle-mapping.md for the table.
|
|
4
|
+
*
|
|
5
|
+
* Objects.BuiltElements.Wall → IfcWall (straight location line, height, WALL_ATTR_WIDTH_PARAM)
|
|
6
|
+
* Objects.BuiltElements.Floor → IfcSlab (flat polygonal outline, FLOOR_ATTR_THICKNESS_PARAM)
|
|
7
|
+
* Objects.BuiltElements.Roof → IfcRoof (flat polygonal footprint, ROOF_ATTR_THICKNESS_PARAM)
|
|
8
|
+
* Objects.BuiltElements.Column → IfcColumn (vertical, unrotated location line, `b` × `h`)
|
|
9
|
+
* Objects.BuiltElements.Beam → IfcBeam (straight location line, `b` × `h`)
|
|
10
|
+
*
|
|
11
|
+
* The body is rebuilt parametrically through the same `bim.store.add*`
|
|
12
|
+
* builders `model.addElement` uses; `bim.store` has no tessellated-body
|
|
13
|
+
* writer, so display meshes are counted and reported, never written.
|
|
14
|
+
* Coordinates are made relative to the element's own Speckle level and
|
|
15
|
+
* written into the one target storey.
|
|
16
|
+
*
|
|
17
|
+
* The walk is iterative with a global visited set (the output for an id is
|
|
18
|
+
* a pure function of that id, so revisits are skipped, not re-counted).
|
|
19
|
+
*/
|
|
20
|
+
import type { AddBeamInStoreParams, AddColumnInStoreParams, AddRoofPolygonParams, AddSlabPolygonParams, AddWallInStoreParams } from '@ifc-lite/sdk';
|
|
21
|
+
import type { SpeckleObject } from './client.js';
|
|
22
|
+
import { type ParamValue } from './parameters.js';
|
|
23
|
+
import { RefusalLog, type SpeckleRefusal } from './refusals.js';
|
|
24
|
+
export declare const PSET_SOURCE = "Speckle_Source";
|
|
25
|
+
export declare const PSET_TYPE = "Speckle_TypeParameters";
|
|
26
|
+
export declare const PSET_INSTANCE = "Speckle_InstanceParameters";
|
|
27
|
+
export type PlannedElement = {
|
|
28
|
+
/** Stable identity across versions: the Revit `applicationId`, else the Speckle id. */
|
|
29
|
+
readonly key: string;
|
|
30
|
+
readonly speckleType: string;
|
|
31
|
+
readonly speckleId: string;
|
|
32
|
+
readonly psets: Readonly<Record<string, Readonly<Record<string, ParamValue>>>>;
|
|
33
|
+
readonly displayMeshes: number;
|
|
34
|
+
readonly skippedEntries: number;
|
|
35
|
+
} & ({
|
|
36
|
+
readonly kind: 'wall';
|
|
37
|
+
readonly params: AddWallInStoreParams;
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: 'slab';
|
|
40
|
+
readonly params: AddSlabPolygonParams;
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: 'roof';
|
|
43
|
+
readonly params: AddRoofPolygonParams;
|
|
44
|
+
} | {
|
|
45
|
+
readonly kind: 'column';
|
|
46
|
+
readonly params: AddColumnInStoreParams;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'beam';
|
|
49
|
+
readonly params: AddBeamInStoreParams;
|
|
50
|
+
});
|
|
51
|
+
export interface MappingOptions {
|
|
52
|
+
/** Only elements on this Speckle level (by name); empty = every level. */
|
|
53
|
+
readonly level?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface MappingResult {
|
|
56
|
+
readonly planned: PlannedElement[];
|
|
57
|
+
readonly refusals: RefusalLog;
|
|
58
|
+
}
|
|
59
|
+
/** Walk the fetched graph from its root and plan every mappable element. */
|
|
60
|
+
export declare function mapSpeckleGraph(objects: ReadonlyMap<string, SpeckleObject>, rootId: string, opts?: MappingOptions): MappingResult;
|
|
61
|
+
export type { SpeckleRefusal };
|
|
62
|
+
//# sourceMappingURL=mapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../src/speckle/mapping.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACpJ,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAuC,KAAK,UAAU,EAAyB,MAAM,iBAAiB,CAAC;AAC9G,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAA6B,MAAM,eAAe,CAAC;AAG3F,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAC5C,eAAO,MAAM,SAAS,2BAA2B,CAAC;AAClD,eAAO,MAAM,aAAa,+BAA+B,CAAC;AAI1D,MAAM,MAAM,cAAc,GAAG;IAC3B,uFAAuF;IACvF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/E,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC,GAAG,CACA;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,GAChE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,GAChE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,GAChE;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAA;CAAE,GACpE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,CACnE,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;CAC/B;AAiKD,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,cAAmB,GAAG,aAAa,CAwBrI;AAED,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,208 @@
|
|
|
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 { DISPLAY_KEYS } from './client.js';
|
|
5
|
+
import { isA, leafType, lineOf, outlineOf, resolverFor } from './geometry.js';
|
|
6
|
+
import { dimension, psetRows, readParameters } from './parameters.js';
|
|
7
|
+
import { RefusalLog } from './refusals.js';
|
|
8
|
+
import { lengthScale } from './units.js';
|
|
9
|
+
export const PSET_SOURCE = 'Speckle_Source';
|
|
10
|
+
export const PSET_TYPE = 'Speckle_TypeParameters';
|
|
11
|
+
export const PSET_INSTANCE = 'Speckle_InstanceParameters';
|
|
12
|
+
const KINDS = [
|
|
13
|
+
['Objects.BuiltElements.Wall', 'wall'],
|
|
14
|
+
['Objects.BuiltElements.Floor', 'slab'],
|
|
15
|
+
['Objects.BuiltElements.Roof', 'roof'],
|
|
16
|
+
['Objects.BuiltElements.Column', 'column'],
|
|
17
|
+
['Objects.BuiltElements.Beam', 'beam'],
|
|
18
|
+
];
|
|
19
|
+
const kindOf = (o) => KINDS.find(([base]) => isA(o, base))?.[1];
|
|
20
|
+
function isContainer(o) {
|
|
21
|
+
const t = typeof o.speckle_type === 'string' ? o.speckle_type : 'Base';
|
|
22
|
+
return t === 'Base' || isA(o, 'Speckle.Core.Models.Collections.Collection') || t.startsWith('Objects.Organization.');
|
|
23
|
+
}
|
|
24
|
+
/** Child slots a container is walked through: `elements` and dynamic `@`-detached members. */
|
|
25
|
+
function childSlots(o) {
|
|
26
|
+
const out = [];
|
|
27
|
+
for (const [k, v] of Object.entries(o)) {
|
|
28
|
+
if (DISPLAY_KEYS.has(k) || (k !== 'elements' && !k.startsWith('@')))
|
|
29
|
+
continue;
|
|
30
|
+
if (Array.isArray(v))
|
|
31
|
+
out.push(...v);
|
|
32
|
+
else if (v !== null && typeof v === 'object')
|
|
33
|
+
out.push(v);
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
/** Display geometry under every key the client skips; a bare object counts as one. */
|
|
38
|
+
function displayCount(o) {
|
|
39
|
+
let n = 0;
|
|
40
|
+
for (const key of DISPLAY_KEYS) {
|
|
41
|
+
const v = o[key];
|
|
42
|
+
if (Array.isArray(v))
|
|
43
|
+
n += v.length;
|
|
44
|
+
else if (v !== null && typeof v === 'object')
|
|
45
|
+
n += 1;
|
|
46
|
+
}
|
|
47
|
+
return n;
|
|
48
|
+
}
|
|
49
|
+
class Refused extends Error {
|
|
50
|
+
reason;
|
|
51
|
+
constructor(reason, detail) {
|
|
52
|
+
super(detail);
|
|
53
|
+
this.reason = reason;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const TOL = 1e-4;
|
|
57
|
+
const str = (v) => (typeof v === 'string' && v.length > 0 ? v : v === null || v === undefined ? undefined : String(v));
|
|
58
|
+
const xy = (p) => [p[0], p[1]];
|
|
59
|
+
function required(params, internal, label) {
|
|
60
|
+
const d = dimension(params, internal);
|
|
61
|
+
if ('reason' in d)
|
|
62
|
+
throw new Refused('missing-dimension', `${d.reason} (${label})`);
|
|
63
|
+
return d.value;
|
|
64
|
+
}
|
|
65
|
+
function line(resolve, o) {
|
|
66
|
+
const l = lineOf(resolve, o.baseLine, o.units);
|
|
67
|
+
if ('reason' in l)
|
|
68
|
+
throw new Refused('geometry', l.reason);
|
|
69
|
+
return l;
|
|
70
|
+
}
|
|
71
|
+
function flatOutline(resolve, o) {
|
|
72
|
+
if (typeof o.slope === 'number' && Math.abs(o.slope) > 1e-9)
|
|
73
|
+
throw new Refused('geometry', 'is sloped; v1 writes flat slabs and roofs only');
|
|
74
|
+
if (Array.isArray(o.voids) && o.voids.length > 0)
|
|
75
|
+
throw new Refused('openings', 'has openings (voids), which a v1 extrusion would fill in');
|
|
76
|
+
const outline = outlineOf(resolve, o.outline, o.units);
|
|
77
|
+
if ('reason' in outline)
|
|
78
|
+
throw new Refused('geometry', outline.reason);
|
|
79
|
+
return outline.points;
|
|
80
|
+
}
|
|
81
|
+
function plan(resolve, o, kind, params, elevation) {
|
|
82
|
+
const header = {
|
|
83
|
+
Name: [str(o.family), str(o.type)].filter((s) => s !== undefined).join(': ') || leafType(o),
|
|
84
|
+
ObjectType: str(o.type),
|
|
85
|
+
Tag: str(o.elementId),
|
|
86
|
+
};
|
|
87
|
+
const local = (p) => [p[0], p[1], p[2] - elevation];
|
|
88
|
+
switch (kind) {
|
|
89
|
+
case 'wall': {
|
|
90
|
+
const { start, end } = line(resolve, o);
|
|
91
|
+
if (Math.abs(start[2] - end[2]) > TOL)
|
|
92
|
+
throw new Refused('geometry', 'has a location line that is not horizontal');
|
|
93
|
+
const height = typeof o.height === 'number' && o.height > 0 ? o.height * (lengthScale(o.units) ?? Number.NaN) : Number.NaN;
|
|
94
|
+
if (!Number.isFinite(height))
|
|
95
|
+
throw new Refused('missing-dimension', 'no positive height');
|
|
96
|
+
return { kind, params: { ...header, Start: local(start), End: local(end), Height: height, Thickness: required(params, 'WALL_ATTR_WIDTH_PARAM', 'Width') } };
|
|
97
|
+
}
|
|
98
|
+
case 'slab': {
|
|
99
|
+
const points = flatOutline(resolve, o);
|
|
100
|
+
const thickness = required(params, 'FLOOR_ATTR_THICKNESS_PARAM', 'Thickness');
|
|
101
|
+
// A Revit floor's outline is its top face at the level: the slab hangs below it.
|
|
102
|
+
return { kind, params: { ...header, Profile: 'polygon', OuterCurve: points.map(xy), Position: [0, 0, points[0][2] - elevation - thickness], Thickness: thickness } };
|
|
103
|
+
}
|
|
104
|
+
case 'roof': {
|
|
105
|
+
if (isA(o, 'Objects.BuiltElements.Revit.RevitRoof.RevitExtrusionRoof'))
|
|
106
|
+
throw new Refused('geometry', 'is an extrusion roof (a profile swept along a path)');
|
|
107
|
+
const points = flatOutline(resolve, o);
|
|
108
|
+
const thickness = required(params, 'ROOF_ATTR_THICKNESS_PARAM', 'Thickness');
|
|
109
|
+
return { kind, params: { ...header, Profile: 'polygon', OuterCurve: points.map(xy), Position: [0, 0, points[0][2] - elevation], Thickness: thickness } };
|
|
110
|
+
}
|
|
111
|
+
case 'column': {
|
|
112
|
+
const { start, end } = line(resolve, o);
|
|
113
|
+
if (Math.abs(start[0] - end[0]) > TOL || Math.abs(start[1] - end[1]) > TOL)
|
|
114
|
+
throw new Refused('geometry', 'is slanted; v1 writes vertical columns only');
|
|
115
|
+
if (typeof o.rotation === 'number' && Math.abs(o.rotation) > 1e-9)
|
|
116
|
+
throw new Refused('geometry', 'is rotated about its axis, which the column writer cannot express');
|
|
117
|
+
const base = start[2] <= end[2] ? start : end;
|
|
118
|
+
const height = Math.abs(end[2] - start[2]);
|
|
119
|
+
if (height <= TOL)
|
|
120
|
+
throw new Refused('missing-dimension', 'no height (zero-length location line)');
|
|
121
|
+
return { kind, params: { ...header, Position: local(base), Height: height, Width: required(params, 'b', 'b'), Depth: required(params, 'h', 'h') } };
|
|
122
|
+
}
|
|
123
|
+
case 'beam': {
|
|
124
|
+
const { start, end } = line(resolve, o);
|
|
125
|
+
return { kind, params: { ...header, Start: local(start), End: local(end), Width: required(params, 'b', 'b'), Height: required(params, 'h', 'h') } };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function sourcePset(o, levelName) {
|
|
130
|
+
const rows = { SpeckleId: o.id, SpeckleType: String(o.speckle_type) };
|
|
131
|
+
const add = (k, v) => {
|
|
132
|
+
const s = str(v);
|
|
133
|
+
if (s !== undefined)
|
|
134
|
+
rows[k] = s;
|
|
135
|
+
};
|
|
136
|
+
add('ApplicationId', o.applicationId);
|
|
137
|
+
add('Category', o.category);
|
|
138
|
+
add('Family', o.family);
|
|
139
|
+
add('Type', o.type);
|
|
140
|
+
add('ElementId', o.elementId);
|
|
141
|
+
add('Level', levelName);
|
|
142
|
+
add('SourceUnits', o.units);
|
|
143
|
+
return rows;
|
|
144
|
+
}
|
|
145
|
+
function mapElement(resolve, o, kind, opts, log, planned) {
|
|
146
|
+
const type = leafType(o);
|
|
147
|
+
const level = resolve(o.level);
|
|
148
|
+
const levelName = str(level?.name);
|
|
149
|
+
if (opts.level && levelName !== opts.level) {
|
|
150
|
+
log.add(type, 'other-level', `on level "${levelName ?? '(none)'}", not the requested level "${opts.level}"`, o.id);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const scale = lengthScale(o.units);
|
|
154
|
+
if (scale === undefined) {
|
|
155
|
+
log.add(type, 'no-units', `units "${String(o.units ?? '(none)')}" is not a length unit`, o.id);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const elevation = typeof level?.elevation === 'number' ? level.elevation * (lengthScale(level.units) ?? scale) : 0;
|
|
159
|
+
const { parameters, skipped } = readParameters(resolve, o);
|
|
160
|
+
try {
|
|
161
|
+
const p = plan(resolve, o, kind, parameters, elevation);
|
|
162
|
+
planned.push({
|
|
163
|
+
...p,
|
|
164
|
+
key: str(o.applicationId) ?? o.id,
|
|
165
|
+
speckleType: type,
|
|
166
|
+
speckleId: o.id,
|
|
167
|
+
psets: { [PSET_SOURCE]: sourcePset(o, levelName), [PSET_TYPE]: psetRows(parameters, 'type'), [PSET_INSTANCE]: psetRows(parameters, 'instance') },
|
|
168
|
+
displayMeshes: displayCount(o),
|
|
169
|
+
skippedEntries: skipped,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
if (!(err instanceof Refused))
|
|
174
|
+
throw err;
|
|
175
|
+
log.add(type, err.reason, err.message, o.id);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/** Walk the fetched graph from its root and plan every mappable element. */
|
|
179
|
+
export function mapSpeckleGraph(objects, rootId, opts = {}) {
|
|
180
|
+
const resolve = resolverFor(objects);
|
|
181
|
+
const log = new RefusalLog();
|
|
182
|
+
const planned = [];
|
|
183
|
+
const root = objects.get(rootId);
|
|
184
|
+
if (!root)
|
|
185
|
+
throw new Error(`speckle.receive: root object ${rootId} was not fetched`);
|
|
186
|
+
const seen = new Set();
|
|
187
|
+
const stack = [root];
|
|
188
|
+
while (stack.length > 0) {
|
|
189
|
+
const o = resolve(stack.pop());
|
|
190
|
+
if (!o || typeof o.id !== 'string' || seen.has(o.id))
|
|
191
|
+
continue;
|
|
192
|
+
seen.add(o.id);
|
|
193
|
+
const kind = kindOf(o);
|
|
194
|
+
if (kind)
|
|
195
|
+
mapElement(resolve, o, kind, opts, log, planned);
|
|
196
|
+
else if (!isContainer(o)) {
|
|
197
|
+
log.add(leafType(o), 'unmapped-type', 'has no v1 mapping', o.id);
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
// Containers, and hosted elements under a mapped one (a stacked wall's
|
|
201
|
+
// layers, a wall's doors), are walked in document order.
|
|
202
|
+
const children = kind ? (Array.isArray(o.elements) ? o.elements : []) : childSlots(o);
|
|
203
|
+
for (let i = children.length - 1; i >= 0; i--)
|
|
204
|
+
stack.push(children[i]);
|
|
205
|
+
}
|
|
206
|
+
return { planned, refusals: log };
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=mapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapping.js","sourceRoot":"","sources":["../../src/speckle/mapping.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAwB/D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAA4B,MAAM,eAAe,CAAC;AACxG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAA0C,MAAM,iBAAiB,CAAC;AAC9G,OAAO,EAAE,UAAU,EAAkD,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAC5C,MAAM,CAAC,MAAM,SAAS,GAAG,wBAAwB,CAAC;AAClD,MAAM,CAAC,MAAM,aAAa,GAAG,4BAA4B,CAAC;AA+B1D,MAAM,KAAK,GAAkC;IAC3C,CAAC,4BAA4B,EAAE,MAAM,CAAC;IACtC,CAAC,6BAA6B,EAAE,MAAM,CAAC;IACvC,CAAC,4BAA4B,EAAE,MAAM,CAAC;IACtC,CAAC,8BAA8B,EAAE,QAAQ,CAAC;IAC1C,CAAC,4BAA4B,EAAE,MAAM,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,CAA0B,EAAoB,EAAE,CAAC,KA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group][name]`
|
|
6
|
+
* = `{ name, value, units?, internalDefinitionName }` (current v2 output);
|
|
7
|
+
* - `parameters[internalName]` = `Objects.BuiltElements.Revit.Parameter`
|
|
8
|
+
* `{ name, value, units, isTypeParameter, applicationInternalName }` (older).
|
|
9
|
+
*
|
|
10
|
+
* Lengths, areas and volumes are converted to metres / m² / m³; every other
|
|
11
|
+
* unit is carried as authored. An entry with no scalar `value` (a compound
|
|
12
|
+
* structure layer, a nested table) is not a parameter and is counted so the
|
|
13
|
+
* caller can report it.
|
|
14
|
+
*/
|
|
15
|
+
import type { Resolver } from './geometry.js';
|
|
16
|
+
import { type Quantity } from './units.js';
|
|
17
|
+
export type ParamValue = string | number | boolean;
|
|
18
|
+
export interface SpeckleParameter {
|
|
19
|
+
readonly scope: 'type' | 'instance';
|
|
20
|
+
readonly name: string;
|
|
21
|
+
/** Revit's BuiltInParameter / shared-parameter name, e.g. `WALL_ATTR_WIDTH_PARAM`. */
|
|
22
|
+
readonly internalName?: string;
|
|
23
|
+
/** Converted to SI when the unit is a length, area or volume. */
|
|
24
|
+
readonly value: ParamValue;
|
|
25
|
+
/** What `value` was converted as; absent when it is carried as authored (no unit, or one the tables do not know). */
|
|
26
|
+
readonly quantity?: Quantity;
|
|
27
|
+
/** The unit label as authored, if any. */
|
|
28
|
+
readonly units?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ParameterRead {
|
|
31
|
+
readonly parameters: SpeckleParameter[];
|
|
32
|
+
/** Entries under a parameter scope that carry no scalar value. */
|
|
33
|
+
readonly skipped: number;
|
|
34
|
+
}
|
|
35
|
+
export declare function readParameters(resolve: Resolver, obj: Record<string, unknown>): ParameterRead;
|
|
36
|
+
/**
|
|
37
|
+
* A positive length parameter by internal name, in metres, instance before
|
|
38
|
+
* type — or why there is none. Only a value that was actually CONVERTED as a
|
|
39
|
+
* length counts: a unit label outside the tables ("Feet and fractional
|
|
40
|
+
* inches", "Fractional inches", none at all) is never read as metres.
|
|
41
|
+
*/
|
|
42
|
+
export declare function dimension(params: readonly SpeckleParameter[], internalName: string): {
|
|
43
|
+
value: number;
|
|
44
|
+
} | {
|
|
45
|
+
reason: string;
|
|
46
|
+
};
|
|
47
|
+
/** Property-set rows for one scope; a repeated display name keeps both, the later one qualified by its internal name. */
|
|
48
|
+
export declare function psetRows(params: readonly SpeckleParameter[], scope: 'type' | 'instance'): Record<string, ParamValue>;
|
|
49
|
+
//# sourceMappingURL=parameters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../src/speckle/parameters.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,qHAAqH;IACrH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,gBAAgB,EAAE,CAAC;IACxC,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AA0BD,wBAAgB,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CA2B7F;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,gBAAgB,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAQ3H;AAED,yHAAyH;AACzH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,gBAAgB,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAYpH"}
|
|
@@ -0,0 +1,95 @@
|
|
|
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 { parameterScale } from './units.js';
|
|
5
|
+
const isScalar = (v) => typeof v === 'string' || typeof v === 'boolean' || (typeof v === 'number' && Number.isFinite(v));
|
|
6
|
+
function convert(value, units) {
|
|
7
|
+
if (typeof value !== 'number')
|
|
8
|
+
return { value };
|
|
9
|
+
const scale = parameterScale(units);
|
|
10
|
+
return scale ? { value: value * scale.factor, quantity: scale.quantity } : { value };
|
|
11
|
+
}
|
|
12
|
+
function entry(scope, key, raw) {
|
|
13
|
+
if (!isScalar(raw.value))
|
|
14
|
+
return undefined;
|
|
15
|
+
const name = typeof raw.name === 'string' && raw.name.length > 0 ? raw.name : key;
|
|
16
|
+
const internal = raw.internalDefinitionName ?? raw.applicationInternalName;
|
|
17
|
+
return {
|
|
18
|
+
scope,
|
|
19
|
+
name,
|
|
20
|
+
internalName: typeof internal === 'string' ? internal : undefined,
|
|
21
|
+
...convert(raw.value, raw.units),
|
|
22
|
+
units: typeof raw.units === 'string' ? raw.units : undefined,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const SCOPES = [['Type Parameters', 'type'], ['Instance Parameters', 'instance']];
|
|
26
|
+
export function readParameters(resolve, obj) {
|
|
27
|
+
const parameters = [];
|
|
28
|
+
let skipped = 0;
|
|
29
|
+
const properties = resolve(obj.properties);
|
|
30
|
+
for (const [key, scope] of SCOPES) {
|
|
31
|
+
const groups = resolve(properties?.[key]);
|
|
32
|
+
for (const group of Object.values(groups ?? {})) {
|
|
33
|
+
const g = resolve(group);
|
|
34
|
+
if (!g)
|
|
35
|
+
continue;
|
|
36
|
+
for (const [name, raw] of Object.entries(g)) {
|
|
37
|
+
const r = resolve(raw);
|
|
38
|
+
if (!r)
|
|
39
|
+
continue;
|
|
40
|
+
const p = entry(scope, name, r);
|
|
41
|
+
if (p)
|
|
42
|
+
parameters.push(p);
|
|
43
|
+
else
|
|
44
|
+
skipped++;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const legacy = resolve(obj.parameters);
|
|
49
|
+
for (const [key, raw] of Object.entries(legacy ?? {})) {
|
|
50
|
+
const r = resolve(raw);
|
|
51
|
+
if (!r || !('value' in r))
|
|
52
|
+
continue; // `id`, `speckle_type`, … of the container itself
|
|
53
|
+
const p = entry(r.isTypeParameter === true ? 'type' : 'instance', key, r);
|
|
54
|
+
if (p)
|
|
55
|
+
parameters.push(p);
|
|
56
|
+
else
|
|
57
|
+
skipped++;
|
|
58
|
+
}
|
|
59
|
+
return { parameters, skipped };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A positive length parameter by internal name, in metres, instance before
|
|
63
|
+
* type — or why there is none. Only a value that was actually CONVERTED as a
|
|
64
|
+
* length counts: a unit label outside the tables ("Feet and fractional
|
|
65
|
+
* inches", "Fractional inches", none at all) is never read as metres.
|
|
66
|
+
*/
|
|
67
|
+
export function dimension(params, internalName) {
|
|
68
|
+
const hits = params.filter((p) => p.internalName === internalName && typeof p.value === 'number' && p.value > 0);
|
|
69
|
+
const pick = (ps) => ps.find((p) => p.scope === 'instance') ?? ps[0];
|
|
70
|
+
const converted = pick(hits.filter((p) => p.quantity === 'length'));
|
|
71
|
+
if (converted)
|
|
72
|
+
return { value: converted.value };
|
|
73
|
+
const other = pick(hits);
|
|
74
|
+
if (other)
|
|
75
|
+
return { reason: `${internalName} has unit "${other.units ?? '(none)'}", which is not a supported length unit` };
|
|
76
|
+
return { reason: `no positive ${internalName} parameter` };
|
|
77
|
+
}
|
|
78
|
+
/** Property-set rows for one scope; a repeated display name keeps both, the later one qualified by its internal name. */
|
|
79
|
+
export function psetRows(params, scope) {
|
|
80
|
+
// Null prototype: parameter names come from the server, and `__proto__`,
|
|
81
|
+
// `constructor` or `toString` must be ordinary keys, not Object.prototype.
|
|
82
|
+
const rows = Object.create(null);
|
|
83
|
+
for (const p of params) {
|
|
84
|
+
if (p.scope !== scope)
|
|
85
|
+
continue;
|
|
86
|
+
let key = p.name;
|
|
87
|
+
if (key in rows)
|
|
88
|
+
key = `${p.name} (${p.internalName ?? 'duplicate'})`;
|
|
89
|
+
for (let n = 2; key in rows; n++)
|
|
90
|
+
key = `${p.name} (${p.internalName ?? 'duplicate'} ${n})`;
|
|
91
|
+
rows[key] = p.value;
|
|
92
|
+
}
|
|
93
|
+
return rows;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=parameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../src/speckle/parameters.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAkB/D,OAAO,EAAE,cAAc,EAAiB,MAAM,YAAY,CAAC;AAuB3D,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAmB,EAAE,CAC/C,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAEnG,SAAS,OAAO,CAAC,KAAiB,EAAE,KAAc;IAChD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OA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,MAAM,IAAI,GAA+B,MAAM,CAAC,MAAM,CAAC,IAAI,CAA+B,CAAC;IAC3F,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK;YAAE,SAAS;QAChC,IAAI,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC;QACjB,IAAI,GAAG,IAAI,IAAI;YAAE,GAAG,GAAG,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,YAAY,IAAI,WAAW,GAAG,CAAC;QACtE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,EAAE;YAAE,GAAG,GAAG,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,YAAY,IAAI,WAAW,IAAI,CAAC,GAAG,CAAC;QAC5F,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;IACtB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a Speckle receive did NOT write, by name and count.
|
|
3
|
+
*
|
|
4
|
+
* Same contract as the LandXML mapping's refusals (`@ifc-lite/create`
|
|
5
|
+
* `landxml/refusals.ts`): nothing is dropped silently. "14 RevitElement
|
|
6
|
+
* objects have no v1 mapping" is actionable; an element that is simply
|
|
7
|
+
* absent from the IFC is not even noticeable.
|
|
8
|
+
*/
|
|
9
|
+
export type SpeckleRefusalReason =
|
|
10
|
+
/** The object's type has no v1 mapping at all. */
|
|
11
|
+
'unmapped-type'
|
|
12
|
+
/** A mapped type whose geometry v1 cannot reproduce (curved, sloped, slanted, rotated, …). */
|
|
13
|
+
| 'geometry'
|
|
14
|
+
/** A mapped type missing a dimension its IFC builder needs (thickness, section size, height). */
|
|
15
|
+
| 'missing-dimension'
|
|
16
|
+
/** A floor or roof with openings, which v1 would fill in. */
|
|
17
|
+
| 'openings'
|
|
18
|
+
/** No length unit to convert from. */
|
|
19
|
+
| 'no-units'
|
|
20
|
+
/** Excluded by the node's `level` filter. */
|
|
21
|
+
| 'other-level'
|
|
22
|
+
/** The IFC writer rejected the mapped element. */
|
|
23
|
+
| 'write-failed'
|
|
24
|
+
/** Re-receive: the new version was rejected, and the element from the earlier receive was KEPT (not replaced). */
|
|
25
|
+
| 'write-failed-kept-previous'
|
|
26
|
+
/** Display meshes of written elements, which are not carried (the body is rebuilt parametrically). */
|
|
27
|
+
| 'display-meshes'
|
|
28
|
+
/** Property entries that are not scalar parameters (compound structure layers, nested tables). */
|
|
29
|
+
| 'non-parameter-entries';
|
|
30
|
+
export interface SpeckleRefusal {
|
|
31
|
+
/** The most-derived `speckle_type` link, e.g. `RevitWall`. */
|
|
32
|
+
readonly speckleType: string;
|
|
33
|
+
readonly reason: SpeckleRefusalReason;
|
|
34
|
+
readonly count: number;
|
|
35
|
+
readonly message: string;
|
|
36
|
+
/** Up to five Speckle object ids, so the operator can find them. */
|
|
37
|
+
readonly examples: readonly string[];
|
|
38
|
+
}
|
|
39
|
+
export declare class RefusalLog {
|
|
40
|
+
private readonly buckets;
|
|
41
|
+
/** Count `n` refused things of one type, for one reason, with one explanation. */
|
|
42
|
+
add(speckleType: string, reason: SpeckleRefusalReason, detail: string, id: string | undefined, n?: number): void;
|
|
43
|
+
list(): SpeckleRefusal[];
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=refusals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusals.d.ts","sourceRoot":"","sources":["../../src/speckle/refusals.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AAEH,MAAM,MAAM,oBAAoB;AAC9B,kDAAkD;AAChD,eAAe;AACjB,8FAA8F;GAC5F,UAAU;AACZ,iGAAiG;GAC/F,mBAAmB;AACrB,6DAA6D;GAC3D,UAAU;AACZ,sCAAsC;GACpC,UAAU;AACZ,6CAA6C;GAC3C,aAAa;AACf,kDAAkD;GAChD,cAAc;AAChB,kHAAkH;GAChH,4BAA4B;AAC9B,sGAAsG;GACpG,gBAAgB;AAClB,kGAAkG;GAChG,uBAAuB,CAAC;AAE5B,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAYD,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IAErD,kFAAkF;IAClF,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,CAAC,SAAI,GAAG,IAAI;IAS3G,IAAI,IAAI,cAAc,EAAE;CASzB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
const MAX_EXAMPLES = 5;
|
|
5
|
+
export class RefusalLog {
|
|
6
|
+
buckets = new Map();
|
|
7
|
+
/** Count `n` refused things of one type, for one reason, with one explanation. */
|
|
8
|
+
add(speckleType, reason, detail, id, n = 1) {
|
|
9
|
+
if (n <= 0)
|
|
10
|
+
return;
|
|
11
|
+
const key = `${speckleType}\u0000${reason}\u0000${detail}`;
|
|
12
|
+
let b = this.buckets.get(key);
|
|
13
|
+
if (!b)
|
|
14
|
+
this.buckets.set(key, (b = { speckleType, reason, detail, count: 0, examples: [] }));
|
|
15
|
+
b.count += n;
|
|
16
|
+
if (id !== undefined && b.examples.length < MAX_EXAMPLES && !b.examples.includes(id))
|
|
17
|
+
b.examples.push(id);
|
|
18
|
+
}
|
|
19
|
+
list() {
|
|
20
|
+
return [...this.buckets.values()].map((b) => ({
|
|
21
|
+
speckleType: b.speckleType,
|
|
22
|
+
reason: b.reason,
|
|
23
|
+
count: b.count,
|
|
24
|
+
message: messageOf(b),
|
|
25
|
+
examples: b.examples,
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function messageOf(b) {
|
|
30
|
+
const plural = b.count === 1 ? '' : 's';
|
|
31
|
+
switch (b.reason) {
|
|
32
|
+
case 'display-meshes':
|
|
33
|
+
return `${b.count} display mesh${b.count === 1 ? '' : 'es'} on written ${b.speckleType} elements not carried: ${b.detail}.`;
|
|
34
|
+
case 'non-parameter-entries':
|
|
35
|
+
return `${b.count} property entr${b.count === 1 ? 'y' : 'ies'} on written ${b.speckleType} elements not carried: ${b.detail}.`;
|
|
36
|
+
default:
|
|
37
|
+
return `${b.count} ${b.speckleType} object${plural} not written: ${b.detail}.`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=refusals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusals.js","sourceRoot":"","sources":["../../src/speckle/refusals.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AA2C/D,MAAM,YAAY,GAAG,CAAC,CAAC;AAUvB,MAAM,OAAO,UAAU;IACJ,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAErD,kFAAkF;IAClF,GAAG,CAAC,WAAmB,EAAE,MAA4B,EAAE,MAAc,EAAE,EAAsB,EAAE,CAAC,GAAG,CAAC;QAClG,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO;QACnB,MAAM,GAAG,GAAG,GAAG,WAAW,SAAS,MAAM,SAAS,MAAM,EAAE,CAAC;QAC3D,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,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KAAK,uBAAuB;YAC1B,OAAO,GAAG,CAAC,CAAC,KAAK,iBAAiB,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,WAAW,0BAA0B,CAAC,CAAC,MAAM,GAAG,CAAC;QACjI;YACE,OAAO,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,WAAW,UAAU,MAAM,iBAAiB,CAAC,CAAC,MAAM,GAAG,CAAC;IACnF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Metres per one `units`, or undefined when `units` is not a length unit (including Speckle's `none`). */
|
|
2
|
+
export declare function lengthScale(units: unknown): number | undefined;
|
|
3
|
+
export type Quantity = 'length' | 'area' | 'volume';
|
|
4
|
+
/**
|
|
5
|
+
* The quantity and SI factor of a parameter unit, e.g. `Square meters` →
|
|
6
|
+
* area × 1, `Cubic feet` → volume × 0.0283…; undefined for anything else
|
|
7
|
+
* (`Currency`, `Degrees`, …).
|
|
8
|
+
*/
|
|
9
|
+
export declare function parameterScale(units: unknown): {
|
|
10
|
+
quantity: Quantity;
|
|
11
|
+
factor: number;
|
|
12
|
+
} | undefined;
|
|
13
|
+
//# sourceMappingURL=units.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/speckle/units.ts"],"names":[],"mappings":"AA2BA,2GAA2G;AAC3G,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG9D;AAED,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAiBjG"}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
* Speckle unit strings → SI scale factors.
|
|
6
|
+
*
|
|
7
|
+
* Geometry carries Speckle's own unit vocabulary (`mm`, `cm`, `m`, `km`,
|
|
8
|
+
* `in`, `ft`, `yd`, `mi` and their spelled-out aliases, per specklepy's
|
|
9
|
+
* `UNITS_STRINGS`). Revit parameters carry Revit's display names instead
|
|
10
|
+
* (`Centimeters`, `Square meters`, `Cubic feet`). Both are handled; a unit
|
|
11
|
+
* outside these tables is not a length/area/volume and its value is carried
|
|
12
|
+
* unconverted, never guessed.
|
|
13
|
+
*/
|
|
14
|
+
const LENGTH_TO_METRES = {
|
|
15
|
+
mm: 0.001, mil: 0.001, millimeter: 0.001, millimeters: 0.001, millimetre: 0.001, millimetres: 0.001,
|
|
16
|
+
cm: 0.01, centimeter: 0.01, centimeters: 0.01, centimetre: 0.01, centimetres: 0.01,
|
|
17
|
+
dm: 0.1, decimeter: 0.1, decimeters: 0.1, decimetre: 0.1, decimetres: 0.1,
|
|
18
|
+
m: 1, meter: 1, meters: 1, metre: 1, metres: 1,
|
|
19
|
+
km: 1000, kilometer: 1000, kilometers: 1000, kilometre: 1000, kilometres: 1000,
|
|
20
|
+
in: 0.0254, inch: 0.0254, inches: 0.0254,
|
|
21
|
+
ft: 0.3048, foot: 0.3048, feet: 0.3048,
|
|
22
|
+
yd: 0.9144, yard: 0.9144, yards: 0.9144,
|
|
23
|
+
mi: 1609.34, mile: 1609.34, miles: 1609.34,
|
|
24
|
+
};
|
|
25
|
+
/** Metres per one `units`, or undefined when `units` is not a length unit (including Speckle's `none`). */
|
|
26
|
+
export function lengthScale(units) {
|
|
27
|
+
if (typeof units !== 'string')
|
|
28
|
+
return undefined;
|
|
29
|
+
return LENGTH_TO_METRES[units.trim().toLowerCase()];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The quantity and SI factor of a parameter unit, e.g. `Square meters` →
|
|
33
|
+
* area × 1, `Cubic feet` → volume × 0.0283…; undefined for anything else
|
|
34
|
+
* (`Currency`, `Degrees`, …).
|
|
35
|
+
*/
|
|
36
|
+
export function parameterScale(units) {
|
|
37
|
+
if (typeof units !== 'string')
|
|
38
|
+
return undefined;
|
|
39
|
+
const u = units.trim().toLowerCase();
|
|
40
|
+
const direct = LENGTH_TO_METRES[u];
|
|
41
|
+
if (direct !== undefined)
|
|
42
|
+
return { quantity: 'length', factor: direct };
|
|
43
|
+
const sq = /^(?:square\s+(.+)|(.+?)(?:²|2))$/.exec(u);
|
|
44
|
+
if (sq) {
|
|
45
|
+
const f = LENGTH_TO_METRES[(sq[1] ?? sq[2]).trim()];
|
|
46
|
+
if (f !== undefined)
|
|
47
|
+
return { quantity: 'area', factor: f * f };
|
|
48
|
+
}
|
|
49
|
+
const cu = /^(?:cubic\s+(.+)|(.+?)(?:³|3))$/.exec(u);
|
|
50
|
+
if (cu) {
|
|
51
|
+
const f = LENGTH_TO_METRES[(cu[1] ?? cu[2]).trim()];
|
|
52
|
+
if (f !== undefined)
|
|
53
|
+
return { quantity: 'volume', factor: f * f * f };
|
|
54
|
+
}
|
|
55
|
+
if (u === 'liters' || u === 'litres' || u === 'l')
|
|
56
|
+
return { quantity: 'volume', factor: 0.001 };
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=units.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"units.js","sourceRoot":"","sources":["../../src/speckle/units.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;GASG;AAEH,MAAM,gBAAgB,GAAqC;IACzD,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,E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