12 #ifndef __GA_PolyCounts__
13 #define __GA_PolyCounts__
23 #include <oneapi/tbb/blocked_range.h>
39 const int &
size()
const {
return mySize; }
40 const int &
count()
const {
return myCount; }
41 int &
size() {
return mySize; }
42 int &
count() {
return myCount; }
51 template<
typename CLASS,
typename ARRAYCLASS>
57 : myArray(&list.array)
64 : myArray(&list.array)
67 ARRAYCLASS &array = *myArray;
71 for (i = 0; i < array.entries()
72 && polygon >= array(i).count(); ++i)
74 start += array(i).product();
75 polygon -= array(i).count();
77 if (i < array.entries())
78 start += polygon*array(i).size();
84 : myArray(that.myArray)
85 , myPolygon(that.myPolygon)
86 , myStart(that.myStart)
87 , myIndex(that.myIndex)
88 , myCount(that.myCount)
99 return myIndex == (*myArray).entries();
106 myStart += nvertices();
108 if (myCount == (*myArray)(myIndex).
count())
120 myCount = (*myArray)(myIndex).
count();
123 myStart -= nvertices();
132 ARRAYCLASS &array = *myArray;
140 if (count >= 0 && count < array(i).
count())
142 start += (count - myCount)*array(i).size();
145 else if (count >= array(i).
count())
147 start += (array(i).count() - myCount)*array(i).size();
148 count -= array(i).count();
149 for (++i; i < array.entries() && count >= array(i).count(); ++i)
151 start += array(i).product();
152 count -= array(i).count();
154 if (i < array.entries())
155 start += count*array(i).size();
160 if (i < array.entries())
161 start -= myCount*array(i).size();
162 for (--i; -count >= array(i).count(); --i)
164 start -= array(i).product();
165 count += array(i).count();
167 start -= (array(i).count() +
count)*array(i).size();
168 count += array(i).count();
174 return (*
this)+(-
count);
182 myArray = that.myArray;
183 myPolygon = that.myPolygon;
184 myStart = that.myStart;
185 myIndex = that.myIndex;
186 myCount = that.myCount;
194 return (myPolygon == that.myPolygon);
200 return (myPolygon != that.myPolygon);
204 return (*myArray)(myIndex).
size();
231 , myNPolygons(list.getNumPolygons())
236 , myNPolygons(list.getNumPolygons())
237 , myGrainSize(grainsize)
240 : myIt(that.myIt + that.myNPolygons/2)
241 , myNPolygons(that.myNPolygons - (that.myNPolygons/2))
242 , myGrainSize(that.myGrainSize)
244 that.myNPolygons = that.myNPolygons/2;
254 {
return const_iterator(NULL, myIt.polygon() + myNPolygons, 0, 0, 0); }
258 bool empty()
const {
return myNPolygons == 0; }
296 for (i = 0; i < array.entries()
297 && relativevertex >= array(i).product(); ++i)
299 relativevertex -= array(i).product();
300 polygon += array(i).count();
306 SYSdivMod(relativevertex,
GA_Size(array(i).
size()), count, remainder);
329 if (array.entries() && array.last().size() ==
size)
330 array.last().count() +=
count;
340 if (array.entries() && array.last().size() == that.array(0).
size())
341 array.last().count() += that.array(0).count();
343 array.
append(that.array(0));
346 array.append(that.array(i));
351 for (
GA_Size i = 0; i < array.entries(); ++i)
352 sum += array(i).count();
358 for (
GA_Size i = 0; i < array.entries(); ++i)
359 sum += array(i).product();
368 for (i = 0; polygon >= array(i).count(); ++i)
369 polygon -= array(i).count();
370 return array(i).size();
378 for (i = 0; polygon >= array(i).count(); ++i)
380 index += array(i).product();
381 polygon -= array(i).count();
383 index += polygon*array(i).size();
385 size = array(i).size();
389 {
return (inclusive ?
sizeof(*
this) : 0) + array.getMemoryUsage(
false); }
Range class for multi-threading with TBB.
GA_API size_t UTestimatedNumItems(const GA_PolyCounts::Range &range)
Range(const GA_PolyCounts &list, GA_Size begin, GA_Size end, GA_Size grainsize=1)
const_iterator end() const
const UT_Array< SizeCount > & getArray() const
UT_Array< SizeCount > & getArray()
iteratorT(CLASS &list, GA_Size polygon)
void append(const GA_PolyCounts &that)
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
bool is_divisible() const
GA_PolyCounts & operator=(const GA_PolyCounts &that)
SizeCount(int sz, int ct)
GA_Size getNumVertices() const
exint GA_Size
Defines the bit width for index and offset types in GA.
GA_Size getSize(GA_Size polygon) const
Simpler than getVertexRange if you just want the polygon size.
iteratorT< CLASS, ARRAYCLASS > & operator++()
GA_Size getNumPolygons() const
GA_Size grainsize() const
const_iterator begin() const
iteratorT< CLASS, ARRAYCLASS > operator-(GA_Size count) const
bool operator!=(const iteratorT< CLASS, ARRAYCLASS > &that) const
iteratorT< GA_PolyCounts, UT_Array< SizeCount > > iterator
const_iterator end() const
int64 getMemoryUsage(bool inclusive) const
iteratorT< const GA_PolyCounts, const UT_Array< SizeCount > > const_iterator
iteratorT< CLASS, ARRAYCLASS > & operator--()
Range(const GA_PolyCounts &list)
const int & count() const
SYS_FORCE_INLINE bool atEnd() const
const_iterator findVertex(GA_Size relativevertex) const
SYS_FORCE_INLINE GA_Size start() const
exint entries() const
Alias of size(). size() is preferred.
const_iterator begin() const
iteratorT(const iteratorT< CLASS, ARRAYCLASS > &that)
iteratorT< CLASS, ARRAYCLASS > & operator*() const
void append(GA_Size size, GA_Size count=1)
GA_PolyCounts(const GA_PolyCounts &that)
iteratorT(ARRAYCLASS *array, GA_Size polygon, GA_Size start, GA_Size index, GA_Size count)
bool operator==(const iteratorT< CLASS, ARRAYCLASS > &that) const
Range(Range &that, UT_Split)
void getVertexRange(GA_Size polygon, GA_Size &start, GA_Size &size) const
SYS_FORCE_INLINE GA_Size nvertices() const
void OIIO_UTIL_API split(string_view str, std::vector< string_view > &result, string_view sep=string_view(), int maxsplit=-1)
iteratorT< CLASS, ARRAYCLASS > operator+(GA_Size count) const
SYS_FORCE_INLINE GA_Size polygon() const
iteratorT< CLASS, ARRAYCLASS > & operator=(const iteratorT< CLASS, ARRAYCLASS > &that)
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.