Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

TeHeightMap.h

Go to the documentation of this file.
00001 //##################################################
00002 //# $Id: TeHeightMap.h 20 2005-03-14 13:15:11Z peciva $
00003 
00004 #ifndef TE_HEIGHT_MAP_H
00005 #define TE_HEIGHT_MAP_H
00006 
00007 /*****************************************************************************\
00008  *
00009  * TeHeightMap.h
00010  *
00011  * TeHeightMap - height map class
00012  *
00013  * Author: Martin Havlíček (xhavli15 AT stud.fit.vutbr.cz)
00014  * Contributors: PCJohn (peciva AT fit.vutbr.cz)
00015  *
00016  * ----------------------------------------------------------------------------
00017  *
00018  * THIS SOFTWARE IS NOT COPYRIGHTED
00019  *
00020  * This source code is offered for use in the public domain.
00021  * You may use, modify or distribute it freely.
00022  *
00023  * This source code is distributed in the hope that it will be useful but
00024  * WITHOUT ANY WARRANTY.  ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
00025  * DISCLAIMED.  This includes but is not limited to warranties of
00026  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00027  *
00028  * If you find the source code useful, authors will kindly welcome
00029  * if you give them credit and keep their names with their source code.
00030  *
00031 \*****************************************************************************/
00032 
00041 #include <Inventor/SbLinear.h>
00042 
00059 class TeHeightMap {
00060 
00061   friend class TeFaultFormation;
00062   friend class TeLinearFilter;
00063 
00064 private:
00065 
00067   int resx;
00069   int resy;
00070 
00072   float *values;
00073 
00075   float minValue;
00077   float maxValue;
00079   float averageValue;
00080 
00082   struct {
00083     unsigned int     minUpdated : 1; // bit 0
00084     unsigned int     maxUpdated : 1; // bit 1
00085     unsigned int averageUpdated : 1; // bit 2
00086     // free                          // ...
00087     // free                          // bit 31
00088   } flags;
00089 
00090   void resetFlags();
00091 
00092 public:
00093 
00094   // Constructors
00095   TeHeightMap();
00096   TeHeightMap(const SbVec2s resolution);
00097   TeHeightMap(const int resx, const int resy);
00098   TeHeightMap(const TeHeightMap &hmap);
00099   TeHeightMap(const TeHeightMap *hmap, const SbVec2s origin, const SbVec2s size);
00100 
00101   // Destructor
00102   ~TeHeightMap();
00103 
00104   // Operators
00105   TeHeightMap& operator= (const TeHeightMap &hmap);
00106 
00107   // Heightmap size management
00108   SbVec2s getResolution() const;
00109   void getResolution(int &x, int &y) const;
00110   void setResolution(const SbVec2s &newRes);
00111 
00112   // Setting values
00113   void setValue(const int x, const int y, const float value);
00114   void setAllValues(const float value);
00115 
00116   // Getting values
00117   float getValue(const int x, const int y) const;
00118   const float* getValues() const;
00119   const float* operator[] (int i) const;
00120   float* startEditing();
00121   void finishEditing();
00122 
00123   // Statistics
00124   void getStats(float *min, float *max, float *average); // 1 pass
00125   float getMinValue();
00126   float getMaxValue();
00127   float getAverageValue();
00128 
00129   // Shifts
00130   void shift(const float delta);
00131   void shiftMinValue(const float value);
00132   void shiftMinValue(const float value, const float old);
00133   void shiftMaxValue(const float value);
00134   void shiftMaxValue(const float value, const float old);
00135   void shiftAverageValue(const float value);
00136   void shiftAverageValue(const float value, const float old);
00137 
00138   // Copying
00139   void copyFrom(const TeHeightMap *hmap);
00140   void copyFrom(const TeHeightMap *hmap, const SbVec2s &sorigin,
00141                 const SbVec2s &size, const SbVec2s &dorigin = SbVec2s(0,0));
00142 
00143   // Adding (with rate, 1.0==100%)
00144   void addFrom(const TeHeightMap *hmap, const float rate);
00145   void addFrom(const TeHeightMap *hmap, const SbVec2s &sorigin,
00146                const SbVec2s &size, const SbVec2s &dorigin,
00147                const float rate);
00148   void addAll(const float value);
00149 
00150   // Subtracting (with rate, 1.0==100%)
00151   void subtractFrom(const TeHeightMap *hmap, const float rate);
00152   void subtractFrom(const TeHeightMap *hmap, const SbVec2s &sorigin,
00153                     const SbVec2s &size, const SbVec2s &dorigin,
00154                     const float rate);
00155   void subtractAll(const float value);
00156 
00157   // Multiplying (with rate, 1.0==100%)
00158   void multiplyFrom(const TeHeightMap *hmap, const float rate);
00159   void multiplyFrom(const TeHeightMap *hmap, const SbVec2s &sorigin,
00160                     const SbVec2s &size, const SbVec2s &dorigin,
00161                     const float rate);
00162   void multiplyAll(const float value);
00163 
00164   // Filtering
00165   void filter_Linear(const float coef, const int times);
00166   // ... more to come ...
00167 
00168   // Generating
00169   void generate_FaultFormation(const unsigned int seed, const int num_faults,
00170                                const float min_delta, const float max_delta);
00171   void generate_4HMOverlap_Mask();
00172   // ... more to come ...
00173 
00174   // FOR DEBUGGING ONLY
00175   void dump();
00176 
00177 };
00178 
00179 #endif /* TE_HEIGHT_MAP_H */

Generated on Sun May 8 16:45:06 2005 for TerrainEngine by Doxygen 1.4.1