
    ^jt                        d Z ddlmZ ddlZddlZddlmZ ddlm	Z	m
Z
mZmZ ddlmZ ddZedk(  r< eej"                  d	   ej"                  d
           edej"                  d
           yy)u  Seat coupon — a cheap test-fit print before committing to cast.

Cuts the HEAD of the fused body (seat, prongs, shoulder stubs) onto a flat
base tab. The jeweler prints it in ordinary rigid resin and drops the REAL
diamond in: verifies girdle diameter and level seating for pennies. Exported
at NOMINAL dims (it simulates the post-cast metal, not the shrink-compensated
print). Rigid resin has no prong spring — it checks the seat, not the set.
    )annotationsN)Path)AlignBoxPos
export_stl)_make_watertightc           	        t        |       }t        j                  j                  d|      }t        j                  j	                  |      }t
        j                  j                  dt        |j                               |j                  j                  |       ddlm}  ||j                        }|j                         }|d   dz
  }d|d   dz  dz   z  }	t!        dd|      t#        |	|	d	t$        j&                  t$        j&                  t$        j(                  f
      z  }
||
z  }t!        dd|dz         t#        |	dz
  |	dz
  dt$        j&                  t$        j&                  t$        j*                  f
      z  }||z   }|j-                         }t/        |d       }t1        |      dkD  r:|j2                  dt5        d |D              z  k  rt7        dt1        |       d      t9        ||dd       t;        |       y )Ngen_modr   )	head_dimsouter_rg      ?   stone_lg      @(   )aligng{Gz?g      ?c                    | j                   S Nvolume)ss     /opt/ringagent/ringcli/coupon.py<lambda>zexport_coupon.<locals>.<lambda>(   s
    QXX     )key   gffffff?c              3  4   K   | ]  }|j                     y wr   r   ).0r   s     r   	<genexpr>z export_coupon.<locals>.<genexpr>)   s     3MAHH3Ms   zcoupon split into z solidsg333333?)	toleranceangular_tolerance)r   	importlibutilspec_from_file_locationmodule_from_specsyspathinsertstrparentloaderexec_moduleringcli.templatesr   SPEC	gen_metalr   r   r   CENTERMINMAXsolidsmaxlenr   sumRuntimeErrorr   r	   )gen_pathout_stlgenspecmodr   hdbodyz_cutwkeepheadtabcouponr2   mains                   r   export_couponrE      s   
x.C>>11)SAD
..
)
)$
/CHHOOAs3::'KKC +	388	B==?DyMCE	R	]Q$%Aq!Uc!Q5<<38993> ? ?D$;D
aEDL
!CCS#/4||U\\/4yy/:%; ;C CZF]]_Fv-.D
6{Q4;;3Mf3M0M)MM/F}GDEEtWDWr   __main__r   r   zcoupon STL: )r7   r(   r8   r(   returnNone)__doc__
__future__r   importlib.utilr!   r%   pathlibr   	build123dr   r   r   r   ringcli.castr	   rE   __name__argvprint r   r   <module>rS      sf    #  
  1 1 )4 z#((1+sxx{+	L!
&' r   