[Insight-users] a overflow maked by "itkBinaryMask3DMeshSource.txx"

hubaoping hubaoping at 126.com
Thu Nov 27 09:20:13 EST 2008


 Hi,
    When I use the "itkBinaryMask3DMeshSource" to creat a mesh,compliled  without error.But it cannot run.There is a  warning likes  "0x******** cannot be read"and break at the point in the"itkBinaryMask3DMeshSource.txx "
   So I look over the "itkBinaryMask3DMeshSource.txx ",the code below make me confused.
  //////////////////////
 InputImageIterator it1( m_InputImage, m_InputImage->GetBufferedRegion() );
  InputImageIterator it2( m_InputImage, m_InputImage->GetBufferedRegion() );
  InputImageIterator it3( m_InputImage, m_InputImage->GetBufferedRegion() );
  InputImageIterator it4( m_InputImage, m_InputImage->GetBufferedRegion() );
  it1.GoToBegin();
  it2.GoToBegin();
  it3.GoToBegin();
  it4.GoToBegin();
  InputImageSizeType inputImageSize = m_InputImage->GetBufferedRegion().GetSize();
  m_ImageWidth  = inputImageSize[0];
  m_ImageHeight = inputImageSize[1];
  m_ImageDepth  = inputImageSize[2];
  int frame = m_ImageWidth * m_ImageHeight;
  int row = m_ImageWidth;
 
  int i = 0;
  int j;
  while ( i < frame )
    {
    ++it3;
    ++it1;
    i++;
    }
  i = 0;
  while ( i < row )
    {
    ++it2;
    ++it4;
    i++;
    }
 
while ( !it4.IsAtEnd() )
    {
    vertexindex = 0;
    if ( it1.Value() == m_ObjectValue ) vertexindex += 1;
    if ( it2.Value() == m_ObjectValue ) vertexindex += 8;
    if ( it3.Value() == m_ObjectValue ) vertexindex += 16;
    if ( it4.Value() == m_ObjectValue ) vertexindex += 128;
    ++it1;
    ++it2;
    ++it3;
    ++it4;
///////////////////////////////////////////////////
If m_ImageWidth = m_ImageHeight = 512, m_ImageDepth  = 1,so   frame = 512*512 =262144,row = 512. Well,after
while ( i < frame )
    {
    ++it3;
    ++it4;
    i++;
    }


the offset of it4 or it3 is 262144.then
while ( i < row )
    {
    ++it2;
    ++it4;
    i++;
    };
the offset of it4 is 262144+512 =262656.but the it4.IsAtEnd() is 262144.so the lines while ( !it4.IsAtEnd() )
will run and not stop. and the offsets of the iterators will  overflow.
--

胡宝平
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20081127/d4d99126/attachment.htm>


More information about the Insight-users mailing list