xmsgrid  1.0
GmExtents.h
Go to the documentation of this file.
1 #pragma once
2 //------------------------------------------------------------------------------
7 //------------------------------------------------------------------------------
8 
9 //----- Included files ---------------------------------------------------------
10 
11 // 3. Standard Library Headers
12 
13 // 4. External Library Headers
14 
15 // 5. Shared Headers
16 #include <xmscore/points/pt.h>
17 
18 // 6. Non-shared Headers
19 
20 //----- Forward declarations ---------------------------------------------------
21 
22 namespace boost
23 {
24 namespace serialization
25 {
26 class access;
27 }
28 }
29 
30 //----- Namespace declaration --------------------------------------------------
31 namespace xms
32 {
33 class GmExtents3d; // forward declaration cause we use it in GmExtents2d ctor
34 
37 {
39  friend class boost::serialization::access;
41 
42 public:
43  GmExtents2d();
44  explicit GmExtents2d(const GmExtents3d& a_extents);
45  GmExtents2d(const Pt2d& a_min, const Pt2d& a_max);
46  GmExtents2d(const Pt3d& a_min, const Pt3d& a_max);
47  virtual ~GmExtents2d();
48 
49  void operator+=(const GmExtents2d& a_rhs);
50  virtual void AddToExtents(const Pt3d& pt);
51  template <class ItrType>
52  void Add(ItrType a_begin, ItrType a_end);
53  bool IsValid();
54  static void SetTolerance(double a_Tol);
55  static double GetTolerance();
56  bool Overlap(const GmExtents2d& a_b) const;
57  void Clear();
58  void GetExtents(double* a_MinX, double* a_MaxX, double* a_MinY, double* a_MaxY);
59  void GetExtents(Pt3d& a_dMin, Pt3d& a_dMax);
60  double GetMinX() const;
61  double GetMaxX() const;
62  double GetMinY() const;
63  double GetMaxY() const;
64  Pt2d GetMin() const;
65  Pt2d GetMax() const;
66  void Set(const Pt2d& a_min, const Pt2d& a_max);
67 
68  template <typename Archive>
69  void serialize(Archive& archive, const unsigned int version);
70 
71 protected:
74  static double m_tolerance;
75 }; // class GmExtents2d
76 
77 //------------------------------------------------------------------------------
81 //------------------------------------------------------------------------------
82 template <typename ItrType>
83 void GmExtents2d::Add(ItrType a_begin, ItrType a_end)
84 {
85  ItrType itr(a_begin);
86  while (itr != a_end)
87  {
88  AddToExtents(*itr);
89  ++itr;
90  }
91 } // GmExtents2d::Add
92 //------------------------------------------------------------------------------
96 //------------------------------------------------------------------------------
97 template <typename Archive>
98 void GmExtents2d::serialize(Archive& archive, const unsigned int version)
99 {
100  (void)version; // Because Doxygen complained when commented out above.
101  archive& m_min;
102  archive& m_max;
103  archive& m_tolerance;
104 } // GmExtents2d::serialize
105 
108 {
109  //#ifdef CXX_TEST
110  // friend class GmExtents3dUnitTests; ///< For unit tests
111  //#endif
113  friend class boost::serialization::access;
115 
116 public:
117  GmExtents3d();
118  explicit GmExtents3d(const GmExtents2d& a_extents);
119  GmExtents3d(const Pt3d& a_min, const Pt3d& a_max);
120  GmExtents3d(const Pt2d& a_min, const Pt2d& a_max);
121 
122  void operator+=(const GmExtents3d& a_rhs);
123  void AddToExtents(const Pt3d& pt);
124  bool IsValid() const;
125  static void SetTolerance(double a_Tol);
126  static double GetTolerance();
127  bool Overlap(GmExtents3d& a_b) const;
128  void Clear();
129  bool IsPointWithin(const Pt3d& pt) const;
130  void GetExtents(double* a_MinX,
131  double* a_MaxX,
132  double* a_MinY,
133  double* a_MaxY,
134  double* a_MinZ,
135  double* a_MaxZ) const;
136  void GetExtents(Pt3d& a_dMin, Pt3d& a_dMax) const;
137  double GetMinX() const;
138  double GetMaxX() const;
139  double GetMinY() const;
140  double GetMaxY() const;
141  double GetMinZ() const;
142  double GetMaxZ() const;
143  Pt3d GetMin() const;
144  Pt3d GetMax() const;
145  void Set(const Pt3d& a_min, const Pt3d& a_max);
146 
147  template <typename Archive>
148  void serialize(Archive& archive, const unsigned int version);
149 
150 protected:
153  static double m_tolerance;
154 }; // class GmExtents3d
155 
156 //------------------------------------------------------------------------------
160 //------------------------------------------------------------------------------
161 template <typename Archive>
162 void GmExtents3d::serialize(Archive& archive, const unsigned int version)
163 {
164  (void)version; // Because Doxygen complained when commented out above.
165  archive& m_min;
166  archive& m_max;
167  archive& m_tolerance;
168 } // GmExtents3d::serialize
169 
170 } // namespace xms
bool Overlap(const GmExtents2d &a_b) const
Test to see if two extents overlap.
Definition: GmExtents.cpp:132
Pt2d GetMin() const
Gets the minimum.
Definition: GmExtents.cpp:237
double GetMinX() const
Gets the minimum x.
Definition: GmExtents.cpp:463
Pt3d GetMin() const
Gets the minimum.
Definition: GmExtents.cpp:511
bool IsValid()
If we don&#39;t have any data we return false.
Definition: GmExtents.cpp:107
double GetMaxY() const
Gets the maximum y.
Definition: GmExtents.cpp:229
static double GetTolerance()
Gets the tolerance in use.
Definition: GmExtents.cpp:348
void GetExtents(double *a_MinX, double *a_MaxX, double *a_MinY, double *a_MaxY)
Gets the extents via the parameters.
Definition: GmExtents.cpp:172
bool IsValid() const
If we don&#39;t have any data we return false.
Definition: GmExtents.cpp:332
Pt2d m_max
Maximum, maximum extents.
Definition: GmExtents.h:73
virtual void AddToExtents(const Pt3d &pt)
Add a point to the extents.
Definition: GmExtents.cpp:94
Pt3d GetMax() const
Gets the maximum.
Definition: GmExtents.cpp:519
Pt2d GetMax() const
Gets the maximum.
Definition: GmExtents.cpp:245
static void SetTolerance(double a_Tol)
Sets the tolerance to use.
Definition: GmExtents.cpp:115
3D geometric extents (min/max).
Definition: GmExtents.h:107
void serialize(Archive &archive, const unsigned int version)
Boost serialize function.
Definition: GmExtents.h:98
GmExtents3d()
constructor
Definition: GmExtents.cpp:269
Pt2< double > Pt2d
bool IsPointWithin(const Pt3d &pt) const
Tests if the point is inside the extents.
Definition: GmExtents.cpp:403
bool Overlap(GmExtents3d &a_b) const
Test to see if two extents overlap.
Definition: GmExtents.cpp:357
void Set(const Pt3d &a_min, const Pt3d &a_max)
Sets the min/max.
Definition: GmExtents.cpp:528
double GetMaxY() const
Gets the maximum y.
Definition: GmExtents.cpp:487
double GetMinY() const
Gets the minimum y.
Definition: GmExtents.cpp:221
static double m_tolerance
Tolerance used in comparisons.
Definition: GmExtents.h:153
GmExtents2d()
constructor
Definition: GmExtents.cpp:40
double GetMaxZ() const
Gets the maximum z.
Definition: GmExtents.cpp:503
void GetExtents(double *a_MinX, double *a_MaxX, double *a_MinY, double *a_MaxY, double *a_MinZ, double *a_MaxZ) const
Gets the extents via the parameters.
Definition: GmExtents.cpp:417
static double m_tolerance
Tolerance used in comparisons.
Definition: GmExtents.h:74
double GetMinZ() const
Gets the minimum z.
Definition: GmExtents.cpp:495
void serialize(Archive &archive, const unsigned int version)
Boost serialize function.
Definition: GmExtents.h:162
void Set(const Pt2d &a_min, const Pt2d &a_max)
Sets the min/max.
Definition: GmExtents.cpp:254
XMS Namespace.
Definition: geoms.cpp:34
static void SetTolerance(double a_Tol)
Sets the tolerance to use.
Definition: GmExtents.cpp:340
void operator+=(const GmExtents2d &a_rhs)
operator +=
Definition: GmExtents.cpp:83
double GetMaxX() const
Gets the maximum x.
Definition: GmExtents.cpp:471
void AddToExtents(const Pt3d &pt)
Add a point to the extents.
Definition: GmExtents.cpp:319
double GetMinY() const
Gets the minimum y.
Definition: GmExtents.cpp:479
void Clear()
Resets the extents to defaults. IsValid will return false.
Definition: GmExtents.cpp:160
2D geometric extents (min/max).
Definition: GmExtents.h:36
Pt3d m_max
Maximum, maximum extents.
Definition: GmExtents.h:152
void Clear()
Resets the extents to defaults. IsValid will return false.
Definition: GmExtents.cpp:393
double GetMinX() const
Gets the minimum x.
Definition: GmExtents.cpp:205
static double GetTolerance()
Gets the tolerance in use.
Definition: GmExtents.cpp:123
void Add(ItrType a_begin, ItrType a_end)
Adds a range defined by two iterators to the extents.
Definition: GmExtents.h:83
Pt3d m_min
Minimum, maximum extents.
Definition: GmExtents.h:151
double GetMaxX() const
Gets the maximum x.
Definition: GmExtents.cpp:213
virtual ~GmExtents2d()
destructor
Definition: GmExtents.cpp:76
void operator+=(const GmExtents3d &a_rhs)
operator +=
Definition: GmExtents.cpp:306
Pt2d m_min
Minimum, maximum extents.
Definition: GmExtents.h:72