14 #ifndef NANOVDB_UTIL_RANGE_H_HAS_BEEN_INCLUDED 15 #define NANOVDB_UTIL_RANGE_H_HAS_BEEN_INCLUDED 20 #ifdef NANOVDB_USE_TBB 21 #include <tbb/blocked_range.h> 30 template <
int,
typename>
43 template<
int,
typename>
50 : mBegin(begin), mEnd(end), mGrainsize(grainsize)
55 Range(
Range &r,
Split) : mBegin(r.mBegin), mEnd(r.mEnd), mGrainsize(r.mGrainsize) {
56 assert(r.is_divisible());
57 r.mEnd = mBegin = this->middle();
59 #ifdef NANOVDB_USE_TBB 62 bool operator==(
const Range& rhs)
const {
return mBegin == rhs.mBegin && mEnd == rhs.mEnd && mGrainsize == rhs.mGrainsize; }
63 T
middle()
const {
return mBegin + (mEnd - mBegin) / T(2);}
65 bool empty()
const {
return !(mBegin < mEnd); }
81 :
Range(
Range<1,T>(beginRow, endRow, grainsizeRow),
Range<1,T>(beginCol, endCol, grainsizeCol) )
84 Range(T beginRow, T endRow, T beginCol, T endCol) :
Range(
Range<1,T>(beginRow, endRow),
Range<1,T>(beginCol, endCol) )
88 assert( r.is_divisible() );
89 if( mRange[0].size()*double(mRange[1].grainsize()) < mRange[1].size()*double(mRange[0].grainsize()) ) {
90 r.mRange[1].mEnd = mRange[1].mBegin = mRange[1].middle();
92 r.mRange[0].mEnd = mRange[0].mBegin = mRange[0].middle();
95 #ifdef NANOVDB_USE_TBB 98 bool operator==(
const Range& rhs)
const {
return mRange[0] == rhs[0] && mRange[1] == rhs[1]; }
99 bool empty()
const {
return mRange[0].empty() || mRange[1].empty(); }
100 bool is_divisible()
const {
return mRange[0].is_divisible() || mRange[1].is_divisible();}
105 template <
typename T>
115 :
Range(
Range<1,T>(beginX, endX, grainsizeX),
116 Range<1,T>(beginY, endY, grainsizeY),
117 Range<1,T>(beginZ, endZ, grainsizeZ) )
120 Range(T beginX, T endX, T beginY, T endY, T beginZ, T endZ)
126 assert( r.is_divisible() );
127 if ( mRange[2].size()*double(mRange[0].grainsize()) < mRange[0].size()*double(mRange[2].grainsize()) ) {
128 if ( mRange[0].size()*double(mRange[1].grainsize()) < mRange[1].size()*double(mRange[0].grainsize()) ) {
129 r.mRange[1].mEnd = mRange[1].mBegin = mRange[1].middle();
131 r.mRange[0].mEnd = mRange[0].mBegin = mRange[0].middle();
134 if ( mRange[2].size()*
double(mRange[1].grainsize()) < mRange[1].size()*
double(mRange[2].grainsize()) ) {
135 r.mRange[1].mEnd = mRange[1].mBegin = mRange[1].middle();
137 r.mRange[2].mEnd = mRange[2].mBegin = mRange[2].middle();
141 #ifdef NANOVDB_USE_TBB 144 bool operator==(
const Range& rhs)
const {
return mRange[0] == rhs[0] && mRange[1] == rhs[1] && mRange[2] == rhs[2]; }
145 bool empty()
const {
return mRange[0].empty() || mRange[1].empty() || mRange[2].empty(); }
146 bool is_divisible()
const {
return mRange[0].is_divisible() || mRange[1].is_divisible() || mRange[2].is_divisible();}
158 #endif // NANOVDB_UTIL_RANGE_H_HAS_BEEN_INCLUDED bool empty() const
Definition: Range.h:65
bool operator==(const Range &rhs) const
Definition: Range.h:62
T middle() const
Definition: Range.h:63
Range< 3, size_t > Range3D
Definition: Range.h:35
typename Range< 1, T >::size_type size_type
Definition: Range.h:78
Range(T begin, T end, size_type grainsize=size_type(1))
Definition: Range.h:49
bool is_divisible() const
Definition: Range.h:100
Range(Range &r, Split)
Definition: Range.h:87
Range< 2, size_t > Range2D
Definition: Range.h:34
size_type size() const
Definition: Range.h:64
const_iterator begin() const
Definition: Range.h:68
Definition: GridHandle.h:27
Range< 1, size_t > Range1D
Definition: Range.h:33
void split(ContainerT &out, const std::string &in, const char delim)
Definition: Name.h:43
bool empty() const
Definition: Range.h:99
bool operator==(const Range &rhs) const
Definition: Range.h:98
const Range< 1, T > & operator[](int i) const
Definition: Range.h:147
typename Range< 1, T >::size_type size_type
Definition: Range.h:110
const_iterator end() const
Definition: Range.h:69
Range(const Range< 1, T > &rangeRow, const Range< 1, T > &rangeCol)
Definition: Range.h:79
size_type grainsize() const
Definition: Range.h:66
bool empty() const
Definition: Range.h:145
bool empty(const char *str)
tests if a c-string str is empty, that is its first value is '\0'
Definition: Util.h:144
bool operator==(const Range &rhs) const
Definition: Range.h:144
Range(T beginX, T endX, size_type grainsizeX, T beginY, T endY, size_type grainsizeY, T beginZ, T endZ, size_type grainsizeZ)
Definition: Range.h:112
const Range< 1, T > & operator[](int i) const
Definition: Range.h:101
Range(T beginRow, T endRow, T beginCol, T endCol)
Definition: Range.h:84
T const_iterator
Definition: Range.h:46
Range(Range &r, Split)
Split constructor: r[a,b[ -> r[a,b/2[ & this[b/2,b[.
Definition: Range.h:55
Range(Range &r, Split)
Definition: Range.h:124
Range(T beginX, T endX, T beginY, T endY, T beginZ, T endZ)
Definition: Range.h:120
bool is_divisible() const
Definition: Range.h:67
size_t size_type
Definition: Range.h:47
Range(T beginRow, T endRow, size_type grainsizeRow, T beginCol, T endCol, size_type grainsizeCol)
Definition: Range.h:80
bool is_divisible() const
Definition: Range.h:146
Range(const Range< 1, T > &rangeX, const Range< 1, T > &rangeY, const Range< 1, T > &rangeZ)
Definition: Range.h:111