Created
November 20, 2017 10:09
-
-
Save esmitt/820ee8080fc1993865ae1e75e1d721b6 to your computer and use it in GitHub Desktop.
Loop subdivision algorithm for an input OBJ. the output is a subdivide mesh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just for testing, a Loop subdivision algorithm to the input OBJ | |
// the output is the subdivide mesh | |
vtkSmartPointer<vtkPolyData> Subdivide(vtkSmartPointer<vtkPolyData> reader) | |
{ | |
// Subdivision filters only work on triangles | |
vtkSmartPointer<vtkTriangleFilter> triangles = vtkSmartPointer<vtkTriangleFilter>::New(); | |
triangles->SetInputData(reader); | |
triangles->Update(); | |
vtkSmartPointer<vtkPolyData> originalMesh = triangles->GetOutput(); // this is the original mesh actually | |
vtkSmartPointer<vtkPolyDataAlgorithm> subdivisionFilter = vtkSmartPointer<vtkLoopSubdivisionFilter >::New(); | |
dynamic_cast<vtkLoopSubdivisionFilter *> (subdivisionFilter.GetPointer())->SetNumberOfSubdivisions(2); | |
subdivisionFilter->SetInputData(originalMesh); | |
subdivisionFilter->Update(); | |
return subdivisionFilter->GetOutput(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment