24 #ifndef _GUSD_GT_VTARRAY_H_
25 #define _GUSD_GT_VTARRAY_H_
34 #include "pxr/base/vt/array.h"
86 const char*
className()
const override {
return "GusdGT_VtArray"; }
91 return reinterpret_cast<T*
>(
_data)[o];
95 {
return getT<PODType>(o, idx); }
108 sizeof(
PODType)*tupleSize*(e-b), 0);
120 const auto *other =
dynamic_cast<const This *
>(&
src);
123 if (
_data == other->_data)
140 template <
typename PODT>
146 template <
typename PODT>
150 template <
typename PODT>
154 template <
typename PODT>
156 int tsize=-1,
int stride=-1)
const;
159 template <
typename PODT>
162 int nrepeats=1,
int stride=-1)
const;
169 {
return sizeof(*this) +
sizeof(
T)*
_size; }
173 #define _DECL_GETTERS(suffix,podt) \
175 virtual podt SYS_CONCAT(get,suffix)(GT_Offset o, \
176 int idx=0) const override \
177 { return getT<podt>(o, idx); } \
179 virtual const podt* SYS_CONCAT(get,SYS_CONCAT(suffix,Array)) \
180 (GT_DataArrayHandle& buf) const override \
181 { return getArrayT<podt>(buf); } \
184 virtual void doImport(GT_Offset o, podt* dst, \
185 GT_Size tsize) const override \
186 { importT(o, dst, tsize); } \
188 virtual void doFillArray(podt* dst, GT_Offset start, \
189 GT_Size length, int tsize, \
190 int stride) const override \
191 { fillArrayT(dst, start, length, \
194 virtual void extendedFill(podt* dst, GT_Offset start, \
195 GT_Size length, int tsize, \
197 int stride=-1) const override \
198 { extendedFillT(dst, start, length, \
199 tsize, nrepeats, stride); } \
222 GT_Size getStringIndexCount()
const override {
return -1; }
238 : _array(array), _type(type), _size(array.
size())
246 : _type(type), _size(0), _data(nullptr)
255 _data =
reinterpret_cast<const PODType*
>(
256 makeUnique ? _array.data() : _array.cdata());
257 UT_ASSERT(_size == 0 || _data !=
nullptr);
266 _size = _array.GetSize();
267 _UpdateDataPointer(
false);
282 template <
typename PODT>
288 return static_cast<PODT
>(_data[tupleSize*o + idx]);
293 template <
typename PODT>
298 return reinterpret_cast<const PODT*
>(_data);
302 _GTArrayType* tmpArray =
new _GTArrayType(_size, tupleSize, _type);
303 fillArrayT(tmpArray->data(), 0, _size, tupleSize);
305 return tmpArray->data();
310 template <
typename PODT>
314 tsize = tsize < 1 ? tupleSize :
SYSmin(tsize, tupleSize);
318 for(
int i = 0; i < tsize; ++i)
319 dst[i] = static_cast<PODT>(src[i]);
325 template <
typename PODT>
328 int tsize,
int stride)
const
336 stride =
SYSmax(stride, tsize);
337 tsize =
SYSmin(tsize, tupleSize);
339 tsize == tupleSize && stride == tupleSize) {
341 memcpy(dst, getData(start), length*tsize*
sizeof(PODT));
343 const PODType*
src = getData(start*tupleSize);
345 for(
int j = 0; j < tsize; ++j)
346 dst[j] = static_cast<PODT>(src[j]);
353 template <
typename PODT>
357 int nrepeats,
int stride)
const
360 return fillArrayT(dst, start, length, tsize, stride);
365 stride =
SYSmax(stride, tsize);
366 tsize =
SYSmin(tsize, tupleSize);
368 const PODType*
src = getData(start*tupleSize);
370 for(
int r = 0;
r < nrepeats; ++
r, dst +=
stride) {
371 for(
int j = 0; j < tsize; ++j)
372 dst[j] = static_cast<PODT>(src[j]);
GLboolean GLboolean GLboolean b
const void * getBackingData() const override
const T & operator()(GT_Offset o) const
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
typename GusdPodTupleTraits< T >::ValueType PODType
GT_Type getTypeInfo() const override
Return "type" information for the data. This defaults to GT_TYPE_NONE.
std::size_t SYS_HashType
Define the type for hash values.
GT_DataArrayHandle harden() const override
Create a "hardened" version of the array.
const PODType * getData(GT_Offset o) const
GT_Size getTupleSize() const override
Number of elements for each array element.
static const GT_Storage storage
const PODT * getArrayT(GT_DataArrayHandle &buf) const
Abstract data class for an array of float, int or string data.
PODType operator()(GT_Offset o, int idx) const
UT_IntrusivePtr< GT_DataArray > GT_DataArrayHandle
void extendedFillT(PODT *dst, GT_Offset start, GT_Size length, int tsize=-1, int nrepeats=1, int stride=-1) const
Extended form of array extraction that supports repeated elems.
void importT(GT_Offset o, PODT *dst, int tsize=-1) const
Extract a tuple into dst.
void swap(ArrayType &o)
Swap our array contents with another array.
static const int tupleSize
SYS_STATIC_ASSERT(GusdIsPodTuple< T >())
void _UpdateDataPointer(bool makeUnique)
const PODType * data() const
GT_Storage getStorage() const override
Type of data stored in the array.
virtual GT_Size entries() const =0
Number of entries in the array.
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GusdGT_VtArray(const ArrayType &array, GT_Type type=GT_TYPE_NONE)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
#define PXR_NAMESPACE_CLOSE_SCOPE
virtual GT_Storage getStorage() const =0
Type of data stored in the array.
An array of numeric values (int32, int64, fpreal16, fpreal32, fpreal64)
getOption("OpenEXR.storage") storage
int64 getMemoryUsage() const override
const ArrayType & operator*() const
SYS_HashType hashRange(exint b, exint e) const override
GLint GLenum GLboolean GLsizei stride
const char * className() const override
virtual GT_Size getTupleSize() const =0
Number of elements for each array element.
GT_Size entries() const override
Number of entries in the array.
virtual bool isEqual(const GT_DataArray &src) const
Compare whether two data arrays are equal.
bool isEqual(const GT_DataArray &src) const override
Compare whether two data arrays are equal.
void fillArrayT(PODT *dst, GT_Offset start, GT_Size length, int tsize=-1, int stride=-1) const
Extract data for entire array into dst.
~GusdGT_VtArray() override=default
PODT getT(GT_Offset o, int idx=0) const