[vtkusers] How to use vtkDataObjectReader in C++

Jothybasu Selvaraj jothybasu at gmail.com
Thu Feb 9 08:59:36 EST 2012


If you want to return dataset don't don't create dataset with smartPointer.

simply use

vtkDataSet* dataSet=vtkDataSet::New();

Jothy

On Thu, Feb 9, 2012 at 1:52 PM, <ycollette.nospam at free.fr> wrote:

> 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
>



-- 
Jothy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120209/50aad036/attachment.htm>


More information about the vtkusers mailing list