File: TerrainMod_impl.h

package info (click to toggle)
mercator 0.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,008 kB
  • sloc: sh: 10,433; cpp: 4,482; makefile: 115
file content (146 lines) | stat: -rw-r--r-- 3,756 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// This file may be redistributed and modified only under the terms of
// the GNU General Public License (See COPYING for details).
// Copyright (C) 2003 Damien McGinnes, Alistair Riddoch

#ifndef MERCATOR_TERRAIN_MOD_IMPL_H
#define MERCATOR_TERRAIN_MOD_IMPL_H

#include <Mercator/TerrainMod.h>

#include <Mercator/Segment.h>

namespace Mercator {

template <template <int> class Shape>
ShapeTerrainMod<Shape>::ShapeTerrainMod(const Shape<2> &s) : m_shape(s)
{
    m_box = m_shape.boundingBox();
}


template <template <int> class Shape> ShapeTerrainMod<Shape>::~ShapeTerrainMod()
{
}

template <template <int> class Shape>
bool ShapeTerrainMod<Shape>::checkIntersects(const Segment& s) const
{
    return WFMath::Intersect(m_shape, s.getRect(), false) ||
        WFMath::Contains(s.getRect(), m_shape.getCorner(0), false);
}
    
template <template <int> class Shape>
void ShapeTerrainMod<Shape>::setShape(const Shape<2> & s)
{
    m_shape = s;
    m_box = m_shape.boundingBox();
}

template <template <int> class Shape> LevelTerrainMod<Shape>::~LevelTerrainMod()
{
}
    
template <template <int> class Shape>
void LevelTerrainMod<Shape>::apply(float &point, int x, int y) const
{
    if (Contains(this->m_shape,WFMath::Point<2>(x,y),true)) {
        point = m_level;
    }
}

template <template <int> class Shape>
TerrainMod * LevelTerrainMod<Shape>::clone() const
{
    return new LevelTerrainMod<Shape>(m_level, this->m_shape);
}

template <template <int> class Shape>
void LevelTerrainMod<Shape>::setShape(float level, const Shape<2> & s)
{
    ShapeTerrainMod<Shape>::setShape(s);
    m_level = level;
}

template <template <int> class Shape> AdjustTerrainMod<Shape>::~AdjustTerrainMod()
{
}
    
template <template <int> class Shape>
void AdjustTerrainMod<Shape>::apply(float &point, int x, int y) const
{
    if (Contains(this->m_shape,WFMath::Point<2>(x,y),true)) {
        point += m_dist;
    }
}
    
template <template <int> class Shape>
TerrainMod * AdjustTerrainMod<Shape>::clone() const
{
    return new AdjustTerrainMod<Shape>(m_dist, this->m_shape);
}

template <template <int> class Shape>
void AdjustTerrainMod<Shape>::setShape(float dist, const Shape<2> & s)
{
    ShapeTerrainMod<Shape>::setShape(s);
    m_dist = dist;
}

template <template <int> class Shape> SlopeTerrainMod<Shape>::~SlopeTerrainMod()
{
}
    
template <template <int> class Shape>
void SlopeTerrainMod<Shape>::apply(float &point, int x, int y) const
{
    if (Contains(this->m_shape,WFMath::Point<2>(x,y),true)) {
        point = m_level + (this->m_shape.getCenter()[0] - x) * m_dx 
                        + (this->m_shape.getCenter()[1] - y) * m_dy;
    }
}
    
template <template <int> class Shape>
TerrainMod * SlopeTerrainMod<Shape>::clone() const
{
    return new SlopeTerrainMod<Shape>(m_level, m_dx, m_dy, this->m_shape);
}

template <template <int> class Shape>
void SlopeTerrainMod<Shape>::setShape(float level, float dx, float dy, const Shape<2> & s)
{
    ShapeTerrainMod<Shape>::setShape(s);
    m_level = level;
    m_dx = dx;
    m_dy = dy;
}


template <template <int> class Shape> CraterTerrainMod<Shape>::~CraterTerrainMod()
{
}
    
template <template <int> class Shape>
void CraterTerrainMod<Shape>::apply(float &point, int x, int y) const
{
    if (Contains(this->m_shape,WFMath::Point<2>(x,y),true)) {
        point += m_level;
    }
}
    
template <template <int> class Shape>
TerrainMod * CraterTerrainMod<Shape>::clone() const
{
    return new CraterTerrainMod<Shape>(m_level, this->m_shape);
}

template <template <int> class Shape>
void CraterTerrainMod<Shape>::setShape(float level, const Shape<2> & s)
{
    ShapeTerrainMod<Shape>::setShape(s);
    m_level = level;
}


} //namespace Mercator

#endif // MERCATOR_TERRAIN_MOD_IMPL_H