[vtkusers] Creating a vtkSource
Mike Jackson
imikejackson at gmail.com
Tue May 2 15:19:40 EDT 2006
I am trying to create a new class that loads data from a custom file
format. The output of the loading is a vtkImageData object. So I
looked through what docs I have and decided to subclass
vtkImageSource. This seems like the right thing to do but I am having
some trouble getting my data out of the class.
I created a new class called "PFVolumeSource", added all the Set/Get
Macros for my instance variables, and then over-rode Update() like
that docs say to do. I can step through the code in a debugger and
"see" my data being loaded from the file and put into a vtkImageData
Object. This part seems ok. The last thing I do before exiting the
Update() method is to "this->SetOutput(image);"
Now, later on in my code I want to write the new vtkImage to a file
(*.vti). Except that nothing is being written except the header.
vtkPFVolumeSource *reader = vtkPFVolumeSource::New();
reader->Update();
vtkXMLImageDataWriter *writer = vtkXMLImageDataWriter::New();
writer->SetInput( reader->GetOutput(0) );
writer->SetFileName("/Users/mjackson/Desktop/Test_HDF_Extract.vti");
writer->Write();
writer->Delete();
reader->Delete();
So nothing is being written...
The odd part is that if I have PFVolumeSource subclass vtkObject, and
implement the GetOutput() and Update() methods, then the writer
successfully writes the data.
I think part of the problem is that I am using vtk 5.x (release), but
the books I have are for vtk 4.2 (3rd edition of the VTK book). I
remember there being something about the pipeline changing from 4.2 to
5.0? Am I just doing something wrong? Not implementing the required
methods for vtk 5.x?
Could some one help point me in the right direction?
Thanks
--
Mike Jackson
imikejackson _at_ gee-mail dot com
More information about the vtkusers
mailing list