rm-graphical-computing-node 1.0.169 → 1.0.171
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 +223 -28
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8716,7 +8716,7 @@ var getBeamLine = async (lines, runDataList, pcdData, lineReader, lineEditor, on
|
|
|
8716
8716
|
let doorEd = new THREE5.Vector3(doorAndDoorFrameDatas[n].doorEndPt.x, doorAndDoorFrameDatas[n].doorEndPt.y, 0);
|
|
8717
8717
|
let beamSt = new THREE5.Vector3(tmpRegion.facePoints[0].x, tmpRegion.facePoints[0].y, 0);
|
|
8718
8718
|
let beamEd = new THREE5.Vector3(tmpRegion.facePoints[1].x, tmpRegion.facePoints[1].y, 0);
|
|
8719
|
-
let bIsTrue = tmpRegion.facePoints[2].z < doorAndDoorFrameDatas[n].maxZ || Math.abs(tmpRegion.facePoints[2].z - doorAndDoorFrameDatas[n].maxZ) < 0.
|
|
8719
|
+
let bIsTrue = tmpRegion.facePoints[2].z < doorAndDoorFrameDatas[n].maxZ || Math.abs(tmpRegion.facePoints[2].z - doorAndDoorFrameDatas[n].maxZ) < 0.4;
|
|
8720
8720
|
let bIsSoTall = Math.abs(tmpRegion.facePoints[2].z - doorAndDoorFrameDatas[n].maxZ) > 0.2;
|
|
8721
8721
|
if (bIsTrue) {
|
|
8722
8722
|
let result = classifySegments(doorSt.clone(), doorEd.clone(), beamSt.clone(), beamEd.clone(), {
|
|
@@ -8772,7 +8772,7 @@ var getBeamLine = async (lines, runDataList, pcdData, lineReader, lineEditor, on
|
|
|
8772
8772
|
let distTmp1 = beamSt.distanceTo(beamEd);
|
|
8773
8773
|
let distTmp2 = doorEd.distanceTo(doorSt);
|
|
8774
8774
|
let tol = doorAndDoorFrameDatas[n].category == "door" ? 0.25 : 0.5;
|
|
8775
|
-
let lenTol = doorAndDoorFrameDatas[n].category == "door" ? 1.
|
|
8775
|
+
let lenTol = doorAndDoorFrameDatas[n].category == "door" ? 1.25 : 1;
|
|
8776
8776
|
if (Math.abs(distTmp1 - result.overlap) < tol || Math.abs(distTmp2 - result.overlap) < tol) {
|
|
8777
8777
|
if (distTmp2 > distTmp1 && Math.abs(distTmp2 - result.overlap) > 0.5 && doorAndDoorFrameDatas[n].category === "door") {
|
|
8778
8778
|
let Line3Tmp = new THREE5.Line3(getPt3(line2.start), getPt3(line2.end));
|
|
@@ -17998,6 +17998,8 @@ var getWindowData = (lines, pcdData, lineReader) => {
|
|
|
17998
17998
|
let beamEd = new THREE10.Vector3(tmpRegion.facePoints[1].x, tmpRegion.facePoints[1].y, 0);
|
|
17999
17999
|
let bIsTrue = true;
|
|
18000
18000
|
let bIsSoTall = Math.abs(tmpRegion.facePoints[2].z - windowDatas[n].maxZ) > 0.2;
|
|
18001
|
+
if (windowDatas[n].maxZ < doorTmpSt.z || Math.abs(windowDatas[n].maxZ - doorTmpSt.z) < 0.3)
|
|
18002
|
+
continue;
|
|
18001
18003
|
if (bIsTrue) {
|
|
18002
18004
|
let result = classifySegments(doorSt.clone(), doorEd.clone(), beamSt.clone(), beamEd.clone(), {
|
|
18003
18005
|
collinearAngleMax: THREE10.MathUtils.degToRad(10),
|
|
@@ -18460,6 +18462,11 @@ var getWindowData = (lines, pcdData, lineReader) => {
|
|
|
18460
18462
|
lines[findDoorIndexs[j]].windowData = savedata2;
|
|
18461
18463
|
}
|
|
18462
18464
|
}
|
|
18465
|
+
for (let i = 0; i < lines.length; i++) {
|
|
18466
|
+
const line2 = lines[i];
|
|
18467
|
+
line2.originalPoints = lineReader.getOriginalPointsById(line2.id);
|
|
18468
|
+
line2.checkResults = lineReader.getLineCheckReultsById(line2.id);
|
|
18469
|
+
}
|
|
18463
18470
|
return { lines, pcdData };
|
|
18464
18471
|
};
|
|
18465
18472
|
var checkWindowAndDoorIsTrue = async (lines, runDataList, collectDataPath, pointCloudCluster = null) => {
|
|
@@ -18924,12 +18931,12 @@ var getWindowPcdData = (lines, pcdData) => {
|
|
|
18924
18931
|
lines.push(newLine2);
|
|
18925
18932
|
if (newLine3.originalPoints.length > 10 && newLine3.length > 0.01)
|
|
18926
18933
|
lines.push(newLine3);
|
|
18927
|
-
pcd.
|
|
18934
|
+
pcd.isPcdFindWindow = true;
|
|
18928
18935
|
line2.isRebuild = true;
|
|
18929
18936
|
} else {
|
|
18930
18937
|
line2.drawWindow.push(windowData);
|
|
18931
18938
|
line2.isWindow = true;
|
|
18932
|
-
pcd.
|
|
18939
|
+
pcd.isPcdFindWindow = true;
|
|
18933
18940
|
}
|
|
18934
18941
|
}
|
|
18935
18942
|
}
|
|
@@ -19577,7 +19584,8 @@ function validateArc(vertices, options = {}) {
|
|
|
19577
19584
|
radialRms: rms / circle.radius <= opts.maxRelativeRms,
|
|
19578
19585
|
radialMax: max2 / circle.radius <= opts.maxRelativeMax,
|
|
19579
19586
|
turning: coarse.turnConsistency >= opts.minTurnConsistency,
|
|
19580
|
-
|
|
19587
|
+
// 有效曲率样本不足时,不用 CV 否决
|
|
19588
|
+
curvature: coarse.validTurnCount < 4 || Number.isFinite(coarse.curvatureCV) && coarse.curvatureCV <= opts.maxCurvatureCV,
|
|
19581
19589
|
sweep: sweepDegrees >= opts.minSweepDegrees && sweepDegrees <= opts.maxSweepDegrees
|
|
19582
19590
|
};
|
|
19583
19591
|
const strictChecks = {
|
|
@@ -19679,6 +19687,7 @@ function curvatureMetrics(points) {
|
|
|
19679
19687
|
const std = abs.length ? Math.sqrt(abs.reduce((s, v2) => s + (v2 - mean) ** 2, 0) / abs.length) : 0;
|
|
19680
19688
|
return {
|
|
19681
19689
|
sampleCount: points.length,
|
|
19690
|
+
validTurnCount: valid.length,
|
|
19682
19691
|
turnConsistency: valid.length ? Math.max(positive, valid.length - positive) / valid.length : 0,
|
|
19683
19692
|
curvatureMean: mean,
|
|
19684
19693
|
curvatureCV: mean > 1e-12 ? std / mean : null
|
|
@@ -19770,7 +19779,7 @@ if (typeof module !== "undefined" && __require.main === module) {
|
|
|
19770
19779
|
}
|
|
19771
19780
|
}
|
|
19772
19781
|
|
|
19773
|
-
// src/utils/
|
|
19782
|
+
// src/utils/detectArcSegmentGroups.mjs
|
|
19774
19783
|
function isFinitePoint(point2) {
|
|
19775
19784
|
return point2 && Number.isFinite(point2.x) && Number.isFinite(point2.y);
|
|
19776
19785
|
}
|
|
@@ -19811,7 +19820,8 @@ function getSegment(line2, index, options) {
|
|
|
19811
19820
|
},
|
|
19812
19821
|
direction,
|
|
19813
19822
|
length: length2,
|
|
19814
|
-
pointSupport
|
|
19823
|
+
pointSupport,
|
|
19824
|
+
originalPoints: points
|
|
19815
19825
|
};
|
|
19816
19826
|
}
|
|
19817
19827
|
function endpointGap(a, b) {
|
|
@@ -19823,11 +19833,7 @@ function endpointGap(a, b) {
|
|
|
19823
19833
|
const dz = Number.isFinite(first.z) && Number.isFinite(second.z) ? first.z - second.z : 0;
|
|
19824
19834
|
gap = Math.min(
|
|
19825
19835
|
gap,
|
|
19826
|
-
Math.hypot(
|
|
19827
|
-
first.x - second.x,
|
|
19828
|
-
first.y - second.y,
|
|
19829
|
-
dz
|
|
19830
|
-
)
|
|
19836
|
+
Math.hypot(first.x - second.x, first.y - second.y, dz)
|
|
19831
19837
|
);
|
|
19832
19838
|
}
|
|
19833
19839
|
}
|
|
@@ -19911,6 +19917,177 @@ function fitCircle(points) {
|
|
|
19911
19917
|
};
|
|
19912
19918
|
return Number.isFinite(circle.radius) ? circle : null;
|
|
19913
19919
|
}
|
|
19920
|
+
function fitOriginalCloudAxis(points, maxSamples = 128) {
|
|
19921
|
+
if (!Array.isArray(points) || points.length < 8) return null;
|
|
19922
|
+
const sampled = [];
|
|
19923
|
+
const count = Math.min(points.length, maxSamples);
|
|
19924
|
+
for (let i = 0; i < count; i++) {
|
|
19925
|
+
const index = count === 1 ? 0 : Math.floor(i * (points.length - 1) / (count - 1));
|
|
19926
|
+
const p = points[index];
|
|
19927
|
+
if (isFinitePoint(p)) {
|
|
19928
|
+
sampled.push({ x: p.x, y: p.y });
|
|
19929
|
+
}
|
|
19930
|
+
}
|
|
19931
|
+
if (sampled.length < 8) return null;
|
|
19932
|
+
const mx = sampled.reduce((sum2, p) => sum2 + p.x, 0) / sampled.length;
|
|
19933
|
+
const my = sampled.reduce((sum2, p) => sum2 + p.y, 0) / sampled.length;
|
|
19934
|
+
let xx = 0, xy = 0, yy = 0;
|
|
19935
|
+
for (const p of sampled) {
|
|
19936
|
+
const x = p.x - mx;
|
|
19937
|
+
const y = p.y - my;
|
|
19938
|
+
xx += x * x;
|
|
19939
|
+
xy += x * y;
|
|
19940
|
+
yy += y * y;
|
|
19941
|
+
}
|
|
19942
|
+
const angle = 0.5 * Math.atan2(2 * xy, xx - yy);
|
|
19943
|
+
const ux = Math.cos(angle);
|
|
19944
|
+
const uy = Math.sin(angle);
|
|
19945
|
+
let minT = Infinity;
|
|
19946
|
+
let maxT = -Infinity;
|
|
19947
|
+
let sumPerp2 = 0;
|
|
19948
|
+
let maxPerp = 0;
|
|
19949
|
+
for (const p of sampled) {
|
|
19950
|
+
const x = p.x - mx;
|
|
19951
|
+
const y = p.y - my;
|
|
19952
|
+
const t = x * ux + y * uy;
|
|
19953
|
+
const d = -uy * x + ux * y;
|
|
19954
|
+
minT = Math.min(minT, t);
|
|
19955
|
+
maxT = Math.max(maxT, t);
|
|
19956
|
+
sumPerp2 += d * d;
|
|
19957
|
+
maxPerp = Math.max(maxPerp, Math.abs(d));
|
|
19958
|
+
}
|
|
19959
|
+
const length2 = maxT - minT;
|
|
19960
|
+
if (!(length2 > 1e-8)) return null;
|
|
19961
|
+
return {
|
|
19962
|
+
center: {
|
|
19963
|
+
x: mx + ux * (minT + maxT) / 2,
|
|
19964
|
+
y: my + uy * (minT + maxT) / 2
|
|
19965
|
+
},
|
|
19966
|
+
direction: { x: ux, y: uy },
|
|
19967
|
+
length: length2,
|
|
19968
|
+
lineRms: Math.sqrt(sumPerp2 / sampled.length),
|
|
19969
|
+
lineMax: maxPerp,
|
|
19970
|
+
sampleCount: sampled.length
|
|
19971
|
+
};
|
|
19972
|
+
}
|
|
19973
|
+
function validateOriginalPointCloud(pathSegments, initialCircle, options) {
|
|
19974
|
+
const cloudSegments = [];
|
|
19975
|
+
const radialResiduals = [];
|
|
19976
|
+
let totalSamples = 0;
|
|
19977
|
+
for (const segment of pathSegments) {
|
|
19978
|
+
const points = segment.originalPoints;
|
|
19979
|
+
if (!Array.isArray(points) || points.length < options.minCloudPoints) {
|
|
19980
|
+
return {
|
|
19981
|
+
available: false,
|
|
19982
|
+
passed: true,
|
|
19983
|
+
reason: "\u539F\u59CB\u70B9\u4E91\u4E0D\u8DB3\uFF0C\u8DF3\u8FC7\u70B9\u4E91\u590D\u6838"
|
|
19984
|
+
};
|
|
19985
|
+
}
|
|
19986
|
+
const axis = fitOriginalCloudAxis(
|
|
19987
|
+
points,
|
|
19988
|
+
options.maxCloudSamplesPerSegment
|
|
19989
|
+
);
|
|
19990
|
+
if (!axis) {
|
|
19991
|
+
return {
|
|
19992
|
+
available: false,
|
|
19993
|
+
passed: false,
|
|
19994
|
+
reason: "\u539F\u59CB\u70B9\u4E91\u65E0\u6CD5\u7A33\u5B9A\u63D0\u53D6\u4E3B\u65B9\u5411"
|
|
19995
|
+
};
|
|
19996
|
+
}
|
|
19997
|
+
const directionAgreement2 = Math.abs(
|
|
19998
|
+
axis.direction.x * segment.direction.x + axis.direction.y * segment.direction.y
|
|
19999
|
+
);
|
|
20000
|
+
if (directionAgreement2 < options.minCloudDirectionAgreement) {
|
|
20001
|
+
return {
|
|
20002
|
+
available: true,
|
|
20003
|
+
passed: false,
|
|
20004
|
+
reason: "\u539F\u59CB\u70B9\u4E91\u65B9\u5411\u4E0E\u7EBF\u6BB5\u65B9\u5411\u4E0D\u4E00\u81F4",
|
|
20005
|
+
directionAgreement: directionAgreement2
|
|
20006
|
+
};
|
|
20007
|
+
}
|
|
20008
|
+
if (axis.lineRms > options.maxCloudLineRms) {
|
|
20009
|
+
return {
|
|
20010
|
+
available: true,
|
|
20011
|
+
passed: false,
|
|
20012
|
+
reason: "\u539F\u59CB\u70B9\u4E91\u504F\u79BB\u76F4\u7EBF\u8FC7\u5927",
|
|
20013
|
+
lineRms: axis.lineRms
|
|
20014
|
+
};
|
|
20015
|
+
}
|
|
20016
|
+
cloudSegments.push({
|
|
20017
|
+
segment,
|
|
20018
|
+
axis,
|
|
20019
|
+
directionAgreement: directionAgreement2
|
|
20020
|
+
});
|
|
20021
|
+
const count = Math.min(
|
|
20022
|
+
points.length,
|
|
20023
|
+
options.maxCloudSamplesPerSegment
|
|
20024
|
+
);
|
|
20025
|
+
for (let i = 0; i < count; i++) {
|
|
20026
|
+
const index = count === 1 ? 0 : Math.floor(i * (points.length - 1) / (count - 1));
|
|
20027
|
+
const point2 = points[index];
|
|
20028
|
+
if (!isFinitePoint(point2)) continue;
|
|
20029
|
+
const residual = Math.hypot(
|
|
20030
|
+
point2.x - initialCircle.center.x,
|
|
20031
|
+
point2.y - initialCircle.center.y
|
|
20032
|
+
) - initialCircle.radius;
|
|
20033
|
+
radialResiduals.push(Math.abs(residual));
|
|
20034
|
+
totalSamples++;
|
|
20035
|
+
}
|
|
20036
|
+
}
|
|
20037
|
+
if (cloudSegments.length !== pathSegments.length || radialResiduals.length < 24) {
|
|
20038
|
+
return {
|
|
20039
|
+
available: false,
|
|
20040
|
+
passed: true,
|
|
20041
|
+
reason: "\u6709\u6548\u539F\u59CB\u70B9\u4E91\u6837\u672C\u4E0D\u8DB3\uFF0C\u8DF3\u8FC7\u70B9\u4E91\u590D\u6838"
|
|
20042
|
+
};
|
|
20043
|
+
}
|
|
20044
|
+
const cloudCenters = cloudSegments.map((item) => item.axis.center);
|
|
20045
|
+
const cloudCircle = fitCircle(cloudCenters);
|
|
20046
|
+
if (!cloudCircle) {
|
|
20047
|
+
return {
|
|
20048
|
+
available: true,
|
|
20049
|
+
passed: false,
|
|
20050
|
+
reason: "\u539F\u59CB\u70B9\u4E91\u4E2D\u5FC3\u65E0\u6CD5\u91CD\u65B0\u62DF\u5408\u5706"
|
|
20051
|
+
};
|
|
20052
|
+
}
|
|
20053
|
+
const centerShift = Math.hypot(
|
|
20054
|
+
cloudCircle.center.x - initialCircle.center.x,
|
|
20055
|
+
cloudCircle.center.y - initialCircle.center.y
|
|
20056
|
+
);
|
|
20057
|
+
const radiusDifference = Math.abs(
|
|
20058
|
+
cloudCircle.radius - initialCircle.radius
|
|
20059
|
+
);
|
|
20060
|
+
const sortedResiduals = radialResiduals.slice().sort((a, b) => a - b);
|
|
20061
|
+
const p95Index = Math.min(
|
|
20062
|
+
sortedResiduals.length - 1,
|
|
20063
|
+
Math.floor((sortedResiduals.length - 1) * 0.95)
|
|
20064
|
+
);
|
|
20065
|
+
const radialRms = Math.sqrt(
|
|
20066
|
+
radialResiduals.reduce((sum2, value) => sum2 + value * value, 0) / radialResiduals.length
|
|
20067
|
+
);
|
|
20068
|
+
const radialP95 = sortedResiduals[p95Index];
|
|
20069
|
+
const radialMax = sortedResiduals[sortedResiduals.length - 1];
|
|
20070
|
+
const meanDirectionAgreement = cloudSegments.reduce(
|
|
20071
|
+
(sum2, item) => sum2 + item.directionAgreement,
|
|
20072
|
+
0
|
|
20073
|
+
) / cloudSegments.length;
|
|
20074
|
+
const passed = centerShift <= options.maxCloudCircleCenterShift && radiusDifference <= options.maxCloudCircleRadiusDifference && radialRms <= options.maxCloudRadialRms && radialP95 <= options.maxCloudRadialP95 && meanDirectionAgreement >= options.minCloudDirectionAgreement;
|
|
20075
|
+
return {
|
|
20076
|
+
available: true,
|
|
20077
|
+
passed,
|
|
20078
|
+
reason: passed ? "\u539F\u59CB\u70B9\u4E91\u590D\u6838\u901A\u8FC7" : "\u539F\u59CB\u70B9\u4E91\u4E0E\u5019\u9009\u5706\u5F27\u4E0D\u4E00\u81F4",
|
|
20079
|
+
sampleCount: totalSamples,
|
|
20080
|
+
center: cloudCircle.center,
|
|
20081
|
+
radius: cloudCircle.radius,
|
|
20082
|
+
centerShift,
|
|
20083
|
+
radiusDifference,
|
|
20084
|
+
radialRms,
|
|
20085
|
+
radialP95,
|
|
20086
|
+
radialMax,
|
|
20087
|
+
meanDirectionAgreement,
|
|
20088
|
+
segmentLineRms: cloudSegments.map((item) => item.axis.lineRms)
|
|
20089
|
+
};
|
|
20090
|
+
}
|
|
19914
20091
|
function evaluatePath(path3, segments, options) {
|
|
19915
20092
|
if (path3.length < options.minSegments) return null;
|
|
19916
20093
|
const pathSegments = path3.map((index) => segments[index]);
|
|
@@ -20045,7 +20222,14 @@ function evaluatePath(path3, segments, options) {
|
|
|
20045
20222
|
maxSweepDegrees: 190,
|
|
20046
20223
|
curvatureSamples: 9
|
|
20047
20224
|
});
|
|
20048
|
-
|
|
20225
|
+
const shapePass = shape.isArcLike || shape.arc?.checks?.radialRms === true && shape.arc?.checks?.radialMax === true && shape.arc?.checks?.turning === true && shape.arc?.checks?.sweep === true && Number.isFinite(shape.arc?.coarse?.curvatureCV) && shape.arc.coarse.curvatureCV <= options.maxAllowedCurvatureCV;
|
|
20226
|
+
if (!shapePass) return null;
|
|
20227
|
+
const cloudValidation = validateOriginalPointCloud(
|
|
20228
|
+
pathSegments,
|
|
20229
|
+
circle,
|
|
20230
|
+
options
|
|
20231
|
+
);
|
|
20232
|
+
if (!cloudValidation.passed) return null;
|
|
20049
20233
|
return {
|
|
20050
20234
|
segmentIndices: pathSegments.map((segment) => segment.index),
|
|
20051
20235
|
center: circle.center,
|
|
@@ -20055,15 +20239,13 @@ function evaluatePath(path3, segments, options) {
|
|
|
20055
20239
|
relativeRms: rms / circle.radius,
|
|
20056
20240
|
radialMax: maxResidual,
|
|
20057
20241
|
turnConsistency,
|
|
20058
|
-
tangentAgreement
|
|
20242
|
+
tangentAgreement,
|
|
20243
|
+
cloudValidation
|
|
20059
20244
|
};
|
|
20060
20245
|
}
|
|
20061
20246
|
function buildAdjacency(segments, lineCount, options) {
|
|
20062
20247
|
const valid = segments.map((segment, index) => segment ? index : -1).filter((index) => index >= 0);
|
|
20063
|
-
const adjacency = Array.from(
|
|
20064
|
-
{ length: lineCount },
|
|
20065
|
-
() => []
|
|
20066
|
-
);
|
|
20248
|
+
const adjacency = Array.from({ length: lineCount }, () => []);
|
|
20067
20249
|
for (let position = 0; position < valid.length; position++) {
|
|
20068
20250
|
const firstIndex = valid[position];
|
|
20069
20251
|
const first = segments[firstIndex];
|
|
@@ -20233,6 +20415,7 @@ function mergeCandidateIntoGroup(candidate, group, segments, options) {
|
|
|
20233
20415
|
group.radialMax = mergedResult.radialMax;
|
|
20234
20416
|
group.turnConsistency = mergedResult.turnConsistency;
|
|
20235
20417
|
group.tangentAgreement = mergedResult.tangentAgreement;
|
|
20418
|
+
group.cloudValidation = mergedResult.cloudValidation;
|
|
20236
20419
|
return true;
|
|
20237
20420
|
}
|
|
20238
20421
|
return false;
|
|
@@ -20242,7 +20425,7 @@ function detectArcSegmentGroups(lines, options = {}) {
|
|
|
20242
20425
|
maxNeighborGap: 0.1,
|
|
20243
20426
|
maxCenterGap: 2.75,
|
|
20244
20427
|
minDirectionAgreement: 0.65,
|
|
20245
|
-
minSegments:
|
|
20428
|
+
minSegments: 3,
|
|
20246
20429
|
maxSegments: 6,
|
|
20247
20430
|
minRadius: 0.3,
|
|
20248
20431
|
maxRadius: 100,
|
|
@@ -20262,9 +20445,20 @@ function detectArcSegmentGroups(lines, options = {}) {
|
|
|
20262
20445
|
minPointLineInlierRatio: 0.9,
|
|
20263
20446
|
minPointSupportRatio: 0.85,
|
|
20264
20447
|
maxPointSamples: 128,
|
|
20448
|
+
// 原始点云二级复核参数。
|
|
20449
|
+
minCloudPoints: 24,
|
|
20450
|
+
maxCloudSamplesPerSegment: 128,
|
|
20451
|
+
maxCloudLineRms: 0.03,
|
|
20452
|
+
minCloudDirectionAgreement: 0.9,
|
|
20453
|
+
maxCloudCircleCenterShift: 0.05,
|
|
20454
|
+
maxCloudCircleRadiusDifference: 0.08,
|
|
20455
|
+
maxCloudRadialRms: 0.04,
|
|
20456
|
+
maxCloudRadialP95: 0.065,
|
|
20457
|
+
// 允许低样本路径的曲率 CV 有一定波动。
|
|
20458
|
+
maxAllowedCurvatureCV: 4,
|
|
20265
20459
|
maxPathEvaluations: 4e5,
|
|
20266
20460
|
maxPathsPerStart: 4e3,
|
|
20267
|
-
//
|
|
20461
|
+
// 合并判断参数。
|
|
20268
20462
|
minMergeOverlapRatio: 0.5,
|
|
20269
20463
|
maxMergeCenterDistance: 0.1,
|
|
20270
20464
|
maxMergeRadiusDifference: 0.08,
|
|
@@ -20273,7 +20467,7 @@ function detectArcSegmentGroups(lines, options = {}) {
|
|
|
20273
20467
|
if (!Array.isArray(lines)) {
|
|
20274
20468
|
throw new Error("lines \u5FC5\u987B\u662F\u6570\u7EC4");
|
|
20275
20469
|
}
|
|
20276
|
-
if (!Number.isFinite(opts.maxNeighborGap) || opts.maxNeighborGap < 0 || !Number.isFinite(opts.maxCenterGap) || opts.maxCenterGap <= 0 || !Number.isFinite(opts.minDirectionAgreement) || opts.minDirectionAgreement < 0 || opts.minDirectionAgreement > 1 || !Number.isFinite(opts.minLineDeviationRatio) || opts.minLineDeviationRatio < 0 || !Number.isFinite(opts.minLineToCircleRmsRatio) || opts.minLineToCircleRmsRatio < 0 || !Number.isFinite(opts.maxPointLineDeviation) || opts.maxPointLineDeviation < 0 || !Number.isFinite(opts.minPointLineInlierRatio) || opts.minPointLineInlierRatio < 0 || opts.minPointLineInlierRatio > 1 || !Number.isFinite(opts.minPointSupportRatio) || opts.minPointSupportRatio < 0 || opts.minPointSupportRatio > 1 || !Number.isInteger(opts.maxPointSamples) || opts.maxPointSamples < 1 || !Number.isInteger(opts.minSegments) || opts.minSegments < 3 || !Number.isInteger(opts.maxSegments) || opts.maxSegments < opts.minSegments || !Number.isInteger(opts.maxPathEvaluations) || opts.maxPathEvaluations < 1 || !Number.isInteger(opts.maxPathsPerStart) || opts.maxPathsPerStart < 1) {
|
|
20470
|
+
if (!Number.isFinite(opts.maxNeighborGap) || opts.maxNeighborGap < 0 || !Number.isFinite(opts.maxCenterGap) || opts.maxCenterGap <= 0 || !Number.isFinite(opts.minDirectionAgreement) || opts.minDirectionAgreement < 0 || opts.minDirectionAgreement > 1 || !Number.isFinite(opts.minLineDeviationRatio) || opts.minLineDeviationRatio < 0 || !Number.isFinite(opts.minLineToCircleRmsRatio) || opts.minLineToCircleRmsRatio < 0 || !Number.isFinite(opts.maxPointLineDeviation) || opts.maxPointLineDeviation < 0 || !Number.isFinite(opts.minPointLineInlierRatio) || opts.minPointLineInlierRatio < 0 || opts.minPointLineInlierRatio > 1 || !Number.isFinite(opts.minPointSupportRatio) || opts.minPointSupportRatio < 0 || opts.minPointSupportRatio > 1 || !Number.isInteger(opts.maxPointSamples) || opts.maxPointSamples < 1 || !Number.isInteger(opts.minCloudPoints) || opts.minCloudPoints < 8 || !Number.isInteger(opts.maxCloudSamplesPerSegment) || opts.maxCloudSamplesPerSegment < 8 || !Number.isFinite(opts.maxCloudLineRms) || opts.maxCloudLineRms < 0 || !Number.isFinite(opts.minCloudDirectionAgreement) || opts.minCloudDirectionAgreement < 0 || opts.minCloudDirectionAgreement > 1 || !Number.isFinite(opts.maxCloudCircleCenterShift) || opts.maxCloudCircleCenterShift < 0 || !Number.isFinite(opts.maxCloudCircleRadiusDifference) || opts.maxCloudCircleRadiusDifference < 0 || !Number.isFinite(opts.maxCloudRadialRms) || opts.maxCloudRadialRms < 0 || !Number.isFinite(opts.maxCloudRadialP95) || opts.maxCloudRadialP95 < 0 || !Number.isFinite(opts.maxAllowedCurvatureCV) || opts.maxAllowedCurvatureCV < 0 || !Number.isInteger(opts.minSegments) || opts.minSegments < 3 || !Number.isInteger(opts.maxSegments) || opts.maxSegments < opts.minSegments || !Number.isInteger(opts.maxPathEvaluations) || opts.maxPathEvaluations < 1 || !Number.isInteger(opts.maxPathsPerStart) || opts.maxPathsPerStart < 1) {
|
|
20277
20471
|
throw new Error("\u5F27\u6BB5\u68C0\u6D4B\u53C2\u6570\u65E0\u6548");
|
|
20278
20472
|
}
|
|
20279
20473
|
const segments = lines.map(
|
|
@@ -20391,10 +20585,10 @@ if (typeof module !== "undefined" && module.exports) {
|
|
|
20391
20585
|
|
|
20392
20586
|
// src/geometry/wallLine.mjs
|
|
20393
20587
|
var getArcWallLine = (lines) => {
|
|
20394
|
-
const arcGroups = detectArcSegmentGroups(lines
|
|
20395
|
-
|
|
20588
|
+
const arcGroups = detectArcSegmentGroups(lines, {
|
|
20589
|
+
minSegments: 3
|
|
20590
|
+
});
|
|
20396
20591
|
const arc = [];
|
|
20397
|
-
const pathArc = [];
|
|
20398
20592
|
let delIndex = [];
|
|
20399
20593
|
for (let i = 0; i < arcGroups.length; i++) {
|
|
20400
20594
|
if (delIndex.includes(i))
|
|
@@ -20461,7 +20655,6 @@ var getArcWallLine = (lines) => {
|
|
|
20461
20655
|
if (!delIndex.includes(i))
|
|
20462
20656
|
mergeIndexs.push(arcGroups[i]);
|
|
20463
20657
|
}
|
|
20464
|
-
console.log(mergeIndexs);
|
|
20465
20658
|
for (let i = 0; i < mergeIndexs.length; i++) {
|
|
20466
20659
|
const acceptedArcSegments = mergeIndexs[i].segmentIndices;
|
|
20467
20660
|
let pts = [];
|
|
@@ -20470,6 +20663,7 @@ var getArcWallLine = (lines) => {
|
|
|
20470
20663
|
for (const index of acceptedArcSegments) {
|
|
20471
20664
|
const line2 = lines[index];
|
|
20472
20665
|
line2.isArc = true;
|
|
20666
|
+
line2.isRebuild = true;
|
|
20473
20667
|
for (let j = 0; j < line2.originalPoints.length; j++)
|
|
20474
20668
|
pts.push(line2.originalPoints[j]);
|
|
20475
20669
|
if (line2.rooftopPz > rooftopPz)
|
|
@@ -20483,7 +20677,6 @@ var getArcWallLine = (lines) => {
|
|
|
20483
20677
|
161
|
|
20484
20678
|
);
|
|
20485
20679
|
const threeData = curve.map((p) => new THREE12.Vector3(p.x, p.y, 0));
|
|
20486
|
-
pathArc.push(threeData);
|
|
20487
20680
|
const points2D = threeData.map(
|
|
20488
20681
|
(p) => new THREE12.Vector2(p.x, p.y)
|
|
20489
20682
|
);
|
|
@@ -20501,12 +20694,14 @@ var getArcWallLine = (lines) => {
|
|
|
20501
20694
|
arc.push({
|
|
20502
20695
|
start: { x: P0.x, y: P0.y, z: floorZ },
|
|
20503
20696
|
end: { x: P3.x, y: P3.y, z: floorZ },
|
|
20504
|
-
|
|
20697
|
+
shape: {
|
|
20505
20698
|
type: "cubic-bezier",
|
|
20506
20699
|
controlPointStart: { x: P1.x, y: P1.y, z: floorZ },
|
|
20507
20700
|
controlPointEnd: { x: P2.x, y: P2.y, z: floorZ }
|
|
20508
20701
|
},
|
|
20509
|
-
rooftopPz
|
|
20702
|
+
rooftopPz,
|
|
20703
|
+
originalPoints: pts,
|
|
20704
|
+
path: threeData
|
|
20510
20705
|
});
|
|
20511
20706
|
}
|
|
20512
20707
|
}
|