build-dxf 0.0.32 → 0.0.34
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 +1 -0
- package/src/build.js +1560 -1371
- package/src/index.css +1 -1
- package/src/index.js +8 -7
- package/src/index3.js +697 -660
- package/src/utils/DxfSystem/components/Dxf copy.d.ts +276 -0
- package/src/utils/DxfSystem/components/Dxf.d.ts +45 -10
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/CommandFlowComponent.d.ts +1 -1
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/MergeLine.d.ts +3 -1
- package/src/utils/DxfSystem/plugin/Editor/components/CommandFlow/VerticalCorrection.d.ts +6 -3
- package/src/utils/PointVirtualGrid/index.d.ts +7 -2
- package/src/utils/Quadtree/LineSegment.d.ts +19 -0
- package/src/utils/Quadtree/Point.d.ts +6 -0
- package/src/utils/Quadtree/Quadtree.d.ts +6 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { Component } from '../../ComponentManager';
|
|
2
|
+
import { Point } from '../../Quadtree/Point';
|
|
3
|
+
import { Box2 } from '../../Quadtree/Box2';
|
|
4
|
+
import { LineSegment } from '../../Quadtree/LineSegment';
|
|
5
|
+
import { Quadtree, QuadtreeNode } from '../../Quadtree/Quadtree';
|
|
6
|
+
import * as THREE from "three";
|
|
7
|
+
type Unit = "Unitless" | "Inches" | "Feet" | "Miles" | "Millimeters" | "Centimeters" | "Meters" | "Kilometers" | "Microinches" | "Mils" | "Yards" | "Angstroms" | "Nanometers" | "Microns" | "Decimeters" | "Decameters" | "Hectometers" | "Gigameters" | "Astronomical units" | "Light years" | "Parsecs";
|
|
8
|
+
export interface OriginalDataItem {
|
|
9
|
+
start: {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
z?: number;
|
|
13
|
+
};
|
|
14
|
+
end: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
z?: number;
|
|
18
|
+
};
|
|
19
|
+
insetionArr: {
|
|
20
|
+
index: number;
|
|
21
|
+
p: {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
z?: number;
|
|
25
|
+
};
|
|
26
|
+
}[];
|
|
27
|
+
length: number;
|
|
28
|
+
isDoor?: boolean;
|
|
29
|
+
doorDirectConnection?: boolean;
|
|
30
|
+
drawDoorData?: {
|
|
31
|
+
start: {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
z?: number;
|
|
35
|
+
};
|
|
36
|
+
n: {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
z?: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
wallWidth?: number;
|
|
43
|
+
isWindow?: boolean;
|
|
44
|
+
isVerticalReferenceLine?: boolean;
|
|
45
|
+
drawWindow?: {
|
|
46
|
+
p: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
z?: number;
|
|
50
|
+
};
|
|
51
|
+
width: number;
|
|
52
|
+
full: boolean;
|
|
53
|
+
}[];
|
|
54
|
+
}
|
|
55
|
+
export type LineUserData = {
|
|
56
|
+
doorDirectConnection?: boolean;
|
|
57
|
+
isDoor?: boolean;
|
|
58
|
+
isWindow?: boolean;
|
|
59
|
+
isVerticalReferenceLine?: boolean;
|
|
60
|
+
wallWidth?: number;
|
|
61
|
+
drawWindow?: {
|
|
62
|
+
p: THREE.Vector3;
|
|
63
|
+
width: number;
|
|
64
|
+
full: boolean;
|
|
65
|
+
}[];
|
|
66
|
+
drawDoorData?: any;
|
|
67
|
+
quadtreeNode?: QuadtreeNode;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* [开始点, 结束点, 相交点, 是否是门, 索引]
|
|
71
|
+
*/
|
|
72
|
+
export type DataItem = [Point, Point, number[], boolean, number];
|
|
73
|
+
export type DrawData = {
|
|
74
|
+
unit: Unit;
|
|
75
|
+
line: [number, number, number, number, string][];
|
|
76
|
+
arc: [number, number, number, number, number, string][];
|
|
77
|
+
dimensionLine: number[][];
|
|
78
|
+
center: {
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
};
|
|
82
|
+
width: number;
|
|
83
|
+
height: number;
|
|
84
|
+
scale: number;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
export interface PointGroup {
|
|
90
|
+
points: Point[];
|
|
91
|
+
indices: number[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 将点云结构转换为DXF格式
|
|
95
|
+
*/
|
|
96
|
+
export declare class Dxf<TEventMap extends {} = {}> extends Component<{
|
|
97
|
+
setDta: {
|
|
98
|
+
originalData: OriginalDataItem[];
|
|
99
|
+
data: DataItem[];
|
|
100
|
+
};
|
|
101
|
+
lineOffset: {
|
|
102
|
+
wallsGroup: Point[][];
|
|
103
|
+
};
|
|
104
|
+
createGroup: {
|
|
105
|
+
groups: Point[][][];
|
|
106
|
+
};
|
|
107
|
+
} & TEventMap> {
|
|
108
|
+
static name: string;
|
|
109
|
+
shortLine: number;
|
|
110
|
+
width: number;
|
|
111
|
+
scale: number;
|
|
112
|
+
originalData: OriginalDataItem[];
|
|
113
|
+
data: DataItem[];
|
|
114
|
+
originalBox: Box2;
|
|
115
|
+
box: Box2;
|
|
116
|
+
pointsGroups: Point[][][];
|
|
117
|
+
wallsGroup: Point[][];
|
|
118
|
+
doors: DataItem[];
|
|
119
|
+
doorLineSegment: LineSegment[];
|
|
120
|
+
lineSegments: LineSegment<LineUserData>[];
|
|
121
|
+
originalZAverage: number;
|
|
122
|
+
static EndType: {
|
|
123
|
+
etOpenSquare: number;
|
|
124
|
+
etOpenRound: number;
|
|
125
|
+
etOpenButt: number;
|
|
126
|
+
};
|
|
127
|
+
static JoinType: {
|
|
128
|
+
jtSquare: number;
|
|
129
|
+
jtRound: number;
|
|
130
|
+
jtMiter: number;
|
|
131
|
+
};
|
|
132
|
+
/** 原始数据组
|
|
133
|
+
*/
|
|
134
|
+
get lines(): LineSegment<LineUserData>[];
|
|
135
|
+
/**初始化
|
|
136
|
+
* @param data 点云数据
|
|
137
|
+
* @param width 墙体宽度
|
|
138
|
+
* @param scale 缩放比例
|
|
139
|
+
*/
|
|
140
|
+
constructor(width?: number, scale?: number);
|
|
141
|
+
/**
|
|
142
|
+
* 预处理数据
|
|
143
|
+
* @param data
|
|
144
|
+
*/
|
|
145
|
+
preprocessing(data: OriginalDataItem[], axisAlignmentCorrection?: boolean): {
|
|
146
|
+
lineSegments: LineSegment<LineUserData>[];
|
|
147
|
+
data: OriginalDataItem[];
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* 设置
|
|
151
|
+
* @param data
|
|
152
|
+
* @param width
|
|
153
|
+
* @param scale
|
|
154
|
+
*/
|
|
155
|
+
set(data: OriginalDataItem[] | string, width?: number, scale?: number, axisAlignmentCorrection?: boolean): Promise<any>;
|
|
156
|
+
/** 创建分组
|
|
157
|
+
* @description 根据相交数组insetionArr, 把相交的线段,划分到一组内,方便后续路径查找合并使用
|
|
158
|
+
* @returns
|
|
159
|
+
*/
|
|
160
|
+
private createGroups;
|
|
161
|
+
/** 计算当前墙体数据的边界框
|
|
162
|
+
* @description 根据分组数据pointsGroups,计算包围盒, pointsGroups数据为缩放后数据。
|
|
163
|
+
* @description 可通过box属性查看计算结果。
|
|
164
|
+
* @returns
|
|
165
|
+
*/
|
|
166
|
+
computedSize(): Box2;
|
|
167
|
+
/** 线路拓扑
|
|
168
|
+
* @description 处理线路拓扑,使线路有序链接,形成长路径
|
|
169
|
+
* @param lines
|
|
170
|
+
*/
|
|
171
|
+
lineTopology(lines: Point[][]): Point<Record<string, any>>[][];
|
|
172
|
+
/** 合并方向相同的线段
|
|
173
|
+
* @param lines
|
|
174
|
+
* @param errAngle
|
|
175
|
+
*/
|
|
176
|
+
private mergeSameDirectionLine;
|
|
177
|
+
/** etOpenRound 去除毛刺
|
|
178
|
+
* @description 检查连续的短线段数量,去除合并后产生的毛刺
|
|
179
|
+
*/
|
|
180
|
+
private squareRemoveBurr;
|
|
181
|
+
/**
|
|
182
|
+
* 线段矫直, 线段中心突刺
|
|
183
|
+
* @description 突变长度小于墙体宽度,该线段可能为突起线段,
|
|
184
|
+
* @description 判断后续第2线段与上一条线段是否方向相同,相同就为突刺
|
|
185
|
+
*/
|
|
186
|
+
lineSegmentStraightening(path: Point[]): Point<Record<string, any>>[];
|
|
187
|
+
/**
|
|
188
|
+
* 移除短线段
|
|
189
|
+
* @todo 根据线段两端线段长度,选取参照物_|▔▔
|
|
190
|
+
* @param path
|
|
191
|
+
*/
|
|
192
|
+
removeShortLine(path: Point[], shortLine?: number): Point<Record<string, any>>[];
|
|
193
|
+
/** 线偏移
|
|
194
|
+
* @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
|
|
195
|
+
*/
|
|
196
|
+
lineOffset(endType?: number, joinType?: number, scale?: number): Point<Record<string, any>>[][];
|
|
197
|
+
/**
|
|
198
|
+
* 将点云结构转换为Float32Array
|
|
199
|
+
*/
|
|
200
|
+
to3DArray(scale: number, z?: number): Float32Array<ArrayBuffer>;
|
|
201
|
+
/** 获取角度范围
|
|
202
|
+
* @param center
|
|
203
|
+
* @param p1
|
|
204
|
+
* @param p2
|
|
205
|
+
* @returns
|
|
206
|
+
*/
|
|
207
|
+
private getArcAngleRange;
|
|
208
|
+
/**
|
|
209
|
+
* 线段数据转为原始json数据
|
|
210
|
+
*/
|
|
211
|
+
lineDataToOriginalData(lines: LineSegment<LineUserData>[], quadtree?: Quadtree): OriginalDataItem[];
|
|
212
|
+
/**
|
|
213
|
+
* 转为绘制数据
|
|
214
|
+
*/
|
|
215
|
+
toDrawDataJson(unit?: Unit): DrawData;
|
|
216
|
+
/**
|
|
217
|
+
*
|
|
218
|
+
* @param type
|
|
219
|
+
*/
|
|
220
|
+
toDxfImageBlob(unit?: Unit, type?: string, background?: string): Promise<any>;
|
|
221
|
+
/**
|
|
222
|
+
* 将点json结构转换为Dxf string
|
|
223
|
+
*/
|
|
224
|
+
toDxfString(unit?: Unit): string;
|
|
225
|
+
/**
|
|
226
|
+
* 将点云结构转换为DXF格式
|
|
227
|
+
* @returns
|
|
228
|
+
*/
|
|
229
|
+
toDxfBlob(unit?: Unit): Blob;
|
|
230
|
+
/**
|
|
231
|
+
* 下载原始json
|
|
232
|
+
* @param filename
|
|
233
|
+
*/
|
|
234
|
+
downloadOriginalData(filename: string): Promise<void>;
|
|
235
|
+
/**
|
|
236
|
+
* 下载
|
|
237
|
+
* @param filename
|
|
238
|
+
*/
|
|
239
|
+
download(filename: string, unit?: Unit): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* 下载
|
|
242
|
+
* @param filename
|
|
243
|
+
*/
|
|
244
|
+
downloadImage(filename: string, unit?: Unit, type?: string): Promise<boolean>;
|
|
245
|
+
/**
|
|
246
|
+
* 计算原始数据的边界框
|
|
247
|
+
* @description 计算所有线段的起点和终点的最小最大值,形成一个边界框
|
|
248
|
+
* @returns
|
|
249
|
+
*/
|
|
250
|
+
private computedOriginalSize;
|
|
251
|
+
/**
|
|
252
|
+
* 创建数据
|
|
253
|
+
* @param pointsGroups
|
|
254
|
+
* @returns
|
|
255
|
+
*/
|
|
256
|
+
static createData(pointsGroups: Point[][], sealed?: boolean): OriginalDataItem[];
|
|
257
|
+
/**
|
|
258
|
+
* 轴对齐垂直修正
|
|
259
|
+
* @param lines 待调整线段组
|
|
260
|
+
* @param targettLine 轴线段
|
|
261
|
+
* @returns
|
|
262
|
+
*/
|
|
263
|
+
static axisAlignmentCorrection(lines: LineSegment[], targettLine: LineSegment): LineSegment<LineUserData>[];
|
|
264
|
+
/**
|
|
265
|
+
* @param lines
|
|
266
|
+
* @param trajectoryPositions
|
|
267
|
+
* @returns
|
|
268
|
+
*/
|
|
269
|
+
static excessLineSegments(lines: LineSegment[], trajectoryPositions: Point[]): LineSegment<Record<string, any>>[];
|
|
270
|
+
/** 边线外扩
|
|
271
|
+
* @param lines
|
|
272
|
+
* @param trajectory
|
|
273
|
+
*/
|
|
274
|
+
static boundaryExtension(lines: LineSegment<LineUserData>[], trajectory: Point[]): LineSegment<LineUserData>[];
|
|
275
|
+
}
|
|
276
|
+
export {};
|
|
@@ -83,6 +83,20 @@ export type DrawData = {
|
|
|
83
83
|
height: number;
|
|
84
84
|
scale: number;
|
|
85
85
|
};
|
|
86
|
+
type AxisAlignmentCorrectionOption = {
|
|
87
|
+
/**
|
|
88
|
+
* 主轴阈值,默认 0.3
|
|
89
|
+
*/
|
|
90
|
+
principalAxisThreshold?: number;
|
|
91
|
+
/**
|
|
92
|
+
* 交叉轴阈值,默认 0.05
|
|
93
|
+
*/
|
|
94
|
+
crossAxistThreshold?: number;
|
|
95
|
+
/**
|
|
96
|
+
* 吸附阈值,默认 0.2
|
|
97
|
+
*/
|
|
98
|
+
snapThreshold?: number;
|
|
99
|
+
};
|
|
86
100
|
/**
|
|
87
101
|
*
|
|
88
102
|
*/
|
|
@@ -104,6 +118,10 @@ export declare class Dxf<TEventMap extends {} = {}> extends Component<{
|
|
|
104
118
|
createGroup: {
|
|
105
119
|
groups: Point[][][];
|
|
106
120
|
};
|
|
121
|
+
preprocessing: {
|
|
122
|
+
data: OriginalDataItem[];
|
|
123
|
+
setData(data: OriginalDataItem[]): void;
|
|
124
|
+
};
|
|
107
125
|
} & TEventMap> {
|
|
108
126
|
static name: string;
|
|
109
127
|
shortLine: number;
|
|
@@ -133,7 +151,6 @@ export declare class Dxf<TEventMap extends {} = {}> extends Component<{
|
|
|
133
151
|
*/
|
|
134
152
|
get lines(): LineSegment<LineUserData>[];
|
|
135
153
|
/**初始化
|
|
136
|
-
* @param data 点云数据
|
|
137
154
|
* @param width 墙体宽度
|
|
138
155
|
* @param scale 缩放比例
|
|
139
156
|
*/
|
|
@@ -142,17 +159,19 @@ export declare class Dxf<TEventMap extends {} = {}> extends Component<{
|
|
|
142
159
|
* 预处理数据
|
|
143
160
|
* @param data
|
|
144
161
|
*/
|
|
145
|
-
preprocessing(data: OriginalDataItem[], axisAlignmentCorrection?: boolean): {
|
|
146
|
-
lineSegments:
|
|
162
|
+
preprocessing(data: OriginalDataItem[], axisAlignmentCorrection?: boolean, option?: AxisAlignmentCorrectionOption): {
|
|
163
|
+
lineSegments: LineSegment<LineUserData>[];
|
|
147
164
|
data: OriginalDataItem[];
|
|
148
165
|
};
|
|
149
|
-
/**
|
|
150
|
-
*
|
|
151
|
-
* @param
|
|
152
|
-
* @param
|
|
153
|
-
* @param
|
|
166
|
+
/** 设置
|
|
167
|
+
* @param data 房屋结构数据,node环境可以为路径
|
|
168
|
+
* @param width 墙体宽度
|
|
169
|
+
* @param scale 缩放比例
|
|
170
|
+
* @param axisAlignmentCorrection 需要执行轴对称垂直纠正
|
|
171
|
+
* @param option
|
|
172
|
+
* @returns
|
|
154
173
|
*/
|
|
155
|
-
set(data: OriginalDataItem[] | string, width?: number, scale?: number, axisAlignmentCorrection?: boolean): Promise<any>;
|
|
174
|
+
set(data: OriginalDataItem[] | string, width?: number, scale?: number, axisAlignmentCorrection?: boolean, option?: AxisAlignmentCorrectionOption): Promise<any>;
|
|
156
175
|
/** 创建分组
|
|
157
176
|
* @description 根据相交数组insetionArr, 把相交的线段,划分到一组内,方便后续路径查找合并使用
|
|
158
177
|
* @returns
|
|
@@ -248,6 +267,10 @@ export declare class Dxf<TEventMap extends {} = {}> extends Component<{
|
|
|
248
267
|
* @returns
|
|
249
268
|
*/
|
|
250
269
|
private computedOriginalSize;
|
|
270
|
+
/**
|
|
271
|
+
* 线段数据转为原始json数据
|
|
272
|
+
*/
|
|
273
|
+
static lineDataToOriginalData(lines: LineSegment<LineUserData>[], originalZAverage?: number, quadtree?: Quadtree): OriginalDataItem[];
|
|
251
274
|
/**
|
|
252
275
|
* 创建数据
|
|
253
276
|
* @param pointsGroups
|
|
@@ -260,6 +283,18 @@ export declare class Dxf<TEventMap extends {} = {}> extends Component<{
|
|
|
260
283
|
* @param targettLine 轴线段
|
|
261
284
|
* @returns
|
|
262
285
|
*/
|
|
263
|
-
static axisAlignmentCorrection(lines: LineSegment[], targettLine: LineSegment
|
|
286
|
+
static axisAlignmentCorrection(lines: LineSegment[], targettLine: LineSegment, option?: AxisAlignmentCorrectionOption): LineSegment<LineUserData>[];
|
|
287
|
+
/**
|
|
288
|
+
* @param lines
|
|
289
|
+
* @param trajectoryPoints
|
|
290
|
+
* @returns
|
|
291
|
+
*/
|
|
292
|
+
static findExteriorWall(lines: LineSegment[], trajectoryPoints: Point[], minWidth?: number): LineSegment<Record<string, any>>[];
|
|
293
|
+
/** 边线外扩
|
|
294
|
+
* @param lines
|
|
295
|
+
* @param trajectoryPoints
|
|
296
|
+
*/
|
|
297
|
+
static boundaryExtension(data: OriginalDataItem[], trajectory: any, wallWidth?: number): OriginalDataItem[];
|
|
298
|
+
boundaryExtension: typeof Dxf.boundaryExtension;
|
|
264
299
|
}
|
|
265
300
|
export {};
|
|
@@ -50,7 +50,7 @@ export declare class CommandFlowComponent<TEventMap extends {} = {}> extends Com
|
|
|
50
50
|
* @param callBack
|
|
51
51
|
* @returns
|
|
52
52
|
*/
|
|
53
|
-
createPointerMove(callBack: (point: Point, isAdsorb: boolean) => void): {
|
|
53
|
+
createPointerMove(callBack: (point: Point, isAdsorb: boolean, line?: LineSegment) => void): {
|
|
54
54
|
destroy(): void;
|
|
55
55
|
setBaseLine(line: LineSegment | null, point: Point | null): void;
|
|
56
56
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CommandFlowComponent } from './CommandFlowComponent';
|
|
2
2
|
import { ComponentManager } from '../../../../../ComponentManager';
|
|
3
|
+
import { LineSegment } from '../../../../../Quadtree/LineSegment';
|
|
3
4
|
/**
|
|
4
5
|
* 合并同向线段
|
|
5
6
|
*/
|
|
@@ -12,11 +13,12 @@ export declare class MergeLine extends CommandFlowComponent<{}> {
|
|
|
12
13
|
* 进入命令约束
|
|
13
14
|
*/
|
|
14
15
|
private constraint;
|
|
16
|
+
mergeLine(line1: LineSegment, line2: LineSegment): false | LineSegment<Record<string, any>>;
|
|
15
17
|
/** 开始
|
|
16
18
|
* @param next
|
|
17
19
|
* @todo 合并所有
|
|
18
20
|
*/
|
|
19
|
-
private
|
|
21
|
+
private mergeLines;
|
|
20
22
|
/** 执行完成
|
|
21
23
|
* @param data
|
|
22
24
|
*/
|
|
@@ -11,10 +11,8 @@ export declare class VerticalCorrection extends CommandFlowComponent<{}> {
|
|
|
11
11
|
static name: string;
|
|
12
12
|
container: THREE.Group<THREE.Object3DEventMap>;
|
|
13
13
|
shortcutKeys: string[];
|
|
14
|
-
shortcutKeys2: string[];
|
|
15
14
|
shortcutKeys3: string[];
|
|
16
15
|
static commandName: string;
|
|
17
|
-
recursion: boolean;
|
|
18
16
|
axisAlignment: boolean;
|
|
19
17
|
onAddFromParent(parent: ComponentManager): void;
|
|
20
18
|
/**
|
|
@@ -55,13 +53,18 @@ export declare class VerticalCorrection extends CommandFlowComponent<{}> {
|
|
|
55
53
|
* @returns
|
|
56
54
|
*/
|
|
57
55
|
axisAlignmentCorrection(targettLine: LineSegment): {
|
|
58
|
-
newLines:
|
|
56
|
+
newLines: LineSegment<LineUserData>[];
|
|
59
57
|
oldLines: LineSegment<LineUserData>[];
|
|
60
58
|
};
|
|
61
59
|
/** 开始
|
|
62
60
|
* @param next
|
|
63
61
|
*/
|
|
64
62
|
verticalCorrection(next: any, selectLines: LineSegment[]): void;
|
|
63
|
+
/**
|
|
64
|
+
* 窗户恢复
|
|
65
|
+
* @param doorLines
|
|
66
|
+
*/
|
|
67
|
+
windowRecover(doorLines: LineSegment<LineUserData>[]): void;
|
|
65
68
|
/** 执行完成
|
|
66
69
|
* @param data
|
|
67
70
|
*/
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { Box2 } from '../Quadtree/Box2';
|
|
2
2
|
import { Point } from '../Quadtree/Point';
|
|
3
3
|
import { Rectangle } from '../Quadtree/Rectangle';
|
|
4
|
-
type
|
|
4
|
+
type Target<T> = {
|
|
5
5
|
point: Point;
|
|
6
6
|
userData?: T;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
type NodeSet<T> = Set<Target<T>>;
|
|
8
9
|
export declare class PointVirtualGrid<T = Record<string, any>> {
|
|
9
10
|
map: Map<string, NodeSet<T>>;
|
|
11
|
+
targetMap: Map<Point<Record<string, any>>, {
|
|
12
|
+
target: Target<T>;
|
|
13
|
+
set: NodeSet<T>;
|
|
14
|
+
}>;
|
|
10
15
|
gridSize: number;
|
|
11
16
|
constructor(gridSize?: number);
|
|
12
17
|
/**
|
|
@@ -144,12 +144,31 @@ export declare class LineSegment<T = Record<string, any>> {
|
|
|
144
144
|
* @param line
|
|
145
145
|
*/
|
|
146
146
|
isParallel(line: LineSegment, errAngle?: number): boolean;
|
|
147
|
+
/** 判断点在当前线段的左边还是右边,或者线段上
|
|
148
|
+
* @param point
|
|
149
|
+
*/
|
|
150
|
+
pointPosition(point: Point): "on" | "left" | "right";
|
|
151
|
+
/**
|
|
152
|
+
* @returns
|
|
153
|
+
*/
|
|
154
|
+
getRightDirection(): Point<Record<string, any>>;
|
|
155
|
+
/**
|
|
156
|
+
*
|
|
157
|
+
* @returns
|
|
158
|
+
*/
|
|
159
|
+
getLeftDirection(): Point<Record<string, any>>;
|
|
160
|
+
/** @param line 获取两条线段之间的最短距离
|
|
161
|
+
*/
|
|
162
|
+
getMinLength(line: LineSegment): number;
|
|
147
163
|
/**
|
|
148
164
|
* 判断两条直线是否重合
|
|
149
165
|
* @param line
|
|
150
166
|
* @returns
|
|
151
167
|
*/
|
|
152
168
|
areLinesCoincident(line: LineSegment): boolean;
|
|
169
|
+
/** 克隆
|
|
170
|
+
* @returns
|
|
171
|
+
*/
|
|
153
172
|
clone(): LineSegment<T>;
|
|
154
173
|
/**
|
|
155
174
|
* 获取最长线段
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LineSegment } from './LineSegment';
|
|
1
2
|
export declare class Point<T = Record<string, any>> {
|
|
2
3
|
x: number;
|
|
3
4
|
y: number;
|
|
@@ -85,6 +86,11 @@ export declare class Point<T = Record<string, any>> {
|
|
|
85
86
|
* @returns
|
|
86
87
|
*/
|
|
87
88
|
direction(point: Point): Point<Record<string, any>>;
|
|
89
|
+
/** 展开为线
|
|
90
|
+
* @param direction
|
|
91
|
+
* @param length
|
|
92
|
+
*/
|
|
93
|
+
expandAsLine<T = any>(direction: Point, length: number, userData?: T): LineSegment<T>;
|
|
88
94
|
/**
|
|
89
95
|
* 计算模长
|
|
90
96
|
* @returns
|
|
@@ -49,6 +49,12 @@ export declare class Quadtree<T = any> {
|
|
|
49
49
|
* @returns 相交的节点数组
|
|
50
50
|
*/
|
|
51
51
|
queryCircle(pos: Point, radius: number): QuadtreeNode<T>[];
|
|
52
|
+
/**
|
|
53
|
+
* 查询与点相交的线段节点
|
|
54
|
+
* @param point 圆心
|
|
55
|
+
* @returns 相交的节点数组
|
|
56
|
+
*/
|
|
57
|
+
queryPoint(point: Point): QuadtreeNode<T>[];
|
|
52
58
|
/**
|
|
53
59
|
* 查询与矩形相交的线段节点
|
|
54
60
|
* @param rectangle 矩形
|