hnourzad
hnourzad

Reputation: 29

How to get faces and vertices from vtkVoxelContoursToSurfaceFilter?

I am following the ContoursToSurface (https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/ContoursToSurface/) example from VTK website. My question is simply how to get the faces and vertices after vtkVoxelContoursToSurfaceFilter acts on the contours?

The number of different elements (Poly,Verts,Pieces,Points, Lines and Cells) after transforming back the output of filter from ijk coordinate to world coordinate before visualizing:

std::cout << "GetNumberOfPolys :" << std::to_string( transformFilter->GetOutput(0)->GetNumberOfPolys()) << std::endl;
std::cout << "GetNumberOfPieces :" << std::to_string( transformFilter->GetOutput(0)->GetNumberOfPieces()) << std::endl;
std::cout << "GetNumberOfLines :" << std::to_string( transformFilter->GetOutput(0)->GetNumberOfLines()) << std::endl;
std::cout << "GetNumberOfVerts :" << std::to_string( transformFilter->GetOutput(0)->GetNumberOfVerts()) << std::endl;
std::cout << "GetNumberOfPoints :" << std::to_string( transformFilter->GetOutput(0)->GetNumberOfPoints()) << std::endl;
std::cout << "GetNumberOfCells :" << std::to_string( transformFilter->GetOutput(0)->GetNumberOfCells()) << std::endl;

This outputs the following (which I was not expecting)?

GetNumberOfPolys :0
GetNumberOfPieces :1
GetNumberOfLines :0
GetNumberOfVerts :0
GetNumberOfPoints :0
GetNumberOfCells :0

Upvotes: 0

Views: 1260

Answers (1)

Mithridates the Great
Mithridates the Great

Reputation: 483

The results of vtkVoxelContoursToSurfaceFilter is a vtkPolyData object. So:

pd = transformFilter->GetOutput();

// Extracting vertices:

vertices = pd->GetPoints();

// Extracting faces (cells):

cells = pd->GetCells();

You can access individual vertices or cells by specifying their ids:

// Extracting point with id = 0:
vert0 = vertices->GetPoint(0);

//Extracting cell with id = 0:
cell0 = cells->GetCell(0);

Upvotes: 1

Related Questions