VTK/Examples/Broken/Geovis/GeoView

From KitwarePublic
< VTK‎ | Examples
Jump to navigationJump to search

GeoView.cxx

#include <vtkGeoFileTerrainSource.h>
#include <vtkGeoView.h>
#include <vtkGeoTerrain.h>
#include <vtkGeoGlobeSource.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>

int main(int argc, char* argv[])
{

  // Create the geo view.
  vtkSmartPointer<vtkGeoView> view = vtkSmartPointer<vtkGeoView>::New();
  view->DisplayHoverTextOff();
  view->GetRenderWindow()->SetMultiSamples(0);
  view->GetRenderWindow()->SetSize(400,400);

  vtkSmartPointer<vtkGeoTerrain> terrain =
      vtkSmartPointer<vtkGeoTerrain>::New();
  vtkSmartPointer<vtkGeoSource> terrainSource;
  vtkGeoGlobeSource* globeSource = vtkGeoGlobeSource::New();
  terrainSource.TakeReference(globeSource);
  terrainSource->Initialize();
  terrain->SetSource(terrainSource);
  view->SetTerrain(terrain);

  //int retVal = vtkRegressionTestImage(win);
  view->Render();
  view->GetInteractor()->Initialize();
  view->GetInteractor()->Start();

  // Shut down sources
  terrainSource->ShutDown();
  return EXIT_SUCCESS;
}

Please try the new VTKExamples website.

CMakeLists.txt

cmake_minimum_required(VERSION 2.8)

PROJECT(GeoView)

find_package(VTK REQUIRED)
include(${VTK_USE_FILE})

add_executable(GeoView MACOSX_BUNDLE GeoView.cxx)

if(VTK_LIBRARIES)
  target_link_libraries(GeoView ${VTK_LIBRARIES})
else()
  target_link_libraries(GeoView vtkHybrid vtkWidgets)
endif()

Download and Build GeoView

Click here to download GeoView. and its CMakeLists.txt file.

Once the tarball GeoView.tar has been downloaded and extracted,

cd GeoView/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:

./GeoView

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.