build-dxf 0.1.54 → 0.1.56
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/package.json +1 -1
- package/src/build.d.ts +9 -2
- package/src/build.js +39 -9
- package/src/utils/DxfSystem/utils/tools.d.ts +4 -1
- package/src/utils/Quadtree.d.ts +1 -1
package/package.json
CHANGED
package/src/build.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DxfSystem } from './utils/DxfSystem';
|
|
2
|
-
import { OriginalDataItem, SetDataOption } from './utils/DxfSystem/type';
|
|
2
|
+
import { LineUserData, OriginalDataItem, SetDataOption } from './utils/DxfSystem/type';
|
|
3
3
|
import { WhiteModel } from './utils/DxfSystem/plugin/ModelDataPlugin/components/WhiteModel';
|
|
4
|
+
import { LineSegment } from './utils';
|
|
4
5
|
import * as THREE from "three";
|
|
5
6
|
export { Dxf } from './utils/DxfSystem/components/Dxf';
|
|
6
7
|
export * from './utils/DxfSystem/DxfSystem';
|
|
@@ -83,4 +84,10 @@ export declare function getGlobalDxfSystem(): DxfSystem | null;
|
|
|
83
84
|
* @param direction
|
|
84
85
|
* @returns
|
|
85
86
|
*/
|
|
86
|
-
export declare function hasCircle(lineData: OriginalDataItem[], startIndex: number, direction: any):
|
|
87
|
+
export declare function hasCircle(lineData: OriginalDataItem[], startIndex: number, direction: any): {
|
|
88
|
+
readonly originalIndices: number[];
|
|
89
|
+
readonly indices: number[];
|
|
90
|
+
circle: LineSegment<Record<string, any>>[];
|
|
91
|
+
originalLines: LineSegment<LineUserData>[];
|
|
92
|
+
lines: LineSegment<Record<string, any>>[];
|
|
93
|
+
} | null;
|
package/src/build.js
CHANGED
|
@@ -711,9 +711,9 @@ class Quadtree {
|
|
|
711
711
|
* 插入线段节点
|
|
712
712
|
* @param node 线段节点
|
|
713
713
|
*/
|
|
714
|
-
insert(node) {
|
|
714
|
+
insert(node, userData) {
|
|
715
715
|
if (node instanceof LineSegment) {
|
|
716
|
-
this.insert({ line: node, userData: {} });
|
|
716
|
+
this.insert({ line: node, userData: userData ?? {} });
|
|
717
717
|
return;
|
|
718
718
|
}
|
|
719
719
|
if (!this.isLeaf) {
|
|
@@ -5443,8 +5443,9 @@ function createPointVirtualGrid(lines) {
|
|
|
5443
5443
|
}
|
|
5444
5444
|
function createQuadtree(lines) {
|
|
5445
5445
|
const quadtree = new Quadtree(Box2.fromByLineSegment(...lines));
|
|
5446
|
-
for (
|
|
5447
|
-
|
|
5446
|
+
for (let i = 0; i < lines.length; i++) {
|
|
5447
|
+
const seg = lines[i];
|
|
5448
|
+
quadtree.insert(seg, { index: i });
|
|
5448
5449
|
}
|
|
5449
5450
|
return quadtree;
|
|
5450
5451
|
}
|
|
@@ -5454,10 +5455,20 @@ function mToMm(value) {
|
|
|
5454
5455
|
function mmTom(value) {
|
|
5455
5456
|
return Number((value / 1e3).toFixed(4));
|
|
5456
5457
|
}
|
|
5458
|
+
function getLineIndexByCenter(targetLines, lines) {
|
|
5459
|
+
const grid = createQuadtree(lines);
|
|
5460
|
+
const indices = targetLines.map((line) => {
|
|
5461
|
+
const res = grid.queryPoint(line.center);
|
|
5462
|
+
if (res.length) return res[0].userData.index;
|
|
5463
|
+
return -1;
|
|
5464
|
+
});
|
|
5465
|
+
return indices;
|
|
5466
|
+
}
|
|
5457
5467
|
const tools = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5458
5468
|
__proto__: null,
|
|
5459
5469
|
createPointVirtualGrid,
|
|
5460
5470
|
createQuadtree,
|
|
5471
|
+
getLineIndexByCenter,
|
|
5461
5472
|
mToMm,
|
|
5462
5473
|
mmTom
|
|
5463
5474
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
@@ -19869,20 +19880,39 @@ function getGlobalDxfSystem() {
|
|
|
19869
19880
|
function hasCircle(lineData, startIndex, direction) {
|
|
19870
19881
|
let lines = originalDataToLineData(lineData).lineSegments;
|
|
19871
19882
|
const center = lines[startIndex].center;
|
|
19872
|
-
|
|
19873
|
-
|
|
19874
|
-
|
|
19883
|
+
let findlines = lineSegmentClipping(lines.map((line2) => line2.clone()), 1e-9);
|
|
19884
|
+
let removeSet = findDiscretePointLine2(findlines, /* @__PURE__ */ new Set(), true);
|
|
19885
|
+
findlines = findlines.filter((line2) => !removeSet.has(line2));
|
|
19886
|
+
const list = findlines.filter((line2) => line2.userData.isBayWindow && line2.isPointOnSegment(center));
|
|
19887
|
+
if (list.length === 0) return null;
|
|
19875
19888
|
const miniCircles = new MiniCircles(), line = list[0], direct = Point.from(direction), entity = line.center.add(direct.multiplyScalar(1e-8)), path = /* @__PURE__ */ new Set([line]);
|
|
19876
19889
|
const result = miniCircles.findSameSidePath({
|
|
19877
19890
|
line,
|
|
19878
19891
|
currentPoint: line.start,
|
|
19879
19892
|
exitPoint: line.start,
|
|
19880
19893
|
entity: entity.clone(),
|
|
19881
|
-
grid:
|
|
19894
|
+
grid: findlines,
|
|
19882
19895
|
side: Side.IN,
|
|
19883
19896
|
path
|
|
19884
19897
|
});
|
|
19885
|
-
|
|
19898
|
+
if (result) {
|
|
19899
|
+
let indices = null;
|
|
19900
|
+
let originalDataIndices = null;
|
|
19901
|
+
return {
|
|
19902
|
+
get originalIndices() {
|
|
19903
|
+
if (!originalDataIndices) originalDataIndices = getLineIndexByCenter(result, lines).filter((i) => i > -1);
|
|
19904
|
+
return originalDataIndices;
|
|
19905
|
+
},
|
|
19906
|
+
get indices() {
|
|
19907
|
+
if (!indices) indices = getLineIndexByCenter(result, findlines).filter((i) => i > -1);
|
|
19908
|
+
return indices;
|
|
19909
|
+
},
|
|
19910
|
+
circle: result,
|
|
19911
|
+
originalLines: lines,
|
|
19912
|
+
lines: findlines
|
|
19913
|
+
};
|
|
19914
|
+
}
|
|
19915
|
+
return null;
|
|
19886
19916
|
}
|
|
19887
19917
|
export {
|
|
19888
19918
|
ArrayMap as A,
|
|
@@ -2,6 +2,9 @@ import { PointVirtualGrid } from '../../PointVirtualGrid';
|
|
|
2
2
|
import { LineSegment } from '../../LineSegment';
|
|
3
3
|
import { Quadtree } from '../../Quadtree';
|
|
4
4
|
export declare function createPointVirtualGrid<T = any>(lines: LineSegment<T>[]): PointVirtualGrid<LineSegment<T>>;
|
|
5
|
-
export declare function createQuadtree<T = any>(lines: LineSegment<T>[]): Quadtree<
|
|
5
|
+
export declare function createQuadtree<T = any>(lines: LineSegment<T>[]): Quadtree<{
|
|
6
|
+
index: number;
|
|
7
|
+
}>;
|
|
6
8
|
export declare function mToMm(value: number): number;
|
|
7
9
|
export declare function mmTom(value: number): number;
|
|
10
|
+
export declare function getLineIndexByCenter(targetLines: LineSegment[], lines: LineSegment[]): number[];
|
package/src/utils/Quadtree.d.ts
CHANGED