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>
52 static_assert(std::is_unsigned<IntegerT>::value,
"IntegerT must be unsigned");
59 template <
typename FloatT,
typename IntegerT>
63 static_assert(std::is_unsigned<IntegerT>::value,
"IntegerT must be unsigned");
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;
348 friend class ::TestAttributeArray;
355 virtual char* dataAsByteArray() = 0;
356 virtual const char* dataAsByteArray()
const = 0;
359 template <
typename IterT>
360 void doCopyValues(
const AttributeArray& sourceArray,
const IterT& iter,
361 bool rangeChecking =
true);
364 #if OPENVDB_ABI_VERSION_NUMBER >= 7
381 bool mIsUniform =
true;
384 uint8_t mUsePagedRead = 0;
402 template <
typename T>
410 mGetter(getter), mSetter(setter), mCollapser(collapser), mFiller(filler) { }
422 namespace attribute_traits
454 template <
typename T>
457 template<
typename ValueType>
static void decode(
const ValueType&, ValueType&);
458 template<
typename ValueType>
static void encode(
const ValueType&, ValueType&);
459 static const char*
name() {
return "null"; }
465 template <
typename T>
468 template<
typename StorageType,
typename ValueType>
static void decode(
const StorageType&, ValueType&);
469 template<
typename StorageType,
typename ValueType>
static void encode(
const ValueType&, StorageType&);
470 static const char*
name() {
return "trnc"; }
477 static const char*
name() {
return "fxpt"; }
478 template <
typename ValueType>
static ValueType
encode(
const ValueType& value) {
return value + ValueType(0.5); }
479 template <
typename ValueType>
static ValueType
decode(
const ValueType& value) {
return value - ValueType(0.5); }
486 static const char*
name() {
return "ufxpt"; }
487 template <
typename ValueType>
static ValueType
encode(
const ValueType& value) {
return value; }
488 template <
typename ValueType>
static ValueType
decode(
const ValueType& value) {
return value; }
492 template <
bool OneByte,
typename Range=PositionRange>
495 template <
typename T>
498 template<
typename StorageType,
typename ValueType>
static void decode(
const StorageType&, ValueType&);
499 template<
typename StorageType,
typename ValueType>
static void encode(
const ValueType&, StorageType&);
502 static const std::string
Name = std::string(Range::name()) + (OneByte ?
"8" :
"16");
512 template <
typename T>
517 static const char*
name() {
return "uvec"; }
526 template<
typename ValueType_,
typename Codec_ = NullCodec>
530 using Ptr = std::shared_ptr<TypedAttributeArray>;
531 using ConstPtr = std::shared_ptr<const TypedAttributeArray>;
535 using StorageType =
typename Codec::template Storage<ValueType>::Type;
541 const ValueType& uniformValue = zeroVal<ValueType>());
542 #if OPENVDB_ABI_VERSION_NUMBER >= 7
579 static Ptr create(
Index n,
Index strideOrTotalSize = 1,
bool constantStride = true,
580 const
Metadata* metadata =
nullptr);
589 static const
NamePair& attributeType();
591 const
NamePair& type()
const override {
return attributeType(); }
594 static bool isRegistered();
596 static void registerType();
598 static void unregisterType();
605 Index stride()
const override {
return hasConstantStride() ? mStrideOrTotalSize : 0; }
609 return hasConstantStride() ? mSize * mStrideOrTotalSize : mStrideOrTotalSize;
626 bool valueTypeIsFloatingPoint()
const override;
629 bool valueTypeIsClass()
const override;
632 bool valueTypeIsVector()
const override;
635 bool valueTypeIsQuaternion()
const override;
638 bool valueTypeIsMatrix()
const override;
644 ValueType getUnsafe(
Index n)
const;
646 ValueType get(
Index n)
const;
648 template<
typename T>
void getUnsafe(
Index n, T& value)
const;
650 template<
typename T>
void get(
Index n, T& value)
const;
657 void setUnsafe(
Index n,
const ValueType& value);
659 void set(
Index n,
const ValueType& value);
661 template<
typename T>
void setUnsafe(
Index n,
const T& value);
663 template<
typename T>
void set(
Index n,
const T& value);
674 bool isUniform()
const override {
return mIsUniform; }
678 void expand(
bool fill =
true)
override;
680 void collapse()
override;
682 bool compact()
override;
685 void collapse(
const ValueType& uniformValue);
688 void fill(
const ValueType& value);
691 static void collapse(
AttributeArray* array,
const ValueType& value);
697 bool compress() override;
700 bool decompress() override;
703 void read(
std::istream&) override;
707 void write(
std::ostream& os,
bool outputTransient) const override;
709 void write(
std::ostream&) const override;
712 void readMetadata(
std::istream&) override;
717 void writeMetadata(
std::ostream& os,
bool outputTransient,
bool paged) const override;
720 void readBuffers(
std::istream&) override;
724 void writeBuffers(
std::ostream& os,
bool outputTransient) const override;
727 void readPagedBuffers(compression::PagedInputStream&) override;
731 void writePagedBuffers(compression::PagedOutputStream& os,
bool outputTransient) const override;
734 inline
bool isOutOfCore() const;
737 void loadData() const override;
740 bool isDataLoaded() const override;
743 AccessorBasePtr getAccessor() const override;
746 inline
StorageType* data() { assert(validData());
return mData.get(); }
750 inline bool validData()
const {
return !(isOutOfCore() || (flags() & PARTIALREAD)); }
753 friend class ::TestAttributeArray;
755 #if OPENVDB_ABI_VERSION_NUMBER >= 7
760 inline void doLoad()
const;
763 inline void doLoadUnsafe(
const bool compression =
true)
const;
765 inline bool compressUnsafe();
768 inline void setOutOfCore(
const bool);
774 char* dataAsByteArray()
override;
775 const char* dataAsByteArray()
const override;
777 size_t arrayMemUsage()
const;
784 return TypedAttributeArray::create(n, strideOrTotalSize, constantStride, metadata);
787 static std::unique_ptr<const NamePair> sTypeName;
788 std::unique_ptr<StorageType[]> mData;
790 Index mStrideOrTotalSize;
799 template <
typename ValueType,
typename CodecType = UnknownCodec>
804 using Ptr = std::shared_ptr<Handle>;
843 friend class ::TestAttributeArray;
845 template <
bool IsUnknownCodec>
846 typename std::enable_if<IsUnknownCodec, bool>::type compatibleType()
const;
848 template <
bool IsUnknownCodec>
849 typename std::enable_if<!IsUnknownCodec, bool>::type compatibleType()
const;
851 template <
bool IsUnknownCodec>
852 typename std::enable_if<IsUnknownCodec, ValueType>::type get(
Index index)
const;
854 template <
bool IsUnknownCodec>
855 typename std::enable_if<!IsUnknownCodec, ValueType>::type get(
Index index)
const;
860 Index mStrideOrTotalSize;
862 bool mCollapseOnDestruction;
870 template <
typename ValueType,
typename CodecType = UnknownCodec>
875 using Ptr = std::shared_ptr<Handle>;
897 void fill(
const ValueType& value);
905 friend class ::TestAttributeArray;
907 template <
bool IsUnknownCodec>
908 typename std::enable_if<IsUnknownCodec, void>::type set(
Index index,
const ValueType& value)
const;
910 template <
bool IsUnknownCodec>
911 typename std::enable_if<!IsUnknownCodec, void>::type set(
Index index,
const ValueType& value)
const;
921 template<
typename ValueType>
923 NullCodec::decode(
const ValueType& data, ValueType& val)
929 template<
typename ValueType>
931 NullCodec::encode(
const ValueType& val, ValueType& data)
937 template<
typename StorageType,
typename ValueType>
939 TruncateCodec::decode(
const StorageType& data, ValueType& val)
941 val =
static_cast<ValueType
>(data);
945 template<
typename StorageType,
typename ValueType>
947 TruncateCodec::encode(
const ValueType& val, StorageType& data)
949 data =
static_cast<StorageType
>(val);
953 template <
bool OneByte,
typename Range>
954 template<
typename StorageType,
typename ValueType>
958 val = fixedPointToFloatingPoint<ValueType>(data);
962 val = Range::template decode<ValueType>(val);
966 template <
bool OneByte,
typename Range>
967 template<
typename StorageType,
typename ValueType>
973 const ValueType newVal = Range::template encode<ValueType>(val);
975 data = floatingPointToFixedPoint<StorageType>(newVal);
983 val = math::QuantizedUnitVec::unpack(data);
991 data = math::QuantizedUnitVec::pack(val);
999 template <
typename IterT>
1000 void AttributeArray::doCopyValues(
const AttributeArray& sourceArray,
const IterT& iter,
1006 assert(sourceArray.
isDataLoaded() && this->isDataLoaded());
1008 assert(this->storageTypeSize()*this->stride() ==
1012 const char*
const sourceBuffer = sourceArray.dataAsByteArray();
1013 char*
const targetBuffer = this->dataAsByteArray();
1014 assert(sourceBuffer && targetBuffer);
1016 if (rangeChecking && this->isUniform()) {
1020 const bool sourceIsUniform = sourceArray.
isUniform();
1022 const Index sourceDataSize = rangeChecking ? sourceArray.
dataSize() : 0;
1023 const Index targetDataSize = rangeChecking ? this->dataSize() : 0;
1025 for (IterT it(iter); it; ++it) {
1026 const Index sourceIndex = sourceIsUniform ? 0 : it.sourceIndex();
1027 const Index targetIndex = it.targetIndex();
1029 if (rangeChecking) {
1030 if (sourceIndex >= sourceDataSize) {
1032 "Cannot copy array data as source index exceeds size of source array.");
1034 if (targetIndex >= targetDataSize) {
1036 "Cannot copy array data as target index exceeds size of target array.");
1040 assert(sourceIndex < sourceArray.
dataSize());
1041 assert(targetIndex < this->dataSize());
1042 if (this->isUniform()) assert(targetIndex ==
Index(0));
1045 const size_t targetOffset(targetIndex * bytes);
1046 const size_t sourceOffset(sourceIndex * bytes);
1048 std::memcpy(targetBuffer + targetOffset, sourceBuffer + sourceOffset, bytes);
1052 template <
typename IterT>
1053 void AttributeArray::copyValuesUnsafe(
const AttributeArray& sourceArray,
const IterT& iter)
1055 this->doCopyValues(sourceArray, iter,
false);
1058 template <
typename IterT>
1059 void AttributeArray::copyValues(
const AttributeArray& sourceArray,
const IterT& iter,
1063 if (bytes != this->storageTypeSize()) {
1080 this->doCopyValues(sourceArray, iter,
true);
1093 template<
typename ValueType_,
typename Codec_>
1097 template<
typename ValueType_,
typename Codec_>
1103 , mStrideOrTotalSize(strideOrTotalSize)
1105 if (constantStride) {
1107 if (strideOrTotalSize == 0) {
1109 "stride to be at least one.")
1114 if (mStrideOrTotalSize < n) {
1116 "a total size of at least the number of elements in the array.")
1120 mStrideOrTotalSize =
std::max(
Index(1), mStrideOrTotalSize);
1121 Codec::encode(uniformValue, this->
data()[0]);
1125 #if OPENVDB_ABI_VERSION_NUMBER >= 7
1126 template<
typename ValueType_,
typename Codec_>
1133 template<
typename ValueType_,
typename Codec_>
1135 const tbb::spin_mutex::scoped_lock& lock)
1138 template<typename ValueType_, typename Codec_>
1143 , mStrideOrTotalSize(rhs.mStrideOrTotalSize)
1147 std::memcpy(
static_cast<void*
>(this->
data()), rhs.
data(), this->arrayMemUsage());
1152 template<
typename ValueType_,
typename Codec_>
1153 TypedAttributeArray<ValueType_, Codec_>&
1158 tbb::spin_mutex::scoped_lock lock(mMutex);
1159 tbb::spin_mutex::scoped_lock rhsLock(rhs.
mMutex);
1166 mStrideOrTotalSize = rhs.mStrideOrTotalSize;
1169 if (this->validData()) {
1171 std::memcpy(
static_cast<void*
>(this->data()), rhs.
data(), this->arrayMemUsage());
1179 template<
typename ValueType_,
typename Codec_>
1183 static std::once_flag once;
1184 std::call_once(once, []()
1186 sTypeName.reset(
new NamePair(typeNameAsString<ValueType>(), Codec::name()));
1192 template<
typename ValueType_,
typename Codec_>
1200 template<
typename ValueType_,
typename Codec_>
1208 template<
typename ValueType_,
typename Codec_>
1216 template<
typename ValueType_,
typename Codec_>
1225 typedMetadata ? typedMetadata->
value() : zeroVal<ValueType>()));
1228 template<
typename ValueType_,
typename Codec_>
1238 template<
typename ValueType_,
typename Codec_>
1248 template<
typename ValueType_,
typename Codec_>
1252 #if OPENVDB_ABI_VERSION_NUMBER < 7
1253 tbb::spin_mutex::scoped_lock lock(mMutex);
1259 template<
typename ValueType_,
typename Codec_>
1263 return this->copy();
1267 template<
typename ValueType_,
typename Codec_>
1271 if (this->isOutOfCore())
return 0;
1273 return (mIsUniform ? 1 : this->dataSize()) *
sizeof(StorageType);
1277 template<
typename ValueType_,
typename Codec_>
1279 TypedAttributeArray<ValueType_, Codec_>::allocate()
1283 mData.reset(
new StorageType[1]);
1286 const size_t size(this->dataSize());
1288 mData.reset(
new StorageType[size]);
1293 template<
typename ValueType_,
typename Codec_>
1295 TypedAttributeArray<ValueType_, Codec_>::deallocate()
1298 if (this->isOutOfCore()) {
1299 this->setOutOfCore(
false);
1300 this->mPageHandle.reset();
1302 if (mData) mData.reset();
1306 template<
typename ValueType_,
typename Codec_>
1312 if (std::is_same<ValueType, Quats>::value ||
1313 std::is_same<ValueType, Quatd>::value ||
1314 std::is_same<ValueType, Mat3s>::value ||
1315 std::is_same<ValueType, Mat3d>::value ||
1316 std::is_same<ValueType, Mat4s>::value ||
1317 std::is_same<ValueType, Mat4d>::value)
return true;
1322 return std::is_floating_point<ElementT>::value || std::is_same<math::half, ElementT>::value;
1326 template<
typename ValueType_,
typename Codec_>
1331 return std::is_class<ValueType>::value && !std::is_same<math::half, ValueType>::value;
1335 template<
typename ValueType_,
typename Codec_>
1343 template<
typename ValueType_,
typename Codec_>
1348 return !this->valueType().compare(0, 4,
"quat");
1352 template<
typename ValueType_,
typename Codec_>
1357 return !this->valueType().compare(0, 3,
"mat");
1361 template<
typename ValueType_,
typename Codec_>
1365 return sizeof(*this) + (bool(mData) ? this->arrayMemUsage() : 0);
1369 template<
typename ValueType_,
typename Codec_>
1373 assert(n < this->dataSize());
1376 Codec::decode(this->data()[mIsUniform ? 0 : n], val);
1381 template<
typename ValueType_,
typename Codec_>
1386 if (this->isOutOfCore()) this->doLoad();
1388 return this->getUnsafe(n);
1392 template<
typename ValueType_,
typename Codec_>
1393 template<
typename T>
1397 val =
static_cast<T
>(this->getUnsafe(n));
1401 template<
typename ValueType_,
typename Codec_>
1402 template<
typename T>
1406 val =
static_cast<T
>(this->get(n));
1410 template<
typename ValueType_,
typename Codec_>
1418 template<
typename ValueType_,
typename Codec_>
1422 assert(n < this->dataSize());
1423 assert(!this->isOutOfCore());
1424 assert(!this->isUniform());
1429 Codec::encode(val, this->data()[mIsUniform ? 0 : n]);
1433 template<
typename ValueType_,
typename Codec_>
1438 if (this->isOutOfCore()) this->doLoad();
1439 if (this->isUniform()) this->expand();
1441 this->setUnsafe(n, val);
1445 template<
typename ValueType_,
typename Codec_>
1446 template<
typename T>
1450 this->setUnsafe(n,
static_cast<ValueType>(val));
1454 template<
typename ValueType_,
typename Codec_>
1455 template<
typename T>
1459 this->set(n,
static_cast<ValueType>(val));
1463 template<
typename ValueType_,
typename Codec_>
1471 template<
typename ValueType_,
typename Codec_>
1478 sourceTypedArray.
get(sourceIndex, sourceValue);
1480 this->set(n, sourceValue);
1484 template<
typename ValueType_,
typename Codec_>
1488 if (!mIsUniform)
return;
1493 tbb::spin_mutex::scoped_lock lock(mMutex);
1500 for (
Index i = 0; i < this->dataSize(); ++i) this->data()[i] = val;
1505 template<
typename ValueType_,
typename Codec_>
1509 if (mIsUniform)
return true;
1512 const ValueType_ val = this->get(0);
1513 for (
Index i = 1; i < this->dataSize(); i++) {
1517 this->collapse(this->get(0));
1522 template<
typename ValueType_,
typename Codec_>
1526 this->collapse(zeroVal<ValueType>());
1530 template<
typename ValueType_,
typename Codec_>
1535 tbb::spin_mutex::scoped_lock lock(mMutex);
1540 Codec::encode(uniformValue, this->data()[0]);
1544 template<
typename ValueType_,
typename Codec_>
1552 template<
typename ValueType_,
typename Codec_>
1556 if (this->isOutOfCore()) {
1557 tbb::spin_mutex::scoped_lock lock(mMutex);
1562 const Index size = mIsUniform ? 1 : this->dataSize();
1563 for (
Index i = 0; i < size; ++i) {
1564 Codec::encode(value, this->data()[i]);
1569 template<
typename ValueType_,
typename Codec_>
1577 template<
typename ValueType_,
typename Codec_>
1585 template<
typename ValueType_,
typename Codec_>
1593 template<
typename ValueType_,
typename Codec_>
1601 template<
typename ValueType_,
typename Codec_>
1609 template<
typename ValueType_,
typename Codec_>
1617 template<
typename ValueType_,
typename Codec_>
1619 TypedAttributeArray<ValueType_, Codec_>::doLoad()
const
1621 if (!(this->isOutOfCore()))
return;
1623 TypedAttributeArray<ValueType_, Codec_>*
self =
1624 const_cast<TypedAttributeArray<ValueType_, Codec_>*
>(
this);
1628 tbb::spin_mutex::scoped_lock lock(self->mMutex);
1629 this->doLoadUnsafe();
1633 template<
typename ValueType_,
typename Codec_>
1641 template<
typename ValueType_,
typename Codec_>
1645 return !this->isOutOfCore();
1649 template<
typename ValueType_,
typename Codec_>
1653 this->readMetadata(is);
1654 this->readBuffers(is);
1658 template<
typename ValueType_,
typename Codec_>
1665 is.read(
reinterpret_cast<char*
>(&bytes),
sizeof(
Index64));
1666 bytes = bytes -
sizeof(
Int16) -
sizeof(
Index);
1668 uint8_t flags = uint8_t(0);
1669 is.read(
reinterpret_cast<char*
>(&flags),
sizeof(uint8_t));
1672 uint8_t serializationFlags = uint8_t(0);
1673 is.read(
reinterpret_cast<char*
>(&serializationFlags),
sizeof(uint8_t));
1676 is.read(
reinterpret_cast<char*
>(&size),
sizeof(
Index));
1680 if (mFlags >= 0x20) {
1685 if (serializationFlags >= 0x10) {
1691 mIsUniform = serializationFlags & WRITEUNIFORM;
1692 mUsePagedRead = serializationFlags & WRITEPAGED;
1693 mCompressedBytes = bytes;
1694 mFlags |= PARTIALREAD;
1698 if (serializationFlags & WRITESTRIDED) {
1700 is.read(
reinterpret_cast<char*
>(&stride),
sizeof(
Index));
1701 mStrideOrTotalSize = stride;
1704 mStrideOrTotalSize = 1;
1709 template<
typename ValueType_,
typename Codec_>
1713 if (mUsePagedRead) {
1718 tbb::spin_mutex::scoped_lock lock(mMutex);
1722 uint8_t bloscCompressed(0);
1723 if (!mIsUniform) is.read(
reinterpret_cast<char*
>(&bloscCompressed),
sizeof(uint8_t));
1725 assert(mFlags & PARTIALREAD);
1726 std::unique_ptr<char[]> buffer(
new char[mCompressedBytes]);
1727 is.read(buffer.get(), mCompressedBytes);
1728 mCompressedBytes = 0;
1729 mFlags =
static_cast<uint8_t
>(mFlags & ~PARTIALREAD);
1733 if (bloscCompressed == uint8_t(1)) {
1737 const size_t inBytes = this->dataSize() *
sizeof(
StorageType);
1739 if (newBuffer) buffer.reset(newBuffer.release());
1744 mData.reset(
reinterpret_cast<StorageType*
>(buffer.release()));
1748 template<
typename ValueType_,
typename Codec_>
1752 if (!mUsePagedRead) {
1760 const bool delayLoad = (mappedFile.get() !=
nullptr);
1764 size_t compressedBytes(mCompressedBytes);
1765 mCompressedBytes = 0;
1766 mFlags =
static_cast<uint8_t
>(mFlags & ~PARTIALREAD);
1767 assert(!mPageHandle);
1772 assert(mPageHandle);
1774 tbb::spin_mutex::scoped_lock lock(mMutex);
1778 this->setOutOfCore(delayLoad);
1779 is.
read(mPageHandle, std::streamsize(mPageHandle->size()), delayLoad);
1782 std::unique_ptr<char[]> buffer = mPageHandle->read();
1783 mData.reset(
reinterpret_cast<StorageType*
>(buffer.release()));
1784 mPageHandle.reset();
1793 template<
typename ValueType_,
typename Codec_>
1797 this->write(os,
false);
1801 template<
typename ValueType_,
typename Codec_>
1805 this->writeMetadata(os, outputTransient,
false);
1806 this->writeBuffers(os, outputTransient);
1810 template<
typename ValueType_,
typename Codec_>
1814 if (!outputTransient && this->isTransient())
return;
1816 if (mFlags & PARTIALREAD) {
1820 uint8_t flags(mFlags);
1821 uint8_t serializationFlags(0);
1823 Index stride(mStrideOrTotalSize);
1824 bool strideOfOne(this->stride() == 1);
1829 if (bloscCompression) this->doLoad();
1831 size_t compressedBytes = 0;
1835 serializationFlags |= WRITESTRIDED;
1840 serializationFlags |= WRITEUNIFORM;
1841 if (bloscCompression && paged) serializationFlags |= WRITEPAGED;
1843 else if (bloscCompression)
1845 if (paged) serializationFlags |= WRITEPAGED;
1847 const char* charBuffer =
reinterpret_cast<const char*
>(this->data());
1848 const size_t inBytes = this->arrayMemUsage();
1855 bytes += (compressedBytes > 0) ? compressedBytes : this->arrayMemUsage();
1859 os.write(
reinterpret_cast<const char*
>(&bytes),
sizeof(
Index64));
1860 os.write(
reinterpret_cast<const char*
>(&flags),
sizeof(uint8_t));
1861 os.write(
reinterpret_cast<const char*
>(&serializationFlags),
sizeof(uint8_t));
1862 os.write(
reinterpret_cast<const char*
>(&size),
sizeof(
Index));
1865 if (!strideOfOne) os.write(
reinterpret_cast<const char*
>(&stride),
sizeof(
Index));
1869 template<
typename ValueType_,
typename Codec_>
1873 if (!outputTransient && this->isTransient())
return;
1875 if (mFlags & PARTIALREAD) {
1881 if (this->isUniform()) {
1882 os.write(
reinterpret_cast<const char*
>(this->data()),
sizeof(
StorageType));
1886 std::unique_ptr<char[]> compressedBuffer;
1887 size_t compressedBytes = 0;
1888 const char* charBuffer =
reinterpret_cast<const char*
>(this->data());
1889 const size_t inBytes = this->arrayMemUsage();
1891 if (compressedBuffer) {
1892 uint8_t bloscCompressed(1);
1893 os.write(
reinterpret_cast<const char*
>(&bloscCompressed),
sizeof(uint8_t));
1894 os.write(
reinterpret_cast<const char*
>(compressedBuffer.get()), compressedBytes);
1897 uint8_t bloscCompressed(0);
1898 os.write(
reinterpret_cast<const char*
>(&bloscCompressed),
sizeof(uint8_t));
1899 os.write(
reinterpret_cast<const char*
>(this->data()), inBytes);
1904 uint8_t bloscCompressed(0);
1905 os.write(
reinterpret_cast<const char*
>(&bloscCompressed),
sizeof(uint8_t));
1906 os.write(
reinterpret_cast<const char*
>(this->data()), this->arrayMemUsage());
1911 template<
typename ValueType_,
typename Codec_>
1915 if (!outputTransient && this->isTransient())
return;
1919 if (!bloscCompression) {
1924 if (mFlags & PARTIALREAD) {
1930 os.
write(
reinterpret_cast<const char*
>(this->data()), this->arrayMemUsage());
1934 template<
typename ValueType_,
typename Codec_>
1938 if (!(this->isOutOfCore()))
return;
1944 assert(self->mPageHandle);
1945 assert(!(self->mFlags & PARTIALREAD));
1947 std::unique_ptr<char[]> buffer =
self->mPageHandle->read();
1949 self->mData.reset(
reinterpret_cast<StorageType*
>(buffer.release()));
1951 self->mPageHandle.reset();
1955 self->mOutOfCore =
false;
1959 template<
typename ValueType_,
typename Codec_>
1974 template<
typename ValueType_,
typename Codec_>
1979 if(!otherT)
return false;
1980 if(this->mSize != otherT->mSize ||
1981 this->mStrideOrTotalSize != otherT->mStrideOrTotalSize ||
1983 this->attributeType() != this->attributeType())
return false;
1988 const StorageType *target = this->data(), *source = otherT->
data();
1989 if (!target && !source)
return true;
1990 if (!target || !source)
return false;
1991 Index n = this->mIsUniform ? 1 : mSize;
1997 template<
typename ValueType_,
typename Codec_>
1999 TypedAttributeArray<ValueType_, Codec_>::dataAsByteArray()
2001 return reinterpret_cast<char*
>(this->data());
2005 template<
typename ValueType_,
typename Codec_>
2007 TypedAttributeArray<ValueType_, Codec_>::dataAsByteArray()
const
2009 return reinterpret_cast<const char*
>(this->data());
2017 template <
typename CodecType,
typename ValueType>
2038 template <
typename ValueType>
2046 return (*functor)(array, n);
2051 (*functor)(array, n, value);
2060 template <
typename ValueType,
typename CodecType>
2068 template <
typename ValueType,
typename CodecType>
2071 , mStrideOrTotalSize(array.hasConstantStride() ? array.stride() : 1)
2072 , mSize(array.hasConstantStride() ? array.size() : array.dataSize())
2073 , mCollapseOnDestruction(collapseOnDestruction && array.isStreaming())
2075 if (!this->compatibleType<std::is_same<CodecType, UnknownCodec>::value>()) {
2096 template <
typename ValueType,
typename CodecType>
2100 if (mCollapseOnDestruction)
const_cast<AttributeArray*
>(this->mArray)->collapse();
2103 template <
typename ValueType,
typename CodecType>
2104 template <
bool IsUnknownCodec>
2105 typename std::enable_if<IsUnknownCodec, bool>::type
2110 return mArray->hasValueType<ValueType>();
2113 template <
typename ValueType,
typename CodecType>
2114 template <
bool IsUnknownCodec>
2115 typename std::enable_if<!IsUnknownCodec, bool>::type
2116 AttributeHandle<ValueType, CodecType>::compatibleType()
const
2120 return mArray->isType<TypedAttributeArray<ValueType, CodecType>>();
2123 template <
typename ValueType,
typename CodecType>
2130 template <
typename ValueType,
typename CodecType>
2133 Index index = n * mStrideOrTotalSize + m;
2134 assert(index < (mSize * mStrideOrTotalSize));
2138 template <
typename ValueType,
typename CodecType>
2141 return this->get<std::is_same<CodecType, UnknownCodec>::value>(this->index(n, m));
2144 template <
typename ValueType,
typename CodecType>
2145 template <
bool IsUnknownCodec>
2146 typename std::enable_if<IsUnknownCodec, ValueType>::type
2151 return (*mGetter)(mArray, index);
2154 template <
typename ValueType,
typename CodecType>
2155 template <
bool IsUnknownCodec>
2156 typename std::enable_if<!IsUnknownCodec, ValueType>::type
2164 template <
typename ValueType,
typename CodecType>
2167 return mArray->isUniform();
2170 template <
typename ValueType,
typename CodecType>
2173 return mArray->hasConstantStride();
2180 template <
typename ValueType,
typename CodecType>
2188 template <
typename ValueType,
typename CodecType>
2195 template <
typename ValueType,
typename CodecType>
2198 this->set<std::is_same<CodecType, UnknownCodec>::value>(this->index(n, 0), value);
2201 template <
typename ValueType,
typename CodecType>
2204 this->set<std::is_same<CodecType, UnknownCodec>::value>(this->index(n, m), value);
2207 template <
typename ValueType,
typename CodecType>
2213 template <
typename ValueType,
typename CodecType>
2219 template <
typename ValueType,
typename CodecType>
2225 template <
typename ValueType,
typename CodecType>
2228 this->mCollapser(
const_cast<AttributeArray*
>(this->mArray), uniformValue);
2231 template <
typename ValueType,
typename CodecType>
2237 template <
typename ValueType,
typename CodecType>
2238 template <
bool IsUnknownCodec>
2239 typename std::enable_if<IsUnknownCodec, void>::type
2244 (*this->mSetter)(
const_cast<AttributeArray*
>(this->mArray), index, value);
2247 template <
typename ValueType,
typename CodecType>
2248 template <
bool IsUnknownCodec>
2249 typename std::enable_if<!IsUnknownCodec, void>::type
2257 template <
typename ValueType,
typename CodecType>
2260 assert(this->mArray);
Convenience wrappers to using Blosc and reading and writing of Paged data.
Definition: openvdb/Exceptions.h:57
Definition: openvdb/Exceptions.h:58
Definition: openvdb/Exceptions.h:64
Definition: openvdb/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.
virtual ~AttributeArray()
Definition: AttributeArray.h:133
compression::PageHandle::Ptr mPageHandle
Definition: AttributeArray.h:388
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:383
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:385
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:384
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:382
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:389
bool mIsUniform
Definition: AttributeArray.h:381
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:801
virtual ~AttributeHandle()
Definition: AttributeArray.h:2097
Index size() const
Definition: AttributeArray.h:823
void(*)(AttributeArray *array, const ValueType &value) ValuePtr
Definition: AttributeArray.h:810
SetterPtr mSetter
Definition: AttributeArray.h:838
Index stride() const
Definition: AttributeArray.h:822
std::shared_ptr< Handle > Ptr
Definition: AttributeArray.h:804
GetterPtr mGetter
Definition: AttributeArray.h:837
void(*)(AttributeArray *array, const Index n, const ValueType &value) SetterPtr
Definition: AttributeArray.h:809
static Ptr create(const AttributeArray &array, const bool collapseOnDestruction=true)
Definition: AttributeArray.h:2062
AttributeHandle(const AttributeArray &array, const bool collapseOnDestruction=true)
Definition: AttributeArray.h:2069
AttributeHandle & operator=(const AttributeHandle &)=default
ValuePtr mFiller
Definition: AttributeArray.h:840
ValueType get(Index n, Index m=0) const
Definition: AttributeArray.h:2139
ValueType(*)(const AttributeArray *array, const Index n) GetterPtr
Definition: AttributeArray.h:808
AttributeHandle(const AttributeHandle &)=default
ValuePtr mCollapser
Definition: AttributeArray.h:839
const AttributeArray & array() const
Definition: AttributeArray.h:2124
const AttributeArray * mArray
Definition: AttributeArray.h:835
bool isUniform() const
Definition: AttributeArray.h:2165
std::unique_ptr< Handle > UniquePtr
Definition: AttributeArray.h:805
bool hasConstantStride() const
Definition: AttributeArray.h:2171
Index index(Index n, Index m) const
Definition: AttributeArray.h:2131
Write-able version of AttributeHandle.
Definition: AttributeArray.h:872
virtual ~AttributeWriteHandle()=default
AttributeWriteHandle(AttributeArray &array, const bool expand=true)
Definition: AttributeArray.h:2189
std::shared_ptr< Handle > Ptr
Definition: AttributeArray.h:875
bool compact()
Compact the existing array to become uniform if all values are identical.
Definition: AttributeArray.h:2220
void collapse()
Replace the existing array with a uniform value (zero if none provided).
Definition: AttributeArray.h:2214
void set(Index n, const ValueType &value)
Definition: AttributeArray.h:2196
void expand(bool fill=true)
If this array is uniform, replace it with an array of length size().
Definition: AttributeArray.h:2208
AttributeArray & array()
Definition: AttributeArray.h:2258
std::unique_ptr< Handle > ScopedPtr
Definition: AttributeArray.h:876
static Ptr create(AttributeArray &array, const bool expand=true)
Definition: AttributeArray.h:2182
void set(Index n, Index m, const ValueType &value)
Definition: AttributeArray.h:2202
void fill(const ValueType &value)
Fill the existing array with the given value.
Definition: AttributeArray.h:2232
void collapse(const ValueType &uniformValue)
Definition: AttributeArray.h:2226
Typed class for storing attribute data.
Definition: AttributeArray.h:528
Index valueTypeSize() const override
Return the size in bytes of the value type of a single element in this array.
Definition: AttributeArray.h:619
ValueType getUnsafe(Index n) const
Return the value at index n (assumes in-core)
Definition: AttributeArray.h:1371
void readBuffers(std::istream &) override
Read attribute buffers from a stream.
Definition: AttributeArray.h:1711
std::shared_ptr< TypedAttributeArray > Ptr
Definition: AttributeArray.h:530
AccessorBasePtr getAccessor() const override
Obtain an Accessor that stores getter and setter functors.
Definition: AttributeArray.h:1961
void write(std::ostream &os, bool outputTransient) const override
Definition: AttributeArray.h:1803
typename Codec::template Storage< ValueType >::Type StorageType
Definition: AttributeArray.h:535
size_t memUsage() const override
Return the number of bytes of memory used by this attribute.
Definition: AttributeArray.h:1363
const StorageType * data() const
Definition: AttributeArray.h:747
ValueType_ ValueType
Definition: AttributeArray.h:533
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:1098
bool isDataLoaded() const override
Return true if all data has been loaded.
Definition: AttributeArray.h:1643
bool isOutOfCore() const
Return true if this buffer's values have not yet been read from disk.
Definition: AttributeArray.h:1603
bool valueTypeIsVector() const override
Return true if the value type is a vector.
Definition: AttributeArray.h:1337
bool validData() const
Verify that data is not out-of-core or in a partially-read state.
Definition: AttributeArray.h:750
bool compact() override
Compact the existing array to become uniform if all values are identical.
Definition: AttributeArray.h:1507
static TypedAttributeArray & cast(AttributeArray &attributeArray)
Cast an AttributeArray to TypedAttributeArray<T>
Definition: AttributeArray.h:1230
void writeBuffers(std::ostream &os, bool outputTransient) const override
Definition: AttributeArray.h:1871
AttributeArray::Ptr copy() const override
Definition: AttributeArray.h:1250
Index storageTypeSize() const override
Definition: AttributeArray.h:623
bool valueTypeIsQuaternion() const override
Return true if the value type is a quaternion.
Definition: AttributeArray.h:1345
void readPagedBuffers(compression::PagedInputStream &) override
Read attribute buffers from a paged stream.
Definition: AttributeArray.h:1750
void set(Index n, const ValueType &value)
Set value at the given index n.
Definition: AttributeArray.h:1435
TypedAttributeArray & operator=(const TypedAttributeArray &)
Definition: AttributeArray.h:1154
static void registerType()
Register this attribute type along with a factory function.
Definition: AttributeArray.h:1202
bool valueTypeIsFloatingPoint() const override
Return true if the value type is floating point.
Definition: AttributeArray.h:1308
void writeMetadata(std::ostream &os, bool outputTransient, bool paged) const override
Definition: AttributeArray.h:1812
static void unregisterType()
Remove this attribute type from the registry.
Definition: AttributeArray.h:1210
void loadData() const override
Ensures all data is in-core.
Definition: AttributeArray.h:1635
void read(std::istream &) override
Read attribute data from a stream.
Definition: AttributeArray.h:1651
ValueType get(Index n) const
Return the value at index n.
Definition: AttributeArray.h:1383
TypedAttributeArray(TypedAttributeArray &&)=delete
Move constructor disabled.
static const NamePair & attributeType()
Return the name of this attribute's type (includes codec)
Definition: AttributeArray.h:1181
bool valueTypeIsClass() const override
Return true if the value type is a class (ie vector, matrix or quaternion return true)
Definition: AttributeArray.h:1328
Index size() const override
Return the number of elements in this array.
Definition: AttributeArray.h:601
void collapse() override
Replace the existing array with a uniform zero value.
Definition: AttributeArray.h:1524
Index dataSize() const override
Return the size of the data in this array.
Definition: AttributeArray.h:608
Codec_ Codec
Definition: AttributeArray.h:534
~TypedAttributeArray() override
Definition: AttributeArray.h:567
void expand(bool fill=true) override
Replace the single value storage with an array of length size().
Definition: AttributeArray.h:1486
AttributeArray::Ptr copyUncompressed() const override
Definition: AttributeArray.h:1261
static bool isRegistered()
Return true if this attribute type is registered.
Definition: AttributeArray.h:1194
TypedAttributeArray & operator=(TypedAttributeArray &&)=delete
Move assignment operator disabled.
bool valueTypeIsMatrix() const override
Return true if the value type is a matrix.
Definition: AttributeArray.h:1354
void fill(const ValueType &value)
Fill the existing array with the given value.
Definition: AttributeArray.h:1554
Index stride() const override
Definition: AttributeArray.h:605
StorageType * data()
Return the raw data buffer.
Definition: AttributeArray.h:746
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:1218
Name codecType() const override
Return the name of the codec used by this array (e.g., "trnc" or "fxpt").
Definition: AttributeArray.h:616
bool decompress() override
Uncompress the attribute array.
Definition: AttributeArray.h:1595
bool compress() override
Compress the attribute array.
Definition: AttributeArray.h:1579
void writePagedBuffers(compression::PagedOutputStream &os, bool outputTransient) const override
Definition: AttributeArray.h:1913
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:613
void setUnsafe(Index n, const ValueType &value)
Set value at the given index n (assumes in-core)
Definition: AttributeArray.h:1420
void readMetadata(std::istream &) override
Read attribute metadata from a stream.
Definition: AttributeArray.h:1660
#define OPENVDB_LOG_WARN(message)
Log a warning message of the form 'someVar << "some text" << ...'.
Definition: logging.h:253
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 operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:477
internal::half half
Definition: openvdb/Types.h:25
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:444
IntegerVectorT floatingPointToFixedPoint(const math::Vec3< FloatT > &v)
Definition: AttributeArray.h:69
FloatVectorT fixedPointToFloatingPoint(const math::Vec3< IntegerT > &v)
Definition: AttributeArray.h:79
std::string Name
Definition: Name.h:17
Index32 Index
Definition: openvdb/Types.h:50
int16_t Int16
Definition: openvdb/Types.h:51
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:39
uint64_t Index64
Definition: openvdb/Types.h:49
Definition: openvdb/Exceptions.h:13
#define OPENVDB_THROW(exception, message)
Definition: openvdb/Exceptions.h:74
Definition: openvdb/Types.h:201
typename T::ValueType ElementType
Definition: openvdb/Types.h:204
static ValueType get(GetterPtr functor, const AttributeArray *array, const Index n)
Getter that calls the supplied functor.
Definition: AttributeArray.h:2045
void(*)(AttributeArray *array, const Index n, const ValueType &value) SetterPtr
Definition: AttributeArray.h:2042
static void set(SetterPtr functor, AttributeArray *array, const Index n, const ValueType &value)
Setter that calls the supplied functor.
Definition: AttributeArray.h:2050
ValueType(*)(const AttributeArray *array, const Index n) GetterPtr
Definition: AttributeArray.h:2041
Accessor to call unsafe get and set methods based on templated Codec and Value.
Definition: AttributeArray.h:2019
void(*)(AttributeArray *array, const Index n, const ValueType &value) SetterPtr
Definition: AttributeArray.h:2021
static ValueType get(GetterPtr, const AttributeArray *array, const Index n)
Definition: AttributeArray.h:2025
ValueType(*)(const AttributeArray *array, const Index n) GetterPtr
Definition: AttributeArray.h:2020
static void set(SetterPtr, AttributeArray *array, const Index n, const ValueType &value)
Definition: AttributeArray.h:2031
Accessor base class for AttributeArray storage where type is not available.
Definition: AttributeArray.h:398
virtual ~AccessorBase()=default
Definition: AttributeArray.h:404
SetterPtr mSetter
Definition: AttributeArray.h:413
GetterPtr mGetter
Definition: AttributeArray.h:412
void(*)(AttributeArray *array, const T &value) ValuePtr
Definition: AttributeArray.h:407
T(*)(const AttributeArray *array, const Index n) GetterPtr
Definition: AttributeArray.h:405
void(*)(AttributeArray *array, const Index n, const T &value) SetterPtr
Definition: AttributeArray.h:406
ValuePtr mFiller
Definition: AttributeArray.h:415
Accessor(GetterPtr getter, SetterPtr setter, ValuePtr collapser, ValuePtr filler)
Definition: AttributeArray.h:409
ValuePtr mCollapser
Definition: AttributeArray.h:414
Definition: AttributeArray.h:496
typename attribute_traits::UIntTypeTrait< OneByte, T >::Type Type
Definition: AttributeArray.h:496
Definition: AttributeArray.h:494
static const char * name()
Definition: AttributeArray.h:501
Definition: AttributeArray.h:455
T Type
Definition: AttributeArray.h:455
Definition: AttributeArray.h:453
static const char * name()
Definition: AttributeArray.h:459
Definition: AttributeArray.h:476
static ValueType decode(const ValueType &value)
Definition: AttributeArray.h:479
static ValueType encode(const ValueType &value)
Definition: AttributeArray.h:478
static const char * name()
Definition: AttributeArray.h:477
Definition: AttributeArray.h:466
typename attribute_traits::TruncateTrait< T >::Type Type
Definition: AttributeArray.h:466
Definition: AttributeArray.h:464
static const char * name()
Definition: AttributeArray.h:470
Definition: AttributeArray.h:485
static ValueType decode(const ValueType &value)
Definition: AttributeArray.h:488
static ValueType encode(const ValueType &value)
Definition: AttributeArray.h:487
static const char * name()
Definition: AttributeArray.h:486
Definition: AttributeArray.h:513
StorageType Type
Definition: AttributeArray.h:513
Definition: AttributeArray.h:509
uint16_t StorageType
Definition: AttributeArray.h:510
static const char * name()
Definition: AttributeArray.h:517
Definition: AttributeArray.h:449
short Type
Definition: AttributeArray.h:426
Definition: AttributeArray.h:424
uint16_t Type
Definition: AttributeArray.h:434
uint8_t Type
Definition: AttributeArray.h:433
Definition: AttributeArray.h:432
#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:178