Hi David,<br><br>As I recall<br><br>Your AddArray() wont do anything.. because its the same array as before and Reset does do much other than setting the MaxId to -1 (which means that you will get NumberOfTuples to 0 when you query later)<br>
<br>vtkIdType GetNumberOfTuples() <br>    {return (this-&gt;MaxId + 1)/this-&gt;NumberOfComponents;}<br><br>HTH, <br>Aashish<br><br><br><br><div class="gmail_quote">On Tue, Mar 30, 2010 at 4:09 PM, David Doria <span dir="ltr">&lt;<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">It seems that after I call Reset(), I cannot add anything to the<br>
EdgeData. The following examples shows that I add a length 2 weight<br>
array to the graph, prove that it was added properly, Reset() the<br>
EdgeData, then try to add the weight array again. This time, the graph<br>
contains 0 weights after adding the weights array. The only reason I<br>
started calling Reset is because in my filter the number of weights is<br>
being reported incorrectly, I believe because it used to have a<br>
&quot;Weights&quot; array, and I am trying to replace it with a new one.<br>
<br>
Any thoughts?<br>
<br>
#include &lt;vtkSmartPointer.h&gt;<br>
#include &lt;vtkDoubleArray.h&gt;<br>
#include &lt;vtkDataSetAttributes.h&gt;<br>
#include &lt;vtkMutableDirectedGraph.h&gt;<br>
<br>
int main(int argc, char *argv[])<br>
{<br>
  vtkSmartPointer&lt;vtkMutableDirectedGraph&gt; dg =<br>
      vtkSmartPointer&lt;vtkMutableDirectedGraph&gt;::New();<br>
<br>
  vtkIdType v1 = dg-&gt;AddVertex();<br>
  vtkIdType v2 = dg-&gt;AddChild(v1);<br>
<br>
  vtkSmartPointer&lt;vtkDoubleArray&gt; weights =<br>
      vtkSmartPointer&lt;vtkDoubleArray&gt;::New();<br>
  weights-&gt;SetNumberOfComponents(1);<br>
  weights-&gt;SetName(&quot;Weights&quot;);<br>
<br>
  //set the edge weights<br>
  weights-&gt;InsertNextValue(1.0);<br>
  weights-&gt;InsertNextValue(2.0);<br>
<br>
  cout &lt;&lt; &quot;Number of weights in array: &quot; &lt;&lt;<br>
weights-&gt;GetNumberOfTuples() &lt;&lt; endl;<br>
<br>
  //add the edge weight array to the graph<br>
  dg-&gt;GetEdgeData()-&gt;AddArray(weights);<br>
<br>
  cout &lt;&lt; &quot;Number of weights added: &quot; &lt;&lt;<br>
vtkDoubleArray::SafeDownCast(dg-&gt;GetEdgeData()-&gt;GetArray(&quot;Weights&quot;))-&gt;GetNumberOfTuples()<br>
&lt;&lt; endl;<br>
<br>
  dg-&gt;GetEdgeData()-&gt;Reset();<br>
<br>
  cout &lt;&lt; &quot;Number of weights: &quot; &lt;&lt;<br>
vtkDoubleArray::SafeDownCast(dg-&gt;GetEdgeData()-&gt;GetArray(&quot;Weights&quot;))-&gt;GetNumberOfTuples()<br>
&lt;&lt; endl;<br>
<br>
  dg-&gt;GetEdgeData()-&gt;AddArray(weights);<br>
<br>
  cout &lt;&lt; &quot;Number of weights added: &quot; &lt;&lt;<br>
vtkDoubleArray::SafeDownCast(dg-&gt;GetEdgeData()-&gt;GetArray(&quot;Weights&quot;))-&gt;GetNumberOfTuples()<br>
&lt;&lt; endl;<br>
<br>
  return EXIT_SUCCESS;<br>
}<br>
<br>
Thanks,<br>
<br>
David<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>| Aashish Chaudhary <br>| R&amp;D Engineer         <br>| Kitware Inc.            <br>| <a href="http://www.kitware.com">www.kitware.com</a>    <br>