offset default 50으로 변경,

육각 안되는 모양 수정
This commit is contained in:
hyojun.choi 2024-08-02 17:05:15 +09:00
parent 912e433f6a
commit f20be4f0af
2 changed files with 85 additions and 46 deletions

View File

@ -1091,7 +1091,7 @@ export function useMode() {
/** /**
* 지붕 외곽선 생성 polygon을 입력받아 만들기 * 지붕 외곽선 생성 polygon을 입력받아 만들기
*/ */
const handleOuterlinesTest2 = (polygon, offset = 71) => { const handleOuterlinesTest2 = (polygon, offset = 50) => {
const offsetPoints = offsetPolygon(polygon.points, offset) const offsetPoints = offsetPolygon(polygon.points, offset)
const roof = makePolygon( const roof = makePolygon(

View File

@ -253,6 +253,10 @@ export const drawHelpLineInHexagon = (polygon, chon) => {
name: 'hip', name: 'hip',
}) })
if (line.length === 0) {
return
}
line.startPoint = ridgePoint line.startPoint = ridgePoint
line.endPoint = filteredCenterInterSectionPoints line.endPoint = filteredCenterInterSectionPoints
@ -283,6 +287,7 @@ export const drawHelpLineInHexagon = (polygon, chon) => {
const startPoint = remainingPoints.shift() const startPoint = remainingPoints.shift()
const endPoint = remainingPoints.shift() const endPoint = remainingPoints.shift()
if (!(startPoint.x === endPoint.x && startPoint.y === endPoint.y)) {
const line = new QLine([startPoint.x, startPoint.y, endPoint.x, endPoint.y], { const line = new QLine([startPoint.x, startPoint.y, endPoint.x, endPoint.y], {
stroke: 'purple', stroke: 'purple',
fontSize: polygon.fontSize, fontSize: polygon.fontSize,
@ -331,6 +336,25 @@ export const drawHelpLineInHexagon = (polygon, chon) => {
}) })
polygon.canvas.add(line) polygon.canvas.add(line)
} else {
polygon.points.forEach((point) => {
const degree = calculateAngle(startPoint, point)
if (Math.abs(degree) === 45 || Math.abs(degree) === 135) {
const line = new QLine([startPoint.x, startPoint.y, point.x, point.y], {
stroke: 'purple',
fontSize: polygon.fontSize,
name: 'hip',
})
line.startPoint = startPoint
line.endPoint = point
polygon.hips.push(line)
polygon.canvas.add(line)
}
})
}
} }
} }
@ -485,9 +509,8 @@ export const dividePolygon = (polygon) => {
} }
}) })
hips = [...hips, ...connectRidges] hips = [...hips, ...connectRidges]
polygon.setViewLengthText(false)
polygonLines.forEach((line) => { polygonLines.forEach((line, index) => {
let ridge let ridge
const startPoint = line.startPoint const startPoint = line.startPoint
@ -522,15 +545,31 @@ export const dividePolygon = (polygon) => {
return return
} }
let connectedRidge = ridges.find( let connectedRidge
const restRidgeConnection = connectRidges[0]
if (!restRidgeConnection || restRidgeConnection.length === 0) {
connectedRidge = ridges.find(
(ridge) =>
(ridge.startPoint.x === startHip.endPoint.x &&
ridge.startPoint.y === startHip.endPoint.y &&
ridge.endPoint.x === endHip.endPoint.x &&
ridge.endPoint.y === endHip.endPoint.y) ||
(ridge.startPoint.x === endHip.endPoint.x &&
ridge.startPoint.y === endHip.endPoint.y &&
ridge.endPoint.x === startHip.endPoint.x &&
ridge.endPoint.y === startHip.endPoint.y),
)
} else {
connectedRidge = ridges.find(
(ridge) => (ridge) =>
(ridge.startPoint.x === startHip.endPoint.x && ridge.startPoint.y === startHip.endPoint.y) || (ridge.startPoint.x === startHip.endPoint.x && ridge.startPoint.y === startHip.endPoint.y) ||
(ridge.endPoint.x === startHip.endPoint.x && ridge.endPoint.y === startHip.endPoint.y), (ridge.endPoint.x === startHip.endPoint.x && ridge.endPoint.y === startHip.endPoint.y),
) )
}
const hipStartPoint = startHip.endPoint const hipStartPoint = startHip.endPoint
const hipEndPoint = endHip.endPoint const hipEndPoint = endHip.endPoint
const restRidgeConnection = connectRidges[0]
if (connectedRidge.startPoint.x === hipStartPoint.x && connectedRidge.startPoint.y === hipStartPoint.y) { if (connectedRidge.startPoint.x === hipStartPoint.x && connectedRidge.startPoint.y === hipStartPoint.y) {
if (connectedRidge.endPoint.x === hipEndPoint.x && connectedRidge.endPoint.y === hipEndPoint.y) { if (connectedRidge.endPoint.x === hipEndPoint.x && connectedRidge.endPoint.y === hipEndPoint.y) {