rm-graphical-computing-node 1.0.48 → 1.0.50
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 +184 -28
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -10725,9 +10725,26 @@ function computeContour2(points) {
|
|
|
10725
10725
|
|
|
10726
10726
|
// src/geometry/slabLine.mjs
|
|
10727
10727
|
import * as THREE9 from "three";
|
|
10728
|
-
var getSlabData = (lines, runDataList, pointCloudCluster = null) => {
|
|
10729
|
-
const
|
|
10730
|
-
|
|
10728
|
+
var getSlabData = (lines, runDataList, pointCloudCluster = null, getOblique = false) => {
|
|
10729
|
+
const flatSlabPoints = [];
|
|
10730
|
+
const obliqueSlabPoints = [];
|
|
10731
|
+
if (getOblique) {
|
|
10732
|
+
for (let i = 0; i < lines.length; i++) {
|
|
10733
|
+
const normal = lines[i][0];
|
|
10734
|
+
if (normal.length != 3) continue;
|
|
10735
|
+
if (normal[2] > 0.98)
|
|
10736
|
+
flatSlabPoints.push(lines[i]);
|
|
10737
|
+
else {
|
|
10738
|
+
obliqueSlabPoints.push(lines[i]);
|
|
10739
|
+
}
|
|
10740
|
+
}
|
|
10741
|
+
} else {
|
|
10742
|
+
for (let i = 0; i < lines.length; i++)
|
|
10743
|
+
flatSlabPoints.push(lines[i]);
|
|
10744
|
+
}
|
|
10745
|
+
const flatSlabDatas = getFlatSlabData(flatSlabPoints, runDataList, pointCloudCluster);
|
|
10746
|
+
const obliqueSlabDatas = getObliqueSlabData(obliqueSlabPoints, runDataList, pointCloudCluster);
|
|
10747
|
+
return { flatSlabDatas, obliqueSlabDatas };
|
|
10731
10748
|
};
|
|
10732
10749
|
var getFlatSlabData = (lines, runDataList, pointCloudCluster = null) => {
|
|
10733
10750
|
if (lines.length === 0) return;
|
|
@@ -10840,16 +10857,150 @@ var getFlatSlabData = (lines, runDataList, pointCloudCluster = null) => {
|
|
|
10840
10857
|
}
|
|
10841
10858
|
return slabDatas;
|
|
10842
10859
|
};
|
|
10860
|
+
var getObliqueSlabData = (lines, runDataList, pointCloudCluster = null) => {
|
|
10861
|
+
if (lines.length === 0) return [];
|
|
10862
|
+
let slabDatas = [];
|
|
10863
|
+
let maxHeightTrajectoryPt = new THREE9.Vector3(runDataList[0].x, runDataList[0].y, runDataList[0].z);
|
|
10864
|
+
let totalZ = 0;
|
|
10865
|
+
for (let i = 1; i < runDataList.length; i++) {
|
|
10866
|
+
totalZ += runDataList[i].z;
|
|
10867
|
+
if (runDataList[i].z > maxHeightTrajectoryPt.z) {
|
|
10868
|
+
maxHeightTrajectoryPt.set(runDataList[i].x, runDataList[i].y, runDataList[i].z);
|
|
10869
|
+
}
|
|
10870
|
+
}
|
|
10871
|
+
const averageZ = totalZ / (runDataList.length - 1) + 0.3;
|
|
10872
|
+
for (let i = 0; i < lines.length; i++) {
|
|
10873
|
+
let points = lines[i][1].points;
|
|
10874
|
+
let newPoints = [];
|
|
10875
|
+
if (pointCloudCluster != null) {
|
|
10876
|
+
let clusterResult = pointCloudCluster([points], {
|
|
10877
|
+
tolerance: 0.2,
|
|
10878
|
+
minClusterSize: 30,
|
|
10879
|
+
maxClusterSize: 1e7,
|
|
10880
|
+
threadCount: 1
|
|
10881
|
+
});
|
|
10882
|
+
if (clusterResult.length > 0) {
|
|
10883
|
+
for (const cluster of clusterResult[0]) {
|
|
10884
|
+
if (cluster.length < 50) continue;
|
|
10885
|
+
const newOriginalPoints = cluster.map((i2) => points[i2]);
|
|
10886
|
+
newPoints.push(newOriginalPoints);
|
|
10887
|
+
}
|
|
10888
|
+
} else
|
|
10889
|
+
newPoints.push(points);
|
|
10890
|
+
} else
|
|
10891
|
+
newPoints.push(points);
|
|
10892
|
+
if (newPoints.length == 0)
|
|
10893
|
+
continue;
|
|
10894
|
+
for (let x = 0; x < newPoints.length; x++) {
|
|
10895
|
+
let { minZ, maxZ, averagePz: averagePz2, minZPt, maxZPt } = getPointsMinAndMax(newPoints[x]);
|
|
10896
|
+
if (minZ < averageZ) continue;
|
|
10897
|
+
let slabVec = new THREE9.Vector3().subVectors(minZPt, maxZPt).normalize();
|
|
10898
|
+
let pathPoints = newPoints[x].map((p) => [p.x, p.y]);
|
|
10899
|
+
let path3 = computeContour(pathPoints);
|
|
10900
|
+
getPathZ(path3, newPoints[x]);
|
|
10901
|
+
slabDatas.push({
|
|
10902
|
+
points: newPoints[x],
|
|
10903
|
+
contour: path3,
|
|
10904
|
+
normal: lines[i][0]
|
|
10905
|
+
});
|
|
10906
|
+
}
|
|
10907
|
+
}
|
|
10908
|
+
let delIndex = /* @__PURE__ */ new Set();
|
|
10909
|
+
for (let i = 0; i < slabDatas.length; i++) {
|
|
10910
|
+
if (delIndex.has(i)) continue;
|
|
10911
|
+
const slabData1 = slabDatas[i];
|
|
10912
|
+
for (let j = 0; j < slabDatas.length; j++) {
|
|
10913
|
+
if (i == j || delIndex.has(j)) continue;
|
|
10914
|
+
const slabData2 = slabDatas[j];
|
|
10915
|
+
if (Math.abs(slabData1.normal.z - slabData2.normal.z) > 0.05) continue;
|
|
10916
|
+
const isIntersect = contoursIntersect(slabData1.contour, slabData2.contour, 1e-3);
|
|
10917
|
+
if (isIntersect) {
|
|
10918
|
+
for (let b = 0; b < slabData2.points.length; b++)
|
|
10919
|
+
slabData1.points.push(slabData2.points[b]);
|
|
10920
|
+
let pathPoints = slabData1.points.map((p) => [p.x, p.y]);
|
|
10921
|
+
pathPoints = voxelDownsample2DForContour(pathPoints, 0.1);
|
|
10922
|
+
let path3 = computeContour(pathPoints);
|
|
10923
|
+
getPathZ(path3, slabData1.points);
|
|
10924
|
+
slabData1.contour = path3;
|
|
10925
|
+
delIndex.add(j);
|
|
10926
|
+
j = -1;
|
|
10927
|
+
}
|
|
10928
|
+
}
|
|
10929
|
+
}
|
|
10930
|
+
let newSlabDatas = [];
|
|
10931
|
+
for (let j = 0; j < slabDatas.length; j++) {
|
|
10932
|
+
if (!delIndex.has(j))
|
|
10933
|
+
newSlabDatas.push({
|
|
10934
|
+
contour: slabDatas[j].contour,
|
|
10935
|
+
averagePz: slabDatas[j].averagePz,
|
|
10936
|
+
points: slabDatas[j].points,
|
|
10937
|
+
normal: slabDatas[j].normal
|
|
10938
|
+
});
|
|
10939
|
+
}
|
|
10940
|
+
slabDatas = [];
|
|
10941
|
+
for (let i = 0; i < newSlabDatas.length; i++) {
|
|
10942
|
+
let points = newSlabDatas[i].points;
|
|
10943
|
+
let newPoints = [];
|
|
10944
|
+
if (pointCloudCluster != null) {
|
|
10945
|
+
let clusterResult = pointCloudCluster([points], {
|
|
10946
|
+
tolerance: 0.2,
|
|
10947
|
+
minClusterSize: 30,
|
|
10948
|
+
maxClusterSize: 1e7,
|
|
10949
|
+
threadCount: 1
|
|
10950
|
+
});
|
|
10951
|
+
if (clusterResult.length > 0) {
|
|
10952
|
+
for (const cluster of clusterResult[0]) {
|
|
10953
|
+
if (cluster.length < 50) continue;
|
|
10954
|
+
const newOriginalPoints = cluster.map((i2) => points[i2]);
|
|
10955
|
+
newPoints.push(newOriginalPoints);
|
|
10956
|
+
}
|
|
10957
|
+
} else
|
|
10958
|
+
newPoints.push(points);
|
|
10959
|
+
} else
|
|
10960
|
+
newPoints.push(points);
|
|
10961
|
+
if (newPoints.length == 0)
|
|
10962
|
+
continue;
|
|
10963
|
+
for (let x = 0; x < newPoints.length; x++) {
|
|
10964
|
+
let pathPoints = newPoints[x].map((p) => [p.x, p.y]);
|
|
10965
|
+
let path3 = computeContour(pathPoints);
|
|
10966
|
+
let area2 = calculatePolygonArea(path3);
|
|
10967
|
+
if (area2 < 1) continue;
|
|
10968
|
+
getPathZ(path3, newPoints[x]);
|
|
10969
|
+
slabDatas.push({
|
|
10970
|
+
// points: newPoints[x],
|
|
10971
|
+
contour: path3,
|
|
10972
|
+
normal: lines[i][0],
|
|
10973
|
+
area: area2
|
|
10974
|
+
});
|
|
10975
|
+
}
|
|
10976
|
+
}
|
|
10977
|
+
return slabDatas;
|
|
10978
|
+
};
|
|
10979
|
+
function getPathZ(path3, points) {
|
|
10980
|
+
let pathPt = new THREE9.Vector3();
|
|
10981
|
+
for (let i = 0; i < points.length; i++) {
|
|
10982
|
+
for (let j = 0; j < path3.length; j++) {
|
|
10983
|
+
if (path3[j].length == 3)
|
|
10984
|
+
continue;
|
|
10985
|
+
pathPt.set(path3[j][0], path3[j][1], points[i].z);
|
|
10986
|
+
if (pathPt.distanceTo(points[i]) < 1e-3) {
|
|
10987
|
+
path3[j].push(points[i].z);
|
|
10988
|
+
break;
|
|
10989
|
+
}
|
|
10990
|
+
}
|
|
10991
|
+
}
|
|
10992
|
+
}
|
|
10843
10993
|
|
|
10844
10994
|
// src/geometry/window.mjs
|
|
10845
10995
|
import * as THREE10 from "three";
|
|
10846
10996
|
import { mergeGeometries as mergeGeometries5 } from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
|
10847
|
-
var getWindowData = (lines, pcdData) => {
|
|
10997
|
+
var getWindowData = (lines, pcdData, lineReader) => {
|
|
10848
10998
|
if (lines.length <= 0 || !pcdData)
|
|
10849
10999
|
return lines;
|
|
10850
11000
|
if (!pcdData) pcdData = [];
|
|
10851
11001
|
for (let line2 of lines) {
|
|
10852
11002
|
let allRegion = [];
|
|
11003
|
+
line2.checkResults = lineReader.getLineCheckReultsById(line2.id);
|
|
10853
11004
|
if (!line2.checkResults || line2.checkResults.length <= 0)
|
|
10854
11005
|
continue;
|
|
10855
11006
|
for (let r = 0; r < line2.checkResults.length; r++) {
|
|
@@ -10934,6 +11085,7 @@ var getWindowData = (lines, pcdData) => {
|
|
|
10934
11085
|
}
|
|
10935
11086
|
allRegion.push(...val);
|
|
10936
11087
|
}
|
|
11088
|
+
line2.checkResults = null;
|
|
10937
11089
|
line2.mergeCheckRegion = allRegion;
|
|
10938
11090
|
}
|
|
10939
11091
|
const windowDatas = [];
|
|
@@ -10980,10 +11132,12 @@ var getWindowData = (lines, pcdData) => {
|
|
|
10980
11132
|
let line2 = lines[index];
|
|
10981
11133
|
if (line2.length < 0.5) continue;
|
|
10982
11134
|
if (line2.noDetection) continue;
|
|
10983
|
-
|
|
10984
|
-
|
|
10985
|
-
if (!line2.
|
|
10986
|
-
line2.
|
|
11135
|
+
line2.originalPoints = lineReader.getOriginalPointsById(line2.id);
|
|
11136
|
+
line2.checkResults = lineReader.getLineCheckReultsById(line2.id);
|
|
11137
|
+
if (!line2.windowData)
|
|
11138
|
+
line2.windowData = [];
|
|
11139
|
+
if (!line2.windowIdToCheckResults)
|
|
11140
|
+
line2.windowIdToCheckResults = [];
|
|
10987
11141
|
if (!line2.mergeCheckRegion || line2.mergeCheckRegion.length == 0)
|
|
10988
11142
|
continue;
|
|
10989
11143
|
line2.completePointAreaPercentage = -1;
|
|
@@ -11359,11 +11513,11 @@ var getWindowData = (lines, pcdData) => {
|
|
|
11359
11513
|
pcbDoorIndexs,
|
|
11360
11514
|
groundClearance
|
|
11361
11515
|
};
|
|
11362
|
-
line2.
|
|
11363
|
-
line2.
|
|
11516
|
+
line2.windowIdToCheckResults.push([region.index, id]);
|
|
11517
|
+
line2.windowData.push(doorAndBeamDataObj);
|
|
11364
11518
|
doorBeamDataIndex.push({
|
|
11365
11519
|
linesIndex: index,
|
|
11366
|
-
doorIndex: line2.
|
|
11520
|
+
doorIndex: line2.windowData.length - 1
|
|
11367
11521
|
});
|
|
11368
11522
|
allDoorLines1.push({
|
|
11369
11523
|
start: doorTmpSt,
|
|
@@ -11380,26 +11534,28 @@ var getWindowData = (lines, pcdData) => {
|
|
|
11380
11534
|
}
|
|
11381
11535
|
let faceArea = line2.length * (line2.rooftopPz - line2.start.z);
|
|
11382
11536
|
line2.completePointAreaPercentage = totalArea / faceArea * 100;
|
|
11537
|
+
line2.checkResults = null;
|
|
11538
|
+
line2.originalPoints = null;
|
|
11383
11539
|
}
|
|
11384
11540
|
if (findDoorIndexs.length > 1) {
|
|
11385
11541
|
for (let j = 0; j < findDoorIndexs.length; j++) {
|
|
11386
11542
|
let savedata2 = [];
|
|
11387
|
-
for (let d = 0; d < lines[findDoorIndexs[j]].
|
|
11388
|
-
if (lines[findDoorIndexs[j]].
|
|
11543
|
+
for (let d = 0; d < lines[findDoorIndexs[j]].windowData.length; d++) {
|
|
11544
|
+
if (lines[findDoorIndexs[j]].windowData[d].type != "window")
|
|
11389
11545
|
continue;
|
|
11390
11546
|
let isDel = false;
|
|
11391
11547
|
if (!isDel) {
|
|
11392
|
-
let doorSt1 = lines[findDoorIndexs[j]].
|
|
11393
|
-
let doorEd1 = lines[findDoorIndexs[j]].
|
|
11548
|
+
let doorSt1 = lines[findDoorIndexs[j]].windowData[d].windowBottomSt.clone();
|
|
11549
|
+
let doorEd1 = lines[findDoorIndexs[j]].windowData[d].windowBottomEd.clone();
|
|
11394
11550
|
doorSt1.z = doorEd1.z = 0;
|
|
11395
11551
|
let doorLen1 = doorSt1.distanceTo(doorEd1);
|
|
11396
11552
|
for (let b = 0; b < findDoorIndexs.length; b++) {
|
|
11397
11553
|
if (j == b) continue;
|
|
11398
|
-
for (let r = 0; r < lines[findDoorIndexs[b]].
|
|
11399
|
-
if (lines[findDoorIndexs[b]].
|
|
11554
|
+
for (let r = 0; r < lines[findDoorIndexs[b]].windowData.length; r++) {
|
|
11555
|
+
if (lines[findDoorIndexs[b]].windowData[r].type != "window")
|
|
11400
11556
|
continue;
|
|
11401
|
-
let doorSt2 = lines[findDoorIndexs[b]].
|
|
11402
|
-
let doorEd2 = lines[findDoorIndexs[b]].
|
|
11557
|
+
let doorSt2 = lines[findDoorIndexs[b]].windowData[r].windowBottomSt.clone();
|
|
11558
|
+
let doorEd2 = lines[findDoorIndexs[b]].windowData[r].windowBottomEd.clone();
|
|
11403
11559
|
doorSt2.z = doorEd2.z = 0;
|
|
11404
11560
|
let doorLen2 = doorSt2.distanceTo(doorEd2);
|
|
11405
11561
|
let resultTmp = classifySegments(doorSt1, doorEd1, doorSt2, doorEd2);
|
|
@@ -11409,8 +11565,8 @@ var getWindowData = (lines, pcdData) => {
|
|
|
11409
11565
|
let ptClose = line3.closestPointToPoint(ptMid, true, new THREE10.Vector3());
|
|
11410
11566
|
let distTmp = ptMid.distanceTo(ptClose);
|
|
11411
11567
|
if (Math.abs(doorLen1 - resultTmp.overlap) < 0.1 && distTmp < 0.04) {
|
|
11412
|
-
if (lines[findDoorIndexs[b]].
|
|
11413
|
-
lines[findDoorIndexs[b]].
|
|
11568
|
+
if (lines[findDoorIndexs[b]].windowData[r].nearId == lines[findDoorIndexs[j]].windowData[d].id) {
|
|
11569
|
+
lines[findDoorIndexs[b]].windowData[r].nearId = -1;
|
|
11414
11570
|
}
|
|
11415
11571
|
isDel = true;
|
|
11416
11572
|
break;
|
|
@@ -11420,24 +11576,24 @@ var getWindowData = (lines, pcdData) => {
|
|
|
11420
11576
|
}
|
|
11421
11577
|
}
|
|
11422
11578
|
if (isDel) {
|
|
11423
|
-
for (let z = 0; z < lines[findDoorIndexs[j]].
|
|
11424
|
-
if (lines[findDoorIndexs[j]].
|
|
11425
|
-
lines[findDoorIndexs[j]].
|
|
11579
|
+
for (let z = 0; z < lines[findDoorIndexs[j]].windowIdToCheckResults.length; z++) {
|
|
11580
|
+
if (lines[findDoorIndexs[j]].windowIdToCheckResults[1] == lines[findDoorIndexs[j]].windowData[d].id) {
|
|
11581
|
+
lines[findDoorIndexs[j]].windowIdToCheckResults.splice(z, 1);
|
|
11426
11582
|
break;
|
|
11427
11583
|
}
|
|
11428
11584
|
}
|
|
11429
11585
|
}
|
|
11430
|
-
if (!isDel) savedata2.push(lines[findDoorIndexs[j]].
|
|
11586
|
+
if (!isDel) savedata2.push(lines[findDoorIndexs[j]].windowData[d]);
|
|
11431
11587
|
}
|
|
11432
|
-
if (savedata2.length != lines[findDoorIndexs[j]].
|
|
11433
|
-
lines[findDoorIndexs[j]].
|
|
11588
|
+
if (savedata2.length != lines[findDoorIndexs[j]].windowData.length)
|
|
11589
|
+
lines[findDoorIndexs[j]].windowData = savedata2;
|
|
11434
11590
|
}
|
|
11435
11591
|
}
|
|
11436
11592
|
let tmpLines = [];
|
|
11437
11593
|
for (let i = 0; i < lines.length; i++) {
|
|
11438
11594
|
if (!lines[i].isLine2)
|
|
11439
11595
|
tmpLines.push(lines[i]);
|
|
11440
|
-
if (lines[i].isLine2 && lines[i].
|
|
11596
|
+
if (lines[i].isLine2 && lines[i].windowData.length != 0)
|
|
11441
11597
|
tmpLines.push(lines[i]);
|
|
11442
11598
|
}
|
|
11443
11599
|
lines.length = 0;
|