[vtkusers] Output files during the pipeline

Tranchemontagne, Denis dtranche at mc.com
Tue Nov 27 11:20:17 EST 2001


My application reads a bunch of slice, preprocess them, then combines them
to render a new volume. 

After the preprocess stage, I would like to save off the images.  I am able
to setup a call back function that will render the images, but not to save
them to a file. 

I am trying to use vtkImageWriter to do this, as I have a number of slices
that would like saved.

the call back function is
void WritePreProcessedSlice(void *cd)
{
    static int _run = 1;
    if (_run)
    {
        _run = 0;
        vtkImageWriter * writer = (vtkImageWriter*)cd;
        // get the slice number
        int slice = writer->GetInput()->GetUpdateExtent()[4]; 
        writer->GetInput()->GetSource()->Modified();
        writer->Write();
        _run++;
    }
}

and I set it up in main

  vtkImageWriter * sliceWriter = vtkImageWriter::New();

  strcpy(str,medvip_home);
  strcat(str, "\\3drxTest\\3drxTest_data\\parameters\\out\\image");

  sliceWriter->SetFilePattern("%s%.3d.post");
  sliceWriter->SetFilePrefix(str);
  sliceWriter->SetFileDimensionality(2);

  sliceWriter->SetInput(Correct->GetOutput());
 Ramp->SetStartMethod(WritePreProcessedSlice,(void *)sliceWriter);

This works if I am rendering the slices but not when I try to safe them.  If
some one could tell me what I am doing wrong it would be greatly
apprecitated.



More information about the vtkusers mailing list