import type { PierModel } from '../src/core/geometry'; import type { PierInput } from '../src/core/types'; import { localPoint,projectPoint } from './projection'; import type { Entity,ViewId,Bounds,Point } from './types'; /** Survey labels refer to actual model corners; X=Northing, Y=Easting. */ export function foundationNotes(model:PierModel,input:PierInput,id:ViewId,b:Bounds,scale:number):Entity[]{ const out:Entity[]=[],source={pier:model.name,member:'annotation',index:0}; const text=(point:Point,text:string,align:'left'|'right'='left')=>out.push({kind:'text',point,text,height:2.5*scale,align,layer:'TEXT',source}); const line=(a:Point,b:Point)=>out.push({kind:'line',a,b,layer:'TEXT',source}); if(id==='footing')model.footings.forEach((f,index)=>{ const corners=[[-1,-1],[-1,1],[1,-1],[1,1]].map(([s,n])=>{ const world=localPoint(model,f.k,f.s+s*f.length/2,f.top,n*f.width/2); return {point:projectPoint(model,world,id),e:world.x+model.pivot.e,n:-world.z+model.pivot.n}; }); corners.sort((a,b)=>b.point[1]-a.point[1]); const ordered=[...corners.slice(0,2).sort((a,b)=>a.point[0]-b.point[0]),...corners.slice(2).sort((a,b)=>a.point[0]-b.point[0])]; for(const [i,c] of ordered.entries()){const right=i%2===1,upper=i<2,sign=right?1:-1; const x=(right?b.maxX:b.minX),y=(upper?b.maxY+(8+index*8)*scale:b.minY-(12+index*8)*scale); line(c.point,[x-sign*scale,y]);line([x-sign*scale,y],[x,y]); text([x,y+3.5*scale],`X(N) ${c.n.toFixed(3)}`,right?'right':'left'); text([x,y],`Y(E) ${c.e.toFixed(3)}`,right?'right':'left'); } }); if((id==='front'||id==='side')&&model.piles.length){ const pile=model.piles[0],anchor=projectPoint(model,localPoint(model,pile.k,pile.s,pile.top-.2,pile.n),id); const x=b.minX,y=b.minY-25*scale; line(anchor,[x-scale,y]);line([x-scale,y],[x+12*scale,y]); const lengths=model.piles.map(p=>p.top-p.bottom),lo=Math.min(...lengths),hi=Math.max(...lengths); text([x,y+3.5*scale],`${input.pileKind??'종류 미확인'} 말뚝 · ${model.piles.length}본`); text([x,y],`Ø${(pile.diameter*1000).toFixed(1)}${input.pileThicknessMm!=null?' × t'+input.pileThicknessMm:''}`); text([x,y-3.5*scale],`L=${lo.toFixed(3)}${hi-lo>.0005?'~'+hi.toFixed(3):''} m`); } return out; }