xmsgeom  1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
GmExtents.h
Go to the documentation of this file.
1 #pragma once
2 //------------------------------------------------------------------------------
8 //------------------------------------------------------------------------------
9 
10 //----- Included files ---------------------------------------------------------
11 
12 // 3. Standard Library Headers
13 
14 // 4. External Library Headers
15 
16 // 5. Shared Headers
17 #include <xmscore/points/pt.h>
18 
19 // 6. Non-shared Headers
20 
21 //----- Forward declarations ---------------------------------------------------
22 
23 namespace boost
24 {
25 namespace serialization
26 {
27 class access;
28 }
29 }
30 
31 //----- Namespace declaration --------------------------------------------------
32 namespace xms
33 {
34 class GmExtents3d; // forward declaration cause we use it in GmExtents2d ctor
35 
38 {
40  friend class boost::serialization::access;
42 
43 public:
44  GmExtents2d();
45  explicit GmExtents2d(const GmExtents3d& a_extents);
46  GmExtents2d(const Pt2d& a_min, const Pt2d& a_max);
47  GmExtents2d(const Pt3d& a_min, const Pt3d& a_max);
48  virtual ~GmExtents2d();
49 
50  void operator+=(const GmExtents2d& a_rhs);
51  virtual void AddToExtents(const Pt3d& pt);
52  template <class ItrType>
53  void Add(ItrType a_begin, ItrType a_end);
54  bool IsValid();
55  static void SetTolerance(double a_Tol);
56  static double GetTolerance();
57  bool Overlap(const GmExtents2d& a_b) const;
58  void Clear();
59  void GetExtents(double* a_MinX, double* a_MaxX, double* a_MinY, double* a_MaxY);
60  void GetExtents(Pt3d& a_dMin, Pt3d& a_dMax);
61  double GetMinX() const;
62  double GetMaxX() const;
63  double GetMinY() const;
64  double GetMaxY() const;
65  Pt2d GetMin() const;
66  Pt2d GetMax() const;
67  void Set(const Pt2d& a_min, const Pt2d& a_max);
68 
69  template <typename Archive>
70  void serialize(Archive& archive, const unsigned int version);
71 
72 protected:
75  static double m_tolerance;
76 }; // class GmExtents2d
77 
78 //------------------------------------------------------------------------------
82 //------------------------------------------------------------------------------
83 template <typename ItrType>
84 void GmExtents2d::Add(ItrType a_begin, ItrType a_end)
85 {
86  ItrType itr(a_begin);
87  while (itr != a_end)
88  {
89  AddToExtents(*itr);
90  ++itr;
91  }
92 } // GmExtents2d::Add
93 //------------------------------------------------------------------------------
97 //------------------------------------------------------------------------------
98 template <typename Archive>
99 void GmExtents2d::serialize(Archive& archive, const unsigned int version)
100 {
101  (void)version; // Because Doxygen complained when commented out above.
102  archive& m_min;
103  archive& m_max;
104  archive& m_tolerance;
105 } // GmExtents2d::serialize
106 
109 {
110  //#ifdef CXX_TEST
111  // friend class GmExtents3dUnitTests; ///< For unit tests
112  //#endif
114  friend class boost::serialization::access;
116 
117 public:
118  GmExtents3d();
119  explicit GmExtents3d(const GmExtents2d& a_extents);
120  GmExtents3d(const Pt3d& a_min, const Pt3d& a_max);
121  GmExtents3d(const Pt2d& a_min, const Pt2d& a_max);
122 
123  void operator+=(const GmExtents3d& a_rhs);
124  void AddToExtents(const Pt3d& pt);
125  bool IsValid() const;
126  static void SetTolerance(double a_Tol);
127  static double GetTolerance();
128  bool Overlap(GmExtents3d& a_b) const;
129  void Clear();
130  bool IsPointWithin(const Pt3d& pt) const;
131  void GetExtents(double* a_MinX,
132  double* a_MaxX,
133  double* a_MinY,
134  double* a_MaxY,
135  double* a_MinZ,
136  double* a_MaxZ) const;
137  void GetExtents(Pt3d& a_dMin, Pt3d& a_dMax) const;
138  double GetMinX() const;
139  double GetMaxX() const;
140  double GetMinY() const;
141  double GetMaxY() const;
142  double GetMinZ() const;
143  double GetMaxZ() const;
144  Pt3d GetMin() const;
145  Pt3d GetMax() const;
146  void Set(const Pt3d& a_min, const Pt3d& a_max);
147 
148  template <typename Archive>
149  void serialize(Archive& archive, const unsigned int version);
150 
151 protected:
154  static double m_tolerance;
155 }; // class GmExtents3d
156 
157 //------------------------------------------------------------------------------
161 //------------------------------------------------------------------------------
162 template <typename Archive>
163 void GmExtents3d::serialize(Archive& archive, const unsigned int version)
164 {
165  (void)version; // Because Doxygen complained when commented out above.
166  archive& m_min;
167  archive& m_max;
168  archive& m_tolerance;
169 } // GmExtents3d::serialize
170 
171 } // namespace xms
bool Overlap(const GmExtents2d &a_b) const
Test to see if two extents overlap.
Definition: GmExtents.cpp:133
bool IsValid()
If we don't have any data we return false.
Definition: GmExtents.cpp:108
double GetMinZ() const
Gets the minimum z.
Definition: GmExtents.cpp:496
static double GetTolerance()
Gets the tolerance in use.
Definition: GmExtents.cpp:349
Pt3d GetMax() const
Gets the maximum.
Definition: GmExtents.cpp:520
void GetExtents(double *a_MinX, double *a_MaxX, double *a_MinY, double *a_MaxY)
Gets the extents via the parameters.
Definition: GmExtents.cpp:173
Pt2d m_max
Maximum, maximum extents.
Definition: GmExtents.h:74
virtual void AddToExtents(const Pt3d &pt)
Add a point to the extents.
Definition: GmExtents.cpp:95
static void SetTolerance(double a_Tol)
Sets the tolerance to use.
Definition: GmExtents.cpp:116
3D geometric extents (min/max).
Definition: GmExtents.h:108
void serialize(Archive &archive, const unsigned int version)
Boost serialize function.
Definition: GmExtents.h:99
double GetMinY() const
Gets the minimum y.
Definition: GmExtents.cpp:480
double GetMaxX() const
Gets the maximum x.
Definition: GmExtents.cpp:472
GmExtents3d()
constructor
Definition: GmExtents.cpp:270
double GetMaxY() const
Gets the maximum y.
Definition: GmExtents.cpp:488
void Set(const Pt3d &a_min, const Pt3d &a_max)
Sets the min/max.
Definition: GmExtents.cpp:529
double GetMinX() const
Gets the minimum x.
Definition: GmExtents.cpp:206
static double m_tolerance
Tolerance used in comparisons.
Definition: GmExtents.h:154
bool IsValid() const
If we don't have any data we return false.
Definition: GmExtents.cpp:333
double GetMaxX() const
Gets the maximum x.
Definition: GmExtents.cpp:214
Pt2d GetMin() const
Gets the minimum.
Definition: GmExtents.cpp:238
GmExtents2d()
constructor
Definition: GmExtents.cpp:41
static double m_tolerance
Tolerance used in comparisons.
Definition: GmExtents.h:75
void serialize(Archive &archive, const unsigned int version)
Boost serialize function.
Definition: GmExtents.h:163
Pt2d GetMax() const
Gets the maximum.
Definition: GmExtents.cpp:246
void Set(const Pt2d &a_min, const Pt2d &a_max)
Sets the min/max.
Definition: GmExtents.cpp:255
static void SetTolerance(double a_Tol)
Sets the tolerance to use.
Definition: GmExtents.cpp:341
void operator+=(const GmExtents2d &a_rhs)
operator +=
Definition: GmExtents.cpp:84
void AddToExtents(const Pt3d &pt)
Add a point to the extents.
Definition: GmExtents.cpp:320
void Clear()
Resets the extents to defaults. IsValid will return false.
Definition: GmExtents.cpp:161
2D geometric extents (min/max).
Definition: GmExtents.h:37
Pt3d m_max
Maximum, maximum extents.
Definition: GmExtents.h:153
void Clear()
Resets the extents to defaults. IsValid will return false.
Definition: GmExtents.cpp:394
bool IsPointWithin(const Pt3d &pt) const
Tests if the point is inside the extents.
Definition: GmExtents.cpp:404
double GetMinX() const
Gets the minimum x.
Definition: GmExtents.cpp:464
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:418
static double GetTolerance()
Gets the tolerance in use.
Definition: GmExtents.cpp:124
double GetMaxZ() const
Gets the maximum z.
Definition: GmExtents.cpp:504
Pt3d GetMin() const
Gets the minimum.
Definition: GmExtents.cpp:512
double GetMaxY() const
Gets the maximum y.
Definition: GmExtents.cpp:230
void Add(ItrType a_begin, ItrType a_end)
Adds a range defined by two iterators to the extents.
Definition: GmExtents.h:84
double GetMinY() const
Gets the minimum y.
Definition: GmExtents.cpp:222
Pt3d m_min
Minimum, maximum extents.
Definition: GmExtents.h:152
virtual ~GmExtents2d()
destructor
Definition: GmExtents.cpp:77
bool Overlap(GmExtents3d &a_b) const
Test to see if two extents overlap.
Definition: GmExtents.cpp:358
void operator+=(const GmExtents3d &a_rhs)
operator +=
Definition: GmExtents.cpp:307
Pt2d m_min
Minimum, maximum extents.
Definition: GmExtents.h:73