rm-graphical-computing-node 1.0.173 → 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 +251 -229
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -14513,7 +14513,7 @@ var getMergeMeaning = (allProjectionResults, wallLines, wallVerifyType, averageP
|
|
|
14513
14513
|
}
|
|
14514
14514
|
if (
|
|
14515
14515
|
/**array[k].type == 'door frame' || */
|
|
14516
|
-
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"
|
|
14517
14517
|
) {
|
|
14518
14518
|
let tol = array[k].type == "door frame" ? 0.5 : 0.5;
|
|
14519
14519
|
let boxVecK = getObbLongSideDirection(array[k].obb);
|
|
@@ -14661,185 +14661,188 @@ var getMergeMeaning = (allProjectionResults, wallLines, wallVerifyType, averageP
|
|
|
14661
14661
|
}
|
|
14662
14662
|
}
|
|
14663
14663
|
}
|
|
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
|
|
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
|
|
14727
14680
|
});
|
|
14728
|
-
|
|
14729
|
-
|
|
14730
|
-
let
|
|
14731
|
-
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
14736
|
-
const data = {
|
|
14737
|
-
points: newOriginalPoints,
|
|
14738
|
-
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),
|
|
14739
14689
|
h: centerData.h,
|
|
14740
14690
|
minz: centerData.minz,
|
|
14741
14691
|
maxz: centerData.maxz,
|
|
14742
14692
|
center: { x: centerData.x, y: centerData.y, z: centerData.z },
|
|
14743
|
-
|
|
14744
|
-
|
|
14693
|
+
obj_id: array[j].obj_id + `_${h}`,
|
|
14694
|
+
type: array[j].type,
|
|
14695
|
+
averagePz: array[j].averagePz,
|
|
14745
14696
|
obb: null,
|
|
14746
|
-
|
|
14747
|
-
positionArr,
|
|
14748
|
-
isStaircaseBalconyRailing,
|
|
14749
|
-
mapPosition:
|
|
14697
|
+
isDel: false,
|
|
14698
|
+
positionArr: array[j].positionArr,
|
|
14699
|
+
isStaircaseBalconyRailing: false,
|
|
14700
|
+
mapPosition: array[j].averagePz.mapPosition
|
|
14750
14701
|
};
|
|
14751
|
-
|
|
14752
|
-
if (
|
|
14753
|
-
newArray.push(data);
|
|
14754
|
-
add++;
|
|
14702
|
+
cloneA.obb = getObb(cloneA.path, cloneA.center, cloneA.h, (cloneA.maxz + cloneA.minz) / 2);
|
|
14703
|
+
if (cloneA.obb != null) newnewData.push(cloneA);
|
|
14755
14704
|
}
|
|
14756
14705
|
}
|
|
14757
|
-
if (newArray.length != beforeLength) {
|
|
14758
|
-
delArray.add(j);
|
|
14759
|
-
}
|
|
14760
14706
|
}
|
|
14761
|
-
|
|
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 = [];
|
|
14762
14714
|
for (let j = 0; j < newnewData.length; j++) {
|
|
14763
|
-
if (
|
|
14764
|
-
|
|
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
|
+
}
|
|
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
|
+
}
|
|
14765
14768
|
}
|
|
14769
|
+
newnewData.length = 0;
|
|
14770
|
+
newnewData.push(...newArray);
|
|
14766
14771
|
}
|
|
14767
|
-
newnewData.length = 0;
|
|
14768
|
-
newnewData.push(...newArray);
|
|
14769
14772
|
}
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
|
|
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)
|
|
14773
|
+
delData.clear();
|
|
14774
|
+
for (let j = 0; j < newnewData.length; j++) {
|
|
14775
|
+
if (newnewData[j].obb == null || delData.has(j))
|
|
14776
|
+
continue;
|
|
14777
|
+
const cloneData = {
|
|
14778
|
+
...newnewData[j],
|
|
14779
|
+
obb: newnewData[j].obb.clone()
|
|
14780
|
+
};
|
|
14781
|
+
if (cloneData.obb == null)
|
|
14786
14782
|
continue;
|
|
14787
|
-
let
|
|
14788
|
-
|
|
14789
|
-
let
|
|
14790
|
-
let
|
|
14791
|
-
|
|
14792
|
-
polygonJ = setPointsSameZ(polygonJ, 0);
|
|
14793
|
-
let f = getPolygonIntersectionRatio(polygonK, polygonJ);
|
|
14794
|
-
if (boxVecJ.length > 0.2 && boxVecK.length > 0.2 || f > 30) {
|
|
14795
|
-
let isPPPP = isParallel(boxVecJ.direction, boxVecK.direction, tol);
|
|
14796
|
-
if ((!isPPPP || !isPPPP.parallel) && f < 80) {
|
|
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)
|
|
14797
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
|
+
}
|
|
14798
14801
|
}
|
|
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}`);
|
|
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;
|
|
14815
14808
|
}
|
|
14816
|
-
|
|
14817
|
-
|
|
14818
|
-
|
|
14819
|
-
|
|
14820
|
-
|
|
14821
|
-
|
|
14822
|
-
|
|
14823
|
-
|
|
14824
|
-
|
|
14825
|
-
|
|
14826
|
-
|
|
14827
|
-
|
|
14828
|
-
|
|
14829
|
-
|
|
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);
|
|
14830
14837
|
}
|
|
14831
14838
|
}
|
|
14832
|
-
|
|
14833
|
-
|
|
14834
|
-
|
|
14839
|
+
const newData = [];
|
|
14840
|
+
for (let j = 0; j < newnewData.length; j++) {
|
|
14841
|
+
if (!delData.has(j))
|
|
14842
|
+
newData.push(newnewData[j]);
|
|
14835
14843
|
}
|
|
14844
|
+
windowArray.array = newData;
|
|
14836
14845
|
}
|
|
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
14846
|
}
|
|
14844
14847
|
for (let i = 0; i < pcdPointsArr.length; i++) {
|
|
14845
14848
|
const type1 = pcdPointsArr[i].type;
|
|
@@ -19439,32 +19442,23 @@ var getDoorPcdData = (lines, pcdData, needFindOtherDoor = true) => {
|
|
|
19439
19442
|
import * as THREE12 from "three";
|
|
19440
19443
|
|
|
19441
19444
|
// src/utils/arc-tools.js
|
|
19442
|
-
function fitPolyline(points, epsilon3 = 0.01, binCount =
|
|
19443
|
-
if (!Array.isArray(points)) {
|
|
19444
|
-
|
|
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 }));
|
|
19445
19448
|
}
|
|
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 }));
|
|
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 }));
|
|
19456
19454
|
}
|
|
19457
|
-
const pts = points.map((p) => ({
|
|
19458
|
-
x: p.x,
|
|
19459
|
-
y: p.y
|
|
19460
|
-
}));
|
|
19461
19455
|
const circle = fitCircle2D(pts);
|
|
19462
|
-
if (!circle
|
|
19463
|
-
throw new Error("\u5706\
|
|
19456
|
+
if (!circle) {
|
|
19457
|
+
throw new Error("\u5706\u62DF\u5408\u5931\u8D25");
|
|
19464
19458
|
}
|
|
19465
19459
|
const cx = circle.center.x;
|
|
19466
19460
|
const cy = circle.center.y;
|
|
19467
|
-
const
|
|
19461
|
+
const polar = pts.map((p) => {
|
|
19468
19462
|
const dx = p.x - cx;
|
|
19469
19463
|
const dy = p.y - cy;
|
|
19470
19464
|
let angle = Math.atan2(dy, dx);
|
|
@@ -19474,73 +19468,104 @@ function fitPolyline(points, epsilon3 = 0.01, binCount = 32) {
|
|
|
19474
19468
|
radius: Math.hypot(dx, dy)
|
|
19475
19469
|
};
|
|
19476
19470
|
});
|
|
19477
|
-
|
|
19471
|
+
polar.sort((a, b) => a.angle - b.angle);
|
|
19478
19472
|
let maxGap = -1;
|
|
19479
|
-
let
|
|
19480
|
-
for (let i = 0; i <
|
|
19481
|
-
const next2 = (i + 1) %
|
|
19482
|
-
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;
|
|
19483
19477
|
if (next2 === 0) {
|
|
19484
19478
|
gap += Math.PI * 2;
|
|
19485
19479
|
}
|
|
19486
19480
|
if (gap > maxGap) {
|
|
19487
19481
|
maxGap = gap;
|
|
19488
|
-
|
|
19482
|
+
gapIndex = i;
|
|
19489
19483
|
}
|
|
19490
19484
|
}
|
|
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;
|
|
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;
|
|
19505
19490
|
}
|
|
19506
|
-
const
|
|
19507
|
-
const maxAngle = ordered[ordered.length - 1].angle;
|
|
19508
|
-
const angleSpan = maxAngle - minAngle;
|
|
19491
|
+
const angleSpan = endAngle - startAngle;
|
|
19509
19492
|
if (angleSpan < 1e-8) {
|
|
19510
|
-
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
|
+
});
|
|
19511
19511
|
}
|
|
19512
19512
|
const bins = Array.from(
|
|
19513
19513
|
{ length: binCount },
|
|
19514
19514
|
() => []
|
|
19515
19515
|
);
|
|
19516
|
-
for (const p of
|
|
19517
|
-
const t = (p.angle
|
|
19516
|
+
for (const p of polar) {
|
|
19517
|
+
const t = (p.angle >= startAngle ? p.angle : p.angle + Math.PI * 2) - startAngle;
|
|
19518
19518
|
const index = Math.min(
|
|
19519
19519
|
binCount - 1,
|
|
19520
|
-
Math.floor(t * binCount)
|
|
19520
|
+
Math.max(0, Math.floor(t / angleSpan * binCount))
|
|
19521
19521
|
);
|
|
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
|
-
});
|
|
19522
|
+
bins[index].push(p.radius);
|
|
19535
19523
|
}
|
|
19536
|
-
const
|
|
19537
|
-
for (
|
|
19538
|
-
|
|
19539
|
-
|
|
19540
|
-
|
|
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;
|
|
19541
19545
|
}
|
|
19542
19546
|
}
|
|
19543
|
-
|
|
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
|
+
});
|
|
19544
19569
|
}
|
|
19545
19570
|
function medianValue(values) {
|
|
19546
19571
|
if (values.length === 0) return 0;
|
|
@@ -20757,11 +20782,8 @@ var getArcWallLine = (lines) => {
|
|
|
20757
20782
|
if (line2.start.z < floorZ)
|
|
20758
20783
|
floorZ = line2.start.z;
|
|
20759
20784
|
}
|
|
20760
|
-
const polyline = fitPolyline(pts, 5e-3,
|
|
20761
|
-
const curve = resampleByLength(
|
|
20762
|
-
smoothPolyline(polyline, 200, 3),
|
|
20763
|
-
161
|
|
20764
|
-
);
|
|
20785
|
+
const polyline = fitPolyline(pts, 5e-3, 64);
|
|
20786
|
+
const curve = resampleByLength(polyline, 161);
|
|
20765
20787
|
const threeData = curve.map((p) => new THREE12.Vector3(p.x, p.y, 0));
|
|
20766
20788
|
const points2D = threeData.map(
|
|
20767
20789
|
(p) => new THREE12.Vector2(p.x, p.y)
|