Parapa
Parapa

Reputation: 87

How to get VTK's tuple size from vtkDataArray

I'm trying to read all the data from all the tuples from a vtkDataArray class. However vtkDataArray::GetTuple as can be seen here returns a pointer to a double array. I'm wondering how can I get the size of that array. Seems like I'm missing an obvious solution.

Code snipet:

void doSomething(vtkSmartPointer<vtkDataArray> dataArray)
{
  vtkIdType numTuples = dataArray->GetNumberOfTuples();
  for (vtkIdType tupleIdx = 0; tupleIdx < numTuples; ++tupleIdx)
    {
        double* tuple = dataArray->GetTuple(tupleIdx);
        for (int j = 0; j < ¿¿¿???; ++j}
           double var = tuple[j];
           //Do something with var
           //Carefull don't go out of bounds
    }
}

Upvotes: 1

Views: 1122

Answers (1)

user6764549
user6764549

Reputation:

You need dataArray->GetNumberOfComponents(). If you know the number of components then it may be easier to use other functions, for example, for 3 components you can use dataArray->GetTuple3(). VTK provides functions GetTuple1(), GetTuple2(), ... ,GetTuple9().

Upvotes: 2

Related Questions