diff --git a/src/util/qpolygon-utils.js b/src/util/qpolygon-utils.js index e1ff8575..47e8f4e9 100644 --- a/src/util/qpolygon-utils.js +++ b/src/util/qpolygon-utils.js @@ -5992,6 +5992,19 @@ export const calcLineActualSize = (points, degree = 0) => { return Big(planeSize).div(theta).round().toNumber() } +export const calcLineActualSize2 = (points, degree = 0) => { + const planeSize = calcLinePlaneSize(points) + + const xLength = Math.abs(points.x2 - points.x1) * 10 + const yLength = Math.abs(points.y2 - points.y1) * 10 + const hx = xLength * Math.tan(degree * (Math.PI / 180)) + + const hy = yLength * Math.tan(degree * (Math.PI / 180)) + const actualSize = Number(Math.sqrt(hx ** 2 + planeSize ** 2)).toFixed(0) + const actualSize2 = Number(Math.sqrt(hy ** 2 + planeSize ** 2)).toFixed(0) + return actualSize +} + /** * 포인트와 기울기를 기준으로 선의 길이를 구한다. * @param lineLength diff --git a/src/util/skeleton-utils.js b/src/util/skeleton-utils.js index 2ebc06c9..cab518ef 100644 --- a/src/util/skeleton-utils.js +++ b/src/util/skeleton-utils.js @@ -1,6 +1,6 @@ import { LINE_TYPE, POLYGON_TYPE } from '@/common/common' import { SkeletonBuilder } from '@/lib/skeletons' -import { calcLineActualSize, calcLinePlaneSize, toGeoJSON } from '@/util/qpolygon-utils' +import { calcLineActualSize, calcLineActualSize2, calcLinePlaneSize, toGeoJSON } from '@/util/qpolygon-utils' import { QLine } from '@/components/fabric/QLine' import { getDegreeByChon } from '@/util/canvas-util' import Big from 'big.js' @@ -822,7 +822,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { type: 'eaveHelpLine', isStart: true, pitch: wallLine.attributes.pitch, - actualSize: (isDiagonal) ? calcLineActualSize( + actualSize: (isDiagonal) ? calcLineActualSize2( { x1: p1.x, y1: p1.y, @@ -1805,7 +1805,7 @@ function processGableEdge(edgeResult, baseLines, skeletonLines, selectBaseLine, function isOuterEdge(p1, p2, edges) { const tolerance = 0.1; return edges.some(edge => { - const lineStart = { x: edge.Begin.X, y: edge.Begin.Y }; + const lineStart = { x: edge.Begin.X, y: edge.Begin.Y } const lineEnd = { x: edge.End.X, y: edge.End.Y }; const forwardMatch = Math.abs(lineStart.x - p1.x) < tolerance && Math.abs(lineStart.y - p1.y) < tolerance && Math.abs(lineEnd.x - p2.x) < tolerance && Math.abs(lineEnd.y - p2.y) < tolerance; const backwardMatch = Math.abs(lineStart.x - p2.x) < tolerance && Math.abs(lineStart.y - p2.y) < tolerance && Math.abs(lineEnd.x - p1.x) < tolerance && Math.abs(lineEnd.y - p1.y) < tolerance; @@ -1848,7 +1848,7 @@ function addRawLine(id, skeletonLines, p1, p2, lineType, color, width, pitch, is p2, attributes: { roofId: id, - actualSize: (isDiagonal) ? calcLineActualSize( + actualSize: (isDiagonal) ? calcLineActualSize2( { x1: p1.x, y1: p1.y, @@ -1869,7 +1869,7 @@ function addRawLine(id, skeletonLines, p1, p2, lineType, color, width, pitch, is }; skeletonLines.push(newLine); - //console.log('skeletonLines', skeletonLines); + console.log('skeletonLines', skeletonLines); } /**