VTK/Examples/Cxx/GeometricObjects/Planes

From KitwarePublic

Jump to: navigation, search

Planes.cxx

#include <vtkSmartPointer.h>
#include <vtkPlanes.h>
#include <vtkCamera.h>
#include <vtkSphereSource.h>
 
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyData.h>
 
int main(int, char *[])
{
  // one way
  {
  vtkSmartPointer<vtkCamera> camera =
    vtkSmartPointer<vtkCamera>::New();
  double planesArray[24];
 
  camera->GetFrustumPlanes(1, planesArray);
 
  vtkSmartPointer<vtkPlanes> planes =
    vtkSmartPointer<vtkPlanes>::New();
  planes->SetFrustumPlanes(planesArray);
  }
 
  // another way
  {
  vtkSmartPointer<vtkSphereSource> sphereSource =
    vtkSmartPointer<vtkSphereSource>::New();
  sphereSource->Update();
  double bounds[6];
  sphereSource->GetOutput()->GetBounds(bounds);
 
  vtkSmartPointer<vtkPlanes> planes =
    vtkSmartPointer<vtkPlanes>::New();
  planes->SetBounds(bounds);
  }
 
  return EXIT_SUCCESS;
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
 
PROJECT(Planes)
 
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
 
if (APPLE)
  add_executable(Planes MACOSX_BUNDLE Planes.cxx)
else()
  add_executable(Planes Planes.cxx)
endif()
 
if(VTK_LIBRARIES)
  target_link_libraries(Planes ${VTK_LIBRARIES})
else()
  target_link_libraries(Planes vtkHybrid )
endif()
Personal tools