
    aIj                        d Z ddlZddlZddlmZ ej
                  j                  d e ee      j                               ddl
ZddlZddlZddlZddlZdZej*                  dz  ez  Zd Zd Zd Zd	 Zd
 Zedk(  r e        yy)us  s7 — 3라운드: root_C = 외부 fp(fp_l03류)를 기하 SOT 로 앵커한 뿌리 재구축.

진단: 기존 root_A(자체발명)/root_B(production 배치도 상속)가 외부 fp 와 배치
불일치(주거동 축소·계단/설비 위치 오류) → 실외 하류 전체 붕괴. 외부 fp 가 이미
정답 top-down 배치이므로 그것을 직접 재스타일(존→실표면, 실내 미노출)한다.

체인 재검증: root_C → S4_Shot1 마킹 → camview sketch → plate (직행 결론 반영).
산출: out/root/root_C.png, out/outdoor_c/S4_Shot1/
사용: .venv/bin/python s7_root_fp.py [--only root|chain|readback]
    N)PathS4_Shot1	outdoor_cc                 \   | d   D cg c]  }|d   r	|d    }}|D ci c]  }|d c}| d   j                         D ]  }|d   D ]  }|v s|xx   dz  cc<      t        fd	      }| d
   j                  |      xs g }|st        d|       ||d   d   fS c c}w c c}w )u   앵커용 외부 fp 선택 — 데이터 기준: 실외(loc is_indoor=False) loc 의 fp 중
    그룹 실외 샷이 가장 많이 걸린 loc 의 첫 fp.members	is_indoorloc_idr   shotsloc_ids   c                     |    S )N )l
shot_counts    s7_root_fp.py<lambda>z'outdoor_fp_for_anchor.<locals>.<lambda>#   s	    A    )key	fp_by_loczno exterior fp for loc png_path)valuesmaxget
SystemExit)reconmoutdoor_locsr   sbestfpsr   s          @r   outdoor_fp_for_anchorr!      s     */y)9P)9A;AhK)9LP ,-1!Q$-J7^""$9AJ1"  % z67D


 
 
&
,"C24&9::Q
### Q-s   
B$B$
B)c                 l    | j                  d      }| d   j                  |      xs g }|r|d   d   S d S )N
anchor_locr   r   r   )r   )r   anchorr    s      r   indoor_fp_for_boundaryr%   *   s@    YY|$F


 
 
(
.BC!$3q6*.$.r   c                    t        |       \  }}t        |       }dj                  d |d   D              }dj                  d |d   D              }t        j                  | d         }dj                  g ddd	d
ddddddddddddddd|ddd|ddd|ddddd       }|g|r|gng z   }	t        j
                  d!d"||	d#       t        j                  d$||	t        j                  d%z  d&z  '      S )(N
c              3   D   K   | ]  }d |d    d|d    d|d      yw)(idz) name_enu    — 	placementNr   .0es     r   	<genexpr>zroot_c.<locals>.<genexpr>3   s8      4"2Q QtWIR)~U1[>:JK"2s    elementsz, c              3   R   K   | ]  }|d     d|d   j                           ! yw)r*   z: r+   N)upperr-   s     r   r0   zroot_c.<locals>.<genexpr>5   s5      8&6 !"$y1Y<+=+=+?*@A&6s   %'r   zFThe FIRST attached image is the TOP-DOWN zone plan of one real place'szDoutdoor level. Its GEOMETRY is the absolute ground truth: keep everyzEboundary line, every zone's position, size and PROPORTION, the stair,zCthe fixtures and every opening EXACTLY where and how large the planz>puts them. Do not move, resize, mirror or re-arrange anything. zGRedraw that exact layout as ONE hand-drawn TOP-DOWN aerial SITE SKETCH:zDdark ink outlines with light flat colour washes, straight-down view,zDNOT a photograph, NOT 3D. Translate each zone into its real surface:zBan enclosed dwelling zone becomes that dwelling's plain ROOF PLANEzC(never draw its interior rooms or furniture); open zones become thezCworn open terrace surface; a service zone keeps its fixtures (tank,zElaundry line) as drawn; a threshold/entry zone keeps its door and thez-stair stays exactly where the plan places it.uH   The SECOND attached image is the dwelling's indoor floor plan — use itzFONLY to confirm the dwelling's outer boundary shape and where openingsz5sit on that boundary. Never draw any interior layout.zTHE PLACE (production data):zGMark each of the following elements at its position with a small circlez%containing its single capital letter:zEOn the RIGHT side of the image, add a clean legend panel listing eachzCcircled letter with its English name in small neat capital letters:uH   Replace the plan's zone captions and numbers — the circled letters andzGthe legend panel are the ONLY text and the ONLY circular marks allowed.zFAdd a modest margin of the immediate surroundings (neighbouring roofs,zAthe alley the stair descends into) so the place reads in context.infos7)kindstager#   refsroot_C_fp_anchorroot
root_C.pngr9   out_path)r!   r%   joinFmembers_blockrunlogimg_gptOUT)
r   planlocext_fpin_fpel_lineslegend_linesmembers_textpromptr9   s
             r   root_crM   0   s0   '.KC"5)Eyy 4"&z"24 4H99 8&*:&68 8L??5#34LYY "P"N" 	P" 	N	"
 	I" 	" 	R" 	O" 	O" 	M" 	N" 	N" 	P" 	8" 	S"  	Q!"" 	@#"$ 	%"& 	''"( 	)"* 	+", 	R-". 	0/"0 	1"2 	3"4 	P5"6 	N7"8 	9": 	;"< 	S="> 	R?"@ 	QA"B 	LC" "FF 8%wR0DHHft3MN99'deefn|;= =r   c                 x   | d   t            }t        j                  dd       t        j                  dz  dz  }t        |j                  d      xs i j                  d      xs d      }t        j                  j                  |t        j                  |      	      }t        j                  t          d
||gt        dz        }t        j                  t          dt        j                  |gt        dz        }t        j                  t          dt        j                  | ||      ||gt        dz         y )Nr
   T)parentsexist_okr;   r<   stagingcamera_directionr4   )camfigures_rootmark_Czroot_marked.pngr=   
_camview_Cz
sketch.png_plate_Cz	plate.png)SKOUTCmkdirr@   rD   strr   S3MARK_PROMPTformatfigures_clauserC   S5SKETCH_PROMPTplate_prompt)r   	root_planr   root_pngrS   mark_promptmarksketchs           r   chainrh   a   s   grAJJtdJ+uuv~,H
quuY%2**+=>D"
EC..''C9J9J19M'NK99t;'H:"%668DYY"Z("*:*:$ $| 35FIIHoruaCD>D;,>@r   c                     t        j                         } | j                  ddg d       | j                         }t	        j
                         }t	        j                  d      }|j                  dv rt        ||       |j                  dv rt        j                  |d       |j                  d	v rt        ||       t	        j                  d
d|j                  d       y )Nz--onlyall)rj   r;   rh   readback)defaultchoicesrc   )rj   r;   )rj   rk   C)rj   rh   r8   
s7_root_fp)r7   r8   done)argparseArgumentParseradd_argument
parse_argsr@   
load_recon	load_planonlyrM   S1rk   rh   rB   )apargsr   rE   s       r   mainr{   o   s    		 	 	"BOOHe 6BO C==?DLLNE;;{#DyyO#udyy''
D#yy$$eTHHgdiiHIr   __main__)__doc__rq   syspathlibr   pathinsertr[   __file__parent
forest_libr@   forest_chainrn   s1_rootrx   
s3_outdoorr\   	s5_round2r`   rX   rD   rY   r!   r%   rM   rh   r{   __name__r   r   r   <module>r      s   	  
  3tH~,,- .     uu{R$ /.=b@J  zF r   