VTK/Examples/Broken/CellLinks

From KitwarePublic

Jump to: navigation, search

How to use vtkCellLinks::Links class? How to know how many cells GetCells returns?

CellLinks.cxx

#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkProperty.h>
#include <vtkCellLinks.h>
 
int main(int, char *[])
{
   //create an image data
  vtkSmartPointer<vtkSphereSource> sphereSource = 
      vtkSmartPointer<vtkSphereSource>::New();
  sphereSource->Update();
 
  vtkSmartPointer<vtkCellLinks> cellLinksFilter = 
      vtkSmartPointer<vtkCellLinks>::New();
  cellLinksFilter->BuildLinks(sphereSource->GetOutput());
 
  /*
  vtkCellLinks::Link link = cellLinksFilter->GetLink(0);
 
  cout << "There are " << link.ncells << endl;
 
  cout << "Point 0 is used by cells ";
 
  for(unsigned int i = 0; i < link.ncells; i++)
    {
    cout << link.cells[i] << endl;
    }
  */  
 
  vtkIdType* cells = cellLinksFilter->GetCells(0);
 
  cout << "Point 0 is used by cells ";
 
  for(unsigned int i = 0; i < 5; i++)
    {
    cout << cells[i] << endl;
    }
 
  return EXIT_SUCCESS;
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
PROJECT(CellLinks)
 
FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})
 
ADD_EXECUTABLE(CellLinks CellLinks.cxx)
TARGET_LINK_LIBRARIES(CellLinks vtkHybrid)
Personal tools