14 #ifndef __GA_PageArray__
15 #define __GA_PageArray__
40 template <
typename T>
class UT_Array;
101 template<
typename DATA_T=
void,
exint TSIZE=-1,
bool TABLEHARDENED=
true,
bool PAGESHARDENED=
false>
178 template<
typename SRC_T>
181 if (!SYSisSame<DATA_T,void>())
184 NotVoidType dval(val);
216 UT_ASSERT_MSG(0,
"Can't have a GA_PageArray with invalid storage!");
223 if (!SYSisSame<DATA_T,void>())
239 castType<int8>().
setConstant(range, defaults);
return;
241 castType<uint8>().
setConstant(range, defaults);
return;
243 castType<int16>().
setConstant(range, defaults);
return;
245 castType<int32>().
setConstant(range, defaults);
return;
247 castType<int64>().
setConstant(range, defaults);
return;
249 castType<fpreal16>().
setConstant(range, defaults);
return;
251 castType<fpreal32>().
setConstant(range, defaults);
return;
253 castType<fpreal64>().
setConstant(range, defaults);
return;
255 UT_ASSERT_MSG(0,
"Can't have a GA_PageArray with invalid storage!");
266 template<
typename SRC_T>
269 if (!SYSisSame<DATA_T,void>())
272 NotVoidType dval(val);
299 UT_ASSERT_MSG(0,
"Can't have a GA_PageArray with invalid storage!");
304 template<
typename SRC_T>
307 if (!SYSisSame<DATA_T,void>())
342 UT_ASSERT_MSG(0,
"Can't have a GA_PageArray with invalid storage!");
347 template<
typename SRC_T>
350 if (!SYSisSame<DATA_T,void>())
380 UT_ASSERT_MSG(0,
"Can't have a GA_PageArray with invalid storage!");
386 template<
typename SRC_T>
389 if (!SYSisSame<DATA_T,void>())
406 castType<int8>().
setConstant(range, values);
return;
408 castType<uint8>().
setConstant(range, values);
return;
410 castType<int16>().
setConstant(range, values);
return;
412 castType<int32>().
setConstant(range, values);
return;
414 castType<int64>().
setConstant(range, values);
return;
416 castType<fpreal16>().
setConstant(range, values);
return;
418 castType<fpreal32>().
setConstant(range, values);
return;
420 castType<fpreal64>().
setConstant(range, values);
return;
422 UT_ASSERT_MSG(0,
"Can't have a GA_PageArray with invalid storage!");
428 template<
typename SRC_T>
439 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_TABLEHARDENED,
bool SRC_PAGESHARDENED>
442 template<
typename SRC_DATA_T,ex
int SRC_TSIZE,
bool SRC_TABLEHARDENED,
bool SRC_PAGESHARDENED>
456 if (deststart == destend)
461 if (srcstart == srcend)
469 moveRange(src, srcstart, deststart, nelements);
471 deststart += nelements;
472 srcstart += nelements;
479 if (SYSisSame<DATA_T,void>())
486 castType<int8>().
getRange(srcrange, dest);
return;
488 castType<uint8>().
getRange(srcrange, dest);
return;
490 castType<int16>().
getRange(srcrange, dest);
return;
492 castType<int32>().
getRange(srcrange, dest);
return;
494 castType<int64>().
getRange(srcrange, dest);
return;
496 castType<fpreal16>().
getRange(srcrange, dest);
return;
498 castType<fpreal32>().
getRange(srcrange, dest);
return;
500 castType<fpreal64>().
getRange(srcrange, dest);
return;
502 UT_ASSERT_MSG(0,
"Can't have a GA_PageArray with invalid storage!");
511 if (TSIZE == -1 && tuplesize <= 3)
514 castTupleSize<1>().
getRange(srcrange, dest);
515 else if (tuplesize == 2)
516 castTupleSize<2>().
getRange(srcrange, dest);
517 else if (tuplesize == 3)
518 castTupleSize<3>().
getRange(srcrange, dest);
535 if (SYSisSame<DATA_T,void>())
542 castType<int8>().
setRange(destrange, src);
return;
544 castType<uint8>().
setRange(destrange, src);
return;
546 castType<int16>().
setRange(destrange, src);
return;
548 castType<int32>().
setRange(destrange, src);
return;
550 castType<int64>().
setRange(destrange, src);
return;
552 castType<fpreal16>().
setRange(destrange, src);
return;
554 castType<fpreal32>().
setRange(destrange, src);
return;
556 castType<fpreal64>().
setRange(destrange, src);
return;
558 UT_ASSERT_MSG(0,
"Can't have a GA_PageArray with invalid storage!");
567 if (TSIZE == -1 && tuplesize <= 3)
570 castTupleSize<1>().
setRange(destrange, src);
571 else if (tuplesize == 2)
572 castTupleSize<2>().
setRange(destrange, src);
573 else if (tuplesize == 3)
574 castTupleSize<3>().
setRange(destrange, src);
599 if (SYSisSame<DATA_T,void>())
622 UT_ASSERT_MSG(0,
"Can't have a GA_PageArray with invalid storage!");
633 for (
UT_PageNum pagei = 0; pagei < npages; ++pagei)
636 const NotVoidType *thatdata = that.
getPageData(pagei);
637 if (thisdata == thatdata)
640 if (!thisdata || !thatdata ||
653 const UT_IntArray *map =
nullptr,
int defvalue=-1)
const;
663 template<
typename MAP_ARRAY_CLASS>
664 bool jsonSaveConstantOutputPageFlags(
672 bool const_output,
bool const_input,
675 bool jsonSaveRawPageData(
681 class ga_SubPageBlock;
683 static void buildOutputToInternalPageMap(
686 static void buildOutputToInternalPageMap(
689 GA_Size marshallConstantFlagsForOutputPages(
692 GA_Size marshallConstantFlagsForOutputPages(
696 static bool isSubPageConstant(
699 const exint tuplesize,
702 template<
bool ARRAY_OF_ARRAYS>
710 class LoadComponentArrayFunctor;
712 bool jsonLoadRawPageData(
718 int n_packing_entries,
730 template<
typename DEST_DATA_T>
738 template<
typename DEST_DATA_T>
751 template<ex
int DEST_TSIZE>
759 template<ex
int DEST_TSIZE>
SYS_FORCE_INLINE bool isPageConstant(UT_PageNum pagenum) const
Returns true iff the specified page is constant-compressed.
SYS_FORCE_INLINE GA_PageArray< DATA_T, DEST_TSIZE, TABLEHARDENED, PAGESHARDENED > & castTupleSize()
Iteration over a range of elements.
UT_PageArray< DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED, GA_PAGE_BITS, GA_Offset > Base
UT_JID
The UT_JID enums are used in byte-stream encoding of binary JSON.
NotVoid< DATA_T >::type NotVoidType
Class which stores the default values for a GA_Attribute.
getFileOption("OpenEXR:storage") storage
bool jsonSave(UT_JSONWriter &w, const GA_Range &range, const GA_SaveOptions *options=nullptr, const UT_IntArray *map=nullptr, int defvalue=-1) const
void setConstant(const GA_Range &range, const SRC_T *values)
NOTE: values must have a number of values equal to the tuple size.
void comparePages(UT_BitArray &bits, const ThisType &that) const
SYS_FORCE_INLINE GA_Offset size() const
The merge map keeps track of information when merging details.
SYS_FORCE_INLINE DEST_DATA_T get(GA_Offseti, exint component=0) const
GLuint GLsizei GLsizei * length
void setConstant(GA_Offsetstart, GA_Offsetend, NotVoidType v)
SYS_FORCE_INLINE GA_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED > & castType()
JSON reader class which handles parsing of JSON or bJSON files.
void setConstantVector(const GA_Range &range, const UT_FixedVector< SRC_T, theSafeTupleSize > &val)
SYS_FORCE_INLINE exint getTupleSize() const
void defragment(const GA_Defragment &defrag)
Include GA_PageArrayImpl.h to call this.
Class which writes ASCII or binary JSON streams.
#define UT_ASSERT_MSG_P(ZZ,...)
bool jsonLoad(UT_JSONParser &p, const GA_LoadMap &map, GA_AttributeOwner owner)
SYS_FORCE_INLINE UT_FixedVector< DEST_DATA_T, DEST_TSIZE > getVector(GA_Offseti) const
GA_PageArray(exint tuplesize)
SYS_FORCE_INLINE void set(GA_Offseti, SRC_DATA_T v)
component == 0 in this version
SYS_FORCE_INLINE UT_Storage getStorage() const
void setConstant(const GA_Range &range, SRC_T val)
exint GA_Size
Defines the bit width for index and offset types in GA.
void copy(const GA_Range &destrange, const GA_PageArray< SRC_DATA_T, SRC_TSIZE, SRC_TABLEHARDENED, SRC_PAGESHARDENED > &src, const GA_Range &srcrange)
#define GA_INVALID_OFFSET
A range of elements in an index-map.
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
#define UT_ASSERT_MSG(ZZ,...)
void setConstantVector(GA_Offset start, GA_Offset end, const UT_FixedVector< SRC_T, theSafeTupleSize > &val)
SYS_FORCE_INLINE void setConstant(GA_Offset start, GA_Offset end, const GA_Defaults &v)
GA_PageArray(GA_Storage storage)
SYS_FORCE_INLINE void tryCompressPage(UT_PageNum pagenum)
static SYS_FORCE_INLINE UT_PageNum numPages(GA_Offsetnelements)
static SYS_FORCE_INLINE bool isEqual(const T0 *a, const T1 *b, exint tuplesize)
SYS_FORCE_INLINE void getRange(GA_Offsetsrcstart, GA_Offsetnelements, T *dest) const
SYS_FORCE_INLINE void setPageConstant(UT_PageNum pagenum, const NotVoidType &val)
static SYS_FORCE_INLINE bool isZero(const T &val)
void setConstant(GA_Offset start, GA_Offset end, SRC_T val)
SYS_FORCE_INLINE NotVoidType * hardenPage(UT_PageNum pagenum)
void setBitFast(exint index, bool value)
GA_PageArray(exint tuplesize, GA_Storage storage)
SYS_FORCE_INLINE GA_Storage UTStorageToGAStorage(UT_Storage storage)
Defragmentation of IndexMaps.
void getRange(const GA_Range &srcrange, T *dest) const
SYS_FORCE_INLINE NotVoidType * hardenPageNoInit(UT_PageNum pagenum)
const NotVoidType * getPageData(UT_PageNum pagenum) const
static const exint theSafeTupleSize
void mergeGrowArrayAndCopy(const GA_MergeMap &map, GA_AttributeOwner owner, const GA_PageArray< SRC_DATA_T, SRC_TSIZE, SRC_TABLEHARDENED, SRC_PAGESHARDENED > &src, const GA_Defaults &defaults)
Include GA_PageArrayImpl.h to call this.
void setConstant(const GA_Range &range, const GA_Defaults &defaults)
GA_PageArray(exint tuplesize, UT_Storage storage)
void moveRange(GA_Offsetsrcstart, GA_Offsetdeststart, GA_Offsetnelements)
static const exint thePageMask
SYS_FORCE_INLINE void setConstant(GA_Offset start, GA_Offset end, const SRC_T *values)
NOTE: values must have a number of values equal to the tuple size.
void setRange(const GA_Range &destrange, const T *src)
SYS_FORCE_INLINE UT_Storage GAStorageToUTStorage(GA_Storage storage)
void setSize(GA_Offsetnewsize)
GLenum GLsizei GLsizei GLint * values
void swapRange(GA_Offsetastart, GA_Offsetbstart, GA_Offsetnelements)
SYS_FORCE_INLINE GA_Storage getStorage() const
Get the storage type for each component of this GA_PageArray.
void setStorage(const UT_Storage newstorage)
GA_PageArray< DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED > ThisType
SYS_FORCE_INLINE void setRange(GA_Offsetdeststart, GA_Offsetnelements, const T *src)
SYS_FORCE_INLINE UT_PageArray< DATA_T, TSIZE, true, PAGESHARDENED, THEPAGEBITS, GA_Offset > & hardenTable()
static const exint thePageSize
SYS_FORCE_INLINE const GA_PageArray< DATA_T, DEST_TSIZE, TABLEHARDENED, PAGESHARDENED > & castTupleSize() const
GLubyte GLubyte GLubyte GLubyte w
SYS_FORCE_INLINE const GA_PageArray< DEST_DATA_T, TSIZE, TABLEHARDENED, PAGESHARDENED > & castType() const
SYS_FORCE_INLINE void setVector(GA_Offseti, const TS &as)
bool fullBlockAdvance(GA_Offset &start, GA_Offset &end)
void setStorage(GA_Storage storage)
Set the storage type for each component of this GA_PageArray.