/ *   
 
   *   P R O J E C T :   N y A R T o o l k i t 
 
   *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   *   T h i s   w o r k   i s   b a s e d   o n   t h e   o r i g i n a l   A R T o o l K i t   d e v e l o p e d   b y 
 
   *       H i r o k a z u   K a t o 
 
   *       M a r k   B i l l i n g h u r s t 
 
   *       H I T L a b ,   U n i v e r s i t y   o f   W a s h i n g t o n ,   S e a t t l e 
 
   *   h t t p : / / w w w . h i t l . w a s h i n g t o n . e d u / a r t o o l k i t / 
 
   * 
 
   *   T h e   N y A R T o o l k i t   i s   J a v a   e d i t i o n   A R T o o l K i t   c l a s s   l i b r a r y . 
 
   *   C o p y r i g h t   ( C ) 2 0 0 8 - 2 0 0 9   R y o   I i z u k a 
 
   * 
 
   *   T h i s   p r o g r a m   i s   f r e e   s o f t w a r e :   y o u   c a n   r e d i s t r i b u t e   i t   a n d / o r   m o d i f y 
 
   *   i t   u n d e r   t h e   t e r m s   o f   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e   a s   p u b l i s h e d   b y 
 
   *   t h e   F r e e   S o f t w a r e   F o u n d a t i o n ,   e i t h e r   v e r s i o n   3   o f   t h e   L i c e n s e ,   o r 
 
   *   ( a t   y o u r   o p t i o n )   a n y   l a t e r   v e r s i o n . 
 
   *   
 
   *   T h i s   p r o g r a m   i s   d i s t r i b u t e d   i n   t h e   h o p e   t h a t   i t   w i l l   b e   u s e f u l , 
 
   *   b u t   W I T H O U T   A N Y   W A R R A N T Y ;   w i t h o u t   e v e n   t h e   i m p l i e d   w a r r a n t y   o f 
 
   *   M E R C H A N T A B I L I T Y   o r   F I T N E S S   F O R   A   P A R T I C U L A R   P U R P O S E .     S e e   t h e 
 
   *   G N U   G e n e r a l   P u b l i c   L i c e n s e   f o r   m o r e   d e t a i l s . 
 
   * 
 
   *   Y o u   s h o u l d   h a v e   r e c e i v e d   a   c o p y   o f   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e 
 
   *   a l o n g   w i t h   t h i s   p r o g r a m .     I f   n o t ,   s e e   < h t t p : / / w w w . g n u . o r g / l i c e n s e s / > . 
 
   *   
 
   *   F o r   f u r t h e r   i n f o r m a t i o n   p l e a s e   c o n t a c t . 
 
   * 	 h t t p : / / n y a t l a . j p / n y a t o o l k i t / 
 
   * 	 < a i r m a i l ( a t ) e b o n y . p l a l a . o r . j p >   o r   < n y a t l a ( a t ) n y a t l a . j p > 
 
   *   
 
   * / 
 
 u s i n g   S y s t e m . D i a g n o s t i c s ; 
 
 n a m e s p a c e   j p . n y a t l a . n y a r t o o l k i t . c s . c o r e 
 
 { 
 
 
 
         / * * 
 
           *   S0n0000o00*}n0bQ000g0Y00
 
           *   ;uP-Nn0p0Yph0W0f00eMOc"}g0*}0bQW0~0Y00QRo0*퐹pn0MRg0Y00
 
           *   < p > eQRg0M00;u }b__  -   { @ l i n k   # g e t C o n t o u r } k0eQRg0M00;u }b__k06RPL0B00~0Y00< b r / > 
 
           *   { @ l i n k   N y A R B i n R a s t e r } 
 
           *   < u l > 
 
           *   < l i > { @ l i n k   N y A R B u f f e r T y p e # I N T 1 D _ B I N _ 8 } 
 
           *   < / u l > 
 
           *   { @ l i n k   N y A R G r a y s c a l e R a s t e r } 
 
           *   < u l > 
 
           *   < l i > { @ l i n k   N y A R B u f f e r T y p e # I N T 1 D _ G R A Y _ 8 } 
 
           *   < / u l > 
 
           *   < / p > 
 
           * / 
 
         p u b l i c   c l a s s   N y A R C o n t o u r P i c k u p 
 
         { 
 
                 p u b l i c   i n t e r f a c e   I R a s t e r D r i v e r 
 
                 { 
 
                         b o o l   g e t C o n t o u r ( i n t   i _ l ,   i n t   i _ t ,   i n t   i _ r ,   i n t   i _ b ,   i n t   i _ e n t r y _ x ,   i n t   i _ e n t r y _ y ,   i n t   i _ t h ,   N y A R I n t C o o r d i n a t e s   o _ c o o r d ) ; 
 
                 } 
 
                 p u b l i c   s t a t i c   c l a s s   I m a g e D r i v e r F a c t o r y 
 
                 { 
 
                         p u b l i c   s t a t i c   I R a s t e r D r i v e r   c r e a t e D r i v e r ( I N y A R G r a y s c a l e R a s t e r   i _ r e f _ r a s t e r ) 
 
                         { 
 
                                 s w i t c h   ( i _ r e f _ r a s t e r . g e t B u f f e r T y p e ( ) ) 
 
                                 { 
 
                                         c a s e   N y A R B u f f e r T y p e . I N T 1 D _ G R A Y _ 8 : 
 
                                         c a s e   N y A R B u f f e r T y p e . I N T 1 D _ B I N _ 8 : 
 
                                                 r e t u r n   n e w   N y A R C o n t o u r P i c k u p _ B I N _ G S 8 ( i _ r e f _ r a s t e r ) ; 
 
                                         d e f a u l t : 
 
                                                 i f   ( i _ r e f _ r a s t e r   i s   N y A R C o n t o u r P i c k u p _ G s R e a d e r ) 
 
                                                 { 
 
                                                         r e t u r n   n e w   N y A R C o n t o u r P i c k u p _ G s R e a d e r ( ( I N y A R G r a y s c a l e R a s t e r ) i _ r e f _ r a s t e r ) ; 
 
                                                 } 
 
                                                 b r e a k ; 
 
                                 } 
 
                                 t h r o w   n e w   N y A R E x c e p t i o n ( ) ; 
 
                         } 
 
                 } 
 
                 / * *    g_k0QtW0_0000* / 
 
                 p r i v a t e   I N y A R R a s t e r   _ r e f _ l a s t _ i n p u t _ r a s t e r   =   n u l l ; 
 
                 p r i v a t e   I R a s t e r D r i v e r   _ i m d r i v e r ; 
 
 
 
                 / * * 
 
                   *   S0n0peo00000n0c[p0Wpk00*}0bQW0~0Y00
 
                   *   Ypo00*n0 Ng0B00_L0B00~0Y00
 
                   *   8^o000y0000n0P}gn0
N0000h0X 000000000Yph0W0f0eQRW0~0Y00
 
                   *   @ p a r a m   i _ r a s t e r 
 
                   *   *}0bQY000000c[W0~0Y00
 
                   *   @ p a r a m   i _ t h 
 
                   *   *h00j0Y0fpn0weE\$P0c[W0~0Y00
 
                   *   @ p a r a m   i _ e n t r y _ x 
 
                   *   *퐽bQn0Ypg0Y00
 
                   *   @ p a r a m   i _ e n t r y _ y 
 
                   *   *퐽bQn0Ypg0Y00
 
                   *   @ p a r a m   o _ c o o r d 
 
                   *   *퐹p0<h
}Y00MR0c[W0~0Y00i _ a r r a y _ s i z e 000'YM0j0000n0MRL0_g0Y00
 
                   *   @ r e t u r n 
 
                   *   *n0bQk0bRY00h0t r u e 0ԏW0~0Y00*퐽bQk0ASRj00000L0!qD0h00f a l s e k0j00~0Y00
 
                   *   @ 
 
                   * / 
 
                 p u b l i c   b o o l   g e t C o n t o u r ( I N y A R G r a y s c a l e R a s t e r   i _ r a s t e r ,   i n t   i _ t h ,   i n t   i _ e n t r y _ x ,   i n t   i _ e n t r y _ y ,   N y A R I n t C o o r d i n a t e s   o _ c o o r d ) 
 
                 { 
 
                         N y A R I n t S i z e   s   =   i _ r a s t e r . g e t S i z e ( ) ; 
 
                         / / 0000000n0R0fH0
 
                         i f   ( i _ r a s t e r   ! =   t h i s . _ r e f _ l a s t _ i n p u t _ r a s t e r ) 
 
                         { 
 
                                 t h i s . _ i m d r i v e r   =   ( I R a s t e r D r i v e r ) i _ r a s t e r . c r e a t e I n t e r f a c e ( t y p e o f ( I R a s t e r D r i v e r ) ) ; 
 
                                 t h i s . _ r e f _ l a s t _ i n p u t _ r a s t e r   =   i _ r a s t e r ; 
 
                         } 
 
                         r e t u r n   t h i s . _ i m d r i v e r . g e t C o n t o u r ( 0 ,   0 ,   s . w   -   1 ,   s . h   -   1 ,   i _ e n t r y _ x ,   i _ e n t r y _ y ,   i _ t h ,   o _ c o o r d ) ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00000n0c[p0Wpk00;uPn0yr[n0{VQK00*}0bQW0~0Y00
 
                   *   Ypo00*n0 Ng0B00_L0B00~0Y00
 
                   *   8^o000y0000n0P}gn0
N0000h0X 000000000Yph0W0f0eQRW0~0Y00
 
                   *   @ p a r a m   i _ r a s t e r 
 
                   *   *}0bQY000000c[W0~0Y00
 
                   *   @ p a r a m   i _ a r e a 
 
                   *   *}n0bQ{V0c[Y00wb_0i _ r a s t e r n0000Qg0B00_L0B00~0Y00
 
                   *   @ p a r a m   i _ t h 
 
                   *   *h00j0Y0fpn0weE\$P0c[W0~0Y00
 
                   *   @ p a r a m   i _ e n t r y _ x 
 
                   *   *퐽bQn0Ypg0Y00
 
                   *   @ p a r a m   i _ e n t r y _ y 
 
                   *   *퐽bQn0Ypg0Y00
 
                   *   @ p a r a m   o _ c o o r d 
 
                   *   *퐹p0<h
}Y000000000c[W0~0Y00
 
                   *   @ r e t u r n 
 
                   *   *}L0o _ c o o r d n0wU00H0_04XT0f a l s e 0ԏW0~0Y00
 
                   *   @ 
 
                   * / 
 
                 p u b l i c   b o o l   g e t C o n t o u r ( I N y A R G r a y s c a l e R a s t e r   i _ r a s t e r ,   N y A R I n t R e c t   i _ a r e a ,   i n t   i _ t h ,   i n t   i _ e n t r y _ x ,   i n t   i _ e n t r y _ y ,   N y A R I n t C o o r d i n a t e s   o _ c o o r d ) 
 
                 { 
 
                         / / 0000000n0R0fH0
 
                         i f   ( i _ r a s t e r   ! =   t h i s . _ r e f _ l a s t _ i n p u t _ r a s t e r ) 
 
                         { 
 
                                 t h i s . _ i m d r i v e r   =   ( I R a s t e r D r i v e r ) i _ r a s t e r . c r e a t e I n t e r f a c e ( t y p e o f ( I R a s t e r D r i v e r ) ) ; 
 
                                 t h i s . _ r e f _ l a s t _ i n p u t _ r a s t e r   =   i _ r a s t e r ; 
 
                         } 
 
                         r e t u r n   t h i s . _ i m d r i v e r . g e t C o n t o u r ( i _ a r e a . x ,   i _ a r e a . y ,   i _ a r e a . x   +   i _ a r e a . w   -   1 ,   i _ a r e a . h   +   i _ a r e a . y   -   1 ,   i _ e n t r y _ x ,   i _ e n t r y _ y ,   i _ t h ,   o _ c o o r d ) ; 
 
                 } 
 
         } 
 
 
 
         a b s t r a c t   c l a s s   N y A R C o n t o u r P i c k u p _ B a s e   :   N y A R C o n t o u r P i c k u p . I R a s t e r D r i v e r 
 
         { 
 
                 / / ]VSgqg0M000F0k0000000N͑S
 
                 / /                                                                                       0     1     2     3     4     5     6     7       0     1     2     3     4     5     6 
 
                 / * *   8 eMOc"}n0^j000* / 
 
                 p r o t e c t e d   r e a d o n l y   s t a t i c   i n t [ ]   _ g e t C o n t o u r _ x d i r   =   {   0 ,   1 ,   1 ,   1 ,   0 ,   - 1 ,   - 1 ,   - 1 ,   0 ,   1 ,   1 ,   1 ,   0 ,   - 1 ,   - 1   } ; 
 
                 / * *   8 eMOc"}n0^j000* / 
 
                 p r o t e c t e d   r e a d o n l y   s t a t i c   i n t [ ]   _ g e t C o n t o u r _ y d i r   =   {   - 1 ,   - 1 ,   0 ,   1 ,   1 ,   1 ,   0 ,   - 1 ,   - 1 ,   - 1 ,   0 ,   1 ,   1 ,   1 ,   0   } ; 
 
                 p u b l i c   a b s t r a c t   b o o l   g e t C o n t o u r ( i n t   i _ l ,   i n t   i _ t ,   i n t   i _ r ,   i n t   i _ b ,   i n t   i _ e n t r y _ x ,   i n t   i _ e n t r y _ y ,   i n t   i _ t h ,   N y A R I n t C o o r d i n a t e s   o _ c o o r d ) ; 
 
         } 
 
 
 
 
 
 
 
         / * * 
 
           *   ( I N T _ B I N _ 8 h0I N T _ G S _ 8 k0[_) 
 
           * / 
 
         c l a s s   N y A R C o n t o u r P i c k u p _ B I N _ G S 8   :   N y A R C o n t o u r P i c k u p _ B a s e 
 
         { 
 
                 p r i v a t e   I N y A R R a s t e r   _ r e f _ r a s t e r ; 
 
                 p u b l i c   N y A R C o n t o u r P i c k u p _ B I N _ G S 8 ( I N y A R R a s t e r   i _ r e f _ r a s t e r ) 
 
                 { 
 
                         t h i s . _ r e f _ r a s t e r   =   i _ r e f _ r a s t e r ; 
 
                 } 
 
                 p u b l i c   o v e r r i d e   b o o l   g e t C o n t o u r ( i n t   i _ l ,   i n t   i _ t ,   i n t   i _ r ,   i n t   i _ b ,   i n t   i _ e n t r y _ x ,   i n t   i _ e n t r y _ y ,   i n t   i _ t h ,   N y A R I n t C o o r d i n a t e s   o _ c o o r d )   
 
 	 { 
 
 	 	 D e b u g . A s s e r t ( i _ t < = i _ e n t r y _ x ) ; 
 
 	 	 i n t [ ]   b u f = ( i n t [ ] ) t h i s . _ r e f _ r a s t e r . g e t B u f f e r ( ) ; 
 
 	 	 i n t [ ]   x d i r   =   _ g e t C o n t o u r _ x d i r ; / /   s t a t i c   i n t   x d i r [ 8 ]   =   {   0 ,   1 ,   1 ,   1 ,   0 , - 1 , - 1 , - 1 } ; 
 
 	 	 i n t [ ]   y d i r   =   _ g e t C o n t o u r _ y d i r ; / /   s t a t i c   i n t   y d i r [ 8 ]   =   { - 1 , - 1 ,   0 ,   1 ,   1 ,   1 ,   0 , - 1 } ; 
 
 	 	 i n t   w i d t h = t h i s . _ r e f _ r a s t e r . g e t W i d t h ( ) ; 
 
 	 	 / / 0000Wn0
Nzk0cW0f0D0000000_00
 
 	 	 N y A R I n t P o i n t 2 d [ ]   c o o r d = o _ c o o r d . i t e m s ; 
 
 	 	 i n t   m a x _ c o o r d = o _ c o o r d . i t e m s . L e n g t h ; 
 
 	 	 c o o r d [ 0 ] . x   =   i _ e n t r y _ x ; 
 
 	 	 c o o r d [ 0 ] . y   =   i _ e n t r y _ y ; 
 
 	 	 i n t   c o o r d _ n u m   =   1 ; 
 
 	 	 i n t   d i r   =   5 ; 
 
 
 
 	 	 i n t   c   =   i _ e n t r y _ x ; 
 
 	 	 i n t   r   =   i _ e n t r y _ y ; 
 
 	 	 f o r   ( ; ; )   { 
 
 	 	 	 d i r   =   ( d i r   +   5 )   %   8 ; / / d i r n0ckS
 
 	 	 	 / / S0S0o05_0p00c0h0 giSg0M00h0`F000
 
 	 	 	 / / 4 NYn0XLuc0Wn04XTk00XLu00000weuY00h0K0m00
 
 	 	 	 i f ( c > i _ l   & &   c < i _ r   & &   r > i _ t   & &   r < i _ b ) { 
 
 	 	 	 	 f o r ( ; ; ) { / / g o t o n0000000(un0f o r e
 
 	 	 	 	 	 / / XLuk0cW0f0D0j0D0h0M0( fp$R[) 
 
 	 	 	 	 	 i f   ( b u f [ ( r   +   y d i r [ d i r ] ) * w i d t h + ( c   +   x d i r [ d i r ] ) ]   < =   i _ t h )   { 
 
 	 	 	 	 	 	 b r e a k ; 
 
 	 	 	 	 	 } 
 
 	 	 	 	 	 d i r + + ; 
 
 	 	 	 	 	 i f   ( b u f [ ( r   +   y d i r [ d i r ] ) * w i d t h + ( c   +   x d i r [ d i r ] ) ]   < =   i _ t h )   { 
 
 	 	 	 	 	 	 b r e a k ; 
 
 	 	 	 	 	 } 
 
 	 	 	 	 	 d i r + + ; 
 
 	 	 	 	 	 i f   ( b u f [ ( r   +   y d i r [ d i r ] ) * w i d t h + ( c   +   x d i r [ d i r ] ) ]   < =   i _ t h )   { 
 
 	 	 	 	 	 	 b r e a k ; 
 
 	 	 	 	 	 } 
 
 	 	 	 	 	 d i r + + ; 
 
 	 	 	 	 	 i f   ( b u f [ ( r   +   y d i r [ d i r ] ) * w i d t h + ( c   +   x d i r [ d i r ] ) ]   < =   i _ t h )   { 
 
 	 	 	 	 	 	 b r e a k ; 
 
 	 	 	 	 	 } 
 
 	 	 	 	 	 d i r + + ; 
 
 	 	 	 	 	 i f   ( b u f [ ( r   +   y d i r [ d i r ] ) * w i d t h + ( c   +   x d i r [ d i r ] ) ]   < =   i _ t h )   { 
 
 	 	 	 	 	 	 b r e a k ; 
 
 	 	 	 	 	 } 
 
 	 	 	 	 	 d i r + + ; 
 
 	 	 	 	 	 i f   ( b u f [ ( r   +   y d i r [ d i r ] ) * w i d t h + ( c   +   x d i r [ d i r ] ) ]   < =   i _ t h )   { 
 
 	 	 	 	 	 	 b r e a k ; 
 
 	 	 	 	 	 } 
 
 	 	 	 	 	 d i r + + ; 
 
 	 	 	 	 	 i f   ( b u f [ ( r   +   y d i r [ d i r ] ) * w i d t h + ( c   +   x d i r [ d i r ] ) ]   < =   i _ t h )   { 
 
 	 	 	 	 	 	 b r e a k ; 
 
 	 	 	 	 	 } 
 
 	 	 	 	 	 d i r + + ; 
 
 	 	 	 	 	 i f   ( b u f [ ( r   +   y d i r [ d i r ] ) * w i d t h + ( c   +   x d i r [ d i r ] ) ]   < =   i _ t h )   { 
 
 	 	 	 	 	 	 b r e a k ; 
 
 	 	 	 	 	 } 
 
 	 	 	 	 	 / / 8 eThQf0y0_0Q0i0000L0!qD00
 
 	 	 	 	 	 t h r o w   n e w   N y A R E x c e p t i o n ( ) ; 	 	 	 
 
 	 	 	 	 } 
 
 	 	 	 } e l s e { 
 
 	 	 	 	 / / XLuk0cW0f0D00h0M0
 
 	 	 	 	 i n t   i ; 
 
 	 	 	 	 f o r   ( i   =   0 ;   i   <   8 ;   i + + ) { 	 	 	 	 
 
 	 	 	 	 	 i n t   x = c   +   x d i r [ d i r ] ; 
 
 	 	 	 	 	 i n t   y = r   +   y d i r [ d i r ] ; 
 
 	 	 	 	 	 / / XLu0000
 
 	 	 	 	 	 i f ( x > = i _ l   & &   x < = i _ r   & &   y > = i _ t   & &   y < = i _ b ) { 
 
 	 	 	 	 	 	 i f   ( b u f [ ( y ) * w i d t h + ( x ) ]   < =   i _ t h )   { 
 
 	 	 	 	 	 	 	 b r e a k ; 
 
 	 	 	 	 	 	 } 
 
 	 	 	 	 	 } 
 
 	 	 	 	 	 d i r + + ; / / 
Pw00000SgqY00n0g0OULj0W0
 
 	 	 	 	 } 
 
 	 	 	 	 i f   ( i   = =   8 )   { 
 
 	 	 	 	 	 / / 8 eThQf0y0_0Q0i0000L0!qD00
 
 	 	 	 	 	 t h r o w   n e w   N y A R E x c e p t i o n ( ) ; / /   r e t u r n ( - 1 ) ; 
 
 	 	 	 	 } 	 	 	 	 
 
 	 	 	 } 
 
 	 	 	 / /   x c o o r d h0y c o o r d 0c , r k00OX[
 
 	 	 	 c   =   c   +   x d i r [ d i r ] ; 
 
 	 	 	 r   =   r   +   y d i r [ d i r ] ; 
 
 	 	 	 c o o r d [ c o o r d _ n u m ] . x   =   c ; 
 
 	 	 	 c o o r d [ c o o r d _ n u m ] . y   =   r ; 
 
 	 	 	 / / B}NagN$R[
 
 	 	 	 i f   ( c   = =   i _ e n t r y _ x   & &   r   = =   i _ e n t r y _ y ) { 
 
 	 	 	 	 / / Yph0TX00000k00RTW0_000B}pn0S'`L0B000
 
 	 	 	 	 c o o r d _ n u m + + ; 
 
 	 	 	 	 / / +gzn00000
 
 	 	 	 	 i f   ( c o o r d _ n u m   = =   m a x _ c o o r d )   { 
 
 	 	 	 	 	 / / *b u f L0+gzk0TW0_0
 
 	 	 	 	 	 r e t u r n   f a l s e ; 
 
 	 	 	 	 } 	 	 	 	 
 
 	 	 	 	 / / +gzP܈n0!kn000000y00
 
 	 	 	 	 d i r   =   ( d i r   +   5 )   %   8 ; / / d i r n0ckS
 
 	 	 	 	 i n t   i ; 
 
 	 	 	 	 f o r   ( i   =   0 ;   i   <   8 ;   i + + ) { 	 	 	 	 
 
 	 	 	 	 	 i n t   x = c   +   x d i r [ d i r ] ; 
 
 	 	 	 	 	 i n t   y = r   +   y d i r [ d i r ] ; 
 
 	 	 	 	 	 / / XLu0000
 
 	 	 	 	 	 i f ( x > = i _ l   & &   x < = i _ r   & &   y > = i _ t   & &   y < = i _ b ) { 
 
 	 	 	 	 	 	 i f   ( b u f [ ( y ) * w i d t h + ( x ) ]   < =   i _ t h )   { 
 
 	 	 	 	 	 	 	 b r e a k ; 
 
 	 	 	 	 	 	 } 
 
 	 	 	 	 	 } 
 
 	 	 	 	 	 d i r + + ; / / 
Pw00000SgqY00n0g0OULj0W0
 
 	 	 	 	 } 
 
 	 	 	 	 i f   ( i   = =   8 )   { 
 
 	 	 	 	 	 / / 8 eThQf0y0_0Q0i0000L0!qD00
 
 	 	 	 	 	 t h r o w   n e w   N y A R E x c e p t i o n ( ) ; 
 
 	 	 	 	 } 
 
 	 	 	 	 / / __00000L00[ 1 ] h0TX0j00p00+gzg0B000
 
 	 	 	 	 c   =   c   +   x d i r [ d i r ] ; 
 
 	 	 	 	 r   =   r   +   y d i r [ d i r ] ; 
 
 	 	 	 	 i f ( c o o r d [ 1 ] . x   = = c   & &   c o o r d [ 1 ] . y   = = r ) { 
 
 	 	 	 	 	 / / B}pk0TW0f0D000
 
 	 	 	 	 	 o _ c o o r d . l e n g t h = c o o r d _ n u m ; 
 
 	 	 	 	 	 b r e a k ; 
 
 	 	 	 	 } e l s e { 
 
 	 	 	 	 	 / / B}pg0o0j0D00
 
 	 	 	 	 	 c o o r d [ c o o r d _ n u m ] . x   =   c ; 
 
 	 	 	 	 	 c o o r d [ c o o r d _ n u m ] . y   =   r ; 
 
 	 	 	 	 } 
 
 	 	 	 } 
 
 	 	 	 c o o r d _ n u m + + ; 
 
 	 	 	 / / +gzn00000
 
 	 	 	 i f   ( c o o r d _ n u m   = =   m a x _ c o o r d )   { 
 
 	 	 	 	 / / *L0+gzk0TW0_0
 
 	 	 	 	 r e t u r n   f a l s e ; 
 
 	 	 	 } 
 
 	 	 } 
 
 	 	 r e t u r n   t r u e ; 
 
 	 } 
 
         } 
 
 
 
         / * * 
 
           *   ( I N T _ B I N _ 8 h0I N T _ G S _ 8 k0[_) 
 
           * / 
 
         c l a s s   N y A R C o n t o u r P i c k u p _ G s R e a d e r   :   N y A R C o n t o u r P i c k u p _ B a s e 
 
         { 
 
 
 
                 p r i v a t e   I N y A R G r a y s c a l e R a s t e r   _ r e f _ r a s t e r ; 
 
                 p u b l i c   N y A R C o n t o u r P i c k u p _ G s R e a d e r ( I N y A R G r a y s c a l e R a s t e r   i _ r e f _ r a s t e r ) 
 
                 { 
 
                         t h i s . _ r e f _ r a s t e r   =   i _ r e f _ r a s t e r ; 
 
                 } 
 
                 p u b l i c   o v e r r i d e   b o o l   g e t C o n t o u r ( i n t   i _ l ,   i n t   i _ t ,   i n t   i _ r ,   i n t   i _ b ,   i n t   i _ e n t r y _ x ,   i n t   i _ e n t r y _ y ,   i n t   i _ t h ,   N y A R I n t C o o r d i n a t e s   o _ c o o r d ) 
 
                 { 
 
                         D e b u g . A s s e r t ( i _ t   < =   i _ e n t r y _ x ) ; 
 
                         I N y A R G s P i x e l D r i v e r   r e a d e r   =   t h i s . _ r e f _ r a s t e r . g e t G s P i x e l D r i v e r ( ) ; 
 
                         i n t [ ]   x d i r   =   _ g e t C o n t o u r _ x d i r ; / /   s t a t i c   i n t   x d i r [ 8 ]   =   {   0 ,   1 ,   1 ,   1 ,   0 , - 1 , - 1 , - 1 } ; 
 
                         i n t [ ]   y d i r   =   _ g e t C o n t o u r _ y d i r ; / /   s t a t i c   i n t   y d i r [ 8 ]   =   { - 1 , - 1 ,   0 ,   1 ,   1 ,   1 ,   0 , - 1 } ; 
 
                         / / 0000Wn0
Nzk0cW0f0D0000000_00
 
                         N y A R I n t P o i n t 2 d [ ]   c o o r d   =   o _ c o o r d . i t e m s ; 
 
                         i n t   m a x _ c o o r d   =   o _ c o o r d . i t e m s . L e n g t h ; 
 
                         c o o r d [ 0 ] . x   =   i _ e n t r y _ x ; 
 
                         c o o r d [ 0 ] . y   =   i _ e n t r y _ y ; 
 
                         i n t   c o o r d _ n u m   =   1 ; 
 
                         i n t   d i r   =   5 ; 
 
 
 
                         i n t   c   =   i _ e n t r y _ x ; 
 
                         i n t   r   =   i _ e n t r y _ y ; 
 
                         f o r   ( ;   ;   ) 
 
                         { 
 
                                 d i r   =   ( d i r   +   5 )   %   8 ; / / d i r n0ckS
 
                                 / / XLuk0cW0f0D00h0M0
 
                                 i n t   i ; 
 
                                 f o r   ( i   =   0 ;   i   <   8 ;   i + + ) 
 
                                 { 
 
                                         i n t   x   =   c   +   x d i r [ d i r ] ; 
 
                                         i n t   y   =   r   +   y d i r [ d i r ] ; 
 
                                         / / XLu0000
 
                                         i f   ( x   > =   i _ l   & &   x   < =   i _ r   & &   y   > =   i _ t   & &   y   < =   i _ b ) 
 
                                         { 
 
                                                 i f   ( r e a d e r . g e t P i x e l ( x ,   y )   < =   i _ t h ) 
 
                                                 { 
 
                                                         b r e a k ; 
 
                                                 } 
 
                                         } 
 
                                         d i r + + ; / / 
Pw00000SgqY00n0g0OULj0W0
 
                                 } 
 
                                 i f   ( i   = =   8 ) 
 
                                 { 
 
                                         / / 8 eThQf0y0_0Q0i0000L0!qD00
 
                                         t h r o w   n e w   N y A R E x c e p t i o n ( ) ; / /   r e t u r n ( - 1 ) ; 
 
                                 } 
 
                                 / /   x c o o r d h0y c o o r d 0c , r k00OX[
 
                                 c   =   c   +   x d i r [ d i r ] ; 
 
                                 r   =   r   +   y d i r [ d i r ] ; 
 
                                 c o o r d [ c o o r d _ n u m ] . x   =   c ; 
 
                                 c o o r d [ c o o r d _ n u m ] . y   =   r ; 
 
                                 / / B}NagN$R[
 
                                 i f   ( c   = =   i _ e n t r y _ x   & &   r   = =   i _ e n t r y _ y ) 
 
                                 { 
 
                                         / / Yph0TX00000k00RTW0_000B}pn0S'`L0B000
 
                                         c o o r d _ n u m + + ; 
 
                                         / / +gzn00000
 
                                         i f   ( c o o r d _ n u m   = =   m a x _ c o o r d ) 
 
                                         { 
 
                                                 / / *b u f L0+gzk0TW0_0
 
                                                 r e t u r n   f a l s e ; 
 
                                         } 
 
                                         / / +gzP܈n0!kn000000y00
 
                                         d i r   =   ( d i r   +   5 )   %   8 ; / / d i r n0ckS
 
                                         f o r   ( i   =   0 ;   i   <   8 ;   i + + ) 
 
                                         { 
 
                                                 i n t   x   =   c   +   x d i r [ d i r ] ; 
 
                                                 i n t   y   =   r   +   y d i r [ d i r ] ; 
 
                                                 / / XLu0000
 
                                                 i f   ( x   > =   i _ l   & &   x   < =   i _ r   & &   y   > =   i _ t   & &   y   < =   i _ b ) 
 
                                                 { 
 
                                                         i f   ( r e a d e r . g e t P i x e l ( x ,   y )   < =   i _ t h ) 
 
                                                         { 
 
                                                                 b r e a k ; 
 
                                                         } 
 
                                                 } 
 
                                                 d i r + + ; / / 
Pw00000SgqY00n0g0OULj0W0
 
                                         } 
 
                                         i f   ( i   = =   8 ) 
 
                                         { 
 
                                                 / / 8 eThQf0y0_0Q0i0000L0!qD00
 
                                                 t h r o w   n e w   N y A R E x c e p t i o n ( ) ; 
 
                                         } 
 
                                         / / __00000L00[ 1 ] h0TX0j00p00+gzg0B000
 
                                         c   =   c   +   x d i r [ d i r ] ; 
 
                                         r   =   r   +   y d i r [ d i r ] ; 
 
                                         i f   ( c o o r d [ 1 ] . x   = =   c   & &   c o o r d [ 1 ] . y   = =   r ) 
 
                                         { 
 
                                                 / / B}pk0TW0f0D000
 
                                                 o _ c o o r d . l e n g t h   =   c o o r d _ n u m ; 
 
                                                 b r e a k ; 
 
                                         } 
 
                                         e l s e 
 
                                         { 
 
                                                 / / B}pg0o0j0D00
 
                                                 c o o r d [ c o o r d _ n u m ] . x   =   c ; 
 
                                                 c o o r d [ c o o r d _ n u m ] . y   =   r ; 
 
                                         } 
 
                                 } 
 
                                 c o o r d _ n u m + + ; 
 
                                 / / +gzn00000
 
                                 i f   ( c o o r d _ n u m   = =   m a x _ c o o r d ) 
 
                                 { 
 
                                         / / *L0+gzk0TW0_0
 
                                         r e t u r n   f a l s e ; 
 
                                 } 
 
                         } 
 
                         r e t u r n   t r u e ; 
 
                 } 
 
         } 
 
 } 