rm-graphical-computing-node 1.0.49 → 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.
Files changed (2) hide show
  1. package/dist/index.mjs +153 -3
  2. 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 flatSlabDatas = getFlatSlabData(lines, runDataList, pointCloudCluster);
10730
- return flatSlabDatas;
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,6 +10857,139 @@ 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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rm-graphical-computing-node",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "description": "墙体/梁线/点云语义计算库(依赖 Python 与 three.js)",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",