12 #ifndef __GA_PolyCounts__
13 #define __GA_PolyCounts__
23 #include <tbb/tbb_stddef.h>
38 const int &
size()
const {
return mySize; }
39 const int &
count()
const {
return myCount; }
40 int &
size() {
return mySize; }
41 int &
count() {
return myCount; }
50 template<
typename CLASS,
typename ARRAYCLASS>
56 : myArray(&list.array)
63 : myArray(&list.array)
66 ARRAYCLASS &array = *myArray;
70 for (i = 0; i < array.entries()
71 && polygon >= array(i).count(); ++i)
73 start += array(i).product();
74 polygon -= array(i).count();
76 if (i < array.entries())
77 start += polygon*array(i).size();
83 : myArray(that.myArray)
84 , myPolygon(that.myPolygon)
85 , myStart(that.myStart)
86 , myIndex(that.myIndex)
87 , myCount(that.myCount)
98 return myIndex == (*myArray).entries();
105 myStart += nvertices();
107 if (myCount == (*myArray)(myIndex).
count())
119 myCount = (*myArray)(myIndex).
count();
122 myStart -= nvertices();
131 ARRAYCLASS &array = *myArray;
139 if (count >= 0 && count < array(i).
count())
141 start += (count - myCount)*array(i).size();
144 else if (count >= array(i).
count())
146 start += (array(i).count() - myCount)*array(i).size();
147 count -= array(i).count();
148 for (++i; i < array.entries() && count >= array(i).count(); ++i)
150 start += array(i).product();
151 count -= array(i).count();
153 if (i < array.entries())
154 start += count*array(i).size();
159 if (i < array.entries())
160 start -= myCount*array(i).size();
161 for (--i; -count >= array(i).count(); --i)
163 start -= array(i).product();
164 count += array(i).count();
166 start -= (array(i).count() +
count)*array(i).size();
167 count += array(i).count();
173 return (*
this)+(-
count);
181 myArray = that.myArray;
182 myPolygon = that.myPolygon;
183 myStart = that.myStart;
184 myIndex = that.myIndex;
185 myCount = that.myCount;
193 return (myPolygon == that.myPolygon);
199 return (myPolygon != that.myPolygon);
203 return (*myArray)(myIndex).
size();
230 , myNPolygons(list.getNumPolygons())
235 , myNPolygons(list.getNumPolygons())
236 , myGrainSize(grainsize)
239 : myIt(that.myIt + that.myNPolygons/2)
240 , myNPolygons(that.myNPolygons - (that.myNPolygons/2))
241 , myGrainSize(that.myGrainSize)
243 that.myNPolygons = that.myNPolygons/2;
253 {
return const_iterator(NULL, myIt.polygon() + myNPolygons, 0, 0, 0); }
257 bool empty()
const {
return myNPolygons == 0; }
295 for (i = 0; i < array.entries()
296 && relativevertex >= array(i).product(); ++i)
298 relativevertex -= array(i).product();
299 polygon += array(i).count();
305 SYSdivMod(relativevertex,
GA_Size(array(i).
size()), count, remainder);
328 if (array.entries() && array.last().size() ==
size)
329 array.last().count() +=
count;
339 if (array.entries() && array.last().size() == that.array(0).
size())
340 array.last().count() += that.array(0).count();
342 array.
append(that.array(0));
345 array.append(that.array(i));
350 for (
GA_Size i = 0; i < array.entries(); ++i)
351 sum += array(i).count();
357 for (
GA_Size i = 0; i < array.entries(); ++i)
358 sum += array(i).product();
367 for (i = 0; polygon >= array(i).count(); ++i)
368 polygon -= array(i).count();
369 return array(i).size();
377 for (i = 0; polygon >= array(i).count(); ++i)
379 index += array(i).product();
380 polygon -= array(i).count();
382 index += polygon*array(i).size();
384 size = array(i).size();
388 {
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.