rm-graphical-computing-node 1.0.68 → 1.0.69

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.
Files changed (2) hide show
  1. package/dist/index.mjs +112 -9
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -10879,6 +10879,7 @@ var getSlabData = (lines, runDataList, pointCloudCluster = null, getOblique = fa
10879
10879
  flatSlabPoints.push(lines[i]);
10880
10880
  }
10881
10881
  const flatSlabDatas = getFlatSlabData(flatSlabPoints, runDataList, pointCloudCluster);
10882
+ const flatFloorDatas = getFlatFloorData(flatSlabPoints, runDataList, pointCloudCluster);
10882
10883
  const obliqueSlabDatas = getObliqueSlabData(obliqueSlabPoints, runDataList, pointCloudCluster);
10883
10884
  return { flatSlabDatas, obliqueSlabDatas };
10884
10885
  };
@@ -10993,6 +10994,117 @@ var getFlatSlabData = (lines, runDataList, pointCloudCluster = null) => {
10993
10994
  }
10994
10995
  return slabDatas;
10995
10996
  };
10997
+ var getFlatFloorData = (lines, runDataList, pointCloudCluster = null) => {
10998
+ if (lines.length === 0) return;
10999
+ let floorDatas = [];
11000
+ let maxHeightTrajectoryPt = new THREE9.Vector3(runDataList[0].x, runDataList[0].y, runDataList[0].z);
11001
+ let totalZ = 0;
11002
+ for (let i = 1; i < runDataList.length; i++) {
11003
+ totalZ += runDataList[i].z;
11004
+ if (runDataList[i].z > maxHeightTrajectoryPt.z) {
11005
+ maxHeightTrajectoryPt.set(runDataList[i].x, runDataList[i].y, runDataList[i].z);
11006
+ }
11007
+ }
11008
+ const averageZ = totalZ / (runDataList.length - 1);
11009
+ let maxPointsNum = 0;
11010
+ let maxPointsZ = 0;
11011
+ for (const line2 of lines) {
11012
+ let points = line2[1].points;
11013
+ if (points.length < 30) continue;
11014
+ let mapSortPoint = /* @__PURE__ */ new Map();
11015
+ for (let c = 0; c < points.length; c++) {
11016
+ let z = points[c].z;
11017
+ z = Math.floor(z * 10) / 10;
11018
+ if (mapSortPoint.has(z)) {
11019
+ const item = mapSortPoint.get(z);
11020
+ item.num += 1;
11021
+ item.points.push(points[c]);
11022
+ mapSortPoint.set(z, item);
11023
+ } else {
11024
+ mapSortPoint.set(z, { num: 1, points: [points[c]] });
11025
+ }
11026
+ }
11027
+ let mostFrequentEntry = [...mapSortPoint.entries()].reduce(
11028
+ (max2, cur) => cur[1].num > max2[1].num ? cur : max2
11029
+ );
11030
+ points = mostFrequentEntry[1].points.map((p) => new THREE9.Vector3(p.x, p.y, p.z));
11031
+ let newPoints = [];
11032
+ if (pointCloudCluster != null) {
11033
+ let clusterResult = pointCloudCluster([points], {
11034
+ tolerance: 0.1,
11035
+ minClusterSize: 30,
11036
+ maxClusterSize: 1e7,
11037
+ threadCount: 1
11038
+ });
11039
+ if (clusterResult.length > 0) {
11040
+ for (const cluster of clusterResult[0]) {
11041
+ if (cluster.length < 50) continue;
11042
+ const newOriginalPoints = cluster.map((i) => points[i]);
11043
+ newPoints.push(newOriginalPoints);
11044
+ }
11045
+ } else
11046
+ newPoints.push(points);
11047
+ } else
11048
+ newPoints.push(points);
11049
+ for (let u4 = 0; u4 < newPoints.length; u4++) {
11050
+ let { minZ, maxZ, averagePz: averagePz2 } = getPointsMinAndMax(newPoints[u4]);
11051
+ const height = maxZ - minZ;
11052
+ if (averageZ < maxZ) continue;
11053
+ let pathPoints = newPoints[u4].map((p) => [p.x, p.y]);
11054
+ let path3 = computeContour(pathPoints);
11055
+ let area2 = calculatePolygonArea(path3);
11056
+ if (area2 < 0.5) continue;
11057
+ const floorData = {
11058
+ contour: path3,
11059
+ averagePz: averagePz2,
11060
+ points: newPoints[u4]
11061
+ };
11062
+ if (newPoints[u4].length > maxPointsNum) {
11063
+ maxPointsNum = newPoints[u4].length;
11064
+ maxPointsZ = averagePz2;
11065
+ }
11066
+ floorDatas.push(floorData);
11067
+ }
11068
+ }
11069
+ const newFloorDatas = [];
11070
+ for (const floorData of floorDatas) {
11071
+ if (floorData.averagePz <= maxPointsZ || floorData.averagePz < averageZ) {
11072
+ newFloorDatas.push(floorData);
11073
+ }
11074
+ }
11075
+ let delIndex = /* @__PURE__ */ new Set();
11076
+ for (let j = 0; j < newFloorDatas.length; j++) {
11077
+ if (delIndex.has(j)) continue;
11078
+ const floorData1 = newFloorDatas[j];
11079
+ for (let k = 0; k < newFloorDatas.length; k++) {
11080
+ if (j == k || delIndex.has(k))
11081
+ continue;
11082
+ const floorData2 = newFloorDatas[k];
11083
+ if (Math.abs(floorData1.averagePz - floorData2.averagePz) > 0.05) continue;
11084
+ const isIntersect = contoursIntersect(floorData1.contour, floorData2.contour, 1e-3);
11085
+ if (isIntersect) {
11086
+ for (let b = 0; b < floorData2.points.length; b++)
11087
+ floorData1.points.push(floorData2.points[b]);
11088
+ let tmpPoints = floorData1.points.map((p) => [p.x, p.y]);
11089
+ tmpPoints = voxelDownsample2DForContour(tmpPoints, 0.1);
11090
+ let path3 = computeContour(tmpPoints);
11091
+ floorData1.contour = path3;
11092
+ delIndex.add(k);
11093
+ k = -1;
11094
+ }
11095
+ }
11096
+ }
11097
+ floorDatas = [];
11098
+ for (let j = 0; j < newFloorDatas.length; j++) {
11099
+ if (!delIndex.has(j))
11100
+ floorDatas.push({
11101
+ contour: newFloorDatas[j].contour,
11102
+ averagePz: newFloorDatas[j].averagePz
11103
+ // points: newFloorDatas[j].points
11104
+ });
11105
+ }
11106
+ return floorDatas;
11107
+ };
10996
11108
  var getObliqueSlabData = (lines, runDataList, pointCloudCluster = null) => {
10997
11109
  if (lines.length === 0) return [];
10998
11110
  let slabDatas = [];
@@ -11830,15 +11942,6 @@ var getWindowData = (lines, pcdData, lineReader) => {
11830
11942
  lines[findDoorIndexs[j]].windowData = savedata2;
11831
11943
  }
11832
11944
  }
11833
- let tmpLines = [];
11834
- for (let i = 0; i < lines.length; i++) {
11835
- if (!lines[i].isLine2)
11836
- tmpLines.push(lines[i]);
11837
- if (lines[i].isLine2 && lines[i].windowData.length != 0)
11838
- tmpLines.push(lines[i]);
11839
- }
11840
- lines.length = 0;
11841
- lines.push(...tmpLines);
11842
11945
  return { lines, pcdData };
11843
11946
  };
11844
11947
  var checkWindowAndDoorIsTrue = async (lines, runDataList, collectDataPath, pointCloudCluster = null) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rm-graphical-computing-node",
3
- "version": "1.0.68",
3
+ "version": "1.0.69",
4
4
  "description": "墙体/梁线/点云语义计算库(依赖 Python 与 three.js)",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",