vtkNew<vtkStructuredGrid> structuredGrid;
vtkNew<vtkPoints> points;
unsigned int numi = 10;
unsigned int numj = 10;
unsigned int numk = 10;
for (unsigned int k = 0; k < numk; k++)
{
for (unsigned int j = 0; j < numj; j++)
{
for (unsigned int i = 0; i < numi; i++)
{
points->InsertNextPoint(i*3, j*3, k*3);
}
}
}
// Specify the dimensions of the grid
structuredGrid->SetDimensions(numi, numj, numk);
structuredGrid->SetPoints(points);
std::cout << "There are " << structuredGrid->GetNumberOfPoints()
<< " points before shrinking." << std::endl;
std::cout << "There are " << structuredGrid->GetNumberOfCells()
<< " cells before shrinking." << std::endl;
vtkNew<vtkShrinkFilter> shrinkFilter;
shrinkFilter->SetInputData(structuredGrid);
shrinkFilter->SetShrinkFactor(1);
shrinkFilter->Update();
vtkNew<vtkExtractEdges> extract;
extract->SetInputData(shrinkFilter->GetOutput());
std::cout << extract->GetOutput()->GetNumberOfCells() << std::endl;
vtkNew<vtkTubeFilter> tubes;
tubes->SetInputConnection(extract->GetOutputPort());
tubes->SetNumberOfSides(4);
tubes->SetRadius(0.01 * 10);
tubes->Update();
vtkNew<vtkPolyDataMapper> ma;
vtkNew<vtkActor> va;
ma->SetInputData(tubes->GetOutput());
va->SetMapper(ma);