14 #ifndef NANOVDB_RANGE_H_HAS_BEEN_INCLUDED
15 #define NANOVDB_RANGE_H_HAS_BEEN_INCLUDED
19 #ifdef NANOVDB_USE_TBB
20 #include <tbb/blocked_range.h>
27 template <
int,
typename>
40 template<
int,
typename>
47 : mBegin(begin), mEnd(end), mGrainsize(grainsize)
53 assert(r.is_divisible());
54 r.mEnd = mBegin = this->middle();
56 #ifdef NANOVDB_USE_TBB
59 bool operator==(
const Range& rhs)
const {
return mBegin == rhs.mBegin && mEnd == rhs.mEnd && mGrainsize == rhs.mGrainsize; }
60 T middle()
const {
return mBegin + (mEnd - mBegin) /
T(2);}
62 bool empty()
const {
return !(mBegin < mEnd); }
78 :
Range(
Range<1,
T>(beginRow, endRow, grainsizeRow),
Range<1,
T>(beginCol, endCol, grainsizeCol) )
81 Range(T beginRow, T endRow, T beginCol, T endCol) :
Range(
Range<1,
T>(beginRow, endRow),
Range<1,
T>(beginCol, endCol) )
85 assert( r.is_divisible() );
86 if( mRange[0].
size()*double(mRange[1].grainsize()) < mRange[1].size()*double(mRange[0].grainsize()) ) {
87 r.mRange[1].mEnd = mRange[1].mBegin = mRange[1].middle();
89 r.mRange[0].mEnd = mRange[0].mBegin = mRange[0].middle();
92 #ifdef NANOVDB_USE_TBB
95 bool operator==(
const Range& rhs)
const {
return mRange[0] == rhs[0] && mRange[1] == rhs[1]; }
96 bool empty()
const {
return mRange[0].empty() || mRange[1].empty(); }
97 bool is_divisible()
const {
return mRange[0].is_divisible() || mRange[1].is_divisible();}
102 template <
typename T>
113 Range<1,
T>(beginY, endY, grainsizeY),
114 Range<1,
T>(beginZ, endZ, grainsizeZ) )
117 Range(T beginX, T endX, T beginY, T endY, T beginZ, T endZ)
123 assert( r.is_divisible() );
124 if ( mRange[2].
size()*double(mRange[0].grainsize()) < mRange[0].size()*double(mRange[2].grainsize()) ) {
125 if ( mRange[0].
size()*double(mRange[1].grainsize()) < mRange[1].size()*double(mRange[0].grainsize()) ) {
126 r.mRange[1].mEnd = mRange[1].mBegin = mRange[1].middle();
128 r.mRange[0].mEnd = mRange[0].mBegin = mRange[0].middle();
131 if ( mRange[2].
size()*
double(mRange[1].grainsize()) < mRange[1].
size()*
double(mRange[2].grainsize()) ) {
132 r.mRange[1].mEnd = mRange[1].mBegin = mRange[1].middle();
134 r.mRange[2].mEnd = mRange[2].mBegin = mRange[2].middle();
138 #ifdef NANOVDB_USE_TBB
141 bool operator==(
const Range& rhs)
const {
return mRange[0] == rhs[0] && mRange[1] == rhs[1] && mRange[2] == rhs[2]; }
142 bool empty()
const {
return mRange[0].empty() || mRange[1].empty() || mRange[2].empty(); }
143 bool is_divisible()
const {
return mRange[0].is_divisible() || mRange[1].is_divisible() || mRange[2].is_divisible();}
149 #endif // NANOVDB_RANGE_H_HAS_BEEN_INCLUDED
const_iterator begin() const
typename Range< 1, T >::size_type size_type
Range(T beginX, T endX, T beginY, T endY, T beginZ, T endZ)
bool is_divisible() const
Range(T beginRow, T endRow, size_type grainsizeRow, T beginCol, T endCol, size_type grainsizeCol)
Range(T beginRow, T endRow, T beginCol, T endCol)
bool is_divisible() const
const Range< 1, T > & operator[](int i) const
bool is_divisible() const
const Range< 1, T > & operator[](int i) const
size_type grainsize() const
Range(T beginX, T endX, size_type grainsizeX, T beginY, T endY, size_type grainsizeY, T beginZ, T endZ, size_type grainsizeZ)
typename Range< 1, T >::size_type size_type
Range(const Range< 1, T > &rangeX, const Range< 1, T > &rangeY, const Range< 1, T > &rangeZ)
bool operator==(const Range &rhs) const
Range(T begin, T end, size_type grainsize=size_type(1))
bool operator==(const Range &rhs) const
Range(const Range< 1, T > &rangeRow, const Range< 1, T > &rangeCol)
bool operator==(const Range &rhs) const
Range(Range &r, Split)
Split constructor: r[a,b[ -> r[a,b/2[ & this[b/2,b[.
void OIIO_UTIL_API split(string_view str, std::vector< string_view > &result, string_view sep=string_view(), int maxsplit=-1)
const_iterator end() const
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.