rm-graphical-computing-node 1.0.172 → 1.0.174
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 +327 -282
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7772,6 +7772,29 @@ function getPolygonIntersectionRatio(polygon1, polygon2) {
|
|
|
7772
7772
|
}
|
|
7773
7773
|
return Math.max(0, Math.min(100, intersectionArea / area1 * 100));
|
|
7774
7774
|
}
|
|
7775
|
+
var getTriangleAngles = (A, B2, C) => {
|
|
7776
|
+
function getAngle(v1, v2) {
|
|
7777
|
+
const denominator = v1.length() * v2.length();
|
|
7778
|
+
if (denominator === 0) return NaN;
|
|
7779
|
+
const cos = THREE3.MathUtils.clamp(
|
|
7780
|
+
v1.dot(v2) / denominator,
|
|
7781
|
+
-1,
|
|
7782
|
+
1
|
|
7783
|
+
);
|
|
7784
|
+
return THREE3.MathUtils.radToDeg(Math.acos(cos));
|
|
7785
|
+
}
|
|
7786
|
+
const AB = new THREE3.Vector3().subVectors(B2, A);
|
|
7787
|
+
const AC = new THREE3.Vector3().subVectors(C, A);
|
|
7788
|
+
const BA = new THREE3.Vector3().subVectors(A, B2);
|
|
7789
|
+
const BC = new THREE3.Vector3().subVectors(C, B2);
|
|
7790
|
+
const CA = new THREE3.Vector3().subVectors(A, C);
|
|
7791
|
+
const CB = new THREE3.Vector3().subVectors(B2, C);
|
|
7792
|
+
return {
|
|
7793
|
+
angleA: getAngle(AB, AC),
|
|
7794
|
+
angleB: getAngle(BA, BC),
|
|
7795
|
+
angleC: getAngle(CA, CB)
|
|
7796
|
+
};
|
|
7797
|
+
};
|
|
7775
7798
|
|
|
7776
7799
|
// src/utils/updateLine.mjs
|
|
7777
7800
|
import * as THREE4 from "three";
|
|
@@ -8562,13 +8585,6 @@ var getBeamLine = async (lines, runDataList, pcdData, lineReader, lineEditor, on
|
|
|
8562
8585
|
nearExtendDist = Infinity;
|
|
8563
8586
|
indexTmp = -1;
|
|
8564
8587
|
break;
|
|
8565
|
-
} else if (!line2.isLine2 && !lines[f].isLine2) {
|
|
8566
|
-
let minDist = Math.min(tmpDist5, tmpDist6, tmpDist7, tmpDist8);
|
|
8567
|
-
if (minDist < 0.5) {
|
|
8568
|
-
nearExtendDist = minDist;
|
|
8569
|
-
indexTmp = f;
|
|
8570
|
-
break;
|
|
8571
|
-
}
|
|
8572
8588
|
}
|
|
8573
8589
|
}
|
|
8574
8590
|
}
|
|
@@ -8676,13 +8692,6 @@ var getBeamLine = async (lines, runDataList, pcdData, lineReader, lineEditor, on
|
|
|
8676
8692
|
nearExtendDist = Infinity;
|
|
8677
8693
|
indexTmp = -1;
|
|
8678
8694
|
break;
|
|
8679
|
-
} else if (!line2.isLine2 && !lines[f].isLine2) {
|
|
8680
|
-
let minDist = Math.min(tmpDist5, tmpDist6, tmpDist7, tmpDist8);
|
|
8681
|
-
if (minDist < 0.5) {
|
|
8682
|
-
nearExtendDist = minDist;
|
|
8683
|
-
indexTmp = f;
|
|
8684
|
-
break;
|
|
8685
|
-
}
|
|
8686
8695
|
}
|
|
8687
8696
|
}
|
|
8688
8697
|
}
|
|
@@ -8844,6 +8853,23 @@ var getBeamLine = async (lines, runDataList, pcdData, lineReader, lineEditor, on
|
|
|
8844
8853
|
let dist33 = doorEd.distanceTo(beamSt);
|
|
8845
8854
|
let dist44 = doorEd.distanceTo(beamEd);
|
|
8846
8855
|
let isNear = dist11 < nearDist || dist22 < nearDist || dist33 < nearDist || dist44 < nearDist;
|
|
8856
|
+
let doorStExtended2 = doorSt.clone().addScaledVector(vec1, 5);
|
|
8857
|
+
let doorEdExtended2 = doorEd.clone().addScaledVector(vec1.clone().negate(), 5);
|
|
8858
|
+
let beamStExtended2 = beamSt.clone().addScaledVector(vec2, 5);
|
|
8859
|
+
let beamEdExtended2 = beamEd.clone().addScaledVector(vec2.clone().negate(), 5);
|
|
8860
|
+
let insertPt2 = segmentsIntersect2D(doorStExtended2, doorEdExtended2, beamStExtended2, beamEdExtended2);
|
|
8861
|
+
if (insertPt2 == null)
|
|
8862
|
+
continue;
|
|
8863
|
+
let dist55 = doorSt.distanceTo(insertPt2.point);
|
|
8864
|
+
let dist66 = doorEd.distanceTo(insertPt2.point);
|
|
8865
|
+
let dist77 = beamSt.distanceTo(insertPt2.point);
|
|
8866
|
+
let dist88 = beamEd.distanceTo(insertPt2.point);
|
|
8867
|
+
let ptAngle1 = insertPt2.point;
|
|
8868
|
+
let ptAngle2 = dist55 < dist66 ? doorEd.clone() : doorSt.clone();
|
|
8869
|
+
let ptAngle3 = dist77 < dist88 ? beamEd.clone() : beamSt.clone();
|
|
8870
|
+
let triangleAngle = getTriangleAngles(ptAngle1, ptAngle2, ptAngle3);
|
|
8871
|
+
if (triangleAngle.angleA > 100 || triangleAngle.angleB > 100 || triangleAngle.angleC > 100)
|
|
8872
|
+
continue;
|
|
8847
8873
|
if ((isNear || insertPt) && bIsTrue) {
|
|
8848
8874
|
if (doorAndDoorFrameDatas[n].category == "door frame") {
|
|
8849
8875
|
findDoorFrame = true;
|
|
@@ -9377,6 +9403,14 @@ var getBeamLine = async (lines, runDataList, pcdData, lineReader, lineEditor, on
|
|
|
9377
9403
|
nearBeamEd = tmpDoorBeamData.beamEnd.clone();
|
|
9378
9404
|
nearLineIndex = doorBeamDataIndex[w2].linesIndex;
|
|
9379
9405
|
nearDoorIndex = doorBeamDataIndex[w2].doorIndex;
|
|
9406
|
+
if (!doorAndBeamDataObj.isExtend) {
|
|
9407
|
+
if (!isPointOnLine2(line2.start, line2.end, doorAndBeamDataObj.doorStart, 1e-4, true) || !isPointOnLine2(line2.start, line2.end, doorAndBeamDataObj.doorEnd, 1e-4, true))
|
|
9408
|
+
doorAndBeamDataObj.isExtend = true;
|
|
9409
|
+
}
|
|
9410
|
+
if (!tmpDoorBeamData.isExtend) {
|
|
9411
|
+
if (!isPointOnLine2(lines[doorBeamDataIndex[w2].linesIndex].start, lines[doorBeamDataIndex[w2].linesIndex].end, tmpDoorBeamData.doorStart, 1e-4, true) || !isPointOnLine2(lines[doorBeamDataIndex[w2].linesIndex].start, lines[doorBeamDataIndex[w2].linesIndex].end, tmpDoorBeamData.doorEnd, 1e-4, true))
|
|
9412
|
+
tmpDoorBeamData.isExtend = true;
|
|
9413
|
+
}
|
|
9380
9414
|
break;
|
|
9381
9415
|
}
|
|
9382
9416
|
}
|
|
@@ -14479,7 +14513,7 @@ var getMergeMeaning = (allProjectionResults, wallLines, wallVerifyType, averageP
|
|
|
14479
14513
|
}
|
|
14480
14514
|
if (
|
|
14481
14515
|
/**array[k].type == 'door frame' || */
|
|
14482
|
-
array[k].type == "window" || array[k].type == "metal framing of interior glass partitions" || array[k].type == "pipe"
|
|
14516
|
+
array[k].type == "window" || array[k].type == "metal framing of interior glass partitions" || array[k].type == "pipe" || array[k].type == "balcony railing"
|
|
14483
14517
|
) {
|
|
14484
14518
|
let tol = array[k].type == "door frame" ? 0.5 : 0.5;
|
|
14485
14519
|
let boxVecK = getObbLongSideDirection(array[k].obb);
|
|
@@ -14627,185 +14661,188 @@ var getMergeMeaning = (allProjectionResults, wallLines, wallVerifyType, averageP
|
|
|
14627
14661
|
}
|
|
14628
14662
|
}
|
|
14629
14663
|
}
|
|
14630
|
-
|
|
14631
|
-
|
|
14632
|
-
const
|
|
14633
|
-
|
|
14634
|
-
|
|
14635
|
-
|
|
14636
|
-
const
|
|
14637
|
-
|
|
14638
|
-
|
|
14639
|
-
|
|
14640
|
-
|
|
14641
|
-
|
|
14642
|
-
|
|
14643
|
-
|
|
14644
|
-
|
|
14645
|
-
|
|
14646
|
-
delData.add(j);
|
|
14647
|
-
for (let h = 0; h < result.faces.length; h++) {
|
|
14648
|
-
const centerData = getCenterAndPointHeight(result.faces[h]);
|
|
14649
|
-
let tmppoints = result.faces[h].map((p) => [p.x, p.y]);
|
|
14650
|
-
let cloneA = {
|
|
14651
|
-
points: result.faces[h],
|
|
14652
|
-
path: computeContour(tmppoints),
|
|
14653
|
-
h: centerData.h,
|
|
14654
|
-
minz: centerData.minz,
|
|
14655
|
-
maxz: centerData.maxz,
|
|
14656
|
-
center: { x: centerData.x, y: centerData.y, z: centerData.z },
|
|
14657
|
-
obj_id: array[j].obj_id + `_${h}`,
|
|
14658
|
-
type: array[j].type,
|
|
14659
|
-
averagePz: array[j].averagePz,
|
|
14660
|
-
obb: null,
|
|
14661
|
-
isDel: false,
|
|
14662
|
-
positionArr: array[j].positionArr,
|
|
14663
|
-
isStaircaseBalconyRailing: false,
|
|
14664
|
-
mapPosition: array[j].averagePz.mapPosition
|
|
14665
|
-
};
|
|
14666
|
-
cloneA.obb = getObb(cloneA.path, cloneA.center, cloneA.h, (cloneA.maxz + cloneA.minz) / 2);
|
|
14667
|
-
if (cloneA.obb != null) newnewData.push(cloneA);
|
|
14668
|
-
}
|
|
14669
|
-
}
|
|
14670
|
-
}
|
|
14671
|
-
for (let j = 0; j < array.length; j++) {
|
|
14672
|
-
if (!delData.has(j))
|
|
14673
|
-
newnewData.push(array[j]);
|
|
14674
|
-
}
|
|
14675
|
-
if (pointCloudCluster != null) {
|
|
14676
|
-
let delArray = /* @__PURE__ */ new Set();
|
|
14677
|
-
let newArray = [];
|
|
14678
|
-
for (let j = 0; j < newnewData.length; j++) {
|
|
14679
|
-
if (delArray.has(j)) continue;
|
|
14680
|
-
let points = newnewData[j].points;
|
|
14681
|
-
let obj_id = newnewData[j].obj_id;
|
|
14682
|
-
let type = newnewData[j].type;
|
|
14683
|
-
let averagePz3 = newnewData[j].averagePz;
|
|
14684
|
-
let positionArr = newnewData[j].positionArr;
|
|
14685
|
-
let isStaircaseBalconyRailing = newnewData[j].isStaircaseBalconyRailing;
|
|
14686
|
-
if (points.length < 50)
|
|
14687
|
-
continue;
|
|
14688
|
-
let clusterResult = pointCloudCluster([points], {
|
|
14689
|
-
tolerance: tolerancePointCloudCluster,
|
|
14690
|
-
minClusterSize: 20,
|
|
14691
|
-
maxClusterSize: 1e7,
|
|
14692
|
-
threadCount: 1
|
|
14664
|
+
let SpecialTreatment = ["window", "balcony railing"];
|
|
14665
|
+
for (let i = 0; i < SpecialTreatment.length; i++) {
|
|
14666
|
+
const windowArray = pcdPointsArr.find((item) => item.type === SpecialTreatment[i]);
|
|
14667
|
+
if (windowArray) {
|
|
14668
|
+
const delData = /* @__PURE__ */ new Set();
|
|
14669
|
+
const array = windowArray.array;
|
|
14670
|
+
const newnewData = [];
|
|
14671
|
+
for (let j = 0; j < array.length; j++) {
|
|
14672
|
+
const result = splitLShapePointCloud(array[j].points, {
|
|
14673
|
+
threshold: 0.02,
|
|
14674
|
+
iterations: 2e3,
|
|
14675
|
+
minInliers: 100,
|
|
14676
|
+
sampleSize: 12e3,
|
|
14677
|
+
maxPlanes: 10,
|
|
14678
|
+
minPlaneRatio: 0.03,
|
|
14679
|
+
singlePlaneRatio: 0.9
|
|
14693
14680
|
});
|
|
14694
|
-
|
|
14695
|
-
|
|
14696
|
-
let
|
|
14697
|
-
|
|
14698
|
-
|
|
14699
|
-
|
|
14700
|
-
|
|
14701
|
-
|
|
14702
|
-
const data = {
|
|
14703
|
-
points: newOriginalPoints,
|
|
14704
|
-
path: computeContour(pathPoints),
|
|
14681
|
+
if (result.isSplit) {
|
|
14682
|
+
delData.add(j);
|
|
14683
|
+
for (let h = 0; h < result.faces.length; h++) {
|
|
14684
|
+
const centerData = getCenterAndPointHeight(result.faces[h]);
|
|
14685
|
+
let tmppoints = result.faces[h].map((p) => [p.x, p.y]);
|
|
14686
|
+
let cloneA = {
|
|
14687
|
+
points: result.faces[h],
|
|
14688
|
+
path: computeContour(tmppoints),
|
|
14705
14689
|
h: centerData.h,
|
|
14706
14690
|
minz: centerData.minz,
|
|
14707
14691
|
maxz: centerData.maxz,
|
|
14708
14692
|
center: { x: centerData.x, y: centerData.y, z: centerData.z },
|
|
14709
|
-
|
|
14710
|
-
|
|
14693
|
+
obj_id: array[j].obj_id + `_${h}`,
|
|
14694
|
+
type: array[j].type,
|
|
14695
|
+
averagePz: array[j].averagePz,
|
|
14711
14696
|
obb: null,
|
|
14712
|
-
|
|
14713
|
-
positionArr,
|
|
14714
|
-
isStaircaseBalconyRailing,
|
|
14715
|
-
mapPosition:
|
|
14697
|
+
isDel: false,
|
|
14698
|
+
positionArr: array[j].positionArr,
|
|
14699
|
+
isStaircaseBalconyRailing: false,
|
|
14700
|
+
mapPosition: array[j].averagePz.mapPosition
|
|
14716
14701
|
};
|
|
14717
|
-
|
|
14718
|
-
if (
|
|
14719
|
-
newArray.push(data);
|
|
14720
|
-
add++;
|
|
14702
|
+
cloneA.obb = getObb(cloneA.path, cloneA.center, cloneA.h, (cloneA.maxz + cloneA.minz) / 2);
|
|
14703
|
+
if (cloneA.obb != null) newnewData.push(cloneA);
|
|
14721
14704
|
}
|
|
14722
14705
|
}
|
|
14723
|
-
if (newArray.length != beforeLength) {
|
|
14724
|
-
delArray.add(j);
|
|
14725
|
-
}
|
|
14726
14706
|
}
|
|
14727
|
-
|
|
14707
|
+
for (let j = 0; j < array.length; j++) {
|
|
14708
|
+
if (!delData.has(j))
|
|
14709
|
+
newnewData.push(array[j]);
|
|
14710
|
+
}
|
|
14711
|
+
if (pointCloudCluster != null) {
|
|
14712
|
+
let delArray = /* @__PURE__ */ new Set();
|
|
14713
|
+
let newArray = [];
|
|
14728
14714
|
for (let j = 0; j < newnewData.length; j++) {
|
|
14729
|
-
if (
|
|
14730
|
-
|
|
14715
|
+
if (delArray.has(j)) continue;
|
|
14716
|
+
let points = newnewData[j].points;
|
|
14717
|
+
let obj_id = newnewData[j].obj_id;
|
|
14718
|
+
let type = newnewData[j].type;
|
|
14719
|
+
let averagePz3 = newnewData[j].averagePz;
|
|
14720
|
+
let positionArr = newnewData[j].positionArr;
|
|
14721
|
+
let isStaircaseBalconyRailing = newnewData[j].isStaircaseBalconyRailing;
|
|
14722
|
+
if (points.length < 50)
|
|
14723
|
+
continue;
|
|
14724
|
+
let clusterResult = pointCloudCluster([points], {
|
|
14725
|
+
tolerance: tolerancePointCloudCluster,
|
|
14726
|
+
minClusterSize: 20,
|
|
14727
|
+
maxClusterSize: 1e7,
|
|
14728
|
+
threadCount: 1
|
|
14729
|
+
});
|
|
14730
|
+
let beforeLength = newArray.length;
|
|
14731
|
+
if (clusterResult.length > 0 && clusterResult[0].length > 1) {
|
|
14732
|
+
let add = 1;
|
|
14733
|
+
for (const cluster of clusterResult[0]) {
|
|
14734
|
+
if (cluster.length < 50) continue;
|
|
14735
|
+
const newOriginalPoints = cluster.map((i2) => points[i2]);
|
|
14736
|
+
const centerData = getCenterAndPointHeight(newOriginalPoints);
|
|
14737
|
+
let pathPoints = newOriginalPoints.map((p) => [p.x, p.y]);
|
|
14738
|
+
const data = {
|
|
14739
|
+
points: newOriginalPoints,
|
|
14740
|
+
path: computeContour(pathPoints),
|
|
14741
|
+
h: centerData.h,
|
|
14742
|
+
minz: centerData.minz,
|
|
14743
|
+
maxz: centerData.maxz,
|
|
14744
|
+
center: { x: centerData.x, y: centerData.y, z: centerData.z },
|
|
14745
|
+
type,
|
|
14746
|
+
averagePz: averagePz3,
|
|
14747
|
+
obb: null,
|
|
14748
|
+
obj_id: obj_id + `_${add}`,
|
|
14749
|
+
positionArr,
|
|
14750
|
+
isStaircaseBalconyRailing,
|
|
14751
|
+
mapPosition: newnewData[j]?.mapPosition
|
|
14752
|
+
};
|
|
14753
|
+
data.obb = getObb(data.path, data.center, data.h, (data.maxz + data.minz) / 2);
|
|
14754
|
+
if (data.obb == null) continue;
|
|
14755
|
+
newArray.push(data);
|
|
14756
|
+
add++;
|
|
14757
|
+
}
|
|
14731
14758
|
}
|
|
14759
|
+
if (newArray.length != beforeLength) {
|
|
14760
|
+
delArray.add(j);
|
|
14761
|
+
}
|
|
14762
|
+
}
|
|
14763
|
+
if (delArray.size > 0) {
|
|
14764
|
+
for (let j = 0; j < newnewData.length; j++) {
|
|
14765
|
+
if (!delArray.has(j)) {
|
|
14766
|
+
newArray.push(newnewData[j]);
|
|
14767
|
+
}
|
|
14768
|
+
}
|
|
14769
|
+
newnewData.length = 0;
|
|
14770
|
+
newnewData.push(...newArray);
|
|
14732
14771
|
}
|
|
14733
|
-
newnewData.length = 0;
|
|
14734
|
-
newnewData.push(...newArray);
|
|
14735
14772
|
}
|
|
14736
|
-
|
|
14737
|
-
|
|
14738
|
-
|
|
14739
|
-
if (newnewData[j].obb == null || delData.has(j))
|
|
14740
|
-
continue;
|
|
14741
|
-
const cloneData = {
|
|
14742
|
-
...newnewData[j],
|
|
14743
|
-
obb: newnewData[j].obb.clone()
|
|
14744
|
-
};
|
|
14745
|
-
if (cloneData.obb == null)
|
|
14746
|
-
continue;
|
|
14747
|
-
let boxVecJ = null;
|
|
14748
|
-
boxVecJ = getObbLongSideDirection(cloneData.obb);
|
|
14749
|
-
let finMergeObj = false;
|
|
14750
|
-
for (let k = 0; k < newnewData.length; k++) {
|
|
14751
|
-
if (newnewData[k].obb == null || delData.has(k) || j == k)
|
|
14773
|
+
delData.clear();
|
|
14774
|
+
for (let j = 0; j < newnewData.length; j++) {
|
|
14775
|
+
if (newnewData[j].obb == null || delData.has(j))
|
|
14752
14776
|
continue;
|
|
14753
|
-
|
|
14754
|
-
|
|
14755
|
-
|
|
14756
|
-
|
|
14757
|
-
|
|
14758
|
-
|
|
14759
|
-
let
|
|
14760
|
-
|
|
14761
|
-
|
|
14762
|
-
|
|
14777
|
+
const cloneData = {
|
|
14778
|
+
...newnewData[j],
|
|
14779
|
+
obb: newnewData[j].obb.clone()
|
|
14780
|
+
};
|
|
14781
|
+
if (cloneData.obb == null)
|
|
14782
|
+
continue;
|
|
14783
|
+
let boxVecJ = null;
|
|
14784
|
+
boxVecJ = getObbLongSideDirection(cloneData.obb);
|
|
14785
|
+
let finMergeObj = false;
|
|
14786
|
+
for (let k = 0; k < newnewData.length; k++) {
|
|
14787
|
+
if (newnewData[k].obb == null || delData.has(k) || j == k)
|
|
14763
14788
|
continue;
|
|
14789
|
+
let tol = 0.35;
|
|
14790
|
+
let boxVecK = getObbLongSideDirection(newnewData[k].obb);
|
|
14791
|
+
let obbPointsClone = getOBBPoints(cloneData.obb);
|
|
14792
|
+
let polygonK = newnewData[k].path.map((point2) => new THREE8.Vector3(point2[0], point2[1], 0));
|
|
14793
|
+
let polygonJ = [obbPointsClone[0], obbPointsClone[1], obbPointsClone[2], obbPointsClone[3]];
|
|
14794
|
+
polygonJ = setPointsSameZ(polygonJ, 0);
|
|
14795
|
+
let f = getPolygonIntersectionRatio(polygonK, polygonJ);
|
|
14796
|
+
if (boxVecJ.length > 0.2 && boxVecK.length > 0.2 || f > 30) {
|
|
14797
|
+
let isPPPP = isParallel(boxVecJ.direction, boxVecK.direction, tol);
|
|
14798
|
+
if ((!isPPPP || !isPPPP.parallel) && f < 80) {
|
|
14799
|
+
continue;
|
|
14800
|
+
}
|
|
14764
14801
|
}
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
isMerge = f2 > 0.8;
|
|
14772
|
-
}
|
|
14773
|
-
if (isMerge) {
|
|
14774
|
-
delData.add(k);
|
|
14775
|
-
let threePoints = [];
|
|
14776
|
-
let threePointsStr = [];
|
|
14777
|
-
for (let m = 0; m < newnewData[k].points.length; m++) {
|
|
14778
|
-
cloneData.points.push(newnewData[k].points[m]);
|
|
14779
|
-
threePoints.push(newnewData[k].points[m]);
|
|
14780
|
-
threePointsStr.push(`${newnewData[k].points[m].x},${newnewData[k].points[m].y},${newnewData[k].points[m].z}`);
|
|
14802
|
+
let isMerge = cloneData.obb.intersectsOBB(newnewData[k].obb);
|
|
14803
|
+
if (!isMerge)
|
|
14804
|
+
isMerge = obbContainsOBB(cloneData.obb, newnewData[k].obb);
|
|
14805
|
+
if (!isMerge) {
|
|
14806
|
+
let f2 = calculateClosePointWithOBB(newnewData[k].points, cloneData.obb, 1);
|
|
14807
|
+
isMerge = f2 > 0.8;
|
|
14781
14808
|
}
|
|
14782
|
-
|
|
14783
|
-
|
|
14784
|
-
|
|
14785
|
-
|
|
14786
|
-
|
|
14787
|
-
|
|
14788
|
-
|
|
14789
|
-
|
|
14790
|
-
|
|
14791
|
-
|
|
14792
|
-
|
|
14793
|
-
|
|
14794
|
-
|
|
14795
|
-
|
|
14809
|
+
if (isMerge) {
|
|
14810
|
+
delData.add(k);
|
|
14811
|
+
let threePoints = [];
|
|
14812
|
+
let threePointsStr = [];
|
|
14813
|
+
for (let m = 0; m < newnewData[k].points.length; m++) {
|
|
14814
|
+
cloneData.points.push(newnewData[k].points[m]);
|
|
14815
|
+
threePoints.push(newnewData[k].points[m]);
|
|
14816
|
+
threePointsStr.push(`${newnewData[k].points[m].x},${newnewData[k].points[m].y},${newnewData[k].points[m].z}`);
|
|
14817
|
+
}
|
|
14818
|
+
let tmpPoints = cloneData.points.map((p) => [p.x, p.y]);
|
|
14819
|
+
tmpPoints = voxelDownsample2DForContour(tmpPoints, 0.1);
|
|
14820
|
+
cloneData.path = computeContour(tmpPoints);
|
|
14821
|
+
const centerData = getCenterAndPointHeight(cloneData.points);
|
|
14822
|
+
cloneData.h = centerData.h;
|
|
14823
|
+
cloneData.minz = centerData.minz;
|
|
14824
|
+
cloneData.maxz = centerData.maxz;
|
|
14825
|
+
cloneData.center = { x: centerData.x, y: centerData.y, z: centerData.z };
|
|
14826
|
+
let newObb = getObb(cloneData.path, cloneData.center, cloneData.h, (cloneData.maxz + cloneData.minz) / 2);
|
|
14827
|
+
if (newObb != null)
|
|
14828
|
+
cloneData.obb = newObb;
|
|
14829
|
+
boxVecJ = getObbLongSideDirection(cloneData.obb);
|
|
14830
|
+
k = -1;
|
|
14831
|
+
finMergeObj = true;
|
|
14832
|
+
}
|
|
14833
|
+
}
|
|
14834
|
+
if (finMergeObj) {
|
|
14835
|
+
delData.add(j);
|
|
14836
|
+
newnewData.push(cloneData);
|
|
14796
14837
|
}
|
|
14797
14838
|
}
|
|
14798
|
-
|
|
14799
|
-
|
|
14800
|
-
|
|
14839
|
+
const newData = [];
|
|
14840
|
+
for (let j = 0; j < newnewData.length; j++) {
|
|
14841
|
+
if (!delData.has(j))
|
|
14842
|
+
newData.push(newnewData[j]);
|
|
14801
14843
|
}
|
|
14844
|
+
windowArray.array = newData;
|
|
14802
14845
|
}
|
|
14803
|
-
const newData = [];
|
|
14804
|
-
for (let j = 0; j < newnewData.length; j++) {
|
|
14805
|
-
if (!delData.has(j))
|
|
14806
|
-
newData.push(newnewData[j]);
|
|
14807
|
-
}
|
|
14808
|
-
windowArray.array = newData;
|
|
14809
14846
|
}
|
|
14810
14847
|
for (let i = 0; i < pcdPointsArr.length; i++) {
|
|
14811
14848
|
const type1 = pcdPointsArr[i].type;
|
|
@@ -17969,13 +18006,6 @@ var getWindowData = (lines, pcdData, lineReader) => {
|
|
|
17969
18006
|
if (!line2.mergeCheckRegion || line2.mergeCheckRegion.length == 0)
|
|
17970
18007
|
continue;
|
|
17971
18008
|
line2.completePointAreaPercentage = -1;
|
|
17972
|
-
let box = new THREE10.Box3();
|
|
17973
|
-
box.setFromPoints(line2.originalPoints);
|
|
17974
|
-
let maxZ = box.max.z;
|
|
17975
|
-
let minZ = box.min.z;
|
|
17976
|
-
const lineStart = new THREE10.Vector3(line2.start.x, line2.start.y, line2.start.z);
|
|
17977
|
-
const lineEnd = new THREE10.Vector3(line2.end.x, line2.end.y, line2.end.z);
|
|
17978
|
-
let floorHeightTmp = line2.rooftopPz - line2.start.z;
|
|
17979
18009
|
let totalArea = 0;
|
|
17980
18010
|
for (const region of line2.mergeCheckRegion) {
|
|
17981
18011
|
const facePoints = region.facePoints;
|
|
@@ -19412,32 +19442,23 @@ var getDoorPcdData = (lines, pcdData, needFindOtherDoor = true) => {
|
|
|
19412
19442
|
import * as THREE12 from "three";
|
|
19413
19443
|
|
|
19414
19444
|
// src/utils/arc-tools.js
|
|
19415
|
-
function fitPolyline(points, epsilon3 = 0.01, binCount =
|
|
19416
|
-
if (!Array.isArray(points)) {
|
|
19417
|
-
|
|
19418
|
-
}
|
|
19419
|
-
if (points.some(
|
|
19420
|
-
(p) => !p || !Number.isFinite(p.x) || !Number.isFinite(p.y)
|
|
19421
|
-
)) {
|
|
19422
|
-
throw new Error("\u70B9\u5750\u6807\u5FC5\u987B\u4E3A\u6709\u9650\u6570\u503C");
|
|
19445
|
+
function fitPolyline(points, epsilon3 = 0.01, binCount = 64) {
|
|
19446
|
+
if (!Array.isArray(points) || points.length < 3) {
|
|
19447
|
+
return (points || []).map((p) => ({ x: p.x, y: p.y }));
|
|
19423
19448
|
}
|
|
19424
|
-
|
|
19425
|
-
|
|
19426
|
-
|
|
19427
|
-
if (
|
|
19428
|
-
return
|
|
19449
|
+
const pts = points.filter(
|
|
19450
|
+
(p) => p && Number.isFinite(p.x) && Number.isFinite(p.y)
|
|
19451
|
+
);
|
|
19452
|
+
if (pts.length < 3) {
|
|
19453
|
+
return pts.map((p) => ({ ...p }));
|
|
19429
19454
|
}
|
|
19430
|
-
const pts = points.map((p) => ({
|
|
19431
|
-
x: p.x,
|
|
19432
|
-
y: p.y
|
|
19433
|
-
}));
|
|
19434
19455
|
const circle = fitCircle2D(pts);
|
|
19435
|
-
if (!circle
|
|
19436
|
-
throw new Error("\u5706\
|
|
19456
|
+
if (!circle) {
|
|
19457
|
+
throw new Error("\u5706\u62DF\u5408\u5931\u8D25");
|
|
19437
19458
|
}
|
|
19438
19459
|
const cx = circle.center.x;
|
|
19439
19460
|
const cy = circle.center.y;
|
|
19440
|
-
const
|
|
19461
|
+
const polar = pts.map((p) => {
|
|
19441
19462
|
const dx = p.x - cx;
|
|
19442
19463
|
const dy = p.y - cy;
|
|
19443
19464
|
let angle = Math.atan2(dy, dx);
|
|
@@ -19447,73 +19468,104 @@ function fitPolyline(points, epsilon3 = 0.01, binCount = 32) {
|
|
|
19447
19468
|
radius: Math.hypot(dx, dy)
|
|
19448
19469
|
};
|
|
19449
19470
|
});
|
|
19450
|
-
|
|
19471
|
+
polar.sort((a, b) => a.angle - b.angle);
|
|
19451
19472
|
let maxGap = -1;
|
|
19452
|
-
let
|
|
19453
|
-
for (let i = 0; i <
|
|
19454
|
-
const next2 = (i + 1) %
|
|
19455
|
-
let gap =
|
|
19473
|
+
let gapIndex = 0;
|
|
19474
|
+
for (let i = 0; i < polar.length; i++) {
|
|
19475
|
+
const next2 = (i + 1) % polar.length;
|
|
19476
|
+
let gap = polar[next2].angle - polar[i].angle;
|
|
19456
19477
|
if (next2 === 0) {
|
|
19457
19478
|
gap += Math.PI * 2;
|
|
19458
19479
|
}
|
|
19459
19480
|
if (gap > maxGap) {
|
|
19460
19481
|
maxGap = gap;
|
|
19461
|
-
|
|
19482
|
+
gapIndex = i;
|
|
19462
19483
|
}
|
|
19463
19484
|
}
|
|
19464
|
-
const
|
|
19465
|
-
let
|
|
19466
|
-
|
|
19467
|
-
|
|
19468
|
-
|
|
19469
|
-
let angle = p.angle;
|
|
19470
|
-
if (i > 0 && angle < previousAngle) {
|
|
19471
|
-
angle += Math.PI * 2;
|
|
19472
|
-
}
|
|
19473
|
-
ordered.push({
|
|
19474
|
-
angle,
|
|
19475
|
-
radius: p.radius
|
|
19476
|
-
});
|
|
19477
|
-
previousAngle = angle;
|
|
19485
|
+
const startIndex = (gapIndex + 1) % polar.length;
|
|
19486
|
+
let startAngle = polar[startIndex].angle;
|
|
19487
|
+
let endAngle = polar[gapIndex].angle;
|
|
19488
|
+
if (endAngle <= startAngle) {
|
|
19489
|
+
endAngle += Math.PI * 2;
|
|
19478
19490
|
}
|
|
19479
|
-
const
|
|
19480
|
-
const maxAngle = ordered[ordered.length - 1].angle;
|
|
19481
|
-
const angleSpan = maxAngle - minAngle;
|
|
19491
|
+
const angleSpan = endAngle - startAngle;
|
|
19482
19492
|
if (angleSpan < 1e-8) {
|
|
19483
|
-
return
|
|
19493
|
+
return pts;
|
|
19494
|
+
}
|
|
19495
|
+
const radii = polar.map((p) => p.radius);
|
|
19496
|
+
const radiusMedian = medianValue(radii);
|
|
19497
|
+
const deviations = radii.map(
|
|
19498
|
+
(r) => Math.abs(r - radiusMedian)
|
|
19499
|
+
);
|
|
19500
|
+
const radiusMAD = medianValue(deviations);
|
|
19501
|
+
const circularError = radiusMAD / Math.max(radiusMedian, 1e-12);
|
|
19502
|
+
if (circularError < 0.015) {
|
|
19503
|
+
return Array.from({ length: binCount }, (_, i) => {
|
|
19504
|
+
const t = i / (binCount - 1);
|
|
19505
|
+
const angle = startAngle + angleSpan * t;
|
|
19506
|
+
return {
|
|
19507
|
+
x: cx + radiusMedian * Math.cos(angle),
|
|
19508
|
+
y: cy + radiusMedian * Math.sin(angle)
|
|
19509
|
+
};
|
|
19510
|
+
});
|
|
19484
19511
|
}
|
|
19485
19512
|
const bins = Array.from(
|
|
19486
19513
|
{ length: binCount },
|
|
19487
19514
|
() => []
|
|
19488
19515
|
);
|
|
19489
|
-
for (const p of
|
|
19490
|
-
const t = (p.angle
|
|
19516
|
+
for (const p of polar) {
|
|
19517
|
+
const t = (p.angle >= startAngle ? p.angle : p.angle + Math.PI * 2) - startAngle;
|
|
19491
19518
|
const index = Math.min(
|
|
19492
19519
|
binCount - 1,
|
|
19493
|
-
Math.floor(t * binCount)
|
|
19520
|
+
Math.max(0, Math.floor(t / angleSpan * binCount))
|
|
19494
19521
|
);
|
|
19495
|
-
bins[index].push(p);
|
|
19496
|
-
}
|
|
19497
|
-
const centerline = [];
|
|
19498
|
-
for (const bin of bins) {
|
|
19499
|
-
if (bin.length === 0) continue;
|
|
19500
|
-
const angles = bin.map((p) => p.angle);
|
|
19501
|
-
const radii = bin.map((p) => p.radius);
|
|
19502
|
-
const angle = medianValue(angles);
|
|
19503
|
-
const radius = medianValue(radii);
|
|
19504
|
-
centerline.push({
|
|
19505
|
-
x: cx + radius * Math.cos(angle),
|
|
19506
|
-
y: cy + radius * Math.sin(angle)
|
|
19507
|
-
});
|
|
19522
|
+
bins[index].push(p.radius);
|
|
19508
19523
|
}
|
|
19509
|
-
const
|
|
19510
|
-
for (
|
|
19511
|
-
|
|
19512
|
-
|
|
19513
|
-
|
|
19524
|
+
const profile = [];
|
|
19525
|
+
for (let i = 0; i < binCount; i++) {
|
|
19526
|
+
profile.push(
|
|
19527
|
+
bins[i].length ? medianValue(bins[i]) : NaN
|
|
19528
|
+
);
|
|
19529
|
+
}
|
|
19530
|
+
const valid = profile.map((v2, i) => Number.isFinite(v2) ? i : -1).filter((i) => i >= 0);
|
|
19531
|
+
if (valid.length < 3) {
|
|
19532
|
+
return pts;
|
|
19533
|
+
}
|
|
19534
|
+
for (let i = 0; i < profile.length; i++) {
|
|
19535
|
+
if (Number.isFinite(profile[i])) continue;
|
|
19536
|
+
const left = valid.filter((j) => j < i).pop();
|
|
19537
|
+
const right = valid.find((j) => j > i);
|
|
19538
|
+
if (left === void 0) {
|
|
19539
|
+
profile[i] = profile[right];
|
|
19540
|
+
} else if (right === void 0) {
|
|
19541
|
+
profile[i] = profile[left];
|
|
19542
|
+
} else {
|
|
19543
|
+
const t = (i - left) / (right - left);
|
|
19544
|
+
profile[i] = profile[left] * (1 - t) + profile[right] * t;
|
|
19514
19545
|
}
|
|
19515
19546
|
}
|
|
19516
|
-
|
|
19547
|
+
const smooth = profile.map((v2, i) => {
|
|
19548
|
+
let sum2 = 0;
|
|
19549
|
+
let weightSum = 0;
|
|
19550
|
+
for (let j = -2; j <= 2; j++) {
|
|
19551
|
+
const index = Math.max(
|
|
19552
|
+
0,
|
|
19553
|
+
Math.min(binCount - 1, i + j)
|
|
19554
|
+
);
|
|
19555
|
+
const weight = [1, 2, 3, 2, 1][j + 2];
|
|
19556
|
+
sum2 += profile[index] * weight;
|
|
19557
|
+
weightSum += weight;
|
|
19558
|
+
}
|
|
19559
|
+
return v2 + (sum2 / weightSum - v2) * 0.35;
|
|
19560
|
+
});
|
|
19561
|
+
return smooth.map((radius, i) => {
|
|
19562
|
+
const t = i / (binCount - 1);
|
|
19563
|
+
const angle = startAngle + angleSpan * t;
|
|
19564
|
+
return {
|
|
19565
|
+
x: cx + radius * Math.cos(angle),
|
|
19566
|
+
y: cy + radius * Math.sin(angle)
|
|
19567
|
+
};
|
|
19568
|
+
});
|
|
19517
19569
|
}
|
|
19518
19570
|
function medianValue(values) {
|
|
19519
19571
|
if (values.length === 0) return 0;
|
|
@@ -19552,51 +19604,47 @@ function rdp(points, epsilon3) {
|
|
|
19552
19604
|
if (typeof module !== "undefined" && module.exports) {
|
|
19553
19605
|
module.exports = { fitPolyline, rdp };
|
|
19554
19606
|
}
|
|
19555
|
-
function smoothPolyline(vertices, samplesPerSegment = 40) {
|
|
19556
|
-
if (!
|
|
19557
|
-
throw new Error("
|
|
19607
|
+
function smoothPolyline(vertices, samplesPerSegment = 40, rounds = 3) {
|
|
19608
|
+
if (!Array.isArray(vertices)) {
|
|
19609
|
+
throw new Error("vertices \u5FC5\u987B\u4E3A\u6570\u7EC4");
|
|
19610
|
+
}
|
|
19611
|
+
if (!Number.isInteger(rounds) || rounds < 0 || rounds > 8) {
|
|
19612
|
+
throw new Error("rounds \u5FC5\u987B\u4E3A 0~8 \u7684\u6574\u6570");
|
|
19558
19613
|
}
|
|
19559
|
-
if (
|
|
19614
|
+
if (vertices.some(
|
|
19560
19615
|
(p) => !p || !Number.isFinite(p.x) || !Number.isFinite(p.y)
|
|
19561
19616
|
)) {
|
|
19562
19617
|
throw new Error("vertices \u5FC5\u987B\u4E3A\u6709\u6548 XY \u70B9\u6570\u7EC4");
|
|
19563
19618
|
}
|
|
19564
|
-
|
|
19619
|
+
let points = [];
|
|
19565
19620
|
for (const p of vertices) {
|
|
19566
19621
|
const last = points[points.length - 1];
|
|
19567
19622
|
if (!last || Math.hypot(p.x - last.x, p.y - last.y) > 1e-12) {
|
|
19568
19623
|
points.push({ x: p.x, y: p.y });
|
|
19569
19624
|
}
|
|
19570
19625
|
}
|
|
19571
|
-
if (points.length <
|
|
19572
|
-
|
|
19573
|
-
|
|
19574
|
-
|
|
19575
|
-
const
|
|
19576
|
-
|
|
19577
|
-
|
|
19578
|
-
|
|
19579
|
-
|
|
19580
|
-
|
|
19581
|
-
|
|
19582
|
-
|
|
19583
|
-
|
|
19584
|
-
|
|
19585
|
-
|
|
19586
|
-
|
|
19587
|
-
|
|
19588
|
-
continue;
|
|
19589
|
-
}
|
|
19590
|
-
const t = t1 + (t2 - t1) * j / samplesPerSegment;
|
|
19591
|
-
const a1 = blend(p0, p1, t0, t1, t);
|
|
19592
|
-
const a2 = blend(p1, p2, t1, t2, t);
|
|
19593
|
-
const a3 = blend(p2, p3, t2, t3, t);
|
|
19594
|
-
const b1 = blend(a1, a2, t0, t2, t);
|
|
19595
|
-
const b2 = blend(a2, a3, t1, t3, t);
|
|
19596
|
-
result.push(blend(b1, b2, t1, t2, t));
|
|
19626
|
+
if (points.length < 3 || rounds === 0) {
|
|
19627
|
+
return points;
|
|
19628
|
+
}
|
|
19629
|
+
for (let r = 0; r < rounds; r++) {
|
|
19630
|
+
const result = [points[0]];
|
|
19631
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
19632
|
+
const p0 = points[i];
|
|
19633
|
+
const p1 = points[i + 1];
|
|
19634
|
+
const q = {
|
|
19635
|
+
x: p0.x * 0.75 + p1.x * 0.25,
|
|
19636
|
+
y: p0.y * 0.75 + p1.y * 0.25
|
|
19637
|
+
};
|
|
19638
|
+
const r2 = {
|
|
19639
|
+
x: p0.x * 0.25 + p1.x * 0.75,
|
|
19640
|
+
y: p0.y * 0.25 + p1.y * 0.75
|
|
19641
|
+
};
|
|
19642
|
+
result.push(q, r2);
|
|
19597
19643
|
}
|
|
19644
|
+
result.push(points[points.length - 1]);
|
|
19645
|
+
points = result;
|
|
19598
19646
|
}
|
|
19599
|
-
return
|
|
19647
|
+
return points;
|
|
19600
19648
|
}
|
|
19601
19649
|
if (typeof module !== "undefined" && module.exports) {
|
|
19602
19650
|
module.exports.smoothPolyline = smoothPolyline;
|
|
@@ -20734,11 +20782,8 @@ var getArcWallLine = (lines) => {
|
|
|
20734
20782
|
if (line2.start.z < floorZ)
|
|
20735
20783
|
floorZ = line2.start.z;
|
|
20736
20784
|
}
|
|
20737
|
-
const polyline = fitPolyline(pts, 5e-3,
|
|
20738
|
-
const curve = resampleByLength(
|
|
20739
|
-
smoothPolyline(polyline, 200),
|
|
20740
|
-
161
|
|
20741
|
-
);
|
|
20785
|
+
const polyline = fitPolyline(pts, 5e-3, 64);
|
|
20786
|
+
const curve = resampleByLength(polyline, 161);
|
|
20742
20787
|
const threeData = curve.map((p) => new THREE12.Vector3(p.x, p.y, 0));
|
|
20743
20788
|
const points2D = threeData.map(
|
|
20744
20789
|
(p) => new THREE12.Vector2(p.x, p.y)
|