itk::LineConstIterator does not work with otb::VectorImage
Mantis Issue 234, reported by ebarthelet, assigned to ghost, created: 2011-02-14
When dealing with otb::VectorImage, the Get() method of itk::LineConstIterator returns a reference on a temporary variable... At compilation time, the compiler displays a warning and, at running time, the program crashes (segfault).
To fix the bug, I simply suggest that the itk::LineConstIterator::Get() method returns a variable of type PixelType and not of type PixelType&. The same work has to be done on the Get() method of class otb::PolyLineImageConstIterator which calls itk::LineConstIterator::Get().
Thanks,
Edouard
1309362793 - julienmThis is an ITK bug, not an OTB bug. I confirm there is something really wrong going on when using LineIterator over VectorImage.
The workaround is to not use Get(), but GetIndex(), and then call image->GetPixel with this index as parameter (this is pretty much the implementation of Get() )
1313511604 - C ValladeauI don't thing the warning is in relation with your segfault (the copy constructor must be called if you do PixelType myPix = iter->Get() )... To my knowledge, the LineConstIterator doesn't deal with the buffered image region. That is to say that the asked line must be inside the bufferedRegion of the input image. For example if you do that, it will segfault : reader->SetFileName(argv[1]);
ImageType::IndexType startId, lastId; startId.Fill( atoi(argv[2])); lastId.Fill( atoi(argv[3]));
IteratorType iter( reader->GetOutput(), startId, lastId );
while( ! iter.IsAtEnd() ) { ++iter; }
If you add a reader->Update(), it will pass (i