OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimIpt.h
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: David Burken
6 //
7 // Description:
8 //
9 // Contains class declaration for ipt.
10 // Used to represent an interger point containing an x and y data member.
11 //
12 //*******************************************************************
13 // $Id: ossimIpt.h 19793 2011-06-30 13:26:56Z gpotts $
14 
15 #ifndef ossimIpt_HEADER
16 #define ossimIpt_HEADER
17 #include <iosfwd>
18 
20 #include <ossim/base/ossimCommon.h>
21 #include <ossim/base/ossimDpt.h>
22 
23 // Forward class declarations.
24 class ossimFpt;
25 class ossimDpt3d;
26 class ossimString;
27 
29 {
30 public:
31 
32  ossimIpt() : x(0), y(0) {}
33 
34  ossimIpt(ossim_int32 anX, ossim_int32 aY) : x(anX), y(aY) {}
35 
36  ossimIpt(const ossimIpt& pt) : x(pt.x), y(pt.y) {}
37 
38  ossimIpt(const ossimDpt& pt);
39 
40  ossimIpt(const ossimFpt& pt);
41 
42  ossimIpt(const ossimDpt3d &pt);
43 
44  const ossimIpt& operator=(const ossimIpt& pt);
45 
46  const ossimIpt& operator=(const ossimDpt& pt);
47 
48  const ossimIpt& operator=(const ossimFpt& pt);
49 
50  bool operator==(const ossimIpt& pt) const
51  { return ( (x == pt.x) && (y == pt.y) ); }
52 
53  bool operator!=(const ossimIpt& pt) const
54  { return ( (x != pt.x) || (y != pt.y) ); }
55 
57 
58  bool hasNans()const
59  {
60  return ( (x==OSSIM_INT_NAN) || (y==OSSIM_INT_NAN) );
61  }
62  bool isNan()const
63  {
64  return ( (x==OSSIM_INT_NAN) && (y==OSSIM_INT_NAN) );
65  }
66 
67  std::ostream& print(std::ostream& os) const;
68 
70  const ossimIpt& pt);
71 
78  ossimString toString() const;
79 
91  void toPoint(const std::string& s);
92 
107  ossimIpt& pt);
108 
109  bool isEqualTo(const ossimIpt& rhs, ossimCompareType compareType=OSSIM_COMPARE_FULL)const;
114  double length() const { return sqrt((double)x*x + (double)y*y); }
115 
116  //***
117  // OPERATORS: +, -, +=, -=
118  // Point add/subtract with other point:
119  //***
120  ossimIpt operator+(const ossimIpt& p) const
121  { return ossimIpt(x+p.x, y+p.y); }
122  ossimIpt operator-(const ossimIpt& p) const
123  { return ossimIpt(x-p.x, y-p.y); }
124  const ossimIpt& operator+=(const ossimIpt& p)
125  { x += p.x; y += p.y; return *this; }
126  const ossimIpt& operator-=(const ossimIpt& p)
127  { x -= p.x; y -= p.y; return *this; }
128 
129  //***
130  // OPERATORS: *, /
131  // Scale point components by scalar:
132  //***
133  ossimDpt operator*(const double& d) const
134  { return ossimDpt(d*x, d*y); }
135  ossimDpt operator/(const double& d) const
136  { return ossimDpt(x/d, y/d); }
137 
138  //***
139  // Public data members:
140  //***
143 
144 };
145 
146 inline const ossimIpt& ossimIpt::operator=(const ossimIpt& pt)
147 {
148  if (this != &pt)
149  {
150  x = pt.x;
151  y = pt.y;
152  }
153 
154  return *this;
155 }
156 #endif
ossim_uint32 x
void makeNan()
Definition: ossimIpt.h:56
#define OSSIMDLLEXPORT
ossim_uint32 y
bool isNan() const
Definition: ossimIpt.h:62
#define OSSIM_INT_NAN
std::ostream & print(H5::H5File *file, std::ostream &out)
Print method.
Definition: ossimH5Util.cpp:41
ossimIpt(const ossimIpt &pt)
Definition: ossimIpt.h:36
ossimCompareType
ossimIpt operator-(const ossimIpt &p) const
Definition: ossimIpt.h:122
ossimDpt operator/(const double &d) const
Definition: ossimIpt.h:135
bool operator==(const ossimIpt &pt) const
Definition: ossimIpt.h:50
ostream & operator<<(ostream &out, const ossimAxes &axes)
Definition: ossimAxes.h:88
ossimDpt operator*(const double &d) const
Definition: ossimIpt.h:133
const ossimIpt & operator+=(const ossimIpt &p)
Definition: ossimIpt.h:124
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
ossim_int32 y
Definition: ossimIpt.h:142
ossimIpt()
Definition: ossimIpt.h:32
double length() const
Definition: ossimIpt.h:114
ossim_int32 x
Definition: ossimIpt.h:141
bool operator!=(const ossimIpt &pt) const
Definition: ossimIpt.h:53
const ossimIpt & operator-=(const ossimIpt &p)
Definition: ossimIpt.h:126
bool hasNans() const
Definition: ossimIpt.h:58
const ossimIpt & operator=(const ossimIpt &pt)
Definition: ossimIpt.h:146
OSSIM_DLL void operator>>(ossimIStream &in, ossimOStream &out)
ossimIpt(ossim_int32 anX, ossim_int32 aY)
Definition: ossimIpt.h:34
ossimIpt operator+(const ossimIpt &p) const
Definition: ossimIpt.h:120
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
int ossim_int32