[vtkusers] How to use vtkDataObjectReader in C++

ycollette.nospam at free.fr ycollette.nospam at free.fr
Thu Feb 9 08:52:53 EST 2012


Hello,

Thanks for all these advices. Now it works:

bool VTKContainer::read_file(const char * Filename)
{
  //vtkDataObjectReader * do_reader = vtkSmartPointer<vtkDataObjectReader>::New();
  vtkDataObjectReader * do_reader = vtkDataObjectReader::New();
  
  do_reader->SetFileName(Filename);

  do_reader->ReadAllFieldsOn();
  
  dataSet = do_reader->GetOutput()->GetFieldData();
  
  return (dataSet!=NULL);
}

There is still 1 thing:
- The smart pointer version doesn't work: it hangs when calling SetFileName.

YC

----- Mail original -----
De: "David Doria" <daviddoria at gmail.com>
À: "ycollette nospam" <ycollette.nospam at free.fr>
Cc: vtkusers at vtk.org
Envoyé: Jeudi 9 Février 2012 14:44:21
Objet: Re: [vtkusers] How to use vtkDataObjectReader in C++

On Thu, Feb 9, 2012 at 8:04 AM,  <ycollette.nospam at free.fr> wrote:
> Hello,
>
> I tried to compile the following code under C++, but the compiler complains about not being able to access protected members (the contructor and the destructor).
> Here is the peice of code:
>
>  vtkFieldData * dataSet = NULL;
>  vtkDataObjectReader * do_reader = new vtkDataObjectReader;
>
>  do_reader->ReadAllFieldsOn();
>  do_reader->SetFileName(Filename);
>  dataSet = do_reader->ReadFieldData();
>
>
> My question is: how to use vtkDataObjectReader in C++ ?
>
> Best regards,
>
> YC

Once you get this working it would be great if you could make a short
example an post it on the wiki:
http://www.vtk.org/Wiki/VTK/Examples/Cxx

David



More information about the vtkusers mailing list