VTK/Examples/Broken/CellLinks
From KitwarePublic
Jump to navigationJump to searchHow to use vtkCellLinks::Links class? How to know how many cells GetCells returns?
Contents
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;
}
Please try the new VTKExamples website.
CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
PROJECT(CellLinks)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
add_executable(CellLinks MACOSX_BUNDLE CellLinks.cxx)
if(VTK_LIBRARIES)
target_link_libraries(CellLinks ${VTK_LIBRARIES})
else()
target_link_libraries(CellLinks vtkHybrid vtkWidgets)
endif()
Download and Build CellLinks
Click here to download CellLinks. and its CMakeLists.txt file.
Once the tarball CellLinks.tar has been downloaded and extracted,
cd CellLinks/build
- If VTK is installed:
cmake ..
- If VTK is not installed but compiled on your system, you will need to specify the path to your VTK build:
cmake -DVTK_DIR:PATH=/home/me/vtk_build ..
Build the project:
make
and run it:
./CellLinks
WINDOWS USERS PLEASE NOTE: Be sure to add the VTK bin directory to your path. This will resolve the VTK dll's at run time.