rm-graphical-computing-node 1.0.40 → 1.0.42
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 +122 -90
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -3447,6 +3447,65 @@ function pointToSegmentDistance(p, a, b) {
|
|
|
3447
3447
|
p.y - y
|
|
3448
3448
|
);
|
|
3449
3449
|
}
|
|
3450
|
+
var voxelDownsample2DForContour = (points, cellSize) => {
|
|
3451
|
+
if (!points || points.length === 0) return [];
|
|
3452
|
+
const map = /* @__PURE__ */ new Map();
|
|
3453
|
+
for (let i = 0; i < points.length; i++) {
|
|
3454
|
+
const p = points[i];
|
|
3455
|
+
const x = p[0];
|
|
3456
|
+
const y = p[1];
|
|
3457
|
+
const gx = Math.floor(x / cellSize);
|
|
3458
|
+
const gy = Math.floor(y / cellSize);
|
|
3459
|
+
const key = `${gx}_${gy}`;
|
|
3460
|
+
let cell = map.get(key);
|
|
3461
|
+
if (!cell) {
|
|
3462
|
+
const cx = (gx + 0.5) * cellSize;
|
|
3463
|
+
const cy = (gy + 0.5) * cellSize;
|
|
3464
|
+
const dx2 = x - cx;
|
|
3465
|
+
const dy2 = y - cy;
|
|
3466
|
+
cell = {
|
|
3467
|
+
minX: p,
|
|
3468
|
+
maxX: p,
|
|
3469
|
+
minY: p,
|
|
3470
|
+
maxY: p,
|
|
3471
|
+
center: p,
|
|
3472
|
+
centerDist2: dx2 * dx2 + dy2 * dy2,
|
|
3473
|
+
cx,
|
|
3474
|
+
cy
|
|
3475
|
+
};
|
|
3476
|
+
map.set(key, cell);
|
|
3477
|
+
continue;
|
|
3478
|
+
}
|
|
3479
|
+
if (x < cell.minX[0]) cell.minX = p;
|
|
3480
|
+
if (x > cell.maxX[0]) cell.maxX = p;
|
|
3481
|
+
if (y < cell.minY[1]) cell.minY = p;
|
|
3482
|
+
if (y > cell.maxY[1]) cell.maxY = p;
|
|
3483
|
+
const dx = x - cell.cx;
|
|
3484
|
+
const dy = y - cell.cy;
|
|
3485
|
+
const dist22 = dx * dx + dy * dy;
|
|
3486
|
+
if (dist22 < cell.centerDist2) {
|
|
3487
|
+
cell.center = p;
|
|
3488
|
+
cell.centerDist2 = dist22;
|
|
3489
|
+
}
|
|
3490
|
+
}
|
|
3491
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3492
|
+
const result = [];
|
|
3493
|
+
function addPoint(p) {
|
|
3494
|
+
const key = `${p[0]}_${p[1]}`;
|
|
3495
|
+
if (!seen.has(key)) {
|
|
3496
|
+
seen.add(key);
|
|
3497
|
+
result.push(p);
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
for (const cell of map.values()) {
|
|
3501
|
+
addPoint(cell.minX);
|
|
3502
|
+
addPoint(cell.maxX);
|
|
3503
|
+
addPoint(cell.minY);
|
|
3504
|
+
addPoint(cell.maxY);
|
|
3505
|
+
addPoint(cell.center);
|
|
3506
|
+
}
|
|
3507
|
+
return result;
|
|
3508
|
+
};
|
|
3450
3509
|
|
|
3451
3510
|
// src/utils/updateLine.mjs
|
|
3452
3511
|
import * as THREE4 from "three";
|
|
@@ -4582,8 +4641,6 @@ var getBeamLine = async (lines, runDataList, pcdData, lineReader, lineEditor, on
|
|
|
4582
4641
|
let afterDoorLen = doorTmpEd.distanceTo(doorTmpSt);
|
|
4583
4642
|
if (afterDoorLen < 0.4 && !isDoor || afterDoorLen < 0.3 && isDoor)
|
|
4584
4643
|
continue;
|
|
4585
|
-
if (!findDoorIndexs.includes(index))
|
|
4586
|
-
findDoorIndexs.push(index);
|
|
4587
4644
|
let dataType = "";
|
|
4588
4645
|
let doorType = isDoor ? "singleDoor" : "";
|
|
4589
4646
|
doorType = isPullOutDoor ? "pullOutDoor" : doorType;
|
|
@@ -4635,11 +4692,23 @@ var getBeamLine = async (lines, runDataList, pcdData, lineReader, lineEditor, on
|
|
|
4635
4692
|
let isPPP = getParallelism(startPt2, endPt2, doorTmpSt, doorTmpEd);
|
|
4636
4693
|
if (result && result.maxPerpendicularDistance < 0.5) {
|
|
4637
4694
|
if (isPPP && isPPP.isParallel) {
|
|
4695
|
+
let lineLen = startPt2.distanceTo(endPt2);
|
|
4696
|
+
let doorLen = doorTmpSt.distanceTo(doorTmpEd);
|
|
4638
4697
|
let tmpLine66 = new THREE5.Line3(startPt2, endPt2);
|
|
4639
4698
|
let tmpPt66 = new THREE5.Vector3(doorTmpSt.x, doorTmpSt.y, startPt2.z);
|
|
4640
4699
|
let ptClose66 = tmpLine66.closestPointToPoint(tmpPt66, true, new THREE5.Vector3());
|
|
4641
4700
|
let isPPPP = perpendicularInfo(ptClose66, tmpPt66, doorTmpSt, doorTmpEd);
|
|
4642
|
-
if (
|
|
4701
|
+
if (doorLen > lineLen) {
|
|
4702
|
+
tmpLine66 = new THREE5.Line3(
|
|
4703
|
+
new THREE5.Vector3(doorTmpSt.x, doorTmpSt.y, startPt2.z),
|
|
4704
|
+
new THREE5.Vector3(doorTmpEd.x, doorTmpEd.y, startPt2.z)
|
|
4705
|
+
);
|
|
4706
|
+
tmpPt66 = startPt2.clone();
|
|
4707
|
+
ptClose66 = tmpLine66.closestPointToPoint(tmpPt66, true, new THREE5.Vector3());
|
|
4708
|
+
isPPPP = perpendicularInfo(ptClose66, tmpPt66, doorTmpSt, doorTmpEd);
|
|
4709
|
+
[ptClose66, tmpPt66] = [tmpPt66, ptClose66];
|
|
4710
|
+
}
|
|
4711
|
+
if (isPPPP && isPPPP.angle > 85 && !wallBelowBeam) {
|
|
4643
4712
|
doorAndBeamDataObj.beamNearWallVec = new THREE5.Vector3().subVectors(ptClose66, tmpPt66).normalize();
|
|
4644
4713
|
if (doorAndBeamDataObj.beamStart.z > lines[x].rooftopPz - 0.03 && length2 > 1) {
|
|
4645
4714
|
wallBelowBeam = true;
|
|
@@ -4928,8 +4997,12 @@ var getBeamLine = async (lines, runDataList, pcdData, lineReader, lineEditor, on
|
|
|
4928
4997
|
});
|
|
4929
4998
|
allDoorLines1.push({
|
|
4930
4999
|
start: doorTmpSt,
|
|
4931
|
-
end: doorTmpEd
|
|
5000
|
+
end: doorTmpEd,
|
|
5001
|
+
index,
|
|
5002
|
+
id: doorAndBeamDataObj.id
|
|
4932
5003
|
});
|
|
5004
|
+
if (!findDoorIndexs.includes(index))
|
|
5005
|
+
findDoorIndexs.push(index);
|
|
4933
5006
|
id++;
|
|
4934
5007
|
if (isPullOutDoor && length2 < 2) break;
|
|
4935
5008
|
}
|
|
@@ -5538,7 +5611,8 @@ function clonePoint(p) {
|
|
|
5538
5611
|
}
|
|
5539
5612
|
|
|
5540
5613
|
// src/geometry/colLine.mjs
|
|
5541
|
-
|
|
5614
|
+
import * as gfx from "rm-gxf-computing-rusts";
|
|
5615
|
+
var getColLine = async (lines, runDataList, collectDataPath, pointCloudCluster = null) => {
|
|
5542
5616
|
if (!lines || lines.length <= 0) return;
|
|
5543
5617
|
let colDatas = {
|
|
5544
5618
|
rectangles: [],
|
|
@@ -5756,6 +5830,7 @@ var getColLine = (lines, runDataList) => {
|
|
|
5756
5830
|
continue;
|
|
5757
5831
|
let colIndexs = {
|
|
5758
5832
|
uuids: [],
|
|
5833
|
+
rooftopPz: 0,
|
|
5759
5834
|
missingEdge: {
|
|
5760
5835
|
start: new THREE6.Vector3(),
|
|
5761
5836
|
end: new THREE6.Vector3()
|
|
@@ -5854,6 +5929,7 @@ var getColLine = (lines, runDataList) => {
|
|
|
5854
5929
|
let area2 = length1 * length2;
|
|
5855
5930
|
if (area2 < minArea || area2 > maxArea) continue;
|
|
5856
5931
|
colIndexs.uuids = [lines[i].uuid, lines[j].uuid, lines[k].uuid];
|
|
5932
|
+
colIndexs.rooftopPz = Math.max(lines[i].rooftopPz, lines[j].rooftopPz, lines[k].rooftopPz);
|
|
5857
5933
|
colIndexs.missingEdge.start = nextNextEndPt;
|
|
5858
5934
|
colIndexs.missingEdge.end = startPt;
|
|
5859
5935
|
break;
|
|
@@ -8755,17 +8831,25 @@ var getMergeMeaning = (allProjectionResults, averagePz2, pointCloudCluster = nul
|
|
|
8755
8831
|
const isMaxBox = compareBoxVolume(obb1, obb2);
|
|
8756
8832
|
if (type1 !== "wall" && type1 !== "floor" && type1 !== "roof") {
|
|
8757
8833
|
if (type1 === "window") {
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8834
|
+
const size1 = new THREE8.Vector3();
|
|
8835
|
+
obb1.getSize(size1);
|
|
8836
|
+
let maxLen1 = size1.x > size1.y ? size1.x : size1.y;
|
|
8837
|
+
const size2 = new THREE8.Vector3();
|
|
8838
|
+
obb2.getSize(size2);
|
|
8839
|
+
let maxLen2 = size2.x > size2.y ? size2.x : size2.y;
|
|
8840
|
+
if (Math.abs(maxLen1 - maxLen2) < 0.5 || maxLen1 > maxLen2) {
|
|
8841
|
+
if (type2 === "balcony railing" && containsObbPoints(obb1, array2[k].points)) {
|
|
8842
|
+
array2[k].isDel = true;
|
|
8843
|
+
continue;
|
|
8844
|
+
}
|
|
8845
|
+
if (type2 === "balcony railing" && containsObbPoints(obb2, array1[e].points)) {
|
|
8846
|
+
array1[e].isDel = true;
|
|
8847
|
+
break;
|
|
8848
|
+
}
|
|
8849
|
+
if (type2 === "balcony railing" && checkBundingBox(obb1, obb2, array1[e].points, array2[k].points) && (Math.abs(minz1 - minz2) < 0.1 || Math.abs(minz2 - averagePz3) > 0.3)) {
|
|
8850
|
+
array2[k].isDel = true;
|
|
8851
|
+
continue;
|
|
8852
|
+
}
|
|
8769
8853
|
}
|
|
8770
8854
|
if (type2 === "door" && containsObbPoints(obb1, array2[k].points)) {
|
|
8771
8855
|
array2[k].isDel = true;
|
|
@@ -8778,17 +8862,25 @@ var getMergeMeaning = (allProjectionResults, averagePz2, pointCloudCluster = nul
|
|
|
8778
8862
|
if (type2 === "window sill")
|
|
8779
8863
|
continue;
|
|
8780
8864
|
} else if (type1 === "balcony railing") {
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8865
|
+
const size1 = new THREE8.Vector3();
|
|
8866
|
+
obb1.getSize(size1);
|
|
8867
|
+
let maxLen1 = size1.x > size1.y ? size1.x : size1.y;
|
|
8868
|
+
const size2 = new THREE8.Vector3();
|
|
8869
|
+
obb2.getSize(size2);
|
|
8870
|
+
let maxLen2 = size2.x > size2.y ? size2.x : size2.y;
|
|
8871
|
+
if (Math.abs(maxLen1 - maxLen2) < 0.5 || maxLen1 < maxLen2) {
|
|
8872
|
+
if (type2 === "window" && containsObbPoints(obb1, array2[k].points)) {
|
|
8873
|
+
array2[k].isDel = true;
|
|
8874
|
+
continue;
|
|
8875
|
+
}
|
|
8876
|
+
if (type2 === "window" && containsObbPoints(obb2, array1[e].points)) {
|
|
8877
|
+
array1[e].isDel = true;
|
|
8878
|
+
break;
|
|
8879
|
+
}
|
|
8880
|
+
if (type2 === "window" && checkBundingBox(obb1, obb2, array1[e].points, array2[k].points) && (Math.abs(minz1 - minz2) < 0.1 || Math.abs(minz1 - averagePz3) > 0.3)) {
|
|
8881
|
+
array1[e].isDel = true;
|
|
8882
|
+
break;
|
|
8883
|
+
}
|
|
8792
8884
|
}
|
|
8793
8885
|
if (type2 === "Staircase" && containsObbPoints(obb1, array2[k].points)) {
|
|
8794
8886
|
array1[e].isStaircaseBalconyRailing = true;
|
|
@@ -10547,65 +10639,6 @@ function obbContainsPoint(obb, point2, epsilon3 = 1e-6) {
|
|
|
10547
10639
|
const z = v2.dot(zAxis);
|
|
10548
10640
|
return Math.abs(x) <= h.x + epsilon3 && Math.abs(y) <= h.y + epsilon3 && Math.abs(z) <= h.z + epsilon3;
|
|
10549
10641
|
}
|
|
10550
|
-
function voxelDownsample2DForContour(points, cellSize) {
|
|
10551
|
-
if (!points || points.length === 0) return [];
|
|
10552
|
-
const map = /* @__PURE__ */ new Map();
|
|
10553
|
-
for (let i = 0; i < points.length; i++) {
|
|
10554
|
-
const p = points[i];
|
|
10555
|
-
const x = p[0];
|
|
10556
|
-
const y = p[1];
|
|
10557
|
-
const gx = Math.floor(x / cellSize);
|
|
10558
|
-
const gy = Math.floor(y / cellSize);
|
|
10559
|
-
const key = `${gx}_${gy}`;
|
|
10560
|
-
let cell = map.get(key);
|
|
10561
|
-
if (!cell) {
|
|
10562
|
-
const cx = (gx + 0.5) * cellSize;
|
|
10563
|
-
const cy = (gy + 0.5) * cellSize;
|
|
10564
|
-
const dx2 = x - cx;
|
|
10565
|
-
const dy2 = y - cy;
|
|
10566
|
-
cell = {
|
|
10567
|
-
minX: p,
|
|
10568
|
-
maxX: p,
|
|
10569
|
-
minY: p,
|
|
10570
|
-
maxY: p,
|
|
10571
|
-
center: p,
|
|
10572
|
-
centerDist2: dx2 * dx2 + dy2 * dy2,
|
|
10573
|
-
cx,
|
|
10574
|
-
cy
|
|
10575
|
-
};
|
|
10576
|
-
map.set(key, cell);
|
|
10577
|
-
continue;
|
|
10578
|
-
}
|
|
10579
|
-
if (x < cell.minX[0]) cell.minX = p;
|
|
10580
|
-
if (x > cell.maxX[0]) cell.maxX = p;
|
|
10581
|
-
if (y < cell.minY[1]) cell.minY = p;
|
|
10582
|
-
if (y > cell.maxY[1]) cell.maxY = p;
|
|
10583
|
-
const dx = x - cell.cx;
|
|
10584
|
-
const dy = y - cell.cy;
|
|
10585
|
-
const dist22 = dx * dx + dy * dy;
|
|
10586
|
-
if (dist22 < cell.centerDist2) {
|
|
10587
|
-
cell.center = p;
|
|
10588
|
-
cell.centerDist2 = dist22;
|
|
10589
|
-
}
|
|
10590
|
-
}
|
|
10591
|
-
const seen = /* @__PURE__ */ new Set();
|
|
10592
|
-
const result = [];
|
|
10593
|
-
function addPoint(p) {
|
|
10594
|
-
const key = `${p[0]}_${p[1]}`;
|
|
10595
|
-
if (!seen.has(key)) {
|
|
10596
|
-
seen.add(key);
|
|
10597
|
-
result.push(p);
|
|
10598
|
-
}
|
|
10599
|
-
}
|
|
10600
|
-
for (const cell of map.values()) {
|
|
10601
|
-
addPoint(cell.minX);
|
|
10602
|
-
addPoint(cell.maxX);
|
|
10603
|
-
addPoint(cell.minY);
|
|
10604
|
-
addPoint(cell.maxY);
|
|
10605
|
-
addPoint(cell.center);
|
|
10606
|
-
}
|
|
10607
|
-
return result;
|
|
10608
|
-
}
|
|
10609
10642
|
|
|
10610
10643
|
// src/utils/clusert.mjs
|
|
10611
10644
|
function alphaForTriangle(points, ia, ib, ic) {
|
|
@@ -10775,10 +10808,9 @@ var getFlatSlabData = (lines, runDataList, pointCloudCluster = null) => {
|
|
|
10775
10808
|
if (isIntersect) {
|
|
10776
10809
|
for (let b = 0; b < slabData2.points.length; b++)
|
|
10777
10810
|
slabData1.points.push(slabData2.points[b]);
|
|
10778
|
-
let
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
let path3 = computeContour(pathPoints);
|
|
10811
|
+
let tmpPoints = slabData1.points.map((p) => [p.x, p.y]);
|
|
10812
|
+
tmpPoints = voxelDownsample2DForContour(tmpPoints, 0.1);
|
|
10813
|
+
let path3 = computeContour(tmpPoints);
|
|
10782
10814
|
slabData1.contour = path3;
|
|
10783
10815
|
delIndex.add(k);
|
|
10784
10816
|
k = -1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rm-graphical-computing-node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.42",
|
|
4
4
|
"description": "墙体/梁线/点云语义计算库(依赖 Python 与 three.js)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"d3-delaunay": "^6.0.4",
|
|
22
22
|
"geojson-minimum-bounding-rectangle": "^2.0.3",
|
|
23
23
|
"rm-graphical-computing-node": "^1.0.24",
|
|
24
|
+
"rm-gxf-computing-rusts": "^0.0.61",
|
|
24
25
|
"rm-point-cloud-calculation": "^1.0.4",
|
|
25
26
|
"rm-point-cloud-calculation-napi": "^1.0.9",
|
|
26
27
|
"three": "^0.184.0"
|