build-dxf 0.0.9 → 0.0.10

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.
@@ -1,596 +0,0 @@
1
- import { EventDispatcher as EventDispatcher_2 } from 'three';
2
- import * as THREE from 'three';
3
-
4
- declare class Box2 {
5
- minX: number;
6
- maxX: number;
7
- minY: number;
8
- maxY: number;
9
- get points(): Point[];
10
- get width(): number;
11
- get height(): number;
12
- get center(): Point;
13
- constructor(minX?: number, maxX?: number, minY?: number, maxY?: number);
14
- /**
15
- *
16
- * @param z
17
- * @returns
18
- */
19
- getPaths3D(z?: number): number[];
20
- /**
21
- * 判断线段是与包围盒相交
22
- * @description Liang-Barsky算法的变种
23
- * @param line
24
- */
25
- intersectLineSegment(line: LineSegment): boolean;
26
- /**
27
- * 判断线段是在包围盒内
28
- * @param line
29
- */
30
- containsLineSegment(line: LineSegment): boolean;
31
- /**
32
- * 判断矩形与包围盒相交
33
- * @param rectangle
34
- */
35
- intersectRectangle(rectangle: Rectangle): boolean;
36
- /**
37
- * 判断矩形是在包围盒内
38
- * @param rectangle
39
- */
40
- containsRectangle(rectangle: Rectangle): boolean;
41
- /**
42
- * 判断包围盒与包围盒相交
43
- * @param box
44
- */
45
- intersectBox(box: Box2): boolean;
46
- /**
47
- * 判断包围盒是在包围盒内
48
- * @param box
49
- */
50
- containsBox(box: Box2): boolean;
51
- /** 判断点是在包围盒内
52
- * @param point
53
- */
54
- containsPoint(point: Point): boolean;
55
- /**
56
- *
57
- * @param minX
58
- * @param minY
59
- * @param maxX
60
- * @param maxY
61
- * @returns
62
- */
63
- set(minX: number, minY: number, maxX: number, maxY: number): this;
64
- /**
65
- *
66
- * @param maxWidth
67
- * @param maxHeight
68
- * @param mode
69
- * @returns
70
- */
71
- scaleSize(maxWidth: number, maxHeight: number, mode?: 'min' | 'max'): number;
72
- /**
73
- *
74
- * @param scalar
75
- * @returns
76
- */
77
- multiplyScalar(scalar: number): this;
78
- /**
79
- *
80
- * @returns
81
- */
82
- clone(): Box2;
83
- /**
84
- *
85
- * @param points
86
- * @returns
87
- */
88
- static fromByPoints(...points: Point[]): Box2;
89
- }
90
-
91
- declare class Component<TEventMap extends {} = {}> extends EventDispatcher<{
92
- addFromParent: {
93
- parent: ComponentManager;
94
- };
95
- removeFromParent: {
96
- parent: ComponentManager;
97
- };
98
- update: {};
99
- } & TEventMap> {
100
- parent?: ComponentManager;
101
- constructor(...arg: any[]);
102
- onAddFromParent(parent: ComponentManager): void;
103
- onRemoveFromParent(parent: ComponentManager): void;
104
- destroy(): void;
105
- }
106
-
107
- declare class ComponentManager<TEventMap extends {} = {}> extends EventDispatcher<TEventMap & EventTypeMap> {
108
- static readonly EventType: {
109
- ADD_COMPONENT: string;
110
- };
111
- components: Component[];
112
- /**
113
- * 添加组件
114
- * @param component
115
- */
116
- addComponent(component: Component): this;
117
- /**
118
- * 移除组件
119
- * @param component
120
- */
121
- removeComponent(component: Component): void;
122
- /**
123
- * 查找符合条件的第一个组件
124
- * @param callBack
125
- */
126
- findComponent(predicate: (component: Component, index: number) => boolean): Component<{}> | undefined;
127
- /**
128
- * 查找所有符合条件的组件
129
- * @param callBack
130
- */
131
- findComponents(predicate: (component: Component, index: number) => boolean): Component<{}> | undefined;
132
- /**
133
- *
134
- * @param type
135
- */
136
- findComponentByType<T extends typeof Component>(type: T): InstanceType<T> | null;
137
- /**
138
- *
139
- * @param type
140
- */
141
- findComponentByName(name: string): Component<{}> | null;
142
- }
143
-
144
- declare namespace components {
145
- export {
146
- WhiteModel,
147
- DetailsPoint,
148
- DxfLineModel
149
- }
150
- }
151
- export { components }
152
-
153
- /**
154
- * [开始点, 结束点, 相交点, 是否是门, 索引]
155
- */
156
- declare type DataItem = [Point, Point, number[], boolean, number];
157
-
158
- declare class DetailsPoint extends Component<{
159
- handleSuccess: {
160
- desPoints: IDesPointItem[];
161
- };
162
- }> {
163
- Dxf: Dxf | null;
164
- WhiteModel: WhiteModel | null;
165
- Variable: Variable | null;
166
- desPoints: IDesPointItem[];
167
- raylines: [THREE.Vector3, THREE.Vector3][];
168
- data: any[];
169
- onAddFromParent(parent: ComponentManager): void;
170
- /**
171
- * 设置值
172
- * @param data
173
- */
174
- set(data: any): Promise<void>;
175
- /**
176
- * 设置射线辅助
177
- */
178
- racasterHelper(position: THREE.Vector3, direction: THREE.Vector3, far: number): void;
179
- private _timer;
180
- /**
181
- * 更新模型
182
- */
183
- updateModel(): void;
184
- }
185
-
186
- /**
187
- * 将点云结构转换为DXF格式
188
- */
189
- declare class Dxf extends Component<{
190
- setDta: {
191
- originalData: OriginalDataItem[];
192
- data: DataItem[];
193
- };
194
- lineOffset: {
195
- wallsGroup: Point[][];
196
- };
197
- createGroup: {
198
- groups: Point[][][];
199
- };
200
- }> {
201
- width: number;
202
- scale: number;
203
- originalData: OriginalDataItem[];
204
- data: DataItem[];
205
- originalBox: Box2;
206
- box: Box2;
207
- pointsGroups: Point[][][];
208
- wallsGroup: Point[][];
209
- doors: DataItem[];
210
- lineSegments: LineSegment<{
211
- isDoor: boolean;
212
- }>[];
213
- originalZAverage: number;
214
- static EndType: {
215
- etOpenSquare: number;
216
- etOpenRound: number;
217
- etOpenButt: number;
218
- };
219
- static JoinType: {
220
- jtSquare: number;
221
- jtRound: number;
222
- jtMiter: number;
223
- };
224
- /** 原始数据组
225
- */
226
- get lines(): LineSegment<{
227
- isDoor: boolean;
228
- }>[];
229
- /**初始化
230
- * @param data 点云数据
231
- * @param width 墙体宽度
232
- * @param scale 缩放比例
233
- */
234
- constructor(width?: number, scale?: number);
235
- /**
236
- * 设置
237
- * @param data
238
- * @param width
239
- * @param scale
240
- */
241
- set(data: OriginalDataItem[] | string, width?: number, scale?: number): Promise<any>;
242
- /** 创建分组
243
- * @description 根据相交数组insetionArr, 把相交的线段,划分到一组内,方便后续路径查找合并使用
244
- * @returns
245
- */
246
- private createGroups;
247
- /** 计算当前墙体数据的边界框
248
- * @description 根据分组数据pointsGroups,计算包围盒, pointsGroups数据为缩放后数据。
249
- * @description 可通过box属性查看计算结果。
250
- * @returns
251
- */
252
- computedSize(): Box2;
253
- /** 线路拓扑
254
- * @description 处理线路拓扑,使线路有序链接,形成长路径
255
- * @param lines
256
- */
257
- private lineTopology;
258
- /** etOpenRound 去除毛刺
259
- * @description 检查连续的短线段数量,去除合并后产生的毛刺
260
- */
261
- private squareRemoveBurr;
262
- /** 线偏移
263
- * @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
264
- */
265
- lineOffset(endType?: number, joinType?: number, scale?: number): Point[][];
266
- /**
267
- * 将点云结构转换为Float32Array
268
- */
269
- to3DArray(scale: number): Float32Array<ArrayBuffer>;
270
- /**
271
- * 将点云结构转换为string
272
- */
273
- toDxfString(unit?: Unit): string;
274
- /**
275
- * 将点云结构转换为DXF格式
276
- * @returns
277
- */
278
- toDxfBlob(unit?: Unit): Blob;
279
- /**
280
- * 下载
281
- * @param filename
282
- */
283
- download(filename: string, unit?: Unit): Promise<void>;
284
- /**
285
- * 计算原始数据的边界框
286
- * @description 计算所有线段的起点和终点的最小最大值,形成一个边界框
287
- * @returns
288
- */
289
- private computedOriginalSize;
290
- /**
291
- * 创建数据
292
- * @param pointsGroups
293
- * @returns
294
- */
295
- static createData(pointsGroups: Point[][], sealed?: boolean): OriginalDataItem[];
296
- }
297
-
298
- declare class DxfLineModel extends Component {
299
- private dxfLineModel;
300
- private dxfDoorsLineModel;
301
- dxfModelGroup: THREE.Group<THREE.Object3DEventMap>;
302
- onAddFromParent(parent: ComponentManager): void;
303
- updateMode(): void;
304
- }
305
-
306
- declare class DxfSystem extends ComponentManager {
307
- Dxf: Dxf;
308
- Variable: Variable;
309
- wallWidth: number;
310
- environment: "node" | "browser" | "unknown";
311
- /** 构造函数
312
- * @param wallWidth 输出墙壁厚度,该墙壁厚度不受缩放影响
313
- * @param scale 原始数据缩放比例
314
- */
315
- constructor(wallWidth?: number, scale?: number);
316
- usePlugin(plugin: (this: DxfSystem, dxfSystem: DxfSystem) => void): this;
317
- destroy(): void;
318
- }
319
-
320
- declare type EventData<T> = {
321
- value: T;
322
- oldValue: T;
323
- };
324
-
325
- declare class EventDispatcher<TEventMap extends {} = {}> extends EventDispatcher_2<TEventMap> {
326
- uuid: string;
327
- }
328
-
329
- declare interface EventType {
330
- originalLineVisible: EventData<boolean>;
331
- dxfVisible: EventData<boolean>;
332
- whiteModelVisible: EventData<boolean>;
333
- isLook: EventData<boolean>;
334
- currentWheel: EventData<number>;
335
- pointerMove: EventData<{
336
- x: number;
337
- y: number;
338
- }>;
339
- currentKeyUp: EventData<string>;
340
- }
341
-
342
- declare interface EventTypeMap {
343
- addComponent: {
344
- component: Component;
345
- };
346
- removeComponent: {
347
- component: Component;
348
- };
349
- }
350
-
351
- declare interface IDesPointItem {
352
- message: string;
353
- position: THREE.Vector3;
354
- intersection: THREE.Vector3;
355
- }
356
-
357
- /**
358
- * 非轴对称线段
359
- */
360
- declare class LineSegment<T = Record<string, any>> {
361
- points: Point[];
362
- userData?: T;
363
- get center(): Point;
364
- get start(): Point;
365
- get end(): Point;
366
- constructor(p1?: Point, p2?: Point);
367
- /**
368
- * 计算线段的长度
369
- * @returns 线段的长度
370
- */
371
- getLength(): number;
372
- /**
373
- * 获取方向
374
- * @returns
375
- */
376
- direction(): Point;
377
- /**
378
- * 计算一条线段在另一条直线上的投影,并裁剪超出目标线段的部分
379
- * @param line 要投影的线段
380
- * @returns 投影并裁剪后的线段
381
- */
382
- projectLineSegment(line: LineSegment): LineSegment;
383
- clone(): LineSegment<Record<string, any>>;
384
- }
385
-
386
- export declare function ModelDataPlugin(dxfSystem: DxfSystem): void;
387
-
388
- declare interface OriginalDataItem {
389
- start: {
390
- x: number;
391
- y: number;
392
- z: number;
393
- };
394
- end: {
395
- x: number;
396
- y: number;
397
- z: number;
398
- };
399
- insetionArr: {
400
- index: number;
401
- p: {
402
- x: number;
403
- y: number;
404
- z: number;
405
- };
406
- }[];
407
- isDoor?: boolean;
408
- }
409
-
410
- declare class Point {
411
- x: number;
412
- y: number;
413
- get X(): number;
414
- get Y(): number;
415
- /**
416
- *
417
- * @param x
418
- * @param y
419
- */
420
- constructor(x?: number, y?: number);
421
- set(x: number, y: number): this;
422
- setX(x: number): this;
423
- setY(y: number): this;
424
- /**
425
- *
426
- * @param point
427
- * @returns
428
- */
429
- equal(point: Point): boolean;
430
- /**
431
- *
432
- * @param arr
433
- */
434
- setByArray(arr: number[]): this;
435
- /**
436
- *
437
- */
438
- toArray(): [number, number];
439
- /**
440
- * multiplyScalar
441
- * @param scalar
442
- */
443
- mutiplyScalar(scalar: number): this;
444
- multiplyScalar(scalar: number): this;
445
- /**
446
- *
447
- * @param scalar
448
- * @returns
449
- */
450
- divisionScalar(scalar: number): this;
451
- /**
452
- * 减法
453
- * @description 将当前点的坐标减去指定点的坐标
454
- * @param point
455
- * @returns
456
- */
457
- division(point: Point): this;
458
- /**
459
- * 加法
460
- * @description 将当前点的坐标加上指定点的坐标
461
- * @param point
462
- * @returns
463
- */
464
- add(point: Point): this;
465
- /**
466
- * 保留小数位数
467
- * @param count
468
- */
469
- fixed(count: number): this;
470
- /**
471
- * 归一化
472
- * @description 将当前点的坐标归一化为单位向量
473
- * @returns
474
- */
475
- normalize(): this;
476
- /**
477
- * 获取单位法向量
478
- * @description 计算当前点到指定点的方向向量,并返回逆时针旋转90度后的单位法向量
479
- * @param point
480
- * @returns
481
- */
482
- normal(point: Point): Point;
483
- /**
484
- * 获取由传入的点到该点的单位方向向量
485
- * @description 计算当前点到指定点的方向向量,并返回单位方向
486
- * @param point
487
- * @returns
488
- */
489
- direction(point: Point): Point;
490
- /**
491
- * 计算模长
492
- * @returns
493
- */
494
- magnitude(): number;
495
- /**
496
- * 计算点点积
497
- * @param point
498
- * @returns
499
- */
500
- dot(point: Point): number;
501
- /** 计算两个向量夹角
502
- * @description 公式:a · b = |a| × |b| × cosθ
503
- * @param point
504
- * @returns
505
- */
506
- angleBetween(point: Point): number;
507
- /** 获取向量长度
508
- */
509
- length(): number;
510
- /**
511
- * 获取两个点长度
512
- * @param point
513
- */
514
- distance(point: Point): number;
515
- /**
516
- * 克隆
517
- * @returns
518
- */
519
- clone(): Point;
520
- static from(arr: any): Point;
521
- static zero(): Point;
522
- }
523
-
524
- /**
525
- * 非轴对称矩形
526
- */
527
- declare class Rectangle {
528
- points: Point[];
529
- get path(): number[];
530
- constructor(points: Point[]);
531
- /**
532
- * 判断线段是否与矩形相交
533
- * @param line 线段
534
- * @returns 是否与矩形相交
535
- */
536
- intersectLineSegment(line: LineSegment): boolean;
537
- /**
538
- * 判断线段是否完全位于矩形内部
539
- * @param line 线段
540
- * @returns 是否完全在矩形内部
541
- */
542
- containsLineSegment(line: LineSegment): boolean;
543
- /**
544
- * 判断点是否完全位于矩形内部
545
- * @param point
546
- */
547
- containsPoint(point: Point): boolean;
548
- /**
549
- *
550
- * @returns
551
- */
552
- toBox(): Box2;
553
- /**
554
- *
555
- * @param line
556
- * @param width
557
- * @returns
558
- */
559
- static fromByLineSegment(line: LineSegment, width?: number, horizontal?: boolean, hScale?: number): Rectangle;
560
- }
561
-
562
- declare 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";
563
-
564
- declare class Variable extends Component<EventType> {
565
- originalLineVisible: boolean;
566
- dxfVisible: boolean;
567
- whiteModelVisible: boolean;
568
- isLook: boolean;
569
- currentWheel: number;
570
- pointerMove: {
571
- x: number;
572
- y: number;
573
- };
574
- currentKeyUp: string;
575
- set<KeyT extends keyof EventType>(key: KeyT, value: any): void;
576
- get<KeyT extends keyof EventType>(key: KeyT): this[KeyT] | undefined;
577
- }
578
-
579
- declare class WhiteModel extends Component<{
580
- updateModel: {
581
- whiteModelGroup: THREE.Group;
582
- originalWhiteMode: THREE.Group;
583
- };
584
- }> {
585
- Dxf: Dxf | null;
586
- Variable: Variable | null;
587
- whiteModelGroup: THREE.Group<THREE.Object3DEventMap>;
588
- originalWhiteMode: THREE.Group<THREE.Object3DEventMap>;
589
- onAddFromParent(parent: ComponentManager): void;
590
- updateModel(): void;
591
- toOBJ(): Promise<string>;
592
- toBlob(): Promise<Blob | undefined>;
593
- download(filename: string): Promise<void>;
594
- }
595
-
596
- export { }