grid.h

Go to the documentation of this file.
00001 /*
00002  *  grid.h
00003  *  Wadiscape
00004  *
00005  *  Created by Forschung on Mon Nov 28 2005.
00006  *  Copyright (c) 2005 __MyCompanyName__. All rights reserved.
00007  *
00008  */
00009 
00010 // General documentation for your code to be used with DOXYGEN
00011 // Put this part somewhere in your code (I suggest you put it at the top of main.cpp or some other prominent place
00012 
00013 
00055 #ifndef GRID_H
00056 #define GRID_H
00057 
00058 const int N=512; //< preset edge length of the grid
00059 
00060 //---------------------------------------------------------------------------
00062 class flowinfo  // zugefuegt 20051130
00063 {
00064 private:
00065   flowinfo* nbsFrom[8];
00066   int contributing; //< number of directly contributing patches
00067   float total; //< number of all contributing patches
00068   float share; //< the number of nb cells with equal elevation among which the water flow is split
00069   bool checked; //< has this cell been checked already?
00070   
00071 public:
00072   flowinfo(void) {contributing = 0; checked = 0; total=1; share=1.0;}
00073   ~flowinfo() {};
00074   float getContributing (void) {return contributing;} //< returns the number of nbs that contribute water
00075   float getTotalContributing (void) {return total>0.5?total:1;} //< returns the accumulated flow of one cell 
00076   float getTotalContributing (flowinfo* receivingCell); //< returns the accumulated flow of the nb cells
00077   void setInflow (flowinfo* pCell); //< sets the pointers to nbs where water comes from and counts them
00078   void setShare (float s) {share = s;} //< sets the number of nb cells with equal elevation among which the water flow is split
00079 };
00080 
00081 //---------------------------------------------------------------------------
00083 struct celldata
00084 {
00085   char Position; //< habitat codes (P: plateau, N: North-facing slope, S: South-facing slope, W: wadi bottom)
00086   float NCellsAll; //< flow accumulation; new 20051206 
00087 };
00088 
00089 //---------------------------------------------------------------------------
00091 
00092 struct xyC // new 20051222
00093 {
00094   int col;
00095   int row;
00096   float height;
00097 };
00098 
00099 //---------------------------------------------------------------------------
00101 
00102 class TGrid
00103 {
00104 public:
00105   TGrid (void);
00106   ~TGrid ();
00107 
00109 
00112   void clearArrays(); 
00113 
00114   
00116 
00126   void createMountain (int Iterations, int Sigma, float Hurst, bool Addition);
00127   
00128   
00130 
00132   void createWadi (float Grad, bool Parabel);
00133   
00134   
00136 
00138   void calculateElevation (void);
00139   
00141 
00144   void countHigherCellsGIS (void);
00145 
00146   
00148 
00149   void outputContributing(void);
00150 
00151   
00153   
00154   void outputElevation(void);
00155   
00156   
00158 
00160   void outputTestVariable(void);
00161   
00162   
00164 
00167   void writeFile(float slope, int r);
00168 
00169 
00170 private:
00171   celldata CellCount[N+1][N+1]; //< accumulated flow and habitat code
00172   float CellArray[N+1][N+1];  //< elevation of the fractal wadiscape
00173   float CellArrayF[N+1][N+1]; //< elevation in fractal surface
00174   float CellArrayL[N+1][N+1]; //< elevation in wadi landscape
00175 
00176   flowinfo dir[N+1][N+1]; //< information about the neighbouring cells  
00177   float f3 (float delta, float x0, float x1, float x2); //< used in the fractal creation; changed 20070215
00178   float f4 (float delta, float x0,float x1, float x2, float x3); //< used in the fractal creation; changed 20070215
00179 };
00180 
00181 #endif

Generated on Tue Mar 11 11:02:38 2008 for Wadiscape Generator by  doxygen 1.5.1