Files
Pier_v1/RAG/design-model-box-sample_2/tools/publish_slab_tie_contacts.py
T
ahnyongjooandClaude Sonnet 5.5 964a841de1 chore(rebar): Pier_T_rebar 작업 폴더 초기 구성 및 외부 의존 파일 통합
- Code\rebar_pipeline, review_pipeline, pier-program을 정션에서 실제 폴더로 전환
- Code\rhino_mcp 및 CLAUDE_rhino배경.md 추가, .mcp.json은 PYTHONPATH로 새 위치 사용
- pier-program 내부 .git 제거(이력은 backup\pier-program_20261028.bundle에 보관)
- worktree 가이드 반영(CLAUDE.local.md, HANDOFF.md)
- D:\Rhino-MCP 경로 참조를 새 위치로 치환

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 11:20:18 +09:00

52 lines
3.0 KiB
Python

"""Apply the authorized inward contact rule without changing other geometry."""
import argparse,copy,json,math,os,sys,tempfile,time
from pathlib import Path
root=Path(__file__).resolve().parents[1]
sys.path.insert(0,str(root/'src/backend'if (root/'src/backend').is_dir()else root))
from slab_tie_contact import retarget_slab_returns
def main():
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('job',type=Path);parser.add_argument('--apply',action='store_true')
parser.add_argument('--walls',action='store_true')
args=parser.parse_args();raw=args.job.read_bytes();job=json.loads(raw)
if job.get('status')not in ('awaiting_feedback','completed','failed'):raise ValueError('active job')
old=job['result']
if args.walls:
from wall_tie_contact import retarget_wall_ties
new,summary=retarget_wall_ties(old,apply=True)
else:new,summary=retarget_slab_returns(old,apply_inward=True)
changed={s['id']for s in summary}
assert old['concrete_components']==new['concrete_components']
for a,b in zip(old['rebar_groups'],new['rebar_groups']):
assert a['id']==b['id']
if a['id']not in changed:assert a==b;continue
assert a['count']==b['count'] and a['host_component_ids']==b['host_component_ids']
assert b['attachment_check']['pass'],b['id']
for pa,pb in zip(a['instance_paths_m'],b['instance_paths_m']):
assert len(pa)==len(pb)
shifts=[[y-x for x,y in zip(p,q)]for p,q in zip(pa,pb)]
if args.walls:
for i in range(len(pa)):
for j in range(i):assert abs(math.dist(pa[i],pa[j])-math.dist(pb[i],pb[j]))<1e-8
assert abs((pa[1][0]+pa[2][0]-pb[1][0]-pb[2][0])/2)<1e-8
else:
assert all(math.dist(shifts[0],s)<1e-8 for s in shifts)
assert abs(shifts[0][0])<1e-8
new['drawingEvidence'].setdefault('preview_geometry',{})['rebar_groups']=copy.deepcopy(new['rebar_groups'])
new['drawingEvidence']['wall_tie_contact_audit'if args.walls else 'slab_tie_contact_audit']={'rule':'wall-face-contact-v1'if args.walls else 'slab-face-inward-contact-v1','groups':summary,
'concrete_and_unrelated_rebar_preserved':True,'detail_lengths_and_counts_preserved':True,
'structural_or_full_clash_approval':False}
print(json.dumps({'applied':args.apply,'groups':summary},ensure_ascii=False),flush=True)
if not args.apply:return
backup=args.job.with_name(args.job.stem+f'.before-slab-contact-{time.time_ns()}.json')
with backup.open('xb')as f:f.write(raw)
job.update(result=new,partialResult=copy.deepcopy(new),geometryRevision=time.time_ns())
with tempfile.NamedTemporaryFile(mode='w',dir=args.job.resolve().parent,delete=False)as f:
json.dump(job,f,ensure_ascii=False,allow_nan=False);temporary=f.name
if args.job.read_bytes()!=raw:raise ValueError('concurrent modification; not published')
os.replace(temporary,args.job.resolve())
print('backup: '+str(backup))
if __name__=='__main__':main()