@mlightcad/cad-simple-viewer 1.3.4 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3532 -3305
- package/dist/index.umd.cjs +196 -202
- package/lib/app/AcApContext.d.ts.map +1 -1
- package/lib/app/AcApContext.js +4 -0
- package/lib/app/AcApContext.js.map +1 -1
- package/lib/app/AcApDocManager.d.ts +14 -2
- package/lib/app/AcApDocManager.d.ts.map +1 -1
- package/lib/app/AcApDocManager.js +19 -7
- package/lib/app/AcApDocManager.js.map +1 -1
- package/lib/command/AcApEraseCmd.d.ts +14 -0
- package/lib/command/AcApEraseCmd.d.ts.map +1 -0
- package/lib/command/AcApEraseCmd.js +40 -0
- package/lib/command/AcApEraseCmd.js.map +1 -0
- package/lib/command/index.d.ts +1 -0
- package/lib/command/index.d.ts.map +1 -1
- package/lib/command/index.js +1 -0
- package/lib/command/index.js.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInput.d.ts.map +1 -1
- package/lib/editor/input/ui/AcEdFloatingInput.js +33 -21
- package/lib/editor/input/ui/AcEdFloatingInput.js.map +1 -1
- package/lib/editor/view/AcEdBaseView.d.ts +11 -14
- package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
- package/lib/editor/view/AcEdBaseView.js +6 -3
- package/lib/editor/view/AcEdBaseView.js.map +1 -1
- package/lib/editor/view/AcEdSpatialQueryResult.d.ts +15 -0
- package/lib/editor/view/AcEdSpatialQueryResult.d.ts.map +1 -0
- package/lib/editor/view/AcEdSpatialQueryResult.js +2 -0
- package/lib/editor/view/AcEdSpatialQueryResult.js.map +1 -0
- package/lib/editor/view/index.d.ts +1 -0
- package/lib/editor/view/index.d.ts.map +1 -1
- package/lib/editor/view/index.js +1 -0
- package/lib/editor/view/index.js.map +1 -1
- package/lib/i18n/en/command.d.ts +1 -0
- package/lib/i18n/en/command.d.ts.map +1 -1
- package/lib/i18n/en/command.js +1 -0
- package/lib/i18n/en/command.js.map +1 -1
- package/lib/i18n/zh/command.d.ts +1 -0
- package/lib/i18n/zh/command.d.ts.map +1 -1
- package/lib/i18n/zh/command.js +1 -0
- package/lib/i18n/zh/command.js.map +1 -1
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.d.ts +54 -0
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.d.ts.map +1 -0
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.js +191 -0
- package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.js.map +1 -0
- package/lib/spatialIndex/AcTrLinearSpatialIndex.d.ts +36 -0
- package/lib/spatialIndex/AcTrLinearSpatialIndex.d.ts.map +1 -0
- package/lib/spatialIndex/AcTrLinearSpatialIndex.js +85 -0
- package/lib/spatialIndex/AcTrLinearSpatialIndex.js.map +1 -0
- package/lib/spatialIndex/AcTrRBushSpatialIndex.d.ts +16 -0
- package/lib/spatialIndex/AcTrRBushSpatialIndex.d.ts.map +1 -0
- package/lib/spatialIndex/AcTrRBushSpatialIndex.js +40 -0
- package/lib/spatialIndex/AcTrRBushSpatialIndex.js.map +1 -0
- package/lib/spatialIndex/AcTrSpatialIndex.d.ts +77 -0
- package/lib/spatialIndex/AcTrSpatialIndex.d.ts.map +1 -0
- package/lib/spatialIndex/AcTrSpatialIndex.js +2 -0
- package/lib/spatialIndex/AcTrSpatialIndex.js.map +1 -0
- package/lib/spatialIndex/index.d.ts +3 -0
- package/lib/spatialIndex/index.d.ts.map +1 -0
- package/lib/spatialIndex/index.js +3 -0
- package/lib/spatialIndex/index.js.map +1 -0
- package/lib/view/AcTrLayer.d.ts +1 -1
- package/lib/view/AcTrLayer.d.ts.map +1 -1
- package/lib/view/AcTrLayer.js +2 -3
- package/lib/view/AcTrLayer.js.map +1 -1
- package/lib/view/AcTrLayout.d.ts +4 -13
- package/lib/view/AcTrLayout.d.ts.map +1 -1
- package/lib/view/AcTrLayout.js +18 -22
- package/lib/view/AcTrLayout.js.map +1 -1
- package/lib/view/AcTrScene.d.ts +2 -3
- package/lib/view/AcTrScene.d.ts.map +1 -1
- package/lib/view/AcTrScene.js +0 -6
- package/lib/view/AcTrScene.js.map +1 -1
- package/lib/view/AcTrView2d.d.ts +8 -9
- package/lib/view/AcTrView2d.d.ts.map +1 -1
- package/lib/view/AcTrView2d.js +23 -21
- package/lib/view/AcTrView2d.js.map +1 -1
- package/package.json +5 -5
package/lib/i18n/en/command.js
CHANGED
|
@@ -3,6 +3,7 @@ export default {
|
|
|
3
3
|
circle: 'Creates one circle by center and radius',
|
|
4
4
|
csvg: 'Converts current drawing to SVG',
|
|
5
5
|
dimlinear: 'Creates linear dimensions',
|
|
6
|
+
erase: 'Deletes selected entities from the drawing',
|
|
6
7
|
line: 'Draws straight line segments between points',
|
|
7
8
|
log: 'Logs debug information in console',
|
|
8
9
|
open: 'Opens an existing drawing file',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/i18n/en/command.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,IAAI,EAAE;QACJ,MAAM,EAAE,yCAAyC;QACjD,IAAI,EAAE,iCAAiC;QACvC,SAAS,EAAE,2BAA2B;QACtC,IAAI,EAAE,6CAA6C;QACnD,GAAG,EAAE,mCAAmC;QACxC,IAAI,EAAE,gCAAgC;QACtC,GAAG,EAAE,yEAAyE;QAC9E,OAAO,EACL,qEAAqE;QACvE,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,4BAA4B;QACnC,MAAM,EAAE,kBAAkB;QAC1B,IAAI,EAAE,sDAAsD;QAC5D,KAAK,EAAE,4DAA4D;KACpE;IACD,IAAI,EAAE,EAAE;CACT,CAAA"}
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/i18n/en/command.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,IAAI,EAAE;QACJ,MAAM,EAAE,yCAAyC;QACjD,IAAI,EAAE,iCAAiC;QACvC,SAAS,EAAE,2BAA2B;QACtC,KAAK,EAAE,4CAA4C;QACnD,IAAI,EAAE,6CAA6C;QACnD,GAAG,EAAE,mCAAmC;QACxC,IAAI,EAAE,gCAAgC;QACtC,GAAG,EAAE,yEAAyE;QAC9E,OAAO,EACL,qEAAqE;QACvE,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,4BAA4B;QACnC,MAAM,EAAE,kBAAkB;QAC1B,IAAI,EAAE,sDAAsD;QAC5D,KAAK,EAAE,4DAA4D;KACpE;IACD,IAAI,EAAE,EAAE;CACT,CAAA"}
|
package/lib/i18n/zh/command.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/i18n/zh/command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/i18n/zh/command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,wBAkBC"}
|
package/lib/i18n/zh/command.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/i18n/zh/command.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,IAAI,EAAE;QACJ,MAAM,EAAE,YAAY;QACpB,IAAI,EAAE,cAAc;QACpB,SAAS,EAAE,UAAU;QACrB,IAAI,EAAE,aAAa;QACnB,GAAG,EAAE,YAAY;QACjB,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,MAAM;QACX,OAAO,EAAE,oBAAoB;QAC7B,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,eAAe;KACvB;IACD,IAAI,EAAE,EAAE;CACT,CAAA"}
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/i18n/zh/command.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,IAAI,EAAE;QACJ,MAAM,EAAE,YAAY;QACpB,IAAI,EAAE,cAAc;QACpB,SAAS,EAAE,UAAU;QACrB,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,aAAa;QACnB,GAAG,EAAE,YAAY;QACjB,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,MAAM;QACX,OAAO,EAAE,oBAAoB;QAC7B,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,eAAe;KACvB;IACD,IAAI,EAAE,EAAE;CACT,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AcDbObjectId } from '@mlightcad/data-model';
|
|
2
|
+
import { AcTrGroup } from '@mlightcad/three-renderer';
|
|
3
|
+
import { AcEdSpatialQueryResultItem, AcEdSpatialQueryResultItemEx } from '../editor/view';
|
|
4
|
+
import { AcTrSpatialIndex, AcTrSpatialIndexBBox } from './AcTrSpatialIndex';
|
|
5
|
+
/**
|
|
6
|
+
* A two-level (hierarchical) spatial index designed for complex CAD
|
|
7
|
+
* scene structures such as blocks, groups, layers, or nested entities.
|
|
8
|
+
*
|
|
9
|
+
* The index consists of:
|
|
10
|
+
*
|
|
11
|
+
* 1. A first-level spatial index that stores coarse bounding boxes
|
|
12
|
+
* (AcEdSpatialQueryResultItem) and maps each result to an `id`.
|
|
13
|
+
*
|
|
14
|
+
* 2. A second-level map from `id` to another spatial index, which
|
|
15
|
+
* contains more detailed spatial data for that specific entity,
|
|
16
|
+
* block, or group.
|
|
17
|
+
*
|
|
18
|
+
* Spatial queries are executed in two phases:
|
|
19
|
+
* - First, the query is performed against the root spatial index to
|
|
20
|
+
* find candidate items.
|
|
21
|
+
* - Then, for each candidate, the corresponding second-level spatial
|
|
22
|
+
* index (if present) is queried for more precise results.
|
|
23
|
+
* - Results from both levels are merged into a single query result.
|
|
24
|
+
*
|
|
25
|
+
* This design allows:
|
|
26
|
+
* - Mixing different spatial index implementations (e.g. R-tree and
|
|
27
|
+
* linear scan) at different hierarchy levels
|
|
28
|
+
* - Efficient querying of large, nested CAD datasets
|
|
29
|
+
* - Lazy or selective construction of fine-grained spatial indexes
|
|
30
|
+
*
|
|
31
|
+
* This class is particularly suitable for CAD viewers and editors
|
|
32
|
+
* where entities are grouped hierarchically but still require fast
|
|
33
|
+
* spatial queries such as selection, picking, and hit-testing.
|
|
34
|
+
*/
|
|
35
|
+
export declare class AcTrHierarchicalSpatialIndex implements AcTrSpatialIndex {
|
|
36
|
+
static THRESHOLD: number;
|
|
37
|
+
private readonly rootIndex;
|
|
38
|
+
private readonly childIndexes;
|
|
39
|
+
constructor(rootIndex?: AcTrSpatialIndex<AcEdSpatialQueryResultItem>);
|
|
40
|
+
/** Register second-level index for an id */
|
|
41
|
+
setChildIndex(id: string, index: AcTrSpatialIndex): void;
|
|
42
|
+
/** Remove second-level index */
|
|
43
|
+
removeChildIndex(id: string): void;
|
|
44
|
+
insert(item: AcEdSpatialQueryResultItem): void;
|
|
45
|
+
load(items: readonly AcEdSpatialQueryResultItem[]): void;
|
|
46
|
+
remove(item: AcEdSpatialQueryResultItem, equals?: (a: AcEdSpatialQueryResultItem, b: AcEdSpatialQueryResultItem) => boolean): void;
|
|
47
|
+
removeById(id: AcDbObjectId): void;
|
|
48
|
+
clear(): void;
|
|
49
|
+
search(bbox: AcTrSpatialIndexBBox): AcEdSpatialQueryResultItemEx[];
|
|
50
|
+
collides(bbox: AcTrSpatialIndexBBox): boolean;
|
|
51
|
+
all(): AcEdSpatialQueryResultItem[];
|
|
52
|
+
createChildIndex(group: AcTrGroup): AcTrSpatialIndex<AcEdSpatialQueryResultItem> | undefined;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=AcTrHierarchicalSpatialIndex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcTrHierarchicalSpatialIndex.d.ts","sourceRoot":"","sources":["../../src/spatialIndex/AcTrHierarchicalSpatialIndex.ts"],"names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assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __values = (this && this.__values) || function(o) {
|
|
13
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
14
|
+
if (m) return m.call(o);
|
|
15
|
+
if (o && typeof o.length === "number") return {
|
|
16
|
+
next: function () {
|
|
17
|
+
if (o && i >= o.length) o = void 0;
|
|
18
|
+
return { value: o && o[i++], done: !o };
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
22
|
+
};
|
|
23
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
24
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
25
|
+
if (!m) return o;
|
|
26
|
+
var i = m.call(o), r, ar = [], e;
|
|
27
|
+
try {
|
|
28
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
29
|
+
}
|
|
30
|
+
catch (error) { e = { error: error }; }
|
|
31
|
+
finally {
|
|
32
|
+
try {
|
|
33
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
34
|
+
}
|
|
35
|
+
finally { if (e) throw e.error; }
|
|
36
|
+
}
|
|
37
|
+
return ar;
|
|
38
|
+
};
|
|
39
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
40
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
41
|
+
if (ar || !(i in from)) {
|
|
42
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
43
|
+
ar[i] = from[i];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
47
|
+
};
|
|
48
|
+
import { AcTrLinearSpatialIndex } from './AcTrLinearSpatialIndex';
|
|
49
|
+
import { AcTrRBushSpatialIndex } from './AcTrRBushSpatialIndex';
|
|
50
|
+
/**
|
|
51
|
+
* A two-level (hierarchical) spatial index designed for complex CAD
|
|
52
|
+
* scene structures such as blocks, groups, layers, or nested entities.
|
|
53
|
+
*
|
|
54
|
+
* The index consists of:
|
|
55
|
+
*
|
|
56
|
+
* 1. A first-level spatial index that stores coarse bounding boxes
|
|
57
|
+
* (AcEdSpatialQueryResultItem) and maps each result to an `id`.
|
|
58
|
+
*
|
|
59
|
+
* 2. A second-level map from `id` to another spatial index, which
|
|
60
|
+
* contains more detailed spatial data for that specific entity,
|
|
61
|
+
* block, or group.
|
|
62
|
+
*
|
|
63
|
+
* Spatial queries are executed in two phases:
|
|
64
|
+
* - First, the query is performed against the root spatial index to
|
|
65
|
+
* find candidate items.
|
|
66
|
+
* - Then, for each candidate, the corresponding second-level spatial
|
|
67
|
+
* index (if present) is queried for more precise results.
|
|
68
|
+
* - Results from both levels are merged into a single query result.
|
|
69
|
+
*
|
|
70
|
+
* This design allows:
|
|
71
|
+
* - Mixing different spatial index implementations (e.g. R-tree and
|
|
72
|
+
* linear scan) at different hierarchy levels
|
|
73
|
+
* - Efficient querying of large, nested CAD datasets
|
|
74
|
+
* - Lazy or selective construction of fine-grained spatial indexes
|
|
75
|
+
*
|
|
76
|
+
* This class is particularly suitable for CAD viewers and editors
|
|
77
|
+
* where entities are grouped hierarchically but still require fast
|
|
78
|
+
* spatial queries such as selection, picking, and hit-testing.
|
|
79
|
+
*/
|
|
80
|
+
var AcTrHierarchicalSpatialIndex = /** @class */ (function () {
|
|
81
|
+
function AcTrHierarchicalSpatialIndex(rootIndex) {
|
|
82
|
+
this.childIndexes = new Map();
|
|
83
|
+
this.rootIndex = rootIndex !== null && rootIndex !== void 0 ? rootIndex : new AcTrRBushSpatialIndex();
|
|
84
|
+
}
|
|
85
|
+
/** Register second-level index for an id */
|
|
86
|
+
AcTrHierarchicalSpatialIndex.prototype.setChildIndex = function (id, index) {
|
|
87
|
+
this.childIndexes.set(id, index);
|
|
88
|
+
};
|
|
89
|
+
/** Remove second-level index */
|
|
90
|
+
AcTrHierarchicalSpatialIndex.prototype.removeChildIndex = function (id) {
|
|
91
|
+
this.childIndexes.delete(id);
|
|
92
|
+
};
|
|
93
|
+
AcTrHierarchicalSpatialIndex.prototype.insert = function (item) {
|
|
94
|
+
var _a;
|
|
95
|
+
this.rootIndex.insert(item);
|
|
96
|
+
(_a = this.childIndexes.get(item.id)) === null || _a === void 0 ? void 0 : _a.insert(item);
|
|
97
|
+
};
|
|
98
|
+
AcTrHierarchicalSpatialIndex.prototype.load = function (items) {
|
|
99
|
+
this.rootIndex.load(items);
|
|
100
|
+
};
|
|
101
|
+
AcTrHierarchicalSpatialIndex.prototype.remove = function (item, equals) {
|
|
102
|
+
this.rootIndex.remove(item, equals);
|
|
103
|
+
this.childIndexes.delete(item.id);
|
|
104
|
+
};
|
|
105
|
+
AcTrHierarchicalSpatialIndex.prototype.removeById = function (id) {
|
|
106
|
+
this.rootIndex.removeById(id);
|
|
107
|
+
this.childIndexes.delete(id);
|
|
108
|
+
};
|
|
109
|
+
AcTrHierarchicalSpatialIndex.prototype.clear = function () {
|
|
110
|
+
this.rootIndex.clear();
|
|
111
|
+
this.childIndexes.forEach(function (i) { return i.clear(); });
|
|
112
|
+
};
|
|
113
|
+
AcTrHierarchicalSpatialIndex.prototype.search = function (bbox) {
|
|
114
|
+
var e_1, _a;
|
|
115
|
+
var level1 = this.rootIndex.search(bbox);
|
|
116
|
+
var result = [];
|
|
117
|
+
try {
|
|
118
|
+
for (var level1_1 = __values(level1), level1_1_1 = level1_1.next(); !level1_1_1.done; level1_1_1 = level1_1.next()) {
|
|
119
|
+
var hit = level1_1_1.value;
|
|
120
|
+
var child = this.childIndexes.get(hit.id);
|
|
121
|
+
if (!child) {
|
|
122
|
+
result.push(hit);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
var level2 = child.search(bbox);
|
|
126
|
+
result.push(__assign(__assign({}, hit), { children: level2 }));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
130
|
+
finally {
|
|
131
|
+
try {
|
|
132
|
+
if (level1_1_1 && !level1_1_1.done && (_a = level1_1.return)) _a.call(level1_1);
|
|
133
|
+
}
|
|
134
|
+
finally { if (e_1) throw e_1.error; }
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
};
|
|
138
|
+
AcTrHierarchicalSpatialIndex.prototype.collides = function (bbox) {
|
|
139
|
+
var _this = this;
|
|
140
|
+
if (!this.rootIndex.collides(bbox))
|
|
141
|
+
return false;
|
|
142
|
+
var level1 = this.rootIndex.search(bbox);
|
|
143
|
+
return level1.some(function (hit) {
|
|
144
|
+
var child = _this.childIndexes.get(hit.id);
|
|
145
|
+
return child ? child.collides(bbox) : true;
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
AcTrHierarchicalSpatialIndex.prototype.all = function () {
|
|
149
|
+
var e_2, _a;
|
|
150
|
+
var result = [];
|
|
151
|
+
try {
|
|
152
|
+
for (var _b = __values(this.rootIndex.all()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
153
|
+
var hit = _c.value;
|
|
154
|
+
var child = this.childIndexes.get(hit.id);
|
|
155
|
+
if (child)
|
|
156
|
+
result.push.apply(result, __spreadArray([], __read(child.all()), false));
|
|
157
|
+
else
|
|
158
|
+
result.push(hit);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
162
|
+
finally {
|
|
163
|
+
try {
|
|
164
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
165
|
+
}
|
|
166
|
+
finally { if (e_2) throw e_2.error; }
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
};
|
|
170
|
+
AcTrHierarchicalSpatialIndex.prototype.createChildIndex = function (group) {
|
|
171
|
+
var size = group.boxes.length;
|
|
172
|
+
var spatialIndex = undefined;
|
|
173
|
+
if (size > AcTrHierarchicalSpatialIndex.THRESHOLD) {
|
|
174
|
+
spatialIndex = new AcTrRBushSpatialIndex();
|
|
175
|
+
}
|
|
176
|
+
else if (size > 0) {
|
|
177
|
+
spatialIndex = new AcTrLinearSpatialIndex();
|
|
178
|
+
}
|
|
179
|
+
if (spatialIndex) {
|
|
180
|
+
group.boxes.forEach(function (box) {
|
|
181
|
+
spatialIndex.insert(box);
|
|
182
|
+
});
|
|
183
|
+
this.setChildIndex(group.objectId, spatialIndex);
|
|
184
|
+
}
|
|
185
|
+
return spatialIndex;
|
|
186
|
+
};
|
|
187
|
+
AcTrHierarchicalSpatialIndex.THRESHOLD = 100;
|
|
188
|
+
return AcTrHierarchicalSpatialIndex;
|
|
189
|
+
}());
|
|
190
|
+
export { AcTrHierarchicalSpatialIndex };
|
|
191
|
+
//# sourceMappingURL=AcTrHierarchicalSpatialIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcTrHierarchicalSpatialIndex.js","sourceRoot":"","sources":["../../src/spatialIndex/AcTrHierarchicalSpatialIndex.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAG/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH;IAKE,sCAAY,SAAwD;QAFnD,iBAAY,GAAG,IAAI,GAAG,EAA4B,CAAA;QAGjE,IAAI,CAAC,SAAS,GAAG,SAAS,aAAT,SAAS,cA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ox } from './AcTrSpatialIndex';
|
|
4
|
+
/**
|
|
5
|
+
* A simple spatial index implementation that performs linear scanning
|
|
6
|
+
* over all stored bounding boxes.
|
|
7
|
+
*
|
|
8
|
+
* This index does not build any spatial acceleration structure. All
|
|
9
|
+
* spatial queries are executed by iterating through the full item list
|
|
10
|
+
* and testing bounding-box intersection one by one.
|
|
11
|
+
*
|
|
12
|
+
* Typical use cases:
|
|
13
|
+
* - Small datasets where index construction overhead is unnecessary
|
|
14
|
+
* - Highly dynamic data with frequent insert/remove operations
|
|
15
|
+
* - Debugging or validation of spatial query correctness
|
|
16
|
+
* - Fallback implementation when spatial indexing is not available
|
|
17
|
+
*
|
|
18
|
+
* Time complexity:
|
|
19
|
+
* - Insert / Remove: O(1)
|
|
20
|
+
* - Search / Collides: O(n)
|
|
21
|
+
*
|
|
22
|
+
* This implementation is memory-efficient and predictable, but does
|
|
23
|
+
* not scale well for large numbers of items.
|
|
24
|
+
*/
|
|
25
|
+
export declare class AcTrLinearSpatialIndex implements AcTrSpatialIndex {
|
|
26
|
+
private items;
|
|
27
|
+
insert(item: AcEdSpatialQueryResultItem): void;
|
|
28
|
+
load(items: readonly AcEdSpatialQueryResultItem[]): void;
|
|
29
|
+
remove(item: AcEdSpatialQueryResultItem): void;
|
|
30
|
+
removeById(id: AcDbObjectId): void;
|
|
31
|
+
clear(): void;
|
|
32
|
+
search(bbox: AcTrSpatialIndexBBox): AcEdSpatialQueryResultItem[];
|
|
33
|
+
collides(bbox: AcTrSpatialIndexBBox): boolean;
|
|
34
|
+
all(): AcEdSpatialQueryResultItem[];
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=AcTrLinearSpatialIndex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcTrLinearSpatialIndex.d.ts","sourceRoot":"","sources":["../../src/spatialIndex/AcTrLinearSpatialIndex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAE3E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,sBAAuB,YAAW,gBAAgB;IAC7D,OAAO,CAAC,KAAK,CAAmC;IAEhD,MAAM,CAAC,IAAI,EAAE,0BAA0B,GAAG,IAAI;IAI9C,IAAI,CAAC,KAAK,EAAE,SAAS,0BAA0B,EAAE,GAAG,IAAI;IAIxD,MAAM,CAAC,IAAI,EAAE,0BAA0B,GAAG,IAAI;IAI9C,UAAU,CAAC,EAAE,EAAE,YAAY;IAI3B,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,IAAI,EAAE,oBAAoB,GAAG,0BAA0B,EAAE;IAIhE,QAAQ,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO;IAI7C,GAAG,IAAI,0BAA0B,EAAE;CAGpC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
|
5
|
+
try {
|
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
+
}
|
|
8
|
+
catch (error) { e = { error: error }; }
|
|
9
|
+
finally {
|
|
10
|
+
try {
|
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
+
}
|
|
13
|
+
finally { if (e) throw e.error; }
|
|
14
|
+
}
|
|
15
|
+
return ar;
|
|
16
|
+
};
|
|
17
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
+
if (ar || !(i in from)) {
|
|
20
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
+
ar[i] = from[i];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A simple spatial index implementation that performs linear scanning
|
|
28
|
+
* over all stored bounding boxes.
|
|
29
|
+
*
|
|
30
|
+
* This index does not build any spatial acceleration structure. All
|
|
31
|
+
* spatial queries are executed by iterating through the full item list
|
|
32
|
+
* and testing bounding-box intersection one by one.
|
|
33
|
+
*
|
|
34
|
+
* Typical use cases:
|
|
35
|
+
* - Small datasets where index construction overhead is unnecessary
|
|
36
|
+
* - Highly dynamic data with frequent insert/remove operations
|
|
37
|
+
* - Debugging or validation of spatial query correctness
|
|
38
|
+
* - Fallback implementation when spatial indexing is not available
|
|
39
|
+
*
|
|
40
|
+
* Time complexity:
|
|
41
|
+
* - Insert / Remove: O(1)
|
|
42
|
+
* - Search / Collides: O(n)
|
|
43
|
+
*
|
|
44
|
+
* This implementation is memory-efficient and predictable, but does
|
|
45
|
+
* not scale well for large numbers of items.
|
|
46
|
+
*/
|
|
47
|
+
var AcTrLinearSpatialIndex = /** @class */ (function () {
|
|
48
|
+
function AcTrLinearSpatialIndex() {
|
|
49
|
+
this.items = [];
|
|
50
|
+
}
|
|
51
|
+
AcTrLinearSpatialIndex.prototype.insert = function (item) {
|
|
52
|
+
this.items.push(item);
|
|
53
|
+
};
|
|
54
|
+
AcTrLinearSpatialIndex.prototype.load = function (items) {
|
|
55
|
+
var _a;
|
|
56
|
+
(_a = this.items).push.apply(_a, __spreadArray([], __read(items), false));
|
|
57
|
+
};
|
|
58
|
+
AcTrLinearSpatialIndex.prototype.remove = function (item) {
|
|
59
|
+
this.items = this.items.filter(function (i) { return i.id !== item.id; });
|
|
60
|
+
};
|
|
61
|
+
AcTrLinearSpatialIndex.prototype.removeById = function (id) {
|
|
62
|
+
this.items = this.items.filter(function (i) { return i.id !== id; });
|
|
63
|
+
};
|
|
64
|
+
AcTrLinearSpatialIndex.prototype.clear = function () {
|
|
65
|
+
this.items.length = 0;
|
|
66
|
+
};
|
|
67
|
+
AcTrLinearSpatialIndex.prototype.search = function (bbox) {
|
|
68
|
+
return this.items.filter(function (i) { return intersects(i, bbox); });
|
|
69
|
+
};
|
|
70
|
+
AcTrLinearSpatialIndex.prototype.collides = function (bbox) {
|
|
71
|
+
return this.items.some(function (i) { return intersects(i, bbox); });
|
|
72
|
+
};
|
|
73
|
+
AcTrLinearSpatialIndex.prototype.all = function () {
|
|
74
|
+
return __spreadArray([], __read(this.items), false);
|
|
75
|
+
};
|
|
76
|
+
return AcTrLinearSpatialIndex;
|
|
77
|
+
}());
|
|
78
|
+
export { AcTrLinearSpatialIndex };
|
|
79
|
+
function intersects(a, b) {
|
|
80
|
+
return !(a.maxX < b.minX ||
|
|
81
|
+
a.minX > b.maxX ||
|
|
82
|
+
a.maxY < b.minY ||
|
|
83
|
+
a.minY > b.maxY);
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=AcTrLinearSpatialIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcTrLinearSpatialIndex.js","sourceRoot":"","sources":["../../src/spatialIndex/AcTrLinearSpatialIndex.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAKA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IAAA;QACU,UAAK,GAAiC,EAAE,CAAA;IAiClD,CAAC;IA/BC,uCAAM,GAAN,UAAO,IAAgC;QACrC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAED,qCAAI,GAAJ,UAAK,KAA4C;;QAC/C,CAAA,KAAA,IAAI,CAAC,KAAK,CAAA,CAAC,IAAI,oCAAI,KAAK,WAAC;IAC3B,CAAC;IAED,uCAAM,GAAN,UAAO,IAAgC;QACrC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC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../editor/view';
|
|
3
|
+
import { AcTrSpatialIndex, AcTrSpatialIndexBBox } from './AcTrSpatialIndex';
|
|
4
|
+
export declare class AcTrRBushSpatialIndex implements AcTrSpatialIndex {
|
|
5
|
+
private readonly tree;
|
|
6
|
+
constructor(maxEntries?: number);
|
|
7
|
+
insert(item: AcEdSpatialQueryResultItem): void;
|
|
8
|
+
load(items: readonly AcEdSpatialQueryResultItem[]): void;
|
|
9
|
+
remove(item: AcEdSpatialQueryResultItem, equals?: (a: AcEdSpatialQueryResultItem, b: AcEdSpatialQueryResultItem) => boolean): void;
|
|
10
|
+
removeById(id: AcDbObjectId): void;
|
|
11
|
+
clear(): void;
|
|
12
|
+
search(bbox: AcTrSpatialIndexBBox): AcEdSpatialQueryResultItem[];
|
|
13
|
+
collides(bbox: AcTrSpatialIndexBBox): boolean;
|
|
14
|
+
all(): AcEdSpatialQueryResultItem[];
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=AcTrRBushSpatialIndex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcTrRBushSpatialIndex.d.ts","sourceRoot":"","sources":["../../src/spatialIndex/AcTrRBushSpatialIndex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAGpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAE3E,qBAAa,qBAAsB,YAAW,gBAAgB;IAC5D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmC;gBAE5C,UAAU,CAAC,EAAE,MAAM;IAI/B,MAAM,CAAC,IAAI,EAAE,0BAA0B;IAIvC,IAAI,CAAC,KAAK,EAAE,SAAS,0BAA0B,EAAE;IAIjD,MAAM,CACJ,IAAI,EAAE,0BAA0B,EAChC,MAAM,CAAC,EAAE,CACP,CAAC,EAAE,0BAA0B,EAC7B,CAAC,EAAE,0BAA0B,KAC1B,OAAO,GACX,IAAI;IAIP,UAAU,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI;IAclC,KAAK;IAIL,MAAM,CAAC,IAAI,EAAE,oBAAoB,GAAG,0BAA0B,EAAE;IAIhE,QAAQ,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO;IAI7C,GAAG,IAAI,0BAA0B,EAAE;CAGpC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import RBush from 'rbush';
|
|
2
|
+
var AcTrRBushSpatialIndex = /** @class */ (function () {
|
|
3
|
+
function AcTrRBushSpatialIndex(maxEntries) {
|
|
4
|
+
this.tree = new RBush(maxEntries);
|
|
5
|
+
}
|
|
6
|
+
AcTrRBushSpatialIndex.prototype.insert = function (item) {
|
|
7
|
+
this.tree.insert(item);
|
|
8
|
+
};
|
|
9
|
+
AcTrRBushSpatialIndex.prototype.load = function (items) {
|
|
10
|
+
this.tree.load(items);
|
|
11
|
+
};
|
|
12
|
+
AcTrRBushSpatialIndex.prototype.remove = function (item, equals) {
|
|
13
|
+
this.tree.remove(item, equals);
|
|
14
|
+
};
|
|
15
|
+
AcTrRBushSpatialIndex.prototype.removeById = function (id) {
|
|
16
|
+
// Set minX, minY, maxX, and maxY to 0 in order to pass build
|
|
17
|
+
this.tree.remove({
|
|
18
|
+
minX: 0,
|
|
19
|
+
minY: 0,
|
|
20
|
+
maxX: 0,
|
|
21
|
+
maxY: 0,
|
|
22
|
+
id: id
|
|
23
|
+
}, function (a, b) { return a.id === b.id; });
|
|
24
|
+
};
|
|
25
|
+
AcTrRBushSpatialIndex.prototype.clear = function () {
|
|
26
|
+
this.tree.clear();
|
|
27
|
+
};
|
|
28
|
+
AcTrRBushSpatialIndex.prototype.search = function (bbox) {
|
|
29
|
+
return this.tree.search(bbox);
|
|
30
|
+
};
|
|
31
|
+
AcTrRBushSpatialIndex.prototype.collides = function (bbox) {
|
|
32
|
+
return this.tree.collides(bbox);
|
|
33
|
+
};
|
|
34
|
+
AcTrRBushSpatialIndex.prototype.all = function () {
|
|
35
|
+
return this.tree.all();
|
|
36
|
+
};
|
|
37
|
+
return AcTrRBushSpatialIndex;
|
|
38
|
+
}());
|
|
39
|
+
export { AcTrRBushSpatialIndex };
|
|
40
|
+
//# sourceMappingURL=AcTrRBushSpatialIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcTrRBushSpatialIndex.js","sourceRoot":"","sources":["../../src/spatialIndex/AcTrRBushSpatialIndex.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB;IAGE,+BAAY,UAAmB;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,KAAK,CAA6B,UAAU,CAAC,CAAA;IAC/D,CAAC;IAED,sCAAM,GAAN,UAAO,IAAgC;QACrC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACxB,CAAC;IAED,oCAAI,GAAJ,UAAK,KAA4C;QAC/C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACvB,CAAC;IAED,sCAAM,GAAN,UACE,IAAgC,EAChC,MAGY;QAEZ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAChC,CAAC;IAED,0CAAU,GAAV,UAAW,EAAgB;QACzB,6DAA6D;QAC7D,IAAI,CAAC,IAAI,CAAC,MAAM,CACd;YACE,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,CAAC;YACP,EAAE,EAAE,EAAE;SACP,EACD,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,EAAb,CAAa,CACxB,CAAA;IACH,CAAC;IAED,qCAAK,GAAL;QACE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;IACnB,CAAC;IAED,sCAAM,GAAN,UAAO,IAA0B;QAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC/B,CAAC;IAED,wCAAQ,GAAR,UAAS,IAA0B;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACjC,CAAC;IAED,mCAAG,GAAH;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;IACxB,CAAC;IACH,4BAAC;AAAD,CAAC,AAtDD,IAsDC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { AcDbObjectId } from '@mlightcad/data-model';
|
|
2
|
+
import { AcEdSpatialQueryResultItem } from '../editor/view';
|
|
3
|
+
export type AcTrSpatialIndexBBox = {
|
|
4
|
+
minX: number;
|
|
5
|
+
minY: number;
|
|
6
|
+
maxX: number;
|
|
7
|
+
maxY: number;
|
|
8
|
+
};
|
|
9
|
+
export interface AcTrSpatialIndex<T extends AcEdSpatialQueryResultItem = AcEdSpatialQueryResultItem> {
|
|
10
|
+
/**
|
|
11
|
+
* Inserts an item. To insert many items at once, use `load()`.
|
|
12
|
+
*
|
|
13
|
+
* @param item The item to insert.
|
|
14
|
+
*/
|
|
15
|
+
insert(item: T): void;
|
|
16
|
+
/**
|
|
17
|
+
* Bulk-inserts the given items into the tree.
|
|
18
|
+
*
|
|
19
|
+
* Bulk insertion is usually ~2-3 times faster than inserting items one by
|
|
20
|
+
* one. After bulk loading (bulk insertion into an empty tree), subsequent
|
|
21
|
+
* query performance is also ~20-30% better.
|
|
22
|
+
*
|
|
23
|
+
* Note that when you do bulk insertion into an existing tree, it bulk-loads
|
|
24
|
+
* the given data into a separate tree and inserts the smaller tree into the
|
|
25
|
+
* larger tree. This means that bulk insertion works very well for clustered
|
|
26
|
+
* data (where items in one update are close to each other), but makes query
|
|
27
|
+
* performance worse if the data is scattered.
|
|
28
|
+
*
|
|
29
|
+
* @param items The items to load.
|
|
30
|
+
*/
|
|
31
|
+
load(items: readonly T[]): void;
|
|
32
|
+
/**
|
|
33
|
+
* Removes a previously inserted item, comparing by reference.
|
|
34
|
+
*
|
|
35
|
+
* To remove all items, use `clear()`.
|
|
36
|
+
*
|
|
37
|
+
* @param item The item to remove.
|
|
38
|
+
* @param equals A custom function that allows comparing by value instead.
|
|
39
|
+
* Useful when you have only a copy of the object you need
|
|
40
|
+
* removed (e.g. loaded from server).
|
|
41
|
+
*/
|
|
42
|
+
remove(item: T, equals?: (a: T, b: T) => boolean): void;
|
|
43
|
+
/**
|
|
44
|
+
* Removes a previously inserted item by its id.
|
|
45
|
+
*
|
|
46
|
+
* To remove all items, use `clear()`.
|
|
47
|
+
*
|
|
48
|
+
* @param id The id of a previously inserted item
|
|
49
|
+
*/
|
|
50
|
+
removeById(id: AcDbObjectId): void;
|
|
51
|
+
/**
|
|
52
|
+
* Removes all items.
|
|
53
|
+
*/
|
|
54
|
+
clear(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Returns an array of data items (points or rectangles) that the given
|
|
57
|
+
* bounding box intersects.
|
|
58
|
+
*
|
|
59
|
+
* Note that the search method accepts a bounding box in `{minX, minY, maxX,
|
|
60
|
+
* maxY}` format regardless of the data format.
|
|
61
|
+
*
|
|
62
|
+
* @param box The bounding box in which to search.
|
|
63
|
+
*/
|
|
64
|
+
search(box: AcTrSpatialIndexBBox): T[];
|
|
65
|
+
/**
|
|
66
|
+
* Returns all items contained in the tree.
|
|
67
|
+
*/
|
|
68
|
+
all(): T[];
|
|
69
|
+
/**
|
|
70
|
+
* Returns `true` if there are any items intersecting the given bounding
|
|
71
|
+
* box, otherwise `false`.
|
|
72
|
+
*
|
|
73
|
+
* @param box The bounding box in which to search.
|
|
74
|
+
*/
|
|
75
|
+
collides(box: AcTrSpatialIndexBBox): boolean;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=AcTrSpatialIndex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcTrSpatialIndex.d.ts","sourceRoot":"","sources":["../../src/spatialIndex/AcTrSpatialIndex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAA;AAE3D,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,WAAW,gBAAgB,CAC/B,CAAC,SAAS,0BAA0B,GAAG,0BAA0B;IAEjE;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;IAErB;;;;;;;;;;;;;;OAcG;IACH,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAA;IAE/B;;;;;;;;;OASG;IACH,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,CAAA;IAEvD;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAAA;IAElC;;OAEG;IACH,KAAK,IAAI,IAAI,CAAA;IAEb;;;;;;;;OAQG;IACH,MAAM,CAAC,GAAG,EAAE,oBAAoB,GAAG,CAAC,EAAE,CAAA;IAEtC;;OAEG;IACH,GAAG,IAAI,CAAC,EAAE,CAAA;IAEV;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAA;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcTrSpatialIndex.js","sourceRoot":"","sources":["../../src/spatialIndex/AcTrSpatialIndex.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/spatialIndex/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/spatialIndex/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oBAAoB,CAAA"}
|
package/lib/view/AcTrLayer.d.ts
CHANGED
|
@@ -129,7 +129,7 @@ export declare class AcTrLayer {
|
|
|
129
129
|
* @param objectId Input the object id of the entity to remove
|
|
130
130
|
* @returns Return true if remove the specified entity successfully. Otherwise, return false.
|
|
131
131
|
*/
|
|
132
|
-
removeEntity(
|
|
132
|
+
removeEntity(objectId: AcDbObjectId): boolean;
|
|
133
133
|
/**
|
|
134
134
|
* Update the specified entity in this layer.
|
|
135
135
|
* @param entity Input the entity to update
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcTrLayer.d.ts","sourceRoot":"","sources":["../../src/view/AcTrLayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACX,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEzC;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,GAAG;IACnD,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,SAAS;IACpB;;OAEG;IACH,OAAO,CAAC,KAAK,CAAQ;IACrB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAkB;IAEhC;;OAEG;IACH,OAAO,CAAC,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B;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,YAAY,EAAE;IAM1B;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,YAAY,EAAE;CAK7B"}
|
package/lib/view/AcTrLayer.js
CHANGED
|
@@ -181,9 +181,8 @@ var AcTrLayer = /** @class */ (function () {
|
|
|
181
181
|
* @param objectId Input the object id of the entity to remove
|
|
182
182
|
* @returns Return true if remove the specified entity successfully. Otherwise, return false.
|
|
183
183
|
*/
|
|
184
|
-
AcTrLayer.prototype.removeEntity = function (
|
|
185
|
-
|
|
186
|
-
throw new Error('Not implemented yet!');
|
|
184
|
+
AcTrLayer.prototype.removeEntity = function (objectId) {
|
|
185
|
+
return this._group.removeEntity(objectId);
|
|
187
186
|
};
|
|
188
187
|
/**
|
|
189
188
|
* Update the specified entity in this layer.
|