An abstract raster data map. More...
#include <Preprocess.h>
Public Member Functions | |
InputMap (int width, int height, int channels, int tileSize, int cache=20) | |
Creates a new map. | |
~InputMap () | |
Deletes this input map. | |
virtual vec4f | getValue (int x, int y)=0 |
Returns the value of the given pixel. | |
virtual float * | getValues (int tx, int ty) |
Returns the values of the pixels of the given tile. | |
vec4f | get (int x, int y) |
Returns the value of the given pixel. | |
Public Attributes | |
int | width |
The width of this map. | |
int | height |
The height of this map. | |
int | channels |
The number of components per pixel of this map. | |
int | tileSize |
The tile size to use when reading this map by tile. |
An abstract raster data map.
A map is a 2D array of pixels, whose values can come from anywhere (this depends on how you implement the getValue method). A map can be read pixel by pixel, or tile by tile. The tiles are cached for better efficiency.
proland::InputMap::InputMap | ( | int | width, | |
int | height, | |||
int | channels, | |||
int | tileSize, | |||
int | cache = 20 | |||
) |
Creates a new map.
width | the width of this map. | |
height | the height of this map. | |
channels | the number of components per pixel of this map. | |
tileSize | the tile size to use when reading this map by tile. The width and height must be multiples of this size. | |
cache | how much tiles can be cached at the same time. |
proland::InputMap::~InputMap | ( | ) |
Deletes this input map.
vec4f proland::InputMap::get | ( | int | x, | |
int | y | |||
) |
Returns the value of the given pixel.
This method uses a cache for better efficiency: it reads the tile containing the given pixel, if it is not already in cache, puts it in cache, and returns the requested pixel from this tile.
x | the x coordinate of the pixel to be read. | |
y | the y coordinate of the pixel to be read. |
virtual vec4f proland::InputMap::getValue | ( | int | x, | |
int | y | |||
) | [pure virtual] |
Returns the value of the given pixel.
You can implement this method any way you want.
x | the x coordinate of the pixel to be read. | |
y | the y coordinate of the pixel to be read. |
virtual float* proland::InputMap::getValues | ( | int | tx, | |
int | ty | |||
) | [virtual] |
Returns the values of the pixels of the given tile.
The default implementation of this method calls getValue to read each pixel. If getValue reads a value from disk, it is strongly advised to override this method for better efficiency.
tx | the tx coordinate of the pixel to be read. | |
ty | the ty coordinate of the pixel to be read. |
The number of components per pixel of this map.
The height of this map.
The tile size to use when reading this map by tile.
The width and height must be multiples of this size.
The width of this map.