build-dxf 0.1.145 → 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
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
|
-
|
|
8523
|
-
|
|
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
|
-
|
|
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,29 +8583,31 @@ class CheckPointCloudContinuity {
|
|
|
8570
8583
|
* @param points
|
|
8571
8584
|
*/
|
|
8572
8585
|
static checkByProjectionContinuity(points, opt) {
|
|
8573
|
-
|
|
8574
|
-
|
|
8575
|
-
if (!xline) {
|
|
8586
|
+
let { ratio = 0.6, gridSize = 0.02, axisLine } = opt ?? {};
|
|
8587
|
+
if (!axisLine) {
|
|
8576
8588
|
const rectangle = new Polygon(
|
|
8577
8589
|
points.map((p2) => new Point(p2.x, p2.y))
|
|
8578
8590
|
).toRectangle();
|
|
8579
|
-
|
|
8591
|
+
axisLine = rectangleToLine(rectangle);
|
|
8592
|
+
} else if (!(axisLine instanceof LineSegment)) {
|
|
8593
|
+
axisLine = new LineSegment(Point.from(axisLine.start), Point.from(axisLine.end));
|
|
8580
8594
|
}
|
|
8595
|
+
const xline = axisLine;
|
|
8581
8596
|
const start = new Vector3(), end = new Vector3();
|
|
8582
8597
|
start.set(xline.start.x, xline.start.y, 0);
|
|
8583
8598
|
end.set(xline.end.x, xline.end.y, 0);
|
|
8584
8599
|
const xts = this.projectPoint(points, start, end);
|
|
8585
|
-
if (!this.continuity(xts, xline.length, ratio)) return false;
|
|
8600
|
+
if (!this.continuity(xts, xline.length, gridSize, ratio)) return false;
|
|
8586
8601
|
const yline2 = xline.clone().rotate(Math.PI * 0.5);
|
|
8587
8602
|
start.set(yline2.start.x, yline2.start.y, 0);
|
|
8588
8603
|
end.set(yline2.end.x, yline2.end.y, 0);
|
|
8589
8604
|
const yts = this.projectPoint(points, start, end);
|
|
8590
|
-
if (!this.continuity(yts, yline2.length, ratio)) return false;
|
|
8605
|
+
if (!this.continuity(yts, yline2.length, gridSize, ratio)) return false;
|
|
8591
8606
|
const center = xline.center.clone();
|
|
8592
8607
|
start.set(center.x, center.y, 10);
|
|
8593
8608
|
end.set(center.x, center.y, -10);
|
|
8594
8609
|
const zts = this.projectPoint(points, start, end);
|
|
8595
|
-
if (!this.continuity(zts, 20, ratio)) return false;
|
|
8610
|
+
if (!this.continuity(zts, 20, gridSize, ratio)) return false;
|
|
8596
8611
|
return true;
|
|
8597
8612
|
}
|
|
8598
8613
|
/** 通过区域投影面积占比检测
|
|
@@ -8600,7 +8615,15 @@ class CheckPointCloudContinuity {
|
|
|
8600
8615
|
* @returns
|
|
8601
8616
|
*/
|
|
8602
8617
|
static checkByVoxelDensity(points, opt) {
|
|
8603
|
-
|
|
8618
|
+
let { gridSize = 0.08, xRatio = 0.5, yRatio = 0.4, overallRatio = 0.5, axisLine } = opt ?? {};
|
|
8619
|
+
if (!axisLine) {
|
|
8620
|
+
const rectangle = new Polygon(
|
|
8621
|
+
points.map((p2) => new Point(p2.x, p2.y))
|
|
8622
|
+
).toRectangle();
|
|
8623
|
+
axisLine = rectangleToLine(rectangle);
|
|
8624
|
+
} else if (!(axisLine instanceof LineSegment)) {
|
|
8625
|
+
axisLine = new LineSegment(Point.from(axisLine.start), Point.from(axisLine.end));
|
|
8626
|
+
}
|
|
8604
8627
|
let xline = axisLine;
|
|
8605
8628
|
if (!xline) {
|
|
8606
8629
|
const rectangle = new Polygon(points.map((p2) => new Point(p2.x, p2.y))).toRectangle();
|
|
@@ -8609,7 +8632,7 @@ class CheckPointCloudContinuity {
|
|
|
8609
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();
|
|
8610
8633
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
8611
8634
|
points.forEach((p2) => {
|
|
8612
|
-
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
|
|
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;
|
|
8613
8636
|
if (occupied.has(key)) return;
|
|
8614
8637
|
occupied.add(key);
|
|
8615
8638
|
xMap.increment(x, 1);
|
|
@@ -8636,10 +8659,11 @@ class CheckPointCloudContinuity {
|
|
|
8636
8659
|
*/
|
|
8637
8660
|
static projectPoint(points, start, end) {
|
|
8638
8661
|
const point2 = new Vector3();
|
|
8662
|
+
const dir = end.clone().sub(start);
|
|
8639
8663
|
return points.map((p2) => {
|
|
8640
8664
|
point2.copy(p2);
|
|
8641
|
-
return projectPointToSegment(point2, start, end);
|
|
8642
|
-
})
|
|
8665
|
+
return projectPointToSegment(point2, start, end, dir);
|
|
8666
|
+
});
|
|
8643
8667
|
}
|
|
8644
8668
|
}
|
|
8645
8669
|
const index$3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
@@ -10946,25 +10970,29 @@ function splitIntersectedLine(lines, minLen = 1e-9, opt) {
|
|
|
10946
10970
|
lines = LineSegmentUtils.splitIntersections(lines, {
|
|
10947
10971
|
obstacle,
|
|
10948
10972
|
onSplit: (line, newLines) => {
|
|
10949
|
-
|
|
10950
|
-
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
10955
|
-
}
|
|
10956
|
-
if (balconyRailing && line.userData.isBalconyRailing) {
|
|
10957
|
-
const len = line.length;
|
|
10958
|
-
newLines.forEach((line2) => {
|
|
10959
|
-
if (line2.length / len < balconyRailing.filteringRatio) {
|
|
10960
|
-
if (opt?.balconyRailing?.behavior === "discard") removeSet.add(line2);
|
|
10961
|
-
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;
|
|
10962
10979
|
}
|
|
10963
|
-
}
|
|
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);
|
|
10964
10992
|
}
|
|
10965
10993
|
}
|
|
10966
10994
|
});
|
|
10967
|
-
lines = lines.filter((line) => line.length >= minLen && !removeSet.has(line));
|
|
10995
|
+
lines = lines.filter((line) => line.length >= minLen && !removeSet.has(line) && LineSegmentUtils.legitimacy(line));
|
|
10968
10996
|
return dedup ? LineSegmentUtils.deduplicate(lines, 3) : lines;
|
|
10969
10997
|
}
|
|
10970
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",
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import { LineSegment } from './LineSegment';
|
|
2
1
|
import { Vector3 } from 'three';
|
|
3
2
|
type Point3D = {
|
|
4
3
|
x: number;
|
|
5
4
|
y: number;
|
|
6
5
|
z: number;
|
|
7
6
|
};
|
|
7
|
+
type LineSegmentType = {
|
|
8
|
+
start: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
z?: number;
|
|
12
|
+
};
|
|
13
|
+
end: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
z?: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
8
19
|
/**
|
|
9
20
|
* 检测点云在分部轴上的连续性,z朝上
|
|
10
21
|
*/
|
|
@@ -15,7 +26,8 @@ export declare class CheckPointCloudContinuity {
|
|
|
15
26
|
*/
|
|
16
27
|
static checkByProjectionContinuity(points: Point3D[], opt?: {
|
|
17
28
|
ratio?: number;
|
|
18
|
-
|
|
29
|
+
gridSize?: number;
|
|
30
|
+
axisLine?: LineSegmentType;
|
|
19
31
|
}): boolean;
|
|
20
32
|
/** 通过区域投影面积占比检测
|
|
21
33
|
* @param points
|
|
@@ -38,7 +50,7 @@ export declare class CheckPointCloudContinuity {
|
|
|
38
50
|
* 总占比比例
|
|
39
51
|
*/
|
|
40
52
|
overallRatio?: number;
|
|
41
|
-
axisLine?:
|
|
53
|
+
axisLine?: LineSegmentType;
|
|
42
54
|
}): boolean;
|
|
43
55
|
/** 获取投影值
|
|
44
56
|
* @param points
|