00001
00002
00003
00004 #ifndef TE_HEIGHT_MAP_H
00005 #define TE_HEIGHT_MAP_H
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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;
00084 unsigned int maxUpdated : 1;
00085 unsigned int averageUpdated : 1;
00086
00087
00088 } flags;
00089
00090 void resetFlags();
00091
00092 public:
00093
00094
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
00102 ~TeHeightMap();
00103
00104
00105 TeHeightMap& operator= (const TeHeightMap &hmap);
00106
00107
00108 SbVec2s getResolution() const;
00109 void getResolution(int &x, int &y) const;
00110 void setResolution(const SbVec2s &newRes);
00111
00112
00113 void setValue(const int x, const int y, const float value);
00114 void setAllValues(const float value);
00115
00116
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
00124 void getStats(float *min, float *max, float *average);
00125 float getMinValue();
00126 float getMaxValue();
00127 float getAverageValue();
00128
00129
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
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
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
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
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
00165 void filter_Linear(const float coef, const int times);
00166
00167
00168
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
00173
00174
00175 void dump();
00176
00177 };
00178
00179 #endif