OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
point.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 // Copyright (C) 2003-2010 by the IPLT authors
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 3.0 of the License, or (at your option)
10 // any later version.
11 // This library is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //------------------------------------------------------------------------------
20 
21 /*
22  integer triplet based point
23 
24  Author: Ansgar Philippsen
25 */
26 
27 /*
28  TODO: use boost operator
29 */
30 
31 #ifndef IMG_POINT_H
32 #define IMG_POINT_H
33 
34 #include <vector>
35 #include <iosfwd>
36 
37 #include <ost/img/module_config.hh>
38 #include "vecmat.hh"
39 
40 namespace ost { namespace img {
41 
42 //fw decl
43 class Size;
44 
47 public:
48  Point();
49  Point(const Point &p);
50 
52  explicit Point(int a);
54  Point(int a, int b);
56  Point(int a, int b, int c);
58  explicit Point(const Vec2& v);
59 
61  explicit Point(const Vec3& v);
62 
64  explicit Point(const Vec4& v);
65 
67  Point(const Size& s);
68 
70  Point Mirror(int planes);
71 
72  // operators
73  int operator[](unsigned int index) const;
74 
75  int& operator[](unsigned int index);
76 
77  Point& operator=(const Point& p);
78 
79  Point& operator+=(const Point& p);
80 
81  Point& operator-=(const Point& p);
82 
83  Point operator-() const;
84 
85  bool operator==(const Point &p) const;
86 
87  bool operator!=(const Point &p) const;
88 
89  bool operator<(const Point &p) const;
90 
91  bool operator<=(const Point &p) const;
92 
93  bool operator>(const Point &p) const;
94 
95  bool operator>=(const Point &p) const;
96 
97  Point& operator+=(const Size& p);
98 
99  Point& operator-=(const Size& p);
100 
101  // conversion to vectors
102  Vec2 ToVec2() const;
103  Vec3 ToVec3() const;
104  Vec4 ToVec4() const;
105 
106 private:
107  int data_[3];
108 
109  bool equal(const Point &p) const;
110  bool less(const Point &p) const;
111  Point neg() const;
112 
113  friend Point absolute(const Point&);
114 
115  Point absolute() const;
116 };
117 
118 DLLEXPORT_OST_IMG_BASE Point operator+(const Point& p1, const Point& p2);
119 DLLEXPORT_OST_IMG_BASE Point operator-(const Point& p1, const Point& p2);
120 
121  /*
122 Point operator+(const Point& p, const Size& s);
123 Point operator+(const Size& s, const Point& p);
124 
125 Point operator-(const Point& p, const Size& s);
126 Point operator-(const Size& s, const Point& p);
127  */
128 
129 DLLEXPORT_OST_IMG_BASE std::ostream& operator<<(std::ostream& os, const Point &p);
130 
131 
132 }} // namespace img
133 
134 
135 #endif
136 
137 
138