[vtkusers] Re: how to create a generic reader?

Dominik Szczerba domi at vision.ee.ethz.ch
Fri Jul 14 10:48:57 EDT 2006


OK, got it working, here it is for others:

vtkDataObject* dataObject;
vtkDataSetReader* reader = vtkDataSetReader::New();
reader->SetFileName(argv[1]);
dataObject = reader->GetOutput();
dataObject->Update();

switch (dataObject->GetDataObjectType())
// RTFD on vtkDataSetReader

--ds

Dominik Szczerba wrote:
> Hi,
> 
> I want read a file without apriori knowledge of the file type. I use:
> 
> vtkDataReader* reader = vtkDataReader::New();
> //...
> dataObject = reader->GetOutputDataObject(0);
> 
> but this aborts at runtime (see below). Is it possible to load an 
> arbitrary file and downcast based on its type it as appropriate?
> 
> regards,
> Dominik
> 
> ERROR: In /home/domi/src/vtk/VTK-CVS-080706/Filtering/vtkAlgorithm.cxx, 
> line 665
> vtkDataReader (0x805ba60): FillOutputPortInformation is not implemented.
> 
> ERROR: In 
> /home/domi/src/vtk/VTK-CVS-080706/Filtering/vtkDemandDrivenPipeline.cxx, 
> line 675
> vtkStreamingDemandDrivenPipeline (0x805be90): Algorithm 
> vtkDataReader(0x805ba60) did not create output for port 0 when asked by 
> REQUEST_DATA_OBJECT and does not specify any DATA_TYPE_NAME.
> 



More information about the vtkusers mailing list