Difference between revisions of "VTK/Examples/Cxx/PolyData/CleanPolyData"

From KitwarePublic
< VTK‎ | Examples‎ | Cxx
Jump to: navigation, search
Line 1: Line 1:
When a cube is created, it has 24 vertices (4 for each face). This is done because
= '''See [https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/CleanPolyData CleanPolyData] on the new [https://lorensen.github.io/VTKExamples/site/ VTKExamples website].''' =
the normal at each face is very different. Often we would want a cube to only have 8 vertices. The vtkCleanPolyData filter removes coincident points, resulting in the cube we would expect.
<source lang="cpp">
#include <vtkSmartPointer.h>
#include <vtkCubeSource.h>
#include <vtkPolyData.h>
#include <vtkCleanPolyData.h>
int main(int, char *[])
  vtkSmartPointer<vtkCubeSource> cubeSource =
  std::cout << "Input cube has " << cubeSource->GetOutput()->GetNumberOfPoints()
    << " vertices." << std::endl;
  vtkSmartPointer<vtkCleanPolyData> cleanPolyData =
  std::cout << "Cleaned cube has " << cleanPolyData->GetOutput()->GetNumberOfPoints()
    << " vertices." << std::endl;
  return EXIT_SUCCESS;
Show the normals - this will show that there is more than one normal at each point before, and exactly one after.

Latest revision as of 16:29, 9 September 2019

See CleanPolyData on the new VTKExamples website.