@itwin/editor-backend 4.0.0-dev.8 → 4.0.0-dev.81
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/CHANGELOG.md +43 -1
- package/lib/cjs/EditBuiltInCommand.d.ts +78 -78
- package/lib/cjs/EditBuiltInCommand.js +637 -638
- package/lib/cjs/EditBuiltInCommand.js.map +1 -1
- package/lib/cjs/EditCommand.d.ts +70 -70
- package/lib/cjs/EditCommand.d.ts.map +1 -1
- package/lib/cjs/EditCommand.js +136 -136
- package/lib/cjs/EditCommand.js.map +1 -1
- package/lib/cjs/editor-backend.d.ts +2 -2
- package/lib/cjs/editor-backend.js +22 -18
- package/lib/cjs/editor-backend.js.map +1 -1
- package/package.json +17 -17
|
@@ -1,639 +1,638 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module Editing
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.SolidModelingCommand = exports.BasicManipulationCommand = void 0;
|
|
11
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
-
const core_geometry_1 = require("@itwin/core-geometry");
|
|
13
|
-
const core_common_1 = require("@itwin/core-common");
|
|
14
|
-
const editor_common_1 = require("@itwin/editor-common");
|
|
15
|
-
const EditCommand_1 = require("./EditCommand");
|
|
16
|
-
/** @alpha */
|
|
17
|
-
class BasicManipulationCommand extends EditCommand_1.EditCommand {
|
|
18
|
-
constructor(iModel, _str) {
|
|
19
|
-
super(iModel);
|
|
20
|
-
this._str = _str;
|
|
21
|
-
}
|
|
22
|
-
async onStart() { return BasicManipulationCommand.commandId; }
|
|
23
|
-
async deleteElements(ids) {
|
|
24
|
-
const idSet = core_bentley_1.CompressedId64Set.decompressSet(ids);
|
|
25
|
-
await this.iModel.locks.acquireLocks({ exclusive: idSet });
|
|
26
|
-
for (const id of idSet)
|
|
27
|
-
this.iModel.elements.deleteElement(id);
|
|
28
|
-
return core_bentley_1.IModelStatus.Success;
|
|
29
|
-
}
|
|
30
|
-
async transformPlacement(ids, transProps) {
|
|
31
|
-
const idSet = core_bentley_1.CompressedId64Set.decompressSet(ids);
|
|
32
|
-
await this.iModel.locks.acquireLocks({ exclusive: idSet });
|
|
33
|
-
const transform = core_geometry_1.Transform.fromJSON(transProps);
|
|
34
|
-
for (const id of idSet) {
|
|
35
|
-
const element = this.iModel.elements.getElement(id);
|
|
36
|
-
if (!element.placement.isValid)
|
|
37
|
-
continue; // Ignore assembly parents w/o geometry, etc...
|
|
38
|
-
element.placement.multiplyTransform(transform);
|
|
39
|
-
this.iModel.elements.updateElement(element.toJSON());
|
|
40
|
-
}
|
|
41
|
-
return core_bentley_1.IModelStatus.Success;
|
|
42
|
-
}
|
|
43
|
-
async rotatePlacement(ids, matrixProps, aboutCenter) {
|
|
44
|
-
const idSet = core_bentley_1.CompressedId64Set.decompressSet(ids);
|
|
45
|
-
await this.iModel.locks.acquireLocks({ exclusive: idSet });
|
|
46
|
-
const matrix = core_geometry_1.Matrix3d.fromJSON(matrixProps);
|
|
47
|
-
for (const id of idSet) {
|
|
48
|
-
const element = this.iModel.elements.getElement(id);
|
|
49
|
-
if (!element.placement.isValid)
|
|
50
|
-
continue; // Ignore assembly parents w/o geometry, etc...
|
|
51
|
-
const fixedPoint = aboutCenter ? element.placement.calculateRange().center : core_geometry_1.Point3d.createFrom(element.placement.origin);
|
|
52
|
-
const transform = core_geometry_1.Transform.createFixedPointAndMatrix(fixedPoint, matrix);
|
|
53
|
-
element.placement.multiplyTransform(transform);
|
|
54
|
-
this.iModel.elements.updateElement(element.toJSON());
|
|
55
|
-
}
|
|
56
|
-
return core_bentley_1.IModelStatus.Success;
|
|
57
|
-
}
|
|
58
|
-
async insertGeometricElement(props, data) {
|
|
59
|
-
await this.iModel.locks.acquireLocks({ shared: props.model });
|
|
60
|
-
if (undefined !== data)
|
|
61
|
-
props.elementGeometryBuilderParams = { entryArray: data.entryArray, viewIndependent: data.viewIndependent };
|
|
62
|
-
return this.iModel.elements.insertElement(props);
|
|
63
|
-
}
|
|
64
|
-
async insertGeometryPart(props, data) {
|
|
65
|
-
await this.iModel.locks.acquireLocks({ shared: props.model });
|
|
66
|
-
if (undefined !== data)
|
|
67
|
-
props.elementGeometryBuilderParams = { entryArray: data.entryArray, is2dPart: data.is2dPart };
|
|
68
|
-
return this.iModel.elements.insertElement(props);
|
|
69
|
-
}
|
|
70
|
-
async updateGeometricElement(propsOrId, data) {
|
|
71
|
-
let props;
|
|
72
|
-
if (typeof propsOrId === "string") {
|
|
73
|
-
if (undefined === data)
|
|
74
|
-
throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "Flatbuffer data required for update by id");
|
|
75
|
-
props = this.iModel.elements.getElementProps(propsOrId);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
props = propsOrId;
|
|
79
|
-
}
|
|
80
|
-
if (undefined === props.id)
|
|
81
|
-
throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "Element id required for update");
|
|
82
|
-
await this.iModel.locks.acquireLocks({ exclusive: props.id });
|
|
83
|
-
if (undefined !== data)
|
|
84
|
-
props.elementGeometryBuilderParams = { entryArray: data.entryArray, viewIndependent: data.viewIndependent };
|
|
85
|
-
this.iModel.elements.updateElement(props);
|
|
86
|
-
}
|
|
87
|
-
async requestElementGeometry(elementId, filter) {
|
|
88
|
-
let accepted;
|
|
89
|
-
const onGeometry = (info) => {
|
|
90
|
-
accepted = info;
|
|
91
|
-
if (undefined !== filter) {
|
|
92
|
-
let numDisplayable = 0;
|
|
93
|
-
for (const entry of info.entryArray) {
|
|
94
|
-
if (!core_common_1.ElementGeometry.isDisplayableEntry(entry))
|
|
95
|
-
continue;
|
|
96
|
-
numDisplayable++;
|
|
97
|
-
if (filter.maxDisplayable && numDisplayable > filter.maxDisplayable) {
|
|
98
|
-
accepted = undefined;
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
if (filter.reject && filter.reject.some((opcode) => entry.opcode === opcode)) {
|
|
102
|
-
accepted = undefined;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
if (filter.accept && !filter.accept.some((opcode) => entry.opcode === opcode)) {
|
|
106
|
-
accepted = undefined;
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
if (undefined === filter.geometry)
|
|
110
|
-
continue;
|
|
111
|
-
let entityType;
|
|
112
|
-
if (filter.geometry.curves && !(filter.geometry.surfaces || filter.geometry.solids))
|
|
113
|
-
entityType = core_common_1.ElementGeometry.isCurve(entry) ? core_common_1.BRepEntity.Type.Wire : undefined; // skip surface/solid opcodes...
|
|
114
|
-
else
|
|
115
|
-
entityType = core_common_1.ElementGeometry.getBRepEntityType(entry);
|
|
116
|
-
switch (entityType) {
|
|
117
|
-
case core_common_1.BRepEntity.Type.Wire:
|
|
118
|
-
if (!filter.geometry.curves)
|
|
119
|
-
accepted = undefined;
|
|
120
|
-
break;
|
|
121
|
-
case core_common_1.BRepEntity.Type.Sheet:
|
|
122
|
-
if (!filter.geometry.surfaces)
|
|
123
|
-
accepted = undefined;
|
|
124
|
-
break;
|
|
125
|
-
case core_common_1.BRepEntity.Type.Solid:
|
|
126
|
-
if (!filter.geometry.solids)
|
|
127
|
-
accepted = undefined;
|
|
128
|
-
break;
|
|
129
|
-
default:
|
|
130
|
-
accepted = undefined;
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
if (undefined === accepted)
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
const requestProps = {
|
|
139
|
-
onGeometry,
|
|
140
|
-
elementId,
|
|
141
|
-
};
|
|
142
|
-
if (core_bentley_1.IModelStatus.Success !== this.iModel.elementGeometryRequest(requestProps))
|
|
143
|
-
return undefined;
|
|
144
|
-
return accepted;
|
|
145
|
-
}
|
|
146
|
-
async updateProjectExtents(extents) {
|
|
147
|
-
const newExtents = new core_geometry_1.Range3d();
|
|
148
|
-
newExtents.setFromJSON(extents);
|
|
149
|
-
if (newExtents.isNull)
|
|
150
|
-
throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "Invalid project extents");
|
|
151
|
-
await this.iModel.acquireSchemaLock();
|
|
152
|
-
this.iModel.updateProjectExtents(newExtents);
|
|
153
|
-
// Set source from calculated to user so connectors preserve the change.
|
|
154
|
-
const unitsProps = { name: "Units", namespace: "dgn_Db" };
|
|
155
|
-
const unitsStr = this.iModel.queryFilePropertyString(unitsProps);
|
|
156
|
-
if (undefined !== unitsStr) {
|
|
157
|
-
const unitsVal = JSON.parse(unitsStr);
|
|
158
|
-
const calculated = 1;
|
|
159
|
-
if (calculated !== unitsVal.extentsSource) {
|
|
160
|
-
unitsVal.extentsSource = calculated;
|
|
161
|
-
this.iModel.saveFileProperty(unitsProps, JSON.stringify(unitsVal));
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
async updateEcefLocation(ecefLocation) {
|
|
166
|
-
await this.iModel.acquireSchemaLock();
|
|
167
|
-
// Clear GCS that caller already determined was invalid...
|
|
168
|
-
this.iModel.deleteFileProperty({ name: "DgnGCS", namespace: "dgn_Db" });
|
|
169
|
-
const newEcefLocation = new core_common_1.EcefLocation(ecefLocation);
|
|
170
|
-
this.iModel.updateEcefLocation(newEcefLocation);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
BasicManipulationCommand
|
|
175
|
-
var QuerySubEntity;
|
|
176
|
-
(function (QuerySubEntity) {
|
|
177
|
-
/** Return whether the supplied face has a planar surface */
|
|
178
|
-
QuerySubEntity[QuerySubEntity["PlanarFace"] = 0] = "PlanarFace";
|
|
179
|
-
/** Return whether the angle between the normals of the supplied edge's faces never exceeds the internal smooth angle tolerance along the length of the edge */
|
|
180
|
-
QuerySubEntity[QuerySubEntity["SmoothEdge"] = 1] = "SmoothEdge";
|
|
181
|
-
/** Return whether the supplied sub-entity is a laminar edge of a sheet body, i.e. boundary of a single face */
|
|
182
|
-
QuerySubEntity[QuerySubEntity["LaminarEdge"] = 2] = "LaminarEdge";
|
|
183
|
-
/** Return whether the supplied sub-entity is a linear edge */
|
|
184
|
-
QuerySubEntity[QuerySubEntity["LinearEdge"] = 3] = "LinearEdge";
|
|
185
|
-
/** Return whether the angle between the normals of the supplied vertices's edges never exceeds the internal smooth angle tolerance along the length of the edge */
|
|
186
|
-
QuerySubEntity[QuerySubEntity["SmoothVertex"] = 4] = "SmoothVertex";
|
|
187
|
-
/** Return whether the supplied sub-entity is a redundant edge (containing faces share surface) */
|
|
188
|
-
QuerySubEntity[QuerySubEntity["RedundantEdge"] = 5] = "RedundantEdge";
|
|
189
|
-
})(QuerySubEntity || (QuerySubEntity = {}));
|
|
190
|
-
var QueryBody;
|
|
191
|
-
(function (QueryBody) {
|
|
192
|
-
/** Return whether the geometric primitive index is a disjoint body */
|
|
193
|
-
QueryBody[QueryBody["DisjointBody"] = 0] = "DisjointBody";
|
|
194
|
-
/** Return whether the geometric primitive index is a sheet body with a single planar face */
|
|
195
|
-
QueryBody[QueryBody["SingleFacePlanarSheet"] = 1] = "SingleFacePlanarSheet";
|
|
196
|
-
/** Return whether the geometric primitive index is a sheet or solid entity that has all planar faces */
|
|
197
|
-
QueryBody[QueryBody["OnlyPlanarFaces"] = 2] = "OnlyPlanarFaces";
|
|
198
|
-
/** Return whether the geometric primitive index is a body with any edge that is non-linear or any face that is non-planar */
|
|
199
|
-
QueryBody[QueryBody["CurvedFaceOrEdge"] = 3] = "CurvedFaceOrEdge";
|
|
200
|
-
/** Return whether the geometric primitive index is a planar sheet or wire body */
|
|
201
|
-
QueryBody[QueryBody["PlanarBody"] = 4] = "PlanarBody";
|
|
202
|
-
})(QueryBody || (QueryBody = {}));
|
|
203
|
-
var OperationType;
|
|
204
|
-
(function (OperationType) {
|
|
205
|
-
OperationType[OperationType["GeometrySummary"] = 0] = "GeometrySummary";
|
|
206
|
-
OperationType[OperationType["SubEntityGeometry"] = 1] = "SubEntityGeometry";
|
|
207
|
-
OperationType[OperationType["SubEntityParameterRange"] = 2] = "SubEntityParameterRange";
|
|
208
|
-
OperationType[OperationType["SubEntityEvaluate"] = 3] = "SubEntityEvaluate";
|
|
209
|
-
OperationType[OperationType["SubEntityQuery"] = 4] = "SubEntityQuery";
|
|
210
|
-
OperationType[OperationType["BodyQuery"] = 5] = "BodyQuery";
|
|
211
|
-
OperationType[OperationType["BodySubEntities"] = 6] = "BodySubEntities";
|
|
212
|
-
OperationType[OperationType["ConnectedSubEntity"] = 7] = "ConnectedSubEntity";
|
|
213
|
-
OperationType[OperationType["LocateSubEntity"] = 8] = "LocateSubEntity";
|
|
214
|
-
OperationType[OperationType["LocateFace"] = 9] = "LocateFace";
|
|
215
|
-
OperationType[OperationType["ClosestSubEntity"] = 10] = "ClosestSubEntity";
|
|
216
|
-
OperationType[OperationType["ClosestFace"] = 11] = "ClosestFace";
|
|
217
|
-
OperationType[OperationType["ClosestPoint"] = 12] = "ClosestPoint";
|
|
218
|
-
OperationType[OperationType["PointInside"] = 13] = "PointInside";
|
|
219
|
-
OperationType[OperationType["BooleanOp"] = 14] = "BooleanOp";
|
|
220
|
-
OperationType[OperationType["SewSheets"] = 15] = "SewSheets";
|
|
221
|
-
OperationType[OperationType["ThickenSheets"] = 16] = "ThickenSheets";
|
|
222
|
-
OperationType[OperationType["OffsetFaces"] = 17] = "OffsetFaces";
|
|
223
|
-
OperationType[OperationType["OffsetEdges"] = 18] = "OffsetEdges";
|
|
224
|
-
OperationType[OperationType["HollowFaces"] = 19] = "HollowFaces";
|
|
225
|
-
OperationType[OperationType["SweepFaces"] = 20] = "SweepFaces";
|
|
226
|
-
OperationType[OperationType["SpinFaces"] = 21] = "SpinFaces";
|
|
227
|
-
OperationType[OperationType["DeleteSubEntity"] = 22] = "DeleteSubEntity";
|
|
228
|
-
OperationType[OperationType["TransformSubEntity"] = 23] = "TransformSubEntity";
|
|
229
|
-
OperationType[OperationType["Blend"] = 24] = "Blend";
|
|
230
|
-
OperationType[OperationType["Chamfer"] = 25] = "Chamfer";
|
|
231
|
-
OperationType[OperationType["Cut"] = 26] = "Cut";
|
|
232
|
-
OperationType[OperationType["Emboss"] = 27] = "Emboss";
|
|
233
|
-
OperationType[OperationType["Imprint"] = 28] = "Imprint";
|
|
234
|
-
OperationType[OperationType["SweepPath"] = 29] = "SweepPath";
|
|
235
|
-
OperationType[OperationType["Loft"] = 30] = "Loft";
|
|
236
|
-
})(OperationType || (OperationType = {}));
|
|
237
|
-
/** @alpha */
|
|
238
|
-
class SolidModelingCommand extends BasicManipulationCommand {
|
|
239
|
-
async onStart() { return SolidModelingCommand.commandId; }
|
|
240
|
-
async updateElementGeometryCache(props) {
|
|
241
|
-
return this.iModel.nativeDb.updateElementGeometryCache(props);
|
|
242
|
-
}
|
|
243
|
-
async createElementGeometryCache(id, filter) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
};
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
};
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
appearance.
|
|
301
|
-
appearance.
|
|
302
|
-
appearance.
|
|
303
|
-
appearance.
|
|
304
|
-
appearance
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
resultProps
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
};
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
};
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
};
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
};
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
};
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
};
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
};
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
};
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
};
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
};
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
};
|
|
462
|
-
const
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
};
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
opts.insertProps.
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
updateProps.
|
|
518
|
-
updateProps
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
const
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
resultProps
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
props
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
exports.SolidModelingCommand = SolidModelingCommand;
|
|
638
|
-
SolidModelingCommand.commandId = editor_common_1.editorBuiltInCmdIds.cmdSolidModeling;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Editing
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SolidModelingCommand = exports.BasicManipulationCommand = void 0;
|
|
11
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
+
const core_geometry_1 = require("@itwin/core-geometry");
|
|
13
|
+
const core_common_1 = require("@itwin/core-common");
|
|
14
|
+
const editor_common_1 = require("@itwin/editor-common");
|
|
15
|
+
const EditCommand_1 = require("./EditCommand");
|
|
16
|
+
/** @alpha */
|
|
17
|
+
class BasicManipulationCommand extends EditCommand_1.EditCommand {
|
|
18
|
+
constructor(iModel, _str) {
|
|
19
|
+
super(iModel);
|
|
20
|
+
this._str = _str;
|
|
21
|
+
}
|
|
22
|
+
async onStart() { return BasicManipulationCommand.commandId; }
|
|
23
|
+
async deleteElements(ids) {
|
|
24
|
+
const idSet = core_bentley_1.CompressedId64Set.decompressSet(ids);
|
|
25
|
+
await this.iModel.locks.acquireLocks({ exclusive: idSet });
|
|
26
|
+
for (const id of idSet)
|
|
27
|
+
this.iModel.elements.deleteElement(id);
|
|
28
|
+
return core_bentley_1.IModelStatus.Success;
|
|
29
|
+
}
|
|
30
|
+
async transformPlacement(ids, transProps) {
|
|
31
|
+
const idSet = core_bentley_1.CompressedId64Set.decompressSet(ids);
|
|
32
|
+
await this.iModel.locks.acquireLocks({ exclusive: idSet });
|
|
33
|
+
const transform = core_geometry_1.Transform.fromJSON(transProps);
|
|
34
|
+
for (const id of idSet) {
|
|
35
|
+
const element = this.iModel.elements.getElement(id);
|
|
36
|
+
if (!element.placement.isValid)
|
|
37
|
+
continue; // Ignore assembly parents w/o geometry, etc...
|
|
38
|
+
element.placement.multiplyTransform(transform);
|
|
39
|
+
this.iModel.elements.updateElement(element.toJSON());
|
|
40
|
+
}
|
|
41
|
+
return core_bentley_1.IModelStatus.Success;
|
|
42
|
+
}
|
|
43
|
+
async rotatePlacement(ids, matrixProps, aboutCenter) {
|
|
44
|
+
const idSet = core_bentley_1.CompressedId64Set.decompressSet(ids);
|
|
45
|
+
await this.iModel.locks.acquireLocks({ exclusive: idSet });
|
|
46
|
+
const matrix = core_geometry_1.Matrix3d.fromJSON(matrixProps);
|
|
47
|
+
for (const id of idSet) {
|
|
48
|
+
const element = this.iModel.elements.getElement(id);
|
|
49
|
+
if (!element.placement.isValid)
|
|
50
|
+
continue; // Ignore assembly parents w/o geometry, etc...
|
|
51
|
+
const fixedPoint = aboutCenter ? element.placement.calculateRange().center : core_geometry_1.Point3d.createFrom(element.placement.origin);
|
|
52
|
+
const transform = core_geometry_1.Transform.createFixedPointAndMatrix(fixedPoint, matrix);
|
|
53
|
+
element.placement.multiplyTransform(transform);
|
|
54
|
+
this.iModel.elements.updateElement(element.toJSON());
|
|
55
|
+
}
|
|
56
|
+
return core_bentley_1.IModelStatus.Success;
|
|
57
|
+
}
|
|
58
|
+
async insertGeometricElement(props, data) {
|
|
59
|
+
await this.iModel.locks.acquireLocks({ shared: props.model });
|
|
60
|
+
if (undefined !== data)
|
|
61
|
+
props.elementGeometryBuilderParams = { entryArray: data.entryArray, viewIndependent: data.viewIndependent };
|
|
62
|
+
return this.iModel.elements.insertElement(props);
|
|
63
|
+
}
|
|
64
|
+
async insertGeometryPart(props, data) {
|
|
65
|
+
await this.iModel.locks.acquireLocks({ shared: props.model });
|
|
66
|
+
if (undefined !== data)
|
|
67
|
+
props.elementGeometryBuilderParams = { entryArray: data.entryArray, is2dPart: data.is2dPart };
|
|
68
|
+
return this.iModel.elements.insertElement(props);
|
|
69
|
+
}
|
|
70
|
+
async updateGeometricElement(propsOrId, data) {
|
|
71
|
+
let props;
|
|
72
|
+
if (typeof propsOrId === "string") {
|
|
73
|
+
if (undefined === data)
|
|
74
|
+
throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "Flatbuffer data required for update by id");
|
|
75
|
+
props = this.iModel.elements.getElementProps(propsOrId);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
props = propsOrId;
|
|
79
|
+
}
|
|
80
|
+
if (undefined === props.id)
|
|
81
|
+
throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "Element id required for update");
|
|
82
|
+
await this.iModel.locks.acquireLocks({ exclusive: props.id });
|
|
83
|
+
if (undefined !== data)
|
|
84
|
+
props.elementGeometryBuilderParams = { entryArray: data.entryArray, viewIndependent: data.viewIndependent };
|
|
85
|
+
this.iModel.elements.updateElement(props);
|
|
86
|
+
}
|
|
87
|
+
async requestElementGeometry(elementId, filter) {
|
|
88
|
+
let accepted;
|
|
89
|
+
const onGeometry = (info) => {
|
|
90
|
+
accepted = info;
|
|
91
|
+
if (undefined !== filter) {
|
|
92
|
+
let numDisplayable = 0;
|
|
93
|
+
for (const entry of info.entryArray) {
|
|
94
|
+
if (!core_common_1.ElementGeometry.isDisplayableEntry(entry))
|
|
95
|
+
continue;
|
|
96
|
+
numDisplayable++;
|
|
97
|
+
if (filter.maxDisplayable && numDisplayable > filter.maxDisplayable) {
|
|
98
|
+
accepted = undefined;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
if (filter.reject && filter.reject.some((opcode) => entry.opcode === opcode)) {
|
|
102
|
+
accepted = undefined;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
if (filter.accept && !filter.accept.some((opcode) => entry.opcode === opcode)) {
|
|
106
|
+
accepted = undefined;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
if (undefined === filter.geometry)
|
|
110
|
+
continue;
|
|
111
|
+
let entityType;
|
|
112
|
+
if (filter.geometry.curves && !(filter.geometry.surfaces || filter.geometry.solids))
|
|
113
|
+
entityType = core_common_1.ElementGeometry.isCurve(entry) ? core_common_1.BRepEntity.Type.Wire : undefined; // skip surface/solid opcodes...
|
|
114
|
+
else
|
|
115
|
+
entityType = core_common_1.ElementGeometry.getBRepEntityType(entry);
|
|
116
|
+
switch (entityType) {
|
|
117
|
+
case core_common_1.BRepEntity.Type.Wire:
|
|
118
|
+
if (!filter.geometry.curves)
|
|
119
|
+
accepted = undefined;
|
|
120
|
+
break;
|
|
121
|
+
case core_common_1.BRepEntity.Type.Sheet:
|
|
122
|
+
if (!filter.geometry.surfaces)
|
|
123
|
+
accepted = undefined;
|
|
124
|
+
break;
|
|
125
|
+
case core_common_1.BRepEntity.Type.Solid:
|
|
126
|
+
if (!filter.geometry.solids)
|
|
127
|
+
accepted = undefined;
|
|
128
|
+
break;
|
|
129
|
+
default:
|
|
130
|
+
accepted = undefined;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
if (undefined === accepted)
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const requestProps = {
|
|
139
|
+
onGeometry,
|
|
140
|
+
elementId,
|
|
141
|
+
};
|
|
142
|
+
if (core_bentley_1.IModelStatus.Success !== this.iModel.elementGeometryRequest(requestProps))
|
|
143
|
+
return undefined;
|
|
144
|
+
return accepted;
|
|
145
|
+
}
|
|
146
|
+
async updateProjectExtents(extents) {
|
|
147
|
+
const newExtents = new core_geometry_1.Range3d();
|
|
148
|
+
newExtents.setFromJSON(extents);
|
|
149
|
+
if (newExtents.isNull)
|
|
150
|
+
throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "Invalid project extents");
|
|
151
|
+
await this.iModel.acquireSchemaLock();
|
|
152
|
+
this.iModel.updateProjectExtents(newExtents);
|
|
153
|
+
// Set source from calculated to user so connectors preserve the change.
|
|
154
|
+
const unitsProps = { name: "Units", namespace: "dgn_Db" };
|
|
155
|
+
const unitsStr = this.iModel.queryFilePropertyString(unitsProps);
|
|
156
|
+
if (undefined !== unitsStr) {
|
|
157
|
+
const unitsVal = JSON.parse(unitsStr);
|
|
158
|
+
const calculated = 1;
|
|
159
|
+
if (calculated !== unitsVal.extentsSource) {
|
|
160
|
+
unitsVal.extentsSource = calculated;
|
|
161
|
+
this.iModel.saveFileProperty(unitsProps, JSON.stringify(unitsVal));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async updateEcefLocation(ecefLocation) {
|
|
166
|
+
await this.iModel.acquireSchemaLock();
|
|
167
|
+
// Clear GCS that caller already determined was invalid...
|
|
168
|
+
this.iModel.deleteFileProperty({ name: "DgnGCS", namespace: "dgn_Db" });
|
|
169
|
+
const newEcefLocation = new core_common_1.EcefLocation(ecefLocation);
|
|
170
|
+
this.iModel.updateEcefLocation(newEcefLocation);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
BasicManipulationCommand.commandId = editor_common_1.editorBuiltInCmdIds.cmdBasicManipulation;
|
|
174
|
+
exports.BasicManipulationCommand = BasicManipulationCommand;
|
|
175
|
+
var QuerySubEntity;
|
|
176
|
+
(function (QuerySubEntity) {
|
|
177
|
+
/** Return whether the supplied face has a planar surface */
|
|
178
|
+
QuerySubEntity[QuerySubEntity["PlanarFace"] = 0] = "PlanarFace";
|
|
179
|
+
/** Return whether the angle between the normals of the supplied edge's faces never exceeds the internal smooth angle tolerance along the length of the edge */
|
|
180
|
+
QuerySubEntity[QuerySubEntity["SmoothEdge"] = 1] = "SmoothEdge";
|
|
181
|
+
/** Return whether the supplied sub-entity is a laminar edge of a sheet body, i.e. boundary of a single face */
|
|
182
|
+
QuerySubEntity[QuerySubEntity["LaminarEdge"] = 2] = "LaminarEdge";
|
|
183
|
+
/** Return whether the supplied sub-entity is a linear edge */
|
|
184
|
+
QuerySubEntity[QuerySubEntity["LinearEdge"] = 3] = "LinearEdge";
|
|
185
|
+
/** Return whether the angle between the normals of the supplied vertices's edges never exceeds the internal smooth angle tolerance along the length of the edge */
|
|
186
|
+
QuerySubEntity[QuerySubEntity["SmoothVertex"] = 4] = "SmoothVertex";
|
|
187
|
+
/** Return whether the supplied sub-entity is a redundant edge (containing faces share surface) */
|
|
188
|
+
QuerySubEntity[QuerySubEntity["RedundantEdge"] = 5] = "RedundantEdge";
|
|
189
|
+
})(QuerySubEntity || (QuerySubEntity = {}));
|
|
190
|
+
var QueryBody;
|
|
191
|
+
(function (QueryBody) {
|
|
192
|
+
/** Return whether the geometric primitive index is a disjoint body */
|
|
193
|
+
QueryBody[QueryBody["DisjointBody"] = 0] = "DisjointBody";
|
|
194
|
+
/** Return whether the geometric primitive index is a sheet body with a single planar face */
|
|
195
|
+
QueryBody[QueryBody["SingleFacePlanarSheet"] = 1] = "SingleFacePlanarSheet";
|
|
196
|
+
/** Return whether the geometric primitive index is a sheet or solid entity that has all planar faces */
|
|
197
|
+
QueryBody[QueryBody["OnlyPlanarFaces"] = 2] = "OnlyPlanarFaces";
|
|
198
|
+
/** Return whether the geometric primitive index is a body with any edge that is non-linear or any face that is non-planar */
|
|
199
|
+
QueryBody[QueryBody["CurvedFaceOrEdge"] = 3] = "CurvedFaceOrEdge";
|
|
200
|
+
/** Return whether the geometric primitive index is a planar sheet or wire body */
|
|
201
|
+
QueryBody[QueryBody["PlanarBody"] = 4] = "PlanarBody";
|
|
202
|
+
})(QueryBody || (QueryBody = {}));
|
|
203
|
+
var OperationType;
|
|
204
|
+
(function (OperationType) {
|
|
205
|
+
OperationType[OperationType["GeometrySummary"] = 0] = "GeometrySummary";
|
|
206
|
+
OperationType[OperationType["SubEntityGeometry"] = 1] = "SubEntityGeometry";
|
|
207
|
+
OperationType[OperationType["SubEntityParameterRange"] = 2] = "SubEntityParameterRange";
|
|
208
|
+
OperationType[OperationType["SubEntityEvaluate"] = 3] = "SubEntityEvaluate";
|
|
209
|
+
OperationType[OperationType["SubEntityQuery"] = 4] = "SubEntityQuery";
|
|
210
|
+
OperationType[OperationType["BodyQuery"] = 5] = "BodyQuery";
|
|
211
|
+
OperationType[OperationType["BodySubEntities"] = 6] = "BodySubEntities";
|
|
212
|
+
OperationType[OperationType["ConnectedSubEntity"] = 7] = "ConnectedSubEntity";
|
|
213
|
+
OperationType[OperationType["LocateSubEntity"] = 8] = "LocateSubEntity";
|
|
214
|
+
OperationType[OperationType["LocateFace"] = 9] = "LocateFace";
|
|
215
|
+
OperationType[OperationType["ClosestSubEntity"] = 10] = "ClosestSubEntity";
|
|
216
|
+
OperationType[OperationType["ClosestFace"] = 11] = "ClosestFace";
|
|
217
|
+
OperationType[OperationType["ClosestPoint"] = 12] = "ClosestPoint";
|
|
218
|
+
OperationType[OperationType["PointInside"] = 13] = "PointInside";
|
|
219
|
+
OperationType[OperationType["BooleanOp"] = 14] = "BooleanOp";
|
|
220
|
+
OperationType[OperationType["SewSheets"] = 15] = "SewSheets";
|
|
221
|
+
OperationType[OperationType["ThickenSheets"] = 16] = "ThickenSheets";
|
|
222
|
+
OperationType[OperationType["OffsetFaces"] = 17] = "OffsetFaces";
|
|
223
|
+
OperationType[OperationType["OffsetEdges"] = 18] = "OffsetEdges";
|
|
224
|
+
OperationType[OperationType["HollowFaces"] = 19] = "HollowFaces";
|
|
225
|
+
OperationType[OperationType["SweepFaces"] = 20] = "SweepFaces";
|
|
226
|
+
OperationType[OperationType["SpinFaces"] = 21] = "SpinFaces";
|
|
227
|
+
OperationType[OperationType["DeleteSubEntity"] = 22] = "DeleteSubEntity";
|
|
228
|
+
OperationType[OperationType["TransformSubEntity"] = 23] = "TransformSubEntity";
|
|
229
|
+
OperationType[OperationType["Blend"] = 24] = "Blend";
|
|
230
|
+
OperationType[OperationType["Chamfer"] = 25] = "Chamfer";
|
|
231
|
+
OperationType[OperationType["Cut"] = 26] = "Cut";
|
|
232
|
+
OperationType[OperationType["Emboss"] = 27] = "Emboss";
|
|
233
|
+
OperationType[OperationType["Imprint"] = 28] = "Imprint";
|
|
234
|
+
OperationType[OperationType["SweepPath"] = 29] = "SweepPath";
|
|
235
|
+
OperationType[OperationType["Loft"] = 30] = "Loft";
|
|
236
|
+
})(OperationType || (OperationType = {}));
|
|
237
|
+
/** @alpha */
|
|
238
|
+
class SolidModelingCommand extends BasicManipulationCommand {
|
|
239
|
+
async onStart() { return SolidModelingCommand.commandId; }
|
|
240
|
+
async updateElementGeometryCache(props) {
|
|
241
|
+
return this.iModel.nativeDb.updateElementGeometryCache(props);
|
|
242
|
+
}
|
|
243
|
+
async createElementGeometryCache(id, filter) {
|
|
244
|
+
const result = await this.updateElementGeometryCache({ id });
|
|
245
|
+
if (core_bentley_1.BentleyStatus.SUCCESS !== result.status)
|
|
246
|
+
return false;
|
|
247
|
+
if (undefined === filter)
|
|
248
|
+
return true;
|
|
249
|
+
if (filter.minGeom && (undefined === result.numGeom || filter.minGeom > result.numGeom))
|
|
250
|
+
return false;
|
|
251
|
+
if (filter.maxGeom && (undefined === result.numGeom || filter.maxGeom < result.numGeom))
|
|
252
|
+
return false;
|
|
253
|
+
if (!filter.parts && (result.numPart ?? 0 > 0))
|
|
254
|
+
return false;
|
|
255
|
+
if (!filter.curves && (result.numCurve ?? 0 > 0))
|
|
256
|
+
return false;
|
|
257
|
+
if (!filter.surfaces && (result.numSurface ?? 0 > 0))
|
|
258
|
+
return false;
|
|
259
|
+
if (!filter.solids && (result.numSolid ?? 0 > 0))
|
|
260
|
+
return false;
|
|
261
|
+
if (!filter.other && (result.numOther ?? 0 > 0))
|
|
262
|
+
return false;
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
async clearElementGeometryCache() {
|
|
266
|
+
await this.updateElementGeometryCache({});
|
|
267
|
+
}
|
|
268
|
+
async summarizeElementGeometryCache(id) {
|
|
269
|
+
let accepted;
|
|
270
|
+
const onResult = (info) => {
|
|
271
|
+
accepted = info;
|
|
272
|
+
};
|
|
273
|
+
const params = { onResult };
|
|
274
|
+
const props = { id, op: OperationType.GeometrySummary, params };
|
|
275
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
276
|
+
return accepted;
|
|
277
|
+
}
|
|
278
|
+
requestSubEntityGeometry(id, subEntity) {
|
|
279
|
+
let accepted;
|
|
280
|
+
const onResult = (info) => {
|
|
281
|
+
accepted = info;
|
|
282
|
+
};
|
|
283
|
+
const params = { subEntity, onResult };
|
|
284
|
+
const props = { id, op: OperationType.SubEntityGeometry, params };
|
|
285
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
286
|
+
return accepted;
|
|
287
|
+
}
|
|
288
|
+
async getSubEntityGeometry(id, subEntity, opts) {
|
|
289
|
+
const geometryProps = this.requestSubEntityGeometry(id, subEntity);
|
|
290
|
+
if (undefined === geometryProps?.geometry || undefined === geometryProps?.category)
|
|
291
|
+
return undefined;
|
|
292
|
+
const resultProps = {};
|
|
293
|
+
if (opts.wantGeometry)
|
|
294
|
+
resultProps.geometry = geometryProps.geometry;
|
|
295
|
+
if (opts.wantRange)
|
|
296
|
+
resultProps.range = (geometryProps?.range ? core_common_1.ElementGeometry.toElementAlignedBox3d(geometryProps?.range) : undefined);
|
|
297
|
+
if (opts.wantAppearance) {
|
|
298
|
+
const appearance = { category: geometryProps.category };
|
|
299
|
+
appearance.subCategory = geometryProps.subCategory;
|
|
300
|
+
appearance.material = geometryProps.material;
|
|
301
|
+
appearance.color = geometryProps.color;
|
|
302
|
+
appearance.transparency = geometryProps.transparency;
|
|
303
|
+
appearance.weight = geometryProps.weight;
|
|
304
|
+
resultProps.appearance = appearance;
|
|
305
|
+
}
|
|
306
|
+
if (!opts.wantGraphic)
|
|
307
|
+
return resultProps;
|
|
308
|
+
const requestId = opts.requestId ? opts.requestId : `SubEntity:${id}-${subEntity.id}`;
|
|
309
|
+
const toleranceLog10 = (opts.chordTolerance ? Math.floor(Math.log10(opts.chordTolerance)) : -2);
|
|
310
|
+
const requestProps = {
|
|
311
|
+
id: requestId,
|
|
312
|
+
modelId: this.iModel.iModelId,
|
|
313
|
+
toleranceLog10,
|
|
314
|
+
type: "3d",
|
|
315
|
+
placement: { origin: core_geometry_1.Point3d.createZero(), angles: core_geometry_1.YawPitchRollAngles.createDegrees(0, 0, 0) },
|
|
316
|
+
categoryId: geometryProps.category,
|
|
317
|
+
elementId: id,
|
|
318
|
+
geometry: { format: "flatbuffer", data: [geometryProps.geometry] },
|
|
319
|
+
};
|
|
320
|
+
resultProps.graphic = await this.iModel.generateElementGraphics(requestProps);
|
|
321
|
+
return resultProps;
|
|
322
|
+
}
|
|
323
|
+
async getSubEntityParameterRange(id, subEntity) {
|
|
324
|
+
let accepted;
|
|
325
|
+
const onResult = (info) => {
|
|
326
|
+
accepted = info;
|
|
327
|
+
};
|
|
328
|
+
const params = { subEntity, onResult };
|
|
329
|
+
const props = { id, op: OperationType.SubEntityParameterRange, params };
|
|
330
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
331
|
+
return accepted;
|
|
332
|
+
}
|
|
333
|
+
async evaluateSubEntity(id, subEntity, uParam, vParam) {
|
|
334
|
+
let accepted;
|
|
335
|
+
const onResult = (info) => {
|
|
336
|
+
accepted = info;
|
|
337
|
+
};
|
|
338
|
+
const params = { subEntity, uParam, vParam, onResult };
|
|
339
|
+
const props = { id, op: OperationType.SubEntityEvaluate, params };
|
|
340
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
341
|
+
return accepted;
|
|
342
|
+
}
|
|
343
|
+
async subEntityQuery(id, subEntity, query) {
|
|
344
|
+
let accepted = false;
|
|
345
|
+
const onResult = (info) => {
|
|
346
|
+
accepted = info;
|
|
347
|
+
};
|
|
348
|
+
const params = { subEntity, query, onResult };
|
|
349
|
+
const props = { id, op: OperationType.SubEntityQuery, params };
|
|
350
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
351
|
+
return accepted;
|
|
352
|
+
}
|
|
353
|
+
async isPlanarFace(id, subEntity) {
|
|
354
|
+
return this.subEntityQuery(id, subEntity, QuerySubEntity.PlanarFace);
|
|
355
|
+
}
|
|
356
|
+
async isSmoothEdge(id, subEntity) {
|
|
357
|
+
return this.subEntityQuery(id, subEntity, QuerySubEntity.SmoothEdge);
|
|
358
|
+
}
|
|
359
|
+
async isLaminarEdge(id, subEntity) {
|
|
360
|
+
return this.subEntityQuery(id, subEntity, QuerySubEntity.LaminarEdge);
|
|
361
|
+
}
|
|
362
|
+
async isLinearEdge(id, subEntity) {
|
|
363
|
+
return this.subEntityQuery(id, subEntity, QuerySubEntity.LinearEdge);
|
|
364
|
+
}
|
|
365
|
+
async isRedundantEdge(id, subEntity) {
|
|
366
|
+
return this.subEntityQuery(id, subEntity, QuerySubEntity.RedundantEdge);
|
|
367
|
+
}
|
|
368
|
+
async isSmoothVertex(id, subEntity) {
|
|
369
|
+
return this.subEntityQuery(id, subEntity, QuerySubEntity.SmoothVertex);
|
|
370
|
+
}
|
|
371
|
+
async bodyQuery(id, index, query) {
|
|
372
|
+
let accepted = false;
|
|
373
|
+
const onResult = (info) => {
|
|
374
|
+
accepted = info;
|
|
375
|
+
};
|
|
376
|
+
const params = { index, query, onResult };
|
|
377
|
+
const props = { id, op: OperationType.BodyQuery, params };
|
|
378
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
379
|
+
return accepted;
|
|
380
|
+
}
|
|
381
|
+
async isDisjointBody(id, index) {
|
|
382
|
+
return this.bodyQuery(id, index, QueryBody.DisjointBody);
|
|
383
|
+
}
|
|
384
|
+
async isPlanarBody(id, index) {
|
|
385
|
+
return this.bodyQuery(id, index, QueryBody.PlanarBody);
|
|
386
|
+
}
|
|
387
|
+
async isSingleFacePlanarSheet(id, index) {
|
|
388
|
+
return this.bodyQuery(id, index, QueryBody.SingleFacePlanarSheet);
|
|
389
|
+
}
|
|
390
|
+
async hasOnlyPlanarFaces(id, index) {
|
|
391
|
+
return this.bodyQuery(id, index, QueryBody.OnlyPlanarFaces);
|
|
392
|
+
}
|
|
393
|
+
async hasCurvedFaceOrEdge(id, index) {
|
|
394
|
+
return this.bodyQuery(id, index, QueryBody.CurvedFaceOrEdge);
|
|
395
|
+
}
|
|
396
|
+
async getBodySubEntities(id, type, firstOnly) {
|
|
397
|
+
let accepted;
|
|
398
|
+
const onResult = (info) => {
|
|
399
|
+
accepted = info;
|
|
400
|
+
};
|
|
401
|
+
const params = { type, firstOnly, onResult };
|
|
402
|
+
const props = { id, op: OperationType.BodySubEntities, params };
|
|
403
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
404
|
+
return accepted;
|
|
405
|
+
}
|
|
406
|
+
async getConnectedSubEntities(id, subEntity, type, options) {
|
|
407
|
+
let accepted;
|
|
408
|
+
const onResult = (info) => {
|
|
409
|
+
accepted = info;
|
|
410
|
+
};
|
|
411
|
+
const params = { subEntity, type, options, onResult };
|
|
412
|
+
const props = { id, op: OperationType.ConnectedSubEntity, params };
|
|
413
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
414
|
+
return accepted;
|
|
415
|
+
}
|
|
416
|
+
async locateSubEntities(id, point, direction, options) {
|
|
417
|
+
let accepted;
|
|
418
|
+
const onResult = (info) => {
|
|
419
|
+
accepted = info;
|
|
420
|
+
};
|
|
421
|
+
const params = { point, direction, options, onResult };
|
|
422
|
+
const props = { id, op: OperationType.LocateSubEntity, params };
|
|
423
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
424
|
+
return accepted;
|
|
425
|
+
}
|
|
426
|
+
async locateFace(id, subEntity, point, direction) {
|
|
427
|
+
let accepted;
|
|
428
|
+
const onResult = (info) => {
|
|
429
|
+
accepted = info;
|
|
430
|
+
};
|
|
431
|
+
const params = { subEntity, point, direction, onResult };
|
|
432
|
+
const props = { id, op: OperationType.LocateFace, params };
|
|
433
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
434
|
+
return accepted;
|
|
435
|
+
}
|
|
436
|
+
async getClosestSubEntity(id, point) {
|
|
437
|
+
let accepted;
|
|
438
|
+
const onResult = (info) => {
|
|
439
|
+
accepted = info;
|
|
440
|
+
};
|
|
441
|
+
const params = { point, onResult };
|
|
442
|
+
const props = { id, op: OperationType.ClosestSubEntity, params };
|
|
443
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
444
|
+
return accepted;
|
|
445
|
+
}
|
|
446
|
+
async getClosestFace(id, point, direction) {
|
|
447
|
+
let accepted;
|
|
448
|
+
const onResult = (info) => {
|
|
449
|
+
accepted = info;
|
|
450
|
+
};
|
|
451
|
+
const params = { point, direction, onResult };
|
|
452
|
+
const props = { id, op: OperationType.ClosestFace, params };
|
|
453
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
454
|
+
return accepted;
|
|
455
|
+
}
|
|
456
|
+
async getClosestPoint(id, subEntity, point) {
|
|
457
|
+
let accepted;
|
|
458
|
+
const onResult = (info) => {
|
|
459
|
+
accepted = info;
|
|
460
|
+
};
|
|
461
|
+
const params = { subEntity, point, onResult };
|
|
462
|
+
const props = { id, op: OperationType.ClosestPoint, params };
|
|
463
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
464
|
+
return accepted;
|
|
465
|
+
}
|
|
466
|
+
async isPointInside(id, point) {
|
|
467
|
+
let accepted;
|
|
468
|
+
const onResult = (info) => {
|
|
469
|
+
accepted = info;
|
|
470
|
+
};
|
|
471
|
+
const params = { point, onResult };
|
|
472
|
+
const props = { id, op: OperationType.PointInside, params };
|
|
473
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
474
|
+
return accepted;
|
|
475
|
+
}
|
|
476
|
+
async getElementGeometryResults(id, info, opts, tools) {
|
|
477
|
+
if (0 === info.entryArray.length || undefined === info.categoryId || undefined === info.bbox)
|
|
478
|
+
return undefined;
|
|
479
|
+
const resultProps = {};
|
|
480
|
+
if (opts.wantGeometry)
|
|
481
|
+
resultProps.geometry = info;
|
|
482
|
+
if (opts.wantRange)
|
|
483
|
+
resultProps.range = core_common_1.ElementGeometry.toElementAlignedBox3d(info.bbox);
|
|
484
|
+
if (opts.wantAppearance)
|
|
485
|
+
resultProps.categoryId = info.categoryId;
|
|
486
|
+
if (!(opts.wantGraphic || opts.writeChanges))
|
|
487
|
+
return resultProps;
|
|
488
|
+
let placement;
|
|
489
|
+
const sourceToWorld = (undefined === info?.sourceToWorld ? undefined : core_common_1.ElementGeometry.toTransform(info.sourceToWorld));
|
|
490
|
+
if (undefined === sourceToWorld) {
|
|
491
|
+
placement = { origin: core_geometry_1.Point3d.createZero(), angles: core_geometry_1.YawPitchRollAngles.createDegrees(0, 0, 0) };
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
const origin = sourceToWorld.getOrigin();
|
|
495
|
+
const angles = new core_geometry_1.YawPitchRollAngles();
|
|
496
|
+
core_geometry_1.YawPitchRollAngles.createFromMatrix3d(sourceToWorld.matrix, angles);
|
|
497
|
+
placement = { origin, angles };
|
|
498
|
+
}
|
|
499
|
+
if (opts.writeChanges) {
|
|
500
|
+
if (undefined !== tools) {
|
|
501
|
+
if (opts.insertProps) {
|
|
502
|
+
// NOTE: Insert model may be different than tool model(s), can't rely on getting shared lock from them...
|
|
503
|
+
await this.iModel.locks.acquireLocks({ shared: opts.insertProps.model, exclusive: tools });
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
await this.iModel.locks.acquireLocks({ exclusive: [id, ...tools] });
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
if (opts.insertProps) {
|
|
510
|
+
opts.insertProps.placement = placement; // entryArray is local to this placement...
|
|
511
|
+
delete opts.insertProps.geom; // Ignore geometry if present...
|
|
512
|
+
resultProps.elementId = await this.insertGeometricElement(opts.insertProps, { entryArray: info.entryArray });
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
const updateProps = this.iModel.elements.getElementProps({ id });
|
|
516
|
+
updateProps.category = info.categoryId; // allow category change...
|
|
517
|
+
updateProps.placement = placement; // entryArray is local to this placement...
|
|
518
|
+
await this.updateGeometricElement(updateProps, { entryArray: info.entryArray });
|
|
519
|
+
resultProps.elementId = id;
|
|
520
|
+
}
|
|
521
|
+
if (undefined !== tools) {
|
|
522
|
+
for (const toolId of core_bentley_1.Id64.iterable(tools))
|
|
523
|
+
this.iModel.elements.deleteElement(toolId);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
if (!opts.wantGraphic)
|
|
527
|
+
return resultProps;
|
|
528
|
+
const requestId = opts.requestId ? opts.requestId : `EGCacheOp:${id}`;
|
|
529
|
+
const toleranceLog10 = (opts.chordTolerance ? Math.floor(Math.log10(opts.chordTolerance)) : -2);
|
|
530
|
+
const requestProps = {
|
|
531
|
+
id: requestId,
|
|
532
|
+
modelId: this.iModel.iModelId,
|
|
533
|
+
toleranceLog10,
|
|
534
|
+
type: "3d",
|
|
535
|
+
placement,
|
|
536
|
+
categoryId: info.categoryId,
|
|
537
|
+
elementId: id,
|
|
538
|
+
geometry: { format: "flatbuffer", data: info.entryArray },
|
|
539
|
+
};
|
|
540
|
+
resultProps.graphic = await this.iModel.generateElementGraphics(requestProps);
|
|
541
|
+
return resultProps;
|
|
542
|
+
}
|
|
543
|
+
async doElementGeometryOperation(props, opts, tools) {
|
|
544
|
+
let accepted;
|
|
545
|
+
const onGeometry = (info) => {
|
|
546
|
+
accepted = info;
|
|
547
|
+
};
|
|
548
|
+
props.onGeometry = onGeometry;
|
|
549
|
+
this.iModel.nativeDb.elementGeometryCacheOperation(props);
|
|
550
|
+
if (undefined === accepted)
|
|
551
|
+
return undefined;
|
|
552
|
+
return this.getElementGeometryResults(props.id, accepted, opts, tools);
|
|
553
|
+
}
|
|
554
|
+
async booleanOperation(id, params, opts) {
|
|
555
|
+
// target insert = keep tools, target update = delete tools...
|
|
556
|
+
const props = { id, op: OperationType.BooleanOp, params };
|
|
557
|
+
return this.doElementGeometryOperation(props, opts, undefined === opts.insertProps ? params.tools : undefined);
|
|
558
|
+
}
|
|
559
|
+
async sewSheets(id, params, opts) {
|
|
560
|
+
// target insert = keep tools, target update = delete tools...
|
|
561
|
+
const props = { id, op: OperationType.SewSheets, params };
|
|
562
|
+
return this.doElementGeometryOperation(props, opts, undefined === opts.insertProps ? params.tools : undefined);
|
|
563
|
+
}
|
|
564
|
+
async thickenSheets(id, params, opts) {
|
|
565
|
+
const props = { id, op: OperationType.ThickenSheets, params };
|
|
566
|
+
return this.doElementGeometryOperation(props, opts);
|
|
567
|
+
}
|
|
568
|
+
async cutSolid(id, params, opts) {
|
|
569
|
+
const props = { id, op: OperationType.Cut, params };
|
|
570
|
+
return this.doElementGeometryOperation(props, opts, !params.keepProfile ? params.profile : undefined);
|
|
571
|
+
}
|
|
572
|
+
async embossBody(id, params, opts) {
|
|
573
|
+
const props = { id, op: OperationType.Emboss, params };
|
|
574
|
+
return this.doElementGeometryOperation(props, opts, !params.keepProfile ? params.profile : undefined);
|
|
575
|
+
}
|
|
576
|
+
async imprintBody(id, params, opts) {
|
|
577
|
+
const props = { id, op: OperationType.Imprint, params };
|
|
578
|
+
return this.doElementGeometryOperation(props, opts, !params.keepProfile && "string" === typeof (params.imprint) ? params.imprint : undefined);
|
|
579
|
+
}
|
|
580
|
+
async sweepAlongPath(id, params, opts) {
|
|
581
|
+
const props = { id, op: OperationType.SweepPath, params };
|
|
582
|
+
return this.doElementGeometryOperation(props, opts, !params.keepPath ? params.path : undefined);
|
|
583
|
+
}
|
|
584
|
+
async loftProfiles(id, params, opts) {
|
|
585
|
+
const toolIds = (opts.writeChanges && (!params.keepTools || !params.keepGuides)) ? new Set() : undefined;
|
|
586
|
+
if (undefined !== toolIds) {
|
|
587
|
+
if (!params.keepTools) {
|
|
588
|
+
for (const toolId of core_bentley_1.Id64.iterable(params.tools))
|
|
589
|
+
toolIds.add(toolId);
|
|
590
|
+
}
|
|
591
|
+
if (undefined !== params.guides && !params.keepGuides) {
|
|
592
|
+
for (const guideId of core_bentley_1.Id64.iterable(params.guides))
|
|
593
|
+
toolIds.add(guideId);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
const props = { id, op: OperationType.Loft, params };
|
|
597
|
+
return this.doElementGeometryOperation(props, opts, toolIds);
|
|
598
|
+
}
|
|
599
|
+
async offsetFaces(id, params, opts) {
|
|
600
|
+
const props = { id, op: OperationType.OffsetFaces, params };
|
|
601
|
+
return this.doElementGeometryOperation(props, opts);
|
|
602
|
+
}
|
|
603
|
+
async offsetEdges(id, params, opts) {
|
|
604
|
+
const props = { id, op: OperationType.OffsetEdges, params };
|
|
605
|
+
return this.doElementGeometryOperation(props, opts);
|
|
606
|
+
}
|
|
607
|
+
async hollowFaces(id, params, opts) {
|
|
608
|
+
const props = { id, op: OperationType.HollowFaces, params };
|
|
609
|
+
return this.doElementGeometryOperation(props, opts);
|
|
610
|
+
}
|
|
611
|
+
async sweepFaces(id, params, opts) {
|
|
612
|
+
const props = { id, op: OperationType.SweepFaces, params };
|
|
613
|
+
return this.doElementGeometryOperation(props, opts);
|
|
614
|
+
}
|
|
615
|
+
async spinFaces(id, params, opts) {
|
|
616
|
+
const props = { id, op: OperationType.SpinFaces, params };
|
|
617
|
+
return this.doElementGeometryOperation(props, opts);
|
|
618
|
+
}
|
|
619
|
+
async deleteSubEntities(id, params, opts) {
|
|
620
|
+
const props = { id, op: OperationType.DeleteSubEntity, params };
|
|
621
|
+
return this.doElementGeometryOperation(props, opts);
|
|
622
|
+
}
|
|
623
|
+
async transformSubEntities(id, params, opts) {
|
|
624
|
+
const props = { id, op: OperationType.TransformSubEntity, params };
|
|
625
|
+
return this.doElementGeometryOperation(props, opts);
|
|
626
|
+
}
|
|
627
|
+
async blendEdges(id, params, opts) {
|
|
628
|
+
const props = { id, op: OperationType.Blend, params };
|
|
629
|
+
return this.doElementGeometryOperation(props, opts);
|
|
630
|
+
}
|
|
631
|
+
async chamferEdges(id, params, opts) {
|
|
632
|
+
const props = { id, op: OperationType.Chamfer, params };
|
|
633
|
+
return this.doElementGeometryOperation(props, opts);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
SolidModelingCommand.commandId = editor_common_1.editorBuiltInCmdIds.cmdSolidModeling;
|
|
637
|
+
exports.SolidModelingCommand = SolidModelingCommand;
|
|
639
638
|
//# sourceMappingURL=EditBuiltInCommand.js.map
|