10 #ifndef OPENVDB_POINTS_ATTRIBUTE_ARRAY_HAS_BEEN_INCLUDED
11 #define OPENVDB_POINTS_ATTRIBUTE_ARRAY_HAS_BEEN_INCLUDED
23 #include <tbb/spin_mutex.h>
29 #include <type_traits>
32 class TestAttributeArray;
48 template <
typename IntegerT,
typename FloatT>
59 template <
typename FloatT,
typename IntegerT>
67 template <
typename IntegerVectorT,
typename FloatT>
71 return IntegerVectorT(
72 floatingPointToFixedPoint<typename IntegerVectorT::ValueType>(v.
x()),
73 floatingPointToFixedPoint<typename IntegerVectorT::ValueType>(v.
y()),
74 floatingPointToFixedPoint<typename IntegerVectorT::ValueType>(v.
z()));
77 template <
typename FloatVectorT,
typename IntegerT>
82 fixedPointToFloatingPoint<typename FloatVectorT::ValueType>(v.
x()),
83 fixedPointToFloatingPoint<typename FloatVectorT::ValueType>(v.
y()),
84 fixedPointToFloatingPoint<typename FloatVectorT::ValueType>(v.
z()));
96 template <
typename T>
struct Accessor;
104 CONSTANTSTRIDE = 0x8,
112 WRITEMEMCOMPRESS = 0x4,
120 tbb::spin_mutex::scoped_lock lock;
125 using Ptr = std::shared_ptr<AttributeArray>;
126 using ConstPtr = std::shared_ptr<const AttributeArray>;
137 if (mFlags & PARTIALREAD) mCompressedBytes = 0;
201 bool constantStride =
true,
213 template<
typename AttributeArrayType>
214 bool isType()
const {
return this->type() == AttributeArrayType::attributeType(); }
217 template<
typename ValueType>
218 bool hasValueType()
const {
return this->type().first == typeNameAsString<ValueType>(); }
250 template<
typename IterT>
251 void copyValuesUnsafe(
const AttributeArray& sourceArray,
const IterT& iter);
255 template<
typename IterT>
256 void copyValues(
const AttributeArray& sourceArray,
const IterT& iter,
bool compact =
true);
262 virtual void expand(
bool fill =
true) = 0;
285 bool isHidden()
const {
return bool(mFlags & HIDDEN); }
306 uint8_t
flags()
const {
return mFlags; }
309 virtual void read(std::istream&) = 0;
312 virtual void write(std::ostream&,
bool outputTransient)
const = 0;
314 virtual void write(std::ostream&)
const = 0;
321 virtual void writeMetadata(std::ostream&,
bool outputTransient,
bool paged)
const = 0;
327 virtual void writeBuffers(std::ostream&,
bool outputTransient)
const = 0;
347 #if OPENVDB_ABI_VERSION_NUMBER >= 9
353 friend class ::TestAttributeArray;
360 virtual char* dataAsByteArray() = 0;
361 virtual const char* dataAsByteArray()
const = 0;
364 template <
typename IterT>
365 void doCopyValues(
const AttributeArray& sourceArray,
const IterT& iter,
366 bool rangeChecking =
true);
369 #if OPENVDB_ABI_VERSION_NUMBER >= 7
386 bool mIsUniform =
true;
389 uint8_t mUsePagedRead = 0;
407 template <
typename T>
415 mGetter(getter), mSetter(setter), mCollapser(collapser), mFiller(filler) { }
427 namespace attribute_traits
459 template <
typename T>
462 template<
typename ValueType>
static void decode(
const ValueType&, ValueType&);
463 template<
typename ValueType>
static void encode(
const ValueType&, ValueType&);
464 static const char*
name() {
return "null"; }
470 template <
typename T>
473 template<
typename StorageType,
typename ValueType>
static void decode(
const StorageType&, ValueType&);
474 template<
typename StorageType,
typename ValueType>
static void encode(
const ValueType&, StorageType&);
475 static const char*
name() {
return "trnc"; }
482 static const char*
name() {
return "fxpt"; }
483 template <
typename ValueType>
static ValueType
encode(
const ValueType&
value) {
return value + ValueType(0.5); }
484 template <
typename ValueType>
static ValueType
decode(
const ValueType&
value) {
return value - ValueType(0.5); }
491 static const char*
name() {
return "ufxpt"; }
492 template <
typename ValueType>
static ValueType
encode(
const ValueType&
value) {
return value; }
493 template <
typename ValueType>
static ValueType
decode(
const ValueType&
value) {
return value; }
497 template <
bool OneByte,
typename Range=PositionRange>
500 template <
typename T>
503 template<
typename StorageType,
typename ValueType>
static void decode(
const StorageType&, ValueType&);
504 template<
typename StorageType,
typename ValueType>
static void encode(
const ValueType&, StorageType&);
507 static const std::string
Name = std::string(Range::name()) + (OneByte ?
"8" :
"16");
517 template <
typename T>
522 static const char*
name() {
return "uvec"; }
531 template<
typename ValueType_,
typename Codec_ = NullCodec>
535 using Ptr = std::shared_ptr<TypedAttributeArray>;
536 using ConstPtr = std::shared_ptr<const TypedAttributeArray>;
540 using StorageType =
typename Codec::template Storage<ValueType>::Type;
546 const ValueType& uniformValue = zeroVal<ValueType>());
547 #if OPENVDB_ABI_VERSION_NUMBER >= 7
584 static Ptr create(
Index n,
Index strideOrTotalSize = 1,
bool constantStride = true,
585 const
Metadata* metadata =
nullptr);
594 static const
NamePair& attributeType();
596 const
NamePair& type()
const override {
return attributeType(); }
599 static bool isRegistered();
601 static void registerType();
603 static void unregisterType();
610 Index stride()
const override {
return hasConstantStride() ? mStrideOrTotalSize : 0; }
614 return hasConstantStride() ? mSize * mStrideOrTotalSize : mStrideOrTotalSize;
631 bool valueTypeIsFloatingPoint()
const override;
634 bool valueTypeIsClass()
const override;
637 bool valueTypeIsVector()
const override;
640 bool valueTypeIsQuaternion()
const override;
643 bool valueTypeIsMatrix()
const override;
649 ValueType getUnsafe(
Index n)
const;
651 ValueType get(
Index n)
const;
653 template<
typename T>
void getUnsafe(
Index n, T&
value)
const;
655 template<
typename T>
void get(
Index n, T&
value)
const;
662 void setUnsafe(
Index n,
const ValueType&
value);
666 template<
typename T>
void setUnsafe(
Index n,
const T&
value);
668 template<
typename T>
void set(
Index n,
const T&
value);
679 bool isUniform()
const override {
return mIsUniform; }
683 void expand(
bool fill =
true)
override;
685 void collapse()
override;
687 bool compact()
override;
690 void collapse(
const ValueType& uniformValue);
693 void fill(
const ValueType&
value);
702 bool compress() override;
705 bool decompress() override;
708 void read(
std::istream&) override;
712 void write(
std::ostream& os,
bool outputTransient) const override;
714 void write(
std::ostream&) const override;
717 void readMetadata(
std::istream&) override;
722 void writeMetadata(
std::ostream& os,
bool outputTransient,
bool paged) const override;
725 void readBuffers(
std::istream&) override;
729 void writeBuffers(
std::ostream& os,
bool outputTransient) const override;
732 void readPagedBuffers(compression::PagedInputStream&) override;
736 void writePagedBuffers(compression::PagedOutputStream& os,
bool outputTransient) const override;
739 inline
bool isOutOfCore() const;
742 void loadData() const override;
745 bool isDataLoaded() const override;
747 #if OPENVDB_ABI_VERSION_NUMBER >= 9
753 AccessorBasePtr getAccessor()
const override;
760 inline bool validData()
const {
return !(isOutOfCore() || (flags() & PARTIALREAD)); }
763 friend class ::TestAttributeArray;
765 #if OPENVDB_ABI_VERSION_NUMBER >= 7
770 inline void doLoad()
const;
773 inline void doLoadUnsafe(
const bool compression =
true)
const;
775 inline bool compressUnsafe();
778 inline void setOutOfCore(
const bool);
784 char* dataAsByteArray()
override;
785 const char* dataAsByteArray()
const override;
787 size_t arrayMemUsage()
const;
794 return TypedAttributeArray::create(n, strideOrTotalSize, constantStride, metadata);
797 static std::unique_ptr<const NamePair> sTypeName;
798 std::unique_ptr<StorageType[]> mData;
800 Index mStrideOrTotalSize;
809 template <
typename ValueType,
typename CodecType = UnknownCodec>
814 using Ptr = std::shared_ptr<Handle>;
853 friend class ::TestAttributeArray;
855 template <
bool IsUnknownCodec>
856 typename std::enable_if<IsUnknownCodec, bool>::type compatibleType()
const;
858 template <
bool IsUnknownCodec>
859 typename std::enable_if<!IsUnknownCodec, bool>::type compatibleType()
const;
861 template <
bool IsUnknownCodec>
862 typename std::enable_if<IsUnknownCodec, ValueType>::type get(
Index index)
const;
864 template <
bool IsUnknownCodec>
865 typename std::enable_if<!IsUnknownCodec, ValueType>::type get(
Index index)
const;
870 Index mStrideOrTotalSize;
872 bool mCollapseOnDestruction;
880 template <
typename ValueType,
typename CodecType = UnknownCodec>
885 using Ptr = std::shared_ptr<Handle>;
915 friend class ::TestAttributeArray;
917 template <
bool IsUnknownCodec>
918 typename std::enable_if<IsUnknownCodec, void>::type set(
Index index,
const ValueType&
value)
const;
920 template <
bool IsUnknownCodec>
921 typename std::enable_if<!IsUnknownCodec, void>::type set(
Index index,
const ValueType&
value)
const;
931 template<
typename ValueType>
933 NullCodec::decode(
const ValueType& data, ValueType& val)
939 template<
typename ValueType>
941 NullCodec::encode(
const ValueType& val, ValueType& data)
947 template<
typename StorageType,
typename ValueType>
949 TruncateCodec::decode(
const StorageType& data, ValueType& val)
951 val =
static_cast<ValueType
>(data);
955 template<
typename StorageType,
typename ValueType>
957 TruncateCodec::encode(
const ValueType& val, StorageType& data)
959 data =
static_cast<StorageType
>(val);
963 template <
bool OneByte,
typename Range>
964 template<
typename StorageType,
typename ValueType>
968 val = fixedPointToFloatingPoint<ValueType>(data);
972 val = Range::template decode<ValueType>(val);
976 template <
bool OneByte,
typename Range>
977 template<
typename StorageType,
typename ValueType>
983 const ValueType newVal = Range::template encode<ValueType>(val);
985 data = floatingPointToFixedPoint<StorageType>(newVal);
993 val = math::QuantizedUnitVec::unpack(data);
1001 data = math::QuantizedUnitVec::pack(val);
1009 template <
typename IterT>
1010 void AttributeArray::doCopyValues(
const AttributeArray& sourceArray,
const IterT& iter,
1016 assert(sourceArray.
isDataLoaded() && this->isDataLoaded());
1018 assert(this->storageTypeSize()*this->stride() ==
1022 const char*
const sourceBuffer = sourceArray.dataAsByteArray();
1023 char*
const targetBuffer = this->dataAsByteArray();
1024 assert(sourceBuffer && targetBuffer);
1026 if (rangeChecking && this->isUniform()) {
1030 const bool sourceIsUniform = sourceArray.
isUniform();
1032 const Index sourceDataSize = rangeChecking ? sourceArray.
dataSize() : 0;
1033 const Index targetDataSize = rangeChecking ? this->dataSize() : 0;
1035 for (IterT it(iter); it; ++it) {
1036 const Index sourceIndex = sourceIsUniform ? 0 : it.sourceIndex();
1037 const Index targetIndex = it.targetIndex();
1039 if (rangeChecking) {
1040 if (sourceIndex >= sourceDataSize) {
1042 "Cannot copy array data as source index exceeds size of source array.");
1044 if (targetIndex >= targetDataSize) {
1046 "Cannot copy array data as target index exceeds size of target array.");
1050 assert(sourceIndex < sourceArray.
dataSize());
1051 assert(targetIndex < this->dataSize());
1052 if (this->isUniform()) assert(targetIndex ==
Index(0));
1055 const size_t targetOffset(targetIndex * bytes);
1056 const size_t sourceOffset(sourceIndex * bytes);
1058 std::memcpy(targetBuffer + targetOffset, sourceBuffer + sourceOffset, bytes);
1062 template <
typename IterT>
1063 void AttributeArray::copyValuesUnsafe(
const AttributeArray& sourceArray,
const IterT& iter)
1065 this->doCopyValues(sourceArray, iter,
false);
1068 template <
typename IterT>
1069 void AttributeArray::copyValues(
const AttributeArray& sourceArray,
const IterT& iter,
1073 if (bytes != this->storageTypeSize()) {
1090 this->doCopyValues(sourceArray, iter,
true);
1103 template<
typename ValueType_,
typename Codec_>
1107 template<
typename ValueType_,
typename Codec_>
1113 , mStrideOrTotalSize(strideOrTotalSize)
1115 if (constantStride) {
1117 if (strideOrTotalSize == 0) {
1119 "stride to be at least one.")
1124 if (mStrideOrTotalSize < n) {
1126 "a total size of at least the number of elements in the array.")
1130 mStrideOrTotalSize =
std::max(
Index(1), mStrideOrTotalSize);
1131 Codec::encode(uniformValue, this->
data()[0]);
1135 #if OPENVDB_ABI_VERSION_NUMBER >= 7
1136 template<
typename ValueType_,
typename Codec_>
1143 template<
typename ValueType_,
typename Codec_>
1145 const tbb::spin_mutex::scoped_lock& lock)
1148 template<typename ValueType_, typename Codec_>
1153 , mStrideOrTotalSize(rhs.mStrideOrTotalSize)
1157 std::memcpy(
static_cast<void*
>(this->
data()), rhs.
data(), this->arrayMemUsage());
1162 template<
typename ValueType_,
typename Codec_>
1163 TypedAttributeArray<ValueType_, Codec_>&
1168 tbb::spin_mutex::scoped_lock lock(mMutex);
1169 tbb::spin_mutex::scoped_lock rhsLock(rhs.
mMutex);
1176 mStrideOrTotalSize = rhs.mStrideOrTotalSize;
1179 if (this->validData()) {
1181 std::memcpy(
static_cast<void*
>(this->data()), rhs.
data(), this->arrayMemUsage());
1189 template<
typename ValueType_,
typename Codec_>
1193 static std::once_flag once;
1194 std::call_once(once, []()
1196 sTypeName.reset(
new NamePair(typeNameAsString<ValueType>(), Codec::name()));
1202 template<
typename ValueType_,
typename Codec_>
1210 template<
typename ValueType_,
typename Codec_>
1218 template<
typename ValueType_,
typename Codec_>
1226 template<
typename ValueType_,
typename Codec_>
1235 typedMetadata ? typedMetadata->
value() : zeroVal<ValueType>()));
1238 template<
typename ValueType_,
typename Codec_>
1248 template<
typename ValueType_,
typename Codec_>
1258 template<
typename ValueType_,
typename Codec_>
1262 #if OPENVDB_ABI_VERSION_NUMBER < 7
1263 tbb::spin_mutex::scoped_lock lock(mMutex);
1269 template<
typename ValueType_,
typename Codec_>
1273 return this->copy();
1277 template<
typename ValueType_,
typename Codec_>
1281 if (this->isOutOfCore())
return 0;
1283 return (mIsUniform ? 1 : this->dataSize()) *
sizeof(StorageType);
1287 template<
typename ValueType_,
typename Codec_>
1289 TypedAttributeArray<ValueType_, Codec_>::allocate()
1293 mData.reset(
new StorageType[1]);
1296 const size_t size(this->dataSize());
1298 mData.reset(
new StorageType[size]);
1303 template<
typename ValueType_,
typename Codec_>
1305 TypedAttributeArray<ValueType_, Codec_>::deallocate()
1308 if (this->isOutOfCore()) {
1309 this->setOutOfCore(
false);
1310 this->mPageHandle.reset();
1312 if (mData) mData.reset();
1316 template<
typename ValueType_,
typename Codec_>
1336 template<
typename ValueType_,
typename Codec_>
1345 template<
typename ValueType_,
typename Codec_>
1353 template<
typename ValueType_,
typename Codec_>
1358 return !this->valueType().compare(0, 4,
"quat");
1362 template<
typename ValueType_,
typename Codec_>
1367 return !this->valueType().compare(0, 3,
"mat");
1371 template<
typename ValueType_,
typename Codec_>
1375 return sizeof(*this) + (bool(mData) ? this->arrayMemUsage() : 0);
1379 template<
typename ValueType_,
typename Codec_>
1383 assert(n < this->dataSize());
1386 Codec::decode(this->data()[mIsUniform ? 0 : n], val);
1391 template<
typename ValueType_,
typename Codec_>
1396 if (this->isOutOfCore()) this->doLoad();
1398 return this->getUnsafe(n);
1402 template<
typename ValueType_,
typename Codec_>
1403 template<
typename T>
1407 val =
static_cast<T
>(this->getUnsafe(n));
1411 template<
typename ValueType_,
typename Codec_>
1412 template<
typename T>
1416 val =
static_cast<T
>(this->get(n));
1420 template<
typename ValueType_,
typename Codec_>
1428 template<
typename ValueType_,
typename Codec_>
1432 assert(n < this->dataSize());
1433 assert(!this->isOutOfCore());
1434 assert(!this->isUniform());
1439 Codec::encode(val, this->data()[mIsUniform ? 0 : n]);
1443 template<
typename ValueType_,
typename Codec_>
1448 if (this->isOutOfCore()) this->doLoad();
1449 if (this->isUniform()) this->expand();
1451 this->setUnsafe(n, val);
1455 template<
typename ValueType_,
typename Codec_>
1456 template<
typename T>
1460 this->setUnsafe(n,
static_cast<ValueType>(val));
1464 template<
typename ValueType_,
typename Codec_>
1465 template<
typename T>
1469 this->set(n,
static_cast<ValueType>(val));
1473 template<
typename ValueType_,
typename Codec_>
1481 template<
typename ValueType_,
typename Codec_>
1488 sourceTypedArray.
get(sourceIndex, sourceValue);
1490 this->set(n, sourceValue);
1494 template<
typename ValueType_,
typename Codec_>
1498 if (!mIsUniform)
return;
1503 tbb::spin_mutex::scoped_lock lock(mMutex);
1510 for (
Index i = 0; i < this->dataSize(); ++i) this->data()[i] = val;
1515 template<
typename ValueType_,
typename Codec_>
1519 if (mIsUniform)
return true;
1522 const ValueType_ val = this->get(0);
1523 for (
Index i = 1; i < this->dataSize(); i++) {
1527 this->collapse(this->get(0));
1532 template<
typename ValueType_,
typename Codec_>
1536 this->collapse(zeroVal<ValueType>());
1540 template<
typename ValueType_,
typename Codec_>
1545 tbb::spin_mutex::scoped_lock lock(mMutex);
1550 Codec::encode(uniformValue, this->data()[0]);
1554 template<
typename ValueType_,
typename Codec_>
1562 template<
typename ValueType_,
typename Codec_>
1566 if (this->isOutOfCore()) {
1567 tbb::spin_mutex::scoped_lock lock(mMutex);
1572 const Index size = mIsUniform ? 1 : this->dataSize();
1573 for (
Index i = 0; i < size; ++i) {
1574 Codec::encode(
value, this->data()[i]);
1579 template<
typename ValueType_,
typename Codec_>
1587 template<
typename ValueType_,
typename Codec_>
1595 template<
typename ValueType_,
typename Codec_>
1603 template<
typename ValueType_,
typename Codec_>
1611 template<
typename ValueType_,
typename Codec_>
1619 template<
typename ValueType_,
typename Codec_>
1627 template<
typename ValueType_,
typename Codec_>
1629 TypedAttributeArray<ValueType_, Codec_>::doLoad()
const
1631 if (!(this->isOutOfCore()))
return;
1633 TypedAttributeArray<ValueType_, Codec_>*
self =
1634 const_cast<TypedAttributeArray<ValueType_, Codec_>*
>(
this);
1638 tbb::spin_mutex::scoped_lock lock(self->mMutex);
1639 this->doLoadUnsafe();
1643 template<
typename ValueType_,
typename Codec_>
1651 template<
typename ValueType_,
typename Codec_>
1655 return !this->isOutOfCore();
1659 template<
typename ValueType_,
typename Codec_>
1663 this->readMetadata(is);
1664 this->readBuffers(is);
1668 template<
typename ValueType_,
typename Codec_>
1675 is.read(
reinterpret_cast<char*
>(&bytes),
sizeof(
Index64));
1676 bytes = bytes -
sizeof(
Int16) -
sizeof(
Index);
1678 uint8_t flags = uint8_t(0);
1679 is.read(
reinterpret_cast<char*
>(&flags),
sizeof(uint8_t));
1682 uint8_t serializationFlags = uint8_t(0);
1683 is.read(
reinterpret_cast<char*
>(&serializationFlags),
sizeof(uint8_t));
1686 is.read(
reinterpret_cast<char*
>(&size),
sizeof(
Index));
1690 if (mFlags >= 0x20) {
1695 if (serializationFlags >= 0x10) {
1701 mIsUniform = serializationFlags & WRITEUNIFORM;
1702 mUsePagedRead = serializationFlags & WRITEPAGED;
1703 mCompressedBytes = bytes;
1704 mFlags |= PARTIALREAD;
1708 if (serializationFlags & WRITESTRIDED) {
1710 is.read(
reinterpret_cast<char*
>(&stride),
sizeof(
Index));
1711 mStrideOrTotalSize = stride;
1714 mStrideOrTotalSize = 1;
1719 template<
typename ValueType_,
typename Codec_>
1723 if (mUsePagedRead) {
1728 tbb::spin_mutex::scoped_lock lock(mMutex);
1732 uint8_t bloscCompressed(0);
1733 if (!mIsUniform) is.read(
reinterpret_cast<char*
>(&bloscCompressed),
sizeof(uint8_t));
1735 assert(mFlags & PARTIALREAD);
1736 std::unique_ptr<char[]> buffer(
new char[mCompressedBytes]);
1737 is.read(buffer.get(), mCompressedBytes);
1738 mCompressedBytes = 0;
1739 mFlags =
static_cast<uint8_t
>(mFlags & ~PARTIALREAD);
1743 if (bloscCompressed == uint8_t(1)) {
1747 const size_t inBytes = this->dataSize() *
sizeof(
StorageType);
1749 if (newBuffer) buffer.reset(newBuffer.release());
1754 mData.reset(
reinterpret_cast<StorageType*
>(buffer.release()));
1758 template<
typename ValueType_,
typename Codec_>
1762 if (!mUsePagedRead) {
1770 const bool delayLoad = (mappedFile.get() !=
nullptr);
1774 size_t compressedBytes(mCompressedBytes);
1775 mCompressedBytes = 0;
1776 mFlags =
static_cast<uint8_t
>(mFlags & ~PARTIALREAD);
1777 assert(!mPageHandle);
1782 assert(mPageHandle);
1784 tbb::spin_mutex::scoped_lock lock(mMutex);
1788 this->setOutOfCore(delayLoad);
1789 is.
read(mPageHandle, std::streamsize(mPageHandle->size()), delayLoad);
1792 std::unique_ptr<char[]> buffer = mPageHandle->read();
1793 mData.reset(
reinterpret_cast<StorageType*
>(buffer.release()));
1794 mPageHandle.reset();
1803 template<
typename ValueType_,
typename Codec_>
1807 this->
write(os,
false);
1811 template<
typename ValueType_,
typename Codec_>
1815 this->writeMetadata(os, outputTransient,
false);
1816 this->writeBuffers(os, outputTransient);
1820 template<
typename ValueType_,
typename Codec_>
1824 if (!outputTransient && this->isTransient())
return;
1826 if (mFlags & PARTIALREAD) {
1830 uint8_t flags(mFlags);
1831 uint8_t serializationFlags(0);
1833 Index stride(mStrideOrTotalSize);
1834 bool strideOfOne(this->stride() == 1);
1839 if (bloscCompression) this->doLoad();
1841 size_t compressedBytes = 0;
1845 serializationFlags |= WRITESTRIDED;
1850 serializationFlags |= WRITEUNIFORM;
1851 if (bloscCompression && paged) serializationFlags |= WRITEPAGED;
1853 else if (bloscCompression)
1855 if (paged) serializationFlags |= WRITEPAGED;
1857 const char* charBuffer =
reinterpret_cast<const char*
>(this->data());
1858 const size_t inBytes = this->arrayMemUsage();
1865 bytes += (compressedBytes > 0) ? compressedBytes : this->arrayMemUsage();
1869 os.write(
reinterpret_cast<const char*
>(&bytes),
sizeof(
Index64));
1870 os.write(
reinterpret_cast<const char*
>(&flags),
sizeof(uint8_t));
1871 os.write(
reinterpret_cast<const char*
>(&serializationFlags),
sizeof(uint8_t));
1872 os.write(
reinterpret_cast<const char*
>(&size),
sizeof(
Index));
1875 if (!strideOfOne) os.write(
reinterpret_cast<const char*
>(&stride),
sizeof(
Index));
1879 template<
typename ValueType_,
typename Codec_>
1883 if (!outputTransient && this->isTransient())
return;
1885 if (mFlags & PARTIALREAD) {
1891 if (this->isUniform()) {
1892 os.write(
reinterpret_cast<const char*
>(this->data()),
sizeof(
StorageType));
1896 std::unique_ptr<char[]> compressedBuffer;
1897 size_t compressedBytes = 0;
1898 const char* charBuffer =
reinterpret_cast<const char*
>(this->data());
1899 const size_t inBytes = this->arrayMemUsage();
1901 if (compressedBuffer) {
1902 uint8_t bloscCompressed(1);
1903 os.write(
reinterpret_cast<const char*
>(&bloscCompressed),
sizeof(uint8_t));
1904 os.write(
reinterpret_cast<const char*
>(compressedBuffer.get()), compressedBytes);
1907 uint8_t bloscCompressed(0);
1908 os.write(
reinterpret_cast<const char*
>(&bloscCompressed),
sizeof(uint8_t));
1909 os.write(
reinterpret_cast<const char*
>(this->data()), inBytes);
1914 uint8_t bloscCompressed(0);
1915 os.write(
reinterpret_cast<const char*
>(&bloscCompressed),
sizeof(uint8_t));
1916 os.write(
reinterpret_cast<const char*
>(this->data()), this->arrayMemUsage());
1921 template<
typename ValueType_,
typename Codec_>
1925 if (!outputTransient && this->isTransient())
return;
1929 if (!bloscCompression) {
1934 if (mFlags & PARTIALREAD) {
1940 os.
write(
reinterpret_cast<const char*
>(this->data()), this->arrayMemUsage());
1944 template<
typename ValueType_,
typename Codec_>
1948 if (!(this->isOutOfCore()))
return;
1954 assert(self->mPageHandle);
1955 assert(!(self->mFlags & PARTIALREAD));
1957 std::unique_ptr<char[]> buffer =
self->mPageHandle->read();
1959 self->mData.reset(
reinterpret_cast<StorageType*
>(buffer.release()));
1961 self->mPageHandle.reset();
1965 self->mOutOfCore =
false;
1969 template<
typename ValueType_,
typename Codec_>
1984 template<
typename ValueType_,
typename Codec_>
1989 if(!otherT)
return false;
1990 if(this->mSize != otherT->mSize ||
1991 this->mStrideOrTotalSize != otherT->mStrideOrTotalSize ||
1993 this->attributeType() != this->attributeType())
return false;
1998 const StorageType *target = this->data(), *source = otherT->
data();
1999 if (!target && !source)
return true;
2000 if (!target || !source)
return false;
2001 Index n = this->mIsUniform ? 1 : mSize;
2007 template<
typename ValueType_,
typename Codec_>
2009 TypedAttributeArray<ValueType_, Codec_>::dataAsByteArray()
2011 return reinterpret_cast<char*
>(this->data());
2015 template<
typename ValueType_,
typename Codec_>
2017 TypedAttributeArray<ValueType_, Codec_>::dataAsByteArray()
const
2019 return reinterpret_cast<const char*
>(this->data());
2027 template <
typename CodecType,
typename ValueType>
2048 template <
typename ValueType>
2056 return (*functor)(array, n);
2061 (*functor)(array, n,
value);
2070 template <
typename ValueType,
typename CodecType>
2078 template <
typename ValueType,
typename CodecType>
2081 , mStrideOrTotalSize(array.hasConstantStride() ? array.stride() : 1)
2082 , mSize(array.hasConstantStride() ? array.size() : array.dataSize())
2083 , mCollapseOnDestruction(collapseOnDestruction && array.isStreaming())
2106 template <
typename ValueType,
typename CodecType>
2110 if (mCollapseOnDestruction)
const_cast<AttributeArray*
>(this->mArray)->collapse();
2113 template <
typename ValueType,
typename CodecType>
2114 template <
bool IsUnknownCodec>
2115 typename std::enable_if<IsUnknownCodec, bool>::type
2120 return mArray->hasValueType<ValueType>();
2123 template <
typename ValueType,
typename CodecType>
2124 template <
bool IsUnknownCodec>
2125 typename std::enable_if<!IsUnknownCodec, bool>::type
2126 AttributeHandle<ValueType, CodecType>::compatibleType()
const
2130 return mArray->isType<TypedAttributeArray<ValueType, CodecType>>();
2133 template <
typename ValueType,
typename CodecType>
2140 template <
typename ValueType,
typename CodecType>
2143 Index index = n * mStrideOrTotalSize + m;
2144 assert(index < (mSize * mStrideOrTotalSize));
2148 template <
typename ValueType,
typename CodecType>
2154 template <
typename ValueType,
typename CodecType>
2155 template <
bool IsUnknownCodec>
2156 typename std::enable_if<IsUnknownCodec, ValueType>::type
2161 return (*mGetter)(mArray, index);
2164 template <
typename ValueType,
typename CodecType>
2165 template <
bool IsUnknownCodec>
2166 typename std::enable_if<!IsUnknownCodec, ValueType>::type
2174 template <
typename ValueType,
typename CodecType>
2177 return mArray->isUniform();
2180 template <
typename ValueType,
typename CodecType>
2183 return mArray->hasConstantStride();
2190 template <
typename ValueType,
typename CodecType>
2198 template <
typename ValueType,
typename CodecType>
2205 template <
typename ValueType,
typename CodecType>
2211 template <
typename ValueType,
typename CodecType>
2217 template <
typename ValueType,
typename CodecType>
2223 template <
typename ValueType,
typename CodecType>
2229 template <
typename ValueType,
typename CodecType>
2235 template <
typename ValueType,
typename CodecType>
2238 this->mCollapser(
const_cast<AttributeArray*
>(this->mArray), uniformValue);
2241 template <
typename ValueType,
typename CodecType>
2247 template <
typename ValueType,
typename CodecType>
2248 template <
bool IsUnknownCodec>
2249 typename std::enable_if<IsUnknownCodec, void>::type
2257 template <
typename ValueType,
typename CodecType>
2258 template <
bool IsUnknownCodec>
2259 typename std::enable_if<!IsUnknownCodec, void>::type
2267 template <
typename ValueType,
typename CodecType>
2270 assert(this->mArray);
ValueT value
Definition: GridBuilder.h:1287
Convenience wrappers to using Blosc and reading and writing of Paged data.
Definition: Exceptions.h:57
Definition: Exceptions.h:58
Definition: Exceptions.h:64
Definition: Exceptions.h:65
std::unique_ptr< PageHandle > Ptr
Definition: StreamCompression.h:170
A Paging wrapper to std::istream that is responsible for reading from a given input stream and creati...
Definition: StreamCompression.h:205
PageHandle::Ptr createHandle(std::streamsize n)
Creates a PageHandle to access the next.
bool sizeOnly() const
Definition: StreamCompression.h:215
void read(PageHandle::Ptr &pageHandle, std::streamsize n, bool delayed=true)
Takes a pageHandle and updates the referenced page with the current stream pointer position and if de...
std::istream & getInputStream()
Definition: StreamCompression.h:218
A Paging wrapper to std::ostream that is responsible for writing from a given output stream at interv...
Definition: StreamCompression.h:242
PagedOutputStream & write(const char *str, std::streamsize n)
Writes the given.
std::ostream & getOutputStream()
Set and get the output stream.
Definition: StreamCompression.h:255
bool sizeOnly() const
Definition: StreamCompression.h:252
SharedPtr< MappedFile > Ptr
Definition: io.h:136
T & y()
Definition: Vec3.h:90
T & z()
Definition: Vec3.h:91
T & x()
Reference to the component, e.g. v.x() = 4.5f;.
Definition: Vec3.h:89
Definition: AttributeArray.h:119
Base class for storing attribute data.
Definition: AttributeArray.h:93
virtual Name valueType() const =0
Return the name of the value type of a single element in this array (e.g., "float" or "vec3d").
AttributeArray(const AttributeArray &rhs, const tbb::spin_mutex::scoped_lock &)
void setConstantStride(bool state)
Specify whether this attribute has a constant stride or not.
static Ptr create(const NamePair &type, Index length, Index stride=1, bool constantStride=true, const Metadata *metadata=nullptr, const ScopedRegistryLock *lock=nullptr)
bool isTransient() const
Return true if this attribute is not serialized during stream output.
Definition: AttributeArray.h:292
SerializationFlag
Definition: AttributeArray.h:109
virtual Index dataSize() const =0
virtual bool isUniform() const =0
Return true if this array is stored as a single uniform value.
virtual void readBuffers(std::istream &)=0
Read attribute buffers from a stream.
std::shared_ptr< AttributeArray > Ptr
Definition: AttributeArray.h:125
virtual void set(const Index n, const AttributeArray &sourceArray, const Index sourceIndex)=0
Set value at given index n from sourceIndex of another sourceArray.
const char * constDataAsByteArray() const
Indirect virtual function to retrieve the data buffer cast to a char byte array.
Definition: AttributeArray.h:349
virtual ~AttributeArray()
Definition: AttributeArray.h:133
compression::PageHandle::Ptr mPageHandle
Definition: AttributeArray.h:393
AttributeArray & operator=(const AttributeArray &rhs)
Flag
Definition: AttributeArray.h:101
AttributeArray()
Definition: AttributeArray.h:132
virtual Index stride() const =0
bool isHidden() const
Return true if this attribute is hidden (e.g., from UI or iterators).
Definition: AttributeArray.h:285
bool isType() const
Return true if this attribute is of the same type as the template parameter.
Definition: AttributeArray.h:214
virtual const NamePair & type() const =0
Return the name of this attribute's type.
virtual bool valueTypeIsQuaternion() const =0
Return true if the value type is a quaternion.
virtual bool valueTypeIsVector() const =0
Return true if the value type is a vector.
virtual bool compress()=0
uint8_t mFlags
Definition: AttributeArray.h:388
virtual AccessorBasePtr getAccessor() const =0
Obtain an Accessor that stores getter and setter functors.
void setStreaming(bool state)
Specify whether this attribute is to be streamed off disk, in which case, the attributes are collapse...
AttributeArray(const AttributeArray &rhs)
virtual bool isDataLoaded() const =0
Return true if all data has been loaded.
uint8_t flags() const
Retrieve the attribute array flags.
Definition: AttributeArray.h:306
AttributeArray & operator=(AttributeArray &&)=delete
bool hasValueType() const
Return true if this attribute has a value type the same as the template parameter.
Definition: AttributeArray.h:218
std::atomic< Index32 > mOutOfCore
Definition: AttributeArray.h:390
virtual void writeBuffers(std::ostream &, bool outputTransient) const =0
static void clearRegistry(const ScopedRegistryLock *lock=nullptr)
Clear the attribute type registry.
std::shared_ptr< AccessorBase > AccessorBasePtr
Definition: AttributeArray.h:98
virtual Index size() const =0
void setTransient(bool state)
Specify whether this attribute should only exist in memory and not be serialized during stream output...
virtual bool decompress()=0
virtual void read(std::istream &)=0
Read attribute metadata and buffers from a stream.
void setHidden(bool state)
Specify whether this attribute should be hidden (e.g., from UI or iterators).
virtual void write(std::ostream &, bool outputTransient) const =0
virtual bool compact()=0
Compact the existing array to become uniform if all values are identical.
virtual AttributeArray::Ptr copyUncompressed() const =0
Return a copy of this attribute.
virtual void readPagedBuffers(compression::PagedInputStream &)=0
Read attribute buffers from a paged stream.
virtual bool valueTypeIsClass() const =0
Return true if the value type is a class (ie vector, matrix or quaternion return true)
virtual void loadData() const =0
Ensures all data is in-core.
uint8_t mUsePagedRead
Definition: AttributeArray.h:389
virtual bool valueTypeIsMatrix() const =0
Return true if the value type is a matrix.
bool operator==(const AttributeArray &other) const
tbb::spin_mutex mMutex
Definition: AttributeArray.h:387
bool operator!=(const AttributeArray &other) const
Definition: AttributeArray.h:345
bool isStreaming() const
Return true if this attribute is in streaming mode.
Definition: AttributeArray.h:300
virtual void writeMetadata(std::ostream &, bool outputTransient, bool paged) const =0
static bool isRegistered(const NamePair &type, const ScopedRegistryLock *lock=nullptr)
Return true if the given attribute type name is registered.
Ptr(*)(Index, Index, bool, const Metadata *) FactoryMethod
Definition: AttributeArray.h:128
virtual Name codecType() const =0
Return the name of the codec used by this array (e.g., "trnc" or "fxpt").
virtual void readMetadata(std::istream &)=0
Read attribute metadata from a stream.
std::shared_ptr< const AttributeArray > ConstPtr
Definition: AttributeArray.h:126
virtual void collapse()=0
Replace the existing array with a uniform zero value.
virtual void writePagedBuffers(compression::PagedOutputStream &, bool outputTransient) const =0
virtual Index storageTypeSize() const =0
virtual void write(std::ostream &) const =0
Write attribute metadata and buffers to a stream, don't write transient attributes.
static void registerType(const NamePair &type, FactoryMethod, const ScopedRegistryLock *lock=nullptr)
Register a attribute type along with a factory function.
virtual AttributeArray::Ptr copy() const =0
Return a copy of this attribute.
virtual Index valueTypeSize() const =0
virtual bool valueTypeIsFloatingPoint() const =0
Return true if the value type is floating point.
static void unregisterType(const NamePair &type, const ScopedRegistryLock *lock=nullptr)
Remove a attribute type from the registry.
bool hasConstantStride() const
Return true if this attribute has a constant stride.
Definition: AttributeArray.h:303
size_t mCompressedBytes
Definition: AttributeArray.h:394
bool mIsUniform
Definition: AttributeArray.h:386
virtual void expand(bool fill=true)=0
If this array is uniform, replace it with an array of length size().
virtual size_t memUsage() const =0
Return the number of bytes of memory used by this attribute.
AttributeArray(AttributeArray &&)=delete
Definition: AttributeArray.h:811
virtual ~AttributeHandle()
Definition: AttributeArray.h:2107
Index size() const
Definition: AttributeArray.h:833
void(*)(AttributeArray *array, const ValueType &value) ValuePtr
Definition: AttributeArray.h:820
SetterPtr mSetter
Definition: AttributeArray.h:848
Index stride() const
Definition: AttributeArray.h:832
std::shared_ptr< Handle > Ptr
Definition: AttributeArray.h:814
GetterPtr mGetter
Definition: AttributeArray.h:847
void(*)(AttributeArray *array, const Index n, const ValueType &value) SetterPtr
Definition: AttributeArray.h:819
static Ptr create(const AttributeArray &array, const bool collapseOnDestruction=true)
Definition: AttributeArray.h:2072
AttributeHandle(const AttributeArray &array, const bool collapseOnDestruction=true)
Definition: AttributeArray.h:2079
AttributeHandle & operator=(const AttributeHandle &)=default
ValuePtr mFiller
Definition: AttributeArray.h:850
ValueType get(Index n, Index m=0) const
Definition: AttributeArray.h:2149
ValueType(*)(const AttributeArray *array, const Index n) GetterPtr
Definition: AttributeArray.h:818
AttributeHandle(const AttributeHandle &)=default
ValuePtr mCollapser
Definition: AttributeArray.h:849
const AttributeArray & array() const
Definition: AttributeArray.h:2134
const AttributeArray * mArray
Definition: AttributeArray.h:845
bool isUniform() const
Definition: AttributeArray.h:2175
std::unique_ptr< Handle > UniquePtr
Definition: AttributeArray.h:815
bool hasConstantStride() const
Definition: AttributeArray.h:2181
Index index(Index n, Index m) const
Definition: AttributeArray.h:2141
Write-able version of AttributeHandle.
Definition: AttributeArray.h:882
virtual ~AttributeWriteHandle()=default
AttributeWriteHandle(AttributeArray &array, const bool expand=true)
Definition: AttributeArray.h:2199
std::shared_ptr< Handle > Ptr
Definition: AttributeArray.h:885
bool compact()
Compact the existing array to become uniform if all values are identical.
Definition: AttributeArray.h:2230
void collapse()
Replace the existing array with a uniform value (zero if none provided).
Definition: AttributeArray.h:2224
void set(Index n, const ValueType &value)
Definition: AttributeArray.h:2206
void expand(bool fill=true)
If this array is uniform, replace it with an array of length size().
Definition: AttributeArray.h:2218
AttributeArray & array()
Definition: AttributeArray.h:2268
std::unique_ptr< Handle > ScopedPtr
Definition: AttributeArray.h:886
static Ptr create(AttributeArray &array, const bool expand=true)
Definition: AttributeArray.h:2192
void set(Index n, Index m, const ValueType &value)
Definition: AttributeArray.h:2212
void fill(const ValueType &value)
Fill the existing array with the given value.
Definition: AttributeArray.h:2242
void collapse(const ValueType &uniformValue)
Definition: AttributeArray.h:2236
Typed class for storing attribute data.
Definition: AttributeArray.h:533
Index valueTypeSize() const override
Return the size in bytes of the value type of a single element in this array.
Definition: AttributeArray.h:624
ValueType getUnsafe(Index n) const
Return the value at index n (assumes in-core)
Definition: AttributeArray.h:1381
void readBuffers(std::istream &) override
Read attribute buffers from a stream.
Definition: AttributeArray.h:1721
std::shared_ptr< TypedAttributeArray > Ptr
Definition: AttributeArray.h:535
AccessorBasePtr getAccessor() const override
Obtain an Accessor that stores getter and setter functors.
Definition: AttributeArray.h:1971
void write(std::ostream &os, bool outputTransient) const override
Definition: AttributeArray.h:1813
typename Codec::template Storage< ValueType >::Type StorageType
Definition: AttributeArray.h:540
const StorageType * constData() const
Return the raw data buffer.
Definition: AttributeArray.h:749
size_t memUsage() const override
Return the number of bytes of memory used by this attribute.
Definition: AttributeArray.h:1373
const StorageType * data() const
Definition: AttributeArray.h:757
ValueType_ ValueType
Definition: AttributeArray.h:538
TypedAttributeArray(Index n=1, Index strideOrTotalSize=1, bool constantStride=true, const ValueType &uniformValue=zeroVal< ValueType >())
Default constructor, always constructs a uniform attribute.
Definition: AttributeArray.h:1108
bool isDataLoaded() const override
Return true if all data has been loaded.
Definition: AttributeArray.h:1653
bool isOutOfCore() const
Return true if this buffer's values have not yet been read from disk.
Definition: AttributeArray.h:1613
bool valueTypeIsVector() const override
Return true if the value type is a vector.
Definition: AttributeArray.h:1347
bool validData() const
Verify that data is not out-of-core or in a partially-read state.
Definition: AttributeArray.h:760
bool compact() override
Compact the existing array to become uniform if all values are identical.
Definition: AttributeArray.h:1517
static TypedAttributeArray & cast(AttributeArray &attributeArray)
Cast an AttributeArray to TypedAttributeArray<T>
Definition: AttributeArray.h:1240
void writeBuffers(std::ostream &os, bool outputTransient) const override
Definition: AttributeArray.h:1881
AttributeArray::Ptr copy() const override
Definition: AttributeArray.h:1260
Index storageTypeSize() const override
Definition: AttributeArray.h:628
bool valueTypeIsQuaternion() const override
Return true if the value type is a quaternion.
Definition: AttributeArray.h:1355
void readPagedBuffers(compression::PagedInputStream &) override
Read attribute buffers from a paged stream.
Definition: AttributeArray.h:1760
void set(Index n, const ValueType &value)
Set value at the given index n.
Definition: AttributeArray.h:1445
TypedAttributeArray & operator=(const TypedAttributeArray &)
Definition: AttributeArray.h:1164
static void registerType()
Register this attribute type along with a factory function.
Definition: AttributeArray.h:1212
bool valueTypeIsFloatingPoint() const override
Return true if the value type is floating point.
Definition: AttributeArray.h:1318
void writeMetadata(std::ostream &os, bool outputTransient, bool paged) const override
Definition: AttributeArray.h:1822
static void unregisterType()
Remove this attribute type from the registry.
Definition: AttributeArray.h:1220
void loadData() const override
Ensures all data is in-core.
Definition: AttributeArray.h:1645
void read(std::istream &) override
Read attribute data from a stream.
Definition: AttributeArray.h:1661
ValueType get(Index n) const
Return the value at index n.
Definition: AttributeArray.h:1393
TypedAttributeArray(TypedAttributeArray &&)=delete
Move constructor disabled.
static const NamePair & attributeType()
Return the name of this attribute's type (includes codec)
Definition: AttributeArray.h:1191
bool valueTypeIsClass() const override
Return true if the value type is a class (ie vector, matrix or quaternion return true)
Definition: AttributeArray.h:1338
Index size() const override
Return the number of elements in this array.
Definition: AttributeArray.h:606
void collapse() override
Replace the existing array with a uniform zero value.
Definition: AttributeArray.h:1534
Index dataSize() const override
Return the size of the data in this array.
Definition: AttributeArray.h:613
Codec_ Codec
Definition: AttributeArray.h:539
~TypedAttributeArray() override
Definition: AttributeArray.h:572
void expand(bool fill=true) override
Replace the single value storage with an array of length size().
Definition: AttributeArray.h:1496
AttributeArray::Ptr copyUncompressed() const override
Definition: AttributeArray.h:1271
static bool isRegistered()
Return true if this attribute type is registered.
Definition: AttributeArray.h:1204
TypedAttributeArray & operator=(TypedAttributeArray &&)=delete
Move assignment operator disabled.
bool valueTypeIsMatrix() const override
Return true if the value type is a matrix.
Definition: AttributeArray.h:1364
void fill(const ValueType &value)
Fill the existing array with the given value.
Definition: AttributeArray.h:1564
Index stride() const override
Definition: AttributeArray.h:610
StorageType * data()
Return the raw data buffer.
Definition: AttributeArray.h:756
static Ptr create(Index n, Index strideOrTotalSize=1, bool constantStride=true, const Metadata *metadata=nullptr)
Return a new attribute array of the given length n and stride with uniform value zero.
Definition: AttributeArray.h:1228
Name codecType() const override
Return the name of the codec used by this array (e.g., "trnc" or "fxpt").
Definition: AttributeArray.h:621
bool decompress() override
Uncompress the attribute array.
Definition: AttributeArray.h:1605
bool compress() override
Compress the attribute array.
Definition: AttributeArray.h:1589
void writePagedBuffers(compression::PagedOutputStream &os, bool outputTransient) const override
Definition: AttributeArray.h:1923
Name valueType() const override
Return the name of the value type of a single element in this array (e.g., "float" or "vec3d").
Definition: AttributeArray.h:618
void setUnsafe(Index n, const ValueType &value)
Set value at the given index n (assumes in-core)
Definition: AttributeArray.h:1430
void readMetadata(std::istream &) override
Read attribute metadata from a stream.
Definition: AttributeArray.h:1670
#define OPENVDB_LOG_WARN(message)
Log a warning message of the form 'someVar << "some text" << ...'.
Definition: logging.h:256
static void read(std::istream &is, GridHandle< BufferT > &handle, Codec codec)
static fileSize_t write(std::ostream &os, const GridHandle< BufferT > &handle, Codec codec)
OPENVDB_API size_t bloscCompressedSize(const char *buffer, const size_t uncompressedBytes)
Convenience wrapper to retrieve the compressed size of buffer when compressed.
OPENVDB_API void bloscDecompress(char *uncompressedBuffer, const size_t expectedBytes, const size_t bufferBytes, const char *compressedBuffer)
Decompress into the supplied buffer. Will throw if decompression fails or uncompressed buffer has ins...
OPENVDB_API void bloscCompress(char *compressedBuffer, size_t &compressedBytes, const size_t bufferBytes, const char *uncompressedBuffer, const size_t uncompressedBytes)
Compress into the supplied buffer.
OPENVDB_API SharedPtr< MappedFile > getMappedFilePtr(std::ios_base &)
Return a shared pointer to the memory-mapped file with which the given stream is associated,...
@ COMPRESS_BLOSC
Definition: Compression.h:56
OPENVDB_API uint32_t getDataCompression(std::ios_base &)
Return a bitwise OR of compression option flags (COMPRESS_ZIP, COMPRESS_ACTIVE_MASK,...
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:444
internal::half half
Definition: Types.h:29
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:477
FloatVectorT fixedPointToFloatingPoint(const math::Vec3< IntegerT > &v)
Definition: AttributeArray.h:79
IntegerVectorT floatingPointToFixedPoint(const math::Vec3< FloatT > &v)
Definition: AttributeArray.h:69
std::string Name
Definition: Name.h:17
Index32 Index
Definition: Types.h:54
int16_t Int16
Definition: Types.h:55
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:39
uint64_t Index64
Definition: Types.h:53
Definition: Exceptions.h:13
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:74
static pnanovdb_uint32_t allocate(pnanovdb_uint32_t *poffset, pnanovdb_uint32_t size, pnanovdb_uint32_t alignment)
Definition: pnanovdb_validate_strides.h:20
typename T::ValueType ElementType
Definition: Types.h:208
static ValueType get(GetterPtr functor, const AttributeArray *array, const Index n)
Getter that calls the supplied functor.
Definition: AttributeArray.h:2055
void(*)(AttributeArray *array, const Index n, const ValueType &value) SetterPtr
Definition: AttributeArray.h:2052
static void set(SetterPtr functor, AttributeArray *array, const Index n, const ValueType &value)
Setter that calls the supplied functor.
Definition: AttributeArray.h:2060
ValueType(*)(const AttributeArray *array, const Index n) GetterPtr
Definition: AttributeArray.h:2051
Accessor to call unsafe get and set methods based on templated Codec and Value.
Definition: AttributeArray.h:2029
void(*)(AttributeArray *array, const Index n, const ValueType &value) SetterPtr
Definition: AttributeArray.h:2031
static ValueType get(GetterPtr, const AttributeArray *array, const Index n)
Definition: AttributeArray.h:2035
ValueType(*)(const AttributeArray *array, const Index n) GetterPtr
Definition: AttributeArray.h:2030
static void set(SetterPtr, AttributeArray *array, const Index n, const ValueType &value)
Definition: AttributeArray.h:2041
Accessor base class for AttributeArray storage where type is not available.
Definition: AttributeArray.h:403
virtual ~AccessorBase()=default
Definition: AttributeArray.h:409
SetterPtr mSetter
Definition: AttributeArray.h:418
GetterPtr mGetter
Definition: AttributeArray.h:417
void(*)(AttributeArray *array, const T &value) ValuePtr
Definition: AttributeArray.h:412
T(*)(const AttributeArray *array, const Index n) GetterPtr
Definition: AttributeArray.h:410
void(*)(AttributeArray *array, const Index n, const T &value) SetterPtr
Definition: AttributeArray.h:411
ValuePtr mFiller
Definition: AttributeArray.h:420
Accessor(GetterPtr getter, SetterPtr setter, ValuePtr collapser, ValuePtr filler)
Definition: AttributeArray.h:414
ValuePtr mCollapser
Definition: AttributeArray.h:419
Definition: AttributeArray.h:501
typename attribute_traits::UIntTypeTrait< OneByte, T >::Type Type
Definition: AttributeArray.h:501
Definition: AttributeArray.h:499
static const char * name()
Definition: AttributeArray.h:506
Definition: AttributeArray.h:460
T Type
Definition: AttributeArray.h:460
Definition: AttributeArray.h:458
static const char * name()
Definition: AttributeArray.h:464
Definition: AttributeArray.h:481
static ValueType decode(const ValueType &value)
Definition: AttributeArray.h:484
static ValueType encode(const ValueType &value)
Definition: AttributeArray.h:483
static const char * name()
Definition: AttributeArray.h:482
Definition: AttributeArray.h:471
typename attribute_traits::TruncateTrait< T >::Type Type
Definition: AttributeArray.h:471
Definition: AttributeArray.h:469
static const char * name()
Definition: AttributeArray.h:475
Definition: AttributeArray.h:490
static ValueType decode(const ValueType &value)
Definition: AttributeArray.h:493
static ValueType encode(const ValueType &value)
Definition: AttributeArray.h:492
static const char * name()
Definition: AttributeArray.h:491
Definition: AttributeArray.h:518
StorageType Type
Definition: AttributeArray.h:518
Definition: AttributeArray.h:514
uint16_t StorageType
Definition: AttributeArray.h:515
static const char * name()
Definition: AttributeArray.h:522
Definition: AttributeArray.h:454
short Type
Definition: AttributeArray.h:431
Definition: AttributeArray.h:429
uint16_t Type
Definition: AttributeArray.h:439
uint8_t Type
Definition: AttributeArray.h:438
Definition: AttributeArray.h:437
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202