[vtkusers] Reading standard image types

David Doria daviddoria at gmail.com
Sat Oct 16 14:46:26 EDT 2010


> We should try it on a few wiki examples.
Yes, I was intending to use it in all of the wiki examples that do not
highlight a specific reader.

> If it does not  work, we should fix it.
I found the problem. You have to set the FileName of the reader after
it is generated by the factory:

vtkSmartPointer<vtkImageReader2Factory> readerFactory =
  vtkSmartPointer<vtkImageReader2Factory>::New();
vtkImageReader2 * imageReader =
readerFactory->CreateImageReader2(inputFilename.c_str());
imageReader->SetFileName(inputFilename.c_str());
imageReader->Update();

I am not an expert in the factory pattern, but I don't see what we
gain by using it here? It seems to just be more cumbersome for the
user to use the factory to create a reader object which they then just
get the output from. The factory seems to exactly what I had done in
the vtkImageFileReader, but it returns the reader rather than just
returning the image. It seems silly to have to pass the filename to
two different objects, no?

David



More information about the vtkusers mailing list