Mercator
Area.h
1 // This file may be redistributed and modified only under the terms of
2 // the GNU General Public License (See COPYING for details).
3 // Copyright (C) 2005 Alistair Riddoch
4 
5 #ifndef MERCATOR_AREA_H
6 #define MERCATOR_AREA_H
7 
8 #include <Mercator/Effector.h>
9 
10 #include <wfmath/axisbox.h>
11 #include <wfmath/polygon.h>
12 
13 namespace Mercator
14 {
15 
16 class Segment;
17 class Shader;
18 
28 class Area : public Effector
29 {
30 public:
35  Area(int layer, bool hole);
36 
41  void setLayer(int layer, bool hole);
42 
44  void setShape(const WFMath::Polygon<2>& p);
45 
46  void setShader(const Shader * shader) const;
47 
49  bool contains(WFMath::CoordType x, WFMath::CoordType y) const;
50 
52  int getLayer() const
53  {
54  return m_layer;
55  }
56 
58  bool isHole() const
59  {
60  return m_hole;
61  }
62 
64  const WFMath::Polygon<2> & shape() const
65  {
66  return m_shape;
67  }
68 
69  const Shader * getShader() const
70  {
71  return m_shader;
72  }
73 
74  int addToSegment(Segment &) const;
75  void updateToSegment(Segment &) const;
76  void removeFromSegment(Segment &) const;
77 
81  bool checkIntersects(const Segment& s) const;
82 
90  WFMath::Polygon<2> clipToSegment(const Segment& s) const;
91 private:
92 
94  int m_layer;
96  bool m_hole;
98  WFMath::Polygon<2> m_shape;
100  mutable const Shader * m_shader;
101 };
102 
103 }
104 
105 #endif // of MERCATOR_AREA_H
Mercator::BottomClip::inside
bool inside(const Point2 &p) const
Check a point is outside this clip.
Definition: Area.cpp:87
Mercator::BottomClip::BottomClip
BottomClip(CoordType t)
Definition: Area.cpp:81
Mercator::Area::m_hole
bool m_hole
A flag indicating whether this is a hole.
Definition: Area.h:96
Mercator::Area::checkIntersects
bool checkIntersects(const Segment &s) const
Definition: Area.cpp:299
Mercator::Segment
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
Definition: Segment.h:36
Mercator::Area::m_shape
WFMath::Polygon< 2 > m_shape
The geometric shape.
Definition: Area.h:98
Mercator::RightClip::inside
bool inside(const Point2 &p) const
Check a point is outside this clip.
Definition: Area.cpp:163
Mercator::RightClip
Helper to clip points to a given range.
Definition: Area.cpp:151
Mercator::Area::getLayer
int getLayer() const
Accessor for the layer number.
Definition: Area.h:52
Mercator::Area::setShape
void setShape(const WFMath::Polygon< 2 > &p)
Set the geometric shape of this area.
Definition: Area.cpp:239
Mercator::BottomClip::clip
Point2 clip(const Point2 &u, const Point2 &v) const
Determine the point where a line crosses this clip.
Definition: Area.cpp:97
Mercator::TopClip::inside
bool inside(const Point2 &p) const
Check a point is outside this clip.
Definition: Area.cpp:46
Mercator::Area::setLayer
void setLayer(int layer, bool hole)
Set the layer number and flag indicating whether this is a hole.
Mercator::TopClip::topY
CoordType topY
Top of y range.
Definition: Area.cpp:71
Mercator::RightClip::RightClip
RightClip(CoordType t)
Definition: Area.cpp:157
Mercator::LeftClip
Helper to clip points to a given range.
Definition: Area.cpp:112
Mercator::Area
Region of terrain surface which is modified.
Definition: Area.h:28
Mercator::TopClip
Helper to clip points to a given range.
Definition: Area.cpp:34
Mercator::BottomClip::bottomY
CoordType bottomY
Bottom of y range.
Definition: Area.cpp:108
Mercator::TopClip::clip
Point2 clip(const Point2 &u, const Point2 &v) const
Determine the point where a line crosses this clip.
Definition: Area.cpp:56
Mercator::Segment::getRect
WFMath::AxisBox< 2 > getRect() const
The 2d area covered by this segment.
Definition: Segment.cpp:752
Mercator::TopClip::TopClip
TopClip(CoordType t)
Definition: Area.cpp:40
Mercator::Area::isHole
bool isHole() const
Accessor for the flag indicating whether this is a hole.
Definition: Area.h:58
Mercator::Effector
Device which effects a change in the terrain.
Definition: Effector.h:25
Mercator::Area::m_layer
int m_layer
The layer number.
Definition: Area.h:94
Mercator::Effector::m_box
WFMath::AxisBox< 2 > m_box
The bounding box of the geometric shape.
Definition: Effector.h:70
Mercator::Area::shape
const WFMath::Polygon< 2 > & shape() const
Accessor for the geometric shape.
Definition: Area.h:64
Mercator::Shader
Base class for Shader objects which create surface data for use when rendering terrain.
Definition: Shader.h:29
Mercator::Area::m_shader
const Shader * m_shader
Shader that shades this area.
Definition: Area.h:100
Mercator::LeftClip::LeftClip
LeftClip(CoordType t)
Definition: Area.cpp:118
Mercator::RightClip::clip
Point2 clip(const Point2 &u, const Point2 &v) const
Determine the point where a line crosses this clip.
Definition: Area.cpp:173
Mercator::LeftClip::leftX
CoordType leftX
Left of x range.
Definition: Area.cpp:147
Mercator::LeftClip::clip
Point2 clip(const Point2 &u, const Point2 &v) const
Determine the point where a line crosses this clip.
Definition: Area.cpp:134
Mercator::BottomClip
Helper to clip points to a given range.
Definition: Area.cpp:75
Mercator::RightClip::rightX
CoordType rightX
Right of x range.
Definition: Area.cpp:186
Mercator::Area::Area
Area(int layer, bool hole)
Constructor.
Definition: Area.cpp:232
Mercator::Area::contains
bool contains(WFMath::CoordType x, WFMath::CoordType y) const
Determine if a point is contained by the shape of this area.
Definition: Area.cpp:251
Mercator::LeftClip::inside
bool inside(const Point2 &p) const
Check a point is outside this clip.
Definition: Area.cpp:124
Mercator::Area::clipToSegment
WFMath::Polygon< 2 > clipToSegment(const Segment &s) const
Clip the shape of this area to a given segment.
Definition: Area.cpp:284
Mercator::Segment::addArea
int addArea(const Area *a)
Add an area to those that affect this segment.
Definition: Segment.cpp:683