rm-graphical-computing-node 1.0.149 → 1.0.151
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/dist/index.mjs +110 -26
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5939,6 +5939,73 @@ var pointInRectRegion = (point2, regions, epsilon3 = 1e-6) => {
|
|
|
5939
5939
|
}
|
|
5940
5940
|
return isInside;
|
|
5941
5941
|
};
|
|
5942
|
+
function getRectIntersectionRatio(rect1, rect2) {
|
|
5943
|
+
if (!rect1 || !rect2 || rect1.length !== 4 || rect2.length !== 4) {
|
|
5944
|
+
return 0;
|
|
5945
|
+
}
|
|
5946
|
+
const cross3 = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
|
5947
|
+
const polygonArea4 = (points) => {
|
|
5948
|
+
let area2 = 0;
|
|
5949
|
+
for (let i = 0; i < points.length; i++) {
|
|
5950
|
+
const p1 = points[i];
|
|
5951
|
+
const p2 = points[(i + 1) % points.length];
|
|
5952
|
+
area2 += p1.x * p2.y - p2.x * p1.y;
|
|
5953
|
+
}
|
|
5954
|
+
return Math.abs(area2) / 2;
|
|
5955
|
+
};
|
|
5956
|
+
const area1 = polygonArea4(rect1);
|
|
5957
|
+
if (area1 <= 1e-12) return 0;
|
|
5958
|
+
let clip = [...rect2];
|
|
5959
|
+
let signedArea2 = 0;
|
|
5960
|
+
for (let i = 0; i < 4; i++) {
|
|
5961
|
+
const a = clip[i];
|
|
5962
|
+
const b = clip[(i + 1) % 4];
|
|
5963
|
+
signedArea2 += a.x * b.y - b.x * a.y;
|
|
5964
|
+
}
|
|
5965
|
+
if (signedArea2 < 0) {
|
|
5966
|
+
clip.reverse();
|
|
5967
|
+
}
|
|
5968
|
+
let output = [...rect1];
|
|
5969
|
+
for (let i = 0; i < 4; i++) {
|
|
5970
|
+
const A = clip[i];
|
|
5971
|
+
const B2 = clip[(i + 1) % 4];
|
|
5972
|
+
const input = output;
|
|
5973
|
+
output = [];
|
|
5974
|
+
if (!input.length) break;
|
|
5975
|
+
const intersection = (S2, E) => {
|
|
5976
|
+
const dx1 = E.x - S2.x;
|
|
5977
|
+
const dy1 = E.y - S2.y;
|
|
5978
|
+
const dx2 = B2.x - A.x;
|
|
5979
|
+
const dy2 = B2.y - A.y;
|
|
5980
|
+
const denom = dx1 * dy2 - dy1 * dx2;
|
|
5981
|
+
if (Math.abs(denom) < 1e-12) return E.clone();
|
|
5982
|
+
const t = ((A.x - S2.x) * dy2 - (A.y - S2.y) * dx2) / denom;
|
|
5983
|
+
return new THREE3.Vector3(
|
|
5984
|
+
S2.x + t * dx1,
|
|
5985
|
+
S2.y + t * dy1,
|
|
5986
|
+
0
|
|
5987
|
+
);
|
|
5988
|
+
};
|
|
5989
|
+
const inside = (P) => cross3(A, B2, P) >= -1e-10;
|
|
5990
|
+
let S = input[input.length - 1];
|
|
5991
|
+
for (const E of input) {
|
|
5992
|
+
const sInside = inside(S);
|
|
5993
|
+
const eInside = inside(E);
|
|
5994
|
+
if (eInside) {
|
|
5995
|
+
if (!sInside) {
|
|
5996
|
+
output.push(intersection(S, E));
|
|
5997
|
+
}
|
|
5998
|
+
output.push(E);
|
|
5999
|
+
} else if (sInside) {
|
|
6000
|
+
output.push(intersection(S, E));
|
|
6001
|
+
}
|
|
6002
|
+
S = E;
|
|
6003
|
+
}
|
|
6004
|
+
}
|
|
6005
|
+
if (output.length < 3) return 0;
|
|
6006
|
+
const intersectionArea = polygonArea4(output);
|
|
6007
|
+
return Math.max(0, Math.min(100, intersectionArea / area1 * 100));
|
|
6008
|
+
}
|
|
5942
6009
|
|
|
5943
6010
|
// src/utils/updateLine.mjs
|
|
5944
6011
|
import * as THREE4 from "three";
|
|
@@ -9532,6 +9599,7 @@ var getColLine = async (lines, runDataList, collectDataPath, pointCloudCluster =
|
|
|
9532
9599
|
for (let i = 0; i < lines2.length; i++) {
|
|
9533
9600
|
let len = lines2[i].checkResults[0].allCenterPoints.length;
|
|
9534
9601
|
const allCenterPoints = lines2[i].allCenterPoints;
|
|
9602
|
+
if (!allCenterPoints || allCenterPoints.length === 0) continue;
|
|
9535
9603
|
let newPoints = [];
|
|
9536
9604
|
if (pointCloudCluster != null) {
|
|
9537
9605
|
let clusterResult = pointCloudCluster([allCenterPoints], {
|
|
@@ -12248,6 +12316,24 @@ var getMergeMeaning = (allProjectionResults, wallLines, wallVerifyType, averageP
|
|
|
12248
12316
|
if (!averagePz2) averagePz2 = allProjectionResults[0].averagePz;
|
|
12249
12317
|
const pcdPointsArr = [];
|
|
12250
12318
|
const mapMaxSortFloor = /* @__PURE__ */ new Map();
|
|
12319
|
+
const CELL = 0.1;
|
|
12320
|
+
const grid = /* @__PURE__ */ new Map();
|
|
12321
|
+
const rectRegions = [];
|
|
12322
|
+
if (wallLines) {
|
|
12323
|
+
for (const line2 of wallLines) {
|
|
12324
|
+
for (const p2 of line2.originalPoints) {
|
|
12325
|
+
const key = `${Math.floor(p2.x / CELL)},${Math.floor(p2.y / CELL)},${Math.floor(p2.z / CELL)}`;
|
|
12326
|
+
if (!grid.has(key)) grid.set(key, []);
|
|
12327
|
+
grid.get(key).push(p2);
|
|
12328
|
+
}
|
|
12329
|
+
const rect = [];
|
|
12330
|
+
rect.push(getPt3(line2.start));
|
|
12331
|
+
rect.push(getPt3(line2.end));
|
|
12332
|
+
rect.push(getPt3(new THREE8.Vector3(line2.end.x, line2.end.y, line2.rooftopPz ? line2.rooftopPz : line2.end.z)));
|
|
12333
|
+
rect.push(getPt3(new THREE8.Vector3(line2.start.x, line2.start.y, line2.rooftopPz ? line2.rooftopPz : line2.start.z)));
|
|
12334
|
+
rectRegions.push(rect);
|
|
12335
|
+
}
|
|
12336
|
+
}
|
|
12251
12337
|
for (let i = 0; i < allProjectionResults.length; i++) {
|
|
12252
12338
|
let points = allProjectionResults[i].points.map((p) => [p.x, p.y]);
|
|
12253
12339
|
let obj_id = allProjectionResults[i].obj_id;
|
|
@@ -12286,9 +12372,9 @@ var getMergeMeaning = (allProjectionResults, wallLines, wallVerifyType, averageP
|
|
|
12286
12372
|
}
|
|
12287
12373
|
if (wallLines) {
|
|
12288
12374
|
if (wallVerifyType.type1 && wallVerifyType.type1.length && wallVerifyType.type1.includes(word))
|
|
12289
|
-
threePoints = checkNearObjects(
|
|
12375
|
+
threePoints = checkNearObjects(grid, rectRegions, threePoints);
|
|
12290
12376
|
else if (wallVerifyType.type2 && wallVerifyType.type2.length && wallVerifyType.type2.includes(word))
|
|
12291
|
-
threePoints = checkNearObjects(
|
|
12377
|
+
threePoints = checkNearObjects(grid, rectRegions, threePoints, true);
|
|
12292
12378
|
}
|
|
12293
12379
|
let floorZ = -99999;
|
|
12294
12380
|
if (word === "floor") {
|
|
@@ -12455,7 +12541,6 @@ var getMergeMeaning = (allProjectionResults, wallLines, wallVerifyType, averageP
|
|
|
12455
12541
|
for (let i = 0; i < pcdPointsArr.length; i++) {
|
|
12456
12542
|
const array = pcdPointsArr[i].array;
|
|
12457
12543
|
const delData = /* @__PURE__ */ new Set();
|
|
12458
|
-
const mergeData = [];
|
|
12459
12544
|
for (let j = 0; j < array.length; j++) {
|
|
12460
12545
|
if (array[j].obb == null || delData.has(j))
|
|
12461
12546
|
continue;
|
|
@@ -12481,8 +12566,8 @@ var getMergeMeaning = (allProjectionResults, wallLines, wallVerifyType, averageP
|
|
|
12481
12566
|
let boxVecJ = null;
|
|
12482
12567
|
boxVecJ = getObbLongSideDirection(cloneData.obb);
|
|
12483
12568
|
let finMergeObj = false;
|
|
12484
|
-
for (let k =
|
|
12485
|
-
if (array[k].obb == null || delData.has(k))
|
|
12569
|
+
for (let k = 0; k < array.length; k++) {
|
|
12570
|
+
if (array[k].obb == null || delData.has(k) || j == k)
|
|
12486
12571
|
continue;
|
|
12487
12572
|
let minKZ = 0;
|
|
12488
12573
|
let maxKZ = 0;
|
|
@@ -12506,18 +12591,33 @@ var getMergeMeaning = (allProjectionResults, wallLines, wallVerifyType, averageP
|
|
|
12506
12591
|
) {
|
|
12507
12592
|
let tol = array[k].type == "door frame" ? 0.5 : 0.5;
|
|
12508
12593
|
let boxVecK = getObbLongSideDirection(array[k].obb);
|
|
12509
|
-
let
|
|
12594
|
+
let obbPointsK = getOBBPoints(array[k].obb);
|
|
12595
|
+
let obbPointsClone = getOBBPoints(cloneData.obb);
|
|
12596
|
+
let f = getRectIntersectionRatio(
|
|
12597
|
+
[obbPointsK[0], obbPointsK[1], obbPointsK[2], obbPointsK[3]],
|
|
12598
|
+
[obbPointsClone[0], obbPointsClone[1], obbPointsClone[2], obbPointsClone[3]]
|
|
12599
|
+
);
|
|
12510
12600
|
if (boxVecJ.length > 0.2 && boxVecK.length > 0.2 || f > 0.3) {
|
|
12511
12601
|
let isPPPP = isParallel(boxVecJ.direction, boxVecK.direction, tol);
|
|
12512
|
-
if ((!isPPPP || !isPPPP.parallel) && f <
|
|
12602
|
+
if ((!isPPPP || !isPPPP.parallel) && f < 70) {
|
|
12513
12603
|
continue;
|
|
12514
12604
|
}
|
|
12515
12605
|
}
|
|
12516
12606
|
}
|
|
12517
12607
|
let isMerge = false;
|
|
12518
12608
|
if (cloneData.type == "pipe" && !pipeIsVerticalJ) {
|
|
12519
|
-
let
|
|
12520
|
-
|
|
12609
|
+
let obbPointsK = getOBBPoints(array[k].obb);
|
|
12610
|
+
let obbPointsClone = getOBBPoints(cloneData.obb);
|
|
12611
|
+
let f = getRectIntersectionRatio(
|
|
12612
|
+
[obbPointsK[0], obbPointsK[1], obbPointsK[2], obbPointsK[3]],
|
|
12613
|
+
[obbPointsClone[0], obbPointsClone[1], obbPointsClone[2], obbPointsClone[3]]
|
|
12614
|
+
);
|
|
12615
|
+
const overlapHeight = Math.max(0, Math.min(array[k].maxz, cloneData.maxz) - Math.max(array[k].minz, cloneData.minz));
|
|
12616
|
+
let arrayKHeight = array[k].maxz - array[k].minz;
|
|
12617
|
+
let cloneHeight = cloneData.maxz - cloneData.minz;
|
|
12618
|
+
let arrayKOverlapRatio = overlapHeight / arrayKHeight;
|
|
12619
|
+
let cloneOverlapRatio = overlapHeight / cloneHeight;
|
|
12620
|
+
isMerge = f > 30 && (arrayKOverlapRatio > 0.5 || cloneOverlapRatio > 0.5);
|
|
12521
12621
|
} else {
|
|
12522
12622
|
isMerge = cloneData.obb.intersectsOBB(array[k].obb, 0.01);
|
|
12523
12623
|
if (!isMerge)
|
|
@@ -12529,7 +12629,6 @@ var getMergeMeaning = (allProjectionResults, wallLines, wallVerifyType, averageP
|
|
|
12529
12629
|
}
|
|
12530
12630
|
if (isMerge) {
|
|
12531
12631
|
delData.add(k);
|
|
12532
|
-
let nowIndex = cloneData.points.length;
|
|
12533
12632
|
let threePoints = [];
|
|
12534
12633
|
let threePointsStr = [];
|
|
12535
12634
|
for (let m = 0; m < array[k].points.length; m++) {
|
|
@@ -14562,24 +14661,9 @@ function obbContainsPoint(obb, point2, epsilon3 = 1e-6) {
|
|
|
14562
14661
|
const z = v2.dot(zAxis);
|
|
14563
14662
|
return Math.abs(x) <= h.x + epsilon3 && Math.abs(y) <= h.y + epsilon3 && Math.abs(z) <= h.z + epsilon3;
|
|
14564
14663
|
}
|
|
14565
|
-
var checkNearObjects = (
|
|
14664
|
+
var checkNearObjects = (grid, rectRegions, objPoints, delWallPoints = false) => {
|
|
14566
14665
|
const CELL = 0.1;
|
|
14567
|
-
const grid = /* @__PURE__ */ new Map();
|
|
14568
14666
|
const THRESHOLD_SQ = 0.03 * 0.03;
|
|
14569
|
-
const rectRegions = [];
|
|
14570
|
-
for (const line2 of lines) {
|
|
14571
|
-
for (const p2 of line2.originalPoints) {
|
|
14572
|
-
const key = `${Math.floor(p2.x / CELL)},${Math.floor(p2.y / CELL)},${Math.floor(p2.z / CELL)}`;
|
|
14573
|
-
if (!grid.has(key)) grid.set(key, []);
|
|
14574
|
-
grid.get(key).push(p2);
|
|
14575
|
-
}
|
|
14576
|
-
const rect = [];
|
|
14577
|
-
rect.push(getPt3(line2.start));
|
|
14578
|
-
rect.push(getPt3(line2.end));
|
|
14579
|
-
rect.push(getPt3(new THREE8.Vector3(line2.end.x, line2.end.y, line2.rooftopPz ? line2.rooftopPz : line2.end.z)));
|
|
14580
|
-
rect.push(getPt3(new THREE8.Vector3(line2.start.x, line2.start.y, line2.rooftopPz ? line2.rooftopPz : line2.start.z)));
|
|
14581
|
-
rectRegions.push(rect);
|
|
14582
|
-
}
|
|
14583
14667
|
function hasNearbyPoint(p) {
|
|
14584
14668
|
const cx = Math.floor(p.x / CELL);
|
|
14585
14669
|
const cy = Math.floor(p.y / CELL);
|