proland::ResidualProducer Class Reference
[dem]

A TileProducer to load elevation residuals from disk to CPU memory. More...

#include <ResidualProducer.h>

List of all members.

Public Member Functions

 ResidualProducer (ptr< TileCache > cache, const char *name, int deltaLevel=0, float zscale=1.0)
 Creates a new ResidualProducer.
virtual ~ResidualProducer ()
 Deletes this ResidualProducer.
virtual int getBorder ()
 Returns the size in pixels of the borders around each tile.
void addProducer (ptr< ResidualProducer > p)
 Adds a ResidualProducer to provide more details in some region.

Protected Member Functions

 ResidualProducer ()
 Creates an uninitialized ResidualProducer.
void init (ptr< TileCache > cache, const char *name, int deltaLevel=0, float zscale=1.0)
 Initializes this ResidualProducer.
void init (ptr< ResourceManager > manager, Resource *r, const string &name, ptr< ResourceDescriptor > desc, const TiXmlElement *e=NULL)
 Initializes this ResidualProducer from a Resource.
int getMinLevel ()
 Returns the stored tile level of the first tile of size tileSize.
int getDeltaLevel ()
 Returns the stored tiles level that must be considered as the root level in this producer.
void upsample (int level, int tx, int ty, float *parentTile, float *result)
 Upsamples the elevations of a parent tile into a sub tile.

Private Member Functions

int getTileSize (int level)
 Returns the size of tiles of the given level (without borders).
int getTileId (int level, int tx, int ty)
 Returns the id of the given tile.
void readTile (int level, int tx, int ty, unsigned char *compressedData, unsigned char *uncompressedData, float *tile, float *result)
 Reads compressed tile data on disk, uncompress it and scale it with scale.

Private Attributes

string name
 The name of the file containing the residual tiles to load.
int tileSize
 The size of the tiles whose level (on disk) is at least minLevel.
int rootLevel
 The level of the root of the tile pyramid managed by this producer in the global set of tile pyramids describing a terrain.
int deltaLevel
 The stored tiles level that must be considered as the root level in this producer.
int rootTx
 The logical x coordinate of the root of the tile pyramid managed by this producer in the global set of tile pyramids describing a terrain.
int rootTy
 The logical y coordinate of the root of the tile pyramid managed by this producer in the global set of tile pyramids describing a terrain.
int minLevel
 The stored tile level of the first tile of size tileSize.
int maxLevel
 The maximum level of the stored tiles on disk (inclusive, and relatively to rootLevel).
float scale
 A scaling factor to be applied to all residuals read from disk.
unsigned int header
 Offset of the first stored tile on disk.
unsigned int * offsets
 The offsets of each tile on disk, relatively to offset, for each tile id (see getTileId).
void * mutex
 A mutex used to serializes accesses to the file storing the tiles.
FILE * tileFile
 The file storing the residual tiles on disk.
vector< ptr< ResidualProducer > > producers
 The "subproducers" providing more details in some regions.

Static Private Attributes

static void * key
 A key to store thread specific buffers used to produce the tiles.

Detailed Description

A TileProducer to load elevation residuals from disk to CPU memory.

See Residual producer.

Authors:
Eric Bruneton, Antoine Begault

Constructor & Destructor Documentation

proland::ResidualProducer::ResidualProducer ( ptr< TileCache >  cache,
const char *  name,
int  deltaLevel = 0,
float  zscale = 1.0 
)

Creates a new ResidualProducer.

Parameters:
cache the cache to store the produced tiles. The underlying storage must be a CPUTileStorage of float type. The size of tiles in this storage size must be equal to the size of the tiles stored on disk, borders included.
name the name of the file containing the tiles to load.
deltaLevel the stored tiles level that must be considered as the root level in this producer. Must be less than or equal to getMinLevel().
zscale a vertical scaling factor to be applied to all elevations.
virtual proland::ResidualProducer::~ResidualProducer (  )  [virtual]

Deletes this ResidualProducer.

proland::ResidualProducer::ResidualProducer (  )  [protected]

Creates an uninitialized ResidualProducer.


Member Function Documentation

void proland::ResidualProducer::addProducer ( ptr< ResidualProducer p  ) 

Adds a ResidualProducer to provide more details in some region.

Each producer manages a tile pyramid. A "subproducer" can provide a "subpyramid" of tiles in some region, and so on recursively (see Residual producer).

Parameters:
p a ResidualProducer providing more details in some region.
virtual int proland::ResidualProducer::getBorder (  )  [virtual]

Returns the size in pixels of the borders around each tile.

int proland::ResidualProducer::getDeltaLevel (  )  [protected]

Returns the stored tiles level that must be considered as the root level in this producer.

Must be less than or equal to getMinLevel().

int proland::ResidualProducer::getMinLevel (  )  [protected]

Returns the stored tile level of the first tile of size tileSize.

See Residual producer.

int proland::ResidualProducer::getTileId ( int  level,
int  tx,
int  ty 
) [private]

Returns the id of the given tile.

This id is used to find the offset the tile data on disk, using offsets.

Parameters:
level the level of the tile.
tx the logical x coordinate of the tile.
ty the logical y coordinate of the tile.
Returns:
the id of the given tile.
int proland::ResidualProducer::getTileSize ( int  level  )  [private]

Returns the size of tiles of the given level (without borders).

This size can vary with the level if getMinLevel is not 0 (see Residual producer).

Parameters:
level a quadtree level.
void proland::ResidualProducer::init ( ptr< ResourceManager >  manager,
Resource *  r,
const string &  name,
ptr< ResourceDescriptor >  desc,
const TiXmlElement *  e = NULL 
) [protected]

Initializes this ResidualProducer from a Resource.

Parameters:
manager the manager that will manage the created resource.
r the resource.
name the resource name.
desc the resource descriptor.
e an optional XML element providing contextual information (such as the XML element in which the resource descriptor was found).
void proland::ResidualProducer::init ( ptr< TileCache >  cache,
const char *  name,
int  deltaLevel = 0,
float  zscale = 1.0 
) [protected]

Initializes this ResidualProducer.

See ResidualProducer.

void proland::ResidualProducer::readTile ( int  level,
int  tx,
int  ty,
unsigned char *  compressedData,
unsigned char *  uncompressedData,
float *  tile,
float *  result 
) [private]

Reads compressed tile data on disk, uncompress it and scale it with scale.

Parameters:
level the level of the tile.
tx the logical x coordinate of the tile.
ty the logical y coordinate of the tile.
compressedData where the compressed tile data must be stored.
uncompressedData where the uncompressed data must be stored.
tile an optional tile to be added to the result. Maybe NULL.
result where the uncompressed data, scaled by scale and optionally offseted by 'tile', must be stored.
void proland::ResidualProducer::upsample ( int  level,
int  tx,
int  ty,
float *  parentTile,
float *  result 
) [protected]

Upsamples the elevations of a parent tile into a sub tile.

This method is used to compute the root tile from the first residual tiles when getDeltaLevel is not 0.

Parameters:
level the level of the elevation tile to produce.
tx the logical x coordinate of the tile to produce.
ty the logical y coordinate of the tile to produce.
parentTile the elevations of the parent tile (level-1,tx/2,ty/2).
result the upsampled elevations for the sub tile (level,tx,ty).

Member Data Documentation

The stored tiles level that must be considered as the root level in this producer.

Must be less than or equal to getMinLevel().

unsigned int proland::ResidualProducer::header [private]

Offset of the first stored tile on disk.

The offsets indicated in the tile offsets array offsets are relative to this offset.

void* proland::ResidualProducer::key [static, private]

A key to store thread specific buffers used to produce the tiles.

The maximum level of the stored tiles on disk (inclusive, and relatively to rootLevel).

The stored tile level of the first tile of size tileSize.

See Residual producer.

A mutex used to serializes accesses to the file storing the tiles.

The name of the file containing the residual tiles to load.

unsigned int* proland::ResidualProducer::offsets [private]

The offsets of each tile on disk, relatively to offset, for each tile id (see getTileId).

The "subproducers" providing more details in some regions.

Each subproducer can have its own subproducers, recursively.

The level of the root of the tile pyramid managed by this producer in the global set of tile pyramids describing a terrain.

Can be different from 0 when multiple pyramids are used, to provide more details in some regions.

The logical x coordinate of the root of the tile pyramid managed by this producer in the global set of tile pyramids describing a terrain.

Can be different from 0 when multiple pyramids are used, to provide more details in some regions.

The logical y coordinate of the root of the tile pyramid managed by this producer in the global set of tile pyramids describing a terrain.

Can be different from 0 when multiple pyramids are used, to provide more details in some regions.

A scaling factor to be applied to all residuals read from disk.

The file storing the residual tiles on disk.

The size of the tiles whose level (on disk) is at least minLevel.

This size does not include the borders. A tile contains (tileSize+5)*(tileSize+5) samples.


Generated on Sat May 12 09:42:13 2012 for proland by  doxygen 1.6.1