TGrid Class Reference

TGrid contains the landscapes. More...

#include <grid.h>

Collaboration diagram for TGrid:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TGrid (void)
 ~TGrid ()
void clearArrays ()
 Clear all internal arrays.
void createMountain (int Iterations, int Sigma, float Hurst, bool Addition)
 Create a fractal landscape.
void createWadi (float Grad, bool Parabel)
 Create a wadi landscape with a smooth surface.
void calculateElevation (void)
 Drape fractal landscape over wadi and smoothe the topography.
void countHigherCellsGIS (void)
 Calculation of flow accumulation of each cell.
void outputContributing (void)
 The flow accumulation of each cell is written to a file "Contributing.txt".
void outputElevation (void)
 The elevation of each cell is written to a file "Elevation.txt".
void outputTestVariable (void)
 Store a variable in a text file.
void writeFile (float slope, int r)
 Write the elevation and other information to a text file.

Private Member Functions

float f3 (float delta, float x0, float x1, float x2)
float f4 (float delta, float x0, float x1, float x2, float x3)

Private Attributes

celldata CellCount [N+1][N+1]
float CellArray [N+1][N+1]
float CellArrayF [N+1][N+1]
float CellArrayL [N+1][N+1]
flowinfo dir [N+1][N+1]

Detailed Description

TGrid contains the landscapes.

TGrid must be created once.

Definition at line 102 of file grid.h.


Constructor & Destructor Documentation

TGrid::TGrid ( void   ) 

Definition at line 52 of file grid.cpp.

References clearArrays(), r250_init(), and seed.

Here is the call graph for this function:

TGrid::~TGrid (  ) 

Definition at line 62 of file grid.cpp.


Member Function Documentation

void TGrid::clearArrays (  ) 

Clear all internal arrays.

This is necessary when the algorithm is used repeatedly in a loop

Definition at line 68 of file grid.cpp.

References CellArray, CellArrayF, CellArrayL, CellCount, N, celldata::NCellsAll, and celldata::Position.

Referenced by TGrid().

void TGrid::createMountain ( int  Iterations,
int  Sigma,
float  Hurst,
bool  Addition 
)

Create a fractal landscape.

Algorithm of Saupe (1988)
Iterations: The number of iterations used for producing the landscape.
The surface becomes smoother with more iterations.The edge of the grid must have length 2n+1 with n ≤ Iterations.
Sigma: Sigma increases the surface variability (roughness). A standard value is 25.
Hurst: The Hurst factor increases the heterogeneity (patchiness) of the landscape. A standard value is 0.45.
Addition: If TRUE, the fractal landscape is draped over a wadi valley.
Saupe, D. 1988. Algorithms for random fractals. Pages 71-136 in Peitgen, H., and D. Saupe, editors. Algorithms for random fractals. Springer-Verlag, New York, New York, U.S.A.

Definition at line 91 of file grid.cpp.

References CellArrayF, f3(), f4(), N, and RandG().

Referenced by main().

Here is the call graph for this function:

void TGrid::createWadi ( float  Grad,
bool  Parabel 
)

Create a wadi landscape with a smooth surface.

Grad is the inclination (in degrees) of the slopes. When Parabel==TRUE the wadiscape's cross-section has the form of a parabola else it has an inverted symmetric trapezoidal cross-section / cut into a plateau. The bottom of the wadi is always 51 cells (255 m) wide, the length of the slopes and plateau depends on the angle (i.e. Grad). The elevation of the plateau is always 100 m.

Definition at line 156 of file grid.cpp.

References CellArrayL, CellCount, N, and celldata::Position.

Referenced by main().

void TGrid::calculateElevation ( void   ) 

Drape fractal landscape over wadi and smoothe the topography.

The elevation of the fractal landscape is centred and added to the wadi elevation. The result is smoothed by a moving average window of length 2 in 2 dimensions

Definition at line 233 of file grid.cpp.

References CellArray, CellArrayF, CellArrayL, and N.

Referenced by main().

void TGrid::countHigherCellsGIS ( void   ) 

Calculation of flow accumulation of each cell.

This function determines how many cells contribute water to lower cells (flow accumulation). For a particular cell, the function checks which slope to its 8 neighbour cells is the steepest. The water will flow to this cell. (The algorithm used in GIS applications, see http://gis.esri.com/library/userconf/proc97/proc97/to200/pap198/p198.htm ). The receiving cell stores a pointer to the donating cell. In the final step, each cell checks back to its donating cell for the accumulated number of contributing cells.

check whether surrounding cells are lower

route flow to the cell with the smallest ("most negative"!) angle

check the contributing cells for each cell

Definition at line 299 of file grid.cpp.

References CellArray, CellCount, dir, flowinfo::getTotalContributing(), N, and celldata::NCellsAll.

Referenced by main().

Here is the call graph for this function:

void TGrid::outputContributing ( void   ) 

The flow accumulation of each cell is written to a file "Contributing.txt".

Definition at line 435 of file grid.cpp.

References CellCount, and N.

Referenced by main().

void TGrid::outputElevation ( void   ) 

The elevation of each cell is written to a file "Elevation.txt".

Definition at line 417 of file grid.cpp.

References CellArray, and N.

Referenced by main().

void TGrid::outputTestVariable ( void   ) 

Store a variable in a text file.

You need to specify in the code which variable is written to the file. This function is needed only for debugging puposes or if th user needs additional information. Currently the output is CellArrayF (elevation of the fractal landscape)

Definition at line 399 of file grid.cpp.

References CellArrayF, and N.

Referenced by main().

void TGrid::writeFile ( float  slope,
int  r 
)

Write the elevation and other information to a text file.

The function writes into a text file "Wadiscape_SLOPE_ID" where SLOPE is the inclination of the valley slopes and ID is a consecutive number. The file contains the vtab separated values of row number, column number, elevation (m), habitat code (P: plateau, N: North-facing slope, S: South-facing slope, W: wadi bottom), flow accumulation of each cell in a 300 x 300 cell centred subgrid.

Definition at line 452 of file grid.cpp.

References CellArray, CellCount, itoa(), N, celldata::NCellsAll, and celldata::Position.

Referenced by main().

Here is the call graph for this function:

float TGrid::f3 ( float  delta,
float  x0,
float  x1,
float  x2 
) [inline, private]

Definition at line 81 of file grid.cpp.

References RandG().

Referenced by createMountain().

Here is the call graph for this function:

float TGrid::f4 ( float  delta,
float  x0,
float  x1,
float  x2,
float  x3 
) [inline, private]

Definition at line 86 of file grid.cpp.

References RandG().

Referenced by createMountain().

Here is the call graph for this function:


Member Data Documentation

celldata TGrid::CellCount[N+1][N+1] [private]

Definition at line 171 of file grid.h.

Referenced by clearArrays(), countHigherCellsGIS(), createWadi(), outputContributing(), and writeFile().

float TGrid::CellArray[N+1][N+1] [private]

Definition at line 172 of file grid.h.

Referenced by calculateElevation(), clearArrays(), countHigherCellsGIS(), outputElevation(), and writeFile().

float TGrid::CellArrayF[N+1][N+1] [private]

Definition at line 173 of file grid.h.

Referenced by calculateElevation(), clearArrays(), createMountain(), and outputTestVariable().

float TGrid::CellArrayL[N+1][N+1] [private]

Definition at line 174 of file grid.h.

Referenced by calculateElevation(), clearArrays(), and createWadi().

flowinfo TGrid::dir[N+1][N+1] [private]

Definition at line 176 of file grid.h.

Referenced by countHigherCellsGIS().


The documentation for this class was generated from the following files:
Generated on Tue Mar 11 11:02:39 2008 for Wadiscape Generator by  doxygen 1.5.1