@ccpc/snap 0.1.3
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/LICENSE +21 -0
- package/index.js +917 -0
- package/package.json +12 -0
- package/types/i_snap_result.d.ts +12 -0
- package/types/i_snap_result.d.ts.map +1 -0
- package/types/index.d.ts +12 -0
- package/types/index.d.ts.map +1 -0
- package/types/point_snap_result.d.ts +23 -0
- package/types/point_snap_result.d.ts.map +1 -0
- package/types/snap_candidates.d.ts +20 -0
- package/types/snap_candidates.d.ts.map +1 -0
- package/types/snap_context.d.ts +54 -0
- package/types/snap_context.d.ts.map +1 -0
- package/types/snap_direction.d.ts +29 -0
- package/types/snap_direction.d.ts.map +1 -0
- package/types/snap_engine.d.ts +20 -0
- package/types/snap_engine.d.ts.map +1 -0
- package/types/snap_point.d.ts +46 -0
- package/types/snap_point.d.ts.map +1 -0
- package/types/snap_result.d.ts +30 -0
- package/types/snap_result.d.ts.map +1 -0
- package/types/snap_setting.d.ts +74 -0
- package/types/snap_setting.d.ts.map +1 -0
- package/types/snap_type.d.ts +62 -0
- package/types/snap_type.d.ts.map +1 -0
- package/types/snap_util.d.ts +22 -0
- package/types/snap_util.d.ts.map +1 -0
package/index.js
ADDED
|
@@ -0,0 +1,917 @@
|
|
|
1
|
+
import { GGroup as k, GPoint2d as w, GCurve2d as y, DebugUtil as D, GNODE_TYPE as v, GPolycurve as H, GPolygon as R } from "@ccpc/core";
|
|
2
|
+
import { Plane as j, Ln2 as f, Vec2 as _, alg as L, CONST as P, Curve2 as W } from "@ccpc/math";
|
|
3
|
+
var o = /* @__PURE__ */ ((a) => (a[a.InvalidType = -1] = "InvalidType", a[a.EndPoint = 0] = "EndPoint", a[a.Pole = 1] = "Pole", a[a.XPt = 2] = "XPt", a[a.MiddlePoint = 3] = "MiddlePoint", a[a.Center = 4] = "Center", a[a.PerpendicularPoint = 5] = "PerpendicularPoint", a[a.PointOnCurve = 6] = "PointOnCurve", a[a.ReferCurve = 7] = "ReferCurve", a[a.ExtensionPoint = 8] = "ExtensionPoint", a[a.VerticalToCurve = 9] = "VerticalToCurve", a[a.ParallelToCurve = 10] = "ParallelToCurve", a[a.ParallelToX = 11] = "ParallelToX", a[a.ParallelToY = 12] = "ParallelToY", a[a.ClosedLineParallelToX = 13] = "ClosedLineParallelToX", a[a.ClosedLineParallelToY = 14] = "ClosedLineParallelToY", a[a.PointOnFace = 15] = "PointOnFace", a[a.PointOnSnapPlane = 16] = "PointOnSnapPlane", a))(o || {}), M = /* @__PURE__ */ ((a) => (a.POINT = "point", a.CURVE = "curve", a.DIR = "dir", a))(M || {});
|
|
4
|
+
class A {
|
|
5
|
+
constructor(e, n) {
|
|
6
|
+
this._snapHelpers = /* @__PURE__ */ new Map(), e && n && (this._snappableGNodes = e, this._cursorWorld = n);
|
|
7
|
+
}
|
|
8
|
+
get snappableGNodes() {
|
|
9
|
+
return this._snappableGNodes;
|
|
10
|
+
}
|
|
11
|
+
set snappableGNodes(e) {
|
|
12
|
+
this._snappableGNodes = e;
|
|
13
|
+
}
|
|
14
|
+
get cursorWorld() {
|
|
15
|
+
return this._cursorWorld;
|
|
16
|
+
}
|
|
17
|
+
set cursorWorld(e) {
|
|
18
|
+
this._cursorWorld = e;
|
|
19
|
+
}
|
|
20
|
+
get previousPoint() {
|
|
21
|
+
return this._previousPoint;
|
|
22
|
+
}
|
|
23
|
+
set previousPoint(e) {
|
|
24
|
+
this._previousPoint = e;
|
|
25
|
+
}
|
|
26
|
+
get previousLineDir() {
|
|
27
|
+
return this._previousLineDir;
|
|
28
|
+
}
|
|
29
|
+
set previousLineDir(e) {
|
|
30
|
+
this._previousLineDir = e;
|
|
31
|
+
}
|
|
32
|
+
get firstPoint() {
|
|
33
|
+
return this._firstPoint;
|
|
34
|
+
}
|
|
35
|
+
set firstPoint(e) {
|
|
36
|
+
this._firstPoint = e;
|
|
37
|
+
}
|
|
38
|
+
get snapSort() {
|
|
39
|
+
return this._snapSort;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Function used to determine the order of the elements.It is expected to return a negative
|
|
43
|
+
* value if first argument is less than second argument, zero if they're equal and a positive value otherwise.
|
|
44
|
+
*/
|
|
45
|
+
set snapSort(e) {
|
|
46
|
+
this._snapSort = e;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 获取某类吸附辅助对象
|
|
50
|
+
*/
|
|
51
|
+
getSnapHelpers(e) {
|
|
52
|
+
return this._snapHelpers.get(e);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 设置某类吸附辅助对象
|
|
56
|
+
*/
|
|
57
|
+
setSnapHelpers(e, n) {
|
|
58
|
+
this._snapHelpers.set(e, n);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 添加吸附辅助对象
|
|
62
|
+
*/
|
|
63
|
+
addSnapHelpers(e, n) {
|
|
64
|
+
if (n.length) {
|
|
65
|
+
if (this._snapHelpers.get(e)) {
|
|
66
|
+
n[0].isVector2() ? this._snapHelpers.get(e).push(...n) : this._snapHelpers.get(e).push(n);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
n[0].isVector2() ? this.setSnapHelpers(e, n) : this.setSnapHelpers(e, [n]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
class V {
|
|
74
|
+
constructor(e) {
|
|
75
|
+
this._snapType = e, this._snappedGNodes = [], this._snappedObjects = [];
|
|
76
|
+
}
|
|
77
|
+
getSnapType() {
|
|
78
|
+
return this._snapType;
|
|
79
|
+
}
|
|
80
|
+
setSnapType(e) {
|
|
81
|
+
this._snapType = e;
|
|
82
|
+
}
|
|
83
|
+
getSnappedGNodes() {
|
|
84
|
+
return this._snappedGNodes;
|
|
85
|
+
}
|
|
86
|
+
setSnappedGNodes(e) {
|
|
87
|
+
this._snappedGNodes = e;
|
|
88
|
+
}
|
|
89
|
+
addSnappedGNode(e) {
|
|
90
|
+
this._snappedGNodes.push(e);
|
|
91
|
+
}
|
|
92
|
+
addSnappedGNodes(e) {
|
|
93
|
+
this._snappedGNodes.push(...e);
|
|
94
|
+
}
|
|
95
|
+
getSnappedObjects() {
|
|
96
|
+
return this._snappedObjects;
|
|
97
|
+
}
|
|
98
|
+
setSnappedObjects(e) {
|
|
99
|
+
this._snappedObjects = e;
|
|
100
|
+
}
|
|
101
|
+
addSnappedObject(e) {
|
|
102
|
+
this._snappedObjects.push(e);
|
|
103
|
+
}
|
|
104
|
+
addSnappedObjects(e) {
|
|
105
|
+
this._snappedObjects.push(...e);
|
|
106
|
+
}
|
|
107
|
+
getSnapPrompt() {
|
|
108
|
+
throw new Error("method not implement");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
class O extends V {
|
|
112
|
+
constructor(e, n, t, s, r) {
|
|
113
|
+
super(e), this._snappedPt = n, this._disToCursor = t, r && (this._anotherPt = r), s && (this._snappedDir = s);
|
|
114
|
+
}
|
|
115
|
+
get snappedPt() {
|
|
116
|
+
return this._snappedPt;
|
|
117
|
+
}
|
|
118
|
+
set snappedPt(e) {
|
|
119
|
+
this._snappedPt = e;
|
|
120
|
+
}
|
|
121
|
+
set snappedDir(e) {
|
|
122
|
+
this._snappedDir = e;
|
|
123
|
+
}
|
|
124
|
+
get snappedDir() {
|
|
125
|
+
return this._snappedDir;
|
|
126
|
+
}
|
|
127
|
+
set anotherSnapType(e) {
|
|
128
|
+
this._anotherSnapType = e;
|
|
129
|
+
}
|
|
130
|
+
get anotherSnapType() {
|
|
131
|
+
return this._anotherSnapType;
|
|
132
|
+
}
|
|
133
|
+
set disToCursor(e) {
|
|
134
|
+
this._disToCursor = e;
|
|
135
|
+
}
|
|
136
|
+
get disToCursor() {
|
|
137
|
+
return this._disToCursor;
|
|
138
|
+
}
|
|
139
|
+
// TODO待优化
|
|
140
|
+
getSnapPrompt() {
|
|
141
|
+
const e = new k();
|
|
142
|
+
if (this.getSnapType() === o.PointOnSnapPlane)
|
|
143
|
+
return e;
|
|
144
|
+
const n = j.XOY(), t = new w(n, this._snappedPt.clone());
|
|
145
|
+
switch (t.setStyle({
|
|
146
|
+
point: {
|
|
147
|
+
size: 8,
|
|
148
|
+
color: 16777215
|
|
149
|
+
}
|
|
150
|
+
}), e.addNode(t), this.getSnapType()) {
|
|
151
|
+
case o.ParallelToX:
|
|
152
|
+
case o.ClosedLineParallelToX: {
|
|
153
|
+
if (this._anotherPt) {
|
|
154
|
+
const s = new y(n, new f(this._anotherPt, this._snappedPt));
|
|
155
|
+
s.setStyle({
|
|
156
|
+
line: {
|
|
157
|
+
width: 2,
|
|
158
|
+
color: 16711680
|
|
159
|
+
}
|
|
160
|
+
}), e.addNode(s);
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
case o.ParallelToY:
|
|
165
|
+
case o.ClosedLineParallelToY: {
|
|
166
|
+
if (this._anotherPt) {
|
|
167
|
+
const s = new y(n, new f(this._anotherPt, this._snappedPt));
|
|
168
|
+
s.setStyle({
|
|
169
|
+
line: {
|
|
170
|
+
width: 2,
|
|
171
|
+
color: 65280
|
|
172
|
+
}
|
|
173
|
+
}), e.addNode(s);
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return e;
|
|
179
|
+
}
|
|
180
|
+
getSnapPromptString() {
|
|
181
|
+
return ((n) => {
|
|
182
|
+
let t = "unknown";
|
|
183
|
+
switch (n) {
|
|
184
|
+
case o.EndPoint:
|
|
185
|
+
t = "端点";
|
|
186
|
+
break;
|
|
187
|
+
case o.Pole:
|
|
188
|
+
t = "极点";
|
|
189
|
+
break;
|
|
190
|
+
case o.XPt:
|
|
191
|
+
t = "交点";
|
|
192
|
+
break;
|
|
193
|
+
case o.MiddlePoint:
|
|
194
|
+
t = "中点";
|
|
195
|
+
break;
|
|
196
|
+
case o.Center:
|
|
197
|
+
t = "中心";
|
|
198
|
+
break;
|
|
199
|
+
case o.PerpendicularPoint:
|
|
200
|
+
t = "垂足";
|
|
201
|
+
break;
|
|
202
|
+
case o.PointOnCurve:
|
|
203
|
+
t = "边线";
|
|
204
|
+
break;
|
|
205
|
+
case o.ReferCurve:
|
|
206
|
+
t = "参考线";
|
|
207
|
+
break;
|
|
208
|
+
case o.ExtensionPoint:
|
|
209
|
+
t = "延长线";
|
|
210
|
+
break;
|
|
211
|
+
case o.VerticalToCurve:
|
|
212
|
+
t = "垂直于曲线";
|
|
213
|
+
break;
|
|
214
|
+
case o.ParallelToCurve:
|
|
215
|
+
t = "平行于曲线";
|
|
216
|
+
break;
|
|
217
|
+
case o.ParallelToX:
|
|
218
|
+
t = "平行X轴";
|
|
219
|
+
break;
|
|
220
|
+
case o.ParallelToY:
|
|
221
|
+
t = "平行Y轴";
|
|
222
|
+
break;
|
|
223
|
+
case o.ClosedLineParallelToX:
|
|
224
|
+
t = "平行X轴";
|
|
225
|
+
break;
|
|
226
|
+
case o.ClosedLineParallelToY:
|
|
227
|
+
t = "平行Y轴";
|
|
228
|
+
break;
|
|
229
|
+
case o.PointOnFace:
|
|
230
|
+
t = "在面上";
|
|
231
|
+
break;
|
|
232
|
+
case o.PointOnSnapPlane:
|
|
233
|
+
t = "";
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
return t;
|
|
237
|
+
})(this.getSnapType());
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
class I {
|
|
241
|
+
constructor() {
|
|
242
|
+
this._currentIndex = -1, this._snapResults = [];
|
|
243
|
+
}
|
|
244
|
+
get snapResults() {
|
|
245
|
+
return this._snapResults;
|
|
246
|
+
}
|
|
247
|
+
addSnapResult(e) {
|
|
248
|
+
this._snapResults.push(e);
|
|
249
|
+
}
|
|
250
|
+
addSnapResults(e) {
|
|
251
|
+
this._snapResults.push(...e);
|
|
252
|
+
}
|
|
253
|
+
sort(e) {
|
|
254
|
+
if (this._snapResults.length < 2)
|
|
255
|
+
return;
|
|
256
|
+
if (e) {
|
|
257
|
+
this._snapResults.sort(e);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const n = (s) => s.anotherSnapType !== void 0 ? Math.min(s.getSnapType(), s.anotherSnapType) : s.getSnapType(), t = this._snapResults.filter((s) => s instanceof O);
|
|
261
|
+
t.sort((s, r) => n(s) - n(r) || s.disToCursor - r.disToCursor), this._snapResults = [...t];
|
|
262
|
+
}
|
|
263
|
+
getCurrentSnap() {
|
|
264
|
+
if (!(this._snapResults.length < 1))
|
|
265
|
+
return this._snapResults[this.currentIndex];
|
|
266
|
+
}
|
|
267
|
+
get currentIndex() {
|
|
268
|
+
return this._currentIndex;
|
|
269
|
+
}
|
|
270
|
+
set currentIndex(e) {
|
|
271
|
+
D.assert(e < this._snapResults.length && e > -1, "index不合法", "wg", "2026-03-25"), this._currentIndex = e;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
var X = /* @__PURE__ */ ((a) => (a[a.X = 0] = "X", a[a.Y = 1] = "Y", a))(X || {});
|
|
275
|
+
class l {
|
|
276
|
+
static instance() {
|
|
277
|
+
return l._instance || (l._instance = new l()), l._instance;
|
|
278
|
+
}
|
|
279
|
+
constructor() {
|
|
280
|
+
this._snapTolerance = 15, this._isSnapOff = !1, this._pixelsPerUnit = 1, this._reset(!0);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* 修改snapSetting前备份原来状态
|
|
284
|
+
*/
|
|
285
|
+
backup() {
|
|
286
|
+
this._backup = {
|
|
287
|
+
snapTolerance: this._snapTolerance,
|
|
288
|
+
isSnapOff: this._isSnapOff,
|
|
289
|
+
canSnapEndPt: this._canSnapEndPt,
|
|
290
|
+
canSnapMidPt: this._canSnapMidPt,
|
|
291
|
+
canSnapCenter: this._canSnapCenter,
|
|
292
|
+
canSnapPerpendicularPoint: this._canSnapPerpendicularPoint,
|
|
293
|
+
canSnapExtensionPoint: this._canSnapExtensionPoint,
|
|
294
|
+
canSnapVertical: this._canSnapVertical,
|
|
295
|
+
canSnapParallelToX: this._canSnapParallelToX,
|
|
296
|
+
canSnapParallelToY: this._canSnapParallelToY,
|
|
297
|
+
canSnapClosedLineParallelToX: this._canSnapClosedLineParallelToX,
|
|
298
|
+
canSnapClosedLineParallelToY: this._canSnapClosedLineParallelToY,
|
|
299
|
+
canSnapPointOnCurve: this._canSnapPointOnCurve,
|
|
300
|
+
canSnapPointOnFace: this._canSnapPointOnFace,
|
|
301
|
+
canSnapHelperObject: this._canSnapHelperObject,
|
|
302
|
+
canSnapHelperDir: this._canSnapHelperDir
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* 恢复上次备份的snapSetting状态
|
|
307
|
+
*/
|
|
308
|
+
restore() {
|
|
309
|
+
this._backup && (this._snapTolerance = this._backup.snapTolerance, this._isSnapOff = this._backup.isSnapOff, this._canSnapEndPt = this._backup.canSnapEndPt, this._canSnapMidPt = this._backup.canSnapMidPt, this._canSnapCenter = this._backup.canSnapCenter, this._canSnapPerpendicularPoint = this._backup.canSnapPerpendicularPoint, this._canSnapExtensionPoint = this._backup.canSnapExtensionPoint, this._canSnapVertical = this._backup.canSnapVertical, this._canSnapParallelToX = this._backup.canSnapParallelToX, this._canSnapParallelToY = this._backup.canSnapParallelToY, this._canSnapClosedLineParallelToX = this._backup.canSnapClosedLineParallelToX, this._canSnapClosedLineParallelToY = this._backup.canSnapClosedLineParallelToY, this._canSnapPointOnCurve = this._backup.canSnapPointOnCurve, this._canSnapPointOnFace = this._backup.canSnapPointOnFace, this._canSnapHelperObject = this._backup.canSnapHelperObject, this._canSnapHelperDir = this._backup.canSnapHelperDir, delete this._backup);
|
|
310
|
+
}
|
|
311
|
+
getSnapTol() {
|
|
312
|
+
return this._snapTolerance;
|
|
313
|
+
}
|
|
314
|
+
// 设置捕捉精度,屏幕像素值
|
|
315
|
+
setSnapTol(e) {
|
|
316
|
+
this._snapTolerance = e;
|
|
317
|
+
}
|
|
318
|
+
setPixelsPerUnit(e) {
|
|
319
|
+
this._pixelsPerUnit = e;
|
|
320
|
+
}
|
|
321
|
+
getPixelsPerUnit() {
|
|
322
|
+
return this._pixelsPerUnit;
|
|
323
|
+
}
|
|
324
|
+
getSnapTolInWorld() {
|
|
325
|
+
return this._pixelsPerUnit <= 0 ? this._snapTolerance : this._snapTolerance / this._pixelsPerUnit;
|
|
326
|
+
}
|
|
327
|
+
get isSnapOff() {
|
|
328
|
+
return this._isSnapOff;
|
|
329
|
+
}
|
|
330
|
+
set isSnapOff(e) {
|
|
331
|
+
this._isSnapOff = e;
|
|
332
|
+
}
|
|
333
|
+
allowAll() {
|
|
334
|
+
this._reset(!0);
|
|
335
|
+
}
|
|
336
|
+
disableAll() {
|
|
337
|
+
this._reset(!1);
|
|
338
|
+
}
|
|
339
|
+
get canSnapEndPt() {
|
|
340
|
+
return this._canSnapEndPt;
|
|
341
|
+
}
|
|
342
|
+
set canSnapEndPt(e) {
|
|
343
|
+
this._canSnapEndPt = e;
|
|
344
|
+
}
|
|
345
|
+
get canSnapMidPt() {
|
|
346
|
+
return this._canSnapMidPt;
|
|
347
|
+
}
|
|
348
|
+
set canSnapMidPt(e) {
|
|
349
|
+
this._canSnapMidPt = e;
|
|
350
|
+
}
|
|
351
|
+
get canSnapCenter() {
|
|
352
|
+
return this._canSnapCenter;
|
|
353
|
+
}
|
|
354
|
+
set canSnapCenter(e) {
|
|
355
|
+
this._canSnapCenter = e;
|
|
356
|
+
}
|
|
357
|
+
get canSnapPerpendicularPoint() {
|
|
358
|
+
return this._canSnapPerpendicularPoint;
|
|
359
|
+
}
|
|
360
|
+
set canSnapPerpendicularPoint(e) {
|
|
361
|
+
this._canSnapPerpendicularPoint = e;
|
|
362
|
+
}
|
|
363
|
+
get canSnapExtensionPoint() {
|
|
364
|
+
return this._canSnapExtensionPoint;
|
|
365
|
+
}
|
|
366
|
+
set canSnapExtensionPoint(e) {
|
|
367
|
+
this._canSnapExtensionPoint = e;
|
|
368
|
+
}
|
|
369
|
+
get canSnapVertical() {
|
|
370
|
+
return this._canSnapVertical;
|
|
371
|
+
}
|
|
372
|
+
set canSnapVertical(e) {
|
|
373
|
+
this._canSnapVertical = e;
|
|
374
|
+
}
|
|
375
|
+
get canSnapHelperObject() {
|
|
376
|
+
return this._canSnapHelperObject;
|
|
377
|
+
}
|
|
378
|
+
set canSnapHelperObject(e) {
|
|
379
|
+
this._canSnapHelperObject = e;
|
|
380
|
+
}
|
|
381
|
+
get canSnapHelperDir() {
|
|
382
|
+
return this._canSnapHelperDir;
|
|
383
|
+
}
|
|
384
|
+
set canSnapHelperDir(e) {
|
|
385
|
+
this._canSnapHelperDir = e;
|
|
386
|
+
}
|
|
387
|
+
getCanSnapParallelToAxis(e) {
|
|
388
|
+
switch (e) {
|
|
389
|
+
case 0:
|
|
390
|
+
return this._canSnapParallelToX;
|
|
391
|
+
case 1:
|
|
392
|
+
return this._canSnapParallelToY;
|
|
393
|
+
default:
|
|
394
|
+
D.warn(!1, "未定义类型", "wg", "2026-03-25");
|
|
395
|
+
}
|
|
396
|
+
return !1;
|
|
397
|
+
}
|
|
398
|
+
setCanSnapParallelToAxis(e, n) {
|
|
399
|
+
switch (e) {
|
|
400
|
+
case 0:
|
|
401
|
+
this._canSnapParallelToX = n;
|
|
402
|
+
return;
|
|
403
|
+
case 1:
|
|
404
|
+
this._canSnapParallelToY = n;
|
|
405
|
+
return;
|
|
406
|
+
default:
|
|
407
|
+
D.warn(!1, "未定义类型", "wg", "2026-03-25");
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
getCanSnapClosedLineParallelToAxis(e) {
|
|
411
|
+
switch (e) {
|
|
412
|
+
case 0:
|
|
413
|
+
return this._canSnapClosedLineParallelToX;
|
|
414
|
+
case 1:
|
|
415
|
+
return this._canSnapClosedLineParallelToY;
|
|
416
|
+
default:
|
|
417
|
+
D.warn(!1, "未定义类型", "wg", "2026-03-25");
|
|
418
|
+
}
|
|
419
|
+
return !1;
|
|
420
|
+
}
|
|
421
|
+
setCanSnapClosedLineParallelToAxis(e, n) {
|
|
422
|
+
switch (e) {
|
|
423
|
+
case 0:
|
|
424
|
+
this._canSnapClosedLineParallelToX = n;
|
|
425
|
+
return;
|
|
426
|
+
case 1:
|
|
427
|
+
this._canSnapClosedLineParallelToY = n;
|
|
428
|
+
return;
|
|
429
|
+
default:
|
|
430
|
+
D.warn(!1, "未定义类型", "wg", "2026-03-25");
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
get canSnapPointOnCurve() {
|
|
434
|
+
return this._canSnapPointOnCurve;
|
|
435
|
+
}
|
|
436
|
+
set canSnapPointOnCurve(e) {
|
|
437
|
+
this._canSnapPointOnCurve = e;
|
|
438
|
+
}
|
|
439
|
+
get canSnapPointOnFace() {
|
|
440
|
+
return this._canSnapPointOnFace;
|
|
441
|
+
}
|
|
442
|
+
set canSnapPointOnFace(e) {
|
|
443
|
+
this._canSnapPointOnFace = e;
|
|
444
|
+
}
|
|
445
|
+
_reset(e) {
|
|
446
|
+
this._canSnapEndPt = e, this._canSnapMidPt = e, this._canSnapCenter = e, this._canSnapPerpendicularPoint = e, this._canSnapExtensionPoint = e, this._canSnapVertical = e, this._canSnapParallelToX = e, this._canSnapParallelToY = e, this._canSnapClosedLineParallelToX = e, this._canSnapClosedLineParallelToY = e, this._canSnapPointOnCurve = e, this._canSnapPointOnFace = e, this._canSnapHelperObject = e, this._canSnapHelperDir = e;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
class d {
|
|
450
|
+
/**
|
|
451
|
+
* 点吸附
|
|
452
|
+
*/
|
|
453
|
+
static intersectPoint(e, n, t) {
|
|
454
|
+
const s = e.distanceTo(n), r = l.instance().getSnapTolInWorld();
|
|
455
|
+
if (!(s > r))
|
|
456
|
+
return new O(t, n.clone(), s);
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* 曲线吸附
|
|
460
|
+
*/
|
|
461
|
+
static intersectCurve(e, n, t, s) {
|
|
462
|
+
const r = new _(), c = L.D.ptToCurve2d(e, n, r), p = l.instance().getSnapTolInWorld();
|
|
463
|
+
if (c > p)
|
|
464
|
+
return;
|
|
465
|
+
const i = new O(t, r.clone(), c, void 0, s);
|
|
466
|
+
return i.addSnappedObject(n), i;
|
|
467
|
+
}
|
|
468
|
+
static curveIntersectGNode(e, n) {
|
|
469
|
+
let t = [];
|
|
470
|
+
n.getType() === v.GCurve2d ? t = [n.geo] : (n.getType() === v.GPolycurve || n.getType() === v.GPolygon) && (t = n.geo.getAllCurves());
|
|
471
|
+
const s = [];
|
|
472
|
+
return t.forEach((r) => {
|
|
473
|
+
L.X.curve2ds(e, r).forEach((p) => {
|
|
474
|
+
s.push({
|
|
475
|
+
pt: p.point,
|
|
476
|
+
c: r
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
}), s;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
class T {
|
|
483
|
+
/**
|
|
484
|
+
* 捕捉特征点
|
|
485
|
+
*/
|
|
486
|
+
static snapGPoint(e, n) {
|
|
487
|
+
const t = [], s = n.geo.userData?.snapType ?? o.XPt, r = d.intersectPoint(e.cursorWorld, n.geo, s);
|
|
488
|
+
return r && (r.addSnappedGNode(n), t.push(r)), t;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* 捕捉两条线的交点
|
|
492
|
+
*/
|
|
493
|
+
static snapCurvesXPoint(e, n) {
|
|
494
|
+
const t = [], s = n.map((c) => ({
|
|
495
|
+
node: c,
|
|
496
|
+
curves: this._getNodeCurves(c)
|
|
497
|
+
})).filter((c) => c.curves.length > 0);
|
|
498
|
+
if (s.length < 2)
|
|
499
|
+
return t;
|
|
500
|
+
const r = s[0];
|
|
501
|
+
for (let c = 1; c < s.length; c++) {
|
|
502
|
+
const p = s[c];
|
|
503
|
+
for (const i of r.curves)
|
|
504
|
+
for (const u of p.curves) {
|
|
505
|
+
const h = L.X.curve2ds(i, u);
|
|
506
|
+
for (const b of h) {
|
|
507
|
+
const g = d.intersectPoint(
|
|
508
|
+
e.cursorWorld,
|
|
509
|
+
b.point,
|
|
510
|
+
o.XPt
|
|
511
|
+
);
|
|
512
|
+
g && (g.addSnappedGNode(r.node), g.addSnappedGNode(p.node), t.push(g));
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return t.sort((c, p) => c.disToCursor - p.disToCursor);
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* 捕捉“端点”、“中点”
|
|
520
|
+
*/
|
|
521
|
+
static snapCurveFeaturePoint(e, n) {
|
|
522
|
+
let t = [];
|
|
523
|
+
const s = this.snapEndOrMidPoint(e, n);
|
|
524
|
+
if (s.length > 0)
|
|
525
|
+
t = s;
|
|
526
|
+
else {
|
|
527
|
+
const r = this.snapPointOnCurve(e, n);
|
|
528
|
+
r.length > 0 && (t = r);
|
|
529
|
+
}
|
|
530
|
+
return t;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* 捕捉参考线
|
|
534
|
+
*/
|
|
535
|
+
static snapReferenceCurve(e) {
|
|
536
|
+
const n = [], t = e.getSnapHelpers(M.CURVE);
|
|
537
|
+
if (!t?.length || !l.instance().canSnapHelperObject)
|
|
538
|
+
return n;
|
|
539
|
+
const s = [];
|
|
540
|
+
for (const r of t)
|
|
541
|
+
Array.isArray(r) && r.length && !r[0].isVector2() && s.push(r);
|
|
542
|
+
for (const r of s)
|
|
543
|
+
for (const c of r) {
|
|
544
|
+
const p = c.userData?.snapType ?? o.ReferCurve, i = d.intersectCurve(e.cursorWorld, c, p);
|
|
545
|
+
if (i)
|
|
546
|
+
return n.push(i), n;
|
|
547
|
+
}
|
|
548
|
+
return n;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* 捕捉参考点
|
|
552
|
+
*/
|
|
553
|
+
static snapReferencePoint(e) {
|
|
554
|
+
const n = [], t = e.getSnapHelpers(M.POINT);
|
|
555
|
+
if (!t?.length || !l.instance().canSnapHelperObject)
|
|
556
|
+
return n;
|
|
557
|
+
const s = t.filter((r) => !Array.isArray(r));
|
|
558
|
+
for (const r of s) {
|
|
559
|
+
const c = r.userData?.snapType ?? o.XPt, p = d.intersectPoint(e.cursorWorld, r, c);
|
|
560
|
+
if (p)
|
|
561
|
+
return n.push(p), n;
|
|
562
|
+
}
|
|
563
|
+
return n;
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* 捕捉“端点”、“中点”
|
|
567
|
+
*/
|
|
568
|
+
static snapEndOrMidPoint(e, n) {
|
|
569
|
+
const t = [], s = e.cursorWorld;
|
|
570
|
+
if (n instanceof y) {
|
|
571
|
+
const r = n.geo;
|
|
572
|
+
if (l.instance().canSnapEndPt) {
|
|
573
|
+
const c = r.getStartPt();
|
|
574
|
+
let p = d.intersectPoint(s, c, o.EndPoint);
|
|
575
|
+
p && (p.addSnappedGNode(n), t.push(p));
|
|
576
|
+
const i = r.getEndPt();
|
|
577
|
+
p = d.intersectPoint(s, i, o.EndPoint), p && (p.addSnappedGNode(n), t.push(p));
|
|
578
|
+
}
|
|
579
|
+
if (l.instance().canSnapMidPt) {
|
|
580
|
+
const c = r.getMidPt(), p = d.intersectPoint(s, c, o.MiddlePoint);
|
|
581
|
+
p && (p.addSnappedGNode(n), t.push(p));
|
|
582
|
+
}
|
|
583
|
+
return t.sort((c, p) => c.disToCursor - p.disToCursor);
|
|
584
|
+
}
|
|
585
|
+
if (n instanceof H) {
|
|
586
|
+
const r = n.geo.getAllCurves();
|
|
587
|
+
if (!r.length)
|
|
588
|
+
return t;
|
|
589
|
+
if (l.instance().canSnapEndPt) {
|
|
590
|
+
const c = r[0].getStartPt(), p = d.intersectPoint(s, c, o.EndPoint);
|
|
591
|
+
p && (p.addSnappedGNode(n), t.push(p));
|
|
592
|
+
const i = r[r.length - 1].getEndPt(), u = d.intersectPoint(s, i, o.EndPoint);
|
|
593
|
+
u && (u.addSnappedGNode(n), t.push(u));
|
|
594
|
+
}
|
|
595
|
+
if (l.instance().canSnapMidPt) {
|
|
596
|
+
const p = r[Math.floor(r.length / 2)].getMidPt(), i = d.intersectPoint(s, p, o.MiddlePoint);
|
|
597
|
+
i && (i.addSnappedGNode(n), t.push(i));
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
return t.sort((r, c) => r.disToCursor - c.disToCursor);
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* 线上的点
|
|
604
|
+
*/
|
|
605
|
+
static snapPointOnCurve(e, n) {
|
|
606
|
+
const t = [];
|
|
607
|
+
if (!l.instance().canSnapPointOnCurve)
|
|
608
|
+
return t;
|
|
609
|
+
if (n instanceof y) {
|
|
610
|
+
const s = this._snapPtOnCurve(n.geo, e, n);
|
|
611
|
+
return s && t.push(s), t;
|
|
612
|
+
}
|
|
613
|
+
if (n instanceof H)
|
|
614
|
+
for (const s of n.geo.getAllCurves()) {
|
|
615
|
+
const r = this._snapPtOnCurve(s, e, n);
|
|
616
|
+
if (r)
|
|
617
|
+
return t.push(r), t;
|
|
618
|
+
}
|
|
619
|
+
return t;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* 面上的点
|
|
623
|
+
*/
|
|
624
|
+
static snapPointOnFace(e, n) {
|
|
625
|
+
const t = [];
|
|
626
|
+
if (!l.instance().canSnapPointOnFace || L.PJ.ptToPolygon(
|
|
627
|
+
e.cursorWorld,
|
|
628
|
+
n.geo,
|
|
629
|
+
l.instance().getSnapTolInWorld()
|
|
630
|
+
) === L.PtLoopPJType.OUT)
|
|
631
|
+
return t;
|
|
632
|
+
const r = new O(o.PointOnFace, e.cursorWorld.clone(), 0);
|
|
633
|
+
return r.addSnappedGNode(n), t.push(r), t;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* 捕捉和曲线的交点
|
|
637
|
+
*/
|
|
638
|
+
static _snapPtOnCurve(e, n, t) {
|
|
639
|
+
const s = d.intersectCurve(n.cursorWorld, e, o.PointOnCurve);
|
|
640
|
+
if (s)
|
|
641
|
+
return s.addSnappedGNode(t), s;
|
|
642
|
+
}
|
|
643
|
+
static _getNodeCurves(e) {
|
|
644
|
+
return e instanceof y ? [e.geo] : e instanceof H || e instanceof R ? e.geo.getAllCurves() : [];
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
class m {
|
|
648
|
+
static snapDirection(e) {
|
|
649
|
+
const n = [], t = this.snapExtensionPoint(e);
|
|
650
|
+
t.length > 0 && n.push(...t);
|
|
651
|
+
const s = this.snapHelperDirections(e);
|
|
652
|
+
s.length > 0 && n.push(...s);
|
|
653
|
+
const r = this.snapVerticalDir(e);
|
|
654
|
+
r.length > 0 && n.push(...r);
|
|
655
|
+
const c = this.snapPointParallelToAxis(e);
|
|
656
|
+
c.length > 0 && n.push(...c);
|
|
657
|
+
const p = this.snapLastLineDir(e);
|
|
658
|
+
return p.length > 0 && n.push(...p), n;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* 捕捉过上一个点的水平/竖直方向
|
|
662
|
+
*/
|
|
663
|
+
static snapPointParallelToAxis(e) {
|
|
664
|
+
const n = [];
|
|
665
|
+
if (!e.previousPoint)
|
|
666
|
+
return n;
|
|
667
|
+
if (l.instance().getCanSnapParallelToAxis(X.X)) {
|
|
668
|
+
const t = new f(
|
|
669
|
+
e.previousPoint,
|
|
670
|
+
_.X(),
|
|
671
|
+
[-P.MODEL_MAX_LENGTH, P.MODEL_MAX_LENGTH]
|
|
672
|
+
), s = d.intersectCurve(
|
|
673
|
+
e.cursorWorld,
|
|
674
|
+
t,
|
|
675
|
+
o.ParallelToX,
|
|
676
|
+
e.previousPoint
|
|
677
|
+
);
|
|
678
|
+
if (s)
|
|
679
|
+
return s.snappedDir = _.X(), [s];
|
|
680
|
+
}
|
|
681
|
+
if (l.instance().getCanSnapParallelToAxis(X.Y)) {
|
|
682
|
+
const t = new f(
|
|
683
|
+
e.previousPoint,
|
|
684
|
+
_.Y(),
|
|
685
|
+
[-P.MODEL_MAX_LENGTH, P.MODEL_MAX_LENGTH]
|
|
686
|
+
), s = d.intersectCurve(
|
|
687
|
+
e.cursorWorld,
|
|
688
|
+
t,
|
|
689
|
+
o.ParallelToY,
|
|
690
|
+
e.previousPoint
|
|
691
|
+
);
|
|
692
|
+
if (s)
|
|
693
|
+
return s.snappedDir = _.Y(), [s];
|
|
694
|
+
}
|
|
695
|
+
return n;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* 捕捉延长线上的点
|
|
699
|
+
*/
|
|
700
|
+
static snapExtensionPoint(e) {
|
|
701
|
+
const n = [];
|
|
702
|
+
if (!l.instance().canSnapExtensionPoint || !e.previousPoint || !e.previousLineDir)
|
|
703
|
+
return n;
|
|
704
|
+
const t = new f(
|
|
705
|
+
e.previousPoint,
|
|
706
|
+
e.previousLineDir,
|
|
707
|
+
[-P.MODEL_MAX_LENGTH, P.MODEL_MAX_LENGTH]
|
|
708
|
+
), s = d.intersectCurve(
|
|
709
|
+
e.cursorWorld,
|
|
710
|
+
t,
|
|
711
|
+
o.ExtensionPoint
|
|
712
|
+
);
|
|
713
|
+
return s ? (s.snappedDir = t.getDirection(), [s]) : n;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* 捕捉参考方向
|
|
717
|
+
*/
|
|
718
|
+
static snapHelperDirections(e) {
|
|
719
|
+
const n = [];
|
|
720
|
+
if (!l.instance().canSnapHelperDir || !e.previousPoint || !e.getSnapHelpers(M.DIR)?.length)
|
|
721
|
+
return n;
|
|
722
|
+
for (const t of e.getSnapHelpers(M.DIR)) {
|
|
723
|
+
const s = new f(
|
|
724
|
+
e.previousPoint,
|
|
725
|
+
t,
|
|
726
|
+
[-P.MODEL_MAX_LENGTH, P.MODEL_MAX_LENGTH]
|
|
727
|
+
), r = d.intersectCurve(
|
|
728
|
+
e.cursorWorld,
|
|
729
|
+
s,
|
|
730
|
+
t.userData?.snapType || o.ParallelToCurve
|
|
731
|
+
);
|
|
732
|
+
if (r)
|
|
733
|
+
return r.snappedDir = s.getDirection(), r.addSnappedObject(t), [r];
|
|
734
|
+
}
|
|
735
|
+
return n;
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* 捕捉和上一个方向垂直的方向
|
|
739
|
+
*/
|
|
740
|
+
static snapVerticalDir(e) {
|
|
741
|
+
if (!l.instance().canSnapVertical)
|
|
742
|
+
return [];
|
|
743
|
+
if (!e.previousPoint || !e.previousLineDir)
|
|
744
|
+
return [];
|
|
745
|
+
const n = new _(-e.previousLineDir.y, e.previousLineDir.x).normalize(), t = new f(
|
|
746
|
+
e.previousPoint,
|
|
747
|
+
n,
|
|
748
|
+
[-P.MODEL_MAX_LENGTH, P.MODEL_MAX_LENGTH]
|
|
749
|
+
), s = d.intersectCurve(
|
|
750
|
+
e.cursorWorld,
|
|
751
|
+
t,
|
|
752
|
+
o.VerticalToCurve
|
|
753
|
+
);
|
|
754
|
+
return s ? (s.snappedDir = n, [s]) : [];
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* 连续画线时,捕捉第一点与当前鼠标点连线,与坐标轴平行情况
|
|
758
|
+
*/
|
|
759
|
+
static snapLastLineDir(e) {
|
|
760
|
+
const n = [];
|
|
761
|
+
if (!e.firstPoint || !e.previousPoint || e.firstPoint.equals(e.previousPoint))
|
|
762
|
+
return n;
|
|
763
|
+
if (l.instance().getCanSnapClosedLineParallelToAxis(X.X)) {
|
|
764
|
+
const t = new f(
|
|
765
|
+
e.firstPoint,
|
|
766
|
+
_.X(),
|
|
767
|
+
[-P.MODEL_MAX_LENGTH, P.MODEL_MAX_LENGTH]
|
|
768
|
+
), s = d.intersectCurve(
|
|
769
|
+
e.cursorWorld,
|
|
770
|
+
t,
|
|
771
|
+
o.ClosedLineParallelToX,
|
|
772
|
+
e.firstPoint
|
|
773
|
+
);
|
|
774
|
+
if (s)
|
|
775
|
+
return s.snappedDir = _.X(), [s];
|
|
776
|
+
}
|
|
777
|
+
if (l.instance().getCanSnapClosedLineParallelToAxis(X.Y)) {
|
|
778
|
+
const t = new f(
|
|
779
|
+
e.firstPoint,
|
|
780
|
+
_.Y(),
|
|
781
|
+
[-P.MODEL_MAX_LENGTH, P.MODEL_MAX_LENGTH]
|
|
782
|
+
), s = d.intersectCurve(
|
|
783
|
+
e.cursorWorld,
|
|
784
|
+
t,
|
|
785
|
+
o.ClosedLineParallelToY,
|
|
786
|
+
e.firstPoint
|
|
787
|
+
);
|
|
788
|
+
if (s)
|
|
789
|
+
return s.snappedDir = _.Y(), [s];
|
|
790
|
+
}
|
|
791
|
+
return n;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
class z {
|
|
795
|
+
/**
|
|
796
|
+
* 捕捉唯一入口方法
|
|
797
|
+
* @param snapContext 捕捉输入信息
|
|
798
|
+
* @returns 捕捉结果候选集合
|
|
799
|
+
*/
|
|
800
|
+
static snap(e) {
|
|
801
|
+
D.assert(e, "snapContext不应该为空", "wg", "2026-03-25");
|
|
802
|
+
const n = new I();
|
|
803
|
+
if (l.instance().isSnapOff)
|
|
804
|
+
return n;
|
|
805
|
+
const t = e.snappableGNodes;
|
|
806
|
+
if (t[0] && t[0].canSnap) {
|
|
807
|
+
const h = t[0];
|
|
808
|
+
n.addSnapResults(this._snapGNode(h.getType(), e, h));
|
|
809
|
+
}
|
|
810
|
+
const s = T.snapReferencePoint(e);
|
|
811
|
+
n.addSnapResults(s);
|
|
812
|
+
const r = T.snapReferenceCurve(e);
|
|
813
|
+
n.addSnapResults(r);
|
|
814
|
+
const c = m.snapDirection(e);
|
|
815
|
+
n.addSnapResults(c);
|
|
816
|
+
const p = T.snapCurvesXPoint(e, t);
|
|
817
|
+
n.addSnapResults(p);
|
|
818
|
+
const i = this._combineSnaps(e, c.concat(r), n.snapResults);
|
|
819
|
+
if (n.addSnapResults(i), n.sort(e.snapSort), n.snapResults.length)
|
|
820
|
+
return n;
|
|
821
|
+
const u = new O(o.PointOnSnapPlane, e.cursorWorld.clone(), 0);
|
|
822
|
+
return n.addSnapResult(u), n.sort(e.snapSort), n;
|
|
823
|
+
}
|
|
824
|
+
static _snapGNode(e, n, t) {
|
|
825
|
+
let s = [];
|
|
826
|
+
switch (e) {
|
|
827
|
+
case v.GPoint2d:
|
|
828
|
+
s = T.snapGPoint(n, t);
|
|
829
|
+
break;
|
|
830
|
+
case v.GCurve2d:
|
|
831
|
+
s = T.snapCurveFeaturePoint(n, t);
|
|
832
|
+
break;
|
|
833
|
+
case v.GPolycurve:
|
|
834
|
+
s = T.snapCurveFeaturePoint(n, t);
|
|
835
|
+
break;
|
|
836
|
+
case v.GPolygon:
|
|
837
|
+
s = T.snapPointOnFace(n, t);
|
|
838
|
+
break;
|
|
839
|
+
}
|
|
840
|
+
return s;
|
|
841
|
+
}
|
|
842
|
+
static _combineIntersects(e, n, t) {
|
|
843
|
+
const s = [];
|
|
844
|
+
if (!n.length || !t.length)
|
|
845
|
+
return s;
|
|
846
|
+
const r = (i) => {
|
|
847
|
+
if (i instanceof O && i.snappedPt && i.snappedDir)
|
|
848
|
+
return new f(i.snappedPt, i.snappedDir, [-P.MODEL_MAX_LENGTH, P.MODEL_MAX_LENGTH]);
|
|
849
|
+
const u = i.getSnappedObjects().filter((h) => h instanceof W);
|
|
850
|
+
if (u.length === 1)
|
|
851
|
+
return u[0];
|
|
852
|
+
}, c = (i, u) => i instanceof f && u instanceof f && i.getDirection().isParallel(u.getDirection()), p = (i, u) => i.snappedDir !== void 0 && u instanceof f && i.snappedDir.isPerpendicular(u.getDirection());
|
|
853
|
+
for (const i of n) {
|
|
854
|
+
const u = r(i);
|
|
855
|
+
if (u)
|
|
856
|
+
for (const h of t) {
|
|
857
|
+
if (i === h)
|
|
858
|
+
continue;
|
|
859
|
+
const b = h.getSnapType();
|
|
860
|
+
switch (b) {
|
|
861
|
+
case o.PointOnCurve: {
|
|
862
|
+
const g = h.getSnappedGNodes();
|
|
863
|
+
if (g.length !== 1)
|
|
864
|
+
break;
|
|
865
|
+
const G = d.curveIntersectGNode(u, g[0]);
|
|
866
|
+
for (const C of G) {
|
|
867
|
+
const S = d.intersectPoint(
|
|
868
|
+
e.cursorWorld,
|
|
869
|
+
C.pt,
|
|
870
|
+
b
|
|
871
|
+
);
|
|
872
|
+
!S || c(u, C.c) || (i.getSnapType() === o.VerticalToCurve && i.snappedDir && C.c instanceof f && i.snappedDir.isPerpendicular(C.c.getDirection()) && S.setSnapType(o.PerpendicularPoint), S.addSnappedGNodes([...i.getSnappedGNodes(), ...h.getSnappedGNodes()]), S.addSnappedObjects([...i.getSnappedObjects(), ...h.getSnappedObjects()]), S.anotherSnapType = i.getSnapType(), i.snappedDir && (S.snappedDir = i.snappedDir.clone()), s.push(S));
|
|
873
|
+
}
|
|
874
|
+
break;
|
|
875
|
+
}
|
|
876
|
+
default: {
|
|
877
|
+
const g = r(h);
|
|
878
|
+
if (!g || c(u, g))
|
|
879
|
+
break;
|
|
880
|
+
const G = L.X.curve2ds(u, g);
|
|
881
|
+
for (const C of G) {
|
|
882
|
+
const S = d.intersectPoint(
|
|
883
|
+
e.cursorWorld,
|
|
884
|
+
C.point,
|
|
885
|
+
b
|
|
886
|
+
);
|
|
887
|
+
S && (S.addSnappedGNodes([...i.getSnappedGNodes(), ...h.getSnappedGNodes()]), S.addSnappedObjects([...i.getSnappedObjects(), ...h.getSnappedObjects()]), S.anotherSnapType = i.getSnapType(), i.snappedDir && (S.snappedDir = i.snappedDir.clone()), i.getSnapType() === o.VerticalToCurve && (!(h instanceof O) || !h.snappedDir) && p(i, g) && S.setSnapType(o.PerpendicularPoint), s.push(S));
|
|
888
|
+
}
|
|
889
|
+
break;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return s;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* 组合捕捉结果
|
|
898
|
+
*/
|
|
899
|
+
static _combineSnaps(e, n, t) {
|
|
900
|
+
const s = [];
|
|
901
|
+
return s.push(...this._combineIntersects(e, n, t)), s;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
export {
|
|
905
|
+
M as EN_SNAP_HELP_OBJ,
|
|
906
|
+
o as EN_SNAP_TYPE,
|
|
907
|
+
X as EN_XY,
|
|
908
|
+
O as PtSnap,
|
|
909
|
+
I as SnapCandidates,
|
|
910
|
+
A as SnapContext,
|
|
911
|
+
m as SnapDirection,
|
|
912
|
+
z as SnapEngine,
|
|
913
|
+
T as SnapPoint,
|
|
914
|
+
V as SnapResult,
|
|
915
|
+
l as SnapSetting,
|
|
916
|
+
d as SnapUtil
|
|
917
|
+
};
|