@itwin/core-common 3.2.0-dev.72 → 3.3.0-dev.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/lib/cjs/HiddenLine.d.ts +12 -17
- package/lib/cjs/HiddenLine.d.ts.map +1 -1
- package/lib/cjs/HiddenLine.js +6 -2
- package/lib/cjs/HiddenLine.js.map +1 -1
- package/lib/cjs/rpc/web/RpcMultipart.d.ts +1 -0
- package/lib/cjs/rpc/web/RpcMultipart.d.ts.map +1 -1
- package/lib/cjs/rpc/web/multipart/RpcMultipartParser.d.ts +1 -0
- package/lib/cjs/rpc/web/multipart/RpcMultipartParser.d.ts.map +1 -1
- package/lib/cjs/tile/ElementGraphics.d.ts +8 -2
- package/lib/cjs/tile/ElementGraphics.d.ts.map +1 -1
- package/lib/cjs/tile/ElementGraphics.js.map +1 -1
- package/lib/cjs/tile/TileMetadata.d.ts +18 -13
- package/lib/cjs/tile/TileMetadata.d.ts.map +1 -1
- package/lib/cjs/tile/TileMetadata.js +164 -134
- package/lib/cjs/tile/TileMetadata.js.map +1 -1
- package/lib/esm/HiddenLine.d.ts +12 -17
- package/lib/esm/HiddenLine.d.ts.map +1 -1
- package/lib/esm/HiddenLine.js +6 -2
- package/lib/esm/HiddenLine.js.map +1 -1
- package/lib/esm/rpc/web/RpcMultipart.d.ts +1 -0
- package/lib/esm/rpc/web/RpcMultipart.d.ts.map +1 -1
- package/lib/esm/rpc/web/multipart/RpcMultipartParser.d.ts +1 -0
- package/lib/esm/rpc/web/multipart/RpcMultipartParser.d.ts.map +1 -1
- package/lib/esm/tile/ElementGraphics.d.ts +8 -2
- package/lib/esm/tile/ElementGraphics.d.ts.map +1 -1
- package/lib/esm/tile/ElementGraphics.js.map +1 -1
- package/lib/esm/tile/TileMetadata.d.ts +18 -13
- package/lib/esm/tile/TileMetadata.d.ts.map +1 -1
- package/lib/esm/tile/TileMetadata.js +163 -133
- package/lib/esm/tile/TileMetadata.js.map +1 -1
- package/package.json +8 -8
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module Tile
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.TileMetadataReader = exports.computeTileChordTolerance = exports.readTileContentDescription = exports.computeChildTileProps = exports.computeChildTileRanges = exports.bisectTileRange2d = exports.bisectTileRange3d = exports.ContentIdProvider = exports.ContentFlags = exports.compareIModelTileTreeIds = exports.iModelTileTreeIdToString = exports.
|
|
10
|
+
exports.TileMetadataReader = exports.computeTileChordTolerance = exports.readTileContentDescription = exports.computeChildTileProps = exports.computeChildTileRanges = exports.bisectTileRange2d = exports.bisectTileRange3d = exports.ContentIdProvider = exports.ContentFlags = exports.compareIModelTileTreeIds = exports.iModelTileTreeIdToString = exports.TreeFlags = exports.getMaximumMajorTileFormatVersion = exports.defaultTileOptions = exports.parseTileTreeIdAndContentId = exports.TileOptions = void 0;
|
|
11
11
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
12
|
const core_geometry_1 = require("@itwin/core-geometry");
|
|
13
13
|
const FeatureTable_1 = require("../FeatureTable");
|
|
@@ -31,6 +31,7 @@ var TileOptions;
|
|
|
31
31
|
function fromTreeIdAndContentId(treeId, contentId) {
|
|
32
32
|
const tree = treeFlagsAndFormatVersionFromId(treeId);
|
|
33
33
|
const contentFlags = contentFlagsFromId(contentId);
|
|
34
|
+
const edgeOptions = edgeOptionsFromTreeId(treeId);
|
|
34
35
|
return {
|
|
35
36
|
maximumMajorTileFormatVersion: tree.version,
|
|
36
37
|
enableInstancing: 0 !== (contentFlags & ContentFlags.AllowInstancing),
|
|
@@ -42,140 +43,146 @@ var TileOptions;
|
|
|
42
43
|
useLargerTiles: 0 !== (tree.flags & TreeFlags.UseLargerTiles),
|
|
43
44
|
disableMagnification: false,
|
|
44
45
|
alwaysSubdivideIncompleteTiles: false,
|
|
45
|
-
enableIndexedEdges:
|
|
46
|
+
enableIndexedEdges: edgeOptions && edgeOptions.indexed,
|
|
47
|
+
generateAllPolyfaceEdges: edgeOptions && edgeOptions.smooth,
|
|
46
48
|
};
|
|
47
49
|
}
|
|
48
50
|
TileOptions.fromTreeIdAndContentId = fromTreeIdAndContentId;
|
|
49
51
|
})(TileOptions = exports.TileOptions || (exports.TileOptions = {}));
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
contentId: parsedContentId,
|
|
90
|
-
modelId,
|
|
91
|
-
options,
|
|
92
|
-
treeId: parsedTreeId,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
exports.parseTileTreeIdAndContentId = parseTileTreeIdAndContentId;
|
|
96
|
-
function getTreeId(type, edges, sectionCut, animationId, expansion, enforceDisplayPriority) {
|
|
97
|
-
if (type === FeatureTable_1.BatchType.Primary)
|
|
98
|
-
return {
|
|
99
|
-
type,
|
|
100
|
-
edges,
|
|
101
|
-
sectionCut,
|
|
102
|
-
animationId,
|
|
103
|
-
enforceDisplayPriority,
|
|
104
|
-
};
|
|
105
|
-
else
|
|
52
|
+
class Parser {
|
|
53
|
+
constructor(input) {
|
|
54
|
+
this.curPos = 0;
|
|
55
|
+
this.input = input;
|
|
56
|
+
}
|
|
57
|
+
parse(contentId) {
|
|
58
|
+
this.require(this.input.length > 0);
|
|
59
|
+
// Skip version and flags, they're handled by TileOptions.fromTreeIdAndContentId
|
|
60
|
+
while (this.curPos < this.input.length && this.cur() !== "-")
|
|
61
|
+
this.advance();
|
|
62
|
+
this.eat("-");
|
|
63
|
+
this.require(this.curPos < this.input.length);
|
|
64
|
+
const classifier = this.cur() === "C" ? this.parseClassifier() : undefined;
|
|
65
|
+
const animationId = this.parseAnimation();
|
|
66
|
+
const primary = classifier ? undefined : this.parsePrimary();
|
|
67
|
+
this.require((undefined === classifier) !== (undefined === primary));
|
|
68
|
+
const modelId = this.input.substr(this.curPos);
|
|
69
|
+
this.require(core_bentley_1.Id64.isId64(modelId));
|
|
70
|
+
const { flags: treeFlags } = treeFlagsAndFormatVersionFromId(this.input);
|
|
71
|
+
const options = TileOptions.fromTreeIdAndContentId(this.input, contentId);
|
|
72
|
+
let parsedContentId;
|
|
73
|
+
try {
|
|
74
|
+
parsedContentId = ContentIdProvider.create(true, options).specFromId(contentId);
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
this.reject("Invalid content Id");
|
|
78
|
+
}
|
|
79
|
+
if (Object.keys(parsedContentId).some((key) => parsedContentId.hasOwnProperty(key) && typeof parsedContentId[key] === "number" && !Number.isFinite(parsedContentId[key])))
|
|
80
|
+
throw new Error("Invalid content Id");
|
|
81
|
+
let treeId;
|
|
82
|
+
if (classifier) {
|
|
83
|
+
treeId = { ...classifier, animationId };
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
(0, core_bentley_1.assert)(undefined !== primary);
|
|
87
|
+
const enforceDisplayPriority = (treeFlags & TreeFlags.EnforceDisplayPriority) !== 0 ? true : undefined;
|
|
88
|
+
treeId = { ...primary, animationId, type: FeatureTable_1.BatchType.Primary, enforceDisplayPriority };
|
|
89
|
+
}
|
|
106
90
|
return {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
91
|
+
contentId: parsedContentId,
|
|
92
|
+
modelId,
|
|
93
|
+
options,
|
|
94
|
+
treeId,
|
|
110
95
|
};
|
|
111
|
-
}
|
|
112
|
-
function parsePrimary(idx, treeId, edges = EdgeType.None, sectionCut) {
|
|
113
|
-
// Edges
|
|
114
|
-
edges = EdgeType.NonIndexed;
|
|
115
|
-
if (idx < treeId.length) {
|
|
116
|
-
const noEdgesStr = "E:0_";
|
|
117
|
-
if (treeId.startsWith(noEdgesStr, idx))
|
|
118
|
-
edges = EdgeType.None;
|
|
119
|
-
else if (treeId.startsWith("E:2_", idx))
|
|
120
|
-
edges = EdgeType.Indexed;
|
|
121
|
-
if (EdgeType.NonIndexed !== edges)
|
|
122
|
-
idx += noEdgesStr.length;
|
|
123
|
-
}
|
|
124
|
-
// Section cut
|
|
125
|
-
if (idx + 1 < treeId.length && treeId[idx] === "S") {
|
|
126
|
-
idx++; // S
|
|
127
|
-
sectionCut = "";
|
|
128
|
-
while (idx < treeId.length && treeId[idx] !== "s") {
|
|
129
|
-
sectionCut += treeId[idx++];
|
|
130
|
-
}
|
|
131
|
-
if (idx === treeId.length)
|
|
132
|
-
throw new Error("Invalid tree Id");
|
|
133
|
-
idx++; // s
|
|
134
96
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
let type;
|
|
139
|
-
idx++; // C
|
|
140
|
-
if (idx + 1 < treeId.length && treeId[idx] === "P" && treeId[idx + 1] === ":") {
|
|
141
|
-
type = FeatureTable_1.BatchType.PlanarClassifier;
|
|
142
|
-
idx += 2; // P:
|
|
97
|
+
cur() {
|
|
98
|
+
this.require(this.curPos < this.input.length);
|
|
99
|
+
return this.input[this.curPos];
|
|
143
100
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
101
|
+
advance() {
|
|
102
|
+
this.require(this.curPos < this.input.length);
|
|
103
|
+
++this.curPos;
|
|
147
104
|
}
|
|
148
|
-
|
|
149
|
-
|
|
105
|
+
eat(expectedChar) {
|
|
106
|
+
this.require(this.cur() === expectedChar);
|
|
107
|
+
this.advance();
|
|
150
108
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
while (idx < treeId.length && (treeId[idx] >= "0" && treeId[idx] <= "9" || treeId[idx] === ".")) {
|
|
154
|
-
expansionStr += treeId[idx++];
|
|
109
|
+
reject(message = "Invalid tree Id") {
|
|
110
|
+
throw new Error(message);
|
|
155
111
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
idx += 2;
|
|
167
|
-
// Parse animation id
|
|
168
|
-
animationId = "";
|
|
169
|
-
while (idx < treeId.length && treeId[idx] !== "_") {
|
|
170
|
-
animationId += treeId[idx++];
|
|
112
|
+
require(condition, message = "Invalid tree Id") {
|
|
113
|
+
if (!condition)
|
|
114
|
+
this.reject(message);
|
|
115
|
+
}
|
|
116
|
+
parseClassifier() {
|
|
117
|
+
this.eat("C");
|
|
118
|
+
let type = FeatureTable_1.BatchType.VolumeClassifier;
|
|
119
|
+
if (this.cur() === "P") {
|
|
120
|
+
type = FeatureTable_1.BatchType.PlanarClassifier;
|
|
121
|
+
this.advance();
|
|
171
122
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
123
|
+
this.eat(":");
|
|
124
|
+
// C: or CP: is always folowed by expansion then an underscore.
|
|
125
|
+
let expansionStr = "";
|
|
126
|
+
while (this.curPos < this.input.length && (this.cur() >= "0" && this.cur() <= "9" || this.cur() === ".")) {
|
|
127
|
+
expansionStr += this.cur();
|
|
128
|
+
this.advance();
|
|
129
|
+
}
|
|
130
|
+
this.eat("_");
|
|
131
|
+
const expansion = Number.parseFloat(expansionStr);
|
|
132
|
+
this.require(!Number.isNaN(expansion));
|
|
133
|
+
return { type, expansion };
|
|
134
|
+
}
|
|
135
|
+
parseAnimation() {
|
|
136
|
+
if (this.cur() !== "A")
|
|
137
|
+
return undefined;
|
|
138
|
+
this.eat("A");
|
|
139
|
+
this.eat(":");
|
|
140
|
+
const termPos = this.input.indexOf("_", this.curPos);
|
|
141
|
+
this.require(termPos > this.curPos);
|
|
142
|
+
const animationId = this.input.substring(this.curPos, termPos);
|
|
143
|
+
this.require(core_bentley_1.Id64.isId64(animationId));
|
|
144
|
+
this.curPos = termPos + 1; // Skip "_"
|
|
145
|
+
return animationId;
|
|
146
|
+
}
|
|
147
|
+
parsePrimary() {
|
|
148
|
+
const edges = this.parseEdges();
|
|
149
|
+
const sectionCut = this.parseSectionCut();
|
|
150
|
+
return { edges, sectionCut };
|
|
151
|
+
}
|
|
152
|
+
parseEdges() {
|
|
153
|
+
if ("E" !== this.cur())
|
|
154
|
+
return { indexed: false, smooth: false };
|
|
155
|
+
this.eat("E");
|
|
156
|
+
this.eat(":");
|
|
157
|
+
const typeStr = this.cur();
|
|
158
|
+
this.eat(typeStr);
|
|
159
|
+
this.eat("_");
|
|
160
|
+
switch (typeStr) {
|
|
161
|
+
case "0": return false;
|
|
162
|
+
case "2": return { indexed: true, smooth: false };
|
|
163
|
+
case "3": return { indexed: false, smooth: true };
|
|
164
|
+
case "4": return { indexed: true, smooth: true };
|
|
165
|
+
default: this.reject();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
parseSectionCut() {
|
|
169
|
+
if ("S" !== this.cur())
|
|
170
|
+
return undefined;
|
|
171
|
+
this.eat("S");
|
|
172
|
+
const termPos = this.input.indexOf("s", this.curPos);
|
|
173
|
+
this.require(termPos > this.curPos);
|
|
174
|
+
const sectionCut = this.input.substring(this.curPos, termPos);
|
|
175
|
+
this.curPos = termPos + 1; // Skip "_";
|
|
176
|
+
return sectionCut;
|
|
175
177
|
}
|
|
176
|
-
return { idx, animationId };
|
|
177
178
|
}
|
|
178
179
|
/** @internal */
|
|
180
|
+
function parseTileTreeIdAndContentId(treeId, contentId) {
|
|
181
|
+
const parser = new Parser(treeId);
|
|
182
|
+
return parser.parse(contentId);
|
|
183
|
+
}
|
|
184
|
+
exports.parseTileTreeIdAndContentId = parseTileTreeIdAndContentId;
|
|
185
|
+
/** @internal */
|
|
179
186
|
exports.defaultTileOptions = Object.freeze({
|
|
180
187
|
maximumMajorTileFormatVersion: IModelTileIO_1.CurrentImdlVersion.Major,
|
|
181
188
|
enableInstancing: true,
|
|
@@ -188,6 +195,7 @@ exports.defaultTileOptions = Object.freeze({
|
|
|
188
195
|
disableMagnification: false,
|
|
189
196
|
alwaysSubdivideIncompleteTiles: false,
|
|
190
197
|
enableIndexedEdges: true,
|
|
198
|
+
generateAllPolyfaceEdges: true,
|
|
191
199
|
});
|
|
192
200
|
function contentFlagsFromId(id) {
|
|
193
201
|
if (0 === id.length || "-" !== id[0])
|
|
@@ -216,6 +224,18 @@ function treeFlagsAndFormatVersionFromId(id) {
|
|
|
216
224
|
}
|
|
217
225
|
throw new Error("Invalid tree Id");
|
|
218
226
|
}
|
|
227
|
+
function edgeOptionsFromTreeId(id) {
|
|
228
|
+
const pos = id.indexOf("E:");
|
|
229
|
+
if (pos <= 0)
|
|
230
|
+
return { indexed: false, smooth: false };
|
|
231
|
+
switch (id[pos + 2]) {
|
|
232
|
+
case "0": return { indexed: exports.defaultTileOptions.enableIndexedEdges, smooth: exports.defaultTileOptions.generateAllPolyfaceEdges };
|
|
233
|
+
case "2": return { indexed: true, smooth: false };
|
|
234
|
+
case "3": return { indexed: false, smooth: true };
|
|
235
|
+
case "4": return { indexed: true, smooth: true };
|
|
236
|
+
}
|
|
237
|
+
throw new Error("Invalid tree Id");
|
|
238
|
+
}
|
|
219
239
|
/** @internal */
|
|
220
240
|
function getMaximumMajorTileFormatVersion(maxMajorVersion, formatVersion) {
|
|
221
241
|
// The `formatVersion` input is from the backend, telling us precisely the maximum major+minor version it can produce.
|
|
@@ -243,18 +263,19 @@ var TreeFlags;
|
|
|
243
263
|
TreeFlags[TreeFlags["OptimizeBRepProcessing"] = 4] = "OptimizeBRepProcessing";
|
|
244
264
|
TreeFlags[TreeFlags["UseLargerTiles"] = 8] = "UseLargerTiles";
|
|
245
265
|
})(TreeFlags = exports.TreeFlags || (exports.TreeFlags = {}));
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
266
|
+
function compareEdgeOptions(a, b) {
|
|
267
|
+
if (typeof a !== typeof b)
|
|
268
|
+
return a ? 1 : -1;
|
|
269
|
+
if (typeof a === "boolean") {
|
|
270
|
+
(0, core_bentley_1.assert)(typeof b === "boolean");
|
|
271
|
+
return (0, core_bentley_1.compareBooleans)(a, b);
|
|
272
|
+
}
|
|
273
|
+
(0, core_bentley_1.assert)(typeof b === "object");
|
|
274
|
+
let cmp = (0, core_bentley_1.compareBooleans)(a.indexed, b.indexed);
|
|
275
|
+
if (0 === cmp)
|
|
276
|
+
cmp = (0, core_bentley_1.compareBooleans)(a.smooth, b.smooth);
|
|
277
|
+
return cmp;
|
|
278
|
+
}
|
|
258
279
|
function animationIdToString(animationId) {
|
|
259
280
|
return `A:${animationId}_`;
|
|
260
281
|
}
|
|
@@ -273,7 +294,16 @@ function iModelTileTreeIdToString(modelId, treeId, options) {
|
|
|
273
294
|
idStr = `${idStr}${animationIdToString(treeId.animationId)}`;
|
|
274
295
|
else if (treeId.enforceDisplayPriority) // animation and priority are currently mutually exclusive
|
|
275
296
|
flags |= TreeFlags.EnforceDisplayPriority;
|
|
276
|
-
|
|
297
|
+
let edges;
|
|
298
|
+
if (!treeId.edges) {
|
|
299
|
+
edges = "E:0_";
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
if (!treeId.edges.smooth)
|
|
303
|
+
edges = treeId.edges.indexed ? "E:2_" : "";
|
|
304
|
+
else
|
|
305
|
+
edges = treeId.edges.indexed ? "E:4_" : "E:3_";
|
|
306
|
+
}
|
|
277
307
|
const sectionCut = treeId.sectionCut ? `S${treeId.sectionCut}s` : "";
|
|
278
308
|
idStr = `${idStr}${edges}${sectionCut}`;
|
|
279
309
|
}
|
|
@@ -305,7 +335,7 @@ function compareIModelTileTreeIds(lhs, rhs) {
|
|
|
305
335
|
// NB: The redundant checks on BatchType below are to satisfy compiler.
|
|
306
336
|
(0, core_bentley_1.assert)(lhs.type === rhs.type);
|
|
307
337
|
if (FeatureTable_1.BatchType.Primary === lhs.type && FeatureTable_1.BatchType.Primary === rhs.type) {
|
|
308
|
-
cmp = (
|
|
338
|
+
cmp = compareEdgeOptions(lhs.edges, rhs.edges);
|
|
309
339
|
if (0 === cmp) {
|
|
310
340
|
cmp = (0, core_bentley_1.compareBooleansOrUndefined)(lhs.enforceDisplayPriority, rhs.enforceDisplayPriority);
|
|
311
341
|
if (0 === cmp)
|