build-dxf 0.0.20-14 → 0.0.20-16

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/build.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import * as M from "three";
2
- import { EventDispatcher as K } from "three";
3
- import V from "clipper-lib";
4
- import N from "dxf-writer";
5
- import { OBJExporter as Q } from "three/examples/jsm/exporters/OBJExporter.js";
6
- import { GLTFExporter as tt } from "three/examples/jsm/exporters/GLTFExporter.js";
7
- function T() {
8
- return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(g) {
9
- var t = Math.random() * 16 | 0, e = g == "x" ? t : t & 3 | 8;
2
+ import { EventDispatcher as tt } from "three";
3
+ import F from "clipper-lib";
4
+ import R from "dxf-writer";
5
+ import { OBJExporter as et } from "three/examples/jsm/exporters/OBJExporter.js";
6
+ import { GLTFExporter as nt } from "three/examples/jsm/exporters/GLTFExporter.js";
7
+ function z() {
8
+ return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(y) {
9
+ var t = Math.random() * 16 | 0, e = y == "x" ? t : t & 3 | 8;
10
10
  return e.toString(16);
11
11
  });
12
12
  }
13
- class $ extends K {
14
- uuid = T();
13
+ class $ extends tt {
14
+ uuid = z();
15
15
  addEventListener(t, e, n) {
16
16
  const { once: i = !1 } = n ?? {}, o = (r) => {
17
17
  e(r), i && s();
@@ -31,7 +31,7 @@ class $ extends K {
31
31
  e && (e.forEach((n) => n()), this.eventRecordStack.delete(t));
32
32
  }
33
33
  }
34
- class X extends $ {
34
+ class j extends $ {
35
35
  parent;
36
36
  destroyed = !1;
37
37
  constructor(...t) {
@@ -49,7 +49,7 @@ class X extends $ {
49
49
  this.destroyed = !0;
50
50
  }
51
51
  }
52
- class et extends $ {
52
+ class it extends $ {
53
53
  static EventType = {
54
54
  ADD_COMPONENT: "addComponent"
55
55
  };
@@ -72,7 +72,7 @@ class et extends $ {
72
72
  * @param component
73
73
  */
74
74
  removeComponent(t) {
75
- if (t instanceof X) {
75
+ if (t instanceof j) {
76
76
  const e = this.components.indexOf(t);
77
77
  e > -1 && (this.components.splice(e, 1), this.dispatchEvent({
78
78
  type: "removeComponent",
@@ -117,7 +117,7 @@ class et extends $ {
117
117
  return e || null;
118
118
  }
119
119
  }
120
- class f {
120
+ class p {
121
121
  x;
122
122
  y;
123
123
  get X() {
@@ -201,6 +201,15 @@ class f {
201
201
  add(t) {
202
202
  return this.x += t.x, this.y += t.y, this;
203
203
  }
204
+ /**
205
+ * 绕point旋转angle
206
+ * @param point
207
+ * @param angle 旋转角度,单位为弧度
208
+ */
209
+ rotate(t, e) {
210
+ const n = this.x - t.x, i = this.y - t.y, o = Math.cos(e), s = Math.sin(e), r = n * o - i * s, c = n * s + i * o;
211
+ return this.x = r + t.x, this.y = c + t.y, this;
212
+ }
204
213
  /**
205
214
  * 保留小数位数
206
215
  * @param count
@@ -225,7 +234,7 @@ class f {
225
234
  */
226
235
  normal(t) {
227
236
  const e = this.x - t.x, n = this.y - t.y, i = Math.sqrt(e * e + n * n), o = -n / i, s = e / i;
228
- return new f(o, s);
237
+ return new p(o, s);
229
238
  }
230
239
  /**
231
240
  * 获取由传入的点到该点的单位方向向量
@@ -235,7 +244,7 @@ class f {
235
244
  */
236
245
  direction(t) {
237
246
  const e = this.x - t.x, n = this.y - t.y, i = Math.sqrt(e * e + n * n);
238
- return i === 0 ? new f(0, 0) : new f(e / i, n / i);
247
+ return i === 0 ? new p(0, 0) : new p(e / i, n / i);
239
248
  }
240
249
  /**
241
250
  * 计算模长
@@ -270,8 +279,8 @@ class f {
270
279
  angleBetween(t, e = "radian", n = "180") {
271
280
  const i = this.dot(t), o = this.magnitude(), s = t.magnitude();
272
281
  if (o === 0 || s === 0) return 0;
273
- const r = i / (o * s), a = Math.max(-1, Math.min(1, r));
274
- return e === "radian" ? Math.acos(a) : e === "cos" ? a : n === "180" || this.cross(t) < 0 ? Math.acos(a) / (Math.PI / 180) : 360 - Math.acos(a) / (Math.PI / 180);
282
+ const r = i / (o * s), c = Math.max(-1, Math.min(1, r));
283
+ return e === "radian" ? Math.acos(c) : e === "cos" ? c : n === "180" || this.cross(t) < 0 ? Math.acos(c) / (Math.PI / 180) : 360 - Math.acos(c) / (Math.PI / 180);
275
284
  }
276
285
  /** 获取向量长度
277
286
  */
@@ -293,14 +302,14 @@ class f {
293
302
  * @returns
294
303
  */
295
304
  clone() {
296
- return new f(this.x, this.y);
305
+ return new p(this.x, this.y);
297
306
  }
298
307
  /**
299
308
  * 克隆
300
309
  * @returns
301
310
  */
302
311
  copy(t) {
303
- this.x = t.x ?? 0, this.y = t.y ?? 0;
312
+ return this.x = t.x ?? 0, this.y = t.y ?? 0, this;
304
313
  }
305
314
  toJson(t = 0) {
306
315
  return {
@@ -310,23 +319,23 @@ class f {
310
319
  };
311
320
  }
312
321
  static from(t) {
313
- return Array.isArray(t) ? new f(t[0], t[1]) : "x" in t && "y" in t ? new f(t.x, t.y) : "X" in t && "Y" in t ? new f(t.X, t.Y) : this.zero();
322
+ return Array.isArray(t) ? new p(t[0], t[1]) : "x" in t && "y" in t ? new p(t.x, t.y) : "X" in t && "Y" in t ? new p(t.X, t.Y) : this.zero();
314
323
  }
315
324
  static zero() {
316
- return new f(0, 0);
325
+ return new p(0, 0);
317
326
  }
318
327
  }
319
- class A {
328
+ class v {
320
329
  minX = 0;
321
330
  maxX = 0;
322
331
  minY = 0;
323
332
  maxY = 0;
324
333
  get points() {
325
334
  return [
326
- new f(this.minX, this.minY),
327
- new f(this.maxX, this.minY),
328
- new f(this.maxX, this.maxY),
329
- new f(this.minX, this.maxY)
335
+ new p(this.minX, this.minY),
336
+ new p(this.maxX, this.minY),
337
+ new p(this.maxX, this.maxY),
338
+ new p(this.minX, this.maxY)
330
339
  ];
331
340
  }
332
341
  get width() {
@@ -336,7 +345,7 @@ class A {
336
345
  return this.maxY - this.minY;
337
346
  }
338
347
  get center() {
339
- return new f(
348
+ return new p(
340
349
  this.minX + (this.maxX - this.minX) * 0.5,
341
350
  this.minY + (this.maxY - this.minY) * 0.5
342
351
  );
@@ -367,13 +376,13 @@ class A {
367
376
  return this.minX <= e.x && e.x <= this.maxX && this.minY <= e.y && e.y <= this.maxY;
368
377
  let s = Number.NEGATIVE_INFINITY, r = Number.POSITIVE_INFINITY;
369
378
  if (i !== 0) {
370
- const a = (this.minX - e.x) / i, c = (this.maxX - e.x) / i;
371
- s = Math.max(s, Math.min(a, c)), r = Math.min(r, Math.max(a, c));
379
+ const c = (this.minX - e.x) / i, a = (this.maxX - e.x) / i;
380
+ s = Math.max(s, Math.min(c, a)), r = Math.min(r, Math.max(c, a));
372
381
  } else if (e.x < this.minX || e.x > this.maxX)
373
382
  return !1;
374
383
  if (o !== 0) {
375
- const a = (this.minY - e.y) / o, c = (this.maxY - e.y) / o;
376
- s = Math.max(s, Math.min(a, c)), r = Math.min(r, Math.max(a, c));
384
+ const c = (this.minY - e.y) / o, a = (this.maxY - e.y) / o;
385
+ s = Math.max(s, Math.min(c, a)), r = Math.min(r, Math.max(c, a));
377
386
  } else if (e.y < this.minY || e.y > this.maxY)
378
387
  return !1;
379
388
  return s <= r && s <= 1 && r >= 0;
@@ -393,29 +402,29 @@ class A {
393
402
  intersectRectangle(t) {
394
403
  const e = (s) => this.minX <= s.x && s.x <= this.maxX && this.minY <= s.y && s.y <= this.maxY, n = (s) => {
395
404
  let r = 0;
396
- for (let a = 0; a < 4; a++) {
397
- const c = t.points[a], h = t.points[(a + 1) % 4], l = { x: h.x - c.x, y: h.y - c.y }, d = { x: s.x - c.x, y: s.y - c.y }, x = l.x * d.y - l.y * d.x;
398
- if (x === 0) {
399
- const p = l.x !== 0 ? (s.x - c.x) / l.x : (s.y - c.y) / l.y;
400
- if (p >= 0 && p <= 1) return !0;
405
+ for (let c = 0; c < 4; c++) {
406
+ const a = t.points[c], h = t.points[(c + 1) % 4], l = { x: h.x - a.x, y: h.y - a.y }, d = { x: s.x - a.x, y: s.y - a.y }, f = l.x * d.y - l.y * d.x;
407
+ if (f === 0) {
408
+ const m = l.x !== 0 ? (s.x - a.x) / l.x : (s.y - a.y) / l.y;
409
+ if (m >= 0 && m <= 1) return !0;
401
410
  } else {
402
- const p = x > 0 ? 1 : -1;
403
- if (r === 0 && (r = p), r !== p) return !1;
411
+ const m = f > 0 ? 1 : -1;
412
+ if (r === 0 && (r = m), r !== m) return !1;
404
413
  }
405
414
  }
406
415
  return !0;
407
- }, i = (s, r, a, c) => {
408
- const h = (u, m, y) => {
409
- const S = (m.y - u.y) * (y.x - m.x) - (m.x - u.x) * (y.y - m.y);
416
+ }, i = (s, r, c, a) => {
417
+ const h = (u, x, w) => {
418
+ const S = (x.y - u.y) * (w.x - x.x) - (x.x - u.x) * (w.y - x.y);
410
419
  return S === 0 ? 0 : S > 0 ? 1 : 2;
411
- }, l = (u, m, y) => Math.min(u.x, y.x) <= m.x && m.x <= Math.max(u.x, y.x) && Math.min(u.y, y.y) <= m.y && m.y <= Math.max(u.y, y.y), d = h(s, r, a), x = h(s, r, c), p = h(a, c, s), w = h(a, c, r);
412
- return !!(d !== x && p !== w || d === 0 && l(s, a, r) || x === 0 && l(s, c, r) || p === 0 && l(a, s, c) || w === 0 && l(a, r, c));
420
+ }, l = (u, x, w) => Math.min(u.x, w.x) <= x.x && x.x <= Math.max(u.x, w.x) && Math.min(u.y, w.y) <= x.y && x.y <= Math.max(u.y, w.y), d = h(s, r, c), f = h(s, r, a), m = h(c, a, s), g = h(c, a, r);
421
+ return !!(d !== f && m !== g || d === 0 && l(s, c, r) || f === 0 && l(s, a, r) || m === 0 && l(c, s, a) || g === 0 && l(c, r, a));
413
422
  }, o = this.points;
414
423
  for (let s = 0; s < 4; s++) {
415
- const r = o[s], a = o[(s + 1) % 4];
416
- for (let c = 0; c < 4; c++) {
417
- const h = t.points[c], l = t.points[(c + 1) % 4];
418
- if (i(r, a, h, l)) return !0;
424
+ const r = o[s], c = o[(s + 1) % 4];
425
+ for (let a = 0; a < 4; a++) {
426
+ const h = t.points[a], l = t.points[(a + 1) % 4];
427
+ if (i(r, c, h, l)) return !0;
419
428
  }
420
429
  }
421
430
  for (let s of t.points)
@@ -491,7 +500,7 @@ class A {
491
500
  * @returns
492
501
  */
493
502
  clone() {
494
- return new A(this.minX, this.maxX, this.minY, this.maxY);
503
+ return new v(this.minX, this.maxX, this.minY, this.maxY);
495
504
  }
496
505
  /**
497
506
  *
@@ -502,7 +511,7 @@ class A {
502
511
  const e = [], n = [];
503
512
  return t.forEach((i) => {
504
513
  e.push(i.x), n.push(i.y);
505
- }), new A(
514
+ }), new v(
506
515
  Math.min(...e),
507
516
  Math.max(...e),
508
517
  Math.min(...n),
@@ -510,7 +519,16 @@ class A {
510
519
  );
511
520
  }
512
521
  }
513
- class C {
522
+ function O(y) {
523
+ if (y === null || typeof y != "object") return y;
524
+ if (y instanceof Date) return new Date(y.getTime());
525
+ if (Array.isArray(y)) return y.map(O);
526
+ const t = {};
527
+ for (const e in y)
528
+ Object.prototype.hasOwnProperty.call(y, e) && (t[e] = O(y[e]));
529
+ return t;
530
+ }
531
+ class N {
514
532
  points;
515
533
  get p0() {
516
534
  return this.points[0];
@@ -533,7 +551,7 @@ class C {
533
551
  path2D(t) {
534
552
  return this.points.flatMap((e, n) => {
535
553
  const i = this.points[(n + 1) % this.points.length];
536
- return t && t(new f(e.x, e.y), new f(i.x, i.y)), [e.x, e.y, i.x, i.y];
554
+ return t && t(new p(e.x, e.y), new p(i.x, i.y)), [e.x, e.y, i.x, i.y];
537
555
  });
538
556
  }
539
557
  createGeometry() {
@@ -559,12 +577,12 @@ class C {
559
577
  intersectLineSegment(t) {
560
578
  if (t.points.length !== 2)
561
579
  throw new Error("LineSegment must have exactly 2 points");
562
- const [e, n] = t.points, i = (o, s, r, a) => {
563
- const c = (w, u, m) => {
564
- const y = (u.y - w.y) * (m.x - u.x) - (u.x - w.x) * (m.y - u.y);
565
- return y === 0 ? 0 : y > 0 ? 1 : 2;
566
- }, h = (w, u, m) => Math.min(w.x, m.x) <= u.x && u.x <= Math.max(w.x, m.x) && Math.min(w.y, m.y) <= u.y && u.y <= Math.max(w.y, m.y), l = c(o, s, r), d = c(o, s, a), x = c(r, a, o), p = c(r, a, s);
567
- return !!(l !== d && x !== p || l === 0 && h(o, r, s) || d === 0 && h(o, a, s) || x === 0 && h(r, o, a) || p === 0 && h(r, s, a));
580
+ const [e, n] = t.points, i = (o, s, r, c) => {
581
+ const a = (g, u, x) => {
582
+ const w = (u.y - g.y) * (x.x - u.x) - (u.x - g.x) * (x.y - u.y);
583
+ return w === 0 ? 0 : w > 0 ? 1 : 2;
584
+ }, h = (g, u, x) => Math.min(g.x, x.x) <= u.x && u.x <= Math.max(g.x, x.x) && Math.min(g.y, x.y) <= u.y && u.y <= Math.max(g.y, x.y), l = a(o, s, r), d = a(o, s, c), f = a(r, c, o), m = a(r, c, s);
585
+ return !!(l !== d && f !== m || l === 0 && h(o, r, s) || d === 0 && h(o, c, s) || f === 0 && h(r, o, c) || m === 0 && h(r, s, c));
568
586
  };
569
587
  for (let o = 0; o < 4; o++) {
570
588
  const s = this.points[o], r = this.points[(o + 1) % 4];
@@ -584,9 +602,9 @@ class C {
584
602
  const e = (n) => {
585
603
  let i = 0;
586
604
  for (let o = 0; o < 4; o++) {
587
- const s = this.points[o], r = this.points[(o + 1) % 4], a = { x: r.x - s.x, y: r.y - s.y }, c = { x: n.x - s.x, y: n.y - s.y }, h = a.x * c.y - a.y * c.x;
605
+ const s = this.points[o], r = this.points[(o + 1) % 4], c = { x: r.x - s.x, y: r.y - s.y }, a = { x: n.x - s.x, y: n.y - s.y }, h = c.x * a.y - c.y * a.x;
588
606
  if (h === 0) {
589
- const l = a.x !== 0 ? (n.x - s.x) / a.x : (n.y - s.y) / a.y;
607
+ const l = c.x !== 0 ? (n.x - s.x) / c.x : (n.y - s.y) / c.y;
590
608
  if (l >= 0 && l <= 1) return !0;
591
609
  } else {
592
610
  const l = h > 0 ? 1 : -1;
@@ -614,7 +632,7 @@ class C {
614
632
  e.push(s.normal(r));
615
633
  }
616
634
  function n(o, s) {
617
- const r = o.points.map((a) => a.dot(s));
635
+ const r = o.points.map((c) => c.dot(s));
618
636
  return [Math.min(...r), Math.max(...r)];
619
637
  }
620
638
  function i(o, s) {
@@ -649,7 +667,7 @@ class C {
649
667
  let t = 1 / 0, e = -1 / 0, n = 1 / 0, i = -1 / 0;
650
668
  return this.points.forEach((o) => {
651
669
  e = Math.max(o.x, e), t = Math.min(o.x, t), i = Math.max(o.x, i), n = Math.min(o.x, n);
652
- }), new A(t, e, n, i);
670
+ }), new v(t, e, n, i);
653
671
  }
654
672
  /**
655
673
  *
@@ -658,21 +676,21 @@ class C {
658
676
  * @returns
659
677
  */
660
678
  static fromByLineSegment(t, e = 0.1, n = !1, i = 0.5) {
661
- const o = t.points[0], s = t.points[1], r = s.normal(o), a = n ? s.direction(o).mutiplyScalar(e * i) : f.zero(), c = n ? o.direction(s).mutiplyScalar(e * i) : f.zero(), h = r.x * e * 0.5, l = r.y * e * 0.5;
662
- return new C([
663
- new f(o.x + h, o.y + l).add(c),
664
- new f(s.x + h, s.y + l).add(a),
665
- new f(s.x - h, s.y - l).add(a),
666
- new f(o.x - h, o.y - l).add(c)
679
+ const o = t.points[0], s = t.points[1], r = s.normal(o), c = n ? s.direction(o).mutiplyScalar(e * i) : p.zero(), a = n ? o.direction(s).mutiplyScalar(e * i) : p.zero(), h = r.x * e * 0.5, l = r.y * e * 0.5;
680
+ return new N([
681
+ new p(o.x + h, o.y + l).add(a),
682
+ new p(s.x + h, s.y + l).add(c),
683
+ new p(s.x - h, s.y - l).add(c),
684
+ new p(o.x - h, o.y - l).add(a)
667
685
  ]);
668
686
  }
669
687
  }
670
688
  class b {
671
- points = [new f(), new f()];
689
+ points = [new p(), new p()];
672
690
  userData = {};
673
691
  line;
674
692
  get center() {
675
- return new f(
693
+ return new p(
676
694
  this.points[0].x + (this.points[1].x - this.points[0].x) * 0.5,
677
695
  this.points[0].y + (this.points[1].y - this.points[0].y) * 0.5
678
696
  );
@@ -683,11 +701,35 @@ class b {
683
701
  get end() {
684
702
  return this.points[1];
685
703
  }
686
- constructor(t = new f(), e = new f()) {
704
+ constructor(t = new p(), e = new p()) {
687
705
  this.points = [t, e];
688
706
  }
689
707
  set(t, e) {
690
- this.start.copy(t), this.end.copy(e);
708
+ return this.start.copy(t), this.end.copy(e), this;
709
+ }
710
+ /**
711
+ * 是否有相同端点
712
+ * @param line
713
+ * @returns
714
+ */
715
+ sameEndpoint(t) {
716
+ return this.start.equal(t.start) || this.start.equal(t.end) || this.end.equal(t.start) || this.end.equal(t.end);
717
+ }
718
+ /**
719
+ * 相同端点是否为开始
720
+ * @param line
721
+ * @returns
722
+ */
723
+ sameEndpointAsStart(t) {
724
+ return this.start.equal(t.start) || this.start.equal(t.end);
725
+ }
726
+ /**
727
+ * 相同端点是否为结束
728
+ * @param line
729
+ * @returns
730
+ */
731
+ sameEndpointAsEnd(t) {
732
+ return this.end.equal(t.start) || this.end.equal(t.end);
691
733
  }
692
734
  /** 膨胀
693
735
  * @description 向线段的两个端点分别膨胀 width
@@ -728,15 +770,15 @@ class b {
728
770
  * @returns {Rectangle}
729
771
  */
730
772
  expandToRectangle(t = 0.1, e = "all") {
731
- const n = this.start, i = this.end, o = i.normal(n), s = e === "bothSides" ? f.zero() : i.direction(n).mutiplyScalar(t * 0.5), r = e === "bothSides" ? f.zero() : n.direction(i).mutiplyScalar(t * 0.5), a = o.x * t * 0.5, c = o.y * t * 0.5, h = [
773
+ const n = this.start, i = this.end, o = i.normal(n), s = e === "bothSides" ? p.zero() : i.direction(n).mutiplyScalar(t * 0.5), r = e === "bothSides" ? p.zero() : n.direction(i).mutiplyScalar(t * 0.5), c = o.x * t * 0.5, a = o.y * t * 0.5, h = [
732
774
  // 第一条线
733
- new f(n.x + a, n.y + c).add(r),
734
- new f(i.x + a, i.y + c).add(s),
775
+ new p(n.x + c, n.y + a).add(r),
776
+ new p(i.x + c, i.y + a).add(s),
735
777
  // 第二条线
736
- new f(n.x - a, n.y - c).add(r),
737
- new f(i.x - a, i.y - c).add(s)
778
+ new p(n.x - c, n.y - a).add(r),
779
+ new p(i.x - c, i.y - a).add(s)
738
780
  ];
739
- return new C([0, 1, 3, 2].map((l) => h[l]));
781
+ return new N([0, 1, 3, 2].map((l) => h[l]));
740
782
  }
741
783
  /**
742
784
  * 计算线段的长度
@@ -773,24 +815,24 @@ class b {
773
815
  projectLineSegment(t) {
774
816
  if (t.points.length !== 2 || this.points.length !== 2)
775
817
  throw new Error("每条线段必须由两个点定义");
776
- const [e, n] = t.points, [i, o] = this.points, s = new f(o.x - i.x, o.y - i.y);
818
+ const [e, n] = t.points, [i, o] = this.points, s = new p(o.x - i.x, o.y - i.y);
777
819
  if (s.x === 0 && s.y === 0)
778
820
  throw new Error("投影目标线段的两个点不能重合");
779
- const r = (p) => {
780
- const w = new f(p.x - i.x, p.y - i.y), u = s.x * s.x + s.y * s.y, y = (w.x * s.x + w.y * s.y) / u, S = i.x + y * s.x, D = i.y + y * s.y;
781
- return new f(S, D);
821
+ const r = (m) => {
822
+ const g = new p(m.x - i.x, m.y - i.y), u = s.x * s.x + s.y * s.y, w = (g.x * s.x + g.y * s.y) / u, S = i.x + w * s.x, L = i.y + w * s.y;
823
+ return new p(S, L);
782
824
  };
783
- let a = r(e), c = r(n);
784
- const h = (p) => {
785
- const w = new f(p.x - i.x, p.y - i.y), u = s.x * s.x + s.y * s.y;
786
- return (w.x * s.x + w.y * s.y) / u;
825
+ let c = r(e), a = r(n);
826
+ const h = (m) => {
827
+ const g = new p(m.x - i.x, m.y - i.y), u = s.x * s.x + s.y * s.y;
828
+ return (g.x * s.x + g.y * s.y) / u;
787
829
  };
788
- let l = h(a), d = h(c);
789
- const x = (p) => {
790
- const w = Math.max(0, Math.min(1, p)), u = i.x + w * s.x, m = i.y + w * s.y;
791
- return new f(u, m);
830
+ let l = h(c), d = h(a);
831
+ const f = (m) => {
832
+ const g = Math.max(0, Math.min(1, m)), u = i.x + g * s.x, x = i.y + g * s.y;
833
+ return new p(u, x);
792
834
  };
793
- return (l < 0 || l > 1) && (a = x(l)), (d < 0 || d > 1) && (c = x(d)), a.x === c.x && a.y === c.y ? new b(a, a) : new b(a, c);
835
+ return (l < 0 || l > 1) && (c = f(l)), (d < 0 || d > 1) && (a = f(d)), c.x === a.x && c.y === a.y ? new b(c, c) : new b(c, a);
794
836
  }
795
837
  /**
796
838
  * 计算一条线段在另一条直线上的投影
@@ -799,19 +841,19 @@ class b {
799
841
  * @returns 投影并裁剪后的线段
800
842
  */
801
843
  projectPoint(t, e = !0) {
802
- const [n, i] = this.points, o = new f(i.x - n.x, i.y - n.y);
844
+ const [n, i] = this.points, o = new p(i.x - n.x, i.y - n.y);
803
845
  if (o.x === 0 && o.y === 0)
804
846
  throw new Error("投影目标线段的两个点不能重合");
805
847
  let r = ((h) => {
806
- const l = new f(h.x - n.x, h.y - n.y), d = o.x * o.x + o.y * o.y, p = (l.x * o.x + l.y * o.y) / d, w = n.x + p * o.x, u = n.y + p * o.y;
807
- return new f(w, u);
848
+ const l = new p(h.x - n.x, h.y - n.y), d = o.x * o.x + o.y * o.y, m = (l.x * o.x + l.y * o.y) / d, g = n.x + m * o.x, u = n.y + m * o.y;
849
+ return new p(g, u);
808
850
  })(t);
809
851
  if (!e) return r;
810
- let c = ((h) => {
811
- const l = new f(h.x - n.x, h.y - n.y), d = o.x * o.x + o.y * o.y;
852
+ let a = ((h) => {
853
+ const l = new p(h.x - n.x, h.y - n.y), d = o.x * o.x + o.y * o.y;
812
854
  return (l.x * o.x + l.y * o.y) / d;
813
855
  })(r);
814
- return c < 0 || c > 1 ? null : r;
856
+ return a < 0 || a > 1 ? null : r;
815
857
  }
816
858
  /**
817
859
  * 判断线段是否与另一条线段相交(包含共用端点或部分重合的情况)
@@ -819,14 +861,14 @@ class b {
819
861
  */
820
862
  intersectLineSegment(t) {
821
863
  const e = this.start, n = this.end, i = t.start, o = t.end;
822
- function s(d, x, p) {
823
- return (x.x - d.x) * (p.y - d.y) - (x.y - d.y) * (p.x - d.x);
864
+ function s(d, f, m) {
865
+ return (f.x - d.x) * (m.y - d.y) - (f.y - d.y) * (m.x - d.x);
824
866
  }
825
- function r(d, x, p) {
826
- return Math.min(x.x, p.x) - 1e-10 <= d.x && d.x <= Math.max(x.x, p.x) + 1e-10 && Math.min(x.y, p.y) - 1e-10 <= d.y && d.y <= Math.max(x.y, p.y) + 1e-10;
867
+ function r(d, f, m) {
868
+ return Math.min(f.x, m.x) - 1e-10 <= d.x && d.x <= Math.max(f.x, m.x) + 1e-10 && Math.min(f.y, m.y) - 1e-10 <= d.y && d.y <= Math.max(f.y, m.y) + 1e-10;
827
869
  }
828
- const a = s(e, n, i), c = s(e, n, o), h = s(i, o, e), l = s(i, o, n);
829
- return !!(a * c < 0 && h * l < 0 || Math.abs(a) < 1e-10 && r(i, e, n) || Math.abs(c) < 1e-10 && r(o, e, n) || Math.abs(h) < 1e-10 && r(e, i, o) || Math.abs(l) < 1e-10 && r(n, i, o));
870
+ const c = s(e, n, i), a = s(e, n, o), h = s(i, o, e), l = s(i, o, n);
871
+ return !!(c * a < 0 && h * l < 0 || Math.abs(c) < 1e-10 && r(i, e, n) || Math.abs(a) < 1e-10 && r(o, e, n) || Math.abs(h) < 1e-10 && r(e, i, o) || Math.abs(l) < 1e-10 && r(n, i, o));
830
872
  }
831
873
  /**
832
874
  * 获取交点
@@ -837,8 +879,8 @@ class b {
837
879
  const e = this.start, n = this.end, i = t.start, o = t.end, s = (e.x - n.x) * (i.y - o.y) - (e.y - n.y) * (i.x - o.x);
838
880
  if (Math.abs(s) < 1e-10)
839
881
  return null;
840
- const r = ((e.x - i.x) * (i.y - o.y) - (e.y - i.y) * (i.x - o.x)) / s, a = e.x + r * (n.x - e.x), c = e.y + r * (n.y - e.y);
841
- return new f(a, c);
882
+ const r = ((e.x - i.x) * (i.y - o.y) - (e.y - i.y) * (i.x - o.x)) / s, c = e.x + r * (n.x - e.x), a = e.y + r * (n.y - e.y);
883
+ return new p(c, a);
842
884
  }
843
885
  /**
844
886
  * 获取两条线段夹角
@@ -876,28 +918,29 @@ class b {
876
918
  * @returns
877
919
  */
878
920
  areLinesCoincident(t) {
879
- const e = this.start, n = this.end, i = t.start, o = t.end, s = (n.y - e.y) / (n.x - e.x), r = e.y - s * e.x, a = (o.y - i.y) / (o.x - i.x), c = i.y - a * i.x;
880
- return !isFinite(s) && !isFinite(a) ? e.x === i.x && n.x === i.x : Math.abs(s - a) < 1e-3 && Math.abs(r - c) < 1e-3;
921
+ const e = this.start, n = this.end, i = t.start, o = t.end, s = (n.y - e.y) / (n.x - e.x), r = e.y - s * e.x, c = (o.y - i.y) / (o.x - i.x), a = i.y - c * i.x;
922
+ return !isFinite(s) && !isFinite(c) ? e.x === i.x && n.x === i.x : Math.abs(s - c) < 1e-3 && Math.abs(r - a) < 1e-3;
881
923
  }
882
924
  clone() {
883
- return new b(
925
+ const t = new b(
884
926
  this.points[0].clone(),
885
927
  this.points[1].clone()
886
928
  );
929
+ return t.userData = O(this.userData), t;
887
930
  }
888
931
  }
889
- async function j(g, t = !0) {
932
+ async function G(y, t = !0) {
890
933
  if (typeof global < "u" && typeof require < "u")
891
- return require(g);
934
+ return require(y);
892
935
  {
893
936
  let e = await import(
894
937
  /* @vite-ignore */
895
- g
938
+ y
896
939
  );
897
940
  return t && (e = e.default), e;
898
941
  }
899
942
  }
900
- const nt = {
943
+ const st = {
901
944
  Unitless: 1,
902
945
  // 无单位,1米 = 1(无单位)
903
946
  Inches: 39.37007874015748,
@@ -941,27 +984,27 @@ const nt = {
941
984
  Parsecs: 3240779289666404e-32
942
985
  // 秒差距,1米 ≈ 0.00000000000000003240779289666404秒差距
943
986
  };
944
- function F(g) {
987
+ function k(y) {
945
988
  const t = [];
946
- for (let e = 0; e < g.length; e++)
989
+ for (let e = 0; e < y.length; e++)
947
990
  t.push(new b(
948
- g[e].clone(),
949
- g[(e + 1) % g.length].clone()
991
+ y[e].clone(),
992
+ y[(e + 1) % y.length].clone()
950
993
  ));
951
994
  return t;
952
995
  }
953
- function z(g) {
954
- return g.flatMap((t, e) => (e === g.length - 1 && [...t.points, g[0].points[0]], [t.points[0]]));
996
+ function J(y) {
997
+ return y.flatMap((t, e) => (e === y.length - 1 && [...t.points, y[0].points[0]], [t.points[0]]));
955
998
  }
956
- class I extends X {
999
+ class X extends j {
957
1000
  static name = "Dxf";
958
1001
  shortLine = 0.04;
959
1002
  width = 0.04;
960
1003
  scale = 1;
961
1004
  originalData = [];
962
1005
  data = [];
963
- originalBox = new A(0, 0, 0, 0);
964
- box = new A(0, 0, 0, 0);
1006
+ originalBox = new v(0, 0, 0, 0);
1007
+ box = new v(0, 0, 0, 0);
965
1008
  pointsGroups = [];
966
1009
  wallsGroup = [];
967
1010
  doors = [];
@@ -1005,24 +1048,24 @@ class I extends X {
1005
1048
  const { default: s } = await import(
1006
1049
  /* @vite-ignore */
1007
1050
  "fs"
1008
- ), r = s.readFileSync(t), a = JSON.parse(r.toString("utf-8"));
1009
- return this.set(a, e, n);
1051
+ ), r = s.readFileSync(t), c = JSON.parse(r.toString("utf-8"));
1052
+ return this.set(c, e, n);
1010
1053
  } else
1011
1054
  throw new Error("非node环境不允许使用路径");
1012
1055
  this.scale = n, this.width = e, this.originalData = t, this.lineSegments.length = 0;
1013
1056
  const i = [];
1014
- this.data = t.map(({ start: o, end: s, insetionArr: r, isDoor: a = !1, isWindow: c, drawDoorData: h }, l) => {
1057
+ this.data = t.map(({ start: o, end: s, insetionArr: r, isDoor: c = !1, ...a }, h) => {
1015
1058
  i.push(o.z ?? 0, s.z ?? 0);
1016
- const d = new b(
1017
- f.from(o).mutiplyScalar(n),
1018
- f.from(s).mutiplyScalar(n)
1059
+ const l = new b(
1060
+ p.from(o).mutiplyScalar(n),
1061
+ p.from(s).mutiplyScalar(n)
1019
1062
  );
1020
- return d.userData = { isDoor: a, isWindow: c, drawDoorData: h }, this.lineSegments.push(d), [
1021
- d.points[0],
1022
- d.points[1],
1023
- (r ?? []).map((x) => x.index),
1024
- a,
1025
- l
1063
+ return l.userData = { isDoor: c, ...a }, this.lineSegments.push(l), [
1064
+ l.points[0],
1065
+ l.points[1],
1066
+ (r ?? []).map((d) => d.index),
1067
+ c,
1068
+ h
1026
1069
  ];
1027
1070
  }), this.originalZAverage = i.reduce((o, s) => o + s, 0) / i.length, this.computedOriginalSize(t, this.originalBox), this.dispatchEvent({
1028
1071
  type: "setDta",
@@ -1038,18 +1081,18 @@ class I extends X {
1038
1081
  * @returns
1039
1082
  */
1040
1083
  createGroups() {
1041
- const t = [], e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), o = (s, r, a = -1) => {
1042
- const [c, h, l, d] = this.data[s];
1084
+ const t = [], e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), o = (s, r, c = -1) => {
1085
+ const [a, h, l, d] = this.data[s];
1043
1086
  if (e.add(s), d)
1044
- return i.has(s) || i.set(s, []), i.get(s)?.push(a), n.add(this.data[s]);
1045
- r.push([c, h]), l.forEach((x) => {
1046
- e.has(x) || o(x, r, s);
1087
+ return i.has(s) || i.set(s, []), i.get(s)?.push(c), n.add(this.data[s]);
1088
+ r.push([a, h]), l.forEach((f) => {
1089
+ e.has(f) || o(f, r, s);
1047
1090
  });
1048
1091
  };
1049
1092
  return this.data.forEach((s, r) => {
1050
1093
  if (!e.has(r)) {
1051
- const a = [];
1052
- o(r, a), t.push(a);
1094
+ const c = [];
1095
+ o(r, c), t.push(c);
1053
1096
  }
1054
1097
  }), this.doors = [...n], this.pointsGroups = t, t;
1055
1098
  }
@@ -1059,7 +1102,7 @@ class I extends X {
1059
1102
  * @returns
1060
1103
  */
1061
1104
  computedSize() {
1062
- const t = this.pointsGroups.flatMap((r) => r.flatMap((a) => [a[0].x, a[1].x])), e = this.pointsGroups.flatMap((r) => r.flatMap((a) => [a[0].y, a[1].y])), n = Math.min(...t), i = Math.min(...e), o = Math.max(...t), s = Math.max(...e);
1105
+ const t = this.pointsGroups.flatMap((r) => r.flatMap((c) => [c[0].x, c[1].x])), e = this.pointsGroups.flatMap((r) => r.flatMap((c) => [c[0].y, c[1].y])), n = Math.min(...t), i = Math.min(...e), o = Math.max(...t), s = Math.max(...e);
1063
1106
  return this.box.set(n, i, o, s), this.box;
1064
1107
  }
1065
1108
  /** 线路拓扑
@@ -1069,12 +1112,12 @@ class I extends X {
1069
1112
  lineTopology(t) {
1070
1113
  const e = [];
1071
1114
  function n(o, s) {
1072
- const [r, a] = t[o];
1073
- e[o] = !0, s.push(a);
1074
- for (let c = 0; c < t.length; c++) {
1075
- const [h, l] = t[c];
1076
- if (!e[c] && Math.abs(a.x - h.x) < 1e-6 && Math.abs(a.y - h.y) < 1e-6)
1077
- return n(c, s);
1115
+ const [r, c] = t[o];
1116
+ e[o] = !0, s.push(c);
1117
+ for (let a = 0; a < t.length; a++) {
1118
+ const [h, l] = t[a];
1119
+ if (!e[a] && Math.abs(c.x - h.x) < 1e-6 && Math.abs(c.y - h.y) < 1e-6)
1120
+ return n(a, s);
1078
1121
  }
1079
1122
  }
1080
1123
  const i = [];
@@ -1111,9 +1154,9 @@ class I extends X {
1111
1154
  const i = t[n - 1], o = t[n];
1112
1155
  if (i.distance(o) < this.width * 0.5) {
1113
1156
  let r = 0;
1114
- for (let a = n + 1; a < t.length; a++) {
1115
- const c = t[a - 1], h = t[a];
1116
- if (c.distance(h) < this.width * 0.8) r++;
1157
+ for (let c = n + 1; c < t.length; c++) {
1158
+ const a = t[c - 1], h = t[c];
1159
+ if (a.distance(h) < this.width * 0.8) r++;
1117
1160
  else break;
1118
1161
  }
1119
1162
  r === 0 && n + r === t.length - 1 || n == 1 && r === 1 || (r === 3 ? (e.push(t[n + 1]), n += r) : r === 5 ? (e.push(t[n + 2]), n += r) : e.push(o));
@@ -1135,7 +1178,7 @@ class I extends X {
1135
1178
  break;
1136
1179
  }
1137
1180
  }
1138
- const e = this.mergeSameDirectionLine(F(t)), n = [e[0]];
1181
+ const e = this.mergeSameDirectionLine(k(t)), n = [e[0]];
1139
1182
  for (let i = 1; i < e.length; i++) {
1140
1183
  const o = e[i], s = e[(e.length + i - 1) % e.length];
1141
1184
  if (o.length() > this.width * 0.9) {
@@ -1147,10 +1190,10 @@ class I extends X {
1147
1190
  n.push(o), n.push(r), i = i + 1;
1148
1191
  continue;
1149
1192
  }
1150
- const a = e[i + 2];
1151
- a && s.includedAngle(a) < 2 ? (i = i + 2, n.push(a)) : n.push(o);
1193
+ const c = e[i + 2];
1194
+ c && s.includedAngle(c) < 2 ? (i = i + 2, n.push(c)) : n.push(o);
1152
1195
  }
1153
- return n.length > 3 ? z(this.mergeSameDirectionLine(n)) : [];
1196
+ return n.length > 3 ? J(this.mergeSameDirectionLine(n)) : [];
1154
1197
  }
1155
1198
  /**
1156
1199
  * 移除短线段
@@ -1158,48 +1201,48 @@ class I extends X {
1158
1201
  * @param path
1159
1202
  */
1160
1203
  removeShortLine(t, e = this.shortLine) {
1161
- const n = F(t), i = [], o = Math.PI / 180;
1204
+ const n = k(t), i = [], o = Math.PI / 180;
1162
1205
  for (let s = 0; s < n.length; s++) {
1163
- const r = n[s], a = r.length(), c = s;
1164
- if (a > e || i.length === 0) {
1206
+ const r = n[s], c = r.length(), a = s;
1207
+ if (c > e || i.length === 0) {
1165
1208
  i.push(r);
1166
1209
  continue;
1167
1210
  }
1168
1211
  let h = n[++s];
1169
1212
  const l = i[i.length - 1], d = l.direction();
1170
1213
  for (; s < n.length; ) {
1171
- const p = d.angleBetween(h.direction()) / o;
1172
- if (h.length() <= e || p < 4 || p > 176)
1214
+ const m = d.angleBetween(h.direction()) / o;
1215
+ if (h.length() <= e || m < 4 || m > 176)
1173
1216
  h = n[++s];
1174
1217
  else break;
1175
1218
  }
1176
1219
  if (!h) continue;
1177
- const x = n[s - 1];
1178
- if (l.length() > x.length()) {
1179
- const p = l.getIntersection(h);
1180
- if (p) {
1181
- const w = l.points[1].clone(), u = h.points[0].clone();
1182
- l.points[1].copy(p), h.points[0].copy(p), l.length() < this.width ? (l.points[1].copy(w), h.points[0].copy(w)) : h.length() < this.width && (l.points[1].copy(u), h.points[0].copy(u));
1220
+ const f = n[s - 1];
1221
+ if (l.length() > f.length()) {
1222
+ const m = l.getIntersection(h);
1223
+ if (m) {
1224
+ const g = l.points[1].clone(), u = h.points[0].clone();
1225
+ l.points[1].copy(m), h.points[0].copy(m), l.length() < this.width ? (l.points[1].copy(g), h.points[0].copy(g)) : h.length() < this.width && (l.points[1].copy(u), h.points[0].copy(u));
1183
1226
  } else
1184
1227
  l.points[1].copy(h.points[0]);
1185
1228
  i.push(h);
1186
1229
  } else
1187
- s = c;
1230
+ s = a;
1188
1231
  }
1189
- return i.length > 3 ? z(i) : [];
1232
+ return i.length > 3 ? J(i) : [];
1190
1233
  }
1191
1234
  /** 线偏移
1192
1235
  * @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
1193
1236
  */
1194
- lineOffset(t = I.EndType.etOpenSquare, e = I.JoinType.jtMiter, n = 1e4) {
1195
- let i = new V.Paths();
1196
- const o = new V.ClipperOffset(20, 0.25);
1237
+ lineOffset(t = X.EndType.etOpenSquare, e = X.JoinType.jtMiter, n = 1e4) {
1238
+ let i = new F.Paths();
1239
+ const o = new F.ClipperOffset(20, 0.25);
1197
1240
  return this.pointsGroups.forEach((s) => {
1198
- const r = this.lineTopology(s).map((a) => a.map((c) => c.clone().mutiplyScalar(n)));
1241
+ const r = this.lineTopology(s).map((c) => c.map((a) => a.clone().mutiplyScalar(n)));
1199
1242
  o.AddPaths(r, e, t);
1200
1243
  }), o.Execute(i, this.width / 2 * n), this.wallsGroup = i.map((s) => {
1201
- let r = s.map((a) => f.from(a).divisionScalar(n));
1202
- return r = this.lineSegmentStraightening(r), t == I.EndType.etOpenSquare && (r = this.squareRemoveBurr(r)), r = this.removeShortLine(r), r;
1244
+ let r = s.map((c) => p.from(c).divisionScalar(n));
1245
+ return r = this.lineSegmentStraightening(r), t == X.EndType.etOpenSquare && (r = this.squareRemoveBurr(r)), r = this.removeShortLine(r), r;
1203
1246
  }), this.dispatchEvent({
1204
1247
  type: "lineOffset",
1205
1248
  wallsGroup: this.wallsGroup
@@ -1212,8 +1255,8 @@ class I extends X {
1212
1255
  const n = [];
1213
1256
  return this.wallsGroup.forEach((i) => {
1214
1257
  for (let o = 0; o < i.length; o++) {
1215
- const s = i[o], r = o === i.length - 1 ? 0 : o + 1, a = i[r];
1216
- n.push(s.X * t, s.Y * t, e, a.X * t, a.Y * t, e);
1258
+ const s = i[o], r = o === i.length - 1 ? 0 : o + 1, c = i[r];
1259
+ n.push(s.X * t, s.Y * t, e, c.X * t, c.Y * t, e);
1217
1260
  }
1218
1261
  }), new Float32Array(n);
1219
1262
  }
@@ -1225,58 +1268,133 @@ class I extends X {
1225
1268
  */
1226
1269
  getArcAngleRange(t, e, n) {
1227
1270
  const i = e.x - t.x, o = e.y - t.y, s = n.x - t.x, r = n.y - t.y;
1228
- let a = Math.atan2(o, i), c = Math.atan2(r, s);
1229
- a = a < 0 ? a + 2 * Math.PI : a, c = c < 0 ? c + 2 * Math.PI : c;
1271
+ let c = Math.atan2(o, i), a = Math.atan2(r, s);
1272
+ c = c < 0 ? c + 2 * Math.PI : c, a = a < 0 ? a + 2 * Math.PI : a;
1230
1273
  let h, l;
1231
- return Math.abs(c - a) <= Math.PI ? (h = Math.min(a, c), l = Math.max(a, c)) : (h = Math.max(a, c), l = Math.min(a, c) + 2 * Math.PI), [h / (Math.PI / 180), l / (Math.PI / 180)];
1274
+ return Math.abs(a - c) <= Math.PI ? (h = Math.min(c, a), l = Math.max(c, a)) : (h = Math.max(c, a), l = Math.min(c, a) + 2 * Math.PI), [h / (Math.PI / 180), l / (Math.PI / 180)];
1232
1275
  }
1233
1276
  /**
1234
- * 将点云结构转换为string
1277
+ * 转为绘制数据
1235
1278
  */
1236
- toDxfString(t = "Millimeters") {
1237
- const e = new N();
1238
- e.setUnits("Millimeters");
1239
- const n = nt[t];
1240
- function i(r, a) {
1241
- e.drawLine(r.X * n, r.Y * n, a.X * n, a.Y * n);
1279
+ toDrawDataJson(t = "Millimeters") {
1280
+ const e = st[t], n = {
1281
+ unit: t,
1282
+ line: [],
1283
+ arc: [],
1284
+ dimensionLine: [],
1285
+ center: this.box.center.toJson(),
1286
+ width: this.box.width * e,
1287
+ height: this.box.height * e,
1288
+ scale: e
1289
+ };
1290
+ let i = "white";
1291
+ function o(a, h) {
1292
+ n.line.push([a.X * e, a.Y * e, h.X * e, h.Y * e, i]);
1293
+ }
1294
+ function s(a, h, l, d) {
1295
+ n.arc.push([
1296
+ a.x * e,
1297
+ a.y * e,
1298
+ h * e,
1299
+ l,
1300
+ d,
1301
+ i
1302
+ ]);
1303
+ }
1304
+ for (let a = 0; a < this.originalData.length; a++) {
1305
+ const h = this.originalData[a];
1306
+ if (h.isVerticalReferenceLine) {
1307
+ n.dimensionLine.push([h.start.x * e, h.start.y * e, h.end.x * e, h.end.y * e]);
1308
+ break;
1309
+ }
1242
1310
  }
1243
- this.wallsGroup.forEach((r) => {
1244
- for (let a = 0; a < r.length; a++) {
1245
- const c = r[a], h = a === r.length - 1 ? 0 : a + 1, l = r[h];
1246
- i(c, l);
1311
+ this.wallsGroup.forEach((a) => {
1312
+ for (let h = 0; h < a.length; h++) {
1313
+ const l = a[h], d = h === a.length - 1 ? 0 : h + 1, f = a[d];
1314
+ o(l, f);
1247
1315
  }
1248
1316
  });
1249
- const o = this.width * 0.2, s = [];
1250
- return e.addLayer("l_cyan", N.ACI.CYAN, "DOTTED"), this.doorLineSegment.forEach((r) => {
1251
- if (r.length() < 0.4) return;
1252
- const a = r.clone().expansion(-this.width * 0.5);
1253
- if (e.setActiveLayer("l_cyan"), a.length() < 1.2) {
1254
- a.expansion(-o * 0.5);
1255
- const c = r.normal();
1256
- let h = new b(
1257
- a.start.clone(),
1258
- a.start.clone().add(c.clone().multiplyScalar(a.length()))
1317
+ const r = this.width * 0.2, c = [];
1318
+ return this.doorLineSegment.forEach((a) => {
1319
+ if (a.length() < 0.4) return;
1320
+ const h = a.clone().expansion(-this.width * 0.5);
1321
+ if (i = "cyan", h.length() < 1.2) {
1322
+ h.expansion(-r * 0.5);
1323
+ const l = a.normal();
1324
+ let d = new b(
1325
+ h.start.clone(),
1326
+ h.start.clone().add(l.clone().multiplyScalar(h.length()))
1259
1327
  );
1260
- const l = h.clone().directionMove(h.normal(), a.length() * -0.5).expandToRectangle(a.length(), "bothSides");
1261
- for (let y = 0; y < s.length; y++)
1262
- if (s[y].intersectRectangle(l)) {
1263
- h = new b(
1264
- a.start.clone(),
1265
- a.start.clone().add(c.clone().multiplyScalar(-a.length()))
1328
+ const f = d.clone().directionMove(d.normal(), h.length() * -0.5).expandToRectangle(h.length(), "bothSides");
1329
+ for (let L = 0; L < c.length; L++)
1330
+ if (c[L].intersectRectangle(f)) {
1331
+ d = new b(
1332
+ h.start.clone(),
1333
+ h.start.clone().add(l.clone().multiplyScalar(-h.length()))
1266
1334
  );
1267
1335
  break;
1268
1336
  }
1269
- h.expansion(-o * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((y, S) => i(y, S));
1270
- const d = a.length(), x = h.length(), p = (d ** 2 + x ** 2) / (2 * x), w = h.end.clone().add(h.direction().multiplyScalar(-p)), [u, m] = this.getArcAngleRange(w, a.end, h.end);
1271
- e.drawArc(w.x * n, w.y * n, p * n, Math.min(u, m), Math.max(u, m)), s.push(l);
1337
+ d.expansion(-r * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((L, P) => o(L, P));
1338
+ const m = h.length(), g = d.length(), u = (m ** 2 + g ** 2) / (2 * g), x = d.end.clone().add(d.direction().multiplyScalar(-u)), [w, S] = this.getArcAngleRange(x, h.end, d.end);
1339
+ s(x, u, Math.min(w, S), Math.max(w, S)), c.push(f);
1272
1340
  } else
1273
- a.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((c, h) => i(c, h)), a.clone().directionMove(a.normal(), o * 0.5).directionMove(a.direction(), o * 0.5).expansion(-a.length() * 0.45, "end").forward(o * 0.5).expandToRectangle(o).path2D((c, h) => i(c, h)), a.clone().directionMove(a.normal(), -o * 0.5).directionMove(a.direction(), -o * 0.5).expansion(-a.length() * 0.45, "start").forward(-o * 0.5).expandToRectangle(o).path2D((c, h) => i(c, h));
1274
- }), e.addLayer("l_yellow", N.ACI.YELLOW, "DOTTED"), e.setActiveLayer("l_yellow"), this.lineSegments.forEach((r) => {
1275
- if (!r.userData.isWindow) return !1;
1276
- Array.isArray(r.userData.drawDoorData) && r.userData.drawDoorData.forEach((a) => {
1277
- const { p: c, width: h } = a, l = f.from(c), d = l.clone().add(r.direction().multiplyScalar(h * 0.5)), x = l.clone().add(r.direction().multiplyScalar(-h * 0.5)), p = new b(d, x);
1278
- i(p.start, p.end), p.expandToRectangle(this.width, "bothSides").path2D((w, u) => i(w, u));
1341
+ h.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((l, d) => o(l, d)), h.clone().directionMove(h.normal(), r * 0.5).directionMove(h.direction(), r * 0.5).expansion(-h.length() * 0.45, "end").forward(r * 0.5).expandToRectangle(r).path2D((l, d) => o(l, d)), h.clone().directionMove(h.normal(), -r * 0.5).directionMove(h.direction(), -r * 0.5).expansion(-h.length() * 0.45, "start").forward(-r * 0.5).expandToRectangle(r).path2D((l, d) => o(l, d));
1342
+ }), i = "yellow", this.lineSegments.forEach((a) => {
1343
+ if (!a.userData.isWindow) return !1;
1344
+ Array.isArray(a.userData.drawWindow) && a.userData.drawWindow.forEach((h) => {
1345
+ const { p: l, width: d } = h, f = p.from(l), m = f.clone().add(a.direction().multiplyScalar(d * 0.5)), g = f.clone().add(a.direction().multiplyScalar(-d * 0.5)), u = new b(m, g);
1346
+ o(u.start, u.end), u.expandToRectangle(this.width, "bothSides").path2D((x, w) => o(x, w));
1279
1347
  });
1348
+ }), n;
1349
+ }
1350
+ /**
1351
+ *
1352
+ * @param type
1353
+ */
1354
+ async toDxfImageBlob(t = "Centimeters", e = "image/jpeg") {
1355
+ const n = this.toDrawDataJson(t);
1356
+ let i;
1357
+ if (typeof window < "u")
1358
+ i = document.createElement("canvas");
1359
+ else if (typeof global < "u") {
1360
+ const { createCanvas: c } = await G("canvas");
1361
+ i = c();
1362
+ } else
1363
+ throw new Error("创建画布失败");
1364
+ const o = 2 * n.scale, s = {
1365
+ cyan: "cyan",
1366
+ yellow: "yellow",
1367
+ white: "white"
1368
+ };
1369
+ i.width = n.width + o * 2, i.height = n.height + o * 2;
1370
+ const r = i.getContext("2d");
1371
+ return r.fillRect(0, 0, i.width, i.height), r.translate(n.width * 0.5 + o, n.height * 0.5 + o), n.line.forEach(([c, a, h, l, d]) => {
1372
+ r.strokeStyle = s[d], r.beginPath(), r.moveTo(c, a), r.lineTo(h, l), r.closePath(), r.stroke();
1373
+ }), n.arc.forEach(([c, a, h, l, d, f]) => {
1374
+ r.strokeStyle = s[f], r.beginPath(), r.arc(c, a, h, l * (Math.PI / 180), d * (Math.PI / 180)), r.stroke();
1375
+ }), r.beginPath(), n.dimensionLine.forEach((c) => {
1376
+ let [a, h, l, d] = c;
1377
+ const f = Math.min(h, d), m = Math.max(h, d), g = (i.width * 0.5 - 0.4 * n.scale) * (a < 0 ? -1 : 1), u = (m - f) * 0.45;
1378
+ r.fillStyle = "#fff", r.font = `${0.15 * n.scale}px Arial`, r.textAlign = "center", r.textBaseline = "middle", r.fillText((m - f).toFixed(2) + "cm", g, f + (m - f) * 0.5), r.moveTo(g - 0.1 * n.scale, f), r.lineTo(g + 0.1 * n.scale, f), r.moveTo(g, f), r.lineTo(g, u + f), r.moveTo(g, m), r.lineTo(g, m - u), r.moveTo(g - 0.1 * n.scale, m), r.lineTo(g + 0.1 * n.scale, m);
1379
+ }), r.closePath(), r.strokeStyle = "#fff", r.stroke(), i instanceof HTMLCanvasElement ? new Promise((c) => {
1380
+ i.toBlob((a) => {
1381
+ c(a);
1382
+ }, e, 1);
1383
+ }) : i.toBuffer(e);
1384
+ }
1385
+ /**
1386
+ * 将点json结构转换为Dxf string
1387
+ */
1388
+ toDxfString(t = "Millimeters") {
1389
+ const e = new R();
1390
+ e.setUnits(t), e.addLayer("cyan", R.ACI.CYAN, "DOTTED"), e.addLayer("yellow", R.ACI.YELLOW, "DOTTED"), e.addLayer("white", R.ACI.WHITE, "DOTTED");
1391
+ const n = this.toDrawDataJson();
1392
+ return n.line.forEach((i) => {
1393
+ let [o, s, r, c, a] = i;
1394
+ e.setActiveLayer(a), e.drawLine(o, s, r, c);
1395
+ }), n.arc.forEach((i) => {
1396
+ const [o, s, r, c, a, h] = i;
1397
+ e.setActiveLayer(h), e.drawArc(o, s, r, c, a);
1280
1398
  }), e.toDxfString();
1281
1399
  }
1282
1400
  /**
@@ -1294,16 +1412,29 @@ class I extends X {
1294
1412
  if (typeof window < "u") {
1295
1413
  const n = this.toDxfBlob(e), i = document.createElement("a");
1296
1414
  i.href = URL.createObjectURL(n), i.download = t + ".dxf", i.click();
1297
- } else typeof global < "u" && (await j("fs", !1)).writeFileSync(t, this.toDxfString(e));
1415
+ } else typeof global < "u" && (await G("fs", !1)).writeFileSync(t, this.toDxfString(e));
1416
+ }
1417
+ /**
1418
+ * 下载
1419
+ * @param filename
1420
+ */
1421
+ async downloadImage(t, e = "Centimeters", n = "image/jpg") {
1422
+ const i = await this.toDxfImageBlob(e, n);
1423
+ if (!i) return !1;
1424
+ if (typeof window < "u") {
1425
+ const o = document.createElement("a");
1426
+ o.href = URL.createObjectURL(i), o.download = t, o.click();
1427
+ } else typeof global < "u" && (await G("fs", !1)).writeFileSync(t, i);
1428
+ return !0;
1298
1429
  }
1299
1430
  /**
1300
1431
  * 计算原始数据的边界框
1301
1432
  * @description 计算所有线段的起点和终点的最小最大值,形成一个边界框
1302
1433
  * @returns
1303
1434
  */
1304
- computedOriginalSize(t, e = new A(0, 0, 0, 0)) {
1305
- const n = t.flatMap((c) => [c.start.x, c.end.x]), i = t.flatMap((c) => [c.start.y, c.end.y]), o = Math.min(...n), s = Math.min(...i), r = Math.max(...n), a = Math.max(...i);
1306
- return e.set(o, s, r, a), e;
1435
+ computedOriginalSize(t, e = new v(0, 0, 0, 0)) {
1436
+ const n = t.flatMap((a) => [a.start.x, a.end.x]), i = t.flatMap((a) => [a.start.y, a.end.y]), o = Math.min(...n), s = Math.min(...i), r = Math.max(...n), c = Math.max(...i);
1437
+ return e.set(o, s, r, c), e;
1307
1438
  }
1308
1439
  /**
1309
1440
  * 创建数据
@@ -1313,14 +1444,14 @@ class I extends X {
1313
1444
  static createData(t, e = !0) {
1314
1445
  let n = 0;
1315
1446
  return t.flatMap((o) => {
1316
- const s = o.map((r, a) => {
1317
- const c = a === o.length - 1 ? 0 : a + 1, h = o[c];
1447
+ const s = o.map((r, c) => {
1448
+ const a = c === o.length - 1 ? 0 : c + 1, h = o[a];
1318
1449
  return {
1319
1450
  start: { x: r.x, y: r.y },
1320
1451
  end: { x: h.x, y: h.y },
1321
1452
  insetionArr: [
1322
1453
  {
1323
- index: c + n
1454
+ index: a + n
1324
1455
  }
1325
1456
  ]
1326
1457
  };
@@ -1329,7 +1460,51 @@ class I extends X {
1329
1460
  });
1330
1461
  }
1331
1462
  }
1332
- class k extends X {
1463
+ const I = new b();
1464
+ class ot extends X {
1465
+ static name = "AngleCorrectionDxf";
1466
+ onAddFromParent(t) {
1467
+ const e = t.findComponentByName("Dxf"), n = t.findComponentByName("LineAnalysis");
1468
+ n.addEventListener("analysisCompleted", async () => {
1469
+ let i = 0, o = null;
1470
+ for (let a = 0; a < e.originalData.length; a++) {
1471
+ const h = e.originalData[a];
1472
+ if (I.start.copy(h.start), I.end.copy(h.end), h.isVerticalReferenceLine) {
1473
+ const [l, d] = h.start.y < h.end.y ? [I.start, I.end] : [I.end, I.start];
1474
+ i = -new b(l, d).direction().angleBetween(new p(0, 1), "angle", "360"), o = null;
1475
+ break;
1476
+ }
1477
+ (!o || I.length() > o.length()) && (o = I.clone(), o.userData.index = a);
1478
+ }
1479
+ if (o) {
1480
+ e.originalData[o.userData.index].isVerticalReferenceLine = !0;
1481
+ const [a, h] = o.start.y < o.end.y ? [o.start, o.end] : [o.end, o.start];
1482
+ i = -new b(a, h).direction().angleBetween(new p(0, 1), "angle", "360");
1483
+ }
1484
+ const s = e.originalBox.center, r = p.zero(), c = e.originalData.map((a) => {
1485
+ const h = r.copy(a.start).division(s).rotate(p.zero(), i * (Math.PI / 180)).toJson(a.start.z), l = r.copy(a.end).division(s).rotate(p.zero(), i * (Math.PI / 180)).toJson(a.end.z), d = Object.assign(O(a), { start: h, end: l });
1486
+ return d.drawWindow && d.drawWindow.forEach((f) => {
1487
+ f.p = r.copy(f.p).division(s).rotate(p.zero(), i * (Math.PI / 180)).toJson(f.p.z), f.p.y = -f.p.y;
1488
+ }), d;
1489
+ });
1490
+ n.appendLineSegmentList.forEach((a) => {
1491
+ const h = a.clone();
1492
+ h.start.division(s).rotate(p.zero(), i * (Math.PI / 180)), h.end.division(s).rotate(p.zero(), i * (Math.PI / 180)), c.push({
1493
+ start: h.start.toJson(e.originalZAverage),
1494
+ end: h.end.toJson(e.originalZAverage),
1495
+ insetionArr: [],
1496
+ length: h.length()
1497
+ });
1498
+ }), c.forEach((a) => {
1499
+ a.start.y = -a.start.y, a.end.y = -a.end.y;
1500
+ }), await this.set(c, e.width, e.scale), this.lineOffset(), this.doorLineSegment = e.doorLineSegment.map((a) => {
1501
+ const h = a.clone();
1502
+ return h.start.division(s).rotate(p.zero(), i * (Math.PI / 180)), h.end.division(s).rotate(p.zero(), i * (Math.PI / 180)), h.start.y = -h.start.y, h.end.y = -h.end.y, h;
1503
+ });
1504
+ });
1505
+ }
1506
+ }
1507
+ class _ extends j {
1333
1508
  static name = "Variable";
1334
1509
  originalLineVisible = !0;
1335
1510
  dxfVisible = !0;
@@ -1356,7 +1531,7 @@ class k extends X {
1356
1531
  if (t in this) return this[t];
1357
1532
  }
1358
1533
  }
1359
- class B {
1534
+ class q {
1360
1535
  bounds;
1361
1536
  // 包围盒
1362
1537
  capacity;
@@ -1422,23 +1597,23 @@ class B {
1422
1597
  if (!this.isLeaf) return;
1423
1598
  this.isLeaf = !1, this.children = [];
1424
1599
  const t = (this.bounds.minX + this.bounds.maxX) / 2, e = (this.bounds.minY + this.bounds.maxY) / 2;
1425
- this.children[0] = new B(
1426
- new A(this.bounds.minX, t, this.bounds.minY, e),
1600
+ this.children[0] = new q(
1601
+ new v(this.bounds.minX, t, this.bounds.minY, e),
1427
1602
  this.capacity,
1428
1603
  this.maxDepth,
1429
1604
  this.depth + 1
1430
- ), this.children[1] = new B(
1431
- new A(t, this.bounds.maxX, this.bounds.minY, e),
1605
+ ), this.children[1] = new q(
1606
+ new v(t, this.bounds.maxX, this.bounds.minY, e),
1432
1607
  this.capacity,
1433
1608
  this.maxDepth,
1434
1609
  this.depth + 1
1435
- ), this.children[2] = new B(
1436
- new A(this.bounds.minX, t, e, this.bounds.maxY),
1610
+ ), this.children[2] = new q(
1611
+ new v(this.bounds.minX, t, e, this.bounds.maxY),
1437
1612
  this.capacity,
1438
1613
  this.maxDepth,
1439
1614
  this.depth + 1
1440
- ), this.children[3] = new B(
1441
- new A(t, this.bounds.maxX, e, this.bounds.maxY),
1615
+ ), this.children[3] = new q(
1616
+ new v(t, this.bounds.maxX, e, this.bounds.maxY),
1442
1617
  this.capacity,
1443
1618
  this.maxDepth,
1444
1619
  this.depth + 1
@@ -1467,7 +1642,7 @@ class B {
1467
1642
  * @returns 相交的节点数组
1468
1643
  */
1469
1644
  queryCircle(t, e) {
1470
- const n = [], i = new A(
1645
+ const n = [], i = new v(
1471
1646
  t.x - e,
1472
1647
  t.x + e,
1473
1648
  t.y - e,
@@ -1476,11 +1651,11 @@ class B {
1476
1651
  if (!this.bounds.intersectBox(i))
1477
1652
  return n;
1478
1653
  for (const o of this.nodes) {
1479
- const [s, r] = o.line.points, a = r.x - s.x, c = r.y - s.y, h = a * a + c * c;
1480
- let l = ((t.x - s.x) * a + (t.y - s.y) * c) / h;
1654
+ const [s, r] = o.line.points, c = r.x - s.x, a = r.y - s.y, h = c * c + a * a;
1655
+ let l = ((t.x - s.x) * c + (t.y - s.y) * a) / h;
1481
1656
  l = Math.max(0, Math.min(1, l));
1482
- const d = s.x + l * a, x = s.y + l * c;
1483
- t.distance(new f(d, x)) <= e && n.push(o);
1657
+ const d = s.x + l * c, f = s.y + l * a;
1658
+ t.distance(new p(d, f)) <= e && n.push(o);
1484
1659
  }
1485
1660
  if (!this.isLeaf)
1486
1661
  for (const o of this.children)
@@ -1582,7 +1757,7 @@ class U {
1582
1757
  */
1583
1758
  decodeGridId(t) {
1584
1759
  const [e, n] = t.split(".").map(Number);
1585
- return new f(e, n);
1760
+ return new p(e, n);
1586
1761
  }
1587
1762
  /**
1588
1763
  * 查询与矩形相交的点
@@ -1592,10 +1767,10 @@ class U {
1592
1767
  queryRect(t) {
1593
1768
  const e = t.toBox(), n = Math.ceil(e.minX / this.gridSize), i = Math.ceil(e.maxX / this.gridSize), o = Math.ceil(e.minY / this.gridSize), s = Math.ceil(e.maxY / this.gridSize);
1594
1769
  for (let r = n; r <= i; r++)
1595
- for (let a = o; a <= s; a++) {
1596
- const c = `${r}.${a}`;
1597
- if (!this.map.has(c)) continue;
1598
- this.map.get(c)?.forEach((l) => {
1770
+ for (let c = o; c <= s; c++) {
1771
+ const a = `${r}.${c}`;
1772
+ if (!this.map.has(a)) continue;
1773
+ this.map.get(a)?.forEach((l) => {
1599
1774
  t.containsPoint(l.point);
1600
1775
  });
1601
1776
  }
@@ -1607,16 +1782,16 @@ class U {
1607
1782
  * @returns 相交的节点数组
1608
1783
  */
1609
1784
  queryCircle(t, e) {
1610
- const n = new A(t.x - e, t.x + e, t.y - e, t.y + e), i = Math.ceil(n.minX / this.gridSize), o = Math.ceil(n.maxX / this.gridSize), s = Math.ceil(n.minY / this.gridSize), r = Math.ceil(n.maxY / this.gridSize), a = [];
1611
- for (let c = i; c <= o; c++)
1785
+ const n = new v(t.x - e, t.x + e, t.y - e, t.y + e), i = Math.ceil(n.minX / this.gridSize), o = Math.ceil(n.maxX / this.gridSize), s = Math.ceil(n.minY / this.gridSize), r = Math.ceil(n.maxY / this.gridSize), c = [];
1786
+ for (let a = i; a <= o; a++)
1612
1787
  for (let h = s; h <= r; h++) {
1613
- const l = `${c}.${h}`;
1788
+ const l = `${a}.${h}`;
1614
1789
  if (!this.map.has(l)) continue;
1615
- this.map.get(l)?.forEach((x) => {
1616
- t.distance(x.point) <= e && a.push(x);
1790
+ this.map.get(l)?.forEach((f) => {
1791
+ t.distance(f.point) <= e && c.push(f);
1617
1792
  });
1618
1793
  }
1619
- return a;
1794
+ return c;
1620
1795
  }
1621
1796
  /**
1622
1797
  * 查询与包围盒相交的点
@@ -1626,10 +1801,10 @@ class U {
1626
1801
  queryBox(t) {
1627
1802
  const e = Math.ceil(t.minX / this.gridSize), n = Math.ceil(t.maxX / this.gridSize), i = Math.ceil(t.minY / this.gridSize), o = Math.ceil(t.maxY / this.gridSize), s = [];
1628
1803
  for (let r = e; r <= n; r++)
1629
- for (let a = i; a <= o; a++) {
1630
- const c = `${r}.${a}`;
1631
- if (!this.map.has(c)) continue;
1632
- this.map.get(c)?.forEach((l) => {
1804
+ for (let c = i; c <= o; c++) {
1805
+ const a = `${r}.${c}`;
1806
+ if (!this.map.has(a)) continue;
1807
+ this.map.get(a)?.forEach((l) => {
1633
1808
  t.containsPoint(l.point) && s.push(l);
1634
1809
  });
1635
1810
  }
@@ -1646,7 +1821,7 @@ class U {
1646
1821
  }), n;
1647
1822
  }
1648
1823
  }
1649
- class it {
1824
+ class rt {
1650
1825
  // 所有可查找的点位
1651
1826
  possibleDoorPoints = [];
1652
1827
  doorPoint = [];
@@ -1680,33 +1855,33 @@ class it {
1680
1855
  search(t, e = [], n = 0.6, i = this.doorSearchDistance, o = this.doorSearchNearAngle) {
1681
1856
  const s = this.dxf, r = this.searchNearby(t, e, i, o);
1682
1857
  r.push(
1683
- ...t.map((c) => {
1684
- const h = this.searchAlongDirection(c, i);
1858
+ ...t.map((a) => {
1859
+ const h = this.searchAlongDirection(a, i);
1685
1860
  if (h) return {
1686
- start: c.point,
1861
+ start: a.point,
1687
1862
  end: h.point
1688
1863
  };
1689
- const l = this.searchAlongNormalDirection(c, i);
1864
+ const l = this.searchAlongNormalDirection(a, i);
1690
1865
  if (l) return {
1691
- start: c.point,
1866
+ start: a.point,
1692
1867
  end: l.point
1693
1868
  };
1694
- }).filter((c) => !!c && c.start.distance(c.end) < i)
1869
+ }).filter((a) => !!a && a.start.distance(a.end) < i)
1695
1870
  );
1696
- const a = [];
1697
- return r.forEach((c) => {
1698
- const h = new b(c?.start, c?.end), l = h.length();
1871
+ const c = [];
1872
+ return r.forEach((a) => {
1873
+ const h = new b(a?.start, a?.end), l = h.length();
1699
1874
  if (l < n) return;
1700
- const d = h.normal(), x = h.direction(), p = (l - s.width * 2) / 2;
1701
- for (let w = 0; w < 3; w++) {
1702
- const u = h.start.clone().add(x.clone().multiplyScalar(s.width + p * w)), m = new b(
1875
+ const d = h.normal(), f = h.direction(), m = (l - s.width * 2) / 2;
1876
+ for (let g = 0; g < 3; g++) {
1877
+ const u = h.start.clone().add(f.clone().multiplyScalar(s.width + m * g)), x = new b(
1703
1878
  u,
1704
1879
  u.clone().add(d.clone().multiplyScalar(1))
1705
1880
  );
1706
- if (m.directionMove(d, -0.5), this.quadtree.queryLineSegment(m).length) return;
1881
+ if (x.directionMove(d, -0.5), this.quadtree.queryLineSegment(x).length) return;
1707
1882
  }
1708
- a.push(h);
1709
- }), a;
1883
+ c.push(h);
1884
+ }), c;
1710
1885
  }
1711
1886
  /** 添加可查找点的过滤规则
1712
1887
  * @param rule
@@ -1723,7 +1898,7 @@ class it {
1723
1898
  return this.lineSegments.forEach((e) => {
1724
1899
  e.points.forEach((n, i) => {
1725
1900
  for (let s = 0; s < this._pointsExcludeRule.length; s++) if (this._pointsExcludeRule[s](e, n, i)) return;
1726
- this.pointVirtualGrid.queryPoint(n).filter((s) => s.userData !== e).length === 0 && t.push({ line: e, point: n, uuid: T() });
1901
+ this.pointVirtualGrid.queryPoint(n).filter((s) => s.userData !== e).length === 0 && t.push({ line: e, point: n, uuid: z() });
1727
1902
  });
1728
1903
  }), t;
1729
1904
  }
@@ -1735,21 +1910,21 @@ class it {
1735
1910
  return e.doors.forEach((i) => {
1736
1911
  const o = e.lineSegments[i[4]], s = e.originalData[i[4]];
1737
1912
  if (s.drawDoorData) {
1738
- const r = f.from(s.drawDoorData.start), a = f.from(s.drawDoorData.n), c = n.queryPoint(r).filter((h) => {
1913
+ const r = p.from(s.drawDoorData.start), c = p.from(s.drawDoorData.n), a = n.queryPoint(r).filter((h) => {
1739
1914
  if (h.userData === o) return !1;
1740
1915
  const l = h.userData, d = l.direction();
1741
1916
  l.start.equal(r) && d.multiplyScalar(-1);
1742
- const x = a.angleBetween(d, "angle");
1743
- return x > 80 || x < 10;
1917
+ const f = c.angleBetween(d, "angle");
1918
+ return f > 80 || f < 10;
1744
1919
  });
1745
- c.length && t.push({
1746
- line: c[0].userData,
1920
+ a.length && t.push({
1921
+ line: a[0].userData,
1747
1922
  point: r,
1748
- uuid: T()
1923
+ uuid: z()
1749
1924
  });
1750
1925
  } else if (s.doorDirectConnection) {
1751
1926
  this.continueFind = !1;
1752
- const r = new b(f.from(s.start), f.from(s.end));
1927
+ const r = new b(p.from(s.start), p.from(s.end));
1753
1928
  r.userData = {
1754
1929
  doorDirectConnection: !0,
1755
1930
  isDoor: !0
@@ -1765,8 +1940,8 @@ class it {
1765
1940
  searchDoubleLinePoint() {
1766
1941
  const t = /* @__PURE__ */ new Map();
1767
1942
  return this.resultList.flatMap((e) => {
1768
- const n = this.lineSegments[e.sourceIndex], i = this.lineSegments[e.targetIndex], o = i.projectPoint(n.start), s = i.projectPoint(n.end), r = n.projectPoint(i.start), a = n.projectPoint(i.end), c = o && s ? -1 : o ? 0 : s ? 1 : -1, h = r && a ? -1 : r ? 0 : a ? 1 : -1;
1769
- t.has(e.sourceIndex) ? t.get(e.sourceIndex) != c && t.set(e.sourceIndex, -1) : t.set(e.sourceIndex, c), t.has(e.targetIndex) ? t.get(e.targetIndex) != h && t.set(e.targetIndex, -1) : t.set(e.targetIndex, h);
1943
+ const n = this.lineSegments[e.sourceIndex], i = this.lineSegments[e.targetIndex], o = i.projectPoint(n.start), s = i.projectPoint(n.end), r = n.projectPoint(i.start), c = n.projectPoint(i.end), a = o && s ? -1 : o ? 0 : s ? 1 : -1, h = r && c ? -1 : r ? 0 : c ? 1 : -1;
1944
+ t.has(e.sourceIndex) ? t.get(e.sourceIndex) != a && t.set(e.sourceIndex, -1) : t.set(e.sourceIndex, a), t.has(e.targetIndex) ? t.get(e.targetIndex) != h && t.set(e.targetIndex, -1) : t.set(e.targetIndex, h);
1770
1945
  }), t;
1771
1946
  }
1772
1947
  /** 查找方案一:最近点查找
@@ -1779,94 +1954,94 @@ class it {
1779
1954
  */
1780
1955
  searchNearby(t, e = [], n = this.doorSearchDistance, i = this.doorSearchNearAngle) {
1781
1956
  const o = this.findPointVirtualGrid, s = this.quadtree;
1782
- function r({ point: u, line: m }, y, S) {
1783
- const D = m.direction();
1784
- m.start === u && D.multiplyScalar(-1);
1785
- const P = o.queryCircle(u, n).filter((L) => L.userData !== m).sort((L, E) => L.point.distance(u) - E.point.distance(u)), v = [];
1786
- for (let L = 0; L < P.length; L++) {
1787
- const E = e.findIndex((R) => R.point === P[L].point), Y = t[y].uuid, G = e[E].uuid;
1788
- if (S.has(`${Y}.${G}`)) continue;
1789
- S.add(`${Y}.${G}`), S.add(`${G}.${Y}`);
1790
- const Z = P[L].point, q = new b(u.clone(), Z.clone());
1791
- if (q.direction().angleBetween(D, "angle") < i) {
1792
- const R = t[E].line.direction();
1793
- P[L].userData.start.equal(P[L].point) && R.multiplyScalar(-1), q.direction().multiplyScalar(-1).angleBetween(R, "angle") < i && (s.queryLineSegment(q).length || v.push({
1794
- findData: P[L],
1795
- findUuid: G,
1796
- doorLine: q,
1957
+ function r({ point: u, line: x }, w, S) {
1958
+ const L = x.direction();
1959
+ x.start === u && L.multiplyScalar(-1);
1960
+ const P = o.queryCircle(u, n).filter((D) => D.userData !== x).sort((D, E) => D.point.distance(u) - E.point.distance(u)), A = [];
1961
+ for (let D = 0; D < P.length; D++) {
1962
+ const E = e.findIndex((T) => T.point === P[D].point), Y = t[w].uuid, B = e[E].uuid;
1963
+ if (S.has(`${Y}.${B}`)) continue;
1964
+ S.add(`${Y}.${B}`), S.add(`${B}.${Y}`);
1965
+ const Q = P[D].point, C = new b(u.clone(), Q.clone());
1966
+ if (C.direction().angleBetween(L, "angle") < i) {
1967
+ const T = t[E].line.direction();
1968
+ P[D].userData.start.equal(P[D].point) && T.multiplyScalar(-1), C.direction().multiplyScalar(-1).angleBetween(T, "angle") < i && (s.queryLineSegment(C).length || A.push({
1969
+ findData: P[D],
1970
+ findUuid: B,
1971
+ doorLine: C,
1797
1972
  doorUuid: Y
1798
1973
  }));
1799
1974
  }
1800
1975
  }
1801
- return v;
1976
+ return A;
1802
1977
  }
1803
- function a(u, m, y, S, D) {
1978
+ function c(u, x, w, S, L) {
1804
1979
  S.add(u);
1805
1980
  const P = [];
1806
- D && P.push(D);
1807
- for (let v = 0; v < y.length; v++) {
1808
- const L = y[v];
1809
- if (m.has(L.findUuid)) {
1810
- const E = m.get(L.findUuid);
1811
- a(L.findUuid, m, E, S, L) && P.push(L);
1812
- } else P.push(L);
1981
+ L && P.push(L);
1982
+ for (let A = 0; A < w.length; A++) {
1983
+ const D = w[A];
1984
+ if (x.has(D.findUuid)) {
1985
+ const E = x.get(D.findUuid);
1986
+ c(D.findUuid, x, E, S, D) && P.push(D);
1987
+ } else P.push(D);
1813
1988
  }
1814
- return P.sort((v, L) => v.doorLine.length() - L.doorLine.length()), D && P[0] === D ? (y.splice(0), !0) : (y.splice(1), !1);
1989
+ return P.sort((A, D) => A.doorLine.length() - D.doorLine.length()), L && P[0] === L ? (w.splice(0), !0) : (w.splice(1), !1);
1815
1990
  }
1816
- const c = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map();
1817
- t.map((u, m) => {
1818
- const y = r(u, m, c);
1819
- y.length && h.set(u.uuid, y);
1820
- }), c.clear();
1991
+ const a = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map();
1992
+ t.map((u, x) => {
1993
+ const w = r(u, x, a);
1994
+ w.length && h.set(u.uuid, w);
1995
+ }), a.clear();
1821
1996
  const l = /* @__PURE__ */ new Map();
1822
- h.forEach((u, m) => {
1823
- if (!c.has(m) && u.length && a(m, h, u, c), u.length) {
1824
- const y = u[0];
1825
- l.has(y.doorUuid) || l.set(y.doorUuid, []), l.get(y.doorUuid)?.push(y), l.has(y.findUuid) || l.set(y.findUuid, []), l.get(y.findUuid)?.push(y);
1997
+ h.forEach((u, x) => {
1998
+ if (!a.has(x) && u.length && c(x, h, u, a), u.length) {
1999
+ const w = u[0];
2000
+ l.has(w.doorUuid) || l.set(w.doorUuid, []), l.get(w.doorUuid)?.push(w), l.has(w.findUuid) || l.set(w.findUuid, []), l.get(w.findUuid)?.push(w);
1826
2001
  }
1827
2002
  });
1828
2003
  const d = /* @__PURE__ */ new Set();
1829
2004
  l.forEach((u) => {
1830
2005
  if (u.length > 1) {
1831
- u.sort((m, y) => m.doorLine.length() - y.doorLine.length());
1832
- for (let m = 1; m < u.length; m++) d.add(u[m]);
2006
+ u.sort((x, w) => x.doorLine.length() - w.doorLine.length());
2007
+ for (let x = 1; x < u.length; x++) d.add(u[x]);
1833
2008
  }
1834
2009
  });
1835
- const x = [], p = [];
2010
+ const f = [], m = [];
1836
2011
  h.forEach((u) => {
1837
2012
  if (u.length) {
1838
- const m = u[0];
1839
- d.has(m) || (x.push(m), p.push(m.doorUuid, m.findUuid));
2013
+ const x = u[0];
2014
+ d.has(x) || (f.push(x), m.push(x.doorUuid, x.findUuid));
1840
2015
  }
1841
2016
  });
1842
- const w = [];
1843
- return x.forEach((u) => {
1844
- const m = t.findIndex((E) => E.uuid === u.doorUuid), y = e.findIndex((E) => E.uuid === u.findUuid), S = t[m].point.clone(), D = e[y].point.clone(), P = this.findLongLineSegment(t[m].line), v = this.findLongLineSegment(e[y].line), L = P.projectPoint(D);
1845
- if (L) {
1846
- S.copy(L);
1847
- const E = new b(S, D), Y = v.includedAngle(E);
1848
- (Y < 10 || Y > 170 || Math.abs(90 - Y) < 10) && w.push({
2017
+ const g = [];
2018
+ return f.forEach((u) => {
2019
+ const x = t.findIndex((E) => E.uuid === u.doorUuid), w = e.findIndex((E) => E.uuid === u.findUuid), S = t[x].point.clone(), L = e[w].point.clone(), P = this.findLongLineSegment(t[x].line), A = this.findLongLineSegment(e[w].line), D = P.projectPoint(L);
2020
+ if (D) {
2021
+ S.copy(D);
2022
+ const E = new b(S, L), Y = A.includedAngle(E);
2023
+ (Y < 10 || Y > 170 || Math.abs(90 - Y) < 10) && g.push({
1849
2024
  start: S,
1850
- end: D
2025
+ end: L
1851
2026
  });
1852
2027
  } else {
1853
- const E = v.projectPoint(S);
1854
- E && D.copy(E);
1855
- const Y = new b(S, D), G = P.includedAngle(Y);
1856
- (G < 10 || G > 170 || Math.abs(90 - G) < 10) && w.push({
2028
+ const E = A.projectPoint(S);
2029
+ E && L.copy(E);
2030
+ const Y = new b(S, L), B = P.includedAngle(Y);
2031
+ (B < 10 || B > 170 || Math.abs(90 - B) < 10) && g.push({
1857
2032
  start: S,
1858
- end: D
2033
+ end: L
1859
2034
  });
1860
2035
  }
1861
2036
  }), e.splice(
1862
2037
  0,
1863
2038
  e.length,
1864
- ...e.filter((u) => p.indexOf(u.uuid) === -1)
2039
+ ...e.filter((u) => m.indexOf(u.uuid) === -1)
1865
2040
  ), t.splice(
1866
2041
  0,
1867
2042
  t.length,
1868
- ...t.filter((u) => p.indexOf(u.uuid) === -1)
1869
- ), w;
2043
+ ...t.filter((u) => m.indexOf(u.uuid) === -1)
2044
+ ), g;
1870
2045
  }
1871
2046
  /** 方案二: 沿方向查找
1872
2047
  * @description
@@ -1876,14 +2051,14 @@ class it {
1876
2051
  searchAlongDirection({ point: t, line: e }, n = this.doorSearchDistance) {
1877
2052
  const i = this.quadtree, o = e.direction();
1878
2053
  e.start === t && o.multiplyScalar(-1);
1879
- const s = t.clone().add(o.clone().multiplyScalar(n)), r = new b(t.clone(), s), a = i.queryLineSegment(r).map((c) => ({
1880
- point: c.line.getIntersection(r),
1881
- line: c.line
1882
- })).filter((c) => c.point).sort((c, h) => t.distance(c.point) - t.distance(h.point));
1883
- if (a.length) {
1884
- const c = a[0];
1885
- if (Math.abs(90 - c.line.direction().angleBetween(o, "angle")) < 5)
1886
- return c;
2054
+ const s = t.clone().add(o.clone().multiplyScalar(n)), r = new b(t.clone(), s), c = i.queryLineSegment(r).map((a) => ({
2055
+ point: a.line.getIntersection(r),
2056
+ line: a.line
2057
+ })).filter((a) => a.point).sort((a, h) => t.distance(a.point) - t.distance(h.point));
2058
+ if (c.length) {
2059
+ const a = c[0];
2060
+ if (Math.abs(90 - a.line.direction().angleBetween(o, "angle")) < 5)
2061
+ return a;
1887
2062
  }
1888
2063
  }
1889
2064
  /** 方案三: 沿法线方向查找
@@ -1893,12 +2068,12 @@ class it {
1893
2068
  * @returns
1894
2069
  */
1895
2070
  searchAlongNormalDirection({ point: t, line: e }, n = this.doorSearchDistance) {
1896
- const i = this.pointVirtualGrid, o = this.quadtree, s = e.direction(), r = e.start.normal(e.end), a = e.start.clone();
1897
- e.start === t && s.multiplyScalar(-1), e.start === t && a.copy(e.end);
1898
- const c = i.queryPoint(a).filter((d) => d.userData !== e);
1899
- for (let d = 0; d < c.length; d++) {
1900
- const x = c[d], p = x.userData, w = p.direction();
1901
- if (p.start === x.point && s.multiplyScalar(-1), w.angleBetween(r) / (Math.PI / 180) > 90) {
2071
+ const i = this.pointVirtualGrid, o = this.quadtree, s = e.direction(), r = e.start.normal(e.end), c = e.start.clone();
2072
+ e.start === t && s.multiplyScalar(-1), e.start === t && c.copy(e.end);
2073
+ const a = i.queryPoint(c).filter((d) => d.userData !== e);
2074
+ for (let d = 0; d < a.length; d++) {
2075
+ const f = a[d], m = f.userData, g = m.direction();
2076
+ if (m.start === f.point && s.multiplyScalar(-1), g.angleBetween(r) / (Math.PI / 180) > 90) {
1902
2077
  r.multiplyScalar(-1);
1903
2078
  break;
1904
2079
  }
@@ -1906,7 +2081,7 @@ class it {
1906
2081
  const h = new b(t.clone(), t.clone().add(r.multiplyScalar(n))), l = o.queryLineSegment(h).map((d) => ({
1907
2082
  point: d.line.getIntersection(h),
1908
2083
  line: d.line
1909
- })).filter((d) => d.point).sort((d, x) => t.distance(d.point) - t.distance(x.point));
2084
+ })).filter((d) => d.point).sort((d, f) => t.distance(d.point) - t.distance(f.point));
1910
2085
  if (l.length) {
1911
2086
  const d = l[0];
1912
2087
  if (Math.abs(90 - d.line.direction().angleBetween(r, "angle")) < 5)
@@ -1937,7 +2112,7 @@ class it {
1937
2112
  return e;
1938
2113
  }
1939
2114
  }
1940
- class st extends X {
2115
+ class at extends j {
1941
2116
  static name = "LineAnalysis";
1942
2117
  Dxf = null;
1943
2118
  Variable = null;
@@ -1951,7 +2126,7 @@ class st extends X {
1951
2126
  * @param parent
1952
2127
  */
1953
2128
  onAddFromParent(t) {
1954
- this.Dxf = t.findComponentByType(I), this.Variable = this.parent?.findComponentByType(k), this.Dxf.addEventListener("setDta", this.lineAnalysis.bind(this)), this.Dxf.addEventListener("createGroup", this.doorsAnalysis.bind(this));
2129
+ this.Dxf = t.findComponentByType(X), this.Variable = this.parent?.findComponentByType(_), this.Dxf.addEventListener("setDta", this.lineAnalysis.bind(this)), this.Dxf.addEventListener("createGroup", this.doorsAnalysis.bind(this));
1955
2130
  }
1956
2131
  /**
1957
2132
  *
@@ -1961,15 +2136,15 @@ class st extends X {
1961
2136
  * @returns
1962
2137
  */
1963
2138
  expandLineSegment(t, e, n = 0.1) {
1964
- const i = e.normal(t), o = e.direction(t).mutiplyScalar(n * 0.5), s = t.direction(e).mutiplyScalar(n * 0.5), r = i.x * n * 0.5, a = i.y * n * 0.5;
2139
+ const i = e.normal(t), o = e.direction(t).mutiplyScalar(n * 0.5), s = t.direction(e).mutiplyScalar(n * 0.5), r = i.x * n * 0.5, c = i.y * n * 0.5;
1965
2140
  return {
1966
2141
  points: [
1967
2142
  // 第一条线
1968
- new f(t.x + r, t.y + a).add(s),
1969
- new f(e.x + r, e.y + a).add(o),
2143
+ new p(t.x + r, t.y + c).add(s),
2144
+ new p(e.x + r, e.y + c).add(o),
1970
2145
  // 第二条线
1971
- new f(t.x - r, t.y - a).add(s),
1972
- new f(e.x - r, e.y - a).add(o)
2146
+ new p(t.x - r, t.y - c).add(s),
2147
+ new p(e.x - r, e.y - c).add(o)
1973
2148
  ],
1974
2149
  indices: [0, 1, 1, 3, 3, 2, 2, 0],
1975
2150
  rectIndices: [0, 1, 3, 2, 0]
@@ -1991,14 +2166,14 @@ class st extends X {
1991
2166
  createRectangle(t) {
1992
2167
  const e = this.Dxf, n = t.project, i = t.project2;
1993
2168
  n.includedAngle(i) > 135 && (i.points = [i.points[1], i.points[0]]), this.addData(n.points[0], i.points[0]), this.addData(n.points[1], i.points[1]);
1994
- const o = n.points[0].distance(i.points[0]), s = n.points[1].distance(i.points[1]), r = Math.ceil(Math.max(o, s) / e.width), a = o / r, c = s / r, h = i.points[0].direction(n.points[0]), l = i.points[1].direction(n.points[1]), d = n.points[0].clone(), x = n.points[1].clone(), p = x.direction(d);
1995
- p.multiplyScalar(e.width * 0.5);
1996
- const w = d.clone().add(p), u = x.clone().add(p.multiplyScalar(-1)), m = d.direction(x), y = w.direction(u);
1997
- if (!(m.x > 0 && y.x < 0 || m.x < 0 && y.x > 0 || m.y > 0 && y.y < 0 || m.y < 0 && y.y > 0)) {
1998
- d.set(w.x, w.y), x.set(u.x, u.y);
2169
+ const o = n.points[0].distance(i.points[0]), s = n.points[1].distance(i.points[1]), r = Math.ceil(Math.max(o, s) / e.width), c = o / r, a = s / r, h = i.points[0].direction(n.points[0]), l = i.points[1].direction(n.points[1]), d = n.points[0].clone(), f = n.points[1].clone(), m = f.direction(d);
2170
+ m.multiplyScalar(e.width * 0.5);
2171
+ const g = d.clone().add(m), u = f.clone().add(m.multiplyScalar(-1)), x = d.direction(f), w = g.direction(u);
2172
+ if (!(x.x > 0 && w.x < 0 || x.x < 0 && w.x > 0 || x.y > 0 && w.y < 0 || x.y < 0 && w.y > 0)) {
2173
+ d.set(g.x, g.y), f.set(u.x, u.y);
1999
2174
  for (let S = 1; S < r; S++) {
2000
- const D = h.clone().multiplyScalar(a * S), P = l.clone().multiplyScalar(c * S), v = d.clone().add(D), L = x.clone().add(P);
2001
- this.addData(v, L);
2175
+ const L = h.clone().multiplyScalar(c * S), P = l.clone().multiplyScalar(a * S), A = d.clone().add(L), D = f.clone().add(P);
2176
+ this.addData(A, D);
2002
2177
  }
2003
2178
  }
2004
2179
  }
@@ -2008,7 +2183,7 @@ class st extends X {
2008
2183
  */
2009
2184
  buildQuadtree() {
2010
2185
  const t = this.Dxf, e = [];
2011
- this.quadtree = new B(t.originalBox, 2), t.lineSegments.forEach((n) => {
2186
+ this.quadtree = new q(t.originalBox, 2), t.lineSegments.forEach((n) => {
2012
2187
  n.userData?.isDoor || (this.quadtree?.insert({
2013
2188
  line: n,
2014
2189
  userData: e.length
@@ -2025,8 +2200,8 @@ class st extends X {
2025
2200
  this.buildQuadtree();
2026
2201
  const t = this.quadtree, e = this.lineSegmentList, n = /* @__PURE__ */ new Set(), i = [];
2027
2202
  e.forEach((o, s) => {
2028
- const r = e[s], a = C.fromByLineSegment(r, this.width * 2, !1, -0.01);
2029
- t.queryRect(a).map((h) => h.userData).filter((h) => h !== s).forEach((h) => {
2203
+ const r = e[s], c = N.fromByLineSegment(r, this.width * 2, !1, -0.01);
2204
+ t.queryRect(c).map((h) => h.userData).filter((h) => h !== s).forEach((h) => {
2030
2205
  try {
2031
2206
  if (n.has(`${s}-${h}`) || n.has(`${h}-${s}`)) return;
2032
2207
  const l = this.projectionAnalysis(h, s, r, e);
@@ -2043,36 +2218,39 @@ class st extends X {
2043
2218
  * @returns
2044
2219
  */
2045
2220
  projectionAnalysis(t, e, n, i) {
2046
- const o = i[t], s = n.direction(), r = o.direction(), a = s.angleBetween(r) / (Math.PI / 180);
2047
- if (a < this.errorAngle || a > 180 - this.errorAngle) {
2048
- let c;
2221
+ const o = i[t], s = n.direction(), r = o.direction(), c = s.angleBetween(r) / (Math.PI / 180);
2222
+ if (c < this.errorAngle || c > 180 - this.errorAngle) {
2223
+ let a;
2049
2224
  const h = o.projectLineSegment(n), l = n.projectLineSegment(o);
2050
- return h.getLength() > l.getLength() ? c = {
2225
+ return h.getLength() > l.getLength() ? a = {
2051
2226
  target: o,
2052
2227
  targetIndex: t,
2053
2228
  source: n,
2054
2229
  sourceIndex: e,
2055
2230
  project: h,
2056
2231
  project2: l
2057
- } : c = {
2232
+ } : a = {
2058
2233
  target: n,
2059
2234
  targetIndex: e,
2060
2235
  source: o,
2061
2236
  sourceIndex: t,
2062
2237
  project: l,
2063
2238
  project2: h
2064
- }, !c || c.project.getLength() < 0.2 || c.project2.getLength() < 0.2 ? void 0 : c;
2239
+ }, !a || a.project.getLength() < 0.2 || a.project2.getLength() < 0.2 ? void 0 : a;
2065
2240
  }
2066
2241
  }
2067
2242
  doorSearchNearAngle = 110;
2068
2243
  doorSearchDistance = 2;
2069
2244
  doors = [];
2070
2245
  doorsAnalysis() {
2071
- new it(this);
2246
+ new rt(this), this.dispatchEvent({
2247
+ type: "analysisCompleted"
2248
+ });
2072
2249
  }
2073
2250
  }
2074
- class ot extends et {
2251
+ class ct extends it {
2075
2252
  Dxf;
2253
+ AngleCorrectionDxf;
2076
2254
  Variable;
2077
2255
  wallWidth;
2078
2256
  environment;
@@ -2081,7 +2259,7 @@ class ot extends et {
2081
2259
  * @param scale 原始数据缩放比例
2082
2260
  */
2083
2261
  constructor(t = 0.1, e = 1) {
2084
- super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = t, this.Dxf = new I(this.wallWidth, e), this.Variable = new k(), this.addComponent(this.Variable), this.addComponent(this.Dxf), this.addComponent(new st());
2262
+ super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = t, this.Dxf = new X(this.wallWidth, e), this.AngleCorrectionDxf = new ot(), this.Variable = new _(), this.addComponent(this.Variable), this.addComponent(this.Dxf), this.addComponent(new at()), this.addComponent(this.AngleCorrectionDxf);
2085
2263
  }
2086
2264
  usePlugin(t) {
2087
2265
  return typeof t == "function" && t.call(this, this), this;
@@ -2094,23 +2272,23 @@ class ot extends et {
2094
2272
  });
2095
2273
  }
2096
2274
  }
2097
- const rt = new Q(), at = new tt();
2098
- function ct(g, t, e = 0.1) {
2099
- const n = t.normal(g), i = t.direction(g).mutiplyScalar(e * 0.5), o = g.direction(t).mutiplyScalar(e * 0.5), s = n.x * e * 0.5, r = n.y * e * 0.5;
2275
+ const ht = new et(), lt = new nt();
2276
+ function dt(y, t, e = 0.1) {
2277
+ const n = t.normal(y), i = t.direction(y).mutiplyScalar(e * 0.5), o = y.direction(t).mutiplyScalar(e * 0.5), s = n.x * e * 0.5, r = n.y * e * 0.5;
2100
2278
  return {
2101
2279
  points: [
2102
2280
  // 第一条线
2103
- new f(g.x + s, g.y + r).add(o),
2104
- new f(t.x + s, t.y + r).add(i),
2281
+ new p(y.x + s, y.y + r).add(o),
2282
+ new p(t.x + s, t.y + r).add(i),
2105
2283
  // 第二条线
2106
- new f(g.x - s, g.y - r).add(o),
2107
- new f(t.x - s, t.y - r).add(i)
2284
+ new p(y.x - s, y.y - r).add(o),
2285
+ new p(t.x - s, t.y - r).add(i)
2108
2286
  ],
2109
2287
  indices: [0, 1, 1, 3, 3, 2, 2, 0],
2110
2288
  rectIndices: [0, 1, 3, 2, 0]
2111
2289
  };
2112
2290
  }
2113
- class J extends X {
2291
+ class H extends j {
2114
2292
  static name = "WhiteModel";
2115
2293
  Dxf = null;
2116
2294
  Variable = null;
@@ -2131,7 +2309,7 @@ class J extends X {
2131
2309
  const t = this.Dxf;
2132
2310
  this.originalWhiteMode.clear(), this.whiteModelGroup.clear(), this.whiteModelLineGroup.clear(), this.whiteModelGroup.add(this.whiteModelLineGroup), this.whiteModelGroup.position.z = t.originalZAverage, this.originalWhiteMode.position.z = t.originalZAverage, t.wallsGroup.forEach((n) => {
2133
2311
  const i = new M.Shape();
2134
- n.forEach((r, a) => a === 0 ? i.moveTo(r.x / t.scale, r.y / t.scale) : i.lineTo(r.x / t.scale, r.y / t.scale));
2312
+ n.forEach((r, c) => c === 0 ? i.moveTo(r.x / t.scale, r.y / t.scale) : i.lineTo(r.x / t.scale, r.y / t.scale));
2135
2313
  const o = new M.ExtrudeGeometry(i, {
2136
2314
  depth: 2.8,
2137
2315
  bevelSize: 0
@@ -2140,18 +2318,18 @@ class J extends X {
2140
2318
  new M.LineSegments(new M.EdgesGeometry(o), new M.LineBasicMaterial({ color: 0 }))
2141
2319
  );
2142
2320
  }), t.originalData.map(({ start: n, end: i, insetionArr: o }) => {
2143
- const s = new f(n.x, n.y).mutiplyScalar(t.scale), r = new f(i.x, i.y).mutiplyScalar(t.scale), { points: a, indices: c, rectIndices: h } = ct(s, r, t.width);
2321
+ const s = new p(n.x, n.y).mutiplyScalar(t.scale), r = new p(i.x, i.y).mutiplyScalar(t.scale), { points: c, indices: a, rectIndices: h } = dt(s, r, t.width);
2144
2322
  return {
2145
- points: a,
2146
- indices: c,
2323
+ points: c,
2324
+ indices: a,
2147
2325
  rectIndices: h,
2148
2326
  insetions: (o ?? []).map((l) => l.index)
2149
2327
  };
2150
2328
  }).forEach((n) => {
2151
2329
  const i = new M.Shape();
2152
- n.rectIndices.forEach((r, a) => {
2153
- const c = n.points[r];
2154
- a === 0 ? i.moveTo(c.x, c.y) : i.lineTo(c.x, c.y);
2330
+ n.rectIndices.forEach((r, c) => {
2331
+ const a = n.points[r];
2332
+ c === 0 ? i.moveTo(a.x, a.y) : i.lineTo(a.x, a.y);
2155
2333
  });
2156
2334
  const o = new M.ExtrudeGeometry(i, {
2157
2335
  depth: 2.8,
@@ -2173,7 +2351,7 @@ class J extends X {
2173
2351
  toOBJ() {
2174
2352
  return new Promise((t) => {
2175
2353
  this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(() => {
2176
- t(rt.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
2354
+ t(ht.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
2177
2355
  }, 20);
2178
2356
  });
2179
2357
  }
@@ -2186,7 +2364,7 @@ class J extends X {
2186
2364
  return new Promise((e) => {
2187
2365
  this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(async () => {
2188
2366
  if (typeof window == "object")
2189
- at.parse(this.whiteModelGroup.children, (n) => {
2367
+ lt.parse(this.whiteModelGroup.children, (n) => {
2190
2368
  e(n), this.material.opacity = 0.8, this.material.transparent = !0;
2191
2369
  }, () => {
2192
2370
  e(void 0);
@@ -2195,7 +2373,7 @@ class J extends X {
2195
2373
  });
2196
2374
  else if (typeof global != "function")
2197
2375
  try {
2198
- const n = await j("obj2gltf", !0), i = await j("fs", !1), o = await this.toOBJ();
2376
+ const n = await G("obj2gltf", !0), i = await G("fs", !1), o = await this.toOBJ();
2199
2377
  i.writeFileSync(this.uuid, o);
2200
2378
  const s = await n(this.uuid, {
2201
2379
  binary: t
@@ -2238,7 +2416,7 @@ class J extends X {
2238
2416
  n.href = URL.createObjectURL(e), n.download = t, n.click();
2239
2417
  } else if (typeof global < "u") {
2240
2418
  const e = await this.toOBJ();
2241
- e && (await j("fs", !1)).writeFileSync(t, e);
2419
+ e && (await G("fs", !1)).writeFileSync(t, e);
2242
2420
  }
2243
2421
  }
2244
2422
  /**
@@ -2254,11 +2432,11 @@ class J extends X {
2254
2432
  i.href = URL.createObjectURL(n), i.download = t, i.click();
2255
2433
  } else if (typeof global < "u") {
2256
2434
  const n = await this.toGltf(e);
2257
- n && (await j("fs", !1)).writeFileSync(t, e ? n : Buffer.from(n));
2435
+ n && (await G("fs", !1)).writeFileSync(t, e ? n : Buffer.from(n));
2258
2436
  }
2259
2437
  }
2260
2438
  }
2261
- class _ extends X {
2439
+ class Z extends j {
2262
2440
  static name = "DetailsPoint";
2263
2441
  Dxf = null;
2264
2442
  WhiteModel = null;
@@ -2321,11 +2499,11 @@ class _ extends X {
2321
2499
  this.racasterHelper(n, i, o), i.z = 0;
2322
2500
  const r = new M.Raycaster(n, i, 0, o).intersectObject(t.originalWhiteMode);
2323
2501
  if (r.length) {
2324
- const { point: a } = r[0];
2502
+ const { point: c } = r[0];
2325
2503
  this.desPoints.push({
2326
2504
  message: e.desc,
2327
2505
  position: n,
2328
- intersection: a
2506
+ intersection: c
2329
2507
  });
2330
2508
  }
2331
2509
  }), this.dispatchEvent({
@@ -2335,7 +2513,7 @@ class _ extends X {
2335
2513
  }, 50);
2336
2514
  }
2337
2515
  }
2338
- class H extends X {
2516
+ class K extends j {
2339
2517
  static name = "DxfLineModel";
2340
2518
  dxfLineModel = new M.LineSegments();
2341
2519
  dxfDoorsLineModel = new M.LineSegments();
@@ -2358,38 +2536,38 @@ class H extends X {
2358
2536
  });
2359
2537
  }
2360
2538
  }
2361
- const ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2539
+ const ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2362
2540
  __proto__: null,
2363
- DetailsPoint: _,
2364
- DxfLineModel: H,
2365
- WhiteModel: J
2541
+ DetailsPoint: Z,
2542
+ DxfLineModel: K,
2543
+ WhiteModel: H
2366
2544
  }, Symbol.toStringTag, { value: "Module" }));
2367
- function W(g, t = {}) {
2545
+ function W(y, t = {}) {
2368
2546
  const {
2369
2547
  detailsPoint: e = !0,
2370
2548
  whiteModel: n = !0,
2371
2549
  dxfLineModel: i = !0
2372
2550
  } = t;
2373
- i && g.addComponent(new H()), n && g.addComponent(new J()), e && g.addComponent(new _());
2551
+ i && y.addComponent(new K()), n && y.addComponent(new H()), e && y.addComponent(new Z());
2374
2552
  }
2375
- const lt = Object.assign(W, {
2376
- create(g = {}) {
2377
- return (t) => W(t, g);
2553
+ const ft = Object.assign(W, {
2554
+ create(y = {}) {
2555
+ return (t) => W(t, y);
2378
2556
  }
2379
- }), dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2557
+ }), pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2380
2558
  __proto__: null,
2381
- ModelDataPlugin: lt,
2382
- components: ht
2559
+ ModelDataPlugin: ft,
2560
+ components: ut
2383
2561
  }, Symbol.toStringTag, { value: "Module" }));
2384
- function ut() {
2562
+ function mt() {
2385
2563
  return import("./index2.js");
2386
2564
  }
2387
- function ft() {
2565
+ function xt() {
2388
2566
  return import("./index3.js");
2389
2567
  }
2390
- let O = null;
2391
- async function Dt(g, t, e = !1, n) {
2392
- const i = await Promise.resolve().then(() => dt), o = await ut(), s = await ft(), r = new ot().usePlugin(i.ModelDataPlugin.create({
2568
+ let V = null;
2569
+ async function Et(y, t, e = !1, n) {
2570
+ const i = await Promise.resolve().then(() => pt), o = await mt(), s = await xt(), r = new ct().usePlugin(i.ModelDataPlugin.create({
2393
2571
  detailsPoint: !1,
2394
2572
  whiteModel: !0
2395
2573
  })).usePlugin(o.RenderPlugin.create({
@@ -2398,14 +2576,14 @@ async function Dt(g, t, e = !1, n) {
2398
2576
  detailsPoint: !1,
2399
2577
  orbitControls: e,
2400
2578
  camera: t
2401
- })).usePlugin(s.Editor.create({ viewPermission: n })), a = r.findComponentByType(o.components.DomContainer);
2402
- return a && g.appendChild(a.domElement), O = r, {
2579
+ })).usePlugin(s.Editor.create({ viewPermission: n })), c = r.findComponentByType(o.components.DomContainer);
2580
+ return c && y.appendChild(c.domElement), V = r, {
2403
2581
  dxfSystem: r,
2404
- getFileAll: () => pt(r)
2582
+ getFileAll: () => yt(r)
2405
2583
  };
2406
2584
  }
2407
- async function pt(g = O) {
2408
- const t = g.findComponentByName("WhiteModel"), e = new File([g.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), n = new File([await t.toOBJBlob()], "model.obj", { type: "application/octet-stream" }), i = new File([await t.toGltfBlob(!0)], "model.glb", { type: "application/octet-stream" }), o = new File([await t.toGltfBlob(!1)], "model.gltf", { type: "application/json" }), s = new File([JSON.stringify(g.Dxf.originalData)], "json.json", { type: "application/json" });
2585
+ async function yt(y = V) {
2586
+ const t = y.findComponentByName("WhiteModel"), e = new File([y.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), n = new File([await t.toOBJBlob()], "model.obj", { type: "application/octet-stream" }), i = new File([await t.toGltfBlob(!0)], "model.glb", { type: "application/octet-stream" }), o = new File([await t.toGltfBlob(!1)], "model.gltf", { type: "application/json" }), s = new File([JSON.stringify(y.Dxf.originalData)], "json.json", { type: "application/json" });
2409
2587
  return {
2410
2588
  dxf: e,
2411
2589
  obj: n,
@@ -2414,24 +2592,24 @@ async function pt(g = O) {
2414
2592
  json: s
2415
2593
  };
2416
2594
  }
2417
- function bt() {
2418
- return O;
2595
+ function At() {
2596
+ return V;
2419
2597
  }
2420
2598
  export {
2421
- A as B,
2422
- X as C,
2423
- ot as D,
2599
+ v as B,
2600
+ j as C,
2601
+ ct as D,
2424
2602
  $ as E,
2425
2603
  b as L,
2426
- lt as M,
2427
- f as P,
2428
- B as Q,
2429
- k as V,
2430
- J as W,
2431
- _ as a,
2604
+ ft as M,
2605
+ p as P,
2606
+ q as Q,
2607
+ _ as V,
2608
+ H as W,
2609
+ Z as a,
2432
2610
  U as b,
2433
- Dt as c,
2434
- bt as d,
2435
- pt as g,
2436
- ht as i
2611
+ Et as c,
2612
+ At as d,
2613
+ yt as g,
2614
+ ut as i
2437
2615
  };