Skip to content

Instantly share code, notes, and snippets.

@suplo
Created August 2, 2013 01:21
Show Gist options
  • Save suplo/6136823 to your computer and use it in GitHub Desktop.
Save suplo/6136823 to your computer and use it in GitHub Desktop.
vtkSmartPointer<vtkSTLReader> stlReader = vtkSmartPointer<vtkSTLReader>::New();
vtkSmartPointer<vtkTriangleFilter> triangle = vtkSmartPointer<vtkTriangleFilter>::New();
vtkSmartPointer<vtkPolyData> mesh;
try {
stlReader->SetFileName(fileName);
triangle->SetInputConnection(stlReader->GetOutputPort());
triangle->Update();
mesh = triangle->GetOutput();
nVertices = mesh->GetNumberOfPoints(); // number of vertices
nTriangles = mesh->GetNumberOfPolys(); // number of triangles
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment