ITK  5.0.0
Insight Segmentation and Registration Toolkit
WikiExamples/Meshes/LoopTriangleCellSubdivision.cxx
// Dimension and coordinate type
constexpr unsigned int Dimension = 3;
using TCoordinate = float;
// Typedefs
int main(int , char * [] )
{
// Specify the number of times the loop subdivision should be applied
constexpr unsigned int NumberOfSubdivisions = 2;
// Create a sphere and assign it to a TQEMesh variable
TSphere::Pointer sphereSource = TSphere::New();
sphereSource->Update();
TQEMesh::Pointer sphere = sphereSource->GetOutput();
// Assign the sphere to the subdivision filter
TSubdivision::Pointer subdivision = TSubdivision::New();
subdivision->SetResolutionLevels( NumberOfSubdivisions );
subdivision->SetInput( sphere );
subdivision->Update();
// Assign the subdivided sphere to its own variable
TQEMesh::Pointer subSphere = subdivision->GetOutput();
// Compare points, edges, and faces for the original and subdivided spheres
std::cout << "Original Sphere:" << std::endl;
std::cout << " Points: " << sphere->GetNumberOfPoints() << std::endl; // 66
std::cout << " Edges: " << sphere->GetNumberOfEdges() << std::endl; // 192
std::cout << " Faces: " << sphere->GetNumberOfFaces() << std::endl; // 128
std::cout << std::endl;
std::cout << "Divided Sphere: " << std::endl;
std::cout << " Points: " << subSphere->GetNumberOfPoints() << std::endl; // 1026
std::cout << " Edges: " << subSphere->GetNumberOfEdges() << std::endl; // 3072
std::cout << " Faces: " << subSphere->GetNumberOfFaces() << std::endl; // 2048
return EXIT_SUCCESS;
}