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
00014 class TerrainMod
00015 {
00016 public:
00017 virtual ~TerrainMod();
00018
00019
00020 virtual void apply(float &point, int x, int y) const = 0;
00021
00022
00023 virtual WFMath::AxisBox<2> bbox() const = 0;
00024
00025 virtual TerrainMod *clone() const = 0;
00026 };
00027
00028 template <typename Shape>
00029 class ShapeTerrainMod : public TerrainMod
00030 {
00031 public:
00032 ShapeTerrainMod(const Shape &s) : m_shape(s) {}
00033 virtual ~ShapeTerrainMod();
00034
00035 virtual WFMath::AxisBox<2> bbox() const;
00036
00037 protected:
00038 Shape m_shape;
00039 };
00040
00041
00042
00043 template <typename Shape>
00044 class LevelTerrainMod : public ShapeTerrainMod<Shape>
00045 {
00046 public:
00047
00048 LevelTerrainMod(float level, const Shape &s)
00049 : ShapeTerrainMod<Shape>(s), m_level(level) {}
00050
00051 virtual ~LevelTerrainMod();
00052
00053 virtual void apply(float &point, int x, int y) const;
00054 virtual TerrainMod *clone() const;
00055
00056 private:
00057 LevelTerrainMod(LevelTerrainMod&);
00058
00059 protected:
00060 float m_level;
00061 };
00062
00063
00064
00065 template <typename Shape>
00066 class AdjustTerrainMod : public ShapeTerrainMod<Shape>
00067 {
00068 public:
00069
00070 AdjustTerrainMod(float dist, const Shape &s)
00071 : ShapeTerrainMod<Shape>(s), m_dist(dist) {}
00072
00073 virtual ~AdjustTerrainMod();
00074
00075 virtual void apply(float &point, int x, int y) const;
00076 virtual TerrainMod *clone() const;
00077
00078 private:
00079 AdjustTerrainMod(AdjustTerrainMod&) {}
00080
00081 protected:
00082 float m_dist;
00083 };
00084
00085
00086
00087 template <typename Shape>
00088 class SlopeTerrainMod : public ShapeTerrainMod<Shape>
00089 {
00090 public:
00091
00092 SlopeTerrainMod(float level, float dx, float dy, const Shape &s)
00093 : ShapeTerrainMod<Shape>(s), m_level(level), m_dx(dx), m_dy(dy) {}
00094
00095 virtual ~SlopeTerrainMod();
00096
00097 virtual void apply(float &point, int x, int y) const;
00098 virtual TerrainMod *clone() const;
00099
00100 private:
00101 SlopeTerrainMod(SlopeTerrainMod&) {}
00102
00103 protected:
00104 float m_level, m_dx, m_dy;
00105 };
00106
00107 class CraterTerrainMod : public TerrainMod
00108 {
00109 public:
00110
00111 CraterTerrainMod(const WFMath::Ball<3> &s) : m_shape(s) {
00112 WFMath::AxisBox<3> bb=m_shape.boundingBox();
00113 ab = WFMath::AxisBox<2> (
00114 WFMath::Point<2>(bb.lowerBound(0), bb.lowerBound(1)),
00115 WFMath::Point<2>(bb.upperBound(0), bb.upperBound(1))
00116 );
00117 }
00118
00119 virtual ~CraterTerrainMod();
00120
00121 virtual WFMath::AxisBox<2> bbox() const;
00122 virtual void apply(float &point, int x, int y) const;
00123 virtual TerrainMod *clone() const;
00124
00125 private:
00126 CraterTerrainMod(CraterTerrainMod&) {}
00127
00128 WFMath::Ball<3> m_shape;
00129 WFMath::AxisBox<2> ab;
00130
00131 };
00132
00133 }
00134
00135 #endif // MERCATOR_TERRAIN_MOD_H