@mlightcad/data-model 1.5.4 → 1.5.5
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/dist/data-model.cjs +2 -2
- package/dist/data-model.js +46 -13
- package/dist/dxf-parser-worker.js +2 -2
- package/lib/database/AcDbDatabase.d.ts +3 -3
- package/lib/database/AcDbDatabase.js +3 -3
- package/lib/database/AcDbDwgVersion.js +2 -2
- package/lib/entity/AcDbFace.d.ts +1 -1
- package/lib/entity/AcDbFace.js +1 -1
- package/lib/misc/AcDbOsnapMode.d.ts +104 -0
- package/lib/misc/AcDbOsnapMode.d.ts.map +1 -1
- package/lib/misc/AcDbOsnapMode.js +162 -0
- package/lib/misc/AcDbOsnapMode.js.map +1 -1
- package/package.json +1 -1
package/dist/data-model.js
CHANGED
|
@@ -16978,6 +16978,33 @@ const Va = class Va extends Oe {
|
|
|
16978
16978
|
Va.typeName = "Leader";
|
|
16979
16979
|
let Qi = Va;
|
|
16980
16980
|
var Dt = /* @__PURE__ */ ((i) => (i[i.EndPoint = 1] = "EndPoint", i[i.MidPoint = 2] = "MidPoint", i[i.Center = 3] = "Center", i[i.Node = 4] = "Node", i[i.Quadrant = 5] = "Quadrant", i[i.Insertion = 7] = "Insertion", i[i.Perpendicular = 8] = "Perpendicular", i[i.Tangent = 9] = "Tangent", i[i.Nearest = 10] = "Nearest", i[i.Centroid = 11] = "Centroid", i))(Dt || {});
|
|
16981
|
+
function D0(i) {
|
|
16982
|
+
let t = 0;
|
|
16983
|
+
for (const e of i)
|
|
16984
|
+
t |= 1 << e - 1;
|
|
16985
|
+
return t;
|
|
16986
|
+
}
|
|
16987
|
+
function U0(i) {
|
|
16988
|
+
const t = [];
|
|
16989
|
+
for (const e of Object.values(Dt)) {
|
|
16990
|
+
if (typeof e != "number") continue;
|
|
16991
|
+
const n = 1 << e - 1;
|
|
16992
|
+
i & n && t.push(e);
|
|
16993
|
+
}
|
|
16994
|
+
return t;
|
|
16995
|
+
}
|
|
16996
|
+
function V0(i, t) {
|
|
16997
|
+
return i ^ 1 << t - 1;
|
|
16998
|
+
}
|
|
16999
|
+
function j0(i, t) {
|
|
17000
|
+
return (i & 1 << t - 1) !== 0;
|
|
17001
|
+
}
|
|
17002
|
+
function G0(i, t) {
|
|
17003
|
+
return i | 1 << t - 1;
|
|
17004
|
+
}
|
|
17005
|
+
function W0(i, t) {
|
|
17006
|
+
return i & ~(1 << t - 1);
|
|
17007
|
+
}
|
|
16981
17008
|
const ja = class ja extends Oe {
|
|
16982
17009
|
/**
|
|
16983
17010
|
* Creates a new line entity.
|
|
@@ -22353,10 +22380,10 @@ var Tl = /* @__PURE__ */ ((i) => (i[i.Undefined = 0] = "Undefined", i[i.Inches =
|
|
|
22353
22380
|
i.Max = 24
|
|
22354
22381
|
/* USSurveyMile */
|
|
22355
22382
|
] = "Max", i))(Tl || {});
|
|
22356
|
-
function
|
|
22383
|
+
function H0(i) {
|
|
22357
22384
|
return i == 4 || i == 5 || i == 6 || i == 7 || i == 12 || i == 13 || i == 14 || i == 15 || i == 16 || i == 17;
|
|
22358
22385
|
}
|
|
22359
|
-
function
|
|
22386
|
+
function q0(i) {
|
|
22360
22387
|
return i == 1 || i == 2 || i == 3 || i == 8 || i == 9 || i == 10 || i == 21;
|
|
22361
22388
|
}
|
|
22362
22389
|
const Cl = "Load Database";
|
|
@@ -24121,8 +24148,8 @@ const qo = [
|
|
|
24121
24148
|
*/
|
|
24122
24149
|
{ name: "AC1014", value: 21 },
|
|
24123
24150
|
/**
|
|
24124
|
-
* AC1500 doesn
|
|
24125
|
-
* it
|
|
24151
|
+
* AC1500 doesn't actually correspond to any real DWG file version.
|
|
24152
|
+
* it's just a legacy or internal placeholder in the enum sequence.
|
|
24126
24153
|
*/
|
|
24127
24154
|
{ name: "AC1500", value: 22 },
|
|
24128
24155
|
/**
|
|
@@ -25150,7 +25177,7 @@ class s0 {
|
|
|
25150
25177
|
function i0(i) {
|
|
25151
25178
|
return new s0(i);
|
|
25152
25179
|
}
|
|
25153
|
-
class
|
|
25180
|
+
class Y0 {
|
|
25154
25181
|
constructor() {
|
|
25155
25182
|
this.setupMessageHandler();
|
|
25156
25183
|
}
|
|
@@ -26686,7 +26713,7 @@ class p0 extends Un {
|
|
|
26686
26713
|
super(t);
|
|
26687
26714
|
}
|
|
26688
26715
|
}
|
|
26689
|
-
class
|
|
26716
|
+
class X0 extends fn {
|
|
26690
26717
|
/**
|
|
26691
26718
|
* Creates a new AcDbDatabase instance.
|
|
26692
26719
|
*/
|
|
@@ -26978,9 +27005,9 @@ class j0 extends fn {
|
|
|
26978
27005
|
}
|
|
26979
27006
|
/**
|
|
26980
27007
|
* Point display size.
|
|
26981
|
-
* - 0:
|
|
26982
|
-
* - > 0:
|
|
26983
|
-
* - < 0:
|
|
27008
|
+
* - 0: Creates a point at 5 percent of the drawing area height
|
|
27009
|
+
* - > 0: Specifies an absolute size
|
|
27010
|
+
* - < 0: Specifies a percentage of the viewport size
|
|
26984
27011
|
*/
|
|
26985
27012
|
get pdsize() {
|
|
26986
27013
|
return this._pdsize;
|
|
@@ -28964,7 +28991,7 @@ export {
|
|
|
28964
28991
|
tl as AcDbAngleUnits,
|
|
28965
28992
|
Xi as AcDbArc,
|
|
28966
28993
|
Uo as AcDbArcDimension,
|
|
28967
|
-
|
|
28994
|
+
Y0 as AcDbBaseWorker,
|
|
28968
28995
|
Jo as AcDbBatchProcessing,
|
|
28969
28996
|
ks as AcDbBlockReference,
|
|
28970
28997
|
l0 as AcDbBlockTable,
|
|
@@ -28973,7 +29000,7 @@ export {
|
|
|
28973
29000
|
el as AcDbCodePage,
|
|
28974
29001
|
Oe as AcDbCurve,
|
|
28975
29002
|
mu as AcDbDataGenerator,
|
|
28976
|
-
|
|
29003
|
+
X0 as AcDbDatabase,
|
|
28977
29004
|
Nl as AcDbDatabaseConverter,
|
|
28978
29005
|
Lr as AcDbDatabaseConverterManager,
|
|
28979
29006
|
ca as AcDbDiametricDimension,
|
|
@@ -29094,7 +29121,13 @@ export {
|
|
|
29094
29121
|
hl as ORIGIN_POINT_3D,
|
|
29095
29122
|
nl as RAD2DEG,
|
|
29096
29123
|
Qt as TAU,
|
|
29124
|
+
W0 as acdbDisableOsnapMode,
|
|
29125
|
+
G0 as acdbEnableOsnapMode,
|
|
29126
|
+
j0 as acdbHasOsnapMode,
|
|
29097
29127
|
Gh as acdbHostApplicationServices,
|
|
29128
|
+
U0 as acdbMaskToOsnapModes,
|
|
29129
|
+
D0 as acdbOsnapModesToMask,
|
|
29130
|
+
V0 as acdbToggleOsnapMode,
|
|
29098
29131
|
Gi as basisFunction,
|
|
29099
29132
|
Hc as calculateCurveLength,
|
|
29100
29133
|
Bc as ceilPowerOfTwo,
|
|
@@ -29121,8 +29154,8 @@ export {
|
|
|
29121
29154
|
Fc as isBetweenAngle,
|
|
29122
29155
|
lc as isEmpty,
|
|
29123
29156
|
Is as isEqual,
|
|
29124
|
-
|
|
29125
|
-
|
|
29157
|
+
q0 as isImperialUnits,
|
|
29158
|
+
H0 as isMetricUnits,
|
|
29126
29159
|
dl as isPointInPolygon,
|
|
29127
29160
|
Uc as isPolygonIntersect,
|
|
29128
29161
|
Oc as isPowerOfTwo,
|
|
@@ -1481,8 +1481,8 @@ const dr = [
|
|
|
1481
1481
|
*/
|
|
1482
1482
|
{ name: "AC1014", value: 21 },
|
|
1483
1483
|
/**
|
|
1484
|
-
* AC1500 doesn
|
|
1485
|
-
* it
|
|
1484
|
+
* AC1500 doesn't actually correspond to any real DWG file version.
|
|
1485
|
+
* it's just a legacy or internal placeholder in the enum sequence.
|
|
1486
1486
|
*/
|
|
1487
1487
|
{ name: "AC1500", value: 22 },
|
|
1488
1488
|
/**
|
|
@@ -486,9 +486,9 @@ export declare class AcDbDatabase extends AcDbObject {
|
|
|
486
486
|
set pdmode(value: number);
|
|
487
487
|
/**
|
|
488
488
|
* Point display size.
|
|
489
|
-
* - 0:
|
|
490
|
-
* - > 0:
|
|
491
|
-
* - < 0:
|
|
489
|
+
* - 0: Creates a point at 5 percent of the drawing area height
|
|
490
|
+
* - > 0: Specifies an absolute size
|
|
491
|
+
* - < 0: Specifies a percentage of the viewport size
|
|
492
492
|
*/
|
|
493
493
|
get pdsize(): number;
|
|
494
494
|
set pdsize(value: number);
|
|
@@ -487,9 +487,9 @@ var AcDbDatabase = /** @class */ (function (_super) {
|
|
|
487
487
|
Object.defineProperty(AcDbDatabase.prototype, "pdsize", {
|
|
488
488
|
/**
|
|
489
489
|
* Point display size.
|
|
490
|
-
* - 0:
|
|
491
|
-
* - > 0:
|
|
492
|
-
* - < 0:
|
|
490
|
+
* - 0: Creates a point at 5 percent of the drawing area height
|
|
491
|
+
* - > 0: Specifies an absolute size
|
|
492
|
+
* - < 0: Specifies a percentage of the viewport size
|
|
493
493
|
*/
|
|
494
494
|
get: function () {
|
|
495
495
|
return this._pdsize;
|
|
@@ -49,8 +49,8 @@ var dwgVersions = [
|
|
|
49
49
|
*/
|
|
50
50
|
{ name: 'AC1014', value: 21 },
|
|
51
51
|
/**
|
|
52
|
-
* AC1500 doesn
|
|
53
|
-
* it
|
|
52
|
+
* AC1500 doesn't actually correspond to any real DWG file version.
|
|
53
|
+
* it's just a legacy or internal placeholder in the enum sequence.
|
|
54
54
|
*/
|
|
55
55
|
{ name: 'AC1500', value: 22 },
|
|
56
56
|
/**
|
package/lib/entity/AcDbFace.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { AcDbOsnapMode } from '../misc';
|
|
|
4
4
|
import { AcDbEntity } from './AcDbEntity';
|
|
5
5
|
/**
|
|
6
6
|
* Represents a three-dimensional surface patch — specifically, a flat polygon that
|
|
7
|
-
* can have three or four vertices (triangular or quadrilateral). It
|
|
7
|
+
* can have three or four vertices (triangular or quadrilateral). It's one of the
|
|
8
8
|
* simplest types of 3D geometry in AutoCAD — used mainly for visual representation
|
|
9
9
|
* of 3D models, not for solid modeling.
|
|
10
10
|
*/
|
package/lib/entity/AcDbFace.js
CHANGED
|
@@ -43,7 +43,7 @@ import { AcDbOsnapMode } from '../misc';
|
|
|
43
43
|
import { AcDbEntity } from './AcDbEntity';
|
|
44
44
|
/**
|
|
45
45
|
* Represents a three-dimensional surface patch — specifically, a flat polygon that
|
|
46
|
-
* can have three or four vertices (triangular or quadrilateral). It
|
|
46
|
+
* can have three or four vertices (triangular or quadrilateral). It's one of the
|
|
47
47
|
* simplest types of 3D geometry in AutoCAD — used mainly for visual representation
|
|
48
48
|
* of 3D models, not for solid modeling.
|
|
49
49
|
*/
|
|
@@ -48,4 +48,108 @@ export declare enum AcDbOsnapMode {
|
|
|
48
48
|
*/
|
|
49
49
|
Centroid = 11
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Converts an array of {@link AcDbOsnapMode} values into a single integer bitmask.
|
|
53
|
+
*
|
|
54
|
+
* ⚠️ Important:
|
|
55
|
+
* {@link AcDbOsnapMode} values are **ordinal identifiers**, not bit flags.
|
|
56
|
+
* Each mode is mapped to a bit position using the rule:
|
|
57
|
+
*
|
|
58
|
+
* `bit = (mode - 1)`
|
|
59
|
+
*
|
|
60
|
+
* This allows multiple object snap modes to be stored efficiently
|
|
61
|
+
* in a single integer using bitwise operations.
|
|
62
|
+
*
|
|
63
|
+
* @param modes - Array of object snap modes to enable
|
|
64
|
+
* @returns Integer bitmask representing the enabled object snap modes
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* const mask = acDbOsnapModesToMask([
|
|
69
|
+
* AcDbOsnapMode.EndPoint,
|
|
70
|
+
* AcDbOsnapMode.MidPoint,
|
|
71
|
+
* AcDbOsnapMode.Perpendicular
|
|
72
|
+
* ])
|
|
73
|
+
* // mask === 131
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function acdbOsnapModesToMask(modes: AcDbOsnapMode[]): number;
|
|
77
|
+
/**
|
|
78
|
+
* Converts an integer bitmask into an array of {@link AcDbOsnapMode} values.
|
|
79
|
+
*
|
|
80
|
+
* The function iterates over all {@link AcDbOsnapMode} enum values and
|
|
81
|
+
* checks whether the corresponding bit (computed as `1 << (mode - 1)`)
|
|
82
|
+
* is set in the provided mask.
|
|
83
|
+
*
|
|
84
|
+
* @param mask - Integer bitmask containing object snap mode flags
|
|
85
|
+
* @returns Array of enabled {@link AcDbOsnapMode} values
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* const modes = acDbMaskToOsnapModes(131)
|
|
90
|
+
* // [
|
|
91
|
+
* // AcDbOsnapMode.EndPoint,
|
|
92
|
+
* // AcDbOsnapMode.MidPoint,
|
|
93
|
+
* // AcDbOsnapMode.Perpendicular
|
|
94
|
+
* // ]
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function acdbMaskToOsnapModes(mask: number): AcDbOsnapMode[];
|
|
98
|
+
/**
|
|
99
|
+
* Toggles a specific {@link AcDbOsnapMode} in an object snap bitmask.
|
|
100
|
+
*
|
|
101
|
+
* If the mode is currently enabled, it will be disabled.
|
|
102
|
+
* If the mode is disabled, it will be enabled.
|
|
103
|
+
*
|
|
104
|
+
* @param mask - Current object snap mode bitmask
|
|
105
|
+
* @param mode - Object snap mode to toggle
|
|
106
|
+
* @returns Updated bitmask with the specified mode toggled
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* mask = acdbToggleOsnapMode(mask, AcDbOsnapMode.MidPoint)
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare function acdbToggleOsnapMode(mask: number, mode: AcDbOsnapMode): number;
|
|
114
|
+
/**
|
|
115
|
+
* Checks whether a specific {@link AcDbOsnapMode} is enabled in the bitmask.
|
|
116
|
+
*
|
|
117
|
+
* @param mask - Object snap mode bitmask
|
|
118
|
+
* @param mode - Object snap mode to test
|
|
119
|
+
* @returns `true` if the mode is enabled; otherwise `false`
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* if (acdbHasOsnapMode(mask, AcDbOsnapMode.EndPoint)) {
|
|
124
|
+
* // EndPoint snapping is enabled
|
|
125
|
+
* }
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export declare function acdbHasOsnapMode(mask: number, mode: AcDbOsnapMode): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Enables a specific {@link AcDbOsnapMode} in the object snap bitmask.
|
|
131
|
+
*
|
|
132
|
+
* @param mask - Current object snap mode bitmask
|
|
133
|
+
* @param mode - Object snap mode to enable
|
|
134
|
+
* @returns Updated bitmask with the mode enabled
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* mask = acdbEnableOsnapMode(mask, AcDbOsnapMode.Tangent)
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export declare function acdbEnableOsnapMode(mask: number, mode: AcDbOsnapMode): number;
|
|
142
|
+
/**
|
|
143
|
+
* Disables a specific {@link AcDbOsnapMode} in the object snap bitmask.
|
|
144
|
+
*
|
|
145
|
+
* @param mask - Current object snap mode bitmask
|
|
146
|
+
* @param mode - Object snap mode to disable
|
|
147
|
+
* @returns Updated bitmask with the mode disabled
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* mask = acdbDisableOsnapMode(mask, AcDbOsnapMode.Nearest)
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
export declare function acdbDisableOsnapMode(mask: number, mode: AcDbOsnapMode): number;
|
|
51
155
|
//# sourceMappingURL=AcDbOsnapMode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcDbOsnapMode.d.ts","sourceRoot":"","sources":["../../src/misc/AcDbOsnapMode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,oBAAY,aAAa;IACvB;;OAEG;IACH,QAAQ,IAAI;IACZ;;OAEG;IACH,QAAQ,IAAI;IACZ;;OAEG;IACH,MAAM,IAAI;IACV;;OAEG;IACH,IAAI,IAAI;IACR;;;OAGG;IACH,QAAQ,IAAI;IACZ;;OAEG;IACH,SAAS,IAAI;IACb;;OAEG;IACH,aAAa,IAAI;IACjB;;OAEG;IACH,OAAO,IAAI;IACX;;OAEG;IACH,OAAO,KAAK;IACZ;;OAEG;IACH,QAAQ,KAAK;CACd"}
|
|
1
|
+
{"version":3,"file":"AcDbOsnapMode.d.ts","sourceRoot":"","sources":["../../src/misc/AcDbOsnapMode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,oBAAY,aAAa;IACvB;;OAEG;IACH,QAAQ,IAAI;IACZ;;OAEG;IACH,QAAQ,IAAI;IACZ;;OAEG;IACH,MAAM,IAAI;IACV;;OAEG;IACH,IAAI,IAAI;IACR;;;OAGG;IACH,QAAQ,IAAI;IACZ;;OAEG;IACH,SAAS,IAAI;IACb;;OAEG;IACH,aAAa,IAAI;IACjB;;OAEG;IACH,OAAO,IAAI;IACX;;OAEG;IACH,OAAO,KAAK;IACZ;;OAEG;IACH,QAAQ,KAAK;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,aAAa,EAAE,GACrB,MAAM,CAQR;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,GACX,aAAa,EAAE,CAajB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,aAAa,GAClB,MAAM,CAER;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,aAAa,GAClB,OAAO,CAET;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,aAAa,GAClB,MAAM,CAER;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,aAAa,GAClB,MAAM,CAER"}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __values = (this && this.__values) || function(o) {
|
|
2
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
+
if (m) return m.call(o);
|
|
4
|
+
if (o && typeof o.length === "number") return {
|
|
5
|
+
next: function () {
|
|
6
|
+
if (o && i >= o.length) o = void 0;
|
|
7
|
+
return { value: o && o[i++], done: !o };
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
+
};
|
|
1
12
|
/**
|
|
2
13
|
* Enumeration of object snap modes used in AutoCAD.
|
|
3
14
|
*
|
|
@@ -49,4 +60,155 @@ export var AcDbOsnapMode;
|
|
|
49
60
|
*/
|
|
50
61
|
AcDbOsnapMode[AcDbOsnapMode["Centroid"] = 11] = "Centroid";
|
|
51
62
|
})(AcDbOsnapMode || (AcDbOsnapMode = {}));
|
|
63
|
+
/**
|
|
64
|
+
* Converts an array of {@link AcDbOsnapMode} values into a single integer bitmask.
|
|
65
|
+
*
|
|
66
|
+
* ⚠️ Important:
|
|
67
|
+
* {@link AcDbOsnapMode} values are **ordinal identifiers**, not bit flags.
|
|
68
|
+
* Each mode is mapped to a bit position using the rule:
|
|
69
|
+
*
|
|
70
|
+
* `bit = (mode - 1)`
|
|
71
|
+
*
|
|
72
|
+
* This allows multiple object snap modes to be stored efficiently
|
|
73
|
+
* in a single integer using bitwise operations.
|
|
74
|
+
*
|
|
75
|
+
* @param modes - Array of object snap modes to enable
|
|
76
|
+
* @returns Integer bitmask representing the enabled object snap modes
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* const mask = acDbOsnapModesToMask([
|
|
81
|
+
* AcDbOsnapMode.EndPoint,
|
|
82
|
+
* AcDbOsnapMode.MidPoint,
|
|
83
|
+
* AcDbOsnapMode.Perpendicular
|
|
84
|
+
* ])
|
|
85
|
+
* // mask === 131
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export function acdbOsnapModesToMask(modes) {
|
|
89
|
+
var e_1, _a;
|
|
90
|
+
var mask = 0;
|
|
91
|
+
try {
|
|
92
|
+
for (var modes_1 = __values(modes), modes_1_1 = modes_1.next(); !modes_1_1.done; modes_1_1 = modes_1.next()) {
|
|
93
|
+
var mode = modes_1_1.value;
|
|
94
|
+
mask |= 1 << (mode - 1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
98
|
+
finally {
|
|
99
|
+
try {
|
|
100
|
+
if (modes_1_1 && !modes_1_1.done && (_a = modes_1.return)) _a.call(modes_1);
|
|
101
|
+
}
|
|
102
|
+
finally { if (e_1) throw e_1.error; }
|
|
103
|
+
}
|
|
104
|
+
return mask;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Converts an integer bitmask into an array of {@link AcDbOsnapMode} values.
|
|
108
|
+
*
|
|
109
|
+
* The function iterates over all {@link AcDbOsnapMode} enum values and
|
|
110
|
+
* checks whether the corresponding bit (computed as `1 << (mode - 1)`)
|
|
111
|
+
* is set in the provided mask.
|
|
112
|
+
*
|
|
113
|
+
* @param mask - Integer bitmask containing object snap mode flags
|
|
114
|
+
* @returns Array of enabled {@link AcDbOsnapMode} values
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* const modes = acDbMaskToOsnapModes(131)
|
|
119
|
+
* // [
|
|
120
|
+
* // AcDbOsnapMode.EndPoint,
|
|
121
|
+
* // AcDbOsnapMode.MidPoint,
|
|
122
|
+
* // AcDbOsnapMode.Perpendicular
|
|
123
|
+
* // ]
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export function acdbMaskToOsnapModes(mask) {
|
|
127
|
+
var e_2, _a;
|
|
128
|
+
var modes = [];
|
|
129
|
+
try {
|
|
130
|
+
for (var _b = __values(Object.values(AcDbOsnapMode)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
131
|
+
var value = _c.value;
|
|
132
|
+
if (typeof value !== 'number')
|
|
133
|
+
continue;
|
|
134
|
+
var bit = 1 << (value - 1);
|
|
135
|
+
if ((mask & bit) !== 0) {
|
|
136
|
+
modes.push(value);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
141
|
+
finally {
|
|
142
|
+
try {
|
|
143
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
144
|
+
}
|
|
145
|
+
finally { if (e_2) throw e_2.error; }
|
|
146
|
+
}
|
|
147
|
+
return modes;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Toggles a specific {@link AcDbOsnapMode} in an object snap bitmask.
|
|
151
|
+
*
|
|
152
|
+
* If the mode is currently enabled, it will be disabled.
|
|
153
|
+
* If the mode is disabled, it will be enabled.
|
|
154
|
+
*
|
|
155
|
+
* @param mask - Current object snap mode bitmask
|
|
156
|
+
* @param mode - Object snap mode to toggle
|
|
157
|
+
* @returns Updated bitmask with the specified mode toggled
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* mask = acdbToggleOsnapMode(mask, AcDbOsnapMode.MidPoint)
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
export function acdbToggleOsnapMode(mask, mode) {
|
|
165
|
+
return mask ^ (1 << (mode - 1));
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Checks whether a specific {@link AcDbOsnapMode} is enabled in the bitmask.
|
|
169
|
+
*
|
|
170
|
+
* @param mask - Object snap mode bitmask
|
|
171
|
+
* @param mode - Object snap mode to test
|
|
172
|
+
* @returns `true` if the mode is enabled; otherwise `false`
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* if (acdbHasOsnapMode(mask, AcDbOsnapMode.EndPoint)) {
|
|
177
|
+
* // EndPoint snapping is enabled
|
|
178
|
+
* }
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
export function acdbHasOsnapMode(mask, mode) {
|
|
182
|
+
return (mask & (1 << (mode - 1))) !== 0;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Enables a specific {@link AcDbOsnapMode} in the object snap bitmask.
|
|
186
|
+
*
|
|
187
|
+
* @param mask - Current object snap mode bitmask
|
|
188
|
+
* @param mode - Object snap mode to enable
|
|
189
|
+
* @returns Updated bitmask with the mode enabled
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* mask = acdbEnableOsnapMode(mask, AcDbOsnapMode.Tangent)
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
export function acdbEnableOsnapMode(mask, mode) {
|
|
197
|
+
return mask | (1 << (mode - 1));
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Disables a specific {@link AcDbOsnapMode} in the object snap bitmask.
|
|
201
|
+
*
|
|
202
|
+
* @param mask - Current object snap mode bitmask
|
|
203
|
+
* @param mode - Object snap mode to disable
|
|
204
|
+
* @returns Updated bitmask with the mode disabled
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```ts
|
|
208
|
+
* mask = acdbDisableOsnapMode(mask, AcDbOsnapMode.Nearest)
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
export function acdbDisableOsnapMode(mask, mode) {
|
|
212
|
+
return mask & ~(1 << (mode - 1));
|
|
213
|
+
}
|
|
52
214
|
//# sourceMappingURL=AcDbOsnapMode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcDbOsnapMode.js","sourceRoot":"","sources":["../../src/misc/AcDbOsnapMode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,aA0CX;AA1CD,WAAY,aAAa;IACvB;;OAEG;IACH,yDAAY,CAAA;IACZ;;OAEG;IACH,yDAAY,CAAA;IACZ;;OAEG;IACH,qDAAU,CAAA;IACV;;OAEG;IACH,iDAAQ,CAAA;IACR;;;OAGG;IACH,yDAAY,CAAA;IACZ;;OAEG;IACH,2DAAa,CAAA;IACb;;OAEG;IACH,mEAAiB,CAAA;IACjB;;OAEG;IACH,uDAAW,CAAA;IACX;;OAEG;IACH,wDAAY,CAAA;IACZ;;OAEG;IACH,0DAAa,CAAA;AACf,CAAC,EA1CW,aAAa,KAAb,aAAa,QA0CxB"}
|
|
1
|
+
{"version":3,"file":"AcDbOsnapMode.js","sourceRoot":"","sources":["../../src/misc/AcDbOsnapMode.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,aA0CX;AA1CD,WAAY,aAAa;IACvB;;OAEG;IACH,yDAAY,CAAA;IACZ;;OAEG;IACH,yDAAY,CAAA;IACZ;;OAEG;IACH,qDAAU,CAAA;IACV;;OAEG;IACH,iDAAQ,CAAA;IACR;;;OAGG;IACH,yDAAY,CAAA;IACZ;;OAEG;IACH,2DAAa,CAAA;IACb;;OAEG;IACH,mEAAiB,CAAA;IACjB;;OAEG;IACH,uDAAW,CAAA;IACX;;OAEG;IACH,wDAAY,CAAA;IACZ;;OAEG;IACH,0DAAa,CAAA;AACf,CAAC,EA1CW,aAAa,KAAb,aAAa,QA0CxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAsB;;IAEtB,IAAI,IAAI,GAAG,CAAC,CAAA;;QAEZ,KAAmB,IAAA,UAAA,SAAA,KAAK,CAAA,4BAAA,+CAAE,CAAC;YAAtB,IAAM,IAAI,kBAAA;YACb,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAA;QACzB,CAAC;;;;;;;;;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAY;;IAEZ,IAAM,KAAK,GAAoB,EAAE,CAAA;;QAEjC,KAAoB,IAAA,KAAA,SAAA,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA,gBAAA,4BAAE,CAAC;YAA9C,IAAM,KAAK,WAAA;YACd,IAAI,OAAO,KAAK,KAAK,QAAQ;gBAAE,SAAQ;YAEvC,IAAM,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;YAC5B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACnB,CAAC;QACH,CAAC;;;;;;;;;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAY,EACZ,IAAmB;IAEnB,OAAO,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAA;AACjC,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,IAAmB;IAEnB,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;AACzC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAY,EACZ,IAAmB;IAEnB,OAAO,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAA;AACjC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,IAAmB;IAEnB,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAA;AAClC,CAAC"}
|