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); }
119 const auto *other =
dynamic_cast<const This *
>(&
src);
122 if (
_data == other->_data)
139 template <
typename PODT>
145 template <
typename PODT>
149 template <
typename PODT>
153 template <
typename PODT>
155 int tsize=-1,
int stride=-1)
const;
158 template <
typename PODT>
161 int nrepeats=1,
int stride=-1)
const;
168 {
return sizeof(*this) +
sizeof(
T)*
_size; }
172 #define _DECL_GETTERS(suffix,podt) \
174 virtual podt SYS_CONCAT(get,suffix)(GT_Offset o, \
175 int idx=0) const override \
176 { return getT<podt>(o, idx); } \
178 virtual const podt* SYS_CONCAT(get,SYS_CONCAT(suffix,Array)) \
179 (GT_DataArrayHandle& buf) const override \
180 { return getArrayT<podt>(buf); } \
183 virtual void doImport(GT_Offset o, podt* dst, \
184 GT_Size tsize) const override \
185 { importT(o, dst, tsize); } \
187 virtual void doFillArray(podt* dst, GT_Offset start, \
188 GT_Size length, int tsize, \
189 int stride) const override \
190 { fillArrayT(dst, start, length, \
193 virtual void extendedFill(podt* dst, GT_Offset start, \
194 GT_Size length, int tsize, \
196 int stride=-1) const override \
197 { extendedFillT(dst, start, length, \
198 tsize, nrepeats, stride); } \
221 GT_Size getStringIndexCount()
const override {
return -1; }
226 GT_Size getDictIndexCount()
const override {
return -1; }
242 : _array(array), _type(type), _size(array.
size())
250 : _type(type), _size(0), _data(nullptr)
259 _data =
reinterpret_cast<const PODType*
>(
260 makeUnique ? _array.data() : _array.cdata());
261 UT_ASSERT(_size == 0 || _data !=
nullptr);
270 _size = _array.size();
271 _UpdateDataPointer(
false);
286 template <
typename PODT>
292 return static_cast<PODT
>(_data[tupleSize*o + idx]);
297 template <
typename PODT>
302 return reinterpret_cast<const PODT*
>(_data);
306 _GTArrayType* tmpArray =
new _GTArrayType(_size, tupleSize, _type);
307 fillArrayT(tmpArray->data(), 0, _size, tupleSize);
309 return tmpArray->data();
314 template <
typename PODT>
318 tsize = tsize < 1 ? tupleSize :
SYSmin(tsize, tupleSize);
322 for(
int i = 0; i < tsize; ++i)
323 dst[i] = static_cast<PODT>(src[i]);
329 template <
typename PODT>
332 int tsize,
int stride)
const
340 stride =
SYSmax(stride, tsize);
341 tsize =
SYSmin(tsize, tupleSize);
343 tsize == tupleSize && stride == tupleSize) {
345 memcpy(dst, getData(start), length*tsize*
sizeof(PODT));
347 const PODType*
src = getData(start*tupleSize);
349 for(
int j = 0;
j < tsize; ++
j)
350 dst[
j] = static_cast<PODT>(src[
j]);
357 template <
typename PODT>
361 int nrepeats,
int stride)
const
364 return fillArrayT(dst, start, length, tsize, stride);
369 stride =
SYSmax(stride, tsize);
370 tsize =
SYSmin(tsize, tupleSize);
372 const PODType*
src = getData(start*tupleSize);
374 for(
int r = 0;
r < nrepeats; ++
r, dst +=
stride) {
375 for(
int j = 0;
j < tsize; ++
j)
376 dst[
j] = static_cast<PODT>(src[
j]);
GLenum GLuint GLenum GLsizei const GLchar * buf
const void * getBackingData() const override
const T & operator()(GT_Offset o) const
getFileOption("OpenEXR:storage") storage
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
typename GusdPodTupleTraits< T >::ValueType PODType
SYS_FORCE_INLINE UT_API XXH64_hash_t UTxxhash64(const void *data, size_t len)
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.
GLuint GLsizei GLsizei * length
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.
GLint GLenum GLboolean GLsizei stride
void swap(ArrayType &o)
Swap our array contents with another array.
static const int tupleSize
SYS_STATIC_ASSERT(GusdIsPodTuple< T >())
void _UpdateDataPointer(bool makeUnique)
GLboolean GLboolean GLboolean b
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.
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)
int64 getMemoryUsage() const override
const ArrayType & operator*() const
SYS_HashType hashRange(exint b, exint e) const override
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