rm-graphical-computing-node 1.0.173 → 1.0.175
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 +269 -232
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -14511,10 +14511,7 @@ var getMergeMeaning = (allProjectionResults, wallLines, wallVerifyType, averageP
|
|
|
14511
14511
|
if (cloneData.type == "pipe" && array[k].type == "pipe" && pipeIsVerticalJ != pipeIsVerticalK) {
|
|
14512
14512
|
continue;
|
|
14513
14513
|
}
|
|
14514
|
-
if (
|
|
14515
|
-
/**array[k].type == 'door frame' || */
|
|
14516
|
-
array[k].type == "window" || array[k].type == "metal framing of interior glass partitions" || array[k].type == "pipe"
|
|
14517
|
-
) {
|
|
14514
|
+
if (array[k].type == "door frame" || array[k].type == "window" || array[k].type == "metal framing of interior glass partitions" || array[k].type == "pipe" || array[k].type == "balcony railing") {
|
|
14518
14515
|
let tol = array[k].type == "door frame" ? 0.5 : 0.5;
|
|
14519
14516
|
let boxVecK = getObbLongSideDirection(array[k].obb);
|
|
14520
14517
|
let obbPointsClone = getOBBPoints(cloneData.obb);
|
|
@@ -14661,185 +14658,188 @@ var getMergeMeaning = (allProjectionResults, wallLines, wallVerifyType, averageP
|
|
|
14661
14658
|
}
|
|
14662
14659
|
}
|
|
14663
14660
|
}
|
|
14664
|
-
|
|
14665
|
-
|
|
14666
|
-
const
|
|
14667
|
-
|
|
14668
|
-
|
|
14669
|
-
|
|
14670
|
-
const
|
|
14671
|
-
|
|
14672
|
-
|
|
14673
|
-
|
|
14674
|
-
|
|
14675
|
-
|
|
14676
|
-
|
|
14677
|
-
|
|
14678
|
-
|
|
14679
|
-
|
|
14680
|
-
delData.add(j);
|
|
14681
|
-
for (let h = 0; h < result.faces.length; h++) {
|
|
14682
|
-
const centerData = getCenterAndPointHeight(result.faces[h]);
|
|
14683
|
-
let tmppoints = result.faces[h].map((p) => [p.x, p.y]);
|
|
14684
|
-
let cloneA = {
|
|
14685
|
-
points: result.faces[h],
|
|
14686
|
-
path: computeContour(tmppoints),
|
|
14687
|
-
h: centerData.h,
|
|
14688
|
-
minz: centerData.minz,
|
|
14689
|
-
maxz: centerData.maxz,
|
|
14690
|
-
center: { x: centerData.x, y: centerData.y, z: centerData.z },
|
|
14691
|
-
obj_id: array[j].obj_id + `_${h}`,
|
|
14692
|
-
type: array[j].type,
|
|
14693
|
-
averagePz: array[j].averagePz,
|
|
14694
|
-
obb: null,
|
|
14695
|
-
isDel: false,
|
|
14696
|
-
positionArr: array[j].positionArr,
|
|
14697
|
-
isStaircaseBalconyRailing: false,
|
|
14698
|
-
mapPosition: array[j].averagePz.mapPosition
|
|
14699
|
-
};
|
|
14700
|
-
cloneA.obb = getObb(cloneA.path, cloneA.center, cloneA.h, (cloneA.maxz + cloneA.minz) / 2);
|
|
14701
|
-
if (cloneA.obb != null) newnewData.push(cloneA);
|
|
14702
|
-
}
|
|
14703
|
-
}
|
|
14704
|
-
}
|
|
14705
|
-
for (let j = 0; j < array.length; j++) {
|
|
14706
|
-
if (!delData.has(j))
|
|
14707
|
-
newnewData.push(array[j]);
|
|
14708
|
-
}
|
|
14709
|
-
if (pointCloudCluster != null) {
|
|
14710
|
-
let delArray = /* @__PURE__ */ new Set();
|
|
14711
|
-
let newArray = [];
|
|
14712
|
-
for (let j = 0; j < newnewData.length; j++) {
|
|
14713
|
-
if (delArray.has(j)) continue;
|
|
14714
|
-
let points = newnewData[j].points;
|
|
14715
|
-
let obj_id = newnewData[j].obj_id;
|
|
14716
|
-
let type = newnewData[j].type;
|
|
14717
|
-
let averagePz3 = newnewData[j].averagePz;
|
|
14718
|
-
let positionArr = newnewData[j].positionArr;
|
|
14719
|
-
let isStaircaseBalconyRailing = newnewData[j].isStaircaseBalconyRailing;
|
|
14720
|
-
if (points.length < 50)
|
|
14721
|
-
continue;
|
|
14722
|
-
let clusterResult = pointCloudCluster([points], {
|
|
14723
|
-
tolerance: tolerancePointCloudCluster,
|
|
14724
|
-
minClusterSize: 20,
|
|
14725
|
-
maxClusterSize: 1e7,
|
|
14726
|
-
threadCount: 1
|
|
14661
|
+
let SpecialTreatment = ["window", "balcony railing", "door frame", "door"];
|
|
14662
|
+
for (let i = 0; i < SpecialTreatment.length; i++) {
|
|
14663
|
+
const windowArray = pcdPointsArr.find((item) => item.type === SpecialTreatment[i]);
|
|
14664
|
+
if (windowArray) {
|
|
14665
|
+
const delData = /* @__PURE__ */ new Set();
|
|
14666
|
+
const array = windowArray.array;
|
|
14667
|
+
const newnewData = [];
|
|
14668
|
+
for (let j = 0; j < array.length; j++) {
|
|
14669
|
+
const result = splitLShapePointCloud(array[j].points, {
|
|
14670
|
+
threshold: 0.02,
|
|
14671
|
+
iterations: 2e3,
|
|
14672
|
+
minInliers: 100,
|
|
14673
|
+
sampleSize: 12e3,
|
|
14674
|
+
maxPlanes: 10,
|
|
14675
|
+
minPlaneRatio: 0.03,
|
|
14676
|
+
singlePlaneRatio: 0.9
|
|
14727
14677
|
});
|
|
14728
|
-
|
|
14729
|
-
|
|
14730
|
-
let
|
|
14731
|
-
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
14736
|
-
const data = {
|
|
14737
|
-
points: newOriginalPoints,
|
|
14738
|
-
path: computeContour(pathPoints),
|
|
14678
|
+
if (result.isSplit) {
|
|
14679
|
+
delData.add(j);
|
|
14680
|
+
for (let h = 0; h < result.faces.length; h++) {
|
|
14681
|
+
const centerData = getCenterAndPointHeight(result.faces[h]);
|
|
14682
|
+
let tmppoints = result.faces[h].map((p) => [p.x, p.y]);
|
|
14683
|
+
let cloneA = {
|
|
14684
|
+
points: result.faces[h],
|
|
14685
|
+
path: computeContour(tmppoints),
|
|
14739
14686
|
h: centerData.h,
|
|
14740
14687
|
minz: centerData.minz,
|
|
14741
14688
|
maxz: centerData.maxz,
|
|
14742
14689
|
center: { x: centerData.x, y: centerData.y, z: centerData.z },
|
|
14743
|
-
|
|
14744
|
-
|
|
14690
|
+
obj_id: array[j].obj_id + `_${h}`,
|
|
14691
|
+
type: array[j].type,
|
|
14692
|
+
averagePz: array[j].averagePz,
|
|
14745
14693
|
obb: null,
|
|
14746
|
-
|
|
14747
|
-
positionArr,
|
|
14748
|
-
isStaircaseBalconyRailing,
|
|
14749
|
-
mapPosition:
|
|
14694
|
+
isDel: false,
|
|
14695
|
+
positionArr: array[j].positionArr,
|
|
14696
|
+
isStaircaseBalconyRailing: false,
|
|
14697
|
+
mapPosition: array[j].averagePz.mapPosition
|
|
14750
14698
|
};
|
|
14751
|
-
|
|
14752
|
-
if (
|
|
14753
|
-
newArray.push(data);
|
|
14754
|
-
add++;
|
|
14699
|
+
cloneA.obb = getObb(cloneA.path, cloneA.center, cloneA.h, (cloneA.maxz + cloneA.minz) / 2);
|
|
14700
|
+
if (cloneA.obb != null) newnewData.push(cloneA);
|
|
14755
14701
|
}
|
|
14756
14702
|
}
|
|
14757
|
-
if (newArray.length != beforeLength) {
|
|
14758
|
-
delArray.add(j);
|
|
14759
|
-
}
|
|
14760
14703
|
}
|
|
14761
|
-
|
|
14704
|
+
for (let j = 0; j < array.length; j++) {
|
|
14705
|
+
if (!delData.has(j))
|
|
14706
|
+
newnewData.push(array[j]);
|
|
14707
|
+
}
|
|
14708
|
+
if (pointCloudCluster != null) {
|
|
14709
|
+
let delArray = /* @__PURE__ */ new Set();
|
|
14710
|
+
let newArray = [];
|
|
14762
14711
|
for (let j = 0; j < newnewData.length; j++) {
|
|
14763
|
-
if (
|
|
14764
|
-
|
|
14712
|
+
if (delArray.has(j)) continue;
|
|
14713
|
+
let points = newnewData[j].points;
|
|
14714
|
+
let obj_id = newnewData[j].obj_id;
|
|
14715
|
+
let type = newnewData[j].type;
|
|
14716
|
+
let averagePz3 = newnewData[j].averagePz;
|
|
14717
|
+
let positionArr = newnewData[j].positionArr;
|
|
14718
|
+
let isStaircaseBalconyRailing = newnewData[j].isStaircaseBalconyRailing;
|
|
14719
|
+
if (points.length < 50)
|
|
14720
|
+
continue;
|
|
14721
|
+
let clusterResult = pointCloudCluster([points], {
|
|
14722
|
+
tolerance: tolerancePointCloudCluster,
|
|
14723
|
+
minClusterSize: 20,
|
|
14724
|
+
maxClusterSize: 1e7,
|
|
14725
|
+
threadCount: 1
|
|
14726
|
+
});
|
|
14727
|
+
let beforeLength = newArray.length;
|
|
14728
|
+
if (clusterResult.length > 0 && clusterResult[0].length > 1) {
|
|
14729
|
+
let add = 1;
|
|
14730
|
+
for (const cluster of clusterResult[0]) {
|
|
14731
|
+
if (cluster.length < 50) continue;
|
|
14732
|
+
const newOriginalPoints = cluster.map((i2) => points[i2]);
|
|
14733
|
+
const centerData = getCenterAndPointHeight(newOriginalPoints);
|
|
14734
|
+
let pathPoints = newOriginalPoints.map((p) => [p.x, p.y]);
|
|
14735
|
+
const data = {
|
|
14736
|
+
points: newOriginalPoints,
|
|
14737
|
+
path: computeContour(pathPoints),
|
|
14738
|
+
h: centerData.h,
|
|
14739
|
+
minz: centerData.minz,
|
|
14740
|
+
maxz: centerData.maxz,
|
|
14741
|
+
center: { x: centerData.x, y: centerData.y, z: centerData.z },
|
|
14742
|
+
type,
|
|
14743
|
+
averagePz: averagePz3,
|
|
14744
|
+
obb: null,
|
|
14745
|
+
obj_id: obj_id + `_${add}`,
|
|
14746
|
+
positionArr,
|
|
14747
|
+
isStaircaseBalconyRailing,
|
|
14748
|
+
mapPosition: newnewData[j]?.mapPosition
|
|
14749
|
+
};
|
|
14750
|
+
data.obb = getObb(data.path, data.center, data.h, (data.maxz + data.minz) / 2);
|
|
14751
|
+
if (data.obb == null) continue;
|
|
14752
|
+
newArray.push(data);
|
|
14753
|
+
add++;
|
|
14754
|
+
}
|
|
14755
|
+
}
|
|
14756
|
+
if (newArray.length != beforeLength) {
|
|
14757
|
+
delArray.add(j);
|
|
14758
|
+
}
|
|
14759
|
+
}
|
|
14760
|
+
if (delArray.size > 0) {
|
|
14761
|
+
for (let j = 0; j < newnewData.length; j++) {
|
|
14762
|
+
if (!delArray.has(j)) {
|
|
14763
|
+
newArray.push(newnewData[j]);
|
|
14764
|
+
}
|
|
14765
14765
|
}
|
|
14766
|
+
newnewData.length = 0;
|
|
14767
|
+
newnewData.push(...newArray);
|
|
14766
14768
|
}
|
|
14767
|
-
newnewData.length = 0;
|
|
14768
|
-
newnewData.push(...newArray);
|
|
14769
14769
|
}
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
if (newnewData[j].obb == null || delData.has(j))
|
|
14774
|
-
continue;
|
|
14775
|
-
const cloneData = {
|
|
14776
|
-
...newnewData[j],
|
|
14777
|
-
obb: newnewData[j].obb.clone()
|
|
14778
|
-
};
|
|
14779
|
-
if (cloneData.obb == null)
|
|
14780
|
-
continue;
|
|
14781
|
-
let boxVecJ = null;
|
|
14782
|
-
boxVecJ = getObbLongSideDirection(cloneData.obb);
|
|
14783
|
-
let finMergeObj = false;
|
|
14784
|
-
for (let k = 0; k < newnewData.length; k++) {
|
|
14785
|
-
if (newnewData[k].obb == null || delData.has(k) || j == k)
|
|
14770
|
+
delData.clear();
|
|
14771
|
+
for (let j = 0; j < newnewData.length; j++) {
|
|
14772
|
+
if (newnewData[j].obb == null || delData.has(j))
|
|
14786
14773
|
continue;
|
|
14787
|
-
|
|
14788
|
-
|
|
14789
|
-
|
|
14790
|
-
|
|
14791
|
-
|
|
14792
|
-
|
|
14793
|
-
let
|
|
14794
|
-
|
|
14795
|
-
|
|
14796
|
-
|
|
14774
|
+
const cloneData = {
|
|
14775
|
+
...newnewData[j],
|
|
14776
|
+
obb: newnewData[j].obb.clone()
|
|
14777
|
+
};
|
|
14778
|
+
if (cloneData.obb == null)
|
|
14779
|
+
continue;
|
|
14780
|
+
let boxVecJ = null;
|
|
14781
|
+
boxVecJ = getObbLongSideDirection(cloneData.obb);
|
|
14782
|
+
let finMergeObj = false;
|
|
14783
|
+
for (let k = 0; k < newnewData.length; k++) {
|
|
14784
|
+
if (newnewData[k].obb == null || delData.has(k) || j == k)
|
|
14797
14785
|
continue;
|
|
14786
|
+
let tol = 0.35;
|
|
14787
|
+
let boxVecK = getObbLongSideDirection(newnewData[k].obb);
|
|
14788
|
+
let obbPointsClone = getOBBPoints(cloneData.obb);
|
|
14789
|
+
let polygonK = newnewData[k].path.map((point2) => new THREE8.Vector3(point2[0], point2[1], 0));
|
|
14790
|
+
let polygonJ = [obbPointsClone[0], obbPointsClone[1], obbPointsClone[2], obbPointsClone[3]];
|
|
14791
|
+
polygonJ = setPointsSameZ(polygonJ, 0);
|
|
14792
|
+
let f = getPolygonIntersectionRatio(polygonK, polygonJ);
|
|
14793
|
+
if (boxVecJ.length > 0.2 && boxVecK.length > 0.2 || f > 30) {
|
|
14794
|
+
let isPPPP = isParallel(boxVecJ.direction, boxVecK.direction, tol);
|
|
14795
|
+
if ((!isPPPP || !isPPPP.parallel) && f < 80) {
|
|
14796
|
+
continue;
|
|
14797
|
+
}
|
|
14798
14798
|
}
|
|
14799
|
-
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
|
|
14803
|
-
|
|
14804
|
-
|
|
14805
|
-
isMerge = f2 > 0.8;
|
|
14806
|
-
}
|
|
14807
|
-
if (isMerge) {
|
|
14808
|
-
delData.add(k);
|
|
14809
|
-
let threePoints = [];
|
|
14810
|
-
let threePointsStr = [];
|
|
14811
|
-
for (let m = 0; m < newnewData[k].points.length; m++) {
|
|
14812
|
-
cloneData.points.push(newnewData[k].points[m]);
|
|
14813
|
-
threePoints.push(newnewData[k].points[m]);
|
|
14814
|
-
threePointsStr.push(`${newnewData[k].points[m].x},${newnewData[k].points[m].y},${newnewData[k].points[m].z}`);
|
|
14799
|
+
let isMerge = cloneData.obb.intersectsOBB(newnewData[k].obb);
|
|
14800
|
+
if (!isMerge)
|
|
14801
|
+
isMerge = obbContainsOBB(cloneData.obb, newnewData[k].obb);
|
|
14802
|
+
if (!isMerge) {
|
|
14803
|
+
let f2 = calculateClosePointWithOBB(newnewData[k].points, cloneData.obb, 1);
|
|
14804
|
+
isMerge = f2 > 0.8;
|
|
14815
14805
|
}
|
|
14816
|
-
|
|
14817
|
-
|
|
14818
|
-
|
|
14819
|
-
|
|
14820
|
-
|
|
14821
|
-
|
|
14822
|
-
|
|
14823
|
-
|
|
14824
|
-
|
|
14825
|
-
|
|
14826
|
-
|
|
14827
|
-
|
|
14828
|
-
|
|
14829
|
-
|
|
14806
|
+
if (isMerge) {
|
|
14807
|
+
delData.add(k);
|
|
14808
|
+
let threePoints = [];
|
|
14809
|
+
let threePointsStr = [];
|
|
14810
|
+
for (let m = 0; m < newnewData[k].points.length; m++) {
|
|
14811
|
+
cloneData.points.push(newnewData[k].points[m]);
|
|
14812
|
+
threePoints.push(newnewData[k].points[m]);
|
|
14813
|
+
threePointsStr.push(`${newnewData[k].points[m].x},${newnewData[k].points[m].y},${newnewData[k].points[m].z}`);
|
|
14814
|
+
}
|
|
14815
|
+
let tmpPoints = cloneData.points.map((p) => [p.x, p.y]);
|
|
14816
|
+
tmpPoints = voxelDownsample2DForContour(tmpPoints, 0.1);
|
|
14817
|
+
cloneData.path = computeContour(tmpPoints);
|
|
14818
|
+
const centerData = getCenterAndPointHeight(cloneData.points);
|
|
14819
|
+
cloneData.h = centerData.h;
|
|
14820
|
+
cloneData.minz = centerData.minz;
|
|
14821
|
+
cloneData.maxz = centerData.maxz;
|
|
14822
|
+
cloneData.center = { x: centerData.x, y: centerData.y, z: centerData.z };
|
|
14823
|
+
let newObb = getObb(cloneData.path, cloneData.center, cloneData.h, (cloneData.maxz + cloneData.minz) / 2);
|
|
14824
|
+
if (newObb != null)
|
|
14825
|
+
cloneData.obb = newObb;
|
|
14826
|
+
boxVecJ = getObbLongSideDirection(cloneData.obb);
|
|
14827
|
+
k = -1;
|
|
14828
|
+
finMergeObj = true;
|
|
14829
|
+
}
|
|
14830
|
+
}
|
|
14831
|
+
if (finMergeObj) {
|
|
14832
|
+
delData.add(j);
|
|
14833
|
+
newnewData.push(cloneData);
|
|
14830
14834
|
}
|
|
14831
14835
|
}
|
|
14832
|
-
|
|
14833
|
-
|
|
14834
|
-
|
|
14836
|
+
const newData = [];
|
|
14837
|
+
for (let j = 0; j < newnewData.length; j++) {
|
|
14838
|
+
if (!delData.has(j))
|
|
14839
|
+
newData.push(newnewData[j]);
|
|
14835
14840
|
}
|
|
14841
|
+
windowArray.array = newData;
|
|
14836
14842
|
}
|
|
14837
|
-
const newData = [];
|
|
14838
|
-
for (let j = 0; j < newnewData.length; j++) {
|
|
14839
|
-
if (!delData.has(j))
|
|
14840
|
-
newData.push(newnewData[j]);
|
|
14841
|
-
}
|
|
14842
|
-
windowArray.array = newData;
|
|
14843
14843
|
}
|
|
14844
14844
|
for (let i = 0; i < pcdPointsArr.length; i++) {
|
|
14845
14845
|
const type1 = pcdPointsArr[i].type;
|
|
@@ -14970,19 +14970,37 @@ var getMergeMeaning = (allProjectionResults, wallLines, wallVerifyType, averageP
|
|
|
14970
14970
|
}
|
|
14971
14971
|
} else if (type1 === "door") {
|
|
14972
14972
|
if (type2 === "window") {
|
|
14973
|
+
const size = new THREE8.Vector3();
|
|
14974
|
+
array2[k].obb.getSize(size);
|
|
14973
14975
|
if (type2 === "window" && containsObbPoints(obb1, array2[k].points)) {
|
|
14976
|
+
if (size.x < 0.2 || size.y < 0.2 || size.z < 0.2) {
|
|
14977
|
+
array2[k].isDel = true;
|
|
14978
|
+
continue;
|
|
14979
|
+
}
|
|
14974
14980
|
array1[e].isDel = true;
|
|
14975
14981
|
break;
|
|
14976
14982
|
}
|
|
14977
14983
|
if (type2 === "window" && containsObbPoints(obb2, array1[e].points)) {
|
|
14984
|
+
if (size.x < 0.2 || size.y < 0.2 || size.z < 0.2) {
|
|
14985
|
+
array2[k].isDel = true;
|
|
14986
|
+
continue;
|
|
14987
|
+
}
|
|
14978
14988
|
array1[e].isDel = true;
|
|
14979
14989
|
break;
|
|
14980
14990
|
}
|
|
14981
14991
|
if (type2 === "window sill" && containsObbPoints(obb1, array2[k].points)) {
|
|
14992
|
+
if (size.x < 0.2 || size.y < 0.2 || size.z < 0.2) {
|
|
14993
|
+
array2[k].isDel = true;
|
|
14994
|
+
continue;
|
|
14995
|
+
}
|
|
14982
14996
|
array1[e].isDel = true;
|
|
14983
14997
|
break;
|
|
14984
14998
|
}
|
|
14985
14999
|
if (type2 === "window sill" && containsObbPoints(obb2, array1[e].points)) {
|
|
15000
|
+
if (size.x < 0.2 || size.y < 0.2 || size.z < 0.2) {
|
|
15001
|
+
array2[k].isDel = true;
|
|
15002
|
+
continue;
|
|
15003
|
+
}
|
|
14986
15004
|
array1[e].isDel = true;
|
|
14987
15005
|
break;
|
|
14988
15006
|
}
|
|
@@ -19439,32 +19457,23 @@ var getDoorPcdData = (lines, pcdData, needFindOtherDoor = true) => {
|
|
|
19439
19457
|
import * as THREE12 from "three";
|
|
19440
19458
|
|
|
19441
19459
|
// src/utils/arc-tools.js
|
|
19442
|
-
function fitPolyline(points, epsilon3 = 0.01, binCount =
|
|
19443
|
-
if (!Array.isArray(points)) {
|
|
19444
|
-
|
|
19460
|
+
function fitPolyline(points, epsilon3 = 0.01, binCount = 64) {
|
|
19461
|
+
if (!Array.isArray(points) || points.length < 3) {
|
|
19462
|
+
return (points || []).map((p) => ({ x: p.x, y: p.y }));
|
|
19445
19463
|
}
|
|
19446
|
-
|
|
19447
|
-
(p) =>
|
|
19448
|
-
)
|
|
19449
|
-
|
|
19450
|
-
|
|
19451
|
-
if (!Number.isFinite(epsilon3) || epsilon3 < 0 || !Number.isInteger(binCount) || binCount < 2) {
|
|
19452
|
-
throw new Error("epsilon \u5FC5\u987B\u975E\u8D1F\uFF0CbinCount \u5FC5\u987B\u4E3A\u5927\u4E8E\u7B49\u4E8E 2 \u7684\u6574\u6570");
|
|
19453
|
-
}
|
|
19454
|
-
if (points.length < 2) {
|
|
19455
|
-
return points.map((p) => ({ x: p.x, y: p.y }));
|
|
19464
|
+
const pts = points.filter(
|
|
19465
|
+
(p) => p && Number.isFinite(p.x) && Number.isFinite(p.y)
|
|
19466
|
+
);
|
|
19467
|
+
if (pts.length < 3) {
|
|
19468
|
+
return pts.map((p) => ({ ...p }));
|
|
19456
19469
|
}
|
|
19457
|
-
const pts = points.map((p) => ({
|
|
19458
|
-
x: p.x,
|
|
19459
|
-
y: p.y
|
|
19460
|
-
}));
|
|
19461
19470
|
const circle = fitCircle2D(pts);
|
|
19462
|
-
if (!circle
|
|
19463
|
-
throw new Error("\u5706\
|
|
19471
|
+
if (!circle) {
|
|
19472
|
+
throw new Error("\u5706\u62DF\u5408\u5931\u8D25");
|
|
19464
19473
|
}
|
|
19465
19474
|
const cx = circle.center.x;
|
|
19466
19475
|
const cy = circle.center.y;
|
|
19467
|
-
const
|
|
19476
|
+
const polar = pts.map((p) => {
|
|
19468
19477
|
const dx = p.x - cx;
|
|
19469
19478
|
const dy = p.y - cy;
|
|
19470
19479
|
let angle = Math.atan2(dy, dx);
|
|
@@ -19474,73 +19483,104 @@ function fitPolyline(points, epsilon3 = 0.01, binCount = 32) {
|
|
|
19474
19483
|
radius: Math.hypot(dx, dy)
|
|
19475
19484
|
};
|
|
19476
19485
|
});
|
|
19477
|
-
|
|
19486
|
+
polar.sort((a, b) => a.angle - b.angle);
|
|
19478
19487
|
let maxGap = -1;
|
|
19479
|
-
let
|
|
19480
|
-
for (let i = 0; i <
|
|
19481
|
-
const next2 = (i + 1) %
|
|
19482
|
-
let gap =
|
|
19488
|
+
let gapIndex = 0;
|
|
19489
|
+
for (let i = 0; i < polar.length; i++) {
|
|
19490
|
+
const next2 = (i + 1) % polar.length;
|
|
19491
|
+
let gap = polar[next2].angle - polar[i].angle;
|
|
19483
19492
|
if (next2 === 0) {
|
|
19484
19493
|
gap += Math.PI * 2;
|
|
19485
19494
|
}
|
|
19486
19495
|
if (gap > maxGap) {
|
|
19487
19496
|
maxGap = gap;
|
|
19488
|
-
|
|
19497
|
+
gapIndex = i;
|
|
19489
19498
|
}
|
|
19490
19499
|
}
|
|
19491
|
-
const
|
|
19492
|
-
let
|
|
19493
|
-
|
|
19494
|
-
|
|
19495
|
-
|
|
19496
|
-
let angle = p.angle;
|
|
19497
|
-
if (i > 0 && angle < previousAngle) {
|
|
19498
|
-
angle += Math.PI * 2;
|
|
19499
|
-
}
|
|
19500
|
-
ordered.push({
|
|
19501
|
-
angle,
|
|
19502
|
-
radius: p.radius
|
|
19503
|
-
});
|
|
19504
|
-
previousAngle = angle;
|
|
19500
|
+
const startIndex = (gapIndex + 1) % polar.length;
|
|
19501
|
+
let startAngle = polar[startIndex].angle;
|
|
19502
|
+
let endAngle = polar[gapIndex].angle;
|
|
19503
|
+
if (endAngle <= startAngle) {
|
|
19504
|
+
endAngle += Math.PI * 2;
|
|
19505
19505
|
}
|
|
19506
|
-
const
|
|
19507
|
-
const maxAngle = ordered[ordered.length - 1].angle;
|
|
19508
|
-
const angleSpan = maxAngle - minAngle;
|
|
19506
|
+
const angleSpan = endAngle - startAngle;
|
|
19509
19507
|
if (angleSpan < 1e-8) {
|
|
19510
|
-
return
|
|
19508
|
+
return pts;
|
|
19509
|
+
}
|
|
19510
|
+
const radii = polar.map((p) => p.radius);
|
|
19511
|
+
const radiusMedian = medianValue(radii);
|
|
19512
|
+
const deviations = radii.map(
|
|
19513
|
+
(r) => Math.abs(r - radiusMedian)
|
|
19514
|
+
);
|
|
19515
|
+
const radiusMAD = medianValue(deviations);
|
|
19516
|
+
const circularError = radiusMAD / Math.max(radiusMedian, 1e-12);
|
|
19517
|
+
if (circularError < 0.015) {
|
|
19518
|
+
return Array.from({ length: binCount }, (_, i) => {
|
|
19519
|
+
const t = i / (binCount - 1);
|
|
19520
|
+
const angle = startAngle + angleSpan * t;
|
|
19521
|
+
return {
|
|
19522
|
+
x: cx + radiusMedian * Math.cos(angle),
|
|
19523
|
+
y: cy + radiusMedian * Math.sin(angle)
|
|
19524
|
+
};
|
|
19525
|
+
});
|
|
19511
19526
|
}
|
|
19512
19527
|
const bins = Array.from(
|
|
19513
19528
|
{ length: binCount },
|
|
19514
19529
|
() => []
|
|
19515
19530
|
);
|
|
19516
|
-
for (const p of
|
|
19517
|
-
const t = (p.angle
|
|
19531
|
+
for (const p of polar) {
|
|
19532
|
+
const t = (p.angle >= startAngle ? p.angle : p.angle + Math.PI * 2) - startAngle;
|
|
19518
19533
|
const index = Math.min(
|
|
19519
19534
|
binCount - 1,
|
|
19520
|
-
Math.floor(t * binCount)
|
|
19535
|
+
Math.max(0, Math.floor(t / angleSpan * binCount))
|
|
19521
19536
|
);
|
|
19522
|
-
bins[index].push(p);
|
|
19523
|
-
}
|
|
19524
|
-
const centerline = [];
|
|
19525
|
-
for (const bin of bins) {
|
|
19526
|
-
if (bin.length === 0) continue;
|
|
19527
|
-
const angles = bin.map((p) => p.angle);
|
|
19528
|
-
const radii = bin.map((p) => p.radius);
|
|
19529
|
-
const angle = medianValue(angles);
|
|
19530
|
-
const radius = medianValue(radii);
|
|
19531
|
-
centerline.push({
|
|
19532
|
-
x: cx + radius * Math.cos(angle),
|
|
19533
|
-
y: cy + radius * Math.sin(angle)
|
|
19534
|
-
});
|
|
19537
|
+
bins[index].push(p.radius);
|
|
19535
19538
|
}
|
|
19536
|
-
const
|
|
19537
|
-
for (
|
|
19538
|
-
|
|
19539
|
-
|
|
19540
|
-
|
|
19539
|
+
const profile = [];
|
|
19540
|
+
for (let i = 0; i < binCount; i++) {
|
|
19541
|
+
profile.push(
|
|
19542
|
+
bins[i].length ? medianValue(bins[i]) : NaN
|
|
19543
|
+
);
|
|
19544
|
+
}
|
|
19545
|
+
const valid = profile.map((v2, i) => Number.isFinite(v2) ? i : -1).filter((i) => i >= 0);
|
|
19546
|
+
if (valid.length < 3) {
|
|
19547
|
+
return pts;
|
|
19548
|
+
}
|
|
19549
|
+
for (let i = 0; i < profile.length; i++) {
|
|
19550
|
+
if (Number.isFinite(profile[i])) continue;
|
|
19551
|
+
const left = valid.filter((j) => j < i).pop();
|
|
19552
|
+
const right = valid.find((j) => j > i);
|
|
19553
|
+
if (left === void 0) {
|
|
19554
|
+
profile[i] = profile[right];
|
|
19555
|
+
} else if (right === void 0) {
|
|
19556
|
+
profile[i] = profile[left];
|
|
19557
|
+
} else {
|
|
19558
|
+
const t = (i - left) / (right - left);
|
|
19559
|
+
profile[i] = profile[left] * (1 - t) + profile[right] * t;
|
|
19541
19560
|
}
|
|
19542
19561
|
}
|
|
19543
|
-
|
|
19562
|
+
const smooth = profile.map((v2, i) => {
|
|
19563
|
+
let sum2 = 0;
|
|
19564
|
+
let weightSum = 0;
|
|
19565
|
+
for (let j = -2; j <= 2; j++) {
|
|
19566
|
+
const index = Math.max(
|
|
19567
|
+
0,
|
|
19568
|
+
Math.min(binCount - 1, i + j)
|
|
19569
|
+
);
|
|
19570
|
+
const weight = [1, 2, 3, 2, 1][j + 2];
|
|
19571
|
+
sum2 += profile[index] * weight;
|
|
19572
|
+
weightSum += weight;
|
|
19573
|
+
}
|
|
19574
|
+
return v2 + (sum2 / weightSum - v2) * 0.35;
|
|
19575
|
+
});
|
|
19576
|
+
return smooth.map((radius, i) => {
|
|
19577
|
+
const t = i / (binCount - 1);
|
|
19578
|
+
const angle = startAngle + angleSpan * t;
|
|
19579
|
+
return {
|
|
19580
|
+
x: cx + radius * Math.cos(angle),
|
|
19581
|
+
y: cy + radius * Math.sin(angle)
|
|
19582
|
+
};
|
|
19583
|
+
});
|
|
19544
19584
|
}
|
|
19545
19585
|
function medianValue(values) {
|
|
19546
19586
|
if (values.length === 0) return 0;
|
|
@@ -20757,11 +20797,8 @@ var getArcWallLine = (lines) => {
|
|
|
20757
20797
|
if (line2.start.z < floorZ)
|
|
20758
20798
|
floorZ = line2.start.z;
|
|
20759
20799
|
}
|
|
20760
|
-
const polyline = fitPolyline(pts, 5e-3,
|
|
20761
|
-
const curve = resampleByLength(
|
|
20762
|
-
smoothPolyline(polyline, 200, 3),
|
|
20763
|
-
161
|
|
20764
|
-
);
|
|
20800
|
+
const polyline = fitPolyline(pts, 5e-3, 64);
|
|
20801
|
+
const curve = resampleByLength(polyline, 161);
|
|
20765
20802
|
const threeData = curve.map((p) => new THREE12.Vector3(p.x, p.y, 0));
|
|
20766
20803
|
const points2D = threeData.map(
|
|
20767
20804
|
(p) => new THREE12.Vector2(p.x, p.y)
|