rm-graphical-computing-node 1.0.39 → 1.0.41

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 +64 -66
  2. package/package.json +1 -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";
@@ -8501,7 +8560,7 @@ var drawStaircase = (pcdPointsArr, scene) => {
8501
8560
  }
8502
8561
  return pointCloudGroup;
8503
8562
  };
8504
- var getMergeMeaning = (allProjectionResults, averagePz2, pointCloudCluster = null) => {
8563
+ var getMergeMeaning = (allProjectionResults, averagePz2, pointCloudCluster = null, tolerancePointCloudCluster = 0.1) => {
8505
8564
  if (allProjectionResults.length == 0) return [];
8506
8565
  if (!averagePz2) averagePz2 = allProjectionResults[0].averagePz;
8507
8566
  const pcdPointsArr = [];
@@ -9027,7 +9086,7 @@ var getMergeMeaning = (allProjectionResults, averagePz2, pointCloudCluster = nul
9027
9086
  if (points.length < 50)
9028
9087
  continue;
9029
9088
  let clusterResult = pointCloudCluster([points], {
9030
- tolerance: 0.2,
9089
+ tolerance: tolerancePointCloudCluster,
9031
9090
  minClusterSize: 50,
9032
9091
  maxClusterSize: 1e7,
9033
9092
  threadCount: 1
@@ -9072,7 +9131,6 @@ var getMergeMeaning = (allProjectionResults, averagePz2, pointCloudCluster = nul
9072
9131
  }
9073
9132
  }
9074
9133
  }
9075
- return pcdPointsArr;
9076
9134
  const retPcdPointArr = [];
9077
9135
  for (let i = 0; i < pcdPointsArr.length; i++) {
9078
9136
  const array = pcdPointsArr[i].array;
@@ -10548,65 +10606,6 @@ function obbContainsPoint(obb, point2, epsilon3 = 1e-6) {
10548
10606
  const z = v2.dot(zAxis);
10549
10607
  return Math.abs(x) <= h.x + epsilon3 && Math.abs(y) <= h.y + epsilon3 && Math.abs(z) <= h.z + epsilon3;
10550
10608
  }
10551
- function voxelDownsample2DForContour(points, cellSize) {
10552
- if (!points || points.length === 0) return [];
10553
- const map = /* @__PURE__ */ new Map();
10554
- for (let i = 0; i < points.length; i++) {
10555
- const p = points[i];
10556
- const x = p[0];
10557
- const y = p[1];
10558
- const gx = Math.floor(x / cellSize);
10559
- const gy = Math.floor(y / cellSize);
10560
- const key = `${gx}_${gy}`;
10561
- let cell = map.get(key);
10562
- if (!cell) {
10563
- const cx = (gx + 0.5) * cellSize;
10564
- const cy = (gy + 0.5) * cellSize;
10565
- const dx2 = x - cx;
10566
- const dy2 = y - cy;
10567
- cell = {
10568
- minX: p,
10569
- maxX: p,
10570
- minY: p,
10571
- maxY: p,
10572
- center: p,
10573
- centerDist2: dx2 * dx2 + dy2 * dy2,
10574
- cx,
10575
- cy
10576
- };
10577
- map.set(key, cell);
10578
- continue;
10579
- }
10580
- if (x < cell.minX[0]) cell.minX = p;
10581
- if (x > cell.maxX[0]) cell.maxX = p;
10582
- if (y < cell.minY[1]) cell.minY = p;
10583
- if (y > cell.maxY[1]) cell.maxY = p;
10584
- const dx = x - cell.cx;
10585
- const dy = y - cell.cy;
10586
- const dist22 = dx * dx + dy * dy;
10587
- if (dist22 < cell.centerDist2) {
10588
- cell.center = p;
10589
- cell.centerDist2 = dist22;
10590
- }
10591
- }
10592
- const seen = /* @__PURE__ */ new Set();
10593
- const result = [];
10594
- function addPoint(p) {
10595
- const key = `${p[0]}_${p[1]}`;
10596
- if (!seen.has(key)) {
10597
- seen.add(key);
10598
- result.push(p);
10599
- }
10600
- }
10601
- for (const cell of map.values()) {
10602
- addPoint(cell.minX);
10603
- addPoint(cell.maxX);
10604
- addPoint(cell.minY);
10605
- addPoint(cell.maxY);
10606
- addPoint(cell.center);
10607
- }
10608
- return result;
10609
- }
10610
10609
 
10611
10610
  // src/utils/clusert.mjs
10612
10611
  function alphaForTriangle(points, ia, ib, ic) {
@@ -10776,10 +10775,9 @@ var getFlatSlabData = (lines, runDataList, pointCloudCluster = null) => {
10776
10775
  if (isIntersect) {
10777
10776
  for (let b = 0; b < slabData2.points.length; b++)
10778
10777
  slabData1.points.push(slabData2.points[b]);
10779
- let pathPoints = slabData1.contour;
10780
- for (let b = 0; b < slabData2.contour.length; b++)
10781
- pathPoints.push(slabData2.contour[b]);
10782
- let path3 = computeContour(pathPoints);
10778
+ let tmpPoints = slabData1.points.map((p) => [p.x, p.y]);
10779
+ tmpPoints = voxelDownsample2DForContour(tmpPoints, 0.1);
10780
+ let path3 = computeContour(tmpPoints);
10783
10781
  slabData1.contour = path3;
10784
10782
  delIndex.add(k);
10785
10783
  k = -1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rm-graphical-computing-node",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "墙体/梁线/点云语义计算库(依赖 Python 与 three.js)",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",