11 #ifndef __GT_DANumeric__
12 #define __GT_DANumeric__
31 , myTupleSize(tuple_size)
43 , myTupleSize(tuple_size)
56 const char *
className()
const override {
return "GT_DANumeric"; }
69 if (mySize != myCapacity)
86 GT_Size obytes = myCapacity * myTupleSize *
sizeof(
T);
87 GT_Size nbytes = capacity * myTupleSize *
sizeof(
T);
89 myData, obytes, nbytes);
92 myCapacity = capacity;
98 if (mySize == myCapacity)
101 set(value, mySize-1);
105 if (mySize == myCapacity)
108 setTuple(value, mySize-1);
117 if (mySize + src.mySize > myCapacity)
118 grow(mySize + src.mySize);
119 memcpy(myData + mySize*myTupleSize,
121 src.mySize*src.myTupleSize*
sizeof(
T));
122 mySize += src.mySize;
135 offset *= myTupleSize;
142 offset *= myTupleSize;
148 offset = offset * myTupleSize +
index;
149 UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
156 offset = offset * myTupleSize;
157 memcpy(myData + offset, value, myTupleSize*
sizeof(
T));
165 offset = offset * myTupleSize;
166 memcpy(myData + offset, values->myData, values->mySize*myTupleSize*
sizeof(
T));
175 offset = offset * myTupleSize;
176 memcpy(myData + offset, values, n*myTupleSize*
sizeof(
T));
184 memcpy(myData, src, myTupleSize*mySize*
sizeof(
T));
196 {
return sizeof(
T)*mySize*myTupleSize; }
200 offset = offset * myTupleSize +
index;
201 UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
206 offset = offset * myTupleSize +
index;
207 UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
212 offset = offset * myTupleSize +
index;
213 UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
218 offset = offset * myTupleSize +
index;
219 UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
224 offset = offset * myTupleSize +
index;
225 UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
230 offset = offset * myTupleSize +
index;
231 UT_ASSERT_P(offset>=0 && offset<mySize*myTupleSize);
251 if (SYSisSame<T, uint8>())
252 return reinterpret_cast<const uint8 *
>(
data());
257 if (SYSisSame<T, int8>())
258 return reinterpret_cast<const int8 *
>(
data());
263 if (SYSisSame<T, int16>())
264 return reinterpret_cast<const int16 *
>(
data());
269 if (SYSisSame<T, int32>())
270 return reinterpret_cast<const int32 *
>(
data());
275 if (SYSisSame<T, int64>())
276 return reinterpret_cast<const int64 *
>(
data());
281 if (SYSisSame<T, fpreal16>())
287 if (SYSisSame<T, fpreal32>())
293 if (SYSisSame<T, fpreal64>())
299 { importTuple<uint8>(idx,
data,
size); }
301 { importTuple<int8>(idx,
data,
size); }
303 { importTuple<int16>(idx,
data,
size); }
305 { importTuple<int32>(idx,
data,
size); }
307 { importTuple<int64>(idx,
data,
size); }
309 { importTuple<fpreal16>(idx,
data,
size); }
311 { importTuple<fpreal32>(idx,
data,
size); }
313 { importTuple<fpreal64>(idx,
data,
size); }
316 int tsize,
int stride)
const override
317 { t_NumericFill(data, start, length, tsize, stride); }
319 int tsize,
int stride)
const override
320 { t_NumericFill(data, start, length, tsize, stride); }
322 int tsize,
int stride)
const override
323 { t_NumericFill(data, start, length, tsize, stride); }
325 int tsize,
int stride)
const override
326 { t_NumericFill(data, start, length, tsize, stride); }
328 int tsize,
int stride)
const override
329 { t_NumericFill(data, start, length, tsize, stride); }
331 int tsize,
int stride)
const override
332 { t_NumericFill(data, start, length, tsize, stride); }
334 int tsize,
int stride)
const override
335 { t_NumericFill(data, start, length, tsize, stride); }
337 int tsize,
int stride)
const override
338 { t_NumericFill(data, start, length, tsize, stride); }
359 for (
int j = 0;
j < myTupleSize; ++
j)
361 myMin[
j] = myMax[
j] = data[
j];
366 , myTupleSize(src.myTupleSize)
369 std::copy(src.myMin, src.myMin+myTupleSize, myMin);
370 std::copy(src.myMax, src.myMax+myTupleSize, myMax);
374 if (myMin != myMinBuffer)
382 for (
GT_Size i = range.begin(),
n = range.end(); i <
n; ++i)
384 const T *pos = myData + i * myTupleSize;
385 for (
int j = 0;
j < myTupleSize; ++
j)
387 myMin[
j] =
SYSmin(myMin[
j], pos[j]);
388 myMax[
j] =
SYSmax(myMax[j], pos[j]);
394 for (
int j = 0;
j < myTupleSize; ++
j)
402 for (
int j = 0;
j < myTupleSize; ++
j)
404 myMin[
j] =
SYSmin(myMin[
j], src.myMin[j]);
405 myMax[
j] =
SYSmax(myMax[j], src.myMax[j]);
411 if (myTupleSize > 16)
413 myMin =
new T[myTupleSize];
414 myMax =
new T[myTupleSize];
438 void grow(
exint sz=-1)
440 GT_Size obytes = myCapacity * myTupleSize *
sizeof(
T);
441 myCapacity = sz < 0 ? UTbumpAlloc(myCapacity+1) : sz;
442 GT_Size nbytes = myCapacity * myTupleSize *
sizeof(
T);
444 myData, obytes, nbytes);
446 template <
typename T_POD>
inline void
452 tsize =
SYSmin(tsize, myTupleSize);
453 const T *
src = myData + idx*myTupleSize;
454 for (
int i = 0; i < tsize; ++i)
455 data[i] = (T_POD)src[i];
460 int tsize,
int stride)
const
464 stride =
SYSmax(stride, tsize);
465 int n =
SYSmin(tsize, myTupleSize);
466 if (n == myTupleSize && stride == myTupleSize)
468 memcpy(dest, myData+start*myTupleSize,
473 const T *src = myData+start*myTupleSize;
475 src += myTupleSize, dest +=
stride)
477 for (
int j = 0;
j <
n; ++
j)
483 template <
typename T_POD>
inline void
485 int tsize,
int stride)
const
489 stride =
SYSmax(stride, tsize);
490 int n =
SYSmin(tsize, myTupleSize);
491 const T *src = myData+start*myTupleSize;
493 src += myTupleSize, dest +=
stride)
495 for (
int j = 0;
j <
n; ++
j)
496 dest[
j] = (T_POD)src[
j];
const fpreal64 * getF64Array(GT_DataArrayHandle &buffer) const override
GT_API GT_DataArray * GTallocateIntArray(const int64 *array, GT_Size size, int tuple_size=1)
void doImport(GT_Offset idx, uint8 *data, GT_Size size) const override
void doImport(GT_Offset idx, int8 *data, GT_Size size) const override
void append(const T *value)
GT_DAPointMaterialID(int pcount)
virtual SYS_HashType hashRange(exint begin, exint end) const
GT_Size getStringIndexCount() const override
const void * getBackingData() const override
Provide virtual access to the backing data.
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
void doFillArray(int32 *data, GT_Offset start, GT_Size length, int tsize, int stride) const override
GLsizei const GLfloat * value
virtual const fpreal32 * getF32Array(GT_DataArrayHandle &buffer) const
uint8 getU8(GT_Offset offset, int index=0) const override
void doFillArray(fpreal64 *data, GT_Offset start, GT_Size length, int tsize, int stride) const override
const uint8 * getU8Array(GT_DataArrayHandle &buffer) const override
const int64 * getI64Array(GT_DataArrayHandle &buffer) const override
std::size_t SYS_HashType
Define the type for hash values.
GLuint GLsizei GLsizei * length
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
T * data() const
Raw access to the data array.
GT_Size getDictIndexCount() const override
T * getData(GT_Offset offset)
Raw pointer access to a tuple.
GT_Size capacity() const
Accessor to capacity of the array.
virtual const fpreal64 * getF64Array(GT_DataArrayHandle &buffer) const
int32 getI32(GT_Offset offset, int index=0) const override
void doImport(GT_Offset idx, int16 *data, GT_Size size) const override
virtual const int16 * getI16Array(GT_DataArrayHandle &buffer) const
void doFillArray(fpreal16 *data, GT_Offset start, GT_Size length, int tsize, int stride) const override
void doFillArray(fpreal32 *data, GT_Offset start, GT_Size length, int tsize, int stride) const override
GT_DANumeric< uint8 > GT_Unsigned8Array
virtual const fpreal16 * getF16Array(GT_DataArrayHandle &buffer) const
void doImport(GT_Offset idx, fpreal64 *data, GT_Size size) const override
Abstract data class for an array of float, int or string data.
const int32 * getI32Array(GT_DataArrayHandle &buffer) const override
GT_Size getTupleSize() const override
const int16 * getI16Array(GT_DataArrayHandle &buffer) const override
GT_String getS(GT_Offset, int) const override
UT_IntrusivePtr< GT_DataArray > GT_DataArrayHandle
int64 getI64(GT_Offset offset, int index=0) const override
num_MinMaxTask(const T *data, int tsize)
static const UT_StringHolder theEmptyString
const T * getData(GT_Offset offset) const
Raw pointer access to a tuple.
void doFillArray(int16 *data, GT_Offset start, GT_Size length, int tsize, int stride) const override
GLint GLenum GLboolean GLsizei stride
void doImport(GT_Offset idx, int64 *data, GT_Size size) const override
virtual const int8 * getI8Array(GT_DataArrayHandle &buffer) const
void doFillArray(uint8 *data, GT_Offset start, GT_Size length, int tsize, int stride) const override
void resize(GT_Size size, GT_Size capacity=-1)
const int8 * getI8Array(GT_DataArrayHandle &buffer) const override
GT_DANumeric(GT_Size array_size, int tuple_size, GT_Type type=GT_TYPE_NONE)
Create a numeric array.
void setTuple(const T *value, GT_Offset offset)
Set an entire tuple.
GT_Offset getDictIndex(GT_Offset, int) const override
ImageBuf OIIO_API resize(const ImageBuf &src, string_view filtername="", float filterwidth=0.0f, ROI roi={}, int nthreads=0)
void set(T value, GT_Offset offset, int index=0)
Set a component of the tuple.
fpreal16 getF16(GT_Offset offset, int index=0) const override
GLenum GLsizei GLsizei GLint * values
void operator()(const UT_BlockedRange< GT_Size > &range)
void doFillArray(int64 *data, GT_Offset start, GT_Size length, int tsize, int stride) const override
GT_DANumeric(const T *data, GT_Size array_size, int tuple_size, GT_Type type=GT_TYPE_NONE)
void concat(const GT_DANumeric< T > &src)
void doFillArray(int8 *data, GT_Offset start, GT_Size length, int tsize, int stride) const override
GT_Offset getStringIndex(GT_Offset, int) const override
virtual const int64 * getI64Array(GT_DataArrayHandle &buffer) const
const fpreal32 * getF32Array(GT_DataArrayHandle &buffer) const override
void copyFrom(const T *src)
Copy an entire data from a flat array.
void doImport(GT_Offset idx, int32 *data, GT_Size size) const override
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
void doImport(GT_Offset idx, fpreal16 *data, GT_Size size) const override
GT_Type getTypeInfo() const override
int64 getMemoryUsage() const override
void append(T value)
Append a scalar value to the array.
GT_Size entries() const override
An array of numeric values (int32, int64, fpreal16, fpreal32, fpreal64)
virtual const uint8 * getU8Array(GT_DataArrayHandle &buffer) const
void doImport(GT_Offset idx, fpreal32 *data, GT_Size size) const override
num_MinMaxTask(num_MinMaxTask &src, UT_Split)
void getIndexedStrings(UT_StringArray &, UT_IntArray &) const override
fpreal64 getF64(GT_Offset offset, int index=0) const override
void setTupleBlock(const T *values, GT_Size n, GT_Offset offset)
Set a block of entire tuples.
GT_DataArrayHandle harden() const override
A numeric array is hard to begin with.
void setTupleBlock(const GT_DANumeric< T > *values, GT_Offset offset)
Set a block of entire tuples.
void join(const num_MinMaxTask &src)
void getIndexedDicts(UT_Array< UT_OptionsHolder > &, UT_IntArray &) const override
virtual bool isEqual(const GT_DataArray &src) const
Compare whether two data arrays are equal.
const char * className() const override
GT_EXTERN_TEMPLATE(GT_DANumeric< int8 >)
GT_Storage getStorage() const override
const fpreal16 * getF16Array(GT_DataArrayHandle &buffer) const override
bool computeMinMax(fpreal64 *min, fpreal64 *max) const override
fpreal32 getF32(GT_Offset offset, int index=0) const override
void UTparallelReduceLightItems(const Range &range, Body &body)
void getResult(fpreal64 *min, fpreal64 *max) const
virtual const int32 * getI32Array(GT_DataArrayHandle &buffer) const
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.