[vtk-developers] [VTK 0013315]: vtk 5.10.0: vtkXGMLReader does not load custom attribute values properly into vtkMutableUndirectedGraph

Mantis Bug Tracker mantis at public.kitware.com
Thu Jul 19 09:55:54 EDT 2012


The following issue has been SUBMITTED. 
====================================================================== 
http://www.vtk.org/Bug/view.php?id=13315 
====================================================================== 
Reported By:                awehrer
Assigned To:                
====================================================================== 
Project:                    VTK
Issue ID:                   13315
Category:                   (No Category)
Reproducibility:            have not tried
Severity:                   minor
Priority:                   normal
Status:                     backlog
Project:                    TBD 
Type:                       incorrect functionality 
Resolution:                 open
Fixed in Version:           
====================================================================== 
Date Submitted:             2012-07-19 09:55 EDT
Last Modified:              2012-07-19 09:55 EDT
====================================================================== 
Summary:                    vtk 5.10.0: vtkXGMLReader does not load custom
attribute values properly into vtkMutableUndirectedGraph
Description: 
Steven had pointed out how the labels on the tiny graph example were all off by
one. Each vertex is defined to have a "label" attribute based on our GML file,
which we set to be the graphical labels. The node labels start with "node1," and
the internal vertex id's start at 0. When you look at the graph when displayed
on the screen, the first label that appears in order is "node2." However, when I
set the labels to be the vertex id's, "node2" becomes "0." With further
investigation into the VertexData for the vtkUndirectedGraph, the first element
that appears in the label attribute array is "node2." This means "node1" was
never stored. Looking at the source code for vtkXGMLReader beforehand, there was
a section where I went, "Huh?" I thought maybe I was reading their syntax wrong,
but it turns out that might be an error after all.

The indices of the attribute data correspond to the internal vertex id's from 0
to n - 1, not the input id's from 1 to n used in the files. When reading input
id's, it maps them to the internal id's in a temporary collection:

id = builder->AddVertex();
nodeIdMap[tok.IntValue] = id;

However, maintaining the same value for the variable id, when it goes to load a
single value into the label attribute array, it uses:

vtkStringArray::SafeDownCast(property_table[i].Data)->SetValue(nodeIdMap[id],
tok.StringValue);

So, for node 1, id = 0, nodeIdMap[1] = 0, and nodeIdMap[id] = nodeIdMap[0] = ??
<-- index of "node1"
So, for node 2, id = 1, nodeIdMap[2] = 1, and nodeIdMap[id] = nodeIdMap[1] = 0
<-- index of "node2"
So, for node 3, id = 2, nodeIdMap[3] = 2, and nodeIdMap[id] = nodeIdMap[2] = 1
<-- index of "node3"

Anyone see a pattern?

Looking at how they used the edgeIdMap, it seems they had intended for it to
work analogously to nodeIdMap, but in order for that to happen, I had to correct
two lines of code. I have attached the corrected file, where the two changed
lines are marked with the comment "FIX." If you need a demonstration, I do have
a python script and our small GML file.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2012-07-19 09:55 awehrer        New Issue                                    
2012-07-19 09:55 awehrer        File Added: vtkXGMLReader.cxx                   

======================================================================




More information about the vtk-developers mailing list