|
|
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.
| |
− | | |
− | ==CleanPolyData.cxx== | |
− | <source lang="cpp">
| |
− | #include <vtkSmartPointer.h>
| |
− | #include <vtkCubeSource.h>
| |
− | #include <vtkPolyData.h>
| |
− | #include <vtkCleanPolyData.h>
| |
− | | |
− | int main(int, char *[])
| |
− | {
| |
− | vtkSmartPointer<vtkCubeSource> cubeSource =
| |
− | vtkSmartPointer<vtkCubeSource>::New();
| |
− | cubeSource->Update();
| |
− |
| |
− | std::cout << "Input cube has " << cubeSource->GetOutput()->GetNumberOfPoints()
| |
− | << " vertices." << std::endl;
| |
− |
| |
− | vtkSmartPointer<vtkCleanPolyData> cleanPolyData =
| |
− | vtkSmartPointer<vtkCleanPolyData>::New();
| |
− | cleanPolyData->SetInputConnection(cubeSource->GetOutputPort());
| |
− | cleanPolyData->Update();
| |
− |
| |
− | std::cout << "Cleaned cube has " << cleanPolyData->GetOutput()->GetNumberOfPoints()
| |
− | << " vertices." << std::endl;
| |
− |
| |
− | return EXIT_SUCCESS;
| |
− | }
| |
− | | |
− | </source>
| |
− | | |
− | {{VTKCMakeLists|{{SUBPAGENAME}}}}
| |
− | | |
− | Show the normals - this will show that there is more than one normal at each point before, and exactly one after.
| |
− | [[Category:VTKAddVisualization]] | |