00001
00002
00003
00004
00005 #ifndef MERCATOR_TERRAIN_MOD_H
00006 #define MERCATOR_TERRAIN_MOD_H
00007
00008 #include <wfmath/intersect.h>
00009 #include <wfmath/axisbox.h>
00010 #include <wfmath/ball.h>
00011
00012 namespace Mercator {
00013
00017 class TerrainMod
00018 {
00019 public:
00020 virtual ~TerrainMod();
00021
00026 virtual void apply(float &point, int x, int y) const = 0;
00027
00029 virtual WFMath::AxisBox<2> bbox() const = 0;
00030
00032 virtual TerrainMod *clone() const = 0;
00033 };
00034
00039 template <typename Shape>
00040 class ShapeTerrainMod : public TerrainMod
00041 {
00042 public:
00046 ShapeTerrainMod(const Shape &s) : m_shape(s) {}
00047 virtual ~ShapeTerrainMod();
00048
00049 virtual WFMath::AxisBox<2> bbox() const;
00050
00051 protected:
00053 Shape m_shape;
00054 };
00055
00056
00060 template <typename Shape>
00061 class LevelTerrainMod : public ShapeTerrainMod<Shape>
00062 {
00063 public:
00068 LevelTerrainMod(float level, const Shape &s)
00069 : ShapeTerrainMod<Shape>(s), m_level(level) {}
00070
00071 virtual ~LevelTerrainMod();
00072
00073 virtual void apply(float &point, int x, int y) const;
00074 virtual TerrainMod *clone() const;
00075
00076 private:
00078 LevelTerrainMod(LevelTerrainMod&);
00079
00080 protected:
00082 float m_level;
00083 };
00084
00089 template <typename Shape>
00090 class AdjustTerrainMod : public ShapeTerrainMod<Shape>
00091 {
00092 public:
00093
00098 AdjustTerrainMod(float dist, const Shape &s)
00099 : ShapeTerrainMod<Shape>(s), m_dist(dist) {}
00100
00101 virtual ~AdjustTerrainMod();
00102
00103 virtual void apply(float &point, int x, int y) const;
00104 virtual TerrainMod *clone() const;
00105
00106 private:
00108 AdjustTerrainMod(AdjustTerrainMod&) {}
00109
00110 protected:
00112 float m_dist;
00113 };
00114
00119 template <typename Shape>
00120 class SlopeTerrainMod : public ShapeTerrainMod<Shape>
00121 {
00122 public:
00123
00130 SlopeTerrainMod(float level, float dx, float dy, const Shape &s)
00131 : ShapeTerrainMod<Shape>(s), m_level(level), m_dx(dx), m_dy(dy) {}
00132
00133 virtual ~SlopeTerrainMod();
00134
00135 virtual void apply(float &point, int x, int y) const;
00136 virtual TerrainMod *clone() const;
00137
00138 private:
00140 SlopeTerrainMod(SlopeTerrainMod&) {}
00141
00142 protected:
00144 float m_level;
00146 float m_dx;
00148 float m_dy;
00149 };
00150
00155 class CraterTerrainMod : public TerrainMod
00156 {
00157 public:
00161 CraterTerrainMod(const WFMath::Ball<3> &s) : m_shape(s) {
00162 WFMath::AxisBox<3> bb=m_shape.boundingBox();
00163 ab = WFMath::AxisBox<2> (
00164 WFMath::Point<2>(bb.lowerBound(0), bb.lowerBound(1)),
00165 WFMath::Point<2>(bb.upperBound(0), bb.upperBound(1))
00166 );
00167 }
00168
00169 virtual ~CraterTerrainMod();
00170
00171 virtual WFMath::AxisBox<2> bbox() const;
00172 virtual void apply(float &point, int x, int y) const;
00173 virtual TerrainMod *clone() const;
00174
00175 private:
00177 CraterTerrainMod(CraterTerrainMod&) {}
00178
00180 WFMath::Ball<3> m_shape;
00182 WFMath::AxisBox<2> ab;
00183
00184 };
00185
00186 }
00187
00188 #endif // MERCATOR_TERRAIN_MOD_H