[vtkusers] SetOutput of the class vtkGraphReader exists in name only

Cory Quammen cory.quammen at kitware.com
Wed Nov 23 00:26:35 EST 2016


You normally don't need to allocate or specify an output. VTK
readers/filters create an output data object for you internally, and
that's what you access with GetOutput(). That is why the output
pointer is different from the one you specified.

HTH,
Cory

On Wed, Nov 23, 2016 at 12:13 AM, zjc <jiezjc at sina.com> wrote:
> Hello everyone,
>
> I'm trying to use the class vtkGraphReader to import a undirected graph. I
> thought the member function SetOutput of the class vtkGraphReader was
> provided for users to specify the resulting object, but I found that the
> return value of GetOutput after Update was called was different from the
> pointer I specified. Is it a bug? Or did I use the class inappropriately?
>
> Regards
> Juncheng
>
> Enclosed is the .vtk file of the graph. And here is the code.
>   vtkSmartPointer<vtkUndirectedGraph> graph =
> vtkSmartPointer<vtkUndirectedGraph>::New();
>   vtkGraphReader *reader = vtkGraphReader::New();
>   reader->SetFileName(Filename);
>   reader->SetOutput(graph);
>   reader->Update();
>   if(graph != vtkUndirectedGraph::SafeDownCast(reader->GetOutput()))
>     cout << "Output is different." << endl;
>   if(graph->GetNumberOfVertices()==0 &&
> reader->GetOutput()->GetNumberOfVertices()>0)
>     cout << "Output specified is not updated." << endl;
>   reader->Delete();
>
>
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>



-- 
Cory Quammen
Staff R&D Engineer
Kitware, Inc.


More information about the vtkusers mailing list