[vtkusers] PolyDataExtractNormals example doers not work as expected with cell normals
Alex Malyushytskyy
alexmalvtk at gmail.com
Thu Aug 11 18:57:44 EDT 2011
I needed to extract cell normals generated by vtkPolyDataNormals
and tried to use code from
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataExtractNormals
on two versions of vtk (5.4.2 and 5.6.1)
On both cell normals were not working as expected from example.
First of all vtkPolyDataNormals generates vtkFloatArray instead of
vtkDoubleArray as an example,
second name of cell array is "Normals" and not "cellNormals"
I suggest to change example
from:
///////////////////////////////////////////////////////////////////////////////////
// Double cell normals
vtkSmartPointer<vtkDoubleArray> normalData4 =
vtkDoubleArray::SafeDownCast(polydata->GetCellData()->GetNormals("cellNormals"));
if(normalData4)
{
std::cout << "There are " << normalData4->GetNumberOfComponents()
<< " components in NormalData4 (double Cell \"Cell
Normals\")" << std::endl;
return true;
}
to:
///////////////////////////////////////////////////////////////////////////////////
// Float cell normals
vtkSmartPointer<vtkFloatArray > normalData4 =
vtkDoubleArray::SafeDownCast(polydata->GetCellData()->GetNormals("Normals"));
if(normalData4)
{
std::cout << "There are " << normalData4->GetNumberOfComponents()
<< " components in NormalData4 (float Cell \"Cell
Normals\")" << std::endl;
return true;
}
Regards,
Alex
More information about the vtkusers
mailing list