How to get VTK's tuple size from vtkDataArray

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


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
}
}




1 Answer
1



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().


dataArray->GetNumberOfComponents()


dataArray->GetTuple3()


GetTuple1()


GetTuple2()


GetTuple9()






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

Future solutions