[vtkusers] Issue when reading unstructured grid on VTK legacy file
joaoroberto88
joaorobertojr88 at gmail.com
Sat Nov 7 11:03:42 EST 2015
Hello VTK Users,
I'm facing a problem reading a legacy VTK file that stores a
vtkUnstructuredGrid with some scalar arrays. Specifically, I'm interested on
waterSurfaceElevation array. When I open it on Paraview it displays
correctly (please see attached), but when I try to render it in my own
application a wrong result is shown (attached). Could anyone help me? I'm
using the code bellow to read and render the legacy file (available at
https://www.dropbox.com/s/fgm1rgne32rd0qw/output-00000001.vtk?dl=0).
std::string filename = "output-00000001.vtk";
std::string arrayName = "waterSurfaceElevation";
vtkSmartPointer<vtkGenericDataObjectReader> reader =
vtkSmartPointer<vtkGenericDataObjectReader>::New();
reader->SetFileName(filename.c_str());
reader->Update();
vtkSmartPointer<vtkUnstructuredGrid> unstructuredGrid =
reader->GetUnstructuredGridOutput();
unstructuredGrid->GetCellData()->SetActiveScalars(arrayName.c_str());
vtkSmartPointer<vtkDataSetMapper> mapper =
vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInputData(unstructuredGrid);
mapper->SetScalarModeToUseCellData();
vtkSmartPointer<vtkActor> meshActor = vtkSmartPointer<vtkActor>::New();
meshActor->SetMapper(mapper->GetPolyDataMapper());
// All rendering stuff allocated in class constructor
renderer->AddActor(meshActor);
renderer->ResetCamera();
Thanks!
<http://vtk.1045678.n5.nabble.com/file/n5734867/paraview.png>
<http://vtk.1045678.n5.nabble.com/file/n5734867/wrong_result.png>
--
View this message in context: http://vtk.1045678.n5.nabble.com/Issue-when-reading-unstructured-grid-on-VTK-legacy-file-tp5734867.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list