build-dxf 0.1.146 → 0.1.147

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "build-dxf",
3
- "version": "0.1.146",
3
+ "version": "0.1.147",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/build.js CHANGED
@@ -3675,6 +3675,18 @@ class LineSegmentUtils {
3675
3675
  }
3676
3676
  return lines;
3677
3677
  }
3678
+ /** 线段合法性检测 */
3679
+ static legitimacy(line) {
3680
+ const values = [
3681
+ line.start.x,
3682
+ line.start.y,
3683
+ line.end.x,
3684
+ line.end.y
3685
+ ];
3686
+ return values.every(
3687
+ (v2) => typeof v2 === "number" && !Number.isNaN(v2)
3688
+ );
3689
+ }
3678
3690
  /**保留四位小数位数
3679
3691
  * @param points
3680
3692
  */
@@ -8519,13 +8531,14 @@ class PCSparseOctree {
8519
8531
  }
8520
8532
  }
8521
8533
  const box3$1 = new THREE.Box3();
8522
- function projectPointToSegment(point2, start, end) {
8523
- const dir = end.clone().sub(start);
8534
+ const temp = new Vector3();
8535
+ function projectPointToSegment(point2, start, _end, dir) {
8524
8536
  const len2 = dir.lengthSq();
8525
8537
  if (len2 < 1e-12) {
8526
8538
  return 0;
8527
8539
  }
8528
- let t2 = point2.clone().sub(start).dot(dir) / len2;
8540
+ temp.copy(point2);
8541
+ let t2 = temp.sub(start).dot(dir) / len2;
8529
8542
  t2 = Math.max(0, Math.min(1, t2));
8530
8543
  return t2;
8531
8544
  }
@@ -8570,7 +8583,7 @@ class CheckPointCloudContinuity {
8570
8583
  * @param points
8571
8584
  */
8572
8585
  static checkByProjectionContinuity(points, opt) {
8573
- let { ratio = 0.6, axisLine } = opt ?? {};
8586
+ let { ratio = 0.6, gridSize = 0.02, axisLine } = opt ?? {};
8574
8587
  if (!axisLine) {
8575
8588
  const rectangle = new Polygon(
8576
8589
  points.map((p2) => new Point(p2.x, p2.y))
@@ -8584,17 +8597,17 @@ class CheckPointCloudContinuity {
8584
8597
  start.set(xline.start.x, xline.start.y, 0);
8585
8598
  end.set(xline.end.x, xline.end.y, 0);
8586
8599
  const xts = this.projectPoint(points, start, end);
8587
- if (!this.continuity(xts, xline.length, ratio)) return false;
8600
+ if (!this.continuity(xts, xline.length, gridSize, ratio)) return false;
8588
8601
  const yline2 = xline.clone().rotate(Math.PI * 0.5);
8589
8602
  start.set(yline2.start.x, yline2.start.y, 0);
8590
8603
  end.set(yline2.end.x, yline2.end.y, 0);
8591
8604
  const yts = this.projectPoint(points, start, end);
8592
- if (!this.continuity(yts, yline2.length, ratio)) return false;
8605
+ if (!this.continuity(yts, yline2.length, gridSize, ratio)) return false;
8593
8606
  const center = xline.center.clone();
8594
8607
  start.set(center.x, center.y, 10);
8595
8608
  end.set(center.x, center.y, -10);
8596
8609
  const zts = this.projectPoint(points, start, end);
8597
- if (!this.continuity(zts, 20, ratio)) return false;
8610
+ if (!this.continuity(zts, 20, gridSize, ratio)) return false;
8598
8611
  return true;
8599
8612
  }
8600
8613
  /** 通过区域投影面积占比检测
@@ -8619,7 +8632,7 @@ class CheckPointCloudContinuity {
8619
8632
  const dir = xline.direction(), angle = Math.atan2(dir.y, dir.x), center = xline.center, cos = Math.cos(-angle), sin = Math.sin(-angle), voxelizationPoints = [], xMap = new CounterMap(), yMap = new CounterMap(), occupied = /* @__PURE__ */ new Set();
8620
8633
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
8621
8634
  points.forEach((p2) => {
8622
- const dx = p2.x - center.x, dy = p2.y - center.y, x = Math.floor((dx * cos - dy * sin) / gridSize), y = Math.floor(p2.z / gridSize), key = BigInt(x) << 32n ^ BigInt(y) & 0xffffffffn;
8635
+ const dx = p2.x - center.x, dy = p2.y - center.y, x = Math.floor((dx * cos - dy * sin) / gridSize), y = Math.floor(p2.z / gridSize), key = BigInt(x) << 32n | BigInt(y) & 0xffffffffn;
8623
8636
  if (occupied.has(key)) return;
8624
8637
  occupied.add(key);
8625
8638
  xMap.increment(x, 1);
@@ -8646,10 +8659,11 @@ class CheckPointCloudContinuity {
8646
8659
  */
8647
8660
  static projectPoint(points, start, end) {
8648
8661
  const point2 = new Vector3();
8662
+ const dir = end.clone().sub(start);
8649
8663
  return points.map((p2) => {
8650
8664
  point2.copy(p2);
8651
- return projectPointToSegment(point2, start, end);
8652
- }).sort((a2, b4) => a2 - b4);
8665
+ return projectPointToSegment(point2, start, end, dir);
8666
+ });
8653
8667
  }
8654
8668
  }
8655
8669
  const index$3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -10956,25 +10970,29 @@ function splitIntersectedLine(lines, minLen = 1e-9, opt) {
10956
10970
  lines = LineSegmentUtils.splitIntersections(lines, {
10957
10971
  obstacle,
10958
10972
  onSplit: (line, newLines) => {
10959
- WallHole.splitHole(line, newLines);
10960
- if (line.userData.isBayWindow) {
10961
- newLines.sort((a2, b4) => b4.length - a2.length);
10962
- for (let i = 1; i < newLines.length; i++) {
10963
- newLines[i].userData.isBayWindow = false;
10964
- }
10965
- }
10966
- if (balconyRailing && line.userData.isBalconyRailing) {
10967
- const len = line.length;
10968
- newLines.forEach((line2) => {
10969
- if (line2.length / len < balconyRailing.filteringRatio) {
10970
- if (opt?.balconyRailing?.behavior === "discard") removeSet.add(line2);
10971
- else delete line2.userData.isBalconyRailing;
10973
+ try {
10974
+ WallHole.splitHole(line, newLines);
10975
+ if (line.userData.isBayWindow) {
10976
+ newLines.sort((a2, b4) => b4.length - a2.length);
10977
+ for (let i = 1; i < newLines.length; i++) {
10978
+ newLines[i].userData.isBayWindow = false;
10972
10979
  }
10973
- });
10980
+ }
10981
+ if (balconyRailing && line.userData.isBalconyRailing) {
10982
+ const len = line.length;
10983
+ newLines.forEach((line2) => {
10984
+ if (line2.length / len < balconyRailing.filteringRatio) {
10985
+ if (opt?.balconyRailing?.behavior === "discard") removeSet.add(line2);
10986
+ else delete line2.userData.isBalconyRailing;
10987
+ }
10988
+ });
10989
+ }
10990
+ } catch (error) {
10991
+ console.error(error.message);
10974
10992
  }
10975
10993
  }
10976
10994
  });
10977
- lines = lines.filter((line) => line.length >= minLen && !removeSet.has(line));
10995
+ lines = lines.filter((line) => line.length >= minLen && !removeSet.has(line) && LineSegmentUtils.legitimacy(line));
10978
10996
  return dedup ? LineSegmentUtils.deduplicate(lines, 3) : lines;
10979
10997
  }
10980
10998
  function mergeChainsLine(lines, callBack, removeLines, newLines) {
package/src/index3.js CHANGED
@@ -11917,7 +11917,9 @@ class Command extends Component {
11917
11917
  " justify-center items-center bg-[rgba(0,0,0,0.5)]": !isMobileRef.value
11918
11918
  },
11919
11919
  "onClick": (e) => e.stopPropagation(),
11920
- "onPointerdown": (e) => e.stopPropagation()
11920
+ "onPointerdown": (e) => e.stopPropagation(),
11921
+ "onPointerup": (e) => e.stopPropagation(),
11922
+ "onMousedown": (e) => e.stopPropagation()
11921
11923
  }, [isMobileRef.value && createVNode("div", {
11922
11924
  "class": "flex-1 pointer-events-none"
11923
11925
  }, null), createVNode("div", {
@@ -14878,6 +14880,8 @@ function createPage$2(el, editWidth, editHeight, editGroundClearance) {
14878
14880
  return createVNode("div", {
14879
14881
  "class": " z-20 absolute left-0 top-[50%] translate-y-[-50%] flex flex-col p-[10px] gap-[16px]",
14880
14882
  "onClick": (e) => e.stopPropagation(),
14883
+ "onMousedown": (e) => e.stopPropagation(),
14884
+ "onPointerup": (e) => e.stopPropagation(),
14881
14885
  "onPointerdown": (e) => e.stopPropagation()
14882
14886
  }, [editWidth && createVNode(_sfc_main$5, {
14883
14887
  "iconSize": "28px",
@@ -18181,6 +18185,7 @@ function createPage(el) {
18181
18185
  return createVNode("div", {
18182
18186
  "class": " z-20 absolute left-0 top-[50%] translate-y-[-50%] flex flex-col p-[10px] gap-[16px]",
18183
18187
  "onClick": (e) => e.stopPropagation(),
18188
+ "onMousedown": (e) => e.stopPropagation(),
18184
18189
  "onPointerdown": (e) => e.stopPropagation()
18185
18190
  }, [createVNode(_sfc_main$4, {
18186
18191
  "icon": "tdesign:rotate-locked-filled",
@@ -26,6 +26,7 @@ export declare class CheckPointCloudContinuity {
26
26
  */
27
27
  static checkByProjectionContinuity(points: Point3D[], opt?: {
28
28
  ratio?: number;
29
+ gridSize?: number;
29
30
  axisLine?: LineSegmentType;
30
31
  }): boolean;
31
32
  /** 通过区域投影面积占比检测
@@ -7,6 +7,8 @@ export declare class LineSegmentUtils {
7
7
  * @param points
8
8
  */
9
9
  static precision(lines: LineSegment[], count: number): LineSegment<Record<string, any>>[];
10
+ /** 线段合法性检测 */
11
+ static legitimacy(line: LineSegment): boolean;
10
12
  /**保留四位小数位数
11
13
  * @param points
12
14
  */