[vtkusers] how to copy point coordinates to an array
Hal Canary
hal at cs.unc.edu
Tue May 8 07:08:28 EDT 2012
On 05/08/2012 06:43 AM, elem wrote:
> hello
> i need to copy point coordinates which i read from the input mesh to an
> array
> because i have to change (point coordinates) but i'd like to let the
> original coordinates unchanged !
>
> what i must do ! i m new in vtk and i neeeed help .
> thanks;
Will something like this work?
vtkDoubleArray * getcoords(vtkPointSet * pointSet) {
vtkPoints * points = pointSet->GetPoints();
int numberOfPoints = points->GetNumberOfPoints();
vtkDoubleArray * coordinates = vtkDoubleArray::New();
coordinates->SetName("coordinates");
coordinates->SetNumberOfComponents(3);
coordinates->SetNumberOfTuples(numberOfPoints);
for (int ptId = 0; ptId < numberOfPoints; ptId++) {
double x[3];
pointSet->GetPoint(ptId, x);
coordinates->SetTupleValue(ptId,x);
}
return coordinates;
}
--
Hal Canary
http://cs.unc.edu/~hal/
More information about the vtkusers
mailing list