[vtkusers] How to use vtkDataObjectReader in C++

ycollette.nospam at free.fr ycollette.nospam at free.fr
Thu Feb 9 09:05:04 EST 2012


After some tests, it seems that the hangs is due to ReadAllFieldsOn.
If I remove the call to this method, everything is fine.

bool VTKContainer::read_file(const char * Filename)
{
#ifdef DEBUG
  cerr << "read_file" << endl;
#endif
  vtkSmartPointer<vtkDataObjectReader> do_reader = vtkSmartPointer<vtkDataObjectReader>::New();
  
  do_reader->SetFileName(Filename);

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

And the smart pointer things went fine too. Thanks.
I thought it would be easier to translate my code from python to C++ ...

YC

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

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
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list