diff --git a/app/src/modules/builder/wall/Instances/instance/helpers/useWallClassification.ts b/app/src/modules/builder/wall/Instances/instance/helpers/useWallClassification.ts index 7451501..aaa3912 100644 --- a/app/src/modules/builder/wall/Instances/instance/helpers/useWallClassification.ts +++ b/app/src/modules/builder/wall/Instances/instance/helpers/useWallClassification.ts @@ -6,9 +6,19 @@ export function useWallClassification(walls: Walls) { if (walls.length < 3) return []; const wallSet = new Map(); + const positionPairSet = new Set(); const makeKey = (p1: Point, p2: Point) => { - return [p1.pointUuid, p2.pointUuid].sort().join("-"); + return [p1.pointUuid, p2.pointUuid].sort((a, b) => a.localeCompare(b)).join("-"); + }; + + const makePositionPairKey = (p1: Point, p2: Point) => { + const sortedPositions = [ + [p1.position[0].toFixed(6), p1.position[2].toFixed(6)], + [p2.position[0].toFixed(6), p2.position[2].toFixed(6)], + ].sort((a, b) => a[0].localeCompare(b[0]) || a[1].localeCompare(b[1])); + + return sortedPositions.map((pos) => pos.join(",")).join("|"); }; for (const wall of walls) { @@ -18,6 +28,14 @@ export function useWallClassification(walls: Walls) { continue; } + const positionPairKey = makePositionPairKey(p1, p2); + + if (positionPairSet.has(positionPairKey)) { + continue; + } + + positionPairSet.add(positionPairKey); + const key = makeKey(p1, p2); if (!wallSet.has(key)) { wallSet.set(key, wall);