Waterflow
Visualize water in terrain
DataHandler Class Reference

Loads and modifies terrain data for easier use. More...

#include <readData.h>

List of all members.

Public Member Functions

 DataHandler (const char *inputfile)
 Reads DEM data, scales it and generates a model.
 ~DataHandler ()
 Handle the internal pointers.
float getCoord (int col, int row)
 Returns a datapoint from the mapdata.
float * getData ()
 Get a pointer to the mapdata data.
int getDataHeight ()
 Getter for the height of the data.
int getDataWidth ()
 Getter for the width of the data.
int getElem ()
 Getter for the number of datapoints.
GLuint getHeightBuffer ()
 Get the buffer ID containing the height data.
GLfloat getTerrainScale ()
 Get the terrain scale.
GLfloat giveHeight (GLfloat x, GLfloat z)
 Gives a height for a certain position in the terrain.

Private Member Functions

void normConvCompute ()
 Performs normalized convolution of the input data as a single computeshader.
void readDEM (const char *inputfile)
 Reads the input data to the private mapdata struct.

Private Attributes

mapdatareaddata
 mapdata struct for the loaded terrain data.
GLuint terrainBufferID
 terrainheight buffer corresponding to readdata data but on GPU.
GLfloat terrainScale
 Height scale for the terrain. Calculated as the diff between min and max in the input data.

Detailed Description

Loads and modifies terrain data for easier use.

Use the DataHandler class to import terrain data and generate terrain. It automatically scales the data for easier filtering, and also generates an initial terrain from the data after the data is loaded.

Definition at line 36 of file readData.h.


Constructor & Destructor Documentation

DataHandler::DataHandler ( const char *  inputfile)

Reads DEM data, scales it and generates a model.

Reads the inputfile for DEM data and populates a mapdata struct, and creates the buffer for Normalized convolution and finally generates an initial terrain height map.

Parameters:
inputfilepath to DEM data.
See also:
readDEM()
GenerateTerrain()

Definition at line 15 of file readData.cpp.


Member Function Documentation

float DataHandler::getCoord ( int  col,
int  row 
)

Returns a datapoint from the mapdata.

Simplifies the getting of data by allowing access by coordinate since the data is stored in a linear vector.

Parameters:
colinput column
rowinput row
Returns:
data(col,row)

Definition at line 33 of file readData.cpp.

float* DataHandler::getData ( ) [inline]

Get a pointer to the mapdata data.

For uses like read all data to FBO or from GPU back to CPU.

Returns:
pointer to the beginning of the mapdata data.

Definition at line 73 of file readData.h.

int DataHandler::getDataHeight ( ) [inline]

Getter for the height of the data.

Returns:
the number of rows.

Definition at line 81 of file readData.h.

int DataHandler::getDataWidth ( ) [inline]

Getter for the width of the data.

Returns:
the number of columns.

Definition at line 77 of file readData.h.

int DataHandler::getElem ( ) [inline]

Getter for the number of datapoints.

Returns:
columns * rows.

Definition at line 85 of file readData.h.

GLuint DataHandler::getHeightBuffer ( ) [inline]

Get the buffer ID containing the height data.

Returns:
Returns the gl buffer id to the buffer containing height data.

Definition at line 93 of file readData.h.

GLfloat DataHandler::getTerrainScale ( ) [inline]

Get the terrain scale.

Returns:
Return a float of the diff between max and min sample in the data.

Definition at line 89 of file readData.h.

GLfloat DataHandler::giveHeight ( GLfloat  x,
GLfloat  z 
)

Gives a height for a certain position in the terrain.

Used if the interpolated height data for a certain point is needed Written by Ingemar Ragnemalm but slightly modfied

Parameters:
xinput width position
zinput depth position
See also:
GenerateTerrain()
giveNormal()

Definition at line 53 of file readData.cpp.

void DataHandler::normConvCompute ( ) [private]

Performs normalized convolution of the input data as a single computeshader.

At the end of the function terrainBufferID containins the buffer ID to the heightmap. The heightmap is also stored in the terrainTexture and will be bound to texture 3

Definition at line 165 of file readData.cpp.

void DataHandler::readDEM ( const char *  inputfile) [private]

Reads the input data to the private mapdata struct.

Currently uses readFile to bulk read the file and then reads out the data info with sscanf and then another implementation of strtof to convert the data to floats.

Parameters:
inputfilepath to DEM data file.

Definition at line 108 of file readData.cpp.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations