Hi VTK community,
Is there any options to get X,Y,Z coordinates of the cell normals?
Currently I have the following code:
normals = vtk.vtkPPolyDataNormals()
For my further processing steps I need to get coordinates (ot at least angle of the normals). I’ve found vtkDeflectNormals() class, however, I get this error with it: AttributeError: module ‘vtkmodules.all’ has no attribute ‘vtkDeflectNormals’
Normals are computed as float array and stored in cell data.
I don’t have the python code, in C++ one can do this
vtkFloatArray* normalsFloat = vtkFloatArray::SafeDownCast( polydata->GetCellData()->GetNormals() );
Thanks for your comment, I’ve tried your solution, however it works only with VTK primitives such as sphere, for example. When I use polydata->GetCellData()->GetNormals() with STL file, the result is None:
filename = “loop.STL”
source = vtk.vtkSTLReader()
polydata = vtk.vtkPolyData()
normals = polydata.GetCellData().GetNormals()
The result as I mentioned is None. I’ve tried different STL files here, but the problem persists. Is there any problem with my code or GetNormals() works only with primitives?
Get the polydata from STL reader and compute the normal as you originally posted. If you don’t compute normal you cannot expect them to be there.
To generate points at the (parametric) center of cells use vtkCellCenters