[vtkusers] how to get the scalar or vector data from vtkstructuredgrid
David Doria
daviddoria at gmail.com
Tue Nov 5 09:11:02 EST 2013
On Mon, Nov 4, 2013 at 5:43 PM, Soumya Dutta <soumya.nsec at gmail.com> wrote:
> Hi All,
>
> I am new to vtk and trying to find my way to use vtk structuredgrid. I have
> a plot3d data that has several variable and vectors. I loaded the file using
> following code:
>
> vtkSmartPointer<vtkMultiBlockPLOT3DReader> reader =
> vtkSmartPointer<vtkMultiBlockPLOT3DReader>::New();
> reader->SetXYZFileName(xyzFilename.c_str());
> reader->SetQFileName(qFilename.c_str());
> reader->SetAutoDetectFormat(1);
> reader->SetScalarFunctionNumber(110);
> reader->SetVectorFunctionNumber(200);
>
>
> the I did the following to convert it into a structured grid:
>
> vtkSmartPointer<vtkStructuredGrid> sgrid =
> vtkSmartPointer<vtkStructuredGrid>::New();
> sgrid = vtkStructuredGrid::SafeDownCast(reader->GetOutput()->GetBlock(0));
>
> now how can I can I access individual scalar values from this grid data
> structure?
>
> If I do the following:
>
> vtkPoints* pts;
> pts = sgrid->GetPoints();
>
> I think I am getting the x,y,z locations of the points.. but I am not able
> to access the fields and their scalar values. Any kind of help would be
> appreciated.
>
> --
> Yours' Sincerely,
> Soumya Dutta
Are you looking for vtkPointData* pointData = sgrid->GetPointData()?
There are some examples that explain how to set and retrieve data from
points and cells (the examples are mostly for vtkPolyData, but they
should apply to vtkStructuredGrid as well):
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/MiscPointData
David
More information about the vtkusers
mailing list