File: xyswappedmask2d.h

package info (click to toggle)
aoflagger 2.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,944 kB
  • sloc: cpp: 60,273; sh: 21; makefile: 8
file content (53 lines) | stat: -rw-r--r-- 1,263 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef XYSWAPPEDMASK2D_H
#define XYSWAPPEDMASK2D_H

#include <boost/shared_ptr.hpp>

#include "mask2d.h"

/**
 * This class wraps a mask and swappes the x and y axes. It provides only the
 * trivial @ref Mask2D functions, and swappes x and y in there, such that the original
 * width becomes the new height, etc. It is useful to convert an algorithm
 * that works originally only in one direction to work in the other direction
 * without rewriting it. If a template parameter is used, the overhead should
 * be negligable.
 * 
 * Note that this method uses references to the original mask. However, masks
 * are normally wrapped in a smart pointer. The caller should make sure the
 * mask exists as long as the XYSwappedMask2D exists.
 * 
 * @author Andre Offringa
 */
class XYSwappedMask2D
{
	public:
		inline XYSwappedMask2D(Mask2D &mask) : _mask(mask)
		{
		}
		
		inline bool Value(unsigned x, unsigned y) const
		{
			return _mask.Value(y, x);
		}
		
		inline void SetValue(unsigned x, unsigned y, bool newValue)
		{
			_mask.SetValue(y, x, newValue);
		}
		
		inline unsigned Width() const
		{
			return _mask.Height();
		}
		
		inline unsigned Height() const
		{
			return _mask.Width();
		}
		
	private:
		Mask2D &_mask;
};

#endif // XYSWAPPEDMASK2D_H