Artec 3D Scanning SDK  2.0
Range.h
Go to the documentation of this file.
1 /********************************************************************
2  *
3  * Project Artec 3D Scanning SDK
4  *
5  * Purpose: Definition of template range class
6  *
7  * Copyright: Artec Group
8  *
9  ********************************************************************/
10 
11 #ifndef _RANGE_H_
12 #define _RANGE_H_
13 
14 namespace artec { namespace sdk { namespace base
15 {
16 
17 /*
18 * Template class for ranges
19 */
20 
21 template < typename T >
22 /// Structure that defines range (e.g., 0..1)
23 struct Range
24 {
25  typedef T value_type;
26 
27  Range() : low(T()), high(T()) {}
28  Range(const T & low, const T & high) : low(low), high(high) {}
29 
30  /// Check whether the range contains that value
31  bool contains(const T & value) const { return value >= low && value <= high; }
32 
33  /// Check whether the value lies inside the range
34  bool operator()(const T & value) const { return value > low && value < high; }
35  bool operator[](const T & value) const { return value >= low && value <= high; }
36 
37  T low;
38  T high;
39 };
40 
44 
45 } } } // namespace artec::sdk::base
46 
47 #endif //_RANGE_H_
Range(const T &low, const T &high)
Definition: Range.h:28
bool contains(const T &value) const
Check whether the range contains that value.
Definition: Range.h:31
Structure that defines range (e.g., 0..1)
Definition: Range.h:23
Range< float > RangeF
Definition: Range.h:42
bool operator[](const T &value) const
Definition: Range.h:35
Range< int > RangeI
Definition: Range.h:41
bool operator()(const T &value) const
Check whether the value lies inside the range.
Definition: Range.h:34
Range< double > RangeD
Definition: Range.h:43