OpenStructure
size.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-2020 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  unsigned integer triplet based size
23 
24  Author: Ansgar Philippsen
25 */
26 
27 #ifndef IMG_SIZE_H
28 #define IMG_SIZE_H
29 
30 #include <iosfwd>
31 
32 #include <ost/img/module_config.hh>
33 
34 namespace ost { namespace img {
35 
36 class Point;
37 
40  public:
41  Size();
42  Size(const Size &s);
43 
45  explicit Size(unsigned int w);
46 
48  explicit Size(unsigned int w, unsigned int h);
49 
51  explicit Size(unsigned int w, unsigned int h, unsigned int d);
52 
54  Size(const Point& p1, const Point& p2);
55 
57 
60  Point GetHalf() const;
61 
63  unsigned int GetWidth() const;
65  unsigned int GetHeight() const;
67  unsigned int GetDepth() const;
69  unsigned int GetSlab() const;
71  unsigned int GetVol() const;
73  unsigned int GetVolume() const;
74 
76  unsigned int GetDim() const;
77 
78  // some operators
79  Size& operator=(const Size& s);
80  unsigned int operator[](unsigned int index) const;
81  unsigned int& operator[](unsigned int index);
82  bool operator==(const Size& s) const;
83  bool operator!=(const Size& s) const;
84 
85  Size& operator+=(const Size& s);
86  Size& operator-=(const Size& s);
87 
88  private:
89  unsigned int w_,h_,d_;
90 
91  bool equal(const Size& s) const;
92 };
93 
96 
97 DLLEXPORT_OST_IMG_BASE std::ostream& operator<<(std::ostream& os, const Size& s);
98 
99 
100 }} // namespace img
101 
102 
103 #endif
class encapsulating 1D to 3D point
Definition: point.hh:47
class encapsulating 1D to 3D size
Definition: size.hh:39
unsigned int GetHeight() const
get height component (convenience to index 1)
Size & operator-=(const Size &s)
Size(unsigned int w)
1D constructor
unsigned int GetDepth() const
get depth component (convenience to index 2)
Size(unsigned int w, unsigned int h, unsigned int d)
3D constructor
Point GetHalf() const
return the point at half the size
unsigned int GetDim() const
return dimensionality (1-3)
unsigned int GetWidth() const
get width component (convenience to index 0)
unsigned int & operator[](unsigned int index)
Size(unsigned int w, unsigned int h)
2D constructor
bool operator!=(const Size &s) const
unsigned int GetVol() const
get volume (depcrecated, use GetVolume() instead)
unsigned int GetVolume() const
get volume
Size & operator+=(const Size &s)
bool operator==(const Size &s) const
unsigned int GetSlab() const
get area (width * height)
Size(const Point &p1, const Point &p2)
initialize from two points
Size & operator=(const Size &s)
Size(const Size &s)
unsigned int operator[](unsigned int index) const
#define DLLEXPORT_OST_IMG_BASE
DLLEXPORT_OST_IMG_BASE ImageHandle operator-(const ConstImageHandle &h, Real v)
DLLEXPORT_OST_IMG_BASE std::ostream & operator<<(std::ostream &os, const img::Extent &b)
DLLEXPORT_OST_IMG_BASE ImageHandle operator+(const ConstImageHandle &h, Real v)
Definition: base.dox:1