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->MaxId + 1)/this->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"><<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>></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>
"Weights" array, and I am trying to replace it with a new one.<br>
<br>
Any thoughts?<br>
<br>
#include <vtkSmartPointer.h><br>
#include <vtkDoubleArray.h><br>
#include <vtkDataSetAttributes.h><br>
#include <vtkMutableDirectedGraph.h><br>
<br>
int main(int argc, char *argv[])<br>
{<br>
vtkSmartPointer<vtkMutableDirectedGraph> dg =<br>
vtkSmartPointer<vtkMutableDirectedGraph>::New();<br>
<br>
vtkIdType v1 = dg->AddVertex();<br>
vtkIdType v2 = dg->AddChild(v1);<br>
<br>
vtkSmartPointer<vtkDoubleArray> weights =<br>
vtkSmartPointer<vtkDoubleArray>::New();<br>
weights->SetNumberOfComponents(1);<br>
weights->SetName("Weights");<br>
<br>
//set the edge weights<br>
weights->InsertNextValue(1.0);<br>
weights->InsertNextValue(2.0);<br>
<br>
cout << "Number of weights in array: " <<<br>
weights->GetNumberOfTuples() << endl;<br>
<br>
//add the edge weight array to the graph<br>
dg->GetEdgeData()->AddArray(weights);<br>
<br>
cout << "Number of weights added: " <<<br>
vtkDoubleArray::SafeDownCast(dg->GetEdgeData()->GetArray("Weights"))->GetNumberOfTuples()<br>
<< endl;<br>
<br>
dg->GetEdgeData()->Reset();<br>
<br>
cout << "Number of weights: " <<<br>
vtkDoubleArray::SafeDownCast(dg->GetEdgeData()->GetArray("Weights"))->GetNumberOfTuples()<br>
<< endl;<br>
<br>
dg->GetEdgeData()->AddArray(weights);<br>
<br>
cout << "Number of weights added: " <<<br>
vtkDoubleArray::SafeDownCast(dg->GetEdgeData()->GetArray("Weights"))->GetNumberOfTuples()<br>
<< 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&D Engineer <br>| Kitware Inc. <br>| <a href="http://www.kitware.com">www.kitware.com</a> <br>