[Insight-developers] Re: Line Iterator problem
Luis Ibanez
luis.ibanez@kitware.com
Tue, 05 Mar 2002 19:05:04 -0500
Bradley,
Thanks a lot for raising this problem and proposing the fix.
The fix has just been checked in. The ImageLinearIterator
(and its Const version) can now call NextLine() and
PreviousLine() from any position.
The previous implementation implicitly assumed that the
iterator was at the end of the line (for NextLine() ) or
at the beginning of the line (for PreviousLine()).
Code/Common/itkImageLinearIteratorTest .cxx
has now a test case for the use of these methods in the
middle of a line.
Thanks
Luis
=========================================
Bradley Wyman wrote:
>Luis,
>
> I've run across a problem with the
>itkImageLinearIteratorWithIndex using the NextLine() function. The
>problem occurs with the following line:
>
>m_Position -= m_OffsetTable[ m_Direction ] *
> ( m_EndIndex[ m_Direction ] - m_BeginIndex[ m_Direction
>] );
>
>This works only if the current m_PositionIndex is at the end of the line
>(in which case m_PositionIndex = m_EndIndex ). If m_PositionIndex is
>anywhere else then this will set the pointer at the wrong location and
>it will be different than the m_PositionIndex which is set by:
>
>m_PositionIndex[m_Direction] = m_BeginIndex[ m_Direction ];
>
>The fix should be to change m_EndIndex to m_PositionIndex and then it
>should work.
>
> I've noticed the same issue exists with the PreviousLine()
>function. I do not know if this problem exists with the other
>iterators. My workaround is to call GoToEndOfLine() before calling
>NextLine().
>
>_____________________________________________
>Brad Wyman, Ph.D. Insightful Corp.
>1700 Westlake Ave. N (206)283-8802 x256
>Seattle, WA 98109 Fax: (206)283-6310
>bwyman@insightful.com
>