How to extract point normals from a .vtk file? -
i use vtkgenericdataobjectreader class read .vtk file contains point locations , vtk_tetra cells:
# vtk datafile version 2.0 unstructured grid ascii dataset unstructured_grid points 19002 double -0.150669 0.33708199999999999 -0.053355 0.240651 -0.40023399999999998 -0.183224 -0.15488199999999999 -0.54804799999999998 -0.210316 ... other points ... cells 75753 378765 4 3472 3996 7922 9626 4 5182 6191 12063 12612 4 5555 2996 18404 18616 ... other cells ... after read file, failed point normals by:
vtk_create(vtkgenericdataobjectreader, reader); reader->setfilename(file.tostdstring().c_str()); reader->update(); q_assert(reader->isfileunstructuredgrid()); vtk_create(vtkunstructuredgrid, ug); ug = vtkunstructuredgrid::safedowncast(reader->getoutput()); vtkdataarray* normals = ug->getpointdata()->getarray("normals"); //vtkdataarray* normals = ug->getpointdata()->getnormals(); vtk_create(vtkdatasetmapper, modelmapper); modelmapper->setinputdata(ug); modelactor->setmapper(modelmapper); // ... because normals got 0 pointer.
however, final rendered lighting effect seems reasonable. here question: (1) how vtk compute point normals in order correct light effect? (2) should point normals?
vtk got vtkpolydatanormals algorithm class allow process normals polygonal mesh.
vtk_create(vtkgenericdataobjectreader, reader); reader->setfilename(file.tostdstring().c_str()); vtk_create(vtkpolydatanormals, norms) norms->setinputconnection (reader->getoutputport ()); // output of vtkpolydatanormals instance polydata normals calculated norms->update() vtk_create(vtkdatasetmapper, modelmapper); modelmapper->setinputdata( norms->getoutput () ); vtkpolydatanormals filter computes point and/or cell normals polygonal mesh.
in case, output polydata must got non-zero normals pointer.
Comments
Post a Comment