[vtkusers] GetEdgeData->Reset() breaks EdgeData

David Doria daviddoria+vtk at gmail.com
Tue Mar 30 18:10:10 EDT 2010


On Tue, Mar 30, 2010 at 5:33 PM, Aashish Chaudhary
<aashish.chaudhary at kitware.com> wrote:
> Hi David,
>
> As I recall
>
> 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)
>
> vtkIdType GetNumberOfTuples()
>     {return (this->MaxId + 1)/this->NumberOfComponents;}
>
> HTH,
> Aashish

Hmmm. The reason I ask is that I have this code:

cout << "There are " << g->GetNumberOfEdges() << " edges." << endl; //
outputs 494
cout << "There are " << weights->GetNumberOfTuples() << " weights." <<
endl; //outputs 494

g->GetEdgeData()->AddArray(weights);

  if(!vtkDoubleArray::SafeDownCast(g->GetEdgeData()->GetArray("Weights")))
    {
    cout << "No weights!" << endl;
    }
  else
    {
    cout << "g has " <<
vtkDoubleArray::SafeDownCast(g->GetEdgeData()->GetArray("Weights"))->GetNumberOfTuples()
<< " weights." << endl; //outputs 289 ??!!
    }

It seems to me like the last output should be the same (494), no?

Anyone know what could be going wrong?

Thanks,

David



More information about the vtkusers mailing list