[vtkusers] Reading standard image types

Bill Lorensen bill.lorensen at gmail.com
Sat Oct 16 15:28:55 EDT 2010


David,

It's not perfect, for sure. But it is what we have for now.

I'll look at your solution. For now, let's just have one example that uses it.


Bill

On Sat, Oct 16, 2010 at 2:46 PM, David Doria <daviddoria at gmail.com> wrote:
>> 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