[vtkusers] Bug? vtkNormalFilter changes # of points in polydata
Cory Quammen
cory.quammen at kitware.com
Sun Feb 5 22:14:30 EST 2017
This is likely due to the Splitting option being on by default and the
polydata having "sharp" edges that the filter assumes you want to
appear sharp. Consider an example of a cube - if you average the
normals from all coincident faces at the vertices of the cube, which
this filter does, then the cube will appear very odd. Instead, the
vtkPolyDataNormals filter splits the edges of the cube. Splitting
means that duplicate points are added to the original cube to
accommodate different normals at the same point, something that is
needed to preserve the appearance of sharp edges in a mesh. You have
the original points with normals assigned for one face of the cube,
then the added split points have normals assigned for the other
adjacent faces of the cube. Splitting is done where the angle between
adjacent normals is greater than some threshold. In this filter, that
threshold is called the "FeatureAngle".
I suspect your polydata has some sharp angles and points are being
added for splitting. The example OBJ file you linked to has reasonably
sharp edges.
HTH,
Cory
On Sun, Feb 5, 2017 at 7:19 PM, BBerco <bebe0705 at colorado.edu> wrote:
> Dear all,
> I have noticed a strange behavior of vtkNormalFilter.
>
> When called, this filter appears to change the number of vtkPolyData ->
> GetNumberOfPoints(), as illustrated below:
> *
> // returns 4586
> * std::cout << read_polydata_without_id -> GetNumberOfPoints() <<
> std::endl;
>
> // The polydata is fed to an IDFilter.
> vtkSmartPointer<vtkIdFilter> id_filter =
> vtkSmartPointer<vtkIdFilter>::New();
> id_filter -> SetIdsArrayName("ids");
> id_filter -> SetInputData(read_polydata_without_id);
> id_filter -> PointIdsOn();
> id_filter -> CellIdsOn();
>
> id_filter -> Update();
> * // returns 4586
> * std::cout << id_filter -> GetOutput() -> GetNumberOfPoints() <<
> std::endl;
>
> // The normals are added to the polydata
> vtkSmartPointer<vtkPolyDataNormals> normal_filter =
> vtkPolyDataNormals::New();
> normal_filter -> ComputePointNormalsOff();
> normal_filter -> ComputeCellNormalsOn();
> normal_filter -> SetInputConnection(id_filter -> GetOutputPort());
> normal_filter -> Update ();
>
> * // returns 4716
> * std::cout << normal_filter -> GetOutput() -> GetNumberOfPoints() <<
> std::endl;
>
>
> I have noticed this issue with several polydatas created from an input obj
> file such as this one (http://echo.jpl.nasa.gov/asteroids/shapes/kw4a.obj).
> Polydata generated from VTK seem unchanged.
>
> In any case, I find strange that this property gets modified. Am I missing
> something? Why would adding the normals to the polydata change the number of
> points it contains?
>
> Best,
> Ben
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Bug-vtkNormalFilter-changes-of-points-in-polydata-tp5742068.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
--
Cory Quammen
Staff R&D Engineer
Kitware, Inc.
More information about the vtkusers
mailing list