OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Vec2ui.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSG_VEC2UI
15 #define OSG_VEC2UI 1
16 
17 namespace osg {
18 
21 class Vec2ui
22 {
23  public:
24 
26  typedef unsigned int value_type;
27 
29  enum { num_components = 2 };
30 
32  value_type _v[2];
33 
34  Vec2ui() { _v[0]=0; _v[1]=0; }
35 
36  Vec2ui(value_type x, value_type y) { _v[0] = x; _v[1] = y; }
37 
38  inline bool operator == (const Vec2ui& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1]; }
39  inline bool operator != (const Vec2ui& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1]; }
40  inline bool operator < (const Vec2ui& v) const
41  {
42  if (_v[0]<v._v[0]) return true;
43  else if (_v[0]>v._v[0]) return false;
44  else return (_v[1]<v._v[1]);
45  }
46 
47  inline value_type* ptr() { return _v; }
48  inline const value_type* ptr() const { return _v; }
49 
50  inline void set( value_type x, value_type y)
51  {
52  _v[0]=x; _v[1]=y;
53  }
54 
55  inline void set( const Vec2ui& rhs)
56  {
57  _v[0]=rhs._v[0]; _v[1]=rhs._v[1];
58  }
59 
60  inline value_type& operator [] (int i) { return _v[i]; }
61  inline value_type operator [] (int i) const { return _v[i]; }
62 
63  inline value_type& x() { return _v[0]; }
64  inline value_type& y() { return _v[1]; }
65 
66  inline value_type x() const { return _v[0]; }
67  inline value_type y() const { return _v[1]; }
68 
69  inline value_type& r() { return _v[0]; }
70  inline value_type& g() { return _v[1]; }
71 
72  inline value_type r() const { return _v[0]; }
73  inline value_type g() const { return _v[1]; }
74 
75  inline Vec2ui operator * (value_type rhs) const
76  {
77  return Vec2ui(_v[0]*rhs, _v[1]*rhs);
78  }
79 
80  inline Vec2ui operator / (value_type rhs) const
81  {
82  return Vec2ui(_v[0]/rhs, _v[1]/rhs);
83  }
84 
85  inline Vec2ui operator + (value_type rhs) const
86  {
87  return Vec2ui(_v[0]+rhs, _v[1]+rhs);
88  }
89 
90  inline Vec2ui operator - (value_type rhs) const
91  {
92  return Vec2ui(_v[0]-rhs, _v[1]-rhs);
93  }
94 
95  inline Vec2ui operator + (const Vec2ui& rhs) const
96  {
97  return Vec2ui(_v[0]+rhs._v[0], _v[1]+rhs._v[1]);
98  }
99 
100  inline Vec2ui operator - (const Vec2ui& rhs) const
101  {
102  return Vec2ui(_v[0]-rhs._v[0], _v[1]-rhs._v[1]);
103  }
104 
105  inline Vec2ui operator * (const Vec2ui& rhs) const
106  {
107  return Vec2ui(_v[0]*rhs._v[0], _v[1]*rhs._v[1]);
108  }
109 
110 };
111 
112 }
113 
114 #endif
value_type & y()
Definition: Vec2ui.h:64
value_type r() const
Definition: Vec2ui.h:72
void set(const Vec2ui &rhs)
Definition: Vec2ui.h:55
void set(value_type x, value_type y)
Definition: Vec2ui.h:50
value_type g() const
Definition: Vec2ui.h:73
Vec2ui(value_type x, value_type y)
Definition: Vec2ui.h:36
value_type _v[2]
Definition: Vec2ui.h:32
bool operator!=(const Vec2ui &v) const
Definition: Vec2ui.h:39
value_type & x()
Definition: Vec2ui.h:63
bool operator==(const Vec2ui &v) const
Definition: Vec2ui.h:38
value_type & operator[](int i)
Definition: Vec2ui.h:60
Vec2ui operator/(value_type rhs) const
Definition: Vec2ui.h:80
Vec2ui operator*(value_type rhs) const
Definition: Vec2ui.h:75
Vec2ui()
Definition: Vec2ui.h:34
unsigned int value_type
Definition: Vec2ui.h:26
value_type & g()
Definition: Vec2ui.h:70
value_type * ptr()
Definition: Vec2ui.h:47
Definition: AlphaFunc.h:19
bool operator<(const Vec2ui &v) const
Definition: Vec2ui.h:40
value_type & r()
Definition: Vec2ui.h:69
value_type y() const
Definition: Vec2ui.h:67
value_type x() const
Definition: Vec2ui.h:66
Vec2ui operator+(value_type rhs) const
Definition: Vec2ui.h:85
Vec2ui operator-(value_type rhs) const
Definition: Vec2ui.h:90
const value_type * ptr() const
Definition: Vec2ui.h:48