rm-graphical-computing-node 1.0.53 → 1.0.55

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 +109 -38
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -3506,6 +3506,11 @@ var voxelDownsample2DForContour = (points, cellSize) => {
3506
3506
  }
3507
3507
  return result;
3508
3508
  };
3509
+ var setPointsSameZ = (points, z) => {
3510
+ for (let i = 0; i < points.length; i++)
3511
+ points[i].z = z;
3512
+ return points;
3513
+ };
3509
3514
 
3510
3515
  // src/utils/updateLine.mjs
3511
3516
  import * as THREE4 from "three";
@@ -4614,7 +4619,7 @@ var getBeamLine = async (lines, runDataList, pcdData, lineReader, lineEditor, on
4614
4619
  let line3TmpDoor = new THREE5.Line3(doorTmpSt.clone(), doorTmpEd.clone());
4615
4620
  let nearWallDist = -1;
4616
4621
  for (let x = 0; x < lines.length; x++) {
4617
- if (lines[x].length < 0.5 || x == index) continue;
4622
+ if (lines[x].length < 0.5 || x == index || lines[x].isLine2) continue;
4618
4623
  let startPt2 = new THREE5.Vector3(lines[x].start.x, lines[x].start.y, lines[x].start.z);
4619
4624
  let endPt2 = new THREE5.Vector3(lines[x].end.x, lines[x].end.y, lines[x].end.z);
4620
4625
  let result = classifySegments(startPt2, endPt2, doorTmpSt, doorTmpEd);
@@ -10998,6 +11003,7 @@ function getPathZ(path3, points) {
10998
11003
  // src/geometry/window.mjs
10999
11004
  import * as THREE10 from "three";
11000
11005
  import { mergeGeometries as mergeGeometries5 } from "three/examples/jsm/utils/BufferGeometryUtils.js";
11006
+ import { retarget } from "three/examples/jsm/utils/SkeletonUtils.js";
11001
11007
  var getWindowData = (lines, pcdData, lineReader) => {
11002
11008
  if (lines.length <= 0 || !pcdData)
11003
11009
  return lines;
@@ -11095,7 +11101,7 @@ var getWindowData = (lines, pcdData, lineReader) => {
11095
11101
  const windowDatas = [];
11096
11102
  for (let i = 0; i < pcdData.length; i++) {
11097
11103
  const window = pcdData[i];
11098
- window.isFindBeam = false;
11104
+ window.isFindWindow = false;
11099
11105
  if (window.category == "window") {
11100
11106
  let boxPoints = [];
11101
11107
  window.coordinatesByArea.coordinates.forEach((p) => {
@@ -11123,7 +11129,8 @@ var getWindowData = (lines, pcdData, lineReader) => {
11123
11129
  isFind: false,
11124
11130
  inWall: false,
11125
11131
  //是否在墙内
11126
- name: window.name
11132
+ name: window.name,
11133
+ rectPts: window.coordinatesByArea.coordinates
11127
11134
  });
11128
11135
  }
11129
11136
  }
@@ -11235,7 +11242,7 @@ var getWindowData = (lines, pcdData, lineReader) => {
11235
11242
  continue;
11236
11243
  let addData = false;
11237
11244
  let isWindow = false;
11238
- let beforePcdDoorIsFindBeam = false;
11245
+ let beforePcdDoorisFindWindow = false;
11239
11246
  let doorOpenVector = new THREE10.Vector3(0, 0, 0);
11240
11247
  let pcbDoorIndexs = [];
11241
11248
  let beamTmpSt = tmpRegion.facePoints[2].clone();
@@ -11295,8 +11302,8 @@ var getWindowData = (lines, pcdData, lineReader) => {
11295
11302
  pcbDoorIndexs.push(windowDatas[n].index);
11296
11303
  windowDatas[n].isFind = true;
11297
11304
  findDoorDataIndex = n;
11298
- beforePcdDoorIsFindBeam = pcdData[windowDatas[n].index].isFindBeam;
11299
- pcdData[windowDatas[n].index].isFindBeam = true;
11305
+ beforePcdDoorisFindWindow = pcdData[windowDatas[n].index].isFindWindow;
11306
+ pcdData[windowDatas[n].index].isFindWindow = true;
11300
11307
  let beamVec = new THREE10.Vector3().subVectors(beamSt, beamEd).normalize();
11301
11308
  let doorLength = doorSt.distanceTo(doorEd) - result.overlap;
11302
11309
  if (dist22 < dist1)
@@ -11323,8 +11330,8 @@ var getWindowData = (lines, pcdData, lineReader) => {
11323
11330
  isWindow = true;
11324
11331
  pcbDoorIndexs.push(windowDatas[n].index);
11325
11332
  windowDatas[n].isFind = true;
11326
- beforePcdDoorIsFindBeam = pcdData[windowDatas[n].index].isFindBeam;
11327
- pcdData[windowDatas[n].index].isFindBeam = true;
11333
+ beforePcdDoorisFindWindow = pcdData[windowDatas[n].index].isFindWindow;
11334
+ pcdData[windowDatas[n].index].isFindWindow = true;
11328
11335
  findDoorDataIndex = n;
11329
11336
  }
11330
11337
  }
@@ -11347,7 +11354,7 @@ var getWindowData = (lines, pcdData, lineReader) => {
11347
11354
  let beamStExtended = beamSt.clone().addScaledVector(vec2, nExtend);
11348
11355
  let beamEdExtended = beamEd.clone().addScaledVector(vec2.clone().negate(), nExtend);
11349
11356
  let isPPP = getParallelism(doorStExtended, doorEdExtended, beamStExtended, beamEdExtended);
11350
- if (isPPP.isParallel)
11357
+ if (isPPP.isParallel || isPPP.angleDeg > 45)
11351
11358
  continue;
11352
11359
  let insertPt = segmentsIntersect2D(doorStExtended, doorEdExtended, beamStExtended, beamEdExtended);
11353
11360
  let bIsTrue = true;
@@ -11357,8 +11364,8 @@ var getWindowData = (lines, pcdData, lineReader) => {
11357
11364
  let dist44 = doorEd.distanceTo(beamEd);
11358
11365
  let isNear = dist11 < nearDist || dist22 < nearDist || dist33 < nearDist || dist44 < nearDist;
11359
11366
  if ((isNear || insertPt) && bIsTrue) {
11360
- beforePcdDoorIsFindBeam = pcdData[windowDatas[n].index].isFindBeam;
11361
- pcdData[windowDatas[n].index].isFindBeam = true;
11367
+ beforePcdDoorisFindWindow = pcdData[windowDatas[n].index].isFindWindow;
11368
+ pcdData[windowDatas[n].index].isFindWindow = true;
11362
11369
  isWindow = true;
11363
11370
  windowDatas[n].isFind = true;
11364
11371
  findDoorDataIndex = n;
@@ -11457,8 +11464,8 @@ var getWindowData = (lines, pcdData, lineReader) => {
11457
11464
  }
11458
11465
  if (isOverlap) {
11459
11466
  if (findDoorDataIndex != -1) {
11460
- if (!beforePcdDoorIsFindBeam) {
11461
- pcdData[windowDatas[findDoorDataIndex].index].isFindBeam = false;
11467
+ if (!beforePcdDoorisFindWindow) {
11468
+ pcdData[windowDatas[findDoorDataIndex].index].isFindWindow = false;
11462
11469
  windowDatas[findDoorDataIndex].isFind = false;
11463
11470
  }
11464
11471
  }
@@ -11467,32 +11474,94 @@ var getWindowData = (lines, pcdData, lineReader) => {
11467
11474
  let afterDoorLen = doorTmpEd.distanceTo(doorTmpSt);
11468
11475
  if (afterDoorLen < 0.4 && !isWindow || afterDoorLen < 0.3 && isWindow)
11469
11476
  continue;
11470
- const windowLine = new THREE10.Line3(new THREE10.Vector3(doorTmpSt.x, doorTmpSt.y, 0), new THREE10.Vector3(doorTmpEd.x, doorTmpEd.y, 0));
11477
+ const windowLine = new THREE10.Line3(doorTmpSt, doorTmpEd);
11471
11478
  const windowPcd = windowDatas[findDoorDataIndex];
11472
11479
  const windowPcdSt = windowPcd.windowStartPt.clone();
11473
11480
  const windowPcdEd = windowPcd.windowEndPt.clone();
11474
- windowPcdSt.z = windowPcdEd.z = doorTmpSt.z;
11475
- let dist11 = doorTmpSt.distanceTo(windowPcdSt);
11476
- let dist22 = doorTmpSt.distanceTo(windowPcdEd);
11477
- let dist33 = doorTmpEd.distanceTo(windowPcdSt);
11478
- let dist44 = doorTmpEd.distanceTo(windowPcdEd);
11479
- let minDist = Math.min(dist11, dist22, dist33, dist44);
11480
- let windowLen = windowPcdSt.distanceTo(windowPcdEd);
11481
- let wZ = doorTmpSt.z;
11481
+ const windowLen = windowPcdSt.distanceTo(windowPcdEd);
11482
+ let rectPts = windowPcd.rectPts.map((p) => new THREE10.Vector3(p.x, p.y, p.z));
11483
+ rectPts = setPointsSameZ(rectPts, doorTmpSt.z);
11482
11484
  let ptClose = new THREE10.Vector3();
11483
11485
  let vec2 = new THREE10.Vector3();
11484
- if (dist11 == minDist) {
11485
- ptClose = windowLine.closestPointToPoint(windowPcdSt, false, new THREE10.Vector3());
11486
- vec2 = new THREE10.Vector3().subVectors(doorTmpEd, doorTmpSt).normalize();
11487
- } else if (dist22 == minDist) {
11488
- ptClose = windowLine.closestPointToPoint(windowPcdEd, false, new THREE10.Vector3());
11489
- vec2 = new THREE10.Vector3().subVectors(doorTmpEd, doorTmpSt).normalize();
11490
- } else if (dist33 == minDist) {
11491
- ptClose = windowLine.closestPointToPoint(windowPcdSt, false, new THREE10.Vector3());
11492
- vec2 = new THREE10.Vector3().subVectors(doorTmpSt, doorTmpEd).normalize();
11493
- } else if (dist44 == minDist) {
11494
- ptClose = windowLine.closestPointToPoint(windowPcdEd, false, new THREE10.Vector3());
11495
- vec2 = new THREE10.Vector3().subVectors(doorTmpSt, doorTmpEd).normalize();
11486
+ if (rectPts.length == 5)
11487
+ rectPts.splice(4, 1);
11488
+ let shortLinePt1 = rectPts[0];
11489
+ let shortLinePt2 = rectPts[1];
11490
+ let shortLinePt3 = rectPts[2];
11491
+ let shortLinePt4 = rectPts[3];
11492
+ if (rectPts[0].distanceTo(rectPts[1]) > rectPts[1].distanceTo(rectPts[2])) {
11493
+ shortLinePt1 = rectPts[1];
11494
+ shortLinePt2 = rectPts[2];
11495
+ shortLinePt3 = rectPts[3];
11496
+ shortLinePt4 = rectPts[0];
11497
+ }
11498
+ let addShortLen = 0.2;
11499
+ let vecShort1 = new THREE10.Vector3().subVectors(shortLinePt2, shortLinePt1).normalize();
11500
+ let vecShort2 = new THREE10.Vector3().subVectors(shortLinePt4, shortLinePt3).normalize();
11501
+ shortLinePt1 = shortLinePt1.addScaledVector(vecShort1, -addShortLen);
11502
+ shortLinePt2 = shortLinePt2.addScaledVector(vecShort1, addShortLen);
11503
+ shortLinePt3 = shortLinePt3.addScaledVector(vecShort2, -addShortLen);
11504
+ shortLinePt4 = shortLinePt4.addScaledVector(vecShort2, addShortLen);
11505
+ let tmpVec = new THREE10.Vector3().subVectors(doorTmpEd, doorTmpSt).normalize();
11506
+ let tmpDoorTmpSt = doorTmpSt.clone().addScaledVector(tmpVec, -addShortLen);
11507
+ let tmpDoorTmpEd = doorTmpEd.clone().addScaledVector(tmpVec, addShortLen);
11508
+ let intersect1 = segmentsIntersect2D(shortLinePt1, shortLinePt2, tmpDoorTmpSt, tmpDoorTmpEd);
11509
+ let intersect2 = segmentsIntersect2D(shortLinePt3, shortLinePt4, tmpDoorTmpSt, tmpDoorTmpEd);
11510
+ let distIntersect1 = 99999;
11511
+ let distIntersect2 = 99999;
11512
+ let near1St = false;
11513
+ let near2St = false;
11514
+ if (intersect1 != null) {
11515
+ let dist55 = intersect1.point.distanceTo(doorTmpSt);
11516
+ let dist66 = intersect1.point.distanceTo(doorTmpEd);
11517
+ if (dist55 < 0.1 || dist66 < 0.1) {
11518
+ if (dist55 < dist66) {
11519
+ near1St = true;
11520
+ distIntersect1 = dist55;
11521
+ } else
11522
+ distIntersect1 = dist66;
11523
+ }
11524
+ }
11525
+ if (intersect2 != null) {
11526
+ let dist55 = intersect2.point.distanceTo(doorTmpSt);
11527
+ let dist66 = intersect2.point.distanceTo(doorTmpEd);
11528
+ if (dist55 < 0.1 || dist66 < 0.1) {
11529
+ if (dist55 < dist66) {
11530
+ near2St = true;
11531
+ distIntersect2 = dist55;
11532
+ } else
11533
+ distIntersect2 = dist66;
11534
+ }
11535
+ }
11536
+ if (distIntersect1 == 99999 && distIntersect2 == 99999) {
11537
+ windowPcdSt.z = windowPcdEd.z = doorTmpSt.z;
11538
+ let dist11 = doorTmpSt.distanceTo(windowPcdSt);
11539
+ let dist22 = doorTmpSt.distanceTo(windowPcdEd);
11540
+ let dist33 = doorTmpEd.distanceTo(windowPcdSt);
11541
+ let dist44 = doorTmpEd.distanceTo(windowPcdEd);
11542
+ let minDist = Math.min(dist11, dist22, dist33, dist44);
11543
+ let wZ = doorTmpSt.z;
11544
+ if (dist11 == minDist) {
11545
+ ptClose = windowLine.closestPointToPoint(windowPcdSt, false, new THREE10.Vector3());
11546
+ vec2 = new THREE10.Vector3().subVectors(doorTmpEd, doorTmpSt).normalize();
11547
+ } else if (dist22 == minDist) {
11548
+ ptClose = windowLine.closestPointToPoint(windowPcdEd, false, new THREE10.Vector3());
11549
+ vec2 = new THREE10.Vector3().subVectors(doorTmpEd, doorTmpSt).normalize();
11550
+ } else if (dist33 == minDist) {
11551
+ ptClose = windowLine.closestPointToPoint(windowPcdSt, false, new THREE10.Vector3());
11552
+ vec2 = new THREE10.Vector3().subVectors(doorTmpSt, doorTmpEd).normalize();
11553
+ } else if (dist44 == minDist) {
11554
+ ptClose = windowLine.closestPointToPoint(windowPcdEd, false, new THREE10.Vector3());
11555
+ vec2 = new THREE10.Vector3().subVectors(doorTmpSt, doorTmpEd).normalize();
11556
+ }
11557
+ } else {
11558
+ if (distIntersect1 < distIntersect2) {
11559
+ ptClose = intersect1.point.clone();
11560
+ vec2 = near1St ? new THREE10.Vector3().subVectors(doorTmpEd, doorTmpSt).normalize() : new THREE10.Vector3().subVectors(doorTmpSt, doorTmpEd).normalize();
11561
+ } else {
11562
+ ptClose = intersect2.point.clone();
11563
+ vec2 = near2St ? new THREE10.Vector3().subVectors(doorTmpEd, doorTmpSt).normalize() : new THREE10.Vector3().subVectors(doorTmpSt, doorTmpEd).normalize();
11564
+ }
11496
11565
  }
11497
11566
  doorTmpSt = ptClose.clone();
11498
11567
  doorTmpEd = doorTmpSt.clone().addScaledVector(vec2, windowLen);
@@ -12480,6 +12549,7 @@ function findWindowWalls(windowObjs, wallSegments, options, preMerged) {
12480
12549
  if (!bs.drawWindow) bs.drawWindow = [];
12481
12550
  bs.drawWindow.push(dw_info);
12482
12551
  bs.isWindow = true;
12552
+ win.isFindWindow = true;
12483
12553
  }
12484
12554
  }
12485
12555
  if (bestSeg) {
@@ -12705,13 +12775,13 @@ function processData(wallSegments, objects, options) {
12705
12775
  seg.isWindow = !!(seg.drawWindow && seg.drawWindow.length > 0);
12706
12776
  }
12707
12777
  }
12708
- return { segments: newFinal, matches };
12778
+ return { segments: newFinal, matches, pcdData: objects };
12709
12779
  }
12710
12780
  for (const seg of finalSegments) {
12711
12781
  ;
12712
12782
  seg.isWindow = !!(seg.drawWindow && seg.drawWindow.length > 0);
12713
12783
  }
12714
- return { segments: finalSegments, matches };
12784
+ return { segments: finalSegments, matches, pcdData: objects };
12715
12785
  }
12716
12786
 
12717
12787
  // src/wall-door-matcher/matcher.ts
@@ -14476,6 +14546,7 @@ function processDoorData(wallSegments, objects, options) {
14476
14546
  groundClearance: drawDoor[doorIndex].groundClearance
14477
14547
  };
14478
14548
  doorSeg.drawDoorData = ddData;
14549
+ doorObj.isFindDoor = true;
14479
14550
  }
14480
14551
  finalSegments.push(doorSeg);
14481
14552
  }
@@ -14565,13 +14636,13 @@ function processDoorData(wallSegments, objects, options) {
14565
14636
  ;
14566
14637
  seg.isDoor = !!(seg.DrawDoor && seg.DrawDoor.length > 0);
14567
14638
  }
14568
- return { segments: newFinal, matches: dedupedMatches };
14639
+ return { segments: newFinal, matches: dedupedMatches, pcdData: objects };
14569
14640
  }
14570
14641
  for (const seg of finalSegments) {
14571
14642
  ;
14572
14643
  seg.isDoor = !!(seg.DrawDoor && seg.DrawDoor.length > 0);
14573
14644
  }
14574
- return { segments: finalSegments, matches: dedupedMatches };
14645
+ return { segments: finalSegments, matches: dedupedMatches, pcdData: objects };
14575
14646
  }
14576
14647
 
14577
14648
  // match-api.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rm-graphical-computing-node",
3
- "version": "1.0.53",
3
+ "version": "1.0.55",
4
4
  "description": "墙体/梁线/点云语义计算库(依赖 Python 与 three.js)",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",