Files
Pier_v1/도면작성/frame-quality.ts
T
2026-11-04 13:34:51 +09:00

17 lines
1.4 KiB
TypeScript

import { templateFrame } from './template';
import { entityBox } from './occupancy';
import type { DrawingDocument,Point,QualityIssue } from './types';
/** Keep the supplied frame unchanged, but flag edited values which cannot fit their original cells. */
export function frameQuality(doc:DrawingDocument):QualityIssue[]{
const frame=templateFrame(doc),edges:Point[][]=[];
for(const e of frame){if(e.kind==='line')edges.push([e.a,e.b]);else if(e.kind==='polyline'){e.points.slice(1).forEach((b,i)=>edges.push([e.points[i],b]));if(e.closed)edges.push([e.points[e.points.length-1],e.points[0]]);}}
const issues:QualityIssue[]=[];
for(const e of frame)if(e.kind==='text'&&e.source.member.startsWith('frame-field:')&&!e.rotation){
const box=entityBox(e),right=edges.filter(([a,b])=>Math.abs(a[0]-b[0])<.01&&a[0]>e.point[0]+.01&&Math.min(a[1],b[1])<=e.point[1]&&Math.max(a[1],b[1])>=e.point[1]).map(([a])=>a[0]);
const limit=right.length?Math.min(...right):doc.paper.width;
if(box.maxX>limit-.2)issues.push({view:'sheet',kind:'outside',first:-2,message:`표제란 ${e.source.member.slice(12)} 문자가 원본 셀 폭을 넘습니다. 도곽 편집에서 내용을 줄이거나 사용자 도곽을 적용하세요.`});
}
if(doc.warnings.some(w=>w.startsWith('NOTE 원문이')))issues.push({view:'sheet',kind:'outside',first:-2,message:'NOTE 내용이 원본 일반사항 영역을 넘습니다.'});
return issues;
}