[vtkusers] vtkImageIterator back again

Mathieu Malaterre Mathieu.Malaterre at creatis.insa-lyon.fr
Wed May 14 08:40:19 EDT 2003


Hi all,
	After fixing some of my bugs, I still have this one, I don't know how 
to fix it.

	If my vtkImageIterator traverse only one slice, the test is ok. But as 
soon as I add one more slice the test fails. Could someone told me why ?

Here is the C++ test prog I use:


//----------------------------------------------------
#include "vtkImageIterator.h"
#include "vtkStructuredPoints.h"

#include "vtkStructuredPointsReader.h"
#include "vtkStructuredPointsWriter.h"

#include "vtkRegressionTestImage.h"

//#include "vtkDebugLeaks.h"
int main( int argc, char ** argv )
{
   // Read the data from a vtk file
   char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv, 
"Data/ironProt.vtk");
   vtkStructuredPointsReader *reader = vtkStructuredPointsReader::New();
   reader->SetFileName(fname);
   reader->Update();
   delete [] fname;

   {
   int subregion[6] = { 10, 50, 10, 50, 10, 10};  //one slice

   vtkImageIterator<unsigned char> inIt(reader->GetOutput(), subregion);

   while (!inIt.IsAtEnd())
     {
     unsigned char* inSI = inIt.BeginSpan();
     unsigned char* inSIEnd = inIt.EndSpan();

       while (inSI != inSIEnd)
         {
         *inSI = 600;
         ++inSI;
         }
     inIt.NextSpan();
     }

   printf("One slice: easy job !\n");
   }

   int subregion[6] = { 10, 50, 10, 50, 11, 12}; //two slices !

   vtkImageIterator<unsigned char> inIt(reader->GetOutput(), subregion);

   while (!inIt.IsAtEnd())
     {
     unsigned char* inSI = inIt.BeginSpan();
     unsigned char* inSIEnd = inIt.EndSpan();

       while (inSI != inSIEnd)
         {
         *inSI = 600;
         ++inSI;
         }
     inIt.NextSpan();
     }

   printf("Two slices...\n");


   vtkStructuredPointsWriter *writer = vtkStructuredPointsWriter::New();
   writer->SetInput(reader->GetOutput());
   writer->SetFileTypeToBinary();
   writer->SetFileName( "myironProt.vtk" );
   writer->Write();

   reader->Delete();
   writer->Delete();

   return 0;
}
//----------------------------------------------------

Any advice/suggestions,

Thanks
mathieu




More information about the vtkusers mailing list