build-dxf 0.0.33 → 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/src/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import "three";
2
- import { D as s, M as o, i as l, d as i, g as m, e as r } from "./build.js";
2
+ import { c as t, D as o, M as l, i, d as m, g as r, e as D } from "./build.js";
3
3
  export {
4
- s as DxfSystem,
5
- o as ModelDataPlugin,
6
- l as components,
7
- i as createEditor,
8
- m as getFileAll,
9
- r as getGlobalDxfSystem
4
+ t as Dxf,
5
+ o as DxfSystem,
6
+ l as ModelDataPlugin,
7
+ i as components,
8
+ m as createEditor,
9
+ r as getFileAll,
10
+ D as getGlobalDxfSystem
10
11
  };
@@ -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): {
162
+ preprocessing(data: OriginalDataItem[], axisAlignmentCorrection?: boolean, option?: AxisAlignmentCorrectionOption): {
146
163
  lineSegments: LineSegment<LineUserData>[];
147
164
  data: OriginalDataItem[];
148
165
  };
149
- /**
150
- * 设置
151
- * @param data
152
- * @param width
153
- * @param scale
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,17 +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): LineSegment<LineUserData>[];
286
+ static axisAlignmentCorrection(lines: LineSegment[], targettLine: LineSegment, option?: AxisAlignmentCorrectionOption): LineSegment<LineUserData>[];
264
287
  /**
265
288
  * @param lines
266
- * @param trajectoryPositions
289
+ * @param trajectoryPoints
267
290
  * @returns
268
291
  */
269
- static excessLineSegments(lines: LineSegment[], trajectoryPositions: Point[]): LineSegment<Record<string, any>>[];
292
+ static findExteriorWall(lines: LineSegment[], trajectoryPoints: Point[], minWidth?: number): LineSegment<Record<string, any>>[];
270
293
  /** 边线外扩
271
294
  * @param lines
272
- * @param trajectory
295
+ * @param trajectoryPoints
273
296
  */
274
- static boundaryExtension(lines: LineSegment<LineUserData>[], trajectory: Point[]): LineSegment<LineUserData>[];
297
+ static boundaryExtension(data: OriginalDataItem[], trajectory: any, wallWidth?: number): OriginalDataItem[];
298
+ boundaryExtension: typeof Dxf.boundaryExtension;
275
299
  }
276
300
  export {};
@@ -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
  * 获取最长线段
@@ -90,7 +90,7 @@ export declare class Point<T = Record<string, any>> {
90
90
  * @param direction
91
91
  * @param length
92
92
  */
93
- expandAsLine(direction: Point, length: number): LineSegment<Record<string, any>>;
93
+ expandAsLine<T = any>(direction: Point, length: number, userData?: T): LineSegment<T>;
94
94
  /**
95
95
  * 计算模长
96
96
  * @returns