[vtkusers] PolyDataExtractNormals example doers not work as expected with cell normals
Alex Malyushytskyy
alexmalvtk at gmail.com
Fri Aug 12 17:18:10 EDT 2011
David,
Thanks for fixes and explanation (which I think is worth to add
somewhere in the help or at least in the wiki example ).
But it is still not clear to me, why filter (vtkPolyDataNormals) help
does not describe the output,
Wouldn't be useful also to change vtkPolyDataNormals help to say something like:
"vtkPolyDataNormals is a filter that computes point and/or cell
normals for a polygonal mesh and by default stores them in array of
floats or doubles named "Normals"
Is there a way to specify array name to direct output for
vtkPolyDataNormals (or for filter in general)?
Regards,
Alex
.
On Fri, Aug 12, 2011 at 8:04 AM, David Doria <daviddoria at gmail.com> wrote:
> On Thu, Aug 11, 2011 at 6:57 PM, Alex Malyushytskyy
> <alexmalvtk at gmail.com> wrote:
>> 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
>
> Alex,
>
> I understand your confusion. The multiple ways normals can be stored
> is indeed very confusing, and this is exactly what this example was
> made to demonstrate. I have made some changes:
>
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolyDataExtractNormals
>
> Basically there are 4 ways the normals could be stored (for both
> pointData and cellData). You should not assume anything about how
> someone has stored the normals, and check all of them. In two of the
> methods, you also don't know for sure the name of the array!
>
> Methods (1 and 2 would be preferred):
>
> 1) As floats, marked as normals explicitly (GetNormals())
> 2) As doubles, marked as normals explicitly (GetNormals())
> 3) As floats, as a regular array (here you'd need to know the name -
> GetArray("name"))
> 4) As doubles, as a regular array (here you'd need to know the name -
> GetArray("name"))
>
> Does the updated example clear anything up?
>
> David
>
More information about the vtkusers
mailing list