@itwin/editor-frontend 3.0.0-dev.135 → 3.0.0-dev.140
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/ElementGeometryTool.d.ts +7 -1
- package/lib/cjs/ElementGeometryTool.d.ts.map +1 -1
- package/lib/cjs/ElementGeometryTool.js +43 -5
- package/lib/cjs/ElementGeometryTool.js.map +1 -1
- package/lib/cjs/SolidModelingTools.d.ts +25 -13
- package/lib/cjs/SolidModelingTools.d.ts.map +1 -1
- package/lib/cjs/SolidModelingTools.js +99 -55
- package/lib/cjs/SolidModelingTools.js.map +1 -1
- package/lib/esm/ElementGeometryTool.d.ts +7 -1
- package/lib/esm/ElementGeometryTool.d.ts.map +1 -1
- package/lib/esm/ElementGeometryTool.js +44 -6
- package/lib/esm/ElementGeometryTool.js.map +1 -1
- package/lib/esm/SolidModelingTools.d.ts +25 -13
- package/lib/esm/SolidModelingTools.d.ts.map +1 -1
- package/lib/esm/SolidModelingTools.js +99 -57
- package/lib/esm/SolidModelingTools.js.map +1 -1
- package/package.json +13 -13
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module Editing
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.SpinFacesTool = exports.SweepFacesTool = exports.ChamferEdgesTool = exports.RoundEdgesTool = exports.BlendEdgesTool = exports.ImprintSolidElementsTool = exports.ImprintSolidMethod = exports.DeleteSubEntitiesTool = exports.HollowFacesTool = exports.OffsetFacesTool = exports.FaceLocationData = exports.LoftProfilesTool = exports.SweepAlongPathTool = exports.EmbossSolidElementsTool = exports.CutSolidElementsTool = exports.ThickenSheetElementsTool = exports.SewSheetElementsTool = exports.IntersectSolidElementsTool = exports.SubtractSolidElementsTool = exports.UniteSolidElementsTool = exports.BooleanOperationTool = void 0;
|
|
10
|
+
exports.SpinFacesTool = exports.SweepFacesTool = exports.LocateFaceOrProfileTool = exports.ProfileLocationData = exports.ChamferEdgesTool = exports.RoundEdgesTool = exports.BlendEdgesTool = exports.ImprintSolidElementsTool = exports.ImprintSolidMethod = exports.DeleteSubEntitiesTool = exports.HollowFacesTool = exports.OffsetFacesTool = exports.FaceLocationData = exports.LoftProfilesTool = exports.SweepAlongPathTool = exports.EmbossSolidElementsTool = exports.CutSolidElementsTool = exports.ThickenSheetElementsTool = exports.SewSheetElementsTool = exports.IntersectSolidElementsTool = exports.SubtractSolidElementsTool = exports.UniteSolidElementsTool = exports.BooleanOperationTool = void 0;
|
|
11
11
|
const editor_common_1 = require("@itwin/editor-common");
|
|
12
12
|
const core_common_1 = require("@itwin/core-common");
|
|
13
13
|
const core_geometry_1 = require("@itwin/core-geometry");
|
|
@@ -692,6 +692,7 @@ class ImprintSolidElementsTool extends ElementGeometryTool_1.LocateSubEntityTool
|
|
|
692
692
|
this.points.push(ev.point.clone());
|
|
693
693
|
if (!ev.isControlKey)
|
|
694
694
|
break;
|
|
695
|
+
this.setupAndPromptForNextAction();
|
|
695
696
|
return core_frontend_1.EventHandled.No;
|
|
696
697
|
}
|
|
697
698
|
default:
|
|
@@ -733,7 +734,7 @@ class ImprintSolidElementsTool extends ElementGeometryTool_1.LocateSubEntityTool
|
|
|
733
734
|
exports.ImprintSolidElementsTool = ImprintSolidElementsTool;
|
|
734
735
|
ImprintSolidElementsTool.toolId = "ImprintSolids";
|
|
735
736
|
ImprintSolidElementsTool.iconSpec = "icon-move"; // TODO: Need better icon...
|
|
736
|
-
/** @alpha
|
|
737
|
+
/** @alpha Base class for tools to identify edges of solids and surfaces and apply blends. */
|
|
737
738
|
class BlendEdgesTool extends ElementGeometryTool_1.LocateSubEntityTool {
|
|
738
739
|
constructor() {
|
|
739
740
|
super(...arguments);
|
|
@@ -883,39 +884,83 @@ class ChamferEdgesTool extends BlendEdgesTool {
|
|
|
883
884
|
exports.ChamferEdgesTool = ChamferEdgesTool;
|
|
884
885
|
ChamferEdgesTool.toolId = "ChamferEdges";
|
|
885
886
|
ChamferEdgesTool.iconSpec = "icon-move"; // TODO: Need better icon...
|
|
886
|
-
/** @alpha
|
|
887
|
-
class
|
|
888
|
-
constructor() {
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
887
|
+
/** @alpha */
|
|
888
|
+
class ProfileLocationData {
|
|
889
|
+
constructor(point, orientation) {
|
|
890
|
+
this.point = point;
|
|
891
|
+
this.orientation = orientation;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
exports.ProfileLocationData = ProfileLocationData;
|
|
895
|
+
/** @alpha Base class for picking profiles (open paths and regions) or faces of solids. */
|
|
896
|
+
class LocateFaceOrProfileTool extends ElementGeometryTool_1.LocateSubEntityTool {
|
|
897
|
+
get wantGeometrySummary() { return true; }
|
|
898
|
+
wantSubEntityType(type) {
|
|
899
|
+
switch (type) {
|
|
900
|
+
case editor_common_1.SubEntityType.Face:
|
|
901
|
+
case editor_common_1.SubEntityType.Edge:
|
|
902
|
+
// Choose all faces or all edges...
|
|
903
|
+
return (0 === this._acceptedSubEntities.length || this._acceptedSubEntities[0].props.type === type);
|
|
904
|
+
default:
|
|
905
|
+
return false;
|
|
906
|
+
}
|
|
894
907
|
}
|
|
895
|
-
get wantDynamics() { return true; }
|
|
896
|
-
get wantAccuSnap() { return this.isDynamicsStarted; }
|
|
897
|
-
// TODO: Sweep open path to surface, sweep surface to solid...
|
|
898
908
|
get geometryCacheFilter() {
|
|
899
|
-
return { parts: true, curves:
|
|
909
|
+
return { parts: true, curves: true, surfaces: true, solids: true, other: false };
|
|
910
|
+
}
|
|
911
|
+
async doPickSubEntities(id, ev) {
|
|
912
|
+
const hits = await super.doPickSubEntities(id, ev);
|
|
913
|
+
if (undefined === hits)
|
|
914
|
+
return hits;
|
|
915
|
+
// Only want edges from wire bodies...
|
|
916
|
+
const accept = (editor_common_1.BRepEntityType.Wire === this.getBRepEntityTypeForSubEntity(id, hits[0].subEntity) ? editor_common_1.SubEntityType.Edge : editor_common_1.SubEntityType.Face);
|
|
917
|
+
return hits.filter((hit) => { return accept === hit.subEntity.type; });
|
|
900
918
|
}
|
|
901
919
|
async createSubEntityData(id, hit) {
|
|
902
920
|
const data = await super.createSubEntityData(id, hit);
|
|
903
|
-
|
|
904
|
-
|
|
921
|
+
// Prefer orientation from snap to take entire path curve as well as placement z into account...
|
|
922
|
+
const snap = core_frontend_1.TentativeOrAccuSnap.getCurrentSnap(false);
|
|
923
|
+
const point = (id === (snap === null || snap === void 0 ? void 0 : snap.sourceId) && snap.isHot ? snap.snapPoint : core_geometry_1.Point3d.fromJSON(hit.point));
|
|
924
|
+
const matrix = (id === (snap === null || snap === void 0 ? void 0 : snap.sourceId) ? core_frontend_1.AccuDraw.getSnapRotation(snap, undefined) : undefined);
|
|
925
|
+
const invMatrix = matrix === null || matrix === void 0 ? void 0 : matrix.inverse(); // getSnapRotation returns row matrix...
|
|
926
|
+
if (undefined !== invMatrix)
|
|
927
|
+
data.toolData = new ProfileLocationData(point, invMatrix);
|
|
928
|
+
else
|
|
929
|
+
data.toolData = new ProfileLocationData(point, undefined !== hit.normal ? core_geometry_1.Vector3d.fromJSON(hit.normal) : core_geometry_1.Vector3d.unitZ());
|
|
905
930
|
return data;
|
|
906
931
|
}
|
|
932
|
+
drawSubEntity(context, subEntity, accepted) {
|
|
933
|
+
const id = this.getCurrentElement();
|
|
934
|
+
if (undefined !== id && editor_common_1.BRepEntityType.Solid !== this.getBRepEntityTypeForSubEntity(id, subEntity.props))
|
|
935
|
+
return; // Operation will be applied to wire or sheet body, don't display sub-entity...
|
|
936
|
+
super.drawSubEntity(context, subEntity, accepted);
|
|
937
|
+
}
|
|
907
938
|
drawAcceptedSubEntities(context) {
|
|
908
939
|
var _a;
|
|
909
940
|
super.drawAcceptedSubEntities(context);
|
|
910
|
-
// Show pick point on last identified face
|
|
911
|
-
const
|
|
912
|
-
if (undefined ===
|
|
941
|
+
// Show pick point on last identified face...
|
|
942
|
+
const profileData = (_a = this.getAcceptedSubEntityData()) === null || _a === void 0 ? void 0 : _a.toolData;
|
|
943
|
+
if (undefined === profileData)
|
|
913
944
|
return;
|
|
914
945
|
const builder = context.createGraphic({ type: core_frontend_1.GraphicType.WorldOverlay });
|
|
915
946
|
builder.setSymbology(context.viewport.getContrastToBackgroundColor(), core_common_1.ColorDef.black, 10);
|
|
916
|
-
builder.addPointString([
|
|
947
|
+
builder.addPointString([profileData.point]);
|
|
917
948
|
context.addDecorationFromBuilder(builder);
|
|
918
949
|
}
|
|
950
|
+
}
|
|
951
|
+
exports.LocateFaceOrProfileTool = LocateFaceOrProfileTool;
|
|
952
|
+
/** @alpha Identify faces of solids and surfaces to translate. */
|
|
953
|
+
class SweepFacesTool extends LocateFaceOrProfileTool {
|
|
954
|
+
constructor() {
|
|
955
|
+
super(...arguments);
|
|
956
|
+
// TODO: Tool settings for sweep distance...
|
|
957
|
+
this.useDistance = false;
|
|
958
|
+
this.distance = 0.1;
|
|
959
|
+
this.addSmoothFaces = false;
|
|
960
|
+
}
|
|
961
|
+
get wantDynamics() { return true; }
|
|
962
|
+
get wantAccuSnap() { return true; }
|
|
963
|
+
get wantSubEntitySnap() { return true; }
|
|
919
964
|
async getSmoothFaces(id, face) {
|
|
920
965
|
try {
|
|
921
966
|
// NOTE: For sweep/translation, it makes sense to limit smooth to immediately adjacent...
|
|
@@ -929,10 +974,10 @@ class SweepFacesTool extends ElementGeometryTool_1.LocateSubEntityTool {
|
|
|
929
974
|
var _a;
|
|
930
975
|
if (undefined === ev.viewport || this.agenda.isEmpty || !this.haveAcceptedSubEntities)
|
|
931
976
|
return undefined;
|
|
932
|
-
const
|
|
933
|
-
if (undefined ===
|
|
977
|
+
const profileData = (_a = this.getAcceptedSubEntityData()) === null || _a === void 0 ? void 0 : _a.toolData;
|
|
978
|
+
if (undefined === profileData)
|
|
934
979
|
return undefined;
|
|
935
|
-
const path = core_geometry_1.Vector3d.createStartEnd(
|
|
980
|
+
const path = core_geometry_1.Vector3d.createStartEnd(profileData.point, ev.point);
|
|
936
981
|
if (this.useDistance && undefined === path.scaleToLength(this.distance, path))
|
|
937
982
|
return undefined;
|
|
938
983
|
if (path.magnitude() < core_geometry_1.Geometry.smallMetricDistance)
|
|
@@ -946,20 +991,24 @@ class SweepFacesTool extends ElementGeometryTool_1.LocateSubEntityTool {
|
|
|
946
991
|
requestId: `${this.toolId}:${id}`,
|
|
947
992
|
writeChanges: isAccept ? true : undefined,
|
|
948
993
|
};
|
|
949
|
-
const
|
|
994
|
+
const subEntities = this.getAcceptedSubEntities();
|
|
995
|
+
const params = { path };
|
|
996
|
+
if (editor_common_1.SubEntityType.Edge === subEntities[0].type || editor_common_1.BRepEntityType.Solid !== this.getBRepEntityTypeForSubEntity(id, subEntities[0])) {
|
|
997
|
+
return await ElementGeometryTool_1.ElementGeometryCacheTool.callCommand("sweepFaces", id, params, opts);
|
|
998
|
+
}
|
|
950
999
|
if (this.addSmoothFaces) {
|
|
951
1000
|
const allSmoothFaces = [];
|
|
952
|
-
for (const face of
|
|
1001
|
+
for (const face of subEntities) {
|
|
953
1002
|
const smoothFaces = await this.getSmoothFaces(id, face);
|
|
954
1003
|
if (undefined !== smoothFaces)
|
|
955
1004
|
allSmoothFaces.push(...smoothFaces);
|
|
956
1005
|
}
|
|
957
1006
|
for (const smooth of allSmoothFaces) {
|
|
958
|
-
if (undefined ===
|
|
959
|
-
|
|
1007
|
+
if (undefined === subEntities.find((selected) => (0, ElementGeometryTool_1.isSameSubEntity)(selected, smooth)))
|
|
1008
|
+
subEntities.unshift(smooth); // Preserve last selected entry as reference face...
|
|
960
1009
|
}
|
|
961
1010
|
}
|
|
962
|
-
|
|
1011
|
+
params.faces = subEntities;
|
|
963
1012
|
return await ElementGeometryTool_1.ElementGeometryCacheTool.callCommand("sweepFaces", id, params, opts);
|
|
964
1013
|
}
|
|
965
1014
|
catch (err) {
|
|
@@ -970,16 +1019,16 @@ class SweepFacesTool extends ElementGeometryTool_1.LocateSubEntityTool {
|
|
|
970
1019
|
var _a;
|
|
971
1020
|
if (!this.haveAcceptedSubEntities)
|
|
972
1021
|
return;
|
|
973
|
-
const
|
|
974
|
-
if (undefined ===
|
|
1022
|
+
const profileData = (_a = this.getAcceptedSubEntityData()) === null || _a === void 0 ? void 0 : _a.toolData;
|
|
1023
|
+
if (undefined === profileData)
|
|
975
1024
|
return;
|
|
976
1025
|
const hints = new core_frontend_1.AccuDrawHintBuilder();
|
|
977
1026
|
hints.setOriginFixed = true;
|
|
978
1027
|
hints.setLockY = true;
|
|
979
1028
|
hints.setLockZ = true;
|
|
980
1029
|
hints.setModeRectangular();
|
|
981
|
-
hints.setOrigin(
|
|
982
|
-
hints.setXAxis2(
|
|
1030
|
+
hints.setOrigin(profileData.point);
|
|
1031
|
+
hints.setXAxis2(profileData.orientation instanceof core_geometry_1.Matrix3d ? profileData.orientation.getColumn(2) : profileData.orientation);
|
|
983
1032
|
hints.sendHints(false);
|
|
984
1033
|
}
|
|
985
1034
|
async onRestartTool() {
|
|
@@ -992,28 +1041,16 @@ exports.SweepFacesTool = SweepFacesTool;
|
|
|
992
1041
|
SweepFacesTool.toolId = "SweepFaces";
|
|
993
1042
|
SweepFacesTool.iconSpec = "icon-move"; // TODO: Need better icon...
|
|
994
1043
|
/** @alpha Identify faces of solids and surfaces to revolve. */
|
|
995
|
-
class SpinFacesTool extends
|
|
1044
|
+
class SpinFacesTool extends LocateFaceOrProfileTool {
|
|
996
1045
|
constructor() {
|
|
997
1046
|
super(...arguments);
|
|
998
|
-
this.points = [];
|
|
999
1047
|
// TODO: Tool settings for sweep angle...
|
|
1000
1048
|
this.sweep = core_geometry_1.Angle.piOver2Radians;
|
|
1049
|
+
this.points = [];
|
|
1001
1050
|
}
|
|
1002
1051
|
get wantDynamics() { return true; }
|
|
1003
|
-
get wantAccuSnap() { return
|
|
1004
|
-
|
|
1005
|
-
get geometryCacheFilter() {
|
|
1006
|
-
return { parts: true, curves: false, surfaces: true, solids: true, other: false };
|
|
1007
|
-
}
|
|
1008
|
-
getSubEntityFilter() {
|
|
1009
|
-
return { nonPlanarFaces: true };
|
|
1010
|
-
}
|
|
1011
|
-
async createSubEntityData(id, hit) {
|
|
1012
|
-
const data = await super.createSubEntityData(id, hit);
|
|
1013
|
-
if (undefined !== hit.point && undefined !== hit.normal)
|
|
1014
|
-
data.toolData = FaceLocationData.create(hit.point, hit.normal);
|
|
1015
|
-
return data;
|
|
1016
|
-
}
|
|
1052
|
+
get wantAccuSnap() { return true; }
|
|
1053
|
+
get wantSubEntitySnap() { return true; }
|
|
1017
1054
|
async applyAgendaOperation(ev, isAccept) {
|
|
1018
1055
|
if (undefined === ev.viewport || this.agenda.isEmpty || !this.haveAcceptedSubEntities || this.points.length < (isAccept ? 2 : 1))
|
|
1019
1056
|
return undefined;
|
|
@@ -1031,8 +1068,12 @@ class SpinFacesTool extends ElementGeometryTool_1.LocateSubEntityTool {
|
|
|
1031
1068
|
requestId: `${this.toolId}:${id}`,
|
|
1032
1069
|
writeChanges: isAccept ? true : undefined,
|
|
1033
1070
|
};
|
|
1034
|
-
const
|
|
1035
|
-
const params = {
|
|
1071
|
+
const subEntities = this.getAcceptedSubEntities();
|
|
1072
|
+
const params = { origin, direction, angle };
|
|
1073
|
+
if (editor_common_1.SubEntityType.Edge === subEntities[0].type || editor_common_1.BRepEntityType.Solid !== this.getBRepEntityTypeForSubEntity(id, subEntities[0])) {
|
|
1074
|
+
return await ElementGeometryTool_1.ElementGeometryCacheTool.callCommand("spinFaces", id, params, opts);
|
|
1075
|
+
}
|
|
1076
|
+
params.faces = subEntities;
|
|
1036
1077
|
let result = await ElementGeometryTool_1.ElementGeometryCacheTool.callCommand("spinFaces", id, params, opts);
|
|
1037
1078
|
// Spun face can be used to create a pocket...retry with negative sweep...
|
|
1038
1079
|
if (undefined === result) {
|
|
@@ -1057,7 +1098,7 @@ class SpinFacesTool extends ElementGeometryTool_1.LocateSubEntityTool {
|
|
|
1057
1098
|
super.onDynamicFrame(ev, context);
|
|
1058
1099
|
}
|
|
1059
1100
|
async gatherInput(ev) {
|
|
1060
|
-
if (this.
|
|
1101
|
+
if (!this.wantAdditionalSubEntities)
|
|
1061
1102
|
this.points.push(ev.point.clone());
|
|
1062
1103
|
return super.gatherInput(ev);
|
|
1063
1104
|
}
|
|
@@ -1068,13 +1109,16 @@ class SpinFacesTool extends ElementGeometryTool_1.LocateSubEntityTool {
|
|
|
1068
1109
|
var _a;
|
|
1069
1110
|
if (!this.haveAcceptedSubEntities || 0 !== this.points.length)
|
|
1070
1111
|
return;
|
|
1071
|
-
const
|
|
1072
|
-
if (undefined ===
|
|
1112
|
+
const profileData = (_a = this.getAcceptedSubEntityData()) === null || _a === void 0 ? void 0 : _a.toolData;
|
|
1113
|
+
if (undefined === profileData)
|
|
1073
1114
|
return;
|
|
1074
1115
|
const hints = new core_frontend_1.AccuDrawHintBuilder();
|
|
1075
1116
|
hints.setModeRectangular();
|
|
1076
|
-
hints.setOrigin(
|
|
1077
|
-
|
|
1117
|
+
hints.setOrigin(profileData.point);
|
|
1118
|
+
if (profileData.orientation instanceof core_geometry_1.Matrix3d)
|
|
1119
|
+
hints.setMatrix(profileData.orientation);
|
|
1120
|
+
else
|
|
1121
|
+
hints.setNormal(profileData.orientation);
|
|
1078
1122
|
hints.sendHints(false);
|
|
1079
1123
|
}
|
|
1080
1124
|
async onRestartTool() {
|