[vtkusers] vtkImageIterator : seg fault

Mathieu Malaterre Mathieu.Malaterre at creatis.insa-lyon.fr
Thu May 15 10:21:03 EDT 2003


Hi all,
	I only change the subject of my last email:
http://vtk.org/pipermail/vtkusers/2003-May/017865.html

	I still didn't understand why I get such seg fault. Could at least 
someone confirm that he also gets a seg fault, please. I can even 
provide a simple CMakeLists.txt in case you don't know how to write it.

	And again here is the C++ code:

//----------------------------------------------------
#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};  //ok
    int subregion[6] = { 10, 50, 10, 50, 11, 12}; //seg fault !!

    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;
}
//----------------------------------------------------

Thanks a lot,
mathieu

-- 
Mathieu Malaterre
CREATIS
28 Avenue du Doyen LEPINE
B.P. Lyon-Montchat
69394 Lyon Cedex 03
http://www.creatis.insa-lyon.fr/~malaterre/




More information about the vtkusers mailing list