-í
 ´§Ec       s‰     d  k  Z   d  k Z  d  k Z  d  k Z 	 d a 
 d a  d a  d a  d Z	  d f  d „  ƒ  YZ
  d f  d „  ƒ  YZ N d „  Z o d „  Z ˆ d a ‰ d a Š d a ‹ d a Œ d a  g  a Ž g  a  g  Z ‘ d	 „  Z ­ d
 „  Z Ò d „  Z ú d „  Z ,g  e d „ Z ig  e d „ Z rg  e d „ Z d „  Z ¥e d j o ¦e i  e ƒ  ƒ n d  S(   Ni    i   s   Pointc      s     d „  Z  RS(   Nc    s9     | d }  | d }  | |  _  | |  _ d  S(   Ni    i   (   s   points   xs   ys   self(   s   selfs   points   ys   x(    (    s   vectorcut.pys   __init__ s   (   s   __init__(    (    (    s   vectorcut.pys   Point s   s	   Rectanglec      sn     d d f d d f f d „ Z  % d „  Z / d „  Z 2 d „  Z 5 d „  Z 8 d „  Z ; d „  Z RS(	   Ni    c    s?    ! | |  _  " t | d ƒ |  _ # t | d ƒ |  _ d  S(   Ni    i   (   s   rects   selfs   Points
   bottomLefts   topRight(   s   selfs   rect(    (    s   vectorcut.pys   __init__ s   c    s‚   % ' | i |  i i j  p | i |  i i j o ( d Sn * | i |  i i j  p | i |  i i j o + d Sn - d Sd  S(   Ni    i   (   s   ps   xs   selfs
   bottomLefts   topRights   y(   s   selfs   p(    (    s   vectorcut.pys   containsPoint% s
   //c    s   / 0 |  i i | j Sd  S(   N(   s   selfs
   bottomLefts   y(   s   selfs   y(    (    s   vectorcut.pys   aboveVertical/ s   c    s   2 3 |  i i | j  Sd  S(   N(   s   selfs   topRights   y(   s   selfs   y(    (    s   vectorcut.pys   belowVertical2 s   c    s   5 6 |  i i | j  Sd  S(   N(   s   selfs   topRights   x(   s   selfs   x(    (    s   vectorcut.pys   leftOfHorizontal5 s   c    s   8 9 |  i i | j Sd  S(   N(   s   selfs
   bottomLefts   x(   s   selfs   x(    (    s   vectorcut.pys   rightOfHorizontal8 s   c    sž   ; > |  i | i i ƒ o ? d Sn A |  i | i i ƒ o B d Sn D |  i | i i ƒ o E d Sn G |  i	 | i i ƒ o H d Sn K d Sd  S(   Ni    i   (
   s   selfs   aboveVerticals   rects   topRights   ys   belowVerticals
   bottomLefts   leftOfHorizontals   xs   rightOfHorizontal(   s   selfs   rect(    (    s   vectorcut.pys   overlaps; s   (   s   __init__s   containsPoints   aboveVerticals   belowVerticals   leftOfHorizontals   rightOfHorizontals   overlaps(    (    (    s   vectorcut.pys	   Rectangle s   !
c    sî   N R T |  \ } } U | \ } }	 Z | | j o [ | d } \ | d } n% ^ t | | ƒ } _ t	 | | ƒ } b | |	 j o c | d } d |	 d } n% f t | |	 ƒ } g t	 | |	 ƒ } j | | f | | f f }
 l |
 Sd S(   sº   Calculate the bounding box around a line segment. To be thorough, look
       for vertical and horizontal lines are well and assume they have a width
       or a height (as needed).
    i   N(   s   pointAs   x1s   y1s   pointBs   x2s   y2s
   lowerLeftXs   upperRightXs   mins   maxs
   lowerLeftYs   upperRightYs   bBox(   s   pointAs   pointBs
   lowerLeftYs   x1s
   lowerLeftXs   y1s   upperRightYs   upperRightXs   x2s   y2s   bBox(    (    s   vectorcut.pys   calcBoundingBoxN s   c    s|   o r s v t  |  | ƒ } y t | ƒ } | t t t f t t t t	 f f ƒ } € | i | ƒ o  d Sn ƒ d Sd S(   sq   Given a line segment with two points, see if the segment is visible
       within our specified "view port".
    i   i    N(   s   calcBoundingBoxs   pointAs   pointBs   bBoxs	   Rectangles   boundingBoxs   _originXs   _originYs   _widths   _heights   mapViews   overlaps(   s   pointAs   pointBs   bBoxs   boundingBoxs   mapView(    (    s   vectorcut.pys   visibilityTesto s   )c    sÎ   ‘ ’ ” — e  | d ƒ a š h  } › e | d <œ e | d < e | d <ž e | d <£ e  |  d ƒ } ¤ | i
 ƒ  } ¥ x1 ¥ | d j o  ¦ | | | U§ | i
 ƒ  } q W¨ | i ƒ  ª t i ƒ  d S(	   s/   Execute a vector file and collect its contents.s   wbs
   setExtentss   addPolylines
   addPolygons   addBezierCurves   rs    N(   s   opens   outputs   _fds   nss
   setExtentss   addPolylines
   addPolygons   addBezierCurves   names   fs   readlines   lines   close(   s   names   outputs   fs   lines   ns(    (    s   vectorcut.pys   cutVectorFile‘ s    	 c 	   s  ­ ® ¯ d } ° d } µ t t t d d ƒ } ¶ t t t d d ƒ } · g  } ¹ xÝ t
 t |  ƒ ƒ D¹ ]Æ } º | d j o+ » | i |  | ƒ ¼ |  | \ } } n† ¾ |  | \ } } Â | | | j p0 | | | j p | | | j p | | | j o+ Ç | i |  | ƒ È |  | \ } } n qk WË t | ƒ d j o6 Í | | f |  d j o Ï | i |  d ƒ n n Ð | Sd  S(   Ni    i   i
   i   iÿÿÿÿ(   s   lastXs   lastYs   mins   _widths   _finalWs	   minDeltaXs   _heights   _finalHs	   minDeltaYs   updatedLists   ranges   lens
   vectorLists   iis   appends   currXs   currY(	   s
   vectorLists   iis   currXs   currYs   updatedLists	   minDeltaYs	   minDeltaXs   lastYs   lastX(    (    s   vectorcut.pys   simplifyLines­ s&   			 	Gc    sð   Ò Õ × Ø Û t  |  ƒ d j  o Ü g  Sn Þ d } ß xƒ t t  |  ƒ d ƒ Dß ]h } á |  | } â |  | d } ä t | | ƒ o. ë | d j  o ì | } n í | d } n ð qP Wò | d j o ó |  | | d !Sn õ g  Sd S(   sz   Do the points in the points list exist within the specified map
       cut?? Return the list of points where this is true.i   iÿÿÿÿi   i    N(	   s   lens
   pointsLists   firstPointNdxs   ranges   iis   pointAs   pointBs   visibilityTests   lastPointNdx(   s
   pointsLists   datas   lastPointNdxs   pointAs   pointBs   firstPointNdxs   ii(    (    s   vectorcut.pys   validCoordinatesÒ s$   	 	c    s"  ú ý ÿ  d d f |  | f f a t t f t t t t f f a t t t	 t t t	 j  p t t t	 t t
 t	 j o' t i i d ƒ t i d ƒ n t t t t t t j  p t t t t t
 t j o' t i i d ƒ t i d ƒ n t t
 t	 t t
 t	 j o' t i i d ƒ t i d ƒ n t t
 t t t
 t j o' t i i d ƒ t i d ƒ n t i d d ƒ } t i | ƒ #t i d	 d
 d
 ƒ } $t i | ƒ (t i d	 t t ƒ } )t i | ƒ d S(   sb   The origin is assumed to be 0,0 and this function defined the maximum
       extents of the image.i    s   Cut Extent X is out of rangeiÿÿÿÿs   Cut Extent Y is out of ranges"   Cut Width + Origin is out of ranges#   Cut Height + Origin is out of ranges   6ss   VG10s   fff0.0N(   s   maxWidths	   maxHeights   _maxExtentss   _originXs   _originYs   _widths   _heights   _cutExtentss   LOWERs   Xs   UPPERs	   twccommons   Logs   errors   syss   exits   Ys   structs   packs   versions   _fds   writes   origins   _finalWs   _finalHs   viewSize(   s   maxWidths	   maxHeights   origins   viewSizes   version(    (    s   vectorcut.pys
   setExtentsú s4   #==  c    sî  ,/124t  |  | ƒ }	 7|	 o t |	 ƒ o
 t d j oH 9t |	 d j o ;t f |	 }	 n >t i	 i
 d ƒ ?d a n At |	 ƒ } Dt | ƒ d j oþ Gt i d t ƒ }
 Ht i |
 ƒ Kt i d | d d !ƒ } Lt i | ƒ Ot i d t | ƒ ƒ } Pt i | ƒ Rxo | DR]d } St | d t t ƒ } Tt | d t t ƒ } Vt i d | | ƒ } Wt i | ƒ q5WZd a n> ]t | ƒ d j o' _|	 d a b|	 d	 a ed a n d
 S(   sl   This function accepts a list of line segments that should be connected
       sequentially to create a line.i   i    s'   addPolyline() Discarding short segment.s   is   6si   s   ls   iiiÿÿÿÿN(   s   validCoordinatess
   pointsLists   datas   croppedLists   lens   _undrawnSegments   _undrawnEnds   _undrawnStarts	   twccommons   Logs   infos   simplifyLiness   updatedLists   structs   packs   POLYLINEs   types   _fds   writes   names	   numPointss   points   ints   _originXs   _scaleXs   xs   _originYs   _scaleYs   ys   xyPoint(   s
   pointsLists   datas   points   updatedLists	   numPointss   names   xyPoints   ys   xs   croppedLists   type(    (    s   vectorcut.pys   addPolyline,s8   $
 	c    s   impt  i i d ƒ d S(   s™   This function accepts a list of points that should be connected
       sequentially (INCLUDING connecting the last point back to the 
       first point.s5   addPolygon() not supported in this release. Ignoring.N(   s	   twccommons   Logs   warning(   s
   pointsLists   data(    (    s   vectorcut.pys
   addPolygonis   c    s!   ruyt  |  | ƒ zd Sd S(   sf   This function accepts a list of points that should be connected
       sequentially to create a curve.N(   s   addPolylines
   pointsLists   data(   s
   pointsLists   data(    (    s   vectorcut.pys   addBezierCurvers   c     s  ‚„t  t i ƒ d j  o& …t i i d ƒ †d GH‡d Sn ‰t i i d ƒ ‹t i d } Œt i d } t i d }  |  i
 d	 ƒ } ’t | d
 ƒ a “t | d ƒ a ”t t i d ƒ a •t t i d ƒ a —t t i d ƒ a ˜t t i d ƒ a œt t ƒ t t ƒ a t t ƒ t t ƒ a Ÿd
 a ¡t i i d | ƒ £t | | ƒ d  S(   Ni   s   Bad command line. Aborting.sV   Usage: vectorcut inputFile outputFile lowerLeftX,lowerLeftY width height finalW finalHiÿÿÿÿs	   vectorcuti   i   i   s   ,i    i   i   i   i   s   Creating vector cut using %s(   s   lens   syss   argvs	   twccommons   Logs   errors   setIdents   names   outputs	   lowerLefts   splits   origins   ints   _originXs   _originYs   _widths   _heights   _finalWs   _finalHs   floats   _scaleXs   _scaleYs   _undrawnSegments   infos   cutVectorFile(   s	   lowerLefts   names   outputs   origin(    (    s   vectorcut.pys   mains,   	s   __main__(!   s   oss   syss   structs   twccommon.Logs	   twccommons   Xs   Ys   LOWERs   UPPERs   POLYLINEs   Points	   Rectangles   calcBoundingBoxs   visibilityTests   _fds   _widths   _heights   _originXs   _originYs   _maxExtentss   _cutExtentss
   _pointLists   cutVectorFiles   simplifyLiness   validCoordinatess
   setExtentss   Nones   addPolylines
   addPolygons   addBezierCurves   mains   __name__s   exit(   s
   addPolygons   calcBoundingBoxs   validCoordinatess   syss   POLYLINEs   addBezierCurves
   _pointLists	   Rectangles   mains   structs   visibilityTests   Points
   setExtentss	   twccommons   cutVectorFiles   addPolylines   oss   simplifyLines(    (    s   vectorcut.pys   ? s<   					1!								%(2=	&