Commit 16aab8e2 authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri Committed by Code Review

Merge topic 'geovis_raster_reader' into master

61e7f03d Fixed various cleanup issues
7f9c70a7 Addressed minor code clean up issues
2cd1a322 Added baseline and data for the testing
781d1b5d Fixed various minor issues
2de16eeb Added GDAL based raster reader
parents b6417845 61e7f03d
find_package(GDAL REQUIRED)
mark_as_advanced(GDAL_INCLUDE_DIR GDAL_LIBRARY)
set(GDAL_SRCS vtkGDALVectorReader.cxx)
set(GDAL_SRCS vtkGDALVectorReader.cxx vtkGDALRasterReader.cxx)
include_directories(${GDAL_INCLUDE_DIRS})
......
vtk_add_test_cxx(${vtk-module}CxxTests tests
TestGDALVectorReader.cxx
TestGDALRasterReader.cxx
)
vtk_test_cxx_executable(${vtk-module}CxxTests tests)
/*=========================================================================
Program: Visualization Toolkit
Module: TestGDALRasterReader.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include <vtkGDALRasterReader.h>
// VTK includes
#include <vtkImageActor.h>
#include <vtkCellData.h>
#include <vtkCompositePolyDataMapper.h>
#include <vtkDataSetAttributes.h>
#include <vtkDoubleArray.h>
#include <vtkLookupTable.h>
#include <vtkMapper.h>
#include <vtkMultiBlockDataSet.h>
#include <vtkNew.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRegressionTestImage.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>
#include <vtkTestUtilities.h>
// C++ includes
#include <sstream>
// Main program
int TestGDALRasterReader(int argc, char** argv)
{
const char* rasterFileName = vtkTestUtilities::ExpandDataFileName(argc, argv,
"Data/GIS/raster.tiff");
// Create reader to read shape file.
vtkNew<vtkGDALRasterReader> reader;
reader->SetFileName(rasterFileName);
reader->Update();
delete [] rasterFileName;
// We need a renderer
vtkNew<vtkRenderer> renderer;
// Get the data
vtkNew<vtkImageActor> actor;
actor->SetInputData(reader->GetOutput());
renderer->AddActor(actor.GetPointer());
// Create a render window, and an interactor
vtkNew<vtkRenderWindow> renderWindow;
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindow->AddRenderer(renderer.GetPointer());
renderWindowInteractor->SetRenderWindow(renderWindow.GetPointer());
//Add the actor to the scene
renderer->SetBackground(1.0, 1.0, 1.0);
renderWindow->SetSize(400, 400);
renderWindow->Render();
renderer->ResetCamera();
renderWindow->Render();
int retVal = vtkRegressionTestImage(renderWindow.GetPointer());
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
renderWindowInteractor->Start();
}
return !retVal;
}
......@@ -2,6 +2,7 @@ vtk_module(vtkIOGDAL
DEPENDS
vtkCommonDataModel
vtkCommonExecutionModel
vtkIOImage
TEST_DEPENDS
vtkTestingCore
vtkRendering${VTK_RENDERING_BACKEND}
......
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkGDALRasterReader.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkGDALRasterReader - Read raster file formats using GDAL.
// .SECTION Description
// vtkGDALRasterReader is a source object that reads raster files and uses
// GDAL as the underlying library for the task. GDAL is required for this
// reader. The output of the reader is a vtkUniformGrid instead of vtkImageData
// to support blanking.
//
//
// .SECTION See Also
// vtkUniformGrid, vtkImageData
#ifndef __vtkGDALRasterReader_h
#define __vtkGDALRasterReader_h
#include <vtkImageReader2.h>
#include <vtkIOGDALModule.h> // For export macro
// C++ includes
#include <string> // string is required
#include <vector> // vector is required
class VTKIOGDAL_EXPORT vtkGDALRasterReader : public vtkImageReader2
{
public:
static vtkGDALRasterReader* New();
vtkTypeMacro(vtkGDALRasterReader, vtkImageReader2);
void PrintSelf(ostream& os, vtkIndent indent);
vtkGDALRasterReader();
virtual ~vtkGDALRasterReader();
// Description:
// Set input file name
vtkSetStringMacro(FileName);
// Get input file name
vtkGetStringMacro(FileName);
// Description:
// Return proj4 spatial reference
const char* GetProjectionString() const;
// Description:
// Return geo-referenced corner points (Upper left,
// lower left, lower right, upper right)
const double* GetGeoCornerPoints();
// Description:
// Set desired width and height of the image
vtkSetVector2Macro(TargetDimensions, int);
vtkGetVector2Macro(TargetDimensions, int);
// Description:
// Get raster width and heigth
vtkGetVector2Macro(RasterDimensions, int);
//BTX
// Description:
// Return metadata as reported by GDAL
const std::vector<std::string>& GetMetaData();
//ETX
// Description:
// Return the invalid value for a pixel (for blanking purposes)
double GetInvalidValue();
//BTX
// Description:
// Return domain metadata
std::vector<std::string> GetDomainMetaData(const std::string& domain);
//ETX
// Description:
// Return driver name which was used to read the current data
const std::string& GetDriverShortName();
const std::string& GetDriverLongName();
protected:
virtual int RequestData(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
virtual int RequestInformation(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
virtual int FillOutputPortInformation(int port,
vtkInformation* info);
protected:
int TargetDimensions[2];
int RasterDimensions[2];
std::string Projection;
std::string DomainMetaData;
std::string DriverShortName;
std::string DriverLongName;
std::vector<std::string> Domains;
std::vector<std::string> MetaData;
class vtkGDALRasterReaderInternal;
vtkGDALRasterReaderInternal* Implementation;
private:
vtkGDALRasterReader(const vtkGDALRasterReader&); // Not implemented.
void operator=(const vtkGDALRasterReader&); // Not implemented
};
#endif // __vtkGDALRasterReader_h
69ec0306d3b3fd9f0f250e1e40429a28
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment