vtHeightFieldGrid3d Class Reference

Inheritance diagram for vtHeightFieldGrid3d:

Inheritance graph
[legend]
List of all members.

Public Member Functions

void Initialize (const LinearUnits units, const DRECT &earthextents, float fMinHeight, float fMaxHeight, int cols, int rows)
virtual void SetEarthExtents (const DRECT &ext)
bool CastRayToSurface (const FPoint3 &point, const FPoint3 &dir, FPoint3 &result) const
bool LineOfSight (const FPoint3 &point1, const FPoint3 &point2) const
DPoint2 GetSpacing () const
FPoint2 GetWorldSpacing () const
void GetDimensions (int &nColumns, int &nRows) const
void EarthToGrid (const DPoint2 &epos, IPoint2 &ipos)
void WorldToGrid (const FPoint3 &pos, IPoint2 &ipos)
float GetInterpolatedElevation (double findex_x, double findex_y) const
int FindNumUnknown ()
virtual float GetElevation (int iX, int iZ, bool bTrue=false) const =0
virtual void GetWorldLocation (int i, int j, FPoint3 &loc, bool bTrue=false) const =0
bool ColorDibFromElevation (vtBitmapBase *pBM, const ColorMap *cmap, int iGranularity, const RGBAi &nodata, bool progress_callback(int)=NULL)
bool ColorDibFromTable (vtBitmapBase *pBM, std::vector< RGBi > &table, float fMin, float fMax, const RGBAi &nodata, bool progress_callback(int)=NULL)
void ShadeDibFromElevation (vtBitmapBase *pBM, const FPoint3 &light_dir, float fLightFactor, float fAmbient=0.1f, float fGamma=1.0f, bool bTrue=false, bool progress_callback(int)=NULL)
void ShadeQuick (vtBitmapBase *pBM, float light_factor, bool bTrue=false, bool progress_callback(int)=NULL)
void ShadowCastDib (vtBitmapBase *pBM, const FPoint3 &ight_dir, float fLightFactor, float fAmbient, bool progress_callback(int)=NULL)

Protected Attributes

int m_iColumns
int m_iRows
float m_fXStep
float m_fZStep
double m_dXStep
double m_dYStep

Detailed Description

This class extends vtHeightField3d with the knowledge of operating on a regular grid of elevation values.


Member Function Documentation

bool vtHeightFieldGrid3d::CastRayToSurface const FPoint3 point,
const FPoint3 dir,
FPoint3 result
const [virtual]
 

Tests a ray against a heightfield grid.

Note: This algorithm is not guaranteed to give absolutely correct results, but it is reasonably fast and efficient. It checks a series of points along the ray against the terrain. When a pair of points (segment) is found to straddle the terrain, it refines the segment in a binary fashion.

Since the length of the test is proportional to a single grid element, there is a small chance that it will give results that are off by a small distance (less than 1 grid element)

Returns:
true if hit terrain. The resulting point of intersection is placed in the 'result' argument.

Implements vtHeightField3d.

bool vtHeightFieldGrid3d::ColorDibFromElevation vtBitmapBase pBM,
const ColorMap cmap,
int  iGranularity,
const RGBAi nodata,
bool   progress_callback(int) = NULL
 

Use the height data in the grid to fill a bitmap with colors.

Parameters:
pBM The bitmap to be colored.
cmap The mapping of elevation values to colors.
iGranularity The smoothness of the mapping, expressed as the size of the internal mapping table. 2000 is a generally good value.
nodata The color to use for NODATA areas, where there are no elevation values.
progress_callback If supplied, this function will be called back with a value of 0 to 100 as the operation progresses.
Returns:
true if any invalid elevation values were encountered.

bool vtHeightFieldGrid3d::ColorDibFromTable vtBitmapBase pBM,
std::vector< RGBi > &  table,
float  fMin,
float  fMax,
const RGBAi nodata,
bool   progress_callback(int) = NULL
 

Use the height data in the grid and a colormap fill a bitmap with colors. Any undefined heixels in the source will be fill with red (255,0,0).

Parameters:
pBM The bitmap to be colored.
table The table of colors.
fMin,fMax The range of valid elevation values expect in the input.
nodata The color to use for NODATA areas, where there are no elevation values.
progress_callback If supplied, this function will be called back with a value of 0 to 100 as the operation progresses.
Returns:
true if any invalid elevation values were encountered.

void vtHeightFieldGrid3d::EarthToGrid const DPoint2 epos,
IPoint2 ipos
 

Convert a point from earth coordinates to the integer coordinates of the grid.

int vtHeightFieldGrid3d::FindNumUnknown  ) 
 

Count the number of unknown (invalid) heixels in this grid.

void vtHeightFieldGrid3d::GetDimensions int &  nColumns,
int &  nRows
const
 

Get the grid size of the grid. The values are placed into the arguments by reference.

Parameters:
nColumns The number of columns (east-west)
nRows THe number of rows (north-south)

float vtHeightFieldGrid3d::GetInterpolatedElevation double  findex_x,
double  findex_y
const
 

Get the interpolated height of the grid at a specific grid coordinate, where the coordinates can be non-integer; the result is interpolated between the source heixels when possible (i.e. not at the edge)

Parameters:
findex_x Floating point index, from 0 to width in heixels.
findex_y Floating point index, from 0 to height in heixels.

DPoint2 vtHeightFieldGrid3d::GetSpacing  )  const
 

Get the grid spacing, the width of each column and row.

bool vtHeightFieldGrid3d::LineOfSight const FPoint3 point1,
const FPoint3 point2
const
 

Returns:
true if a line of sight exists between point1 and point2.

void vtHeightFieldGrid3d::SetEarthExtents const DRECT ext  )  [virtual]
 

Set the geographic extents of the grid.

Reimplemented from vtHeightField3d.

void vtHeightFieldGrid3d::ShadeDibFromElevation vtBitmapBase pBM,
const FPoint3 light_dir,
float  fLightFactor,
float  fAmbient = 0.1f,
float  fGamma = 1.0f,
bool  bTrue = false,
bool   progress_callback(int) = NULL
 

Perform simple shading of a bitmap, based on this grid's elevation values. Lighting is computing using the dot product of the surface normal with the light direction. This is often called "dot-product lighting".

Parameters:
pBM The bitmap to shade.
light_dir Direction vector of the light.
fLightFactor Value from 0 (no shading) to 1 (full shading)
fAmbient Ambient light values from 0 to 1, a typical value is 0.1.
fGamma Gamma values from 0 to 1, values less than 1 boost the brightness curve.
bTrue If true, use the real elevation values, ignoring vertical exaggeration.
progress_callback If supplied, will be called with values from 0 to 100.

void vtHeightFieldGrid3d::ShadeQuick vtBitmapBase pBM,
float  fLightFactor,
bool  bTrue = false,
bool   progress_callback(int) = NULL
 

Quickly produce a shading-like effect by scanning over the bitmap once, using the east-west slope to produce lightening/darkening. The bitmap must be the same size as the elevation grid, or a power of 2 smaller.

void vtHeightFieldGrid3d::ShadowCastDib vtBitmapBase pBM,
const FPoint3 light_dir,
float  fLightFactor,
float  fAmbient,
bool   progress_callback(int) = NULL
 

ShadowCastDib - method to create shadows over the terrain based on the angle of the sun.

Parameters:
pBM An interface to the bitmap to be shaded.
light_dir The direction of the light, in world coordinates, coming down toward the terrain. For example, (-1,-1,0) is pointing down where the sun would be at 9AM on the equator. Despite this example, light_dir should be normalized to unit length.
fLightFactor Amount of shading, from 0 to 1. A value of 0 means no lighting, 1 means full lighting.
fAmbient Amount of ambient light, from 0 to 1. A typical value is 0.1.
progress_callback Optional callback for progress notification.

void vtHeightFieldGrid3d::WorldToGrid const FPoint3 pos,
IPoint2 ipos
 

Convert a point from world coordinates to the integer coordinates of the grid.


Generated on Tue Apr 22 10:11:01 2008 for vtdata library by  doxygen 1.4.5