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

zjc jiezjc at sina.com
Wed Nov 23 00:13:54 EST 2016


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();

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161123/6c141f25/attachment.html>
-------------- next part --------------
# vtk DataFile Version 4.0
vtk output
ASCII
DATASET UNDIRECTED_GRAPH
POINTS 20 float
-0.235597 4.19265 0.557564 -0.226415 3.90285 1.41364 -0.552681 3.99281 1.08117 
-0.408151 -4.16471 0.340572 -0.787696 -4.1173 0.0940845 -0.258744 -4.18317 -0.225288 
-0.00911081 -1.40764 0.0200255 -0.666889 -0.505271 -0.495084 -0.411895 1.53943 0.241843 
-0.684812 0.443477 0.549157 0.471433 0.387155 -0.333095 -1.0063 2.13384 1.45423 
-0.758552 -1.00379 0.794824 1.14556 0.894125 0.47958 0.558745 0.0178654 0.914717 
0.222442 2.77834 1.51518 0.572759 -3.23244 1.02109 0.215907 -2.75125 -0.617971 
-0.0944958 -3.30206 0.0922823 -0.6552 2.88964 0.553324 
VERTICES 20
EDGES 8
17 18
6 17
8 9
6 7
4 18
0 19
7 9
8 19
VERTEX_DATA 20
SCALARS scalars char
LOOKUP_TABLE default
1 1 1 1 1 1 0 0 0 
0 0 0 0 0 0 0 0 0 
0 0 
FIELD FieldData 1
vtkOriginalPointIds 1 20 vtkIdType
10020 10546 10678 11726 11728 12153 13302 13310 13327 
13336 13341 13349 13389 13495 13597 15712 16780 17520 
18069 18098 


More information about the vtkusers mailing list