build-dxf 0.0.22 → 0.0.23

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
@@ -4,14 +4,14 @@ import F from "clipper-lib";
4
4
  import R from "dxf-writer";
5
5
  import { OBJExporter as et } from "three/examples/jsm/exporters/OBJExporter.js";
6
6
  import { GLTFExporter as nt } from "three/examples/jsm/exporters/GLTFExporter.js";
7
- function N() {
7
+ function O() {
8
8
  return "xxxx-xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function(g) {
9
9
  var t = Math.random() * 16 | 0, e = g == "x" ? t : t & 3 | 8;
10
10
  return e.toString(16);
11
11
  });
12
12
  }
13
13
  class $ extends tt {
14
- uuid = N();
14
+ uuid = O();
15
15
  addEventListener(t, e, n) {
16
16
  const { once: i = !1 } = n ?? {}, s = (r) => {
17
17
  e(r), i && o();
@@ -31,7 +31,7 @@ class $ extends tt {
31
31
  e && (e.forEach((n) => n()), this.eventRecordStack.delete(t));
32
32
  }
33
33
  }
34
- class q extends $ {
34
+ class G extends $ {
35
35
  parent;
36
36
  destroyed = !1;
37
37
  constructor(...t) {
@@ -72,7 +72,7 @@ class it extends $ {
72
72
  * @param component
73
73
  */
74
74
  removeComponent(t) {
75
- if (t instanceof q) {
75
+ if (t instanceof G) {
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 it extends $ {
117
117
  return e || null;
118
118
  }
119
119
  }
120
- class p {
120
+ class x {
121
121
  x;
122
122
  y;
123
123
  get X() {
@@ -234,7 +234,7 @@ class p {
234
234
  */
235
235
  normal(t) {
236
236
  const e = this.x - t.x, n = this.y - t.y, i = Math.sqrt(e * e + n * n), s = -n / i, o = e / i;
237
- return new p(s, o);
237
+ return new x(s, o);
238
238
  }
239
239
  /**
240
240
  * 获取由传入的点到该点的单位方向向量
@@ -244,7 +244,7 @@ class p {
244
244
  */
245
245
  direction(t) {
246
246
  const e = this.x - t.x, n = this.y - t.y, i = Math.sqrt(e * e + n * n);
247
- return i === 0 ? new p(0, 0) : new p(e / i, n / i);
247
+ return i === 0 ? new x(0, 0) : new x(e / i, n / i);
248
248
  }
249
249
  /**
250
250
  * 计算模长
@@ -302,7 +302,7 @@ class p {
302
302
  * @returns
303
303
  */
304
304
  clone() {
305
- return new p(this.x, this.y);
305
+ return new x(this.x, this.y);
306
306
  }
307
307
  /**
308
308
  * 克隆
@@ -319,23 +319,23 @@ class p {
319
319
  };
320
320
  }
321
321
  static from(t) {
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();
322
+ return Array.isArray(t) ? new x(t[0], t[1]) : "x" in t && "y" in t ? new x(t.x, t.y) : "X" in t && "Y" in t ? new x(t.X, t.Y) : this.zero();
323
323
  }
324
324
  static zero() {
325
- return new p(0, 0);
325
+ return new x(0, 0);
326
326
  }
327
327
  }
328
- class v {
328
+ class A {
329
329
  minX = 0;
330
330
  maxX = 0;
331
331
  minY = 0;
332
332
  maxY = 0;
333
333
  get points() {
334
334
  return [
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)
335
+ new x(this.minX, this.minY),
336
+ new x(this.maxX, this.minY),
337
+ new x(this.maxX, this.maxY),
338
+ new x(this.minX, this.maxY)
339
339
  ];
340
340
  }
341
341
  get width() {
@@ -345,7 +345,7 @@ class v {
345
345
  return this.maxY - this.minY;
346
346
  }
347
347
  get center() {
348
- return new p(
348
+ return new x(
349
349
  this.minX + (this.maxX - this.minX) * 0.5,
350
350
  this.minY + (this.maxY - this.minY) * 0.5
351
351
  );
@@ -403,22 +403,22 @@ class v {
403
403
  const e = (o) => this.minX <= o.x && o.x <= this.maxX && this.minY <= o.y && o.y <= this.maxY, n = (o) => {
404
404
  let r = 0;
405
405
  for (let a = 0; a < 4; a++) {
406
- const c = t.points[a], h = t.points[(a + 1) % 4], l = { x: h.x - c.x, y: h.y - c.y }, d = { x: o.x - c.x, y: o.y - c.y }, f = l.x * d.y - l.y * d.x;
407
- if (f === 0) {
408
- const m = l.x !== 0 ? (o.x - c.x) / l.x : (o.y - c.y) / l.y;
409
- if (m >= 0 && m <= 1) return !0;
406
+ const c = t.points[a], h = t.points[(a + 1) % 4], l = { x: h.x - c.x, y: h.y - c.y }, d = { x: o.x - c.x, y: o.y - c.y }, p = l.x * d.y - l.y * d.x;
407
+ if (p === 0) {
408
+ const f = l.x !== 0 ? (o.x - c.x) / l.x : (o.y - c.y) / l.y;
409
+ if (f >= 0 && f <= 1) return !0;
410
410
  } else {
411
- const m = f > 0 ? 1 : -1;
412
- if (r === 0 && (r = m), r !== m) return !1;
411
+ const f = p > 0 ? 1 : -1;
412
+ if (r === 0 && (r = f), r !== f) return !1;
413
413
  }
414
414
  }
415
415
  return !0;
416
416
  }, i = (o, r, a, c) => {
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);
419
- return S === 0 ? 0 : S > 0 ? 1 : 2;
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(o, r, a), f = h(o, r, c), m = h(a, c, o), y = h(a, c, r);
421
- return !!(d !== f && m !== y || d === 0 && l(o, a, r) || f === 0 && l(o, c, r) || m === 0 && l(a, o, c) || y === 0 && l(a, r, c));
417
+ const h = (u, y, w) => {
418
+ const D = (y.y - u.y) * (w.x - y.x) - (y.x - u.x) * (w.y - y.y);
419
+ return D === 0 ? 0 : D > 0 ? 1 : 2;
420
+ }, l = (u, y, w) => Math.min(u.x, w.x) <= y.x && y.x <= Math.max(u.x, w.x) && Math.min(u.y, w.y) <= y.y && y.y <= Math.max(u.y, w.y), d = h(o, r, a), p = h(o, r, c), f = h(a, c, o), m = h(a, c, r);
421
+ return !!(d !== p && f !== m || d === 0 && l(o, a, r) || p === 0 && l(o, c, r) || f === 0 && l(a, o, c) || m === 0 && l(a, r, c));
422
422
  }, s = this.points;
423
423
  for (let o = 0; o < 4; o++) {
424
424
  const r = s[o], a = s[(o + 1) % 4];
@@ -500,7 +500,7 @@ class v {
500
500
  * @returns
501
501
  */
502
502
  clone() {
503
- return new v(this.minX, this.maxX, this.minY, this.maxY);
503
+ return new A(this.minX, this.maxX, this.minY, this.maxY);
504
504
  }
505
505
  /**
506
506
  *
@@ -511,7 +511,23 @@ class v {
511
511
  const e = [], n = [];
512
512
  return t.forEach((i) => {
513
513
  e.push(i.x), n.push(i.y);
514
- }), new v(
514
+ }), new A(
515
+ Math.min(...e),
516
+ Math.max(...e),
517
+ Math.min(...n),
518
+ Math.max(...n)
519
+ );
520
+ }
521
+ /**
522
+ *
523
+ * @param points
524
+ * @returns
525
+ */
526
+ static fromByLineSegment(...t) {
527
+ const e = [], n = [];
528
+ return t.forEach((i) => i.points.forEach((s) => {
529
+ e.push(s.x), n.push(s.y);
530
+ })), new A(
515
531
  Math.min(...e),
516
532
  Math.max(...e),
517
533
  Math.min(...n),
@@ -519,7 +535,7 @@ class v {
519
535
  );
520
536
  }
521
537
  }
522
- class O {
538
+ class N {
523
539
  points;
524
540
  get p0() {
525
541
  return this.points[0];
@@ -542,7 +558,7 @@ class O {
542
558
  path2D(t) {
543
559
  return this.points.flatMap((e, n) => {
544
560
  const i = this.points[(n + 1) % this.points.length];
545
- return t && t(new p(e.x, e.y), new p(i.x, i.y)), [e.x, e.y, i.x, i.y];
561
+ return t && t(new x(e.x, e.y), new x(i.x, i.y)), [e.x, e.y, i.x, i.y];
546
562
  });
547
563
  }
548
564
  createGeometry() {
@@ -569,11 +585,11 @@ class O {
569
585
  if (t.points.length !== 2)
570
586
  throw new Error("LineSegment must have exactly 2 points");
571
587
  const [e, n] = t.points, i = (s, o, r, a) => {
572
- const c = (y, u, x) => {
573
- const w = (u.y - y.y) * (x.x - u.x) - (u.x - y.x) * (x.y - u.y);
588
+ const c = (m, u, y) => {
589
+ const w = (u.y - m.y) * (y.x - u.x) - (u.x - m.x) * (y.y - u.y);
574
590
  return w === 0 ? 0 : w > 0 ? 1 : 2;
575
- }, h = (y, u, x) => Math.min(y.x, x.x) <= u.x && u.x <= Math.max(y.x, x.x) && Math.min(y.y, x.y) <= u.y && u.y <= Math.max(y.y, x.y), l = c(s, o, r), d = c(s, o, a), f = c(r, a, s), m = c(r, a, o);
576
- return !!(l !== d && f !== m || l === 0 && h(s, r, o) || d === 0 && h(s, a, o) || f === 0 && h(r, s, a) || m === 0 && h(r, o, a));
591
+ }, h = (m, u, y) => Math.min(m.x, y.x) <= u.x && u.x <= Math.max(m.x, y.x) && Math.min(m.y, y.y) <= u.y && u.y <= Math.max(m.y, y.y), l = c(s, o, r), d = c(s, o, a), p = c(r, a, s), f = c(r, a, o);
592
+ return !!(l !== d && p !== f || l === 0 && h(s, r, o) || d === 0 && h(s, a, o) || p === 0 && h(r, s, a) || f === 0 && h(r, o, a));
577
593
  };
578
594
  for (let s = 0; s < 4; s++) {
579
595
  const o = this.points[s], r = this.points[(s + 1) % 4];
@@ -658,7 +674,7 @@ class O {
658
674
  let t = 1 / 0, e = -1 / 0, n = 1 / 0, i = -1 / 0;
659
675
  return this.points.forEach((s) => {
660
676
  e = Math.max(s.x, e), t = Math.min(s.x, t), i = Math.max(s.x, i), n = Math.min(s.x, n);
661
- }), new v(t, e, n, i);
677
+ }), new A(t, e, n, i);
662
678
  }
663
679
  /**
664
680
  *
@@ -667,21 +683,21 @@ class O {
667
683
  * @returns
668
684
  */
669
685
  static fromByLineSegment(t, e = 0.1, n = !1, i = 0.5) {
670
- const s = t.points[0], o = t.points[1], r = o.normal(s), a = n ? o.direction(s).mutiplyScalar(e * i) : p.zero(), c = n ? s.direction(o).mutiplyScalar(e * i) : p.zero(), h = r.x * e * 0.5, l = r.y * e * 0.5;
671
- return new O([
672
- new p(s.x + h, s.y + l).add(c),
673
- new p(o.x + h, o.y + l).add(a),
674
- new p(o.x - h, o.y - l).add(a),
675
- new p(s.x - h, s.y - l).add(c)
686
+ const s = t.points[0], o = t.points[1], r = o.normal(s), a = n ? o.direction(s).mutiplyScalar(e * i) : x.zero(), c = n ? s.direction(o).mutiplyScalar(e * i) : x.zero(), h = r.x * e * 0.5, l = r.y * e * 0.5;
687
+ return new N([
688
+ new x(s.x + h, s.y + l).add(c),
689
+ new x(o.x + h, o.y + l).add(a),
690
+ new x(o.x - h, o.y - l).add(a),
691
+ new x(s.x - h, s.y - l).add(c)
676
692
  ]);
677
693
  }
678
694
  }
679
695
  class L {
680
- points = [new p(), new p()];
696
+ points = [new x(), new x()];
681
697
  userData = {};
682
698
  // line: any
683
699
  get center() {
684
- return new p(
700
+ return new x(
685
701
  this.points[0].x + (this.points[1].x - this.points[0].x) * 0.5,
686
702
  this.points[0].y + (this.points[1].y - this.points[0].y) * 0.5
687
703
  );
@@ -692,7 +708,7 @@ class L {
692
708
  get end() {
693
709
  return this.points[1];
694
710
  }
695
- constructor(t = new p(), e = new p()) {
711
+ constructor(t = new x(), e = new x()) {
696
712
  this.points = [t, e];
697
713
  }
698
714
  set(t, e) {
@@ -769,15 +785,15 @@ class L {
769
785
  * @returns {Rectangle}
770
786
  */
771
787
  expandToRectangle(t = 0.1, e = "all") {
772
- const n = this.start, i = this.end, s = i.normal(n), o = e === "bothSides" ? p.zero() : i.direction(n).mutiplyScalar(t * 0.5), r = e === "bothSides" ? p.zero() : n.direction(i).mutiplyScalar(t * 0.5), a = s.x * t * 0.5, c = s.y * t * 0.5, h = [
788
+ const n = this.start, i = this.end, s = i.normal(n), o = e === "bothSides" ? x.zero() : i.direction(n).mutiplyScalar(t * 0.5), r = e === "bothSides" ? x.zero() : n.direction(i).mutiplyScalar(t * 0.5), a = s.x * t * 0.5, c = s.y * t * 0.5, h = [
773
789
  // 第一条线
774
- new p(n.x + a, n.y + c).add(r),
775
- new p(i.x + a, i.y + c).add(o),
790
+ new x(n.x + a, n.y + c).add(r),
791
+ new x(i.x + a, i.y + c).add(o),
776
792
  // 第二条线
777
- new p(n.x - a, n.y - c).add(r),
778
- new p(i.x - a, i.y - c).add(o)
793
+ new x(n.x - a, n.y - c).add(r),
794
+ new x(i.x - a, i.y - c).add(o)
779
795
  ];
780
- return new O([0, 1, 3, 2].map((l) => h[l]));
796
+ return new N([0, 1, 3, 2].map((l) => h[l]));
781
797
  }
782
798
  /**
783
799
  * 计算线段的长度
@@ -814,24 +830,24 @@ class L {
814
830
  projectLineSegment(t) {
815
831
  if (t.points.length !== 2 || this.points.length !== 2)
816
832
  throw new Error("每条线段必须由两个点定义");
817
- const [e, n] = t.points, [i, s] = this.points, o = new p(s.x - i.x, s.y - i.y);
833
+ const [e, n] = t.points, [i, s] = this.points, o = new x(s.x - i.x, s.y - i.y);
818
834
  if (o.x === 0 && o.y === 0)
819
835
  throw new Error("投影目标线段的两个点不能重合");
820
- const r = (m) => {
821
- const y = new p(m.x - i.x, m.y - i.y), u = o.x * o.x + o.y * o.y, w = (y.x * o.x + y.y * o.y) / u, S = i.x + w * o.x, b = i.y + w * o.y;
822
- return new p(S, b);
836
+ const r = (f) => {
837
+ const m = new x(f.x - i.x, f.y - i.y), u = o.x * o.x + o.y * o.y, w = (m.x * o.x + m.y * o.y) / u, D = i.x + w * o.x, b = i.y + w * o.y;
838
+ return new x(D, b);
823
839
  };
824
840
  let a = r(e), c = r(n);
825
- const h = (m) => {
826
- const y = new p(m.x - i.x, m.y - i.y), u = o.x * o.x + o.y * o.y;
827
- return (y.x * o.x + y.y * o.y) / u;
841
+ const h = (f) => {
842
+ const m = new x(f.x - i.x, f.y - i.y), u = o.x * o.x + o.y * o.y;
843
+ return (m.x * o.x + m.y * o.y) / u;
828
844
  };
829
845
  let l = h(a), d = h(c);
830
- const f = (m) => {
831
- const y = Math.max(0, Math.min(1, m)), u = i.x + y * o.x, x = i.y + y * o.y;
832
- return new p(u, x);
846
+ const p = (f) => {
847
+ const m = Math.max(0, Math.min(1, f)), u = i.x + m * o.x, y = i.y + m * o.y;
848
+ return new x(u, y);
833
849
  };
834
- return (l < 0 || l > 1) && (a = f(l)), (d < 0 || d > 1) && (c = f(d)), a.x === c.x && a.y === c.y ? new L(a, a) : new L(a, c);
850
+ return (l < 0 || l > 1) && (a = p(l)), (d < 0 || d > 1) && (c = p(d)), a.x === c.x && a.y === c.y ? new L(a, a) : new L(a, c);
835
851
  }
836
852
  /**
837
853
  * 计算一条线段在另一条直线上的投影
@@ -840,16 +856,16 @@ class L {
840
856
  * @returns 投影并裁剪后的线段
841
857
  */
842
858
  projectPoint(t, e = !0) {
843
- const [n, i] = this.points, s = new p(i.x - n.x, i.y - n.y);
859
+ const [n, i] = this.points, s = new x(i.x - n.x, i.y - n.y);
844
860
  if (s.x === 0 && s.y === 0)
845
861
  throw new Error("投影目标线段的两个点不能重合");
846
862
  let r = ((h) => {
847
- const l = new p(h.x - n.x, h.y - n.y), d = s.x * s.x + s.y * s.y, m = (l.x * s.x + l.y * s.y) / d, y = n.x + m * s.x, u = n.y + m * s.y;
848
- return new p(y, u);
863
+ const l = new x(h.x - n.x, h.y - n.y), d = s.x * s.x + s.y * s.y, f = (l.x * s.x + l.y * s.y) / d, m = n.x + f * s.x, u = n.y + f * s.y;
864
+ return new x(m, u);
849
865
  })(t);
850
866
  if (!e) return r;
851
867
  let c = ((h) => {
852
- const l = new p(h.x - n.x, h.y - n.y), d = s.x * s.x + s.y * s.y;
868
+ const l = new x(h.x - n.x, h.y - n.y), d = s.x * s.x + s.y * s.y;
853
869
  return (l.x * s.x + l.y * s.y) / d;
854
870
  })(r);
855
871
  return c < 0 || c > 1 ? null : r;
@@ -862,11 +878,11 @@ class L {
862
878
  */
863
879
  intersectLineSegment(t, e = !0) {
864
880
  const n = this.start, i = this.end, s = t.start, o = t.end;
865
- function r(f, m, y) {
866
- return (m.x - f.x) * (y.y - f.y) - (m.y - f.y) * (y.x - f.x);
881
+ function r(p, f, m) {
882
+ return (f.x - p.x) * (m.y - p.y) - (f.y - p.y) * (m.x - p.x);
867
883
  }
868
- function a(f, m, y) {
869
- return Math.min(m.x, y.x) - 1e-10 <= f.x && f.x <= Math.max(m.x, y.x) + 1e-10 && Math.min(m.y, y.y) - 1e-10 <= f.y && f.y <= Math.max(m.y, y.y) + 1e-10;
884
+ function a(p, f, m) {
885
+ return Math.min(f.x, m.x) - 1e-10 <= p.x && p.x <= Math.max(f.x, m.x) + 1e-10 && Math.min(f.y, m.y) - 1e-10 <= p.y && p.y <= Math.max(f.y, m.y) + 1e-10;
870
886
  }
871
887
  const c = r(n, i, s), h = r(n, i, o), l = r(s, o, n), d = r(s, o, i);
872
888
  return !!(c * h < 0 && l * d < 0 || e && (Math.abs(c) < 1e-10 && a(s, n, i) || Math.abs(h) < 1e-10 && a(o, n, i) || Math.abs(l) < 1e-10 && a(n, s, o) || Math.abs(d) < 1e-10 && a(i, s, o)));
@@ -890,7 +906,7 @@ class L {
890
906
  if (Math.abs(o) < 1e-10)
891
907
  return null;
892
908
  const r = ((e.x - i.x) * (i.y - s.y) - (e.y - i.y) * (i.x - s.x)) / o, a = e.x + r * (n.x - e.x), c = e.y + r * (n.y - e.y);
893
- return new p(a, c);
909
+ return new x(a, c);
894
910
  }
895
911
  /**
896
912
  * 获取两条线段夹角
@@ -907,6 +923,14 @@ class L {
907
923
  directionEqual(t, e = 0.1) {
908
924
  return this.includedAngle(t) < e;
909
925
  }
926
+ /**
927
+ * 两条线段是否平行
928
+ * @param line
929
+ */
930
+ parallel(t, e = 1) {
931
+ const n = this.includedAngle(t);
932
+ return n < e || n > 180 - e;
933
+ }
910
934
  /**
911
935
  * 两条线段方向相反否一致
912
936
  * @param line
@@ -939,7 +963,7 @@ class L {
939
963
  return t.userData = { ...this.userData }, t;
940
964
  }
941
965
  }
942
- async function G(g, t = !0) {
966
+ async function Y(g, t = !0) {
943
967
  if (typeof global < "u" && typeof require < "u")
944
968
  return require(g);
945
969
  {
@@ -994,7 +1018,7 @@ const st = {
994
1018
  Parsecs: 3240779289666404e-32
995
1019
  // 秒差距,1米 ≈ 0.00000000000000003240779289666404秒差距
996
1020
  };
997
- function k(g) {
1021
+ function J(g) {
998
1022
  const t = [];
999
1023
  for (let e = 0; e < g.length; e++)
1000
1024
  t.push(new L(
@@ -1003,18 +1027,18 @@ function k(g) {
1003
1027
  ));
1004
1028
  return t;
1005
1029
  }
1006
- function J(g) {
1030
+ function W(g) {
1007
1031
  return g.flatMap((t, e) => (e === g.length - 1 && [...t.points, g[0].points[0]], [t.points[0]]));
1008
1032
  }
1009
- class X extends q {
1033
+ class j extends G {
1010
1034
  static name = "Dxf";
1011
1035
  shortLine = 0.04;
1012
1036
  width = 0.04;
1013
1037
  scale = 1;
1014
1038
  originalData = [];
1015
1039
  data = [];
1016
- originalBox = new v(0, 0, 0, 0);
1017
- box = new v(0, 0, 0, 0);
1040
+ originalBox = new A(0, 0, 0, 0);
1041
+ box = new A(0, 0, 0, 0);
1018
1042
  pointsGroups = [];
1019
1043
  wallsGroup = [];
1020
1044
  doors = [];
@@ -1067,8 +1091,8 @@ class X extends q {
1067
1091
  this.data = t.map(({ start: s, end: o, insetionArr: r, isDoor: a = !1, ...c }, h) => {
1068
1092
  i.push(s.z ?? 0, o.z ?? 0);
1069
1093
  const l = new L(
1070
- p.from(s).mutiplyScalar(n),
1071
- p.from(o).mutiplyScalar(n)
1094
+ x.from(s).mutiplyScalar(n),
1095
+ x.from(o).mutiplyScalar(n)
1072
1096
  );
1073
1097
  return l.userData = { isDoor: a, ...c }, this.lineSegments.push(l), [
1074
1098
  l.points[0],
@@ -1095,8 +1119,8 @@ class X extends q {
1095
1119
  const [c, h, l, d] = this.data[o];
1096
1120
  if (e.add(o), d)
1097
1121
  return i.has(o) || i.set(o, []), i.get(o)?.push(a), n.add(this.data[o]);
1098
- r.push([c, h]), l.forEach((f) => {
1099
- e.has(f) || s(f, r, o);
1122
+ r.push([c, h]), l.forEach((p) => {
1123
+ e.has(p) || s(p, r, o);
1100
1124
  });
1101
1125
  };
1102
1126
  return this.data.forEach((o, r) => {
@@ -1188,7 +1212,7 @@ class X extends q {
1188
1212
  break;
1189
1213
  }
1190
1214
  }
1191
- const e = this.mergeSameDirectionLine(k(t)), n = [e[0]];
1215
+ const e = this.mergeSameDirectionLine(J(t)), n = [e[0]];
1192
1216
  for (let i = 1; i < e.length; i++) {
1193
1217
  const s = e[i], o = e[(e.length + i - 1) % e.length];
1194
1218
  if (s.length() > this.width * 0.9) {
@@ -1203,7 +1227,7 @@ class X extends q {
1203
1227
  const a = e[i + 2];
1204
1228
  a && o.includedAngle(a) < 2 ? (i = i + 2, n.push(a)) : n.push(s);
1205
1229
  }
1206
- return n.length > 3 ? J(this.mergeSameDirectionLine(n)) : [];
1230
+ return n.length > 3 ? W(this.mergeSameDirectionLine(n)) : [];
1207
1231
  }
1208
1232
  /**
1209
1233
  * 移除短线段
@@ -1211,7 +1235,7 @@ class X extends q {
1211
1235
  * @param path
1212
1236
  */
1213
1237
  removeShortLine(t, e = this.shortLine) {
1214
- const n = k(t), i = [], s = Math.PI / 180;
1238
+ const n = J(t), i = [], s = Math.PI / 180;
1215
1239
  for (let o = 0; o < n.length; o++) {
1216
1240
  const r = n[o], a = r.length(), c = o;
1217
1241
  if (a > e || i.length === 0) {
@@ -1221,38 +1245,38 @@ class X extends q {
1221
1245
  let h = n[++o];
1222
1246
  const l = i[i.length - 1], d = l.direction();
1223
1247
  for (; o < n.length; ) {
1224
- const m = d.angleBetween(h.direction()) / s;
1225
- if (h.length() <= e || m < 4 || m > 176)
1248
+ const f = d.angleBetween(h.direction()) / s;
1249
+ if (h.length() <= e || f < 4 || f > 176)
1226
1250
  h = n[++o];
1227
1251
  else break;
1228
1252
  }
1229
1253
  if (!h) continue;
1230
- const f = n[o - 1];
1231
- if (l.length() > f.length()) {
1232
- const m = l.getIntersection(h);
1233
- if (m) {
1234
- const y = l.points[1].clone(), u = h.points[0].clone();
1235
- l.points[1].copy(m), h.points[0].copy(m), l.length() < this.width ? (l.points[1].copy(y), h.points[0].copy(y)) : h.length() < this.width && (l.points[1].copy(u), h.points[0].copy(u));
1254
+ const p = n[o - 1];
1255
+ if (l.length() > p.length()) {
1256
+ const f = l.getIntersection(h);
1257
+ if (f) {
1258
+ const m = l.points[1].clone(), u = h.points[0].clone();
1259
+ l.points[1].copy(f), h.points[0].copy(f), l.length() < this.width ? (l.points[1].copy(m), h.points[0].copy(m)) : h.length() < this.width && (l.points[1].copy(u), h.points[0].copy(u));
1236
1260
  } else
1237
1261
  l.points[1].copy(h.points[0]);
1238
1262
  i.push(h);
1239
1263
  } else
1240
1264
  o = c;
1241
1265
  }
1242
- return i.length > 3 ? J(i) : [];
1266
+ return i.length > 3 ? W(i) : [];
1243
1267
  }
1244
1268
  /** 线偏移
1245
1269
  * @description 使用 ClipperLib 对每个点组进行线偏移处理,生成具有指定宽度的墙体路径
1246
1270
  */
1247
- lineOffset(t = X.EndType.etOpenSquare, e = X.JoinType.jtMiter, n = 1e4) {
1271
+ lineOffset(t = j.EndType.etOpenSquare, e = j.JoinType.jtMiter, n = 1e4) {
1248
1272
  let i = new F.Paths();
1249
1273
  const s = new F.ClipperOffset(20, 0.25);
1250
1274
  return this.pointsGroups.forEach((o) => {
1251
1275
  const r = this.lineTopology(o).map((a) => a.map((c) => c.clone().mutiplyScalar(n)));
1252
1276
  s.AddPaths(r, e, t);
1253
1277
  }), s.Execute(i, this.width / 2 * n), this.wallsGroup = i.map((o) => {
1254
- let r = o.map((a) => p.from(a).divisionScalar(n));
1255
- return r = this.lineSegmentStraightening(r), t == X.EndType.etOpenSquare && (r = this.squareRemoveBurr(r)), r;
1278
+ let r = o.map((a) => x.from(a).divisionScalar(n));
1279
+ return r = this.lineSegmentStraightening(r), t == j.EndType.etOpenSquare && (r = this.squareRemoveBurr(r)), r;
1256
1280
  }), this.dispatchEvent({
1257
1281
  type: "lineOffset",
1258
1282
  wallsGroup: this.wallsGroup
@@ -1320,8 +1344,8 @@ class X extends q {
1320
1344
  }
1321
1345
  this.wallsGroup.forEach((c) => {
1322
1346
  for (let h = 0; h < c.length; h++) {
1323
- const l = c[h], d = h === c.length - 1 ? 0 : h + 1, f = c[d];
1324
- s(l, f);
1347
+ const l = c[h], d = h === c.length - 1 ? 0 : h + 1, p = c[d];
1348
+ s(l, p);
1325
1349
  }
1326
1350
  });
1327
1351
  const r = this.width * 0.2, a = [];
@@ -1335,9 +1359,9 @@ class X extends q {
1335
1359
  h.start.clone(),
1336
1360
  h.start.clone().add(l.clone().multiplyScalar(h.length()))
1337
1361
  );
1338
- const f = d.clone().directionMove(d.normal(), h.length() * -0.5).expandToRectangle(h.length(), "bothSides");
1362
+ const p = d.clone().directionMove(d.normal(), h.length() * -0.5).expandToRectangle(h.length(), "bothSides");
1339
1363
  for (let b = 0; b < a.length; b++)
1340
- if (a[b].intersectRectangle(f)) {
1364
+ if (a[b].intersectRectangle(p)) {
1341
1365
  d = new L(
1342
1366
  h.start.clone(),
1343
1367
  h.start.clone().add(l.clone().multiplyScalar(-h.length()))
@@ -1345,15 +1369,15 @@ class X extends q {
1345
1369
  break;
1346
1370
  }
1347
1371
  d.expansion(-r * 0.5).expandToRectangle(this.width * 0.2, "bothSides").path2D((b, P) => s(b, P));
1348
- const m = h.length(), y = d.length(), u = (m ** 2 + y ** 2) / (2 * y), x = d.end.clone().add(d.direction().multiplyScalar(-u)), [w, S] = this.getArcAngleRange(x, h.end, d.end);
1349
- o(x, u, Math.min(w, S), Math.max(w, S)), a.push(f);
1372
+ const f = h.length(), m = d.length(), u = (f ** 2 + m ** 2) / (2 * m), y = d.end.clone().add(d.direction().multiplyScalar(-u)), [w, D] = this.getArcAngleRange(y, h.end, d.end);
1373
+ o(y, u, Math.min(w, D), Math.max(w, D)), a.push(p);
1350
1374
  } else
1351
1375
  h.clone().expansion(-this.width * 0.5).expandToRectangle(this.width).path2D((l, d) => s(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) => s(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) => s(l, d));
1352
1376
  }), i = "yellow", this.lineSegments.forEach((c) => {
1353
1377
  if (!c.userData.isWindow) return !1;
1354
1378
  Array.isArray(c.userData.drawWindow) && c.userData.drawWindow.forEach((h) => {
1355
- const { p: l, width: d } = h, f = p.from(l), m = f.clone().add(c.direction().multiplyScalar(d * 0.5)), y = f.clone().add(c.direction().multiplyScalar(-d * 0.5)), u = new L(m, y);
1356
- s(u.start, u.end), u.expandToRectangle(this.width, "bothSides").path2D((x, w) => s(x, w));
1379
+ const { p: l, width: d } = h, p = x.from(l), f = p.clone().add(c.direction().multiplyScalar(d * 0.5)), m = p.clone().add(c.direction().multiplyScalar(-d * 0.5)), u = new L(f, m);
1380
+ s(u.start, u.end), u.expandToRectangle(this.width, "bothSides").path2D((y, w) => s(y, w));
1357
1381
  });
1358
1382
  }), n;
1359
1383
  }
@@ -1367,7 +1391,7 @@ class X extends q {
1367
1391
  if (typeof window < "u")
1368
1392
  s = document.createElement("canvas");
1369
1393
  else if (typeof global < "u") {
1370
- const { createCanvas: c } = await G("canvas");
1394
+ const { createCanvas: c } = await Y("canvas");
1371
1395
  s = c();
1372
1396
  } else
1373
1397
  throw new Error("创建画布失败");
@@ -1378,14 +1402,14 @@ class X extends q {
1378
1402
  };
1379
1403
  s.width = i.width + o * 2, s.height = i.height + o * 2;
1380
1404
  const a = s.getContext("2d");
1381
- return n && (a.fillStyle = n, a.fillRect(0, 0, s.width, s.height)), a.translate(i.width * 0.5 + o, i.height * 0.5 + o), i.line.forEach(([c, h, l, d, f]) => {
1382
- a.strokeStyle = r[f], a.beginPath(), a.moveTo(c, h), a.lineTo(l, d), a.closePath(), a.stroke();
1383
- }), i.arc.forEach(([c, h, l, d, f, m]) => {
1384
- a.strokeStyle = r[m], a.beginPath(), a.arc(c, h, l, d * (Math.PI / 180), f * (Math.PI / 180)), a.stroke();
1405
+ return n && (a.fillStyle = n, a.fillRect(0, 0, s.width, s.height)), a.translate(i.width * 0.5 + o, i.height * 0.5 + o), i.line.forEach(([c, h, l, d, p]) => {
1406
+ a.strokeStyle = r[p], a.beginPath(), a.moveTo(c, h), a.lineTo(l, d), a.closePath(), a.stroke();
1407
+ }), i.arc.forEach(([c, h, l, d, p, f]) => {
1408
+ a.strokeStyle = r[f], a.beginPath(), a.arc(c, h, l, d * (Math.PI / 180), p * (Math.PI / 180)), a.stroke();
1385
1409
  }), a.beginPath(), i.dimensionLine.forEach((c) => {
1386
- let [h, l, d, f] = c;
1387
- const m = Math.min(l, f), y = Math.max(l, f), u = (s.width * 0.5 - 0.4 * i.scale) * (h < 0 ? -1 : 1), x = (y - m) * 0.45;
1388
- a.fillStyle = "#fff", a.font = `${0.15 * i.scale}px Arial`, a.textAlign = "center", a.textBaseline = "middle", a.fillText((y - m).toFixed(2) + "cm", u, m + (y - m) * 0.5), a.moveTo(u - 0.1 * i.scale, m), a.lineTo(u + 0.1 * i.scale, m), a.moveTo(u, m), a.lineTo(u, x + m), a.moveTo(u, y), a.lineTo(u, y - x), a.moveTo(u - 0.1 * i.scale, y), a.lineTo(u + 0.1 * i.scale, y);
1410
+ let [h, l, d, p] = c;
1411
+ const f = Math.min(l, p), m = Math.max(l, p), u = (s.width * 0.5 - 0.4 * i.scale) * (h < 0 ? -1 : 1), y = (m - f) * 0.45;
1412
+ a.fillStyle = "#fff", a.font = `${0.15 * i.scale}px Arial`, a.textAlign = "center", a.textBaseline = "middle", a.fillText((m - f).toFixed(2) + "cm", u, f + (m - f) * 0.5), a.moveTo(u - 0.1 * i.scale, f), a.lineTo(u + 0.1 * i.scale, f), a.moveTo(u, f), a.lineTo(u, y + f), a.moveTo(u, m), a.lineTo(u, m - y), a.moveTo(u - 0.1 * i.scale, m), a.lineTo(u + 0.1 * i.scale, m);
1389
1413
  }), a.closePath(), a.strokeStyle = "#fff", a.stroke(), "toBlob" in s ? new Promise((c) => {
1390
1414
  s.toBlob((h) => {
1391
1415
  c(h);
@@ -1422,7 +1446,7 @@ class X extends q {
1422
1446
  if (typeof window < "u") {
1423
1447
  const n = this.toDxfBlob(e), i = document.createElement("a");
1424
1448
  i.href = URL.createObjectURL(n), i.download = t + ".dxf", i.click();
1425
- } else typeof global < "u" && (await G("fs", !1)).writeFileSync(t, this.toDxfString(e));
1449
+ } else typeof global < "u" && (await Y("fs", !1)).writeFileSync(t, this.toDxfString(e));
1426
1450
  }
1427
1451
  /**
1428
1452
  * 下载
@@ -1434,7 +1458,7 @@ class X extends q {
1434
1458
  if (typeof window < "u") {
1435
1459
  const s = document.createElement("a");
1436
1460
  s.href = URL.createObjectURL(i), s.download = t, s.click();
1437
- } else typeof global < "u" ? (await G("fs", !1)).writeFileSync(t, i) : console.error("图片下载失败");
1461
+ } else typeof global < "u" ? (await Y("fs", !1)).writeFileSync(t, i) : console.error("图片下载失败");
1438
1462
  return !0;
1439
1463
  }
1440
1464
  /**
@@ -1442,7 +1466,7 @@ class X extends q {
1442
1466
  * @description 计算所有线段的起点和终点的最小最大值,形成一个边界框
1443
1467
  * @returns
1444
1468
  */
1445
- computedOriginalSize(t, e = new v(0, 0, 0, 0)) {
1469
+ computedOriginalSize(t, e = new A(0, 0, 0, 0)) {
1446
1470
  const n = t.flatMap((c) => [c.start.x, c.end.x]), i = t.flatMap((c) => [c.start.y, c.end.y]), s = Math.min(...n), o = Math.min(...i), r = Math.max(...n), a = Math.max(...i);
1447
1471
  return e.set(s, o, r, a), e;
1448
1472
  }
@@ -1479,8 +1503,8 @@ function V(g) {
1479
1503
  Object.prototype.hasOwnProperty.call(g, e) && (t[e] = V(g[e]));
1480
1504
  return t;
1481
1505
  }
1482
- const I = new L();
1483
- class ot extends X {
1506
+ const C = new L();
1507
+ class ot extends j {
1484
1508
  static name = "AngleCorrectionDxf";
1485
1509
  angle = 0;
1486
1510
  onAddFromParent(t) {
@@ -1491,27 +1515,27 @@ class ot extends X {
1491
1515
  let i = 0, s = null;
1492
1516
  for (let c = 0; c < e.originalData.length; c++) {
1493
1517
  const h = e.originalData[c];
1494
- if (I.start.copy(h.start), I.end.copy(h.end), h.isVerticalReferenceLine) {
1495
- const [l, d] = h.start.y < h.end.y ? [I.start, I.end] : [I.end, I.start];
1496
- i = -new L(l, d).direction().angleBetween(new p(0, 1), "angle", "360"), s = null;
1518
+ if (C.start.copy(h.start), C.end.copy(h.end), h.isVerticalReferenceLine) {
1519
+ const [l, d] = h.start.y < h.end.y ? [C.start, C.end] : [C.end, C.start];
1520
+ i = -new L(l, d).direction().angleBetween(new x(0, 1), "angle", "360"), s = null;
1497
1521
  break;
1498
1522
  }
1499
- (!s || I.length() > s.length()) && (s = I.clone(), s.userData.index = c);
1523
+ (!s || C.length() > s.length()) && (s = C.clone(), s.userData.index = c);
1500
1524
  }
1501
1525
  if (s) {
1502
1526
  e.originalData[s.userData.index].isVerticalReferenceLine = !0;
1503
1527
  const [c, h] = s.start.y < s.end.y ? [s.start, s.end] : [s.end, s.start];
1504
- i = -new L(c, h).direction().angleBetween(new p(0, 1), "angle", "360");
1528
+ i = -new L(c, h).direction().angleBetween(new x(0, 1), "angle", "360");
1505
1529
  }
1506
- const o = e.originalBox.center, r = p.zero(), a = e.originalData.map((c) => {
1507
- const h = r.copy(c.start).division(o).rotate(p.zero(), i * (Math.PI / 180)).toJson(c.start.z), l = r.copy(c.end).division(o).rotate(p.zero(), i * (Math.PI / 180)).toJson(c.end.z), d = Object.assign(V(c), { start: h, end: l });
1508
- return d.drawWindow && d.drawWindow.forEach((f) => {
1509
- f.p = r.copy(f.p).division(o).rotate(p.zero(), i * (Math.PI / 180)).toJson(f.p.z), f.p.y = -f.p.y;
1530
+ const o = e.originalBox.center, r = x.zero(), a = e.originalData.map((c) => {
1531
+ const h = r.copy(c.start).division(o).rotate(x.zero(), i * (Math.PI / 180)).toJson(c.start.z), l = r.copy(c.end).division(o).rotate(x.zero(), i * (Math.PI / 180)).toJson(c.end.z), d = Object.assign(V(c), { start: h, end: l });
1532
+ return d.drawWindow && d.drawWindow.forEach((p) => {
1533
+ p.p = r.copy(p.p).division(o).rotate(x.zero(), i * (Math.PI / 180)).toJson(p.p.z), p.p.y = -p.p.y;
1510
1534
  }), d;
1511
1535
  });
1512
1536
  n.appendLineSegmentList.forEach((c) => {
1513
1537
  const h = c.clone();
1514
- h.start.division(o).rotate(p.zero(), i * (Math.PI / 180)), h.end.division(o).rotate(p.zero(), i * (Math.PI / 180)), a.push({
1538
+ h.start.division(o).rotate(x.zero(), i * (Math.PI / 180)), h.end.division(o).rotate(x.zero(), i * (Math.PI / 180)), a.push({
1515
1539
  start: h.start.toJson(e.originalZAverage),
1516
1540
  end: h.end.toJson(e.originalZAverage),
1517
1541
  insetionArr: [],
@@ -1521,37 +1545,13 @@ class ot extends X {
1521
1545
  c.start.y = -c.start.y, c.end.y = -c.end.y;
1522
1546
  }), await this.set(a, e.width, e.scale), this.lineOffset(), this.doorLineSegment = e.doorLineSegment.map((c) => {
1523
1547
  const h = c.clone();
1524
- return h.start.division(o).rotate(p.zero(), i * (Math.PI / 180)), h.end.division(o).rotate(p.zero(), i * (Math.PI / 180)), h.start.y = -h.start.y, h.end.y = -h.end.y, h;
1548
+ return h.start.division(o).rotate(x.zero(), i * (Math.PI / 180)), h.end.division(o).rotate(x.zero(), i * (Math.PI / 180)), h.start.y = -h.start.y, h.end.y = -h.end.y, h;
1525
1549
  }), this.angle = i, this.dispatchEvent({
1526
1550
  type: "updateData"
1527
1551
  });
1528
1552
  }
1529
- // async set(data: OriginalDataItem[], width?: number, scale?: number): Promise<any> {
1530
- // await super.set(data, width, scale)
1531
- // const quadtree = new Quadtree(this.box)
1532
- // this.lineSegments.forEach(line => {
1533
- // if(line.userData.isDoor) return
1534
- // quadtree.insert({
1535
- // line,
1536
- // userData: undefined
1537
- // })
1538
- // })
1539
- // this.lineSegments.forEach(line => {
1540
- // if(line.userData.isDoor) return
1541
- // const lines = quadtree.queryLineSegment(line)
1542
- // .filter(l => l.line !== line)
1543
- // .map(l => l.line)
1544
- // const offset = new ClipperLib.ClipperOffset(20, 0.25)
1545
- // offset.AddPaths(lines.map( line => line.points.map(p => p.clone().multiplyScalar(1000)) ), ClipperLib.JoinType.jtMiter, ClipperLib.EndType.etOpenSquare)
1546
- // const result = new ClipperLib.Paths()
1547
- // offset.Execute(result, this.width / 2 * 1000)
1548
- // console.log( result )
1549
- // // const cpr = new ClipperLib.Clipper()
1550
- // // offset.AddPath(linePaths, joinType, endType)
1551
- // })
1552
- // }
1553
1553
  }
1554
- class _ extends q {
1554
+ class H extends G {
1555
1555
  static name = "Variable";
1556
1556
  originalLineVisible = !0;
1557
1557
  dxfVisible = !0;
@@ -1578,7 +1578,7 @@ class _ extends q {
1578
1578
  if (t in this) return this[t];
1579
1579
  }
1580
1580
  }
1581
- class j {
1581
+ class q {
1582
1582
  bounds;
1583
1583
  // 包围盒
1584
1584
  capacity;
@@ -1644,23 +1644,23 @@ class j {
1644
1644
  if (!this.isLeaf) return;
1645
1645
  this.isLeaf = !1, this.children = [];
1646
1646
  const t = (this.bounds.minX + this.bounds.maxX) / 2, e = (this.bounds.minY + this.bounds.maxY) / 2;
1647
- this.children[0] = new j(
1648
- new v(this.bounds.minX, t, this.bounds.minY, e),
1647
+ this.children[0] = new q(
1648
+ new A(this.bounds.minX, t, this.bounds.minY, e),
1649
1649
  this.capacity,
1650
1650
  this.maxDepth,
1651
1651
  this.depth + 1
1652
- ), this.children[1] = new j(
1653
- new v(t, this.bounds.maxX, this.bounds.minY, e),
1652
+ ), this.children[1] = new q(
1653
+ new A(t, this.bounds.maxX, this.bounds.minY, e),
1654
1654
  this.capacity,
1655
1655
  this.maxDepth,
1656
1656
  this.depth + 1
1657
- ), this.children[2] = new j(
1658
- new v(this.bounds.minX, t, e, this.bounds.maxY),
1657
+ ), this.children[2] = new q(
1658
+ new A(this.bounds.minX, t, e, this.bounds.maxY),
1659
1659
  this.capacity,
1660
1660
  this.maxDepth,
1661
1661
  this.depth + 1
1662
- ), this.children[3] = new j(
1663
- new v(t, this.bounds.maxX, e, this.bounds.maxY),
1662
+ ), this.children[3] = new q(
1663
+ new A(t, this.bounds.maxX, e, this.bounds.maxY),
1664
1664
  this.capacity,
1665
1665
  this.maxDepth,
1666
1666
  this.depth + 1
@@ -1689,7 +1689,7 @@ class j {
1689
1689
  * @returns 相交的节点数组
1690
1690
  */
1691
1691
  queryCircle(t, e) {
1692
- const n = [], i = new v(
1692
+ const n = [], i = new A(
1693
1693
  t.x - e,
1694
1694
  t.x + e,
1695
1695
  t.y - e,
@@ -1701,8 +1701,8 @@ class j {
1701
1701
  const [o, r] = s.line.points, a = r.x - o.x, c = r.y - o.y, h = a * a + c * c;
1702
1702
  let l = ((t.x - o.x) * a + (t.y - o.y) * c) / h;
1703
1703
  l = Math.max(0, Math.min(1, l));
1704
- const d = o.x + l * a, f = o.y + l * c;
1705
- t.distance(new p(d, f)) <= e && n.push(s);
1704
+ const d = o.x + l * a, p = o.y + l * c;
1705
+ t.distance(new x(d, p)) <= e && n.push(s);
1706
1706
  }
1707
1707
  if (!this.isLeaf)
1708
1708
  for (const s of this.children)
@@ -1754,7 +1754,7 @@ class j {
1754
1754
  })), t;
1755
1755
  }
1756
1756
  }
1757
- class U {
1757
+ class k {
1758
1758
  map = /* @__PURE__ */ new Map();
1759
1759
  gridSize;
1760
1760
  constructor(t = 2) {
@@ -1785,7 +1785,7 @@ class U {
1785
1785
  * @param point
1786
1786
  */
1787
1787
  remove(t) {
1788
- const { set: e, target: n } = t?.userData?.pointVirtualGrid;
1788
+ const { set: e, target: n } = t?.userData?.pointVirtualGrid ?? {};
1789
1789
  e && (e.delete(n), delete t?.userData?.pointVirtualGridMap);
1790
1790
  }
1791
1791
  /**
@@ -1804,7 +1804,7 @@ class U {
1804
1804
  */
1805
1805
  decodeGridId(t) {
1806
1806
  const [e, n] = t.split(".").map(Number);
1807
- return new p(e, n);
1807
+ return new x(e, n);
1808
1808
  }
1809
1809
  /**
1810
1810
  * 查询与矩形相交的点
@@ -1829,13 +1829,13 @@ class U {
1829
1829
  * @returns 相交的节点数组
1830
1830
  */
1831
1831
  queryCircle(t, e) {
1832
- const n = new v(t.x - e, t.x + e, t.y - e, t.y + e), i = Math.ceil(n.minX / this.gridSize), s = Math.ceil(n.maxX / this.gridSize), o = Math.ceil(n.minY / this.gridSize), r = Math.ceil(n.maxY / this.gridSize), a = [];
1832
+ const n = new A(t.x - e, t.x + e, t.y - e, t.y + e), i = Math.ceil(n.minX / this.gridSize), s = Math.ceil(n.maxX / this.gridSize), o = Math.ceil(n.minY / this.gridSize), r = Math.ceil(n.maxY / this.gridSize), a = [];
1833
1833
  for (let c = i; c <= s; c++)
1834
1834
  for (let h = o; h <= r; h++) {
1835
1835
  const l = `${c}.${h}`;
1836
1836
  if (!this.map.has(l)) continue;
1837
- this.map.get(l)?.forEach((f) => {
1838
- t.distance(f.point) <= e && a.push(f);
1837
+ this.map.get(l)?.forEach((p) => {
1838
+ t.distance(p.point) <= e && a.push(p);
1839
1839
  });
1840
1840
  }
1841
1841
  return a;
@@ -1881,7 +1881,7 @@ class rt {
1881
1881
  doorPoint = [];
1882
1882
  dxf;
1883
1883
  // 包含所有点的虚拟网格
1884
- pointVirtualGrid = new U();
1884
+ pointVirtualGrid = new k();
1885
1885
  // 只包含可查找点的虚拟网格
1886
1886
  findPointVirtualGrid;
1887
1887
  quadtree;
@@ -1894,7 +1894,7 @@ class rt {
1894
1894
  lineAnalysis;
1895
1895
  continueFind = !0;
1896
1896
  constructor(t) {
1897
- if (this.lineAnalysis = t, this.dxf = t.Dxf, this.findPointVirtualGrid = new U(), this.quadtree = t.quadtree, this.resultList = t.resultList, this.lineSegments = t.lineSegmentList, this.dxf.doorLineSegment.length = 0, this.lineSegments.forEach((n) => {
1897
+ if (this.lineAnalysis = t, this.dxf = t.Dxf, this.findPointVirtualGrid = new k(), this.quadtree = t.quadtree, this.resultList = t.resultList, this.lineSegments = t.lineSegmentList, this.dxf.doorLineSegment.length = 0, this.lineSegments.forEach((n) => {
1898
1898
  this.pointVirtualGrid.insert(n.start, n), this.pointVirtualGrid.insert(n.end, n);
1899
1899
  }), this.doorPoint = this.getDoorPoint(), !this.continueFind) return;
1900
1900
  const e = this.searchDoubleLinePoint();
@@ -1926,13 +1926,13 @@ class rt {
1926
1926
  return r.forEach((c) => {
1927
1927
  const h = new L(c?.start, c?.end), l = h.length();
1928
1928
  if (l < n) return;
1929
- const d = h.normal(), f = h.direction(), m = (l - o.width * 2) / 2;
1930
- for (let y = 0; y < 3; y++) {
1931
- const u = h.start.clone().add(f.clone().multiplyScalar(o.width + m * y)), x = new L(
1929
+ const d = h.normal(), p = h.direction(), f = (l - o.width * 2) / 2;
1930
+ for (let m = 0; m < 3; m++) {
1931
+ const u = h.start.clone().add(p.clone().multiplyScalar(o.width + f * m)), y = new L(
1932
1932
  u,
1933
1933
  u.clone().add(d.clone().multiplyScalar(1))
1934
1934
  );
1935
- if (x.directionMove(d, -0.5), this.quadtree.queryLineSegment(x).length) return;
1935
+ if (y.directionMove(d, -0.5), this.quadtree.queryLineSegment(y).length) return;
1936
1936
  }
1937
1937
  a.push(h);
1938
1938
  }), a;
@@ -1952,7 +1952,7 @@ class rt {
1952
1952
  return this.lineSegments.forEach((e) => {
1953
1953
  e.points.forEach((n, i) => {
1954
1954
  for (let o = 0; o < this._pointsExcludeRule.length; o++) if (this._pointsExcludeRule[o](e, n, i)) return;
1955
- this.pointVirtualGrid.queryPoint(n).filter((o) => o.userData !== e).length === 0 && t.push({ line: e, point: n, uuid: N() });
1955
+ this.pointVirtualGrid.queryPoint(n).filter((o) => o.userData !== e).length === 0 && t.push({ line: e, point: n, uuid: O() });
1956
1956
  });
1957
1957
  }), t;
1958
1958
  }
@@ -1964,21 +1964,21 @@ class rt {
1964
1964
  return e.doors.forEach((i) => {
1965
1965
  const s = e.lineSegments[i[4]], o = e.originalData[i[4]];
1966
1966
  if (o.drawDoorData) {
1967
- const r = p.from(o.drawDoorData.start), a = p.from(o.drawDoorData.n), c = n.queryPoint(r).filter((h) => {
1967
+ const r = x.from(o.drawDoorData.start), a = x.from(o.drawDoorData.n), c = n.queryPoint(r).filter((h) => {
1968
1968
  if (h.userData === s) return !1;
1969
1969
  const l = h.userData, d = l.direction();
1970
1970
  l.start.equal(r) && d.multiplyScalar(-1);
1971
- const f = a.angleBetween(d, "angle");
1972
- return f > 80 || f < 10;
1971
+ const p = a.angleBetween(d, "angle");
1972
+ return p > 80 || p < 10;
1973
1973
  });
1974
1974
  c.length && t.push({
1975
1975
  line: c[0].userData,
1976
1976
  point: r,
1977
- uuid: N()
1977
+ uuid: O()
1978
1978
  });
1979
1979
  } else if (o.doorDirectConnection) {
1980
1980
  this.continueFind = !1;
1981
- const r = new L(p.from(o.start), p.from(o.end));
1981
+ const r = new L(x.from(o.start), x.from(o.end));
1982
1982
  r.userData = {
1983
1983
  doorDirectConnection: !0,
1984
1984
  isDoor: !0
@@ -2008,48 +2008,48 @@ class rt {
2008
2008
  */
2009
2009
  searchNearby(t, e = [], n = this.doorSearchDistance, i = this.doorSearchNearAngle) {
2010
2010
  const s = this.findPointVirtualGrid, o = this.quadtree;
2011
- function r({ point: u, line: x }, w, S) {
2012
- const b = x.direction();
2013
- x.start === u && b.multiplyScalar(-1);
2014
- const P = s.queryCircle(u, n).filter((D) => D.userData !== x).sort((D, E) => D.point.distance(u) - E.point.distance(u)), A = [];
2015
- for (let D = 0; D < P.length; D++) {
2016
- const E = e.findIndex((T) => T.point === P[D].point), B = t[w].uuid, Y = e[E].uuid;
2017
- if (S.has(`${B}.${Y}`)) continue;
2018
- S.add(`${B}.${Y}`), S.add(`${Y}.${B}`);
2019
- const Q = P[D].point, C = new L(u.clone(), Q.clone());
2020
- if (C.direction().angleBetween(b, "angle") < i) {
2011
+ function r({ point: u, line: y }, w, D) {
2012
+ const b = y.direction();
2013
+ y.start === u && b.multiplyScalar(-1);
2014
+ const P = s.queryCircle(u, n).filter((S) => S.userData !== y).sort((S, E) => S.point.distance(u) - E.point.distance(u)), v = [];
2015
+ for (let S = 0; S < P.length; S++) {
2016
+ const E = e.findIndex((T) => T.point === P[S].point), B = t[w].uuid, I = e[E].uuid;
2017
+ if (D.has(`${B}.${I}`)) continue;
2018
+ D.add(`${B}.${I}`), D.add(`${I}.${B}`);
2019
+ const Q = P[S].point, X = new L(u.clone(), Q.clone());
2020
+ if (X.direction().angleBetween(b, "angle") < i) {
2021
2021
  const T = t[E].line.direction();
2022
- P[D].userData.start.equal(P[D].point) && T.multiplyScalar(-1), C.direction().multiplyScalar(-1).angleBetween(T, "angle") < i && (o.queryLineSegment(C).length || A.push({
2023
- findData: P[D],
2024
- findUuid: Y,
2025
- doorLine: C,
2022
+ P[S].userData.start.equal(P[S].point) && T.multiplyScalar(-1), X.direction().multiplyScalar(-1).angleBetween(T, "angle") < i && (o.queryLineSegment(X).length || v.push({
2023
+ findData: P[S],
2024
+ findUuid: I,
2025
+ doorLine: X,
2026
2026
  doorUuid: B
2027
2027
  }));
2028
2028
  }
2029
2029
  }
2030
- return A;
2030
+ return v;
2031
2031
  }
2032
- function a(u, x, w, S, b) {
2033
- S.add(u);
2032
+ function a(u, y, w, D, b) {
2033
+ D.add(u);
2034
2034
  const P = [];
2035
2035
  b && P.push(b);
2036
- for (let A = 0; A < w.length; A++) {
2037
- const D = w[A];
2038
- if (x.has(D.findUuid)) {
2039
- const E = x.get(D.findUuid);
2040
- a(D.findUuid, x, E, S, D) && P.push(D);
2041
- } else P.push(D);
2036
+ for (let v = 0; v < w.length; v++) {
2037
+ const S = w[v];
2038
+ if (y.has(S.findUuid)) {
2039
+ const E = y.get(S.findUuid);
2040
+ a(S.findUuid, y, E, D, S) && P.push(S);
2041
+ } else P.push(S);
2042
2042
  }
2043
- return P.sort((A, D) => A.doorLine.length() - D.doorLine.length()), b && P[0] === b ? (w.splice(0), !0) : (w.splice(1), !1);
2043
+ return P.sort((v, S) => v.doorLine.length() - S.doorLine.length()), b && P[0] === b ? (w.splice(0), !0) : (w.splice(1), !1);
2044
2044
  }
2045
2045
  const c = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map();
2046
- t.map((u, x) => {
2047
- const w = r(u, x, c);
2046
+ t.map((u, y) => {
2047
+ const w = r(u, y, c);
2048
2048
  w.length && h.set(u.uuid, w);
2049
2049
  }), c.clear();
2050
2050
  const l = /* @__PURE__ */ new Map();
2051
- h.forEach((u, x) => {
2052
- if (!c.has(x) && u.length && a(x, h, u, c), u.length) {
2051
+ h.forEach((u, y) => {
2052
+ if (!c.has(y) && u.length && a(y, h, u, c), u.length) {
2053
2053
  const w = u[0];
2054
2054
  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);
2055
2055
  }
@@ -2057,45 +2057,45 @@ class rt {
2057
2057
  const d = /* @__PURE__ */ new Set();
2058
2058
  l.forEach((u) => {
2059
2059
  if (u.length > 1) {
2060
- u.sort((x, w) => x.doorLine.length() - w.doorLine.length());
2061
- for (let x = 1; x < u.length; x++) d.add(u[x]);
2060
+ u.sort((y, w) => y.doorLine.length() - w.doorLine.length());
2061
+ for (let y = 1; y < u.length; y++) d.add(u[y]);
2062
2062
  }
2063
2063
  });
2064
- const f = [], m = [];
2064
+ const p = [], f = [];
2065
2065
  h.forEach((u) => {
2066
2066
  if (u.length) {
2067
- const x = u[0];
2068
- d.has(x) || (f.push(x), m.push(x.doorUuid, x.findUuid));
2067
+ const y = u[0];
2068
+ d.has(y) || (p.push(y), f.push(y.doorUuid, y.findUuid));
2069
2069
  }
2070
2070
  });
2071
- const y = [];
2072
- return f.forEach((u) => {
2073
- const x = t.findIndex((E) => E.uuid === u.doorUuid), w = e.findIndex((E) => E.uuid === u.findUuid), S = t[x].point.clone(), b = e[w].point.clone(), P = this.findLongLineSegment(t[x].line), A = this.findLongLineSegment(e[w].line), D = P.projectPoint(b);
2074
- if (D) {
2075
- S.copy(D);
2076
- const E = new L(S, b), B = A.includedAngle(E);
2077
- (B < 10 || B > 170 || Math.abs(90 - B) < 10) && y.push({
2078
- start: S,
2071
+ const m = [];
2072
+ return p.forEach((u) => {
2073
+ const y = t.findIndex((E) => E.uuid === u.doorUuid), w = e.findIndex((E) => E.uuid === u.findUuid), D = t[y].point.clone(), b = e[w].point.clone(), P = this.findLongLineSegment(t[y].line), v = this.findLongLineSegment(e[w].line), S = P.projectPoint(b);
2074
+ if (S) {
2075
+ D.copy(S);
2076
+ const E = new L(D, b), B = v.includedAngle(E);
2077
+ (B < 10 || B > 170 || Math.abs(90 - B) < 10) && m.push({
2078
+ start: D,
2079
2079
  end: b
2080
2080
  });
2081
2081
  } else {
2082
- const E = A.projectPoint(S);
2082
+ const E = v.projectPoint(D);
2083
2083
  E && b.copy(E);
2084
- const B = new L(S, b), Y = P.includedAngle(B);
2085
- (Y < 10 || Y > 170 || Math.abs(90 - Y) < 10) && y.push({
2086
- start: S,
2084
+ const B = new L(D, b), I = P.includedAngle(B);
2085
+ (I < 10 || I > 170 || Math.abs(90 - I) < 10) && m.push({
2086
+ start: D,
2087
2087
  end: b
2088
2088
  });
2089
2089
  }
2090
2090
  }), e.splice(
2091
2091
  0,
2092
2092
  e.length,
2093
- ...e.filter((u) => m.indexOf(u.uuid) === -1)
2093
+ ...e.filter((u) => f.indexOf(u.uuid) === -1)
2094
2094
  ), t.splice(
2095
2095
  0,
2096
2096
  t.length,
2097
- ...t.filter((u) => m.indexOf(u.uuid) === -1)
2098
- ), y;
2097
+ ...t.filter((u) => f.indexOf(u.uuid) === -1)
2098
+ ), m;
2099
2099
  }
2100
2100
  /** 方案二: 沿方向查找
2101
2101
  * @description
@@ -2126,8 +2126,8 @@ class rt {
2126
2126
  e.start === t && o.multiplyScalar(-1), e.start === t && a.copy(e.end);
2127
2127
  const c = i.queryPoint(a).filter((d) => d.userData !== e);
2128
2128
  for (let d = 0; d < c.length; d++) {
2129
- const f = c[d], m = f.userData, y = m.direction();
2130
- if (m.start === f.point && o.multiplyScalar(-1), y.angleBetween(r) / (Math.PI / 180) > 90) {
2129
+ const p = c[d], f = p.userData, m = f.direction();
2130
+ if (f.start === p.point && o.multiplyScalar(-1), m.angleBetween(r) / (Math.PI / 180) > 90) {
2131
2131
  r.multiplyScalar(-1);
2132
2132
  break;
2133
2133
  }
@@ -2135,7 +2135,7 @@ class rt {
2135
2135
  const h = new L(t.clone(), t.clone().add(r.multiplyScalar(n))), l = s.queryLineSegment(h).map((d) => ({
2136
2136
  point: d.line.getIntersection(h),
2137
2137
  line: d.line
2138
- })).filter((d) => d.point).sort((d, f) => t.distance(d.point) - t.distance(f.point));
2138
+ })).filter((d) => d.point).sort((d, p) => t.distance(d.point) - t.distance(p.point));
2139
2139
  if (l.length) {
2140
2140
  const d = l[0];
2141
2141
  if (Math.abs(90 - d.line.direction().angleBetween(r, "angle")) < 5)
@@ -2166,7 +2166,7 @@ class rt {
2166
2166
  return e;
2167
2167
  }
2168
2168
  }
2169
- class at extends q {
2169
+ class at extends G {
2170
2170
  static name = "LineAnalysis";
2171
2171
  Dxf = null;
2172
2172
  Variable = null;
@@ -2180,7 +2180,7 @@ class at extends q {
2180
2180
  * @param parent
2181
2181
  */
2182
2182
  onAddFromParent(t) {
2183
- 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));
2183
+ this.Dxf = t.findComponentByType(j), this.Variable = this.parent?.findComponentByType(H), this.Dxf.addEventListener("setDta", this.lineAnalysis.bind(this)), this.Dxf.addEventListener("createGroup", this.doorsAnalysis.bind(this));
2184
2184
  }
2185
2185
  /**
2186
2186
  *
@@ -2194,11 +2194,11 @@ class at extends q {
2194
2194
  return {
2195
2195
  points: [
2196
2196
  // 第一条线
2197
- new p(t.x + r, t.y + a).add(o),
2198
- new p(e.x + r, e.y + a).add(s),
2197
+ new x(t.x + r, t.y + a).add(o),
2198
+ new x(e.x + r, e.y + a).add(s),
2199
2199
  // 第二条线
2200
- new p(t.x - r, t.y - a).add(o),
2201
- new p(e.x - r, e.y - a).add(s)
2200
+ new x(t.x - r, t.y - a).add(o),
2201
+ new x(e.x - r, e.y - a).add(s)
2202
2202
  ],
2203
2203
  indices: [0, 1, 1, 3, 3, 2, 2, 0],
2204
2204
  rectIndices: [0, 1, 3, 2, 0]
@@ -2220,14 +2220,14 @@ class at extends q {
2220
2220
  createRectangle(t) {
2221
2221
  const e = this.Dxf, n = t.project, i = t.project2;
2222
2222
  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]);
2223
- const s = n.points[0].distance(i.points[0]), o = n.points[1].distance(i.points[1]), r = Math.ceil(Math.max(s, o) / e.width), a = s / r, c = o / 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);
2224
- m.multiplyScalar(e.width * 0.5);
2225
- const y = d.clone().add(m), u = f.clone().add(m.multiplyScalar(-1)), x = d.direction(f), w = y.direction(u);
2226
- 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)) {
2227
- d.set(y.x, y.y), f.set(u.x, u.y);
2228
- for (let S = 1; S < r; S++) {
2229
- const b = h.clone().multiplyScalar(a * S), P = l.clone().multiplyScalar(c * S), A = d.clone().add(b), D = f.clone().add(P);
2230
- this.addData(A, D);
2223
+ const s = n.points[0].distance(i.points[0]), o = n.points[1].distance(i.points[1]), r = Math.ceil(Math.max(s, o) / e.width), a = s / r, c = o / r, h = i.points[0].direction(n.points[0]), l = i.points[1].direction(n.points[1]), d = n.points[0].clone(), p = n.points[1].clone(), f = p.direction(d);
2224
+ f.multiplyScalar(e.width * 0.5);
2225
+ const m = d.clone().add(f), u = p.clone().add(f.multiplyScalar(-1)), y = d.direction(p), w = m.direction(u);
2226
+ if (!(y.x > 0 && w.x < 0 || y.x < 0 && w.x > 0 || y.y > 0 && w.y < 0 || y.y < 0 && w.y > 0)) {
2227
+ d.set(m.x, m.y), p.set(u.x, u.y);
2228
+ for (let D = 1; D < r; D++) {
2229
+ const b = h.clone().multiplyScalar(a * D), P = l.clone().multiplyScalar(c * D), v = d.clone().add(b), S = p.clone().add(P);
2230
+ this.addData(v, S);
2231
2231
  }
2232
2232
  }
2233
2233
  }
@@ -2237,7 +2237,7 @@ class at extends q {
2237
2237
  */
2238
2238
  buildQuadtree() {
2239
2239
  const t = this.Dxf, e = [];
2240
- this.quadtree = new j(t.originalBox, 2), t.lineSegments.forEach((n) => {
2240
+ this.quadtree = new q(t.originalBox, 2), t.lineSegments.forEach((n) => {
2241
2241
  n.userData?.isDoor || (this.quadtree?.insert({
2242
2242
  line: n,
2243
2243
  userData: e.length
@@ -2254,7 +2254,7 @@ class at extends q {
2254
2254
  this.buildQuadtree();
2255
2255
  const t = this.quadtree, e = this.lineSegmentList, n = /* @__PURE__ */ new Set(), i = [];
2256
2256
  e.forEach((s, o) => {
2257
- const r = e[o], a = O.fromByLineSegment(r, this.width * 2, !1, -0.01);
2257
+ const r = e[o], a = N.fromByLineSegment(r, this.width * 2, !1, -0.01);
2258
2258
  t.queryRect(a).map((h) => h.userData).filter((h) => h !== o).forEach((h) => {
2259
2259
  try {
2260
2260
  if (n.has(`${o}-${h}`) || n.has(`${h}-${o}`)) return;
@@ -2296,13 +2296,139 @@ class at extends q {
2296
2296
  doorSearchNearAngle = 110;
2297
2297
  doorSearchDistance = 2;
2298
2298
  doors = [];
2299
+ DoorsAnalysis;
2299
2300
  doorsAnalysis() {
2300
- new rt(this), this.dispatchEvent({
2301
+ this.DoorsAnalysis = new rt(this), this.dispatchEvent({
2301
2302
  type: "analysisCompleted"
2302
2303
  });
2303
2304
  }
2304
2305
  }
2305
- class ct extends it {
2306
+ class ct extends G {
2307
+ static name = "ThreeVJia";
2308
+ lineSegments = [];
2309
+ onAddFromParent() {
2310
+ (this.parent?.findComponentByName("AngleCorrectionDxf")).addEventListener("updateData", async () => this.updateData());
2311
+ }
2312
+ updateData() {
2313
+ const t = this.parent?.findComponentByName("LineAnalysis"), e = this.parent?.findComponentByName("Dxf");
2314
+ this.parent?.findComponentByName("Renderer");
2315
+ const n = this.parent?.findComponentByName("AngleCorrectionDxf"), i = /* @__PURE__ */ new Map();
2316
+ let s = [...e.lineSegments], o = [], r = [];
2317
+ t.resultList.forEach((h) => {
2318
+ const l = i.get(h.target) ?? [], d = i.get(h.source) ?? [], p = h.project.clone(), f = h.project2.clone();
2319
+ p.includedAngle(f) > 135 && (f.points = [f.points[1], f.points[0]]), l.push(...p.points), d.push(...f.points), i.set(h.target, l), i.set(h.source, d);
2320
+ const m = new L(p.start, f.start), u = new L(p.end, f.end), y = new L(m.center, u.center);
2321
+ y.userData.wallWidth = Math.max(m.length(), u.length()), o.push(y);
2322
+ });
2323
+ const a = [];
2324
+ s = s.filter((h) => {
2325
+ if (r.indexOf(h) > -1) return !1;
2326
+ if (i.has(h)) {
2327
+ const l = i.get(h), d = h.clone();
2328
+ if (l) {
2329
+ for (let f = 0; f < l.length; f += 2) {
2330
+ const m = l[f], u = l[f + 1];
2331
+ m.userData.length = m.distance(d.start), u.userData.length = u.distance(d.start), m.userData.type = "start", u.userData.type = "end", d.start.distance(m) > d.start.distance(u) && (l[f] = u, l[f + 1] = m, m.userData.type = "end", u.userData.type = "start");
2332
+ }
2333
+ l.sort((f, m) => f.userData.length - m.userData.length);
2334
+ const p = [];
2335
+ for (let f = 0; f < l.length; f++) {
2336
+ const m = l[f];
2337
+ m.userData.type === "start" ? (p.length === 0 && (a.push(new L(d.start.clone(), m.clone())), d.start.copy(m)), p.push("start")) : (p.pop(), p.length === 0 && d.start.copy(m));
2338
+ }
2339
+ a.push(d);
2340
+ }
2341
+ return !1;
2342
+ }
2343
+ return !0;
2344
+ }), s.push(...o), s.push(...a.filter((h) => h.length() > 0.05));
2345
+ const c = e.box.center;
2346
+ s = s.map((h) => {
2347
+ const l = h.clone();
2348
+ return l.start.rotate(c, n.angle * (Math.PI / 180)), l.end.rotate(c, n.angle * (Math.PI / 180)), l;
2349
+ }), this.lineSegments = s;
2350
+ }
2351
+ toJson() {
2352
+ const e = /* @__PURE__ */ new Map();
2353
+ let n = 0;
2354
+ return {
2355
+ version: "2",
2356
+ name: "测试",
2357
+ communityName: "测试",
2358
+ city: "",
2359
+ province: "",
2360
+ height: 2.8,
2361
+ walls: this.lineSegments.map((i) => {
2362
+ if (!(i.userData.isDoor && !i.userData.doorDirectConnection))
2363
+ return e.set(i, n), {
2364
+ ID: n++,
2365
+ start: { x: i.start.x * 1, y: i.start.y * 1 },
2366
+ end: { x: i.end.x * 1, y: i.end.y * 1 },
2367
+ thickness: (i.userData.wallWidth ? i.userData.wallWidth : 0.12) * 1,
2368
+ type: "LINE",
2369
+ loadBearingWall: !1,
2370
+ height: 2.8 * 1
2371
+ };
2372
+ }).filter((i) => !!i),
2373
+ pillars: [],
2374
+ beams: [],
2375
+ holes: this.lineSegments.flatMap((i) => {
2376
+ if (i.userData.isDoor && i.userData.doorDirectConnection)
2377
+ return {
2378
+ id: n++,
2379
+ type: "DOOR",
2380
+ openSide: "RIGHT",
2381
+ start: {
2382
+ x: i.start.x * 1,
2383
+ y: i.start.y * 1
2384
+ },
2385
+ end: {
2386
+ x: i.end.x * 1,
2387
+ y: i.end.y * 1
2388
+ },
2389
+ height: 2.1 * 1,
2390
+ qroundClearance: 0,
2391
+ sillHeight: 0
2392
+ };
2393
+ if (i.userData.isWindow)
2394
+ return i.userData.drawWindow.map((s) => {
2395
+ const o = x.from(s.p), r = o.clone().add(
2396
+ i.direction().multiplyScalar(s.width * 0.5)
2397
+ ), a = o.clone().add(
2398
+ i.direction().multiplyScalar(-s.width * 0.5)
2399
+ );
2400
+ return {
2401
+ id: n++,
2402
+ type: "WINDOW",
2403
+ start: {
2404
+ x: r.x * 1,
2405
+ y: r.y * 1
2406
+ },
2407
+ end: {
2408
+ x: a.x * 1,
2409
+ y: a.y * 1
2410
+ },
2411
+ height: 1.6 * 1,
2412
+ groundClearance: 0.9 * 1,
2413
+ sillHeiqht: 0.9 * 1
2414
+ };
2415
+ });
2416
+ }).filter((i) => !!i),
2417
+ rooms: []
2418
+ };
2419
+ }
2420
+ /**
2421
+ * 下载
2422
+ * @param filename
2423
+ */
2424
+ async download(t = "download.json") {
2425
+ if (typeof window < "u") {
2426
+ const e = new Blob([JSON.stringify(this.toJson())]), n = document.createElement("a");
2427
+ n.href = URL.createObjectURL(e), n.download = t, n.click();
2428
+ } else typeof global < "u" && (await Y("fs", !1)).writeFileSync(t, JSON.stringify(this.toJson()));
2429
+ }
2430
+ }
2431
+ class ht extends it {
2306
2432
  Dxf;
2307
2433
  AngleCorrectionDxf;
2308
2434
  Variable;
@@ -2313,7 +2439,7 @@ class ct extends it {
2313
2439
  * @param scale 原始数据缩放比例
2314
2440
  */
2315
2441
  constructor(t = 0.1, e = 1) {
2316
- 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);
2442
+ super(), this.environment = typeof window < "u" ? "browser" : typeof global < "u" ? "node" : "unknown", this.wallWidth = t, this.Dxf = new j(this.wallWidth, e), this.AngleCorrectionDxf = new ot(), this.Variable = new H(), this.addComponent(this.Variable), this.addComponent(this.Dxf), this.addComponent(new at()), this.addComponent(this.AngleCorrectionDxf), this.addComponent(new ct());
2317
2443
  }
2318
2444
  usePlugin(t) {
2319
2445
  return typeof t == "function" && t.call(this, this), this;
@@ -2326,23 +2452,23 @@ class ct extends it {
2326
2452
  });
2327
2453
  }
2328
2454
  }
2329
- const ht = new et(), lt = new nt();
2330
- function dt(g, t, e = 0.1) {
2455
+ const lt = new et(), dt = new nt();
2456
+ function ut(g, t, e = 0.1) {
2331
2457
  const n = t.normal(g), i = t.direction(g).mutiplyScalar(e * 0.5), s = g.direction(t).mutiplyScalar(e * 0.5), o = n.x * e * 0.5, r = n.y * e * 0.5;
2332
2458
  return {
2333
2459
  points: [
2334
2460
  // 第一条线
2335
- new p(g.x + o, g.y + r).add(s),
2336
- new p(t.x + o, t.y + r).add(i),
2461
+ new x(g.x + o, g.y + r).add(s),
2462
+ new x(t.x + o, t.y + r).add(i),
2337
2463
  // 第二条线
2338
- new p(g.x - o, g.y - r).add(s),
2339
- new p(t.x - o, t.y - r).add(i)
2464
+ new x(g.x - o, g.y - r).add(s),
2465
+ new x(t.x - o, t.y - r).add(i)
2340
2466
  ],
2341
2467
  indices: [0, 1, 1, 3, 3, 2, 2, 0],
2342
2468
  rectIndices: [0, 1, 3, 2, 0]
2343
2469
  };
2344
2470
  }
2345
- class H extends q {
2471
+ class _ extends G {
2346
2472
  static name = "WhiteModel";
2347
2473
  Dxf = null;
2348
2474
  Variable = null;
@@ -2372,7 +2498,7 @@ class H extends q {
2372
2498
  new M.LineSegments(new M.EdgesGeometry(s), new M.LineBasicMaterial({ color: 0 }))
2373
2499
  );
2374
2500
  }), t.originalData.map(({ start: n, end: i, insetionArr: s }) => {
2375
- const o = new p(n.x, n.y).mutiplyScalar(t.scale), r = new p(i.x, i.y).mutiplyScalar(t.scale), { points: a, indices: c, rectIndices: h } = dt(o, r, t.width);
2501
+ const o = new x(n.x, n.y).mutiplyScalar(t.scale), r = new x(i.x, i.y).mutiplyScalar(t.scale), { points: a, indices: c, rectIndices: h } = ut(o, r, t.width);
2376
2502
  return {
2377
2503
  points: a,
2378
2504
  indices: c,
@@ -2405,7 +2531,7 @@ class H extends q {
2405
2531
  toOBJ() {
2406
2532
  return new Promise((t) => {
2407
2533
  this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(() => {
2408
- t(ht.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
2534
+ t(lt.parse(this.whiteModelGroup)), this.material.opacity = 0.8, this.material.transparent = !0;
2409
2535
  }, 20);
2410
2536
  });
2411
2537
  }
@@ -2418,7 +2544,7 @@ class H extends q {
2418
2544
  return new Promise((e) => {
2419
2545
  this.material.opacity = 1, this.material.needsUpdate = !0, setTimeout(async () => {
2420
2546
  if (typeof window == "object")
2421
- lt.parse(this.whiteModelGroup.children, (n) => {
2547
+ dt.parse(this.whiteModelGroup.children, (n) => {
2422
2548
  e(n), this.material.opacity = 0.8, this.material.transparent = !0;
2423
2549
  }, () => {
2424
2550
  e(void 0);
@@ -2427,7 +2553,7 @@ class H extends q {
2427
2553
  });
2428
2554
  else if (typeof global != "function")
2429
2555
  try {
2430
- const n = await G("obj2gltf", !0), i = await G("fs", !1), s = await this.toOBJ(), o = Date.now().toString(16) + "-" + Math.floor(Math.random() * 16777215).toString(16);
2556
+ const n = await Y("obj2gltf", !0), i = await Y("fs", !1), s = await this.toOBJ(), o = Date.now().toString(16) + "-" + Math.floor(Math.random() * 16777215).toString(16);
2431
2557
  i.writeFileSync(o, s ?? "存贮失败");
2432
2558
  const r = await n(o, {
2433
2559
  binary: t
@@ -2470,7 +2596,7 @@ class H extends q {
2470
2596
  n.href = URL.createObjectURL(e), n.download = t, n.click();
2471
2597
  } else if (typeof global < "u") {
2472
2598
  const e = await this.toOBJ();
2473
- e && (await G("fs", !1)).writeFileSync(t, e);
2599
+ e && (await Y("fs", !1)).writeFileSync(t, e);
2474
2600
  }
2475
2601
  }
2476
2602
  /**
@@ -2486,11 +2612,11 @@ class H extends q {
2486
2612
  i.href = URL.createObjectURL(n), i.download = t, i.click();
2487
2613
  } else if (typeof global < "u") {
2488
2614
  const n = await this.toGltf(e);
2489
- n && (await G("fs", !1)).writeFileSync(t, e ? n : Buffer.from(n));
2615
+ n && (await Y("fs", !1)).writeFileSync(t, e ? n : Buffer.from(n));
2490
2616
  }
2491
2617
  }
2492
2618
  }
2493
- class Z extends q {
2619
+ class Z extends G {
2494
2620
  static name = "DetailsPoint";
2495
2621
  Dxf = null;
2496
2622
  WhiteModel = null;
@@ -2567,7 +2693,7 @@ class Z extends q {
2567
2693
  }, 50);
2568
2694
  }
2569
2695
  }
2570
- class K extends q {
2696
+ class K extends G {
2571
2697
  static name = "DxfLineModel";
2572
2698
  dxfLineModel = new M.LineSegments();
2573
2699
  dxfDoorsLineModel = new M.LineSegments();
@@ -2590,38 +2716,38 @@ class K extends q {
2590
2716
  });
2591
2717
  }
2592
2718
  }
2593
- const ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2719
+ const ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2594
2720
  __proto__: null,
2595
2721
  DetailsPoint: Z,
2596
2722
  DxfLineModel: K,
2597
- WhiteModel: H
2723
+ WhiteModel: _
2598
2724
  }, Symbol.toStringTag, { value: "Module" }));
2599
- function W(g, t = {}) {
2725
+ function U(g, t = {}) {
2600
2726
  const {
2601
2727
  detailsPoint: e = !0,
2602
2728
  whiteModel: n = !0,
2603
2729
  dxfLineModel: i = !0
2604
2730
  } = t;
2605
- i && g.addComponent(new K()), n && g.addComponent(new H()), e && g.addComponent(new Z());
2731
+ i && g.addComponent(new K()), n && g.addComponent(new _()), e && g.addComponent(new Z());
2606
2732
  }
2607
- const ft = Object.assign(W, {
2733
+ const pt = Object.assign(U, {
2608
2734
  create(g = {}) {
2609
- return (t) => W(t, g);
2735
+ return (t) => U(t, g);
2610
2736
  }
2611
- }), pt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2737
+ }), mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2612
2738
  __proto__: null,
2613
- ModelDataPlugin: ft,
2614
- components: ut
2739
+ ModelDataPlugin: pt,
2740
+ components: ft
2615
2741
  }, Symbol.toStringTag, { value: "Module" }));
2616
- function mt() {
2742
+ function xt() {
2617
2743
  return import("./index2.js");
2618
2744
  }
2619
- function xt() {
2745
+ function yt() {
2620
2746
  return import("./index3.js");
2621
2747
  }
2622
2748
  let z = null;
2623
- async function Et(g, t, e = !1, n) {
2624
- const i = await Promise.resolve().then(() => pt), s = await mt(), o = await xt(), r = new ct().usePlugin(i.ModelDataPlugin.create({
2749
+ async function At(g, t, e = !1, n) {
2750
+ const i = await Promise.resolve().then(() => mt), s = await xt(), o = await yt(), r = new ht().usePlugin(i.ModelDataPlugin.create({
2625
2751
  detailsPoint: !1,
2626
2752
  whiteModel: !0
2627
2753
  })).usePlugin(s.RenderPlugin.create({
@@ -2633,10 +2759,10 @@ async function Et(g, t, e = !1, n) {
2633
2759
  })).usePlugin(o.Editor.create({ viewPermission: n })), a = r.findComponentByType(s.components.DomContainer);
2634
2760
  return a && g.appendChild(a.domElement), z = r, {
2635
2761
  dxfSystem: r,
2636
- getFileAll: () => yt(r)
2762
+ getFileAll: () => gt(r)
2637
2763
  };
2638
2764
  }
2639
- async function yt(g = z) {
2765
+ async function gt(g = z) {
2640
2766
  const t = g.findComponentByName("WhiteModel"), e = new File([await g.AngleCorrectionDxf.toDxfImageBlob()], "img.jpg", { type: "image/jpeg" }), n = new File([g.Dxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), i = new File([g.AngleCorrectionDxf.toDxfBlob()], "dxf.dxf", { type: "application/dxf" }), s = new File([await t.toOBJBlob()], "model.obj", { type: "application/octet-stream" }), o = new File([await t.toGltfBlob(!0)], "model.glb", { type: "application/octet-stream" }), r = new File([await t.toGltfBlob(!1)], "model.gltf", { type: "application/json" }), a = new File([JSON.stringify(g.Dxf.originalData)], "json.json", { type: "application/json" });
2641
2767
  return {
2642
2768
  dxf: n,
@@ -2648,25 +2774,26 @@ async function yt(g = z) {
2648
2774
  correctionDxf: i
2649
2775
  };
2650
2776
  }
2651
- function At() {
2777
+ function vt() {
2652
2778
  return z;
2653
2779
  }
2654
2780
  export {
2655
- v as B,
2656
- q as C,
2657
- ct as D,
2781
+ A as B,
2782
+ G as C,
2783
+ ht as D,
2658
2784
  $ as E,
2659
2785
  L,
2660
- ft as M,
2661
- p as P,
2662
- j as Q,
2663
- _ as V,
2664
- H as W,
2786
+ pt as M,
2787
+ x as P,
2788
+ q as Q,
2789
+ ct as T,
2790
+ H as V,
2791
+ _ as W,
2665
2792
  Z as a,
2666
- U as b,
2667
- Et as c,
2668
- At as d,
2669
- yt as g,
2670
- ut as i,
2671
- N as u
2793
+ k as b,
2794
+ At as c,
2795
+ vt as d,
2796
+ gt as g,
2797
+ ft as i,
2798
+ O as u
2672
2799
  };