rm-graphical-computing-node 1.0.56 → 1.0.57
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 +432 -335
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -711,10 +711,10 @@ var require_concaveman = __commonJS({
|
|
|
711
711
|
}
|
|
712
712
|
module.exports = concaveman2;
|
|
713
713
|
module.exports.default = concaveman2;
|
|
714
|
-
function concaveman2(
|
|
714
|
+
function concaveman2(points2, concavity, lengthThreshold) {
|
|
715
715
|
concavity = Math.max(0, concavity === void 0 ? 2 : concavity);
|
|
716
716
|
lengthThreshold = lengthThreshold || 0;
|
|
717
|
-
var hull = fastConvexHull(
|
|
717
|
+
var hull = fastConvexHull(points2);
|
|
718
718
|
var tree = new RBush(16);
|
|
719
719
|
tree.toBBox = function(a2) {
|
|
720
720
|
return {
|
|
@@ -730,7 +730,7 @@ var require_concaveman = __commonJS({
|
|
|
730
730
|
tree.compareMinY = function(a2, b2) {
|
|
731
731
|
return a2[1] - b2[1];
|
|
732
732
|
};
|
|
733
|
-
tree.load(
|
|
733
|
+
tree.load(points2);
|
|
734
734
|
var queue = [];
|
|
735
735
|
for (var i = 0, last; i < hull.length; i++) {
|
|
736
736
|
var p = hull[i];
|
|
@@ -837,13 +837,13 @@ var require_concaveman = __commonJS({
|
|
|
837
837
|
node.maxY = Math.max(p1[1], p2[1]);
|
|
838
838
|
return node;
|
|
839
839
|
}
|
|
840
|
-
function fastConvexHull(
|
|
841
|
-
var left =
|
|
842
|
-
var top =
|
|
843
|
-
var right =
|
|
844
|
-
var bottom =
|
|
845
|
-
for (var i = 0; i <
|
|
846
|
-
var p =
|
|
840
|
+
function fastConvexHull(points2) {
|
|
841
|
+
var left = points2[0];
|
|
842
|
+
var top = points2[0];
|
|
843
|
+
var right = points2[0];
|
|
844
|
+
var bottom = points2[0];
|
|
845
|
+
for (var i = 0; i < points2.length; i++) {
|
|
846
|
+
var p = points2[i];
|
|
847
847
|
if (p[0] < left[0]) left = p;
|
|
848
848
|
if (p[0] > right[0]) right = p;
|
|
849
849
|
if (p[1] < top[1]) top = p;
|
|
@@ -851,8 +851,8 @@ var require_concaveman = __commonJS({
|
|
|
851
851
|
}
|
|
852
852
|
var cull = [left, top, right, bottom];
|
|
853
853
|
var filtered = cull.slice();
|
|
854
|
-
for (i = 0; i <
|
|
855
|
-
if (!pointInPolygon2(
|
|
854
|
+
for (i = 0; i < points2.length; i++) {
|
|
855
|
+
if (!pointInPolygon2(points2[i], cull)) filtered.push(points2[i]);
|
|
856
856
|
}
|
|
857
857
|
return convexHull(filtered);
|
|
858
858
|
}
|
|
@@ -961,21 +961,21 @@ var require_concaveman = __commonJS({
|
|
|
961
961
|
function compareByX(a, b) {
|
|
962
962
|
return a[0] === b[0] ? a[1] - b[1] : a[0] - b[0];
|
|
963
963
|
}
|
|
964
|
-
function convexHull(
|
|
965
|
-
|
|
964
|
+
function convexHull(points2) {
|
|
965
|
+
points2.sort(compareByX);
|
|
966
966
|
var lower = [];
|
|
967
|
-
for (var i = 0; i <
|
|
968
|
-
while (lower.length >= 2 && cross3(lower[lower.length - 2], lower[lower.length - 1],
|
|
967
|
+
for (var i = 0; i < points2.length; i++) {
|
|
968
|
+
while (lower.length >= 2 && cross3(lower[lower.length - 2], lower[lower.length - 1], points2[i]) <= 0) {
|
|
969
969
|
lower.pop();
|
|
970
970
|
}
|
|
971
|
-
lower.push(
|
|
971
|
+
lower.push(points2[i]);
|
|
972
972
|
}
|
|
973
973
|
var upper = [];
|
|
974
|
-
for (var ii =
|
|
975
|
-
while (upper.length >= 2 && cross3(upper[upper.length - 2], upper[upper.length - 1],
|
|
974
|
+
for (var ii = points2.length - 1; ii >= 0; ii--) {
|
|
975
|
+
while (upper.length >= 2 && cross3(upper[upper.length - 2], upper[upper.length - 1], points2[ii]) <= 0) {
|
|
976
976
|
upper.pop();
|
|
977
977
|
}
|
|
978
|
-
upper.push(
|
|
978
|
+
upper.push(points2[ii]);
|
|
979
979
|
}
|
|
980
980
|
upper.pop();
|
|
981
981
|
lower.pop();
|
|
@@ -1322,7 +1322,7 @@ var WallSubdivisionAnalyzer = class {
|
|
|
1322
1322
|
* { projectPlane: plane }
|
|
1323
1323
|
* );
|
|
1324
1324
|
*/
|
|
1325
|
-
analyzePointDistribution(wallGroup,
|
|
1325
|
+
analyzePointDistribution(wallGroup, points2, tolerance = 0.01, options = {}) {
|
|
1326
1326
|
const projectPlane = options.projectPlane || null;
|
|
1327
1327
|
this.results = {
|
|
1328
1328
|
totalSegments: 0,
|
|
@@ -1388,8 +1388,8 @@ var WallSubdivisionAnalyzer = class {
|
|
|
1388
1388
|
plane.setFromCoplanarPoints(p0, p1, p3);
|
|
1389
1389
|
const temp = new Vector33();
|
|
1390
1390
|
const tempProjectedPoint = new Vector33();
|
|
1391
|
-
for (let pointIndex = 0; pointIndex <
|
|
1392
|
-
const rawPoint = new Vector33(
|
|
1391
|
+
for (let pointIndex = 0; pointIndex < points2.length; pointIndex += 3) {
|
|
1392
|
+
const rawPoint = new Vector33(points2[pointIndex], points2[pointIndex + 1], points2[pointIndex + 2]);
|
|
1393
1393
|
const point2 = projectPlane ? projectPlane.projectPoint(rawPoint, tempProjectedPoint) : rawPoint;
|
|
1394
1394
|
const distanceToPlane = Math.abs(plane.distanceToPoint(point2));
|
|
1395
1395
|
if (distanceToPlane > tolerance) {
|
|
@@ -2063,7 +2063,7 @@ var WallSubdivisionAnalyzer2 = class {
|
|
|
2063
2063
|
* { projectPlane: plane }
|
|
2064
2064
|
* );
|
|
2065
2065
|
*/
|
|
2066
|
-
analyzePointDistribution(wallGroup,
|
|
2066
|
+
analyzePointDistribution(wallGroup, points2, tolerance = 0.01, options = {}) {
|
|
2067
2067
|
const projectPlane = options.projectPlane || null;
|
|
2068
2068
|
this.results = {
|
|
2069
2069
|
totalSegments: 0,
|
|
@@ -2129,8 +2129,8 @@ var WallSubdivisionAnalyzer2 = class {
|
|
|
2129
2129
|
plane.setFromCoplanarPoints(p0, p1, p3);
|
|
2130
2130
|
const temp = new Vector35();
|
|
2131
2131
|
const tempProjectedPoint = new Vector35();
|
|
2132
|
-
for (let pointIndex = 0; pointIndex <
|
|
2133
|
-
const rawPoint =
|
|
2132
|
+
for (let pointIndex = 0; pointIndex < points2.length; pointIndex++) {
|
|
2133
|
+
const rawPoint = points2[pointIndex];
|
|
2134
2134
|
const point2 = projectPlane ? projectPlane.projectPoint(rawPoint, tempProjectedPoint) : rawPoint;
|
|
2135
2135
|
const distanceToPlane = Math.abs(plane.distanceToPoint(point2));
|
|
2136
2136
|
if (distanceToPlane > tolerance) {
|
|
@@ -2558,10 +2558,10 @@ import { Vector3 as Vector37 } from "three";
|
|
|
2558
2558
|
var PointsUtils = class {
|
|
2559
2559
|
points = [];
|
|
2560
2560
|
_tempArr = [0, 0, 0];
|
|
2561
|
-
constructor(
|
|
2561
|
+
constructor(points2) {
|
|
2562
2562
|
}
|
|
2563
|
-
initPoints(
|
|
2564
|
-
this.points =
|
|
2563
|
+
initPoints(points2) {
|
|
2564
|
+
this.points = points2;
|
|
2565
2565
|
}
|
|
2566
2566
|
getPointByIndex(index, target) {
|
|
2567
2567
|
const i = index * 3;
|
|
@@ -2584,17 +2584,17 @@ var PointsUtils = class {
|
|
|
2584
2584
|
arr.push(index * 3 + 1);
|
|
2585
2585
|
arr.push(index * 3 + 2);
|
|
2586
2586
|
}
|
|
2587
|
-
pointsToVector3Arr(
|
|
2587
|
+
pointsToVector3Arr(points2) {
|
|
2588
2588
|
const vecArr = [];
|
|
2589
|
-
for (let i = 0; i <
|
|
2590
|
-
vecArr.push(new Vector37(
|
|
2589
|
+
for (let i = 0; i < points2.length / 3; i++) {
|
|
2590
|
+
vecArr.push(new Vector37(points2[i * 3], points2[i * 3 + 1], points2[i * 3 + 2]));
|
|
2591
2591
|
}
|
|
2592
2592
|
return vecArr;
|
|
2593
2593
|
}
|
|
2594
|
-
vector3ArrToPoints(
|
|
2594
|
+
vector3ArrToPoints(points2) {
|
|
2595
2595
|
const arr = [];
|
|
2596
|
-
for (let i = 0; i <
|
|
2597
|
-
arr.push(
|
|
2596
|
+
for (let i = 0; i < points2.length; i++) {
|
|
2597
|
+
arr.push(points2[i].x, points2[i].y, points2[i].z);
|
|
2598
2598
|
}
|
|
2599
2599
|
return arr;
|
|
2600
2600
|
}
|
|
@@ -2717,10 +2717,10 @@ var isParallel = (v1, v2, tolerance = 0.01) => {
|
|
|
2717
2717
|
angle
|
|
2718
2718
|
};
|
|
2719
2719
|
};
|
|
2720
|
-
var getPointCloudData = (
|
|
2720
|
+
var getPointCloudData = (points2, gridWidth, gridHeight, centerPts) => {
|
|
2721
2721
|
if (gridWidth < 1e-4 || gridHeight < 1e-4)
|
|
2722
2722
|
return {};
|
|
2723
|
-
const pts =
|
|
2723
|
+
const pts = points2;
|
|
2724
2724
|
let clonedCenterPts = [];
|
|
2725
2725
|
if (centerPts && centerPts.length) {
|
|
2726
2726
|
clonedCenterPts = centerPts.map((p) => p.clone());
|
|
@@ -3011,27 +3011,27 @@ function closestDistanceBetweenSegments(A, B2, C, D2) {
|
|
|
3011
3011
|
const closest2 = C.clone().add(CD.clone().multiplyScalar(t));
|
|
3012
3012
|
return closest1.distanceTo(closest2);
|
|
3013
3013
|
}
|
|
3014
|
-
var getPointsMinAndMax = (
|
|
3014
|
+
var getPointsMinAndMax = (points2) => {
|
|
3015
3015
|
let minZ = 999999;
|
|
3016
3016
|
let maxZ = -999999;
|
|
3017
3017
|
let minZPt = new THREE3.Vector3();
|
|
3018
3018
|
let maxZPt = new THREE3.Vector3();
|
|
3019
3019
|
let averagePz2 = 0;
|
|
3020
|
-
for (let i = 0; i <
|
|
3021
|
-
if (
|
|
3022
|
-
maxZ =
|
|
3023
|
-
maxZPt.set(
|
|
3020
|
+
for (let i = 0; i < points2.length; i++) {
|
|
3021
|
+
if (points2[i].z > maxZ) {
|
|
3022
|
+
maxZ = points2[i].z;
|
|
3023
|
+
maxZPt.set(points2[i].x, points2[i].y, points2[i].z);
|
|
3024
3024
|
}
|
|
3025
|
-
if (
|
|
3026
|
-
minZ =
|
|
3027
|
-
minZPt.set(
|
|
3025
|
+
if (points2[i].z < minZ) {
|
|
3026
|
+
minZ = points2[i].z;
|
|
3027
|
+
minZPt.set(points2[i].x, points2[i].y, points2[i].z);
|
|
3028
3028
|
}
|
|
3029
|
-
averagePz2 +=
|
|
3029
|
+
averagePz2 += points2[i].z;
|
|
3030
3030
|
}
|
|
3031
|
-
averagePz2 = averagePz2 /
|
|
3031
|
+
averagePz2 = averagePz2 / points2.length;
|
|
3032
3032
|
return { minZ, maxZ, averagePz: averagePz2, minZPt, maxZPt };
|
|
3033
3033
|
};
|
|
3034
|
-
var getProjectedPointOnLine = (lineSt, lineEd,
|
|
3034
|
+
var getProjectedPointOnLine = (lineSt, lineEd, points2) => {
|
|
3035
3035
|
let plane = new THREE3.Plane();
|
|
3036
3036
|
const regionPt1 = new THREE3.Vector3(lineSt.x, lineSt.y, lineSt.z);
|
|
3037
3037
|
const regionPt2 = new THREE3.Vector3(lineEd.x, lineEd.y, lineEd.z);
|
|
@@ -3039,7 +3039,7 @@ var getProjectedPointOnLine = (lineSt, lineEd, points) => {
|
|
|
3039
3039
|
plane.setFromCoplanarPoints(regionPt1, regionPt2, regionPt3);
|
|
3040
3040
|
const projectPoints = [];
|
|
3041
3041
|
const origionProjectPoints = [];
|
|
3042
|
-
|
|
3042
|
+
points2.forEach((point2) => {
|
|
3043
3043
|
const target = new THREE3.Vector3();
|
|
3044
3044
|
plane.projectPoint(point2, target);
|
|
3045
3045
|
origionProjectPoints.push(target.clone());
|
|
@@ -3058,7 +3058,7 @@ var getProjectedPointOnLine = (lineSt, lineEd, points) => {
|
|
|
3058
3058
|
projectPoints.forEach((point2, i) => {
|
|
3059
3059
|
let ptClose = line3Tmp.closestPointToPoint(point2, true, ptTarget);
|
|
3060
3060
|
if (ptClose.distanceTo(point2) < 1e-3) {
|
|
3061
|
-
newOriginalPoints.push(
|
|
3061
|
+
newOriginalPoints.push(points2[i]);
|
|
3062
3062
|
newOnLinePoints.push(origionProjectPoints[i]);
|
|
3063
3063
|
} else {
|
|
3064
3064
|
newProjectPoints.push(point2);
|
|
@@ -3229,15 +3229,15 @@ var isPointOnLine2 = (lineStart, lineEnd, point2, tolerance = 1e-6) => {
|
|
|
3229
3229
|
line2.closestPointToPoint(new THREE3.Vector3(point2.x, point2.y, point2.z), true, closestPoint);
|
|
3230
3230
|
return closestPoint.distanceTo(new THREE3.Vector3(point2.x, point2.y, point2.z)) < tolerance;
|
|
3231
3231
|
};
|
|
3232
|
-
var getFarthestPoints = (
|
|
3232
|
+
var getFarthestPoints = (points2) => {
|
|
3233
3233
|
let maxDist = 0;
|
|
3234
3234
|
let result = [];
|
|
3235
|
-
for (let i = 0; i <
|
|
3236
|
-
for (let j = i + 1; j <
|
|
3237
|
-
const dist3 =
|
|
3235
|
+
for (let i = 0; i < points2.length; i++) {
|
|
3236
|
+
for (let j = i + 1; j < points2.length; j++) {
|
|
3237
|
+
const dist3 = points2[i].distanceTo(points2[j]);
|
|
3238
3238
|
if (dist3 > maxDist) {
|
|
3239
3239
|
maxDist = dist3;
|
|
3240
|
-
result = [
|
|
3240
|
+
result = [points2[i], points2[j]];
|
|
3241
3241
|
}
|
|
3242
3242
|
}
|
|
3243
3243
|
}
|
|
@@ -3252,10 +3252,10 @@ var randomLightHex = () => {
|
|
|
3252
3252
|
const b = Math.floor(Math.random() * 75 + 180).toString(16).padStart(2, "0");
|
|
3253
3253
|
return `#${r}${g}${b}`;
|
|
3254
3254
|
};
|
|
3255
|
-
var uniqueVector3ByTolerance = (
|
|
3255
|
+
var uniqueVector3ByTolerance = (points2, tolerance = 1e-3) => {
|
|
3256
3256
|
const map = /* @__PURE__ */ new Map();
|
|
3257
3257
|
const result = [];
|
|
3258
|
-
for (const p of
|
|
3258
|
+
for (const p of points2) {
|
|
3259
3259
|
const ix = Math.round(p.x / tolerance);
|
|
3260
3260
|
const iy = Math.round(p.y / tolerance);
|
|
3261
3261
|
const iz = Math.round(p.z / tolerance);
|
|
@@ -3278,7 +3278,7 @@ var getOBBPoints = (obb) => {
|
|
|
3278
3278
|
function makePoint(sx, sy, sz) {
|
|
3279
3279
|
return center.clone().addScaledVector(xAxis, sx).addScaledVector(yAxis, sy).addScaledVector(zAxis, sz);
|
|
3280
3280
|
}
|
|
3281
|
-
const
|
|
3281
|
+
const points2 = [
|
|
3282
3282
|
// 下方一圈,局部 Z = -1
|
|
3283
3283
|
makePoint(-1, -1, -1),
|
|
3284
3284
|
makePoint(1, -1, -1),
|
|
@@ -3290,7 +3290,7 @@ var getOBBPoints = (obb) => {
|
|
|
3290
3290
|
makePoint(1, 1, 1),
|
|
3291
3291
|
makePoint(-1, 1, 1)
|
|
3292
3292
|
];
|
|
3293
|
-
return
|
|
3293
|
+
return points2;
|
|
3294
3294
|
};
|
|
3295
3295
|
var createBoxGeometryFromRectPoints = (rectPoints, height) => {
|
|
3296
3296
|
const p0 = rectPoints[0];
|
|
@@ -3318,12 +3318,12 @@ var createBoxGeometryFromRectPoints = (rectPoints, height) => {
|
|
|
3318
3318
|
geometry.computeVertexNormals();
|
|
3319
3319
|
return geometry;
|
|
3320
3320
|
};
|
|
3321
|
-
var getPointSetCentroid = (
|
|
3322
|
-
if (!
|
|
3321
|
+
var getPointSetCentroid = (points2) => {
|
|
3322
|
+
if (!points2 || points2.length === 0) {
|
|
3323
3323
|
return null;
|
|
3324
3324
|
}
|
|
3325
3325
|
const center = new THREE3.Vector3(0, 0, 0);
|
|
3326
|
-
for (const p of
|
|
3326
|
+
for (const p of points2) {
|
|
3327
3327
|
if (Array.isArray(p)) {
|
|
3328
3328
|
center.x += p[0];
|
|
3329
3329
|
center.y += p[1];
|
|
@@ -3334,18 +3334,18 @@ var getPointSetCentroid = (points) => {
|
|
|
3334
3334
|
center.z += p.z;
|
|
3335
3335
|
}
|
|
3336
3336
|
}
|
|
3337
|
-
center.divideScalar(
|
|
3337
|
+
center.divideScalar(points2.length);
|
|
3338
3338
|
return center;
|
|
3339
3339
|
};
|
|
3340
|
-
var calculatePolygonArea = (
|
|
3341
|
-
if (!
|
|
3340
|
+
var calculatePolygonArea = (points2) => {
|
|
3341
|
+
if (!points2 || points2.length < 3) {
|
|
3342
3342
|
return 0;
|
|
3343
3343
|
}
|
|
3344
|
-
let isArray = Array.isArray(
|
|
3344
|
+
let isArray = Array.isArray(points2[0]);
|
|
3345
3345
|
let area2 = 0;
|
|
3346
|
-
for (let i = 0; i <
|
|
3347
|
-
const p1 =
|
|
3348
|
-
const p2 =
|
|
3346
|
+
for (let i = 0; i < points2.length; i++) {
|
|
3347
|
+
const p1 = points2[i];
|
|
3348
|
+
const p2 = points2[(i + 1) % points2.length];
|
|
3349
3349
|
if (isArray) {
|
|
3350
3350
|
area2 += p1[0] * p2[1] - p2[0] * p1[1];
|
|
3351
3351
|
} else {
|
|
@@ -3447,11 +3447,11 @@ function pointToSegmentDistance(p, a, b) {
|
|
|
3447
3447
|
p.y - y
|
|
3448
3448
|
);
|
|
3449
3449
|
}
|
|
3450
|
-
var voxelDownsample2DForContour = (
|
|
3451
|
-
if (!
|
|
3450
|
+
var voxelDownsample2DForContour = (points2, cellSize) => {
|
|
3451
|
+
if (!points2 || points2.length === 0) return [];
|
|
3452
3452
|
const map = /* @__PURE__ */ new Map();
|
|
3453
|
-
for (let i = 0; i <
|
|
3454
|
-
const p =
|
|
3453
|
+
for (let i = 0; i < points2.length; i++) {
|
|
3454
|
+
const p = points2[i];
|
|
3455
3455
|
const x = p[0];
|
|
3456
3456
|
const y = p[1];
|
|
3457
3457
|
const gx = Math.floor(x / cellSize);
|
|
@@ -3506,10 +3506,10 @@ var voxelDownsample2DForContour = (points, cellSize) => {
|
|
|
3506
3506
|
}
|
|
3507
3507
|
return result;
|
|
3508
3508
|
};
|
|
3509
|
-
var setPointsSameZ = (
|
|
3510
|
-
for (let i = 0; i <
|
|
3511
|
-
|
|
3512
|
-
return
|
|
3509
|
+
var setPointsSameZ = (points2, z) => {
|
|
3510
|
+
for (let i = 0; i < points2.length; i++)
|
|
3511
|
+
points2[i].z = z;
|
|
3512
|
+
return points2;
|
|
3513
3513
|
};
|
|
3514
3514
|
|
|
3515
3515
|
// src/utils/updateLine.mjs
|
|
@@ -3618,12 +3618,12 @@ function isPointInRect2D(point2, rectPoints, plane = "xy") {
|
|
|
3618
3618
|
}
|
|
3619
3619
|
return true;
|
|
3620
3620
|
}
|
|
3621
|
-
function getPointSetCentroid2(
|
|
3622
|
-
if (!
|
|
3621
|
+
function getPointSetCentroid2(points2) {
|
|
3622
|
+
if (!points2 || points2.length === 0) {
|
|
3623
3623
|
return null;
|
|
3624
3624
|
}
|
|
3625
3625
|
const center = new THREE4.Vector3(0, 0, 0);
|
|
3626
|
-
for (const p of
|
|
3626
|
+
for (const p of points2) {
|
|
3627
3627
|
if (Array.isArray(p)) {
|
|
3628
3628
|
center.x += p[0];
|
|
3629
3629
|
center.y += p[1];
|
|
@@ -3634,7 +3634,7 @@ function getPointSetCentroid2(points) {
|
|
|
3634
3634
|
center.z += p.z;
|
|
3635
3635
|
}
|
|
3636
3636
|
}
|
|
3637
|
-
center.divideScalar(
|
|
3637
|
+
center.divideScalar(points2.length);
|
|
3638
3638
|
return center;
|
|
3639
3639
|
}
|
|
3640
3640
|
function toVector3(p) {
|
|
@@ -3701,17 +3701,17 @@ function eigenVector2x2(a, b, c) {
|
|
|
3701
3701
|
y: y / len
|
|
3702
3702
|
};
|
|
3703
3703
|
}
|
|
3704
|
-
function getTrendLineEndpoints(
|
|
3704
|
+
function getTrendLineEndpoints(points2, options = {}) {
|
|
3705
3705
|
const {
|
|
3706
3706
|
plane = "xy",
|
|
3707
3707
|
// 0 表示完全取最远两端
|
|
3708
3708
|
// 0.05 表示两端各去掉 5% 离群点
|
|
3709
3709
|
trimRatio = 0
|
|
3710
3710
|
} = options;
|
|
3711
|
-
if (!
|
|
3711
|
+
if (!points2 || points2.length < 2) {
|
|
3712
3712
|
return null;
|
|
3713
3713
|
}
|
|
3714
|
-
const pts =
|
|
3714
|
+
const pts = points2.map((p) => get2D1(p, plane));
|
|
3715
3715
|
let meanX = 0;
|
|
3716
3716
|
let meanY = 0;
|
|
3717
3717
|
let meanUp = 0;
|
|
@@ -5510,7 +5510,7 @@ function splitSegmentsAtIntersections(inputSegments, project, EPS = 1e-6) {
|
|
|
5510
5510
|
const segA = inputSegments[i];
|
|
5511
5511
|
const a1 = project(segA.start);
|
|
5512
5512
|
const a2 = project(segA.end);
|
|
5513
|
-
const
|
|
5513
|
+
const points2 = [
|
|
5514
5514
|
{
|
|
5515
5515
|
t: 0,
|
|
5516
5516
|
point: clonePoint(segA.start)
|
|
@@ -5528,15 +5528,15 @@ function splitSegmentsAtIntersections(inputSegments, project, EPS = 1e-6) {
|
|
|
5528
5528
|
const hit = segmentIntersection(a1, a2, b1, b2, EPS);
|
|
5529
5529
|
if (!hit) continue;
|
|
5530
5530
|
if (hit.t > EPS && hit.t < 1 - EPS) {
|
|
5531
|
-
|
|
5531
|
+
points2.push({
|
|
5532
5532
|
t: hit.t,
|
|
5533
5533
|
point: lerpPoint(segA.start, segA.end, hit.t)
|
|
5534
5534
|
});
|
|
5535
5535
|
}
|
|
5536
5536
|
}
|
|
5537
|
-
|
|
5537
|
+
points2.sort((p1, p2) => p1.t - p2.t);
|
|
5538
5538
|
const uniquePoints = [];
|
|
5539
|
-
for (const p of
|
|
5539
|
+
for (const p of points2) {
|
|
5540
5540
|
if (uniquePoints.length === 0 || Math.abs(p.t - uniquePoints[uniquePoints.length - 1].t) > EPS) {
|
|
5541
5541
|
uniquePoints.push(p);
|
|
5542
5542
|
}
|
|
@@ -5597,11 +5597,11 @@ function dist2(a, b) {
|
|
|
5597
5597
|
const dy = a.y - b.y;
|
|
5598
5598
|
return dx * dx + dy * dy;
|
|
5599
5599
|
}
|
|
5600
|
-
function signedArea(
|
|
5600
|
+
function signedArea(points2) {
|
|
5601
5601
|
let area2 = 0;
|
|
5602
|
-
for (let i = 0; i <
|
|
5603
|
-
const p =
|
|
5604
|
-
const q =
|
|
5602
|
+
for (let i = 0; i < points2.length; i++) {
|
|
5603
|
+
const p = points2[i];
|
|
5604
|
+
const q = points2[(i + 1) % points2.length];
|
|
5605
5605
|
area2 += p.x * q.y - q.x * p.y;
|
|
5606
5606
|
}
|
|
5607
5607
|
return area2 / 2;
|
|
@@ -5629,7 +5629,7 @@ function clonePoint(p) {
|
|
|
5629
5629
|
|
|
5630
5630
|
// src/geometry/colLine.mjs
|
|
5631
5631
|
import * as gfx from "rm-gxf-computing-rusts";
|
|
5632
|
-
var getColLine = (lines, runDataList, collectDataPath, pointCloudCluster = null) => {
|
|
5632
|
+
var getColLine = async (lines, runDataList, collectDataPath, pointCloudCluster = null) => {
|
|
5633
5633
|
if (!lines || lines.length <= 0) return;
|
|
5634
5634
|
let colDatas = {
|
|
5635
5635
|
rectangles: [],
|
|
@@ -5958,8 +5958,105 @@ var getColLine = (lines, runDataList, collectDataPath, pointCloudCluster = null)
|
|
|
5958
5958
|
colDatas.threeEdgeRect.push(colIndexs);
|
|
5959
5959
|
}
|
|
5960
5960
|
}
|
|
5961
|
+
if (colDatas.threeEdgeRect) {
|
|
5962
|
+
let trajectoryObj = {};
|
|
5963
|
+
for (let r = 0; r < runDataList.length; r++) {
|
|
5964
|
+
trajectoryObj[r] = runDataList[r];
|
|
5965
|
+
}
|
|
5966
|
+
let lines2 = [];
|
|
5967
|
+
for (let i = 0; i < colDatas.threeEdgeRect.length; i++) {
|
|
5968
|
+
const data = colDatas.threeEdgeRect[i];
|
|
5969
|
+
const start = data.missingEdge.start;
|
|
5970
|
+
const end = data.missingEdge.end;
|
|
5971
|
+
const direction = new THREE6.Vector3().subVectors(end, start).normalize();
|
|
5972
|
+
let tmpLineData = {
|
|
5973
|
+
checkResults: [],
|
|
5974
|
+
direction,
|
|
5975
|
+
start,
|
|
5976
|
+
end,
|
|
5977
|
+
rooftopPz: data.rooftopPz,
|
|
5978
|
+
originalPoints: [],
|
|
5979
|
+
length: start.distanceTo(end),
|
|
5980
|
+
index: i
|
|
5981
|
+
};
|
|
5982
|
+
getOneLineCheckResults(tmpLineData);
|
|
5983
|
+
if (tmpLineData.checkResults.length != 1) continue;
|
|
5984
|
+
lines2.push(tmpLineData);
|
|
5985
|
+
}
|
|
5986
|
+
await penetratingTask(lines2, trajectoryObj, collectDataPath);
|
|
5987
|
+
for (let i = 0; i < lines2.length; i++) {
|
|
5988
|
+
let len = lines2[i].checkResults[0].allCenterPoints.length;
|
|
5989
|
+
const allCenterPoints = lines2[i].allCenterPoints;
|
|
5990
|
+
let newPoints = [];
|
|
5991
|
+
if (pointCloudCluster != null) {
|
|
5992
|
+
let clusterResult = pointCloudCluster([allCenterPoints], {
|
|
5993
|
+
tolerance: 0.1,
|
|
5994
|
+
minClusterSize: 30,
|
|
5995
|
+
maxClusterSize: 1e7,
|
|
5996
|
+
threadCount: 1
|
|
5997
|
+
});
|
|
5998
|
+
if (clusterResult.length > 0) {
|
|
5999
|
+
let maxNum = 0;
|
|
6000
|
+
for (const cluster of clusterResult[0]) {
|
|
6001
|
+
if (cluster.length < 50) continue;
|
|
6002
|
+
const newOriginalPoints = cluster.map((i2) => points[i2]);
|
|
6003
|
+
if (maxNum < newOriginalPoints.length) {
|
|
6004
|
+
maxNum = newOriginalPoints.length;
|
|
6005
|
+
newPoints = newOriginalPoints;
|
|
6006
|
+
}
|
|
6007
|
+
}
|
|
6008
|
+
} else
|
|
6009
|
+
newPoints = allCenterPoints;
|
|
6010
|
+
} else
|
|
6011
|
+
newPoints = allCenterPoints;
|
|
6012
|
+
let retNum = newPoints.length;
|
|
6013
|
+
let ps = retNum / len * 100;
|
|
6014
|
+
if (ps < 60) {
|
|
6015
|
+
colDatas.threeEdgeRect[lines2[i].index].isDel = true;
|
|
6016
|
+
}
|
|
6017
|
+
}
|
|
6018
|
+
colDatas.threeEdgeRect = colDatas.threeEdgeRect.filter((p) => !p.isDel);
|
|
6019
|
+
}
|
|
5961
6020
|
return colDatas;
|
|
5962
6021
|
};
|
|
6022
|
+
var penetratingTask = async (finalLines, trajectoryObj, collectDataPath, type = "normal", diff = 0.01) => {
|
|
6023
|
+
if (!finalLines.length) return finalLines;
|
|
6024
|
+
const offsets = [];
|
|
6025
|
+
for (let i = 0; i < finalLines[0].checkResults[0].originalVertices.length; i++) {
|
|
6026
|
+
offsets.push(0.01);
|
|
6027
|
+
}
|
|
6028
|
+
finalLines[0].checkResults[0].offsets = offsets;
|
|
6029
|
+
const t = performance.now();
|
|
6030
|
+
const pcdDir = type === "normal" || "res" ? `${collectDataPath}/pcd` : `${collectDataPath}/customData/pcd`;
|
|
6031
|
+
const floatArray = await gfx.squareBackfacePointCloudTestAsync({
|
|
6032
|
+
base: type === "normal" || "res" ? `${collectDataPath}` : `${collectDataPath}/customData`,
|
|
6033
|
+
lines: finalLines,
|
|
6034
|
+
trajectorys: trajectoryObj,
|
|
6035
|
+
pcdDir,
|
|
6036
|
+
distProjection: false,
|
|
6037
|
+
view: false
|
|
6038
|
+
});
|
|
6039
|
+
console.log("\u6D88\u8017\u65F6\u95F4\uFF1A", performance.now() - t, "ms");
|
|
6040
|
+
const data = floatArray;
|
|
6041
|
+
finalLines.forEach((line2) => {
|
|
6042
|
+
line2.allNewPoints = [];
|
|
6043
|
+
line2.allNewSegments = [];
|
|
6044
|
+
});
|
|
6045
|
+
for (let n = 0; n < data.length; n += 4) {
|
|
6046
|
+
const i = data[n];
|
|
6047
|
+
const j = data[n + 1];
|
|
6048
|
+
const k = data[n + 2];
|
|
6049
|
+
const l = data[n + 3];
|
|
6050
|
+
const line2 = finalLines[i];
|
|
6051
|
+
const item = line2.checkResults[j];
|
|
6052
|
+
const vertices = item.originalVertices[k];
|
|
6053
|
+
const center = item.allCenterPoints[k];
|
|
6054
|
+
if (!line2.allCenterPoints)
|
|
6055
|
+
line2.allCenterPoints = [center];
|
|
6056
|
+
else
|
|
6057
|
+
line2.allCenterPoints.push(center);
|
|
6058
|
+
}
|
|
6059
|
+
};
|
|
5963
6060
|
|
|
5964
6061
|
// src/pointCloudProcessing/mergeMeaning.mjs
|
|
5965
6062
|
import * as THREE8 from "three";
|
|
@@ -6338,11 +6435,11 @@ var Delaunator = class _Delaunator {
|
|
|
6338
6435
|
* @param {(p: P) => number} [getY]
|
|
6339
6436
|
*/
|
|
6340
6437
|
// @ts-expect-error TS2322
|
|
6341
|
-
static from(
|
|
6342
|
-
const n =
|
|
6438
|
+
static from(points2, getX = defaultGetX, getY = defaultGetY) {
|
|
6439
|
+
const n = points2.length;
|
|
6343
6440
|
const coords = new Float64Array(n * 2);
|
|
6344
6441
|
for (let i = 0; i < n; i++) {
|
|
6345
|
-
const p =
|
|
6442
|
+
const p = points2[i];
|
|
6346
6443
|
coords[2 * i] = getX(p);
|
|
6347
6444
|
coords[2 * i + 1] = getY(p);
|
|
6348
6445
|
}
|
|
@@ -6819,19 +6916,19 @@ var Voronoi = class {
|
|
|
6819
6916
|
return this;
|
|
6820
6917
|
}
|
|
6821
6918
|
_init() {
|
|
6822
|
-
const { delaunay: { points, hull, triangles }, vectors } = this;
|
|
6919
|
+
const { delaunay: { points: points2, hull, triangles }, vectors } = this;
|
|
6823
6920
|
let bx, by;
|
|
6824
6921
|
const circumcenters = this.circumcenters = this._circumcenters.subarray(0, triangles.length / 3 * 2);
|
|
6825
6922
|
for (let i = 0, j = 0, n = triangles.length, x, y; i < n; i += 3, j += 2) {
|
|
6826
6923
|
const t1 = triangles[i] * 2;
|
|
6827
6924
|
const t2 = triangles[i + 1] * 2;
|
|
6828
6925
|
const t3 = triangles[i + 2] * 2;
|
|
6829
|
-
const x12 =
|
|
6830
|
-
const y12 =
|
|
6831
|
-
const x2 =
|
|
6832
|
-
const y2 =
|
|
6833
|
-
const x3 =
|
|
6834
|
-
const y3 =
|
|
6926
|
+
const x12 = points2[t1];
|
|
6927
|
+
const y12 = points2[t1 + 1];
|
|
6928
|
+
const x2 = points2[t2];
|
|
6929
|
+
const y2 = points2[t2 + 1];
|
|
6930
|
+
const x3 = points2[t3];
|
|
6931
|
+
const y3 = points2[t3 + 1];
|
|
6835
6932
|
const dx = x2 - x12;
|
|
6836
6933
|
const dy = y2 - y12;
|
|
6837
6934
|
const ex = x3 - x12;
|
|
@@ -6840,7 +6937,7 @@ var Voronoi = class {
|
|
|
6840
6937
|
if (Math.abs(ab4) < 1e-9) {
|
|
6841
6938
|
if (bx === void 0) {
|
|
6842
6939
|
bx = by = 0;
|
|
6843
|
-
for (const i2 of hull) bx +=
|
|
6940
|
+
for (const i2 of hull) bx += points2[i2 * 2], by += points2[i2 * 2 + 1];
|
|
6844
6941
|
bx /= hull.length, by /= hull.length;
|
|
6845
6942
|
}
|
|
6846
6943
|
const a = 1e9 * Math.sign((bx - x12) * ey - (by - y12) * ex);
|
|
@@ -6858,13 +6955,13 @@ var Voronoi = class {
|
|
|
6858
6955
|
}
|
|
6859
6956
|
let h = hull[hull.length - 1];
|
|
6860
6957
|
let p0, p1 = h * 4;
|
|
6861
|
-
let x0, x1 =
|
|
6862
|
-
let y0, y1 =
|
|
6958
|
+
let x0, x1 = points2[2 * h];
|
|
6959
|
+
let y0, y1 = points2[2 * h + 1];
|
|
6863
6960
|
vectors.fill(0);
|
|
6864
6961
|
for (let i = 0; i < hull.length; ++i) {
|
|
6865
6962
|
h = hull[i];
|
|
6866
6963
|
p0 = p1, x0 = x1, y0 = y1;
|
|
6867
|
-
p1 = h * 4, x1 =
|
|
6964
|
+
p1 = h * 4, x1 = points2[2 * h], y1 = points2[2 * h + 1];
|
|
6868
6965
|
vectors[p0 + 2] = vectors[p1] = y0 - y1;
|
|
6869
6966
|
vectors[p0 + 3] = vectors[p1 + 1] = x1 - x0;
|
|
6870
6967
|
}
|
|
@@ -6903,21 +7000,21 @@ var Voronoi = class {
|
|
|
6903
7000
|
}
|
|
6904
7001
|
renderCell(i, context) {
|
|
6905
7002
|
const buffer = context == null ? context = new Path() : void 0;
|
|
6906
|
-
const
|
|
6907
|
-
if (
|
|
6908
|
-
context.moveTo(
|
|
6909
|
-
let n =
|
|
6910
|
-
while (
|
|
7003
|
+
const points2 = this._clip(i);
|
|
7004
|
+
if (points2 === null || !points2.length) return;
|
|
7005
|
+
context.moveTo(points2[0], points2[1]);
|
|
7006
|
+
let n = points2.length;
|
|
7007
|
+
while (points2[0] === points2[n - 2] && points2[1] === points2[n - 1] && n > 1) n -= 2;
|
|
6911
7008
|
for (let i2 = 2; i2 < n; i2 += 2) {
|
|
6912
|
-
if (
|
|
6913
|
-
context.lineTo(
|
|
7009
|
+
if (points2[i2] !== points2[i2 - 2] || points2[i2 + 1] !== points2[i2 - 1])
|
|
7010
|
+
context.lineTo(points2[i2], points2[i2 + 1]);
|
|
6914
7011
|
}
|
|
6915
7012
|
context.closePath();
|
|
6916
7013
|
return buffer && buffer.value();
|
|
6917
7014
|
}
|
|
6918
7015
|
*cellPolygons() {
|
|
6919
|
-
const { delaunay: { points } } = this;
|
|
6920
|
-
for (let i = 0, n =
|
|
7016
|
+
const { delaunay: { points: points2 } } = this;
|
|
7017
|
+
for (let i = 0, n = points2.length / 2; i < n; ++i) {
|
|
6921
7018
|
const cell = this.cellPolygon(i);
|
|
6922
7019
|
if (cell) cell.index = i, yield cell;
|
|
6923
7020
|
}
|
|
@@ -6961,35 +7058,35 @@ var Voronoi = class {
|
|
|
6961
7058
|
const { circumcenters, delaunay: { inedges, halfedges, triangles } } = this;
|
|
6962
7059
|
const e0 = inedges[i];
|
|
6963
7060
|
if (e0 === -1) return null;
|
|
6964
|
-
const
|
|
7061
|
+
const points2 = [];
|
|
6965
7062
|
let e = e0;
|
|
6966
7063
|
do {
|
|
6967
7064
|
const t = Math.floor(e / 3);
|
|
6968
|
-
|
|
7065
|
+
points2.push(circumcenters[t * 2], circumcenters[t * 2 + 1]);
|
|
6969
7066
|
e = e % 3 === 2 ? e - 2 : e + 1;
|
|
6970
7067
|
if (triangles[e] !== i) break;
|
|
6971
7068
|
e = halfedges[e];
|
|
6972
7069
|
} while (e !== e0 && e !== -1);
|
|
6973
|
-
return
|
|
7070
|
+
return points2;
|
|
6974
7071
|
}
|
|
6975
7072
|
_clip(i) {
|
|
6976
7073
|
if (i === 0 && this.delaunay.hull.length === 1) {
|
|
6977
7074
|
return [this.xmax, this.ymin, this.xmax, this.ymax, this.xmin, this.ymax, this.xmin, this.ymin];
|
|
6978
7075
|
}
|
|
6979
|
-
const
|
|
6980
|
-
if (
|
|
7076
|
+
const points2 = this._cell(i);
|
|
7077
|
+
if (points2 === null) return null;
|
|
6981
7078
|
const { vectors: V } = this;
|
|
6982
7079
|
const v2 = i * 4;
|
|
6983
|
-
return this._simplify(V[v2] || V[v2 + 1] ? this._clipInfinite(i,
|
|
7080
|
+
return this._simplify(V[v2] || V[v2 + 1] ? this._clipInfinite(i, points2, V[v2], V[v2 + 1], V[v2 + 2], V[v2 + 3]) : this._clipFinite(i, points2));
|
|
6984
7081
|
}
|
|
6985
|
-
_clipFinite(i,
|
|
6986
|
-
const n =
|
|
7082
|
+
_clipFinite(i, points2) {
|
|
7083
|
+
const n = points2.length;
|
|
6987
7084
|
let P = null;
|
|
6988
|
-
let x0, y0, x1 =
|
|
7085
|
+
let x0, y0, x1 = points2[n - 2], y1 = points2[n - 1];
|
|
6989
7086
|
let c0, c1 = this._regioncode(x1, y1);
|
|
6990
7087
|
let e0, e1 = 0;
|
|
6991
7088
|
for (let j = 0; j < n; j += 2) {
|
|
6992
|
-
x0 = x1, y0 = y1, x1 =
|
|
7089
|
+
x0 = x1, y0 = y1, x1 = points2[j], y1 = points2[j + 1];
|
|
6993
7090
|
c0 = c1, c1 = this._regioncode(x1, y1);
|
|
6994
7091
|
if (c0 === 0 && c1 === 0) {
|
|
6995
7092
|
e0 = e1, e1 = 0;
|
|
@@ -7037,8 +7134,8 @@ var Voronoi = class {
|
|
|
7037
7134
|
else x1 = x, y1 = y, c1 = this._regioncode(x1, y1);
|
|
7038
7135
|
}
|
|
7039
7136
|
}
|
|
7040
|
-
_clipInfinite(i,
|
|
7041
|
-
let P = Array.from(
|
|
7137
|
+
_clipInfinite(i, points2, vx0, vy0, vxn, vyn) {
|
|
7138
|
+
let P = Array.from(points2), p;
|
|
7042
7139
|
if (p = this._project(P[0], P[1], vx0, vy0)) P.unshift(p[0], p[1]);
|
|
7043
7140
|
if (p = this._project(P[P.length - 2], P[P.length - 1], vxn, vyn)) P.push(p[0], p[1]);
|
|
7044
7141
|
if (P = this._clipFinite(i, P)) {
|
|
@@ -7152,13 +7249,13 @@ function jitter(x, y, r) {
|
|
|
7152
7249
|
return [x + Math.sin(x + y) * r, y + Math.cos(x - y) * r];
|
|
7153
7250
|
}
|
|
7154
7251
|
var Delaunay = class _Delaunay {
|
|
7155
|
-
static from(
|
|
7156
|
-
return new _Delaunay("length" in
|
|
7252
|
+
static from(points2, fx = pointX, fy = pointY, that) {
|
|
7253
|
+
return new _Delaunay("length" in points2 ? flatArray(points2, fx, fy, that) : Float64Array.from(flatIterable(points2, fx, fy, that)));
|
|
7157
7254
|
}
|
|
7158
|
-
constructor(
|
|
7159
|
-
this._delaunator = new Delaunator(
|
|
7160
|
-
this.inedges = new Int32Array(
|
|
7161
|
-
this._hullIndex = new Int32Array(
|
|
7255
|
+
constructor(points2) {
|
|
7256
|
+
this._delaunator = new Delaunator(points2);
|
|
7257
|
+
this.inedges = new Int32Array(points2.length / 2);
|
|
7258
|
+
this._hullIndex = new Int32Array(points2.length / 2);
|
|
7162
7259
|
this.points = this._delaunator.coords;
|
|
7163
7260
|
this._init();
|
|
7164
7261
|
}
|
|
@@ -7168,16 +7265,16 @@ var Delaunay = class _Delaunay {
|
|
|
7168
7265
|
return this;
|
|
7169
7266
|
}
|
|
7170
7267
|
_init() {
|
|
7171
|
-
const d = this._delaunator,
|
|
7268
|
+
const d = this._delaunator, points2 = this.points;
|
|
7172
7269
|
if (d.hull && d.hull.length > 2 && collinear(d)) {
|
|
7173
|
-
this.collinear = Int32Array.from({ length:
|
|
7174
|
-
const e = this.collinear[0], f = this.collinear[this.collinear.length - 1], bounds = [
|
|
7175
|
-
for (let i = 0, n =
|
|
7176
|
-
const p = jitter(
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
}
|
|
7180
|
-
this._delaunator = new Delaunator(
|
|
7270
|
+
this.collinear = Int32Array.from({ length: points2.length / 2 }, (_, i) => i).sort((i, j) => points2[2 * i] - points2[2 * j] || points2[2 * i + 1] - points2[2 * j + 1]);
|
|
7271
|
+
const e = this.collinear[0], f = this.collinear[this.collinear.length - 1], bounds = [points2[2 * e], points2[2 * e + 1], points2[2 * f], points2[2 * f + 1]], r = 1e-8 * Math.hypot(bounds[3] - bounds[1], bounds[2] - bounds[0]);
|
|
7272
|
+
for (let i = 0, n = points2.length / 2; i < n; ++i) {
|
|
7273
|
+
const p = jitter(points2[2 * i], points2[2 * i + 1], r);
|
|
7274
|
+
points2[2 * i] = p[0];
|
|
7275
|
+
points2[2 * i + 1] = p[1];
|
|
7276
|
+
}
|
|
7277
|
+
this._delaunator = new Delaunator(points2);
|
|
7181
7278
|
} else {
|
|
7182
7279
|
delete this.collinear;
|
|
7183
7280
|
}
|
|
@@ -7239,15 +7336,15 @@ var Delaunay = class _Delaunay {
|
|
|
7239
7336
|
return c;
|
|
7240
7337
|
}
|
|
7241
7338
|
_step(i, x, y) {
|
|
7242
|
-
const { inedges, hull, _hullIndex, halfedges, triangles, points } = this;
|
|
7243
|
-
if (inedges[i] === -1 || !
|
|
7339
|
+
const { inedges, hull, _hullIndex, halfedges, triangles, points: points2 } = this;
|
|
7340
|
+
if (inedges[i] === -1 || !points2.length) return (i + 1) % (points2.length >> 1);
|
|
7244
7341
|
let c = i;
|
|
7245
|
-
let dc = pow(x -
|
|
7342
|
+
let dc = pow(x - points2[i * 2], 2) + pow(y - points2[i * 2 + 1], 2);
|
|
7246
7343
|
const e0 = inedges[i];
|
|
7247
7344
|
let e = e0;
|
|
7248
7345
|
do {
|
|
7249
7346
|
let t = triangles[e];
|
|
7250
|
-
const dt = pow(x -
|
|
7347
|
+
const dt = pow(x - points2[t * 2], 2) + pow(y - points2[t * 2 + 1], 2);
|
|
7251
7348
|
if (dt < dc) dc = dt, c = t;
|
|
7252
7349
|
e = e % 3 === 2 ? e - 2 : e + 1;
|
|
7253
7350
|
if (triangles[e] !== i) break;
|
|
@@ -7255,7 +7352,7 @@ var Delaunay = class _Delaunay {
|
|
|
7255
7352
|
if (e === -1) {
|
|
7256
7353
|
e = hull[(_hullIndex[i] + 1) % hull.length];
|
|
7257
7354
|
if (e !== t) {
|
|
7258
|
-
if (pow(x -
|
|
7355
|
+
if (pow(x - points2[e * 2], 2) + pow(y - points2[e * 2 + 1], 2) < dc) return e;
|
|
7259
7356
|
}
|
|
7260
7357
|
break;
|
|
7261
7358
|
}
|
|
@@ -7264,14 +7361,14 @@ var Delaunay = class _Delaunay {
|
|
|
7264
7361
|
}
|
|
7265
7362
|
render(context) {
|
|
7266
7363
|
const buffer = context == null ? context = new Path() : void 0;
|
|
7267
|
-
const { points, halfedges, triangles } = this;
|
|
7364
|
+
const { points: points2, halfedges, triangles } = this;
|
|
7268
7365
|
for (let i = 0, n = halfedges.length; i < n; ++i) {
|
|
7269
7366
|
const j = halfedges[i];
|
|
7270
7367
|
if (j < i) continue;
|
|
7271
7368
|
const ti = triangles[i] * 2;
|
|
7272
7369
|
const tj = triangles[j] * 2;
|
|
7273
|
-
context.moveTo(
|
|
7274
|
-
context.lineTo(
|
|
7370
|
+
context.moveTo(points2[ti], points2[ti + 1]);
|
|
7371
|
+
context.lineTo(points2[tj], points2[tj + 1]);
|
|
7275
7372
|
}
|
|
7276
7373
|
this.renderHull(context);
|
|
7277
7374
|
return buffer && buffer.value();
|
|
@@ -7280,9 +7377,9 @@ var Delaunay = class _Delaunay {
|
|
|
7280
7377
|
if (r === void 0 && (!context || typeof context.moveTo !== "function")) r = context, context = null;
|
|
7281
7378
|
r = r == void 0 ? 2 : +r;
|
|
7282
7379
|
const buffer = context == null ? context = new Path() : void 0;
|
|
7283
|
-
const { points } = this;
|
|
7284
|
-
for (let i = 0, n =
|
|
7285
|
-
const x =
|
|
7380
|
+
const { points: points2 } = this;
|
|
7381
|
+
for (let i = 0, n = points2.length; i < n; i += 2) {
|
|
7382
|
+
const x = points2[i], y = points2[i + 1];
|
|
7286
7383
|
context.moveTo(x + r, y);
|
|
7287
7384
|
context.arc(x, y, r, 0, tau);
|
|
7288
7385
|
}
|
|
@@ -7290,12 +7387,12 @@ var Delaunay = class _Delaunay {
|
|
|
7290
7387
|
}
|
|
7291
7388
|
renderHull(context) {
|
|
7292
7389
|
const buffer = context == null ? context = new Path() : void 0;
|
|
7293
|
-
const { hull, points } = this;
|
|
7390
|
+
const { hull, points: points2 } = this;
|
|
7294
7391
|
const h = hull[0] * 2, n = hull.length;
|
|
7295
|
-
context.moveTo(
|
|
7392
|
+
context.moveTo(points2[h], points2[h + 1]);
|
|
7296
7393
|
for (let i = 1; i < n; ++i) {
|
|
7297
7394
|
const h2 = 2 * hull[i];
|
|
7298
|
-
context.lineTo(
|
|
7395
|
+
context.lineTo(points2[h2], points2[h2 + 1]);
|
|
7299
7396
|
}
|
|
7300
7397
|
context.closePath();
|
|
7301
7398
|
return buffer && buffer.value();
|
|
@@ -7307,13 +7404,13 @@ var Delaunay = class _Delaunay {
|
|
|
7307
7404
|
}
|
|
7308
7405
|
renderTriangle(i, context) {
|
|
7309
7406
|
const buffer = context == null ? context = new Path() : void 0;
|
|
7310
|
-
const { points, triangles } = this;
|
|
7407
|
+
const { points: points2, triangles } = this;
|
|
7311
7408
|
const t0 = triangles[i *= 3] * 2;
|
|
7312
7409
|
const t1 = triangles[i + 1] * 2;
|
|
7313
7410
|
const t2 = triangles[i + 2] * 2;
|
|
7314
|
-
context.moveTo(
|
|
7315
|
-
context.lineTo(
|
|
7316
|
-
context.lineTo(
|
|
7411
|
+
context.moveTo(points2[t0], points2[t0 + 1]);
|
|
7412
|
+
context.lineTo(points2[t1], points2[t1 + 1]);
|
|
7413
|
+
context.lineTo(points2[t2], points2[t2 + 1]);
|
|
7317
7414
|
context.closePath();
|
|
7318
7415
|
return buffer && buffer.value();
|
|
7319
7416
|
}
|
|
@@ -7329,21 +7426,21 @@ var Delaunay = class _Delaunay {
|
|
|
7329
7426
|
return polygon2.value();
|
|
7330
7427
|
}
|
|
7331
7428
|
};
|
|
7332
|
-
function flatArray(
|
|
7333
|
-
const n =
|
|
7429
|
+
function flatArray(points2, fx, fy, that) {
|
|
7430
|
+
const n = points2.length;
|
|
7334
7431
|
const array = new Float64Array(n * 2);
|
|
7335
7432
|
for (let i = 0; i < n; ++i) {
|
|
7336
|
-
const p =
|
|
7337
|
-
array[i * 2] = fx.call(that, p, i,
|
|
7338
|
-
array[i * 2 + 1] = fy.call(that, p, i,
|
|
7433
|
+
const p = points2[i];
|
|
7434
|
+
array[i * 2] = fx.call(that, p, i, points2);
|
|
7435
|
+
array[i * 2 + 1] = fy.call(that, p, i, points2);
|
|
7339
7436
|
}
|
|
7340
7437
|
return array;
|
|
7341
7438
|
}
|
|
7342
|
-
function* flatIterable(
|
|
7439
|
+
function* flatIterable(points2, fx, fy, that) {
|
|
7343
7440
|
let i = 0;
|
|
7344
|
-
for (const p of
|
|
7345
|
-
yield fx.call(that, p, i,
|
|
7346
|
-
yield fy.call(that, p, i,
|
|
7441
|
+
for (const p of points2) {
|
|
7442
|
+
yield fx.call(that, p, i, points2);
|
|
7443
|
+
yield fy.call(that, p, i, points2);
|
|
7347
7444
|
++i;
|
|
7348
7445
|
}
|
|
7349
7446
|
}
|
|
@@ -7369,12 +7466,12 @@ function addAdj(adj, i, j) {
|
|
|
7369
7466
|
}
|
|
7370
7467
|
arr.push(j);
|
|
7371
7468
|
}
|
|
7372
|
-
function computeContour(
|
|
7373
|
-
if (!
|
|
7469
|
+
function computeContour(points2) {
|
|
7470
|
+
if (!points2 || points2.length < 3) return [];
|
|
7374
7471
|
const seen = /* @__PURE__ */ new Set();
|
|
7375
7472
|
const uniq = [];
|
|
7376
|
-
for (let i = 0; i <
|
|
7377
|
-
const p =
|
|
7473
|
+
for (let i = 0; i < points2.length; i++) {
|
|
7474
|
+
const p = points2[i];
|
|
7378
7475
|
const k = `${p[0]}_${p[1]}`;
|
|
7379
7476
|
if (!seen.has(k)) {
|
|
7380
7477
|
seen.add(k);
|
|
@@ -7830,14 +7927,14 @@ function geomReduce(geojson, callback, initialValue) {
|
|
|
7830
7927
|
var import_concaveman = __toESM(require_concaveman(), 1);
|
|
7831
7928
|
function convex(geojson, options = {}) {
|
|
7832
7929
|
options.concavity = options.concavity || Infinity;
|
|
7833
|
-
const
|
|
7930
|
+
const points2 = [];
|
|
7834
7931
|
coordEach(geojson, (coord) => {
|
|
7835
|
-
|
|
7932
|
+
points2.push([coord[0], coord[1]]);
|
|
7836
7933
|
});
|
|
7837
|
-
if (!
|
|
7934
|
+
if (!points2.length) {
|
|
7838
7935
|
return null;
|
|
7839
7936
|
}
|
|
7840
|
-
const convexHull = (0, import_concaveman.default)(
|
|
7937
|
+
const convexHull = (0, import_concaveman.default)(points2, options.concavity);
|
|
7841
7938
|
if (convexHull.length > 3) {
|
|
7842
7939
|
return polygon([convexHull]);
|
|
7843
7940
|
}
|
|
@@ -8288,9 +8385,9 @@ function distance(p1, p2) {
|
|
|
8288
8385
|
const dy = p2[1] - p1[1];
|
|
8289
8386
|
return Math.sqrt(dx * dx + dy * dy);
|
|
8290
8387
|
}
|
|
8291
|
-
function getCenter(
|
|
8388
|
+
function getCenter(points2) {
|
|
8292
8389
|
let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
|
|
8293
|
-
for (const [x, y] of
|
|
8390
|
+
for (const [x, y] of points2) {
|
|
8294
8391
|
if (x < minX) minX = x;
|
|
8295
8392
|
if (x > maxX) maxX = x;
|
|
8296
8393
|
if (y < minY) minY = y;
|
|
@@ -8437,14 +8534,14 @@ function calculateClosePointRatioWithGrid2(pointsA, pointsB, threshold = 5e-3, m
|
|
|
8437
8534
|
function isNumber2(num) {
|
|
8438
8535
|
return !isNaN(num) && num !== null && !Array.isArray(num);
|
|
8439
8536
|
}
|
|
8440
|
-
function calculateClosePointWithOBB(
|
|
8537
|
+
function calculateClosePointWithOBB(points2, box, maxCalculate = 0.5) {
|
|
8441
8538
|
let closePointsCount = 0;
|
|
8442
8539
|
let calculate = 0;
|
|
8443
|
-
for (const point2 of
|
|
8540
|
+
for (const point2 of points2) {
|
|
8444
8541
|
const inside = box.containsPoint(point2);
|
|
8445
8542
|
if (inside) {
|
|
8446
8543
|
closePointsCount++;
|
|
8447
|
-
calculate = closePointsCount /
|
|
8544
|
+
calculate = closePointsCount / points2.length;
|
|
8448
8545
|
if (calculate > maxCalculate) {
|
|
8449
8546
|
break;
|
|
8450
8547
|
}
|
|
@@ -8480,32 +8577,32 @@ function compareBoxVolume(box1, box2) {
|
|
|
8480
8577
|
return 0;
|
|
8481
8578
|
}
|
|
8482
8579
|
}
|
|
8483
|
-
function containsObbPoints(obb,
|
|
8580
|
+
function containsObbPoints(obb, points2) {
|
|
8484
8581
|
let contains = true;
|
|
8485
|
-
for (let i = 0; i <
|
|
8486
|
-
if (!obb.containsPoint(
|
|
8582
|
+
for (let i = 0; i < points2.length; i++) {
|
|
8583
|
+
if (!obb.containsPoint(points2[i])) {
|
|
8487
8584
|
contains = false;
|
|
8488
8585
|
break;
|
|
8489
8586
|
}
|
|
8490
8587
|
}
|
|
8491
8588
|
return contains;
|
|
8492
8589
|
}
|
|
8493
|
-
function getCenterAndPointHeight(
|
|
8494
|
-
if (
|
|
8590
|
+
function getCenterAndPointHeight(points2) {
|
|
8591
|
+
if (points2.length === 0)
|
|
8495
8592
|
return { x: 0, y: 0, z: 0, h: 0 };
|
|
8496
8593
|
let x = 0;
|
|
8497
8594
|
let y = 0;
|
|
8498
8595
|
let maxz = -Infinity;
|
|
8499
8596
|
let minz = Infinity;
|
|
8500
|
-
for (const p of
|
|
8597
|
+
for (const p of points2) {
|
|
8501
8598
|
x += p.x;
|
|
8502
8599
|
y += p.y;
|
|
8503
8600
|
maxz = Math.max(maxz, p.z);
|
|
8504
8601
|
minz = Math.min(minz, p.z);
|
|
8505
8602
|
}
|
|
8506
8603
|
return {
|
|
8507
|
-
x: x /
|
|
8508
|
-
y: y /
|
|
8604
|
+
x: x / points2.length,
|
|
8605
|
+
y: y / points2.length,
|
|
8509
8606
|
z: 0,
|
|
8510
8607
|
maxz,
|
|
8511
8608
|
minz,
|
|
@@ -8538,19 +8635,19 @@ var drawStaircase = (pcdPointsArr, scene) => {
|
|
|
8538
8635
|
side: THREE8.DoubleSide
|
|
8539
8636
|
});
|
|
8540
8637
|
for (let i = 0; i < pcdPointsArr.length; i++) {
|
|
8541
|
-
const
|
|
8638
|
+
const points2 = [];
|
|
8542
8639
|
for (let j = 0; j < pcdPointsArr[i].path.length; j++) {
|
|
8543
|
-
|
|
8640
|
+
points2.push(new THREE8.Vector3(
|
|
8544
8641
|
pcdPointsArr[i].path[j][0],
|
|
8545
8642
|
pcdPointsArr[i].path[j][1],
|
|
8546
8643
|
0
|
|
8547
8644
|
));
|
|
8548
8645
|
}
|
|
8549
|
-
if (
|
|
8646
|
+
if (points2.length == 0)
|
|
8550
8647
|
continue;
|
|
8551
8648
|
pointCloudGroup.add(pcdPointsArr[i].obb.getBoxEdge());
|
|
8552
8649
|
const geometry3 = new THREE8.BufferGeometry();
|
|
8553
|
-
geometry3.setFromPoints(
|
|
8650
|
+
geometry3.setFromPoints(points2);
|
|
8554
8651
|
const hex = "green";
|
|
8555
8652
|
const _lineMaterial = new THREE8.LineBasicMaterial({ color: hex, depthTest: false, depthWrite: false });
|
|
8556
8653
|
const line2 = new THREE8.Line(geometry3, _lineMaterial);
|
|
@@ -8600,7 +8697,7 @@ var getMergeMeaning = (allProjectionResults, averagePz2, pointCloudCluster = nul
|
|
|
8600
8697
|
const pcdPointsArr = [];
|
|
8601
8698
|
const mapMaxSortFloor = /* @__PURE__ */ new Map();
|
|
8602
8699
|
for (let i = 0; i < allProjectionResults.length; i++) {
|
|
8603
|
-
let
|
|
8700
|
+
let points2 = allProjectionResults[i].points.map((p) => [p.x, p.y]);
|
|
8604
8701
|
let obj_id = allProjectionResults[i].obj_id;
|
|
8605
8702
|
obj_id = obj_id.replace(/calcony railing/g, "balcony railing").replace(/glass balcony railing/g, "balcony railing").replace(/metal balcony railing/g, "balcony railing").replace(/temporary construction guardrail/g, "balcony railing").replace(/the floor of the house/g, "floor").replace(/the outdoor floor/g, "floor").replace(/roof/g, "Ceiling");
|
|
8606
8703
|
const category = obj_id.split("_").slice(1, 3).join("_").split(".")[0].split("_")[0];
|
|
@@ -8651,8 +8748,8 @@ var getMergeMeaning = (allProjectionResults, averagePz2, pointCloudCluster = nul
|
|
|
8651
8748
|
let mostFrequentEntry = [...mapSortPoint.entries()].reduce(
|
|
8652
8749
|
(max, cur) => cur[1].num > max[1].num ? cur : max
|
|
8653
8750
|
);
|
|
8654
|
-
|
|
8655
|
-
|
|
8751
|
+
points2 = [];
|
|
8752
|
+
points2 = mostFrequentEntry[1].points.map((p) => [p.x, p.y]);
|
|
8656
8753
|
threePoints = [];
|
|
8657
8754
|
threePoints = mostFrequentEntry[1].points.map((p) => new THREE8.Vector3(p.x, p.y, p.z));
|
|
8658
8755
|
floorZ = mostFrequentEntry[0];
|
|
@@ -8660,7 +8757,7 @@ var getMergeMeaning = (allProjectionResults, averagePz2, pointCloudCluster = nul
|
|
|
8660
8757
|
const centerData = getCenterAndPointHeight(threePoints);
|
|
8661
8758
|
const data = {
|
|
8662
8759
|
points: threePoints,
|
|
8663
|
-
path: computeContour(
|
|
8760
|
+
path: computeContour(points2),
|
|
8664
8761
|
h: centerData.h,
|
|
8665
8762
|
minz: centerData.minz,
|
|
8666
8763
|
maxz: centerData.maxz,
|
|
@@ -9127,15 +9224,15 @@ var getMergeMeaning = (allProjectionResults, averagePz2, pointCloudCluster = nul
|
|
|
9127
9224
|
let newArray = [];
|
|
9128
9225
|
for (let j = 0; j < array.length; j++) {
|
|
9129
9226
|
if (delArray.has(j)) continue;
|
|
9130
|
-
let
|
|
9227
|
+
let points2 = array[j].points;
|
|
9131
9228
|
let obj_id = array[j].obj_id;
|
|
9132
9229
|
let type2 = array[j].type;
|
|
9133
9230
|
let averagePz3 = array[j].averagePz;
|
|
9134
9231
|
let positionArr = array[j].positionArr;
|
|
9135
9232
|
let isStaircaseBalconyRailing = array[j].isStaircaseBalconyRailing;
|
|
9136
|
-
if (
|
|
9233
|
+
if (points2.length < 50)
|
|
9137
9234
|
continue;
|
|
9138
|
-
let clusterResult = pointCloudCluster([
|
|
9235
|
+
let clusterResult = pointCloudCluster([points2], {
|
|
9139
9236
|
tolerance: tolerancePointCloudCluster,
|
|
9140
9237
|
minClusterSize: 50,
|
|
9141
9238
|
maxClusterSize: 1e7,
|
|
@@ -9145,7 +9242,7 @@ var getMergeMeaning = (allProjectionResults, averagePz2, pointCloudCluster = nul
|
|
|
9145
9242
|
if (clusterResult.length > 0 && clusterResult[0].length > 1) {
|
|
9146
9243
|
for (const cluster of clusterResult[0]) {
|
|
9147
9244
|
if (cluster.length < 50) continue;
|
|
9148
|
-
const newOriginalPoints = cluster.map((i2) =>
|
|
9245
|
+
const newOriginalPoints = cluster.map((i2) => points2[i2]);
|
|
9149
9246
|
const centerData = getCenterAndPointHeight(newOriginalPoints);
|
|
9150
9247
|
let pathPoints = newOriginalPoints.map((p) => [p.x, p.y]);
|
|
9151
9248
|
const data = {
|
|
@@ -9205,7 +9302,7 @@ var getMergeFloorMeaning = (allProjectionResults) => {
|
|
|
9205
9302
|
const pcdPointsArr = [];
|
|
9206
9303
|
const mapMaxSortFloor = /* @__PURE__ */ new Map();
|
|
9207
9304
|
for (let i = 0; i < allProjectionResults.length; i++) {
|
|
9208
|
-
let
|
|
9305
|
+
let points2 = allProjectionResults[i].points.map((p) => [p.x, p.y]);
|
|
9209
9306
|
let obj_id = allProjectionResults[i].obj_id;
|
|
9210
9307
|
obj_id = obj_id.replace(/the floor of the house/g, "floor").replace(/the outdoor floor/g, "floor");
|
|
9211
9308
|
const category = obj_id.split("_").slice(1, 3).join("_").split(".")[0].split("_")[0];
|
|
@@ -9240,8 +9337,8 @@ var getMergeFloorMeaning = (allProjectionResults) => {
|
|
|
9240
9337
|
let mostFrequentEntry = [...mapSortPoint.entries()].reduce(
|
|
9241
9338
|
(max, cur) => cur[1].num > max[1].num ? cur : max
|
|
9242
9339
|
);
|
|
9243
|
-
|
|
9244
|
-
|
|
9340
|
+
points2 = [];
|
|
9341
|
+
points2 = mostFrequentEntry[1].points.map((p) => [p.x, p.y]);
|
|
9245
9342
|
threePoints = [];
|
|
9246
9343
|
threePoints = mostFrequentEntry[1].points.map((p) => new THREE8.Vector3(p.x, p.y, p.z));
|
|
9247
9344
|
floorZ = mostFrequentEntry[0];
|
|
@@ -9249,7 +9346,7 @@ var getMergeFloorMeaning = (allProjectionResults) => {
|
|
|
9249
9346
|
const centerData = getCenterAndPointHeight(threePoints);
|
|
9250
9347
|
const data = {
|
|
9251
9348
|
points: threePoints,
|
|
9252
|
-
path: computeContour(
|
|
9349
|
+
path: computeContour(points2),
|
|
9253
9350
|
h: centerData.h,
|
|
9254
9351
|
minz: centerData.minz,
|
|
9255
9352
|
maxz: centerData.maxz,
|
|
@@ -9385,7 +9482,7 @@ var getStaircase = (allProjectionResults, scene) => {
|
|
|
9385
9482
|
let pcdPointsArr = [];
|
|
9386
9483
|
const floorAllProjectionResults = splitFloorProjectsResults[i];
|
|
9387
9484
|
for (let i2 = 0; i2 < floorAllProjectionResults.length; i2++) {
|
|
9388
|
-
let
|
|
9485
|
+
let points2 = floorAllProjectionResults[i2].points.map((p) => [p.x, p.y]);
|
|
9389
9486
|
let obj_id = floorAllProjectionResults[i2].obj_id;
|
|
9390
9487
|
obj_id = obj_id.replace(/the floor of the house/g, "floor").replace(/the outdoor floor/g, "floor").replace(/calcony railing/g, "balcony railing").replace(/glass balcony railing/g, "balcony railing").replace(/metal balcony railing/g, "balcony railing").replace(/temporary construction guardrail/g, "balcony railing");
|
|
9391
9488
|
const category = obj_id.split("_").slice(1, 3).join("_").split(".")[0].split("_")[0];
|
|
@@ -9421,7 +9518,7 @@ var getStaircase = (allProjectionResults, scene) => {
|
|
|
9421
9518
|
const centerData = getCenterAndPointHeight(threePoints);
|
|
9422
9519
|
const data = {
|
|
9423
9520
|
points: threePoints,
|
|
9424
|
-
path: computeContour(
|
|
9521
|
+
path: computeContour(points2),
|
|
9425
9522
|
h: centerData.h,
|
|
9426
9523
|
minz: centerData.minz,
|
|
9427
9524
|
maxz: centerData.maxz,
|
|
@@ -9662,7 +9759,7 @@ var getStaircase = (allProjectionResults, scene) => {
|
|
|
9662
9759
|
let minDist = 0.2;
|
|
9663
9760
|
for (let i = 0; i < StaircaseArray.length; i++) {
|
|
9664
9761
|
const size = StaircaseArray[i].obb.halfSize.clone().multiplyScalar(2);
|
|
9665
|
-
const
|
|
9762
|
+
const points2 = StaircaseArray[i].points;
|
|
9666
9763
|
let width = size.x;
|
|
9667
9764
|
let length2 = size.y;
|
|
9668
9765
|
let height = size.z;
|
|
@@ -9688,31 +9785,31 @@ var getStaircase = (allProjectionResults, scene) => {
|
|
|
9688
9785
|
let nearLine6PtArray = [];
|
|
9689
9786
|
let nearLine7PtArray = [];
|
|
9690
9787
|
let nearLine8PtArray = [];
|
|
9691
|
-
for (let j = 0; j <
|
|
9692
|
-
let pt1 = line1.closestPointToPoint(
|
|
9693
|
-
let pt2 = line2.closestPointToPoint(
|
|
9694
|
-
let pt3 = line3.closestPointToPoint(
|
|
9695
|
-
let pt4 = line4.closestPointToPoint(
|
|
9696
|
-
let pt5 = line5.closestPointToPoint(
|
|
9697
|
-
let pt6 = line6.closestPointToPoint(
|
|
9698
|
-
let pt7 = line7.closestPointToPoint(
|
|
9699
|
-
let pt8 = line8.closestPointToPoint(
|
|
9700
|
-
if (pt1.distanceTo(
|
|
9701
|
-
nearLine1PtArray.push(
|
|
9702
|
-
if (pt2.distanceTo(
|
|
9703
|
-
nearLine2PtArray.push(
|
|
9704
|
-
if (pt3.distanceTo(
|
|
9705
|
-
nearLine3PtArray.push(
|
|
9706
|
-
if (pt4.distanceTo(
|
|
9707
|
-
nearLine4PtArray.push(
|
|
9708
|
-
if (pt5.distanceTo(
|
|
9709
|
-
nearLine5PtArray.push(
|
|
9710
|
-
if (pt6.distanceTo(
|
|
9711
|
-
nearLine6PtArray.push(
|
|
9712
|
-
if (pt7.distanceTo(
|
|
9713
|
-
nearLine7PtArray.push(
|
|
9714
|
-
if (pt8.distanceTo(
|
|
9715
|
-
nearLine8PtArray.push(
|
|
9788
|
+
for (let j = 0; j < points2.length; j++) {
|
|
9789
|
+
let pt1 = line1.closestPointToPoint(points2[j], true, new THREE8.Vector3());
|
|
9790
|
+
let pt2 = line2.closestPointToPoint(points2[j], true, new THREE8.Vector3());
|
|
9791
|
+
let pt3 = line3.closestPointToPoint(points2[j], true, new THREE8.Vector3());
|
|
9792
|
+
let pt4 = line4.closestPointToPoint(points2[j], true, new THREE8.Vector3());
|
|
9793
|
+
let pt5 = line5.closestPointToPoint(points2[j], true, new THREE8.Vector3());
|
|
9794
|
+
let pt6 = line6.closestPointToPoint(points2[j], true, new THREE8.Vector3());
|
|
9795
|
+
let pt7 = line7.closestPointToPoint(points2[j], true, new THREE8.Vector3());
|
|
9796
|
+
let pt8 = line8.closestPointToPoint(points2[j], true, new THREE8.Vector3());
|
|
9797
|
+
if (pt1.distanceTo(points2[j]) < minDist)
|
|
9798
|
+
nearLine1PtArray.push(points2[j]);
|
|
9799
|
+
if (pt2.distanceTo(points2[j]) < minDist)
|
|
9800
|
+
nearLine2PtArray.push(points2[j]);
|
|
9801
|
+
if (pt3.distanceTo(points2[j]) < minDist)
|
|
9802
|
+
nearLine3PtArray.push(points2[j]);
|
|
9803
|
+
if (pt4.distanceTo(points2[j]) < minDist)
|
|
9804
|
+
nearLine4PtArray.push(points2[j]);
|
|
9805
|
+
if (pt5.distanceTo(points2[j]) < minDist)
|
|
9806
|
+
nearLine5PtArray.push(points2[j]);
|
|
9807
|
+
if (pt6.distanceTo(points2[j]) < minDist)
|
|
9808
|
+
nearLine6PtArray.push(points2[j]);
|
|
9809
|
+
if (pt7.distanceTo(points2[j]) < minDist)
|
|
9810
|
+
nearLine7PtArray.push(points2[j]);
|
|
9811
|
+
if (pt8.distanceTo(points2[j]) < minDist)
|
|
9812
|
+
nearLine8PtArray.push(points2[j]);
|
|
9716
9813
|
}
|
|
9717
9814
|
let len1 = obbPoints[0].distanceTo(obbPoints[1]);
|
|
9718
9815
|
let len2 = obbPoints[1].distanceTo(obbPoints[2]);
|
|
@@ -10395,7 +10492,7 @@ function filterPointSetByMainDirection(inputPoints, options = {}) {
|
|
|
10395
10492
|
const sideY = dirX;
|
|
10396
10493
|
let minT = Infinity;
|
|
10397
10494
|
let maxT = -Infinity;
|
|
10398
|
-
const
|
|
10495
|
+
const points2 = rawPoints.map((p) => {
|
|
10399
10496
|
const dx = p.x - meanX;
|
|
10400
10497
|
const dy = p.y - meanY;
|
|
10401
10498
|
const t = dx * dirX + dy * dirY;
|
|
@@ -10411,7 +10508,7 @@ function filterPointSetByMainDirection(inputPoints, options = {}) {
|
|
|
10411
10508
|
const totalT = maxT - minT || 1;
|
|
10412
10509
|
const binSize = totalT / binCount;
|
|
10413
10510
|
const bins = /* @__PURE__ */ new Map();
|
|
10414
|
-
for (const p of
|
|
10511
|
+
for (const p of points2) {
|
|
10415
10512
|
let bin = Math.floor((p.t - minT) / binSize);
|
|
10416
10513
|
if (bin < 0) bin = 0;
|
|
10417
10514
|
if (bin >= binCount) bin = binCount - 1;
|
|
@@ -10458,7 +10555,7 @@ function filterPointSetByMainDirection(inputPoints, options = {}) {
|
|
|
10458
10555
|
}
|
|
10459
10556
|
const keep = [];
|
|
10460
10557
|
const removed = [];
|
|
10461
|
-
for (const p of
|
|
10558
|
+
for (const p of points2) {
|
|
10462
10559
|
let bin = Math.floor((p.t - minT) / binSize);
|
|
10463
10560
|
if (bin < 0) bin = 0;
|
|
10464
10561
|
if (bin >= binCount) bin = binCount - 1;
|
|
@@ -10502,10 +10599,10 @@ function medianSorted(arr) {
|
|
|
10502
10599
|
}
|
|
10503
10600
|
return arr[mid];
|
|
10504
10601
|
}
|
|
10505
|
-
function buildPointGrid(
|
|
10602
|
+
function buildPointGrid(points2, cellSize) {
|
|
10506
10603
|
const grid = /* @__PURE__ */ new Map();
|
|
10507
|
-
for (let i = 0; i <
|
|
10508
|
-
const p =
|
|
10604
|
+
for (let i = 0; i < points2.length; i++) {
|
|
10605
|
+
const p = points2[i];
|
|
10509
10606
|
const ix = Math.floor(p.x / cellSize);
|
|
10510
10607
|
const iy = Math.floor(p.y / cellSize);
|
|
10511
10608
|
const iz = Math.floor(p.z / cellSize);
|
|
@@ -10517,8 +10614,8 @@ function buildPointGrid(points, cellSize) {
|
|
|
10517
10614
|
}
|
|
10518
10615
|
return grid;
|
|
10519
10616
|
}
|
|
10520
|
-
function findPointNeighbors(
|
|
10521
|
-
const p =
|
|
10617
|
+
function findPointNeighbors(points2, grid, pointIndex, radius, radiusSq) {
|
|
10618
|
+
const p = points2[pointIndex];
|
|
10522
10619
|
const ix = Math.floor(p.x / radius);
|
|
10523
10620
|
const iy = Math.floor(p.y / radius);
|
|
10524
10621
|
const iz = Math.floor(p.z / radius);
|
|
@@ -10531,7 +10628,7 @@ function findPointNeighbors(points, grid, pointIndex, radius, radiusSq) {
|
|
|
10531
10628
|
if (!list) continue;
|
|
10532
10629
|
for (const candidateIndex of list) {
|
|
10533
10630
|
if (candidateIndex === pointIndex) continue;
|
|
10534
|
-
const q =
|
|
10631
|
+
const q = points2[candidateIndex];
|
|
10535
10632
|
const ddx = p.x - q.x;
|
|
10536
10633
|
const ddy = p.y - q.y;
|
|
10537
10634
|
const ddz = p.z - q.z;
|
|
@@ -10577,18 +10674,18 @@ function removeSmallClustersKeepInfo(inputPoints, options = {}) {
|
|
|
10577
10674
|
const {
|
|
10578
10675
|
radius = 0.35
|
|
10579
10676
|
} = options;
|
|
10580
|
-
const
|
|
10677
|
+
const points2 = inputPoints.map((p, index) => ({
|
|
10581
10678
|
index,
|
|
10582
10679
|
x: p.x,
|
|
10583
10680
|
y: p.y,
|
|
10584
10681
|
z: p.z,
|
|
10585
10682
|
raw: p
|
|
10586
10683
|
}));
|
|
10587
|
-
const grid = buildPointGrid(
|
|
10684
|
+
const grid = buildPointGrid(points2, radius);
|
|
10588
10685
|
const radiusSq = radius * radius;
|
|
10589
|
-
const visited = new Array(
|
|
10686
|
+
const visited = new Array(points2.length).fill(false);
|
|
10590
10687
|
const clusters = [];
|
|
10591
|
-
for (let i = 0; i <
|
|
10688
|
+
for (let i = 0; i < points2.length; i++) {
|
|
10592
10689
|
if (visited[i]) continue;
|
|
10593
10690
|
const cluster = [];
|
|
10594
10691
|
const queue = [i];
|
|
@@ -10597,7 +10694,7 @@ function removeSmallClustersKeepInfo(inputPoints, options = {}) {
|
|
|
10597
10694
|
const currentIndex = queue.shift();
|
|
10598
10695
|
cluster.push(currentIndex);
|
|
10599
10696
|
const neighbors = findPointNeighbors(
|
|
10600
|
-
|
|
10697
|
+
points2,
|
|
10601
10698
|
grid,
|
|
10602
10699
|
currentIndex,
|
|
10603
10700
|
radius,
|
|
@@ -10613,7 +10710,7 @@ function removeSmallClustersKeepInfo(inputPoints, options = {}) {
|
|
|
10613
10710
|
clusters.push(cluster);
|
|
10614
10711
|
}
|
|
10615
10712
|
return {
|
|
10616
|
-
points,
|
|
10713
|
+
points: points2,
|
|
10617
10714
|
clusters
|
|
10618
10715
|
};
|
|
10619
10716
|
}
|
|
@@ -10658,8 +10755,8 @@ function obbContainsPoint(obb, point2, epsilon3 = 1e-6) {
|
|
|
10658
10755
|
}
|
|
10659
10756
|
|
|
10660
10757
|
// src/utils/clusert.mjs
|
|
10661
|
-
function alphaForTriangle(
|
|
10662
|
-
const xZero =
|
|
10758
|
+
function alphaForTriangle(points2, ia, ib, ic) {
|
|
10759
|
+
const xZero = points2[ia][0] === 0 || points2[ib][0] === 0 || points2[ic][0] === 0;
|
|
10663
10760
|
return 1 + (xZero ? 1 : 0);
|
|
10664
10761
|
}
|
|
10665
10762
|
function circumradius2(ax, ay, bx, by, cx, cy) {
|
|
@@ -10670,11 +10767,11 @@ function circumradius2(ax, ay, bx, by, cx, cy) {
|
|
|
10670
10767
|
if (area2 === 0) return Infinity;
|
|
10671
10768
|
return a * b * c / (4 * area2);
|
|
10672
10769
|
}
|
|
10673
|
-
function computeContour2(
|
|
10674
|
-
if (!
|
|
10770
|
+
function computeContour2(points2) {
|
|
10771
|
+
if (!points2 || points2.length < 3) return [];
|
|
10675
10772
|
const seen = /* @__PURE__ */ new Set();
|
|
10676
10773
|
const uniq = [];
|
|
10677
|
-
for (const p of
|
|
10774
|
+
for (const p of points2) {
|
|
10678
10775
|
const k = `${p[0]}_${p[1]}`;
|
|
10679
10776
|
if (!seen.has(k)) {
|
|
10680
10777
|
seen.add(k);
|
|
@@ -10766,28 +10863,28 @@ var getFlatSlabData = (lines, runDataList, pointCloudCluster = null) => {
|
|
|
10766
10863
|
let maxPointsNum = 0;
|
|
10767
10864
|
let maxPointsZ = 0;
|
|
10768
10865
|
for (const line2 of lines) {
|
|
10769
|
-
let
|
|
10770
|
-
if (
|
|
10866
|
+
let points2 = line2[1].points;
|
|
10867
|
+
if (points2.length < 30) continue;
|
|
10771
10868
|
let mapSortPoint = /* @__PURE__ */ new Map();
|
|
10772
|
-
for (let c = 0; c <
|
|
10773
|
-
let z =
|
|
10869
|
+
for (let c = 0; c < points2.length; c++) {
|
|
10870
|
+
let z = points2[c].z;
|
|
10774
10871
|
z = Math.floor(z * 10) / 10;
|
|
10775
10872
|
if (mapSortPoint.has(z)) {
|
|
10776
10873
|
const item = mapSortPoint.get(z);
|
|
10777
10874
|
item.num += 1;
|
|
10778
|
-
item.points.push(
|
|
10875
|
+
item.points.push(points2[c]);
|
|
10779
10876
|
mapSortPoint.set(z, item);
|
|
10780
10877
|
} else {
|
|
10781
|
-
mapSortPoint.set(z, { num: 1, points: [
|
|
10878
|
+
mapSortPoint.set(z, { num: 1, points: [points2[c]] });
|
|
10782
10879
|
}
|
|
10783
10880
|
}
|
|
10784
10881
|
let mostFrequentEntry = [...mapSortPoint.entries()].reduce(
|
|
10785
10882
|
(max, cur) => cur[1].num > max[1].num ? cur : max
|
|
10786
10883
|
);
|
|
10787
|
-
|
|
10884
|
+
points2 = mostFrequentEntry[1].points.map((p) => new THREE9.Vector3(p.x, p.y, p.z));
|
|
10788
10885
|
let newPoints = [];
|
|
10789
10886
|
if (pointCloudCluster != null) {
|
|
10790
|
-
let clusterResult = pointCloudCluster([
|
|
10887
|
+
let clusterResult = pointCloudCluster([points2], {
|
|
10791
10888
|
tolerance: 0.1,
|
|
10792
10889
|
minClusterSize: 30,
|
|
10793
10890
|
maxClusterSize: 1e7,
|
|
@@ -10796,13 +10893,13 @@ var getFlatSlabData = (lines, runDataList, pointCloudCluster = null) => {
|
|
|
10796
10893
|
if (clusterResult.length > 0) {
|
|
10797
10894
|
for (const cluster of clusterResult[0]) {
|
|
10798
10895
|
if (cluster.length < 50) continue;
|
|
10799
|
-
const newOriginalPoints = cluster.map((i) =>
|
|
10896
|
+
const newOriginalPoints = cluster.map((i) => points2[i]);
|
|
10800
10897
|
newPoints.push(newOriginalPoints);
|
|
10801
10898
|
}
|
|
10802
10899
|
} else
|
|
10803
|
-
newPoints.push(
|
|
10900
|
+
newPoints.push(points2);
|
|
10804
10901
|
} else
|
|
10805
|
-
newPoints.push(
|
|
10902
|
+
newPoints.push(points2);
|
|
10806
10903
|
for (let u4 = 0; u4 < newPoints.length; u4++) {
|
|
10807
10904
|
let { minZ, maxZ, averagePz: averagePz2 } = getPointsMinAndMax(newPoints[u4]);
|
|
10808
10905
|
const height = maxZ - minZ;
|
|
@@ -10875,10 +10972,10 @@ var getObliqueSlabData = (lines, runDataList, pointCloudCluster = null) => {
|
|
|
10875
10972
|
}
|
|
10876
10973
|
const averageZ = totalZ / (runDataList.length - 1) + 0.3;
|
|
10877
10974
|
for (let i = 0; i < lines.length; i++) {
|
|
10878
|
-
let
|
|
10975
|
+
let points2 = lines[i][1].points;
|
|
10879
10976
|
let newPoints = [];
|
|
10880
10977
|
if (pointCloudCluster != null) {
|
|
10881
|
-
let clusterResult = pointCloudCluster([
|
|
10978
|
+
let clusterResult = pointCloudCluster([points2], {
|
|
10882
10979
|
tolerance: 0.2,
|
|
10883
10980
|
minClusterSize: 30,
|
|
10884
10981
|
maxClusterSize: 1e7,
|
|
@@ -10887,13 +10984,13 @@ var getObliqueSlabData = (lines, runDataList, pointCloudCluster = null) => {
|
|
|
10887
10984
|
if (clusterResult.length > 0) {
|
|
10888
10985
|
for (const cluster of clusterResult[0]) {
|
|
10889
10986
|
if (cluster.length < 50) continue;
|
|
10890
|
-
const newOriginalPoints = cluster.map((i2) =>
|
|
10987
|
+
const newOriginalPoints = cluster.map((i2) => points2[i2]);
|
|
10891
10988
|
newPoints.push(newOriginalPoints);
|
|
10892
10989
|
}
|
|
10893
10990
|
} else
|
|
10894
|
-
newPoints.push(
|
|
10991
|
+
newPoints.push(points2);
|
|
10895
10992
|
} else
|
|
10896
|
-
newPoints.push(
|
|
10993
|
+
newPoints.push(points2);
|
|
10897
10994
|
if (newPoints.length == 0)
|
|
10898
10995
|
continue;
|
|
10899
10996
|
for (let x = 0; x < newPoints.length; x++) {
|
|
@@ -10944,10 +11041,10 @@ var getObliqueSlabData = (lines, runDataList, pointCloudCluster = null) => {
|
|
|
10944
11041
|
}
|
|
10945
11042
|
slabDatas = [];
|
|
10946
11043
|
for (let i = 0; i < newSlabDatas.length; i++) {
|
|
10947
|
-
let
|
|
11044
|
+
let points2 = newSlabDatas[i].points;
|
|
10948
11045
|
let newPoints = [];
|
|
10949
11046
|
if (pointCloudCluster != null) {
|
|
10950
|
-
let clusterResult = pointCloudCluster([
|
|
11047
|
+
let clusterResult = pointCloudCluster([points2], {
|
|
10951
11048
|
tolerance: 0.2,
|
|
10952
11049
|
minClusterSize: 30,
|
|
10953
11050
|
maxClusterSize: 1e7,
|
|
@@ -10956,13 +11053,13 @@ var getObliqueSlabData = (lines, runDataList, pointCloudCluster = null) => {
|
|
|
10956
11053
|
if (clusterResult.length > 0) {
|
|
10957
11054
|
for (const cluster of clusterResult[0]) {
|
|
10958
11055
|
if (cluster.length < 50) continue;
|
|
10959
|
-
const newOriginalPoints = cluster.map((i2) =>
|
|
11056
|
+
const newOriginalPoints = cluster.map((i2) => points2[i2]);
|
|
10960
11057
|
newPoints.push(newOriginalPoints);
|
|
10961
11058
|
}
|
|
10962
11059
|
} else
|
|
10963
|
-
newPoints.push(
|
|
11060
|
+
newPoints.push(points2);
|
|
10964
11061
|
} else
|
|
10965
|
-
newPoints.push(
|
|
11062
|
+
newPoints.push(points2);
|
|
10966
11063
|
if (newPoints.length == 0)
|
|
10967
11064
|
continue;
|
|
10968
11065
|
for (let x = 0; x < newPoints.length; x++) {
|
|
@@ -10985,15 +11082,15 @@ var getObliqueSlabData = (lines, runDataList, pointCloudCluster = null) => {
|
|
|
10985
11082
|
}
|
|
10986
11083
|
return slabDatas;
|
|
10987
11084
|
};
|
|
10988
|
-
function getPathZ(path3,
|
|
11085
|
+
function getPathZ(path3, points2) {
|
|
10989
11086
|
let pathPt = new THREE9.Vector3();
|
|
10990
|
-
for (let i = 0; i <
|
|
11087
|
+
for (let i = 0; i < points2.length; i++) {
|
|
10991
11088
|
for (let j = 0; j < path3.length; j++) {
|
|
10992
11089
|
if (path3[j].length == 3)
|
|
10993
11090
|
continue;
|
|
10994
|
-
pathPt.set(path3[j][0], path3[j][1],
|
|
10995
|
-
if (pathPt.distanceTo(
|
|
10996
|
-
path3[j].push(
|
|
11091
|
+
pathPt.set(path3[j][0], path3[j][1], points2[i].z);
|
|
11092
|
+
if (pathPt.distanceTo(points2[i]) < 1e-3) {
|
|
11093
|
+
path3[j].push(points2[i].z);
|
|
10997
11094
|
break;
|
|
10998
11095
|
}
|
|
10999
11096
|
}
|
|
@@ -14720,14 +14817,14 @@ function pointToSegDist(px, pz, x1, z1, x2, z2) {
|
|
|
14720
14817
|
const ez = pz - cz;
|
|
14721
14818
|
return Math.sqrt(ex * ex + ez * ez);
|
|
14722
14819
|
}
|
|
14723
|
-
function polygonArea2(
|
|
14724
|
-
if (
|
|
14820
|
+
function polygonArea2(points2) {
|
|
14821
|
+
if (points2.length < 3) return 0;
|
|
14725
14822
|
let area2 = 0;
|
|
14726
|
-
const n =
|
|
14823
|
+
const n = points2.length;
|
|
14727
14824
|
for (let i = 0; i < n; i++) {
|
|
14728
14825
|
const j = (i + 1) % n;
|
|
14729
|
-
area2 +=
|
|
14730
|
-
area2 -=
|
|
14826
|
+
area2 += points2[i].x * points2[j].z;
|
|
14827
|
+
area2 -= points2[j].x * points2[i].z;
|
|
14731
14828
|
}
|
|
14732
14829
|
return Math.abs(area2) / 2;
|
|
14733
14830
|
}
|
|
@@ -15304,23 +15401,23 @@ function rotatePoint(x, z, angle) {
|
|
|
15304
15401
|
z: x * sin + z * cos
|
|
15305
15402
|
};
|
|
15306
15403
|
}
|
|
15307
|
-
function calcTotalLength(
|
|
15404
|
+
function calcTotalLength(points2) {
|
|
15308
15405
|
let len = 0;
|
|
15309
|
-
for (let i = 1; i <
|
|
15310
|
-
const dx =
|
|
15311
|
-
const dz =
|
|
15406
|
+
for (let i = 1; i < points2.length; i++) {
|
|
15407
|
+
const dx = points2[i].x - points2[i - 1].x;
|
|
15408
|
+
const dz = points2[i].z - points2[i - 1].z;
|
|
15312
15409
|
len += Math.sqrt(dx * dx + dz * dz);
|
|
15313
15410
|
}
|
|
15314
15411
|
return len;
|
|
15315
15412
|
}
|
|
15316
|
-
function polygonArea3(
|
|
15317
|
-
if (
|
|
15413
|
+
function polygonArea3(points2) {
|
|
15414
|
+
if (points2.length < 3) return 0;
|
|
15318
15415
|
let area2 = 0;
|
|
15319
|
-
const n =
|
|
15416
|
+
const n = points2.length;
|
|
15320
15417
|
for (let i = 0; i < n; i++) {
|
|
15321
15418
|
const j = (i + 1) % n;
|
|
15322
|
-
area2 +=
|
|
15323
|
-
area2 -=
|
|
15419
|
+
area2 += points2[i].x * points2[j].z;
|
|
15420
|
+
area2 -= points2[j].x * points2[i].z;
|
|
15324
15421
|
}
|
|
15325
15422
|
return Math.abs(area2) / 2;
|
|
15326
15423
|
}
|
|
@@ -15366,10 +15463,10 @@ function minDistBetweenPolylines(a, b) {
|
|
|
15366
15463
|
}
|
|
15367
15464
|
|
|
15368
15465
|
// src/wall-shape-classifier/point-cloud.ts
|
|
15369
|
-
function buildDensityGrid(
|
|
15466
|
+
function buildDensityGrid(points2, cellSize) {
|
|
15370
15467
|
const cells = /* @__PURE__ */ new Map();
|
|
15371
15468
|
let minX = Infinity, maxX = -Infinity, minZ = Infinity, maxZ = -Infinity;
|
|
15372
|
-
for (const p of
|
|
15469
|
+
for (const p of points2) {
|
|
15373
15470
|
const cx = Math.floor(p.x / cellSize);
|
|
15374
15471
|
const cz = Math.floor(p.z / cellSize);
|
|
15375
15472
|
const key = cx + "," + cz;
|
|
@@ -15543,22 +15640,22 @@ function extractBoundaryContour(component, cellSize) {
|
|
|
15543
15640
|
}
|
|
15544
15641
|
return result;
|
|
15545
15642
|
}
|
|
15546
|
-
function simplifyPolyline(
|
|
15547
|
-
if (
|
|
15643
|
+
function simplifyPolyline(points2, epsilon3) {
|
|
15644
|
+
if (points2.length <= 2) return [...points2];
|
|
15548
15645
|
let maxDist = 0;
|
|
15549
15646
|
let maxIdx = 0;
|
|
15550
|
-
const first =
|
|
15551
|
-
const last =
|
|
15552
|
-
for (let i = 1; i <
|
|
15553
|
-
const d = distToSegment(
|
|
15647
|
+
const first = points2[0];
|
|
15648
|
+
const last = points2[points2.length - 1];
|
|
15649
|
+
for (let i = 1; i < points2.length - 1; i++) {
|
|
15650
|
+
const d = distToSegment(points2[i].x, points2[i].z, first.x, first.z, last.x, last.z);
|
|
15554
15651
|
if (d > maxDist) {
|
|
15555
15652
|
maxDist = d;
|
|
15556
15653
|
maxIdx = i;
|
|
15557
15654
|
}
|
|
15558
15655
|
}
|
|
15559
15656
|
if (maxDist > epsilon3) {
|
|
15560
|
-
const left = simplifyPolyline(
|
|
15561
|
-
const right = simplifyPolyline(
|
|
15657
|
+
const left = simplifyPolyline(points2.slice(0, maxIdx + 1), epsilon3);
|
|
15658
|
+
const right = simplifyPolyline(points2.slice(maxIdx), epsilon3);
|
|
15562
15659
|
return [...left.slice(0, -1), ...right];
|
|
15563
15660
|
}
|
|
15564
15661
|
return [first, last];
|
|
@@ -16757,10 +16854,10 @@ function emptyResult(rawLines, startTime) {
|
|
|
16757
16854
|
}
|
|
16758
16855
|
|
|
16759
16856
|
// src/wall-shape-classifier/point-cloud-filter.ts
|
|
16760
|
-
function removeOutlierPoints(
|
|
16761
|
-
if (!
|
|
16857
|
+
function removeOutlierPoints(points2, cellSize, minNeighbors) {
|
|
16858
|
+
if (!points2.length || minNeighbors <= 1) return points2;
|
|
16762
16859
|
const grid = /* @__PURE__ */ new Map();
|
|
16763
|
-
for (const p of
|
|
16860
|
+
for (const p of points2) {
|
|
16764
16861
|
const gx = Math.floor(p.x / cellSize);
|
|
16765
16862
|
const gy = Math.floor(p.y / cellSize);
|
|
16766
16863
|
const key = `${gx},${gy}`;
|
|
@@ -16782,7 +16879,7 @@ function removeOutlierPoints(points, cellSize, minNeighbors) {
|
|
|
16782
16879
|
}
|
|
16783
16880
|
const kept = [];
|
|
16784
16881
|
let removed = 0;
|
|
16785
|
-
for (const p of
|
|
16882
|
+
for (const p of points2) {
|
|
16786
16883
|
const gx = Math.floor(p.x / cellSize);
|
|
16787
16884
|
const gy = Math.floor(p.y / cellSize);
|
|
16788
16885
|
const key = `${gx},${gy}`;
|
|
@@ -16794,10 +16891,10 @@ function removeOutlierPoints(points, cellSize, minNeighbors) {
|
|
|
16794
16891
|
}
|
|
16795
16892
|
return kept;
|
|
16796
16893
|
}
|
|
16797
|
-
function applyVoxelFilter(
|
|
16798
|
-
if (!
|
|
16894
|
+
function applyVoxelFilter(points2, voxelSize, minPointsPerVoxel) {
|
|
16895
|
+
if (!points2.length || minPointsPerVoxel <= 1 || voxelSize <= 0) return points2;
|
|
16799
16896
|
const grid = /* @__PURE__ */ new Map();
|
|
16800
|
-
for (const p of
|
|
16897
|
+
for (const p of points2) {
|
|
16801
16898
|
const ix = Math.floor(p.x / voxelSize);
|
|
16802
16899
|
const iy = Math.floor(p.y / voxelSize);
|
|
16803
16900
|
const iz = Math.floor(p.z / voxelSize);
|
|
@@ -16816,9 +16913,9 @@ function applyVoxelFilter(points, voxelSize, minPointsPerVoxel) {
|
|
|
16816
16913
|
}
|
|
16817
16914
|
return kept;
|
|
16818
16915
|
}
|
|
16819
|
-
function voxelFilter(
|
|
16820
|
-
const r = applyVoxelFilter(
|
|
16821
|
-
const removed =
|
|
16916
|
+
function voxelFilter(points2, voxelSize, minPointsPerVoxel) {
|
|
16917
|
+
const r = applyVoxelFilter(points2, voxelSize, minPointsPerVoxel);
|
|
16918
|
+
const removed = points2.length - r.length;
|
|
16822
16919
|
return r;
|
|
16823
16920
|
}
|
|
16824
16921
|
function computeVoxelParams(data) {
|
|
@@ -17348,14 +17445,14 @@ function growPolylines(lines, connectDist, angleTolRad) {
|
|
|
17348
17445
|
}
|
|
17349
17446
|
return results;
|
|
17350
17447
|
}
|
|
17351
|
-
function computeTurnAngles(
|
|
17352
|
-
if (
|
|
17448
|
+
function computeTurnAngles(points2) {
|
|
17449
|
+
if (points2.length < 3) return [];
|
|
17353
17450
|
const deltas = [];
|
|
17354
|
-
for (let i = 1; i <
|
|
17355
|
-
const dx1 =
|
|
17356
|
-
const dz1 =
|
|
17357
|
-
const dx2 =
|
|
17358
|
-
const dz2 =
|
|
17451
|
+
for (let i = 1; i < points2.length - 1; i++) {
|
|
17452
|
+
const dx1 = points2[i].x - points2[i - 1].x;
|
|
17453
|
+
const dz1 = points2[i].z - points2[i - 1].z;
|
|
17454
|
+
const dx2 = points2[i + 1].x - points2[i].x;
|
|
17455
|
+
const dz2 = points2[i + 1].z - points2[i].z;
|
|
17359
17456
|
const angle1 = Math.atan2(dz1, dx1);
|
|
17360
17457
|
const angle2 = Math.atan2(dz2, dx2);
|
|
17361
17458
|
let delta = normalizeAngle(angle2 - angle1);
|
|
@@ -17363,45 +17460,45 @@ function computeTurnAngles(points) {
|
|
|
17363
17460
|
}
|
|
17364
17461
|
return deltas;
|
|
17365
17462
|
}
|
|
17366
|
-
function classifyType(
|
|
17367
|
-
if (
|
|
17368
|
-
const first =
|
|
17369
|
-
const last =
|
|
17463
|
+
function classifyType(points2, minCurvePoints = 6) {
|
|
17464
|
+
if (points2.length < 3) return "straight";
|
|
17465
|
+
const first = points2[0];
|
|
17466
|
+
const last = points2[points2.length - 1];
|
|
17370
17467
|
const dx = last.x - first.x;
|
|
17371
17468
|
const dz = last.z - first.z;
|
|
17372
17469
|
const chordLen = Math.sqrt(dx * dx + dz * dz);
|
|
17373
17470
|
if (chordLen > 0.1) {
|
|
17374
17471
|
let maxDev = 0;
|
|
17375
|
-
for (const p of
|
|
17472
|
+
for (const p of points2) {
|
|
17376
17473
|
const d = distToSegment(p.x, p.z, first.x, first.z, last.x, last.z);
|
|
17377
17474
|
if (d > maxDev) maxDev = d;
|
|
17378
17475
|
}
|
|
17379
17476
|
if (maxDev < 0.05) return "straight";
|
|
17380
17477
|
}
|
|
17381
|
-
const deltas = computeTurnAngles(
|
|
17478
|
+
const deltas = computeTurnAngles(points2);
|
|
17382
17479
|
const totalBend = deltas.reduce((sum2, d) => sum2 + Math.abs(d), 0);
|
|
17383
17480
|
if (totalBend < 0.1) return "straight";
|
|
17384
|
-
if (
|
|
17481
|
+
if (points2.length < minCurvePoints) return "straight";
|
|
17385
17482
|
let signChanges = 0;
|
|
17386
17483
|
for (let i = 0; i < deltas.length - 1; i++) {
|
|
17387
17484
|
if (deltas[i] * deltas[i + 1] < 0) signChanges++;
|
|
17388
17485
|
}
|
|
17389
17486
|
return signChanges > 0 ? "S_curve" : "C_curve";
|
|
17390
17487
|
}
|
|
17391
|
-
function splitAtHardCorners(
|
|
17392
|
-
if (
|
|
17488
|
+
function splitAtHardCorners(points2, thresholdDeg) {
|
|
17489
|
+
if (points2.length < 3) return [points2];
|
|
17393
17490
|
const threshold = degToRad(thresholdDeg);
|
|
17394
|
-
const deltas = computeTurnAngles(
|
|
17491
|
+
const deltas = computeTurnAngles(points2);
|
|
17395
17492
|
const segments = [];
|
|
17396
17493
|
let startIdx = 0;
|
|
17397
17494
|
for (let i = 0; i < deltas.length; i++) {
|
|
17398
17495
|
if (Math.abs(deltas[i]) > threshold) {
|
|
17399
|
-
segments.push(
|
|
17496
|
+
segments.push(points2.slice(startIdx, i + 2));
|
|
17400
17497
|
startIdx = i + 1;
|
|
17401
17498
|
}
|
|
17402
17499
|
}
|
|
17403
|
-
if (startIdx <
|
|
17404
|
-
segments.push(
|
|
17500
|
+
if (startIdx < points2.length - 1) {
|
|
17501
|
+
segments.push(points2.slice(startIdx));
|
|
17405
17502
|
}
|
|
17406
17503
|
return segments;
|
|
17407
17504
|
}
|