10#ifndef OPENVDB_POINTS_ATTRIBUTE_ARRAY_HAS_BEEN_INCLUDED
11#define OPENVDB_POINTS_ATTRIBUTE_ARRAY_HAS_BEEN_INCLUDED
23#include <tbb/spin_mutex.h>
32class TestAttributeArray;
48template <
typename IntegerT,
typename FloatT>
52 static_assert(std::is_unsigned<IntegerT>::value,
"IntegerT must be unsigned");
53 if (FloatT(0.0) > s)
return std::numeric_limits<IntegerT>::min();
54 else if (FloatT(1.0) <= s)
return std::numeric_limits<IntegerT>::max();
55 return IntegerT(s * FloatT(std::numeric_limits<IntegerT>::max()));
59template <
typename FloatT,
typename IntegerT>
63 static_assert(std::is_unsigned<IntegerT>::value,
"IntegerT must be unsigned");
64 return FloatT(s) / FloatT((std::numeric_limits<IntegerT>::max()));
67template <
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()));
77template <
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;
147#if OPENVDB_ABI_VERSION_NUMBER < 10
199#if OPENVDB_ABI_VERSION_NUMBER >= 10
211 bool constantStride =
true,
223 template<
typename AttributeArrayType>
224 bool isType()
const {
return this->type() == AttributeArrayType::attributeType(); }
227 template<
typename ValueType>
228 bool hasValueType()
const {
return this->type().first == typeNameAsString<ValueType>(); }
230#if OPENVDB_ABI_VERSION_NUMBER < 10
262 template<
typename IterT>
263 void copyValuesUnsafe(
const AttributeArray& sourceArray,
const IterT& iter);
267 template<
typename IterT>
268 void copyValues(
const AttributeArray& sourceArray,
const IterT& iter,
bool compact =
true);
274 virtual void expand(
bool fill =
true) = 0;
280#if OPENVDB_ABI_VERSION_NUMBER < 10
285 virtual bool compress() = 0;
290 virtual bool decompress() = 0;
299 bool isHidden()
const {
return bool(mFlags & HIDDEN); }
320 uint8_t
flags()
const {
return mFlags; }
323 virtual void read(std::istream&) = 0;
326 virtual void write(std::ostream&,
bool outputTransient)
const = 0;
328 virtual void write(std::ostream&)
const = 0;
335 virtual void writeMetadata(std::ostream&,
bool outputTransient,
bool paged)
const = 0;
341 virtual void writeBuffers(std::ostream&,
bool outputTransient)
const = 0;
361#if OPENVDB_ABI_VERSION_NUMBER >= 9
367 friend class ::TestAttributeArray;
374 virtual char* dataAsByteArray() = 0;
375 virtual const char* dataAsByteArray()
const = 0;
378 template <
typename IterT>
379 void doCopyValues(
const AttributeArray& sourceArray,
const IterT& iter,
380 bool rangeChecking =
true);
398 bool mIsUniform =
true;
401 uint8_t mUsePagedRead = 0;
427 mGetter(getter), mSetter(setter), mCollapser(collapser), mFiller(filler) { }
439namespace attribute_traits
471 template <
typename T>
474 template<
typename ValueType>
static void decode(
const ValueType&, ValueType&);
475 template<
typename ValueType>
static void encode(
const ValueType&, ValueType&);
476 static const char*
name() {
return "null"; }
482 template <
typename T>
485 template<
typename StorageType,
typename ValueType>
static void decode(
const StorageType&, ValueType&);
486 template<
typename StorageType,
typename ValueType>
static void encode(
const ValueType&, StorageType&);
487 static const char*
name() {
return "trnc"; }
494 static const char*
name() {
return "fxpt"; }
495 template <
typename ValueType>
static ValueType
encode(
const ValueType&
value) {
return value + ValueType(0.5); }
496 template <
typename ValueType>
static ValueType
decode(
const ValueType&
value) {
return value - ValueType(0.5); }
503 static const char*
name() {
return "ufxpt"; }
504 template <
typename ValueType>
static ValueType
encode(
const ValueType&
value) {
return value; }
505 template <
typename ValueType>
static ValueType
decode(
const ValueType&
value) {
return value; }
509template <
bool OneByte,
typename Range=PositionRange>
512 template <
typename T>
515 template<
typename StorageType,
typename ValueType>
static void decode(
const StorageType&, ValueType&);
516 template<
typename StorageType,
typename ValueType>
static void encode(
const ValueType&, StorageType&);
519 static const std::string
Name = std::string(Range::name()) + (OneByte ?
"8" :
"16");
529 template <
typename T>
534 static const char*
name() {
return "uvec"; }
543template<
typename ValueType_,
typename Codec_ = NullCodec>
547 using Ptr = std::shared_ptr<TypedAttributeArray>;
548 using ConstPtr = std::shared_ptr<const TypedAttributeArray>;
552 using StorageType =
typename Codec::template Storage<ValueType>::Type;
558 const ValueType& uniformValue = zeroVal<ValueType>());
567#if OPENVDB_ABI_VERSION_NUMBER < 10
587#if OPENVDB_ABI_VERSION_NUMBER < 10
595 static Ptr create(
Index n,
Index strideOrTotalSize = 1,
bool constantStride =
true,
596 const Metadata* metadata =
nullptr);
605 static const NamePair& attributeType();
610 static bool isRegistered();
612 static void registerType();
614 static void unregisterType();
621 Index stride()
const override {
return hasConstantStride() ? mStrideOrTotalSize : 0; }
625 return hasConstantStride() ? mSize * mStrideOrTotalSize : mStrideOrTotalSize;
642 bool valueTypeIsFloatingPoint()
const override;
645 bool valueTypeIsClass()
const override;
648 bool valueTypeIsVector()
const override;
651 bool valueTypeIsQuaternion()
const override;
654 bool valueTypeIsMatrix()
const override;
657 size_t memUsage()
const override;
659#if OPENVDB_ABI_VERSION_NUMBER >= 10
664 size_t memUsageIfLoaded()
const override;
668 ValueType getUnsafe(
Index n)
const;
670 ValueType get(
Index n)
const;
672 template<
typename T>
void getUnsafe(
Index n, T&
value)
const;
674 template<
typename T>
void get(
Index n, T&
value)
const;
681 void setUnsafe(
Index n,
const ValueType&
value);
685 template<
typename T>
void setUnsafe(
Index n,
const T&
value);
687 template<
typename T>
void set(
Index n,
const T&
value);
693#if OPENVDB_ABI_VERSION_NUMBER < 10
704 void expand(
bool fill =
true)
override;
706 void collapse()
override;
708 bool compact()
override;
711 void collapse(
const ValueType& uniformValue);
714 void fill(
const ValueType&
value);
721#if OPENVDB_ABI_VERSION_NUMBER < 10
724 bool compress() override;
727 bool decompress() override;
731 void read(std::istream&)
override;
735 void write(std::ostream& os,
bool outputTransient)
const override;
737 void write(std::ostream&)
const override;
740 void readMetadata(std::istream&)
override;
745 void writeMetadata(std::ostream& os,
bool outputTransient,
bool paged)
const override;
748 void readBuffers(std::istream&)
override;
752 void writeBuffers(std::ostream& os,
bool outputTransient)
const override;
762 inline bool isOutOfCore()
const;
765 void loadData()
const override;
768 bool isDataLoaded()
const override;
770#if OPENVDB_ABI_VERSION_NUMBER >= 9
776 AccessorBasePtr getAccessor()
const override;
783 inline bool validData()
const {
return !(isOutOfCore() || (flags() & PARTIALREAD)); }
786 friend class ::TestAttributeArray;
791 inline void doLoad()
const;
793#if OPENVDB_ABI_VERSION_NUMBER >= 10
794 inline void doLoadUnsafe()
const;
797 inline void doLoadUnsafe(
const bool compression =
true)
const;
799 inline bool compressUnsafe();
803 inline void setOutOfCore(
const bool);
809 char* dataAsByteArray()
override;
810 const char* dataAsByteArray()
const override;
812 size_t arrayMemUsage()
const;
819 return TypedAttributeArray::create(n, strideOrTotalSize, constantStride, metadata);
822 static std::unique_ptr<const NamePair> sTypeName;
823 std::unique_ptr<StorageType[]> mData;
825 Index mStrideOrTotalSize;
834template <
typename ValueType,
typename CodecType = UnknownCodec>
839 using Ptr = std::shared_ptr<Handle>;
878 friend class ::TestAttributeArray;
880 template <
bool IsUnknownCodec>
881 typename std::enable_if<IsUnknownCodec, bool>::type compatibleType()
const;
883 template <
bool IsUnknownCodec>
884 typename std::enable_if<!IsUnknownCodec, bool>::type compatibleType()
const;
886 template <
bool IsUnknownCodec>
887 typename std::enable_if<IsUnknownCodec, ValueType>::type get(
Index index)
const;
889 template <
bool IsUnknownCodec>
890 typename std::enable_if<!IsUnknownCodec, ValueType>::type get(
Index index)
const;
895 Index mStrideOrTotalSize;
897 bool mCollapseOnDestruction;
905template <
typename ValueType,
typename CodecType = UnknownCodec>
910 using Ptr = std::shared_ptr<Handle>;
940 friend class ::TestAttributeArray;
942 template <
bool IsUnknownCodec>
943 typename std::enable_if<IsUnknownCodec, void>::type set(
Index index,
const ValueType&
value)
const;
945 template <
bool IsUnknownCodec>
946 typename std::enable_if<!IsUnknownCodec, void>::type set(
Index index,
const ValueType&
value)
const;
956template<
typename ValueType>
958NullCodec::decode(
const ValueType& data, ValueType& val)
964template<
typename ValueType>
966NullCodec::encode(
const ValueType& val, ValueType& data)
972template<
typename StorageType,
typename ValueType>
974TruncateCodec::decode(
const StorageType& data, ValueType& val)
976 val =
static_cast<ValueType
>(data);
980template<
typename StorageType,
typename ValueType>
982TruncateCodec::encode(
const ValueType& val, StorageType& data)
984 data =
static_cast<StorageType
>(val);
988template <
bool OneByte,
typename Range>
989template<
typename StorageType,
typename ValueType>
993 val = fixedPointToFloatingPoint<ValueType>(data);
997 val = Range::template decode<ValueType>(val);
1001template <
bool OneByte,
typename Range>
1002template<
typename StorageType,
typename ValueType>
1008 const ValueType newVal = Range::template encode<ValueType>(val);
1010 data = floatingPointToFixedPoint<StorageType>(newVal);
1018 val = math::QuantizedUnitVec::unpack(data);
1026 data = math::QuantizedUnitVec::pack(val);
1034template <
typename IterT>
1035void AttributeArray::doCopyValues(
const AttributeArray& sourceArray,
const IterT& iter,
1041 assert(sourceArray.
isDataLoaded() && this->isDataLoaded());
1043 assert(this->storageTypeSize()*this->stride() ==
1047 const char*
const sourceBuffer = sourceArray.dataAsByteArray();
1048 char*
const targetBuffer = this->dataAsByteArray();
1049 assert(sourceBuffer && targetBuffer);
1051 if (rangeChecking && this->isUniform()) {
1055 const bool sourceIsUniform = sourceArray.
isUniform();
1057 const Index sourceDataSize = rangeChecking ? sourceArray.
dataSize() : 0;
1058 const Index targetDataSize = rangeChecking ? this->dataSize() : 0;
1060 for (IterT it(iter); it; ++it) {
1061 const Index sourceIndex = sourceIsUniform ? 0 : it.sourceIndex();
1062 const Index targetIndex = it.targetIndex();
1064 if (rangeChecking) {
1065 if (sourceIndex >= sourceDataSize) {
1067 "Cannot copy array data as source index exceeds size of source array.");
1069 if (targetIndex >= targetDataSize) {
1071 "Cannot copy array data as target index exceeds size of target array.");
1075 assert(sourceIndex < sourceArray.
dataSize());
1076 assert(targetIndex < this->dataSize());
1077 if (this->isUniform()) assert(targetIndex ==
Index(0));
1080 const size_t targetOffset(targetIndex * bytes);
1081 const size_t sourceOffset(sourceIndex * bytes);
1083 std::memcpy(targetBuffer + targetOffset, sourceBuffer + sourceOffset, bytes);
1087template <
typename IterT>
1088void AttributeArray::copyValuesUnsafe(
const AttributeArray& sourceArray,
const IterT& iter)
1090 this->doCopyValues(sourceArray, iter,
false);
1093template <
typename IterT>
1098 if (bytes != this->storageTypeSize()) {
1115 this->doCopyValues(sourceArray, iter,
true);
1128template<
typename ValueType_,
typename Codec_>
1132template<
typename ValueType_,
typename Codec_>
1138 , mStrideOrTotalSize(strideOrTotalSize)
1140 if (constantStride) {
1142 if (strideOrTotalSize == 0) {
1144 "stride to be at least one.")
1149 if (mStrideOrTotalSize < n) {
1151 "a total size of at least the number of elements in the array.")
1154 mSize = std::max(
Index(1), mSize);
1155 mStrideOrTotalSize = std::max(
Index(1), mStrideOrTotalSize);
1156 Codec::encode(uniformValue, this->
data()[0]);
1160template<
typename ValueType_,
typename Codec_>
1167template<
typename ValueType_,
typename Codec_>
1169 const tbb::spin_mutex::scoped_lock& lock)
1172 , mStrideOrTotalSize(rhs.mStrideOrTotalSize)
1176 std::memcpy(
static_cast<void*
>(this->
data()), rhs.
data(), this->arrayMemUsage());
1181template<
typename ValueType_,
typename Codec_>
1182TypedAttributeArray<ValueType_, Codec_>&
1187 tbb::spin_mutex::scoped_lock lock(mMutex);
1188 tbb::spin_mutex::scoped_lock rhsLock(rhs.
mMutex);
1195 mStrideOrTotalSize = rhs.mStrideOrTotalSize;
1198 if (this->validData()) {
1200 std::memcpy(
static_cast<void*
>(this->data()), rhs.
data(), this->arrayMemUsage());
1208template<
typename ValueType_,
typename Codec_>
1212 static std::once_flag once;
1213 std::call_once(once, []()
1215 sTypeName.reset(
new NamePair(typeNameAsString<ValueType>(), Codec::name()));
1221template<
typename ValueType_,
typename Codec_>
1229template<
typename ValueType_,
typename Codec_>
1237template<
typename ValueType_,
typename Codec_>
1245template<
typename ValueType_,
typename Codec_>
1254 typedMetadata ? typedMetadata->
value() : zeroVal<ValueType>()));
1257template<
typename ValueType_,
typename Codec_>
1267template<
typename ValueType_,
typename Codec_>
1277template<
typename ValueType_,
typename Codec_>
1285#if OPENVDB_ABI_VERSION_NUMBER < 10
1286template<
typename ValueType_,
typename Codec_>
1290 return this->copy();
1294template<
typename ValueType_,
typename Codec_>
1296TypedAttributeArray<ValueType_, Codec_>::arrayMemUsage()
const
1298 if (this->isOutOfCore())
return 0;
1300 return (mIsUniform ? 1 : this->dataSize()) * sizeof(StorageType);
1304template<
typename ValueType_,
typename Codec_>
1306TypedAttributeArray<ValueType_, Codec_>::allocate()
1310 mData.reset(
new StorageType[1]);
1313 const size_t size(this->dataSize());
1315 mData.reset(
new StorageType[size]);
1320template<
typename ValueType_,
typename Codec_>
1322TypedAttributeArray<ValueType_, Codec_>::deallocate()
1325 if (this->isOutOfCore()) {
1326 this->setOutOfCore(
false);
1327 this->mPageHandle.reset();
1329 if (mData) mData.reset();
1333template<
typename ValueType_,
typename Codec_>
1339 if (std::is_same<ValueType, Quats>::value ||
1340 std::is_same<ValueType, Quatd>::value ||
1341 std::is_same<ValueType, Mat3s>::value ||
1342 std::is_same<ValueType, Mat3d>::value ||
1343 std::is_same<ValueType, Mat4s>::value ||
1344 std::is_same<ValueType, Mat4d>::value)
return true;
1349 return std::is_floating_point<ElementT>::value || std::is_same<math::half, ElementT>::value;
1353template<
typename ValueType_,
typename Codec_>
1358 return std::is_class<ValueType>::value && !std::is_same<math::half, ValueType>::value;
1362template<
typename ValueType_,
typename Codec_>
1370template<
typename ValueType_,
typename Codec_>
1375 return !this->valueType().compare(0, 4,
"quat");
1379template<
typename ValueType_,
typename Codec_>
1384 return !this->valueType().compare(0, 3,
"mat");
1388template<
typename ValueType_,
typename Codec_>
1392 return sizeof(*this) + (bool(mData) ? this->arrayMemUsage() : 0);
1395#if OPENVDB_ABI_VERSION_NUMBER >= 10
1396template<
typename ValueType_,
typename Codec_>
1400 return sizeof(*this) + (mIsUniform ? 1 : this->dataSize()) *
sizeof(
StorageType);
1405template<
typename ValueType_,
typename Codec_>
1409 assert(n < this->dataSize());
1412 Codec::decode(this->data()[mIsUniform ? 0 : n], val);
1417template<
typename ValueType_,
typename Codec_>
1422 if (this->isOutOfCore()) this->doLoad();
1424 return this->getUnsafe(n);
1428template<
typename ValueType_,
typename Codec_>
1433 val =
static_cast<T
>(this->getUnsafe(n));
1437template<
typename ValueType_,
typename Codec_>
1442 val =
static_cast<T
>(this->get(n));
1446template<
typename ValueType_,
typename Codec_>
1454template<
typename ValueType_,
typename Codec_>
1458 assert(n < this->dataSize());
1459 assert(!this->isOutOfCore());
1460 assert(!this->isUniform());
1465 Codec::encode(val, this->data()[mIsUniform ? 0 : n]);
1469template<
typename ValueType_,
typename Codec_>
1474 if (this->isOutOfCore()) this->doLoad();
1475 if (this->isUniform()) this->expand();
1477 this->setUnsafe(n, val);
1481template<
typename ValueType_,
typename Codec_>
1486 this->setUnsafe(n,
static_cast<ValueType>(val));
1490template<
typename ValueType_,
typename Codec_>
1495 this->set(n,
static_cast<ValueType>(val));
1499template<
typename ValueType_,
typename Codec_>
1507#if OPENVDB_ABI_VERSION_NUMBER < 10
1508template<
typename ValueType_,
typename Codec_>
1514 ValueType sourceValue;
1515 sourceTypedArray.
get(sourceIndex, sourceValue);
1517 this->set(n, sourceValue);
1522template<
typename ValueType_,
typename Codec_>
1526 if (!mIsUniform)
return;
1531 tbb::spin_mutex::scoped_lock lock(mMutex);
1538 for (
Index i = 0; i < this->dataSize(); ++i) this->data()[i] = val;
1543template<
typename ValueType_,
typename Codec_>
1547 if (mIsUniform)
return true;
1550 const ValueType_ val = this->get(0);
1551 for (
Index i = 1; i < this->dataSize(); i++) {
1555 this->collapse(this->get(0));
1560template<
typename ValueType_,
typename Codec_>
1564 this->collapse(zeroVal<ValueType>());
1568template<
typename ValueType_,
typename Codec_>
1573 tbb::spin_mutex::scoped_lock lock(mMutex);
1578 Codec::encode(uniformValue, this->data()[0]);
1582template<
typename ValueType_,
typename Codec_>
1590template<
typename ValueType_,
typename Codec_>
1594 if (this->isOutOfCore()) {
1595 tbb::spin_mutex::scoped_lock lock(mMutex);
1600 const Index size = mIsUniform ? 1 : this->dataSize();
1601 for (
Index i = 0; i < size; ++i) {
1602 Codec::encode(
value, this->data()[i]);
1607template<
typename ValueType_,
typename Codec_>
1615#if OPENVDB_ABI_VERSION_NUMBER < 10
1616template<
typename ValueType_,
typename Codec_>
1624template<
typename ValueType_,
typename Codec_>
1626TypedAttributeArray<ValueType_, Codec_>::compressUnsafe()
1632template<
typename ValueType_,
typename Codec_>
1634TypedAttributeArray<ValueType_, Codec_>::decompress()
1641template<
typename ValueType_,
typename Codec_>
1649template<
typename ValueType_,
typename Codec_>
1657template<
typename ValueType_,
typename Codec_>
1659TypedAttributeArray<ValueType_, Codec_>::doLoad()
const
1661 if (!(this->isOutOfCore()))
return;
1663 TypedAttributeArray<ValueType_, Codec_>* self =
1664 const_cast<TypedAttributeArray<ValueType_, Codec_>*
>(
this);
1668 tbb::spin_mutex::scoped_lock lock(self->mMutex);
1669 this->doLoadUnsafe();
1673template<
typename ValueType_,
typename Codec_>
1681template<
typename ValueType_,
typename Codec_>
1685 return !this->isOutOfCore();
1689template<
typename ValueType_,
typename Codec_>
1693 this->readMetadata(is);
1694 this->readBuffers(is);
1698template<
typename ValueType_,
typename Codec_>
1705 is.read(
reinterpret_cast<char*
>(&bytes),
sizeof(
Index64));
1706 bytes = bytes -
sizeof(
Int16) -
sizeof(
Index);
1708 uint8_t flags = uint8_t(0);
1709 is.read(
reinterpret_cast<char*
>(&flags),
sizeof(uint8_t));
1712 uint8_t serializationFlags = uint8_t(0);
1713 is.read(
reinterpret_cast<char*
>(&serializationFlags),
sizeof(uint8_t));
1716 is.read(
reinterpret_cast<char*
>(&size),
sizeof(
Index));
1720 if (mFlags >= 0x20) {
1725 if (serializationFlags >= 0x10) {
1731 mIsUniform = serializationFlags & WRITEUNIFORM;
1732 mUsePagedRead = serializationFlags & WRITEPAGED;
1733 mCompressedBytes = bytes;
1734 mFlags |= PARTIALREAD;
1738 if (serializationFlags & WRITESTRIDED) {
1740 is.read(
reinterpret_cast<char*
>(&stride),
sizeof(
Index));
1741 mStrideOrTotalSize = stride;
1744 mStrideOrTotalSize = 1;
1749template<
typename ValueType_,
typename Codec_>
1753 if (mUsePagedRead) {
1758 tbb::spin_mutex::scoped_lock lock(mMutex);
1762 uint8_t bloscCompressed(0);
1763 if (!mIsUniform) is.read(
reinterpret_cast<char*
>(&bloscCompressed),
sizeof(uint8_t));
1765 assert(mFlags & PARTIALREAD);
1766 std::unique_ptr<char[]> buffer(
new char[mCompressedBytes]);
1767 is.read(buffer.get(), mCompressedBytes);
1768 mCompressedBytes = 0;
1769 mFlags =
static_cast<uint8_t
>(mFlags & ~PARTIALREAD);
1773 if (bloscCompressed == uint8_t(1)) {
1777 const size_t inBytes = this->dataSize() *
sizeof(
StorageType);
1779 if (newBuffer) buffer.reset(newBuffer.release());
1784 mData.reset(
reinterpret_cast<StorageType*
>(buffer.release()));
1788template<
typename ValueType_,
typename Codec_>
1792 if (!mUsePagedRead) {
1797#ifdef OPENVDB_USE_DELAYED_LOADING
1800 io::MappedFile::Ptr mappedFile = io::getMappedFilePtr(is.
getInputStream());
1801 const bool delayLoad = (mappedFile.get() !=
nullptr);
1806 size_t compressedBytes(mCompressedBytes);
1807 mCompressedBytes = 0;
1808 mFlags =
static_cast<uint8_t
>(mFlags & ~PARTIALREAD);
1809 assert(!mPageHandle);
1814 assert(mPageHandle);
1816 tbb::spin_mutex::scoped_lock lock(mMutex);
1820#ifdef OPENVDB_USE_DELAYED_LOADING
1821 this->setOutOfCore(delayLoad);
1822 is.
read(mPageHandle, std::streamsize(mPageHandle->size()), delayLoad);
1824 is.
read(mPageHandle, std::streamsize(mPageHandle->size()),
false);
1827#ifdef OPENVDB_USE_DELAYED_LOADING
1830 std::unique_ptr<char[]> buffer = mPageHandle->read();
1831 mData.reset(
reinterpret_cast<StorageType*
>(buffer.release()));
1832 mPageHandle.reset();
1833#ifdef OPENVDB_USE_DELAYED_LOADING
1843template<
typename ValueType_,
typename Codec_>
1847 this->write(os,
false);
1851template<
typename ValueType_,
typename Codec_>
1855 this->writeMetadata(os, outputTransient,
false);
1856 this->writeBuffers(os, outputTransient);
1860template<
typename ValueType_,
typename Codec_>
1864 if (!outputTransient && this->isTransient())
return;
1866 if (mFlags & PARTIALREAD) {
1870 uint8_t flags(mFlags);
1871 uint8_t serializationFlags(0);
1873 Index stride(mStrideOrTotalSize);
1874 bool strideOfOne(this->stride() == 1);
1879 if (bloscCompression) this->doLoad();
1881 size_t compressedBytes = 0;
1885 serializationFlags |= WRITESTRIDED;
1890 serializationFlags |= WRITEUNIFORM;
1891 if (bloscCompression && paged) serializationFlags |= WRITEPAGED;
1893 else if (bloscCompression)
1895 if (paged) serializationFlags |= WRITEPAGED;
1897 const char* charBuffer =
reinterpret_cast<const char*
>(this->data());
1898 const size_t inBytes = this->arrayMemUsage();
1905 bytes += (compressedBytes > 0) ? compressedBytes : this->arrayMemUsage();
1909 os.write(
reinterpret_cast<const char*
>(&bytes),
sizeof(
Index64));
1910 os.write(
reinterpret_cast<const char*
>(&flags),
sizeof(uint8_t));
1911 os.write(
reinterpret_cast<const char*
>(&serializationFlags),
sizeof(uint8_t));
1912 os.write(
reinterpret_cast<const char*
>(&size),
sizeof(
Index));
1915 if (!strideOfOne) os.write(
reinterpret_cast<const char*
>(&stride),
sizeof(
Index));
1919template<
typename ValueType_,
typename Codec_>
1923 if (!outputTransient && this->isTransient())
return;
1925 if (mFlags & PARTIALREAD) {
1931 if (this->isUniform()) {
1932 os.write(
reinterpret_cast<const char*
>(this->data()),
sizeof(
StorageType));
1936 std::unique_ptr<char[]> compressedBuffer;
1937 size_t compressedBytes = 0;
1938 const char* charBuffer =
reinterpret_cast<const char*
>(this->data());
1939 const size_t inBytes = this->arrayMemUsage();
1941 if (compressedBuffer) {
1942 uint8_t bloscCompressed(1);
1943 os.write(
reinterpret_cast<const char*
>(&bloscCompressed),
sizeof(uint8_t));
1944 os.write(
reinterpret_cast<const char*
>(compressedBuffer.get()), compressedBytes);
1947 uint8_t bloscCompressed(0);
1948 os.write(
reinterpret_cast<const char*
>(&bloscCompressed),
sizeof(uint8_t));
1949 os.write(
reinterpret_cast<const char*
>(this->data()), inBytes);
1954 uint8_t bloscCompressed(0);
1955 os.write(
reinterpret_cast<const char*
>(&bloscCompressed),
sizeof(uint8_t));
1956 os.write(
reinterpret_cast<const char*
>(this->data()), this->arrayMemUsage());
1961template<
typename ValueType_,
typename Codec_>
1965 if (!outputTransient && this->isTransient())
return;
1969 if (!bloscCompression) {
1974 if (mFlags & PARTIALREAD) {
1980 os.
write(
reinterpret_cast<const char*
>(this->data()), this->arrayMemUsage());
1984template<
typename ValueType_,
typename Codec_>
1986#if OPENVDB_ABI_VERSION_NUMBER >= 10
1992 if (!(this->isOutOfCore()))
return;
1998 assert(self->mPageHandle);
1999 assert(!(self->mFlags & PARTIALREAD));
2001 std::unique_ptr<char[]> buffer = self->mPageHandle->read();
2003 self->mData.reset(
reinterpret_cast<StorageType*
>(buffer.release()));
2005 self->mPageHandle.reset();
2009 self->mOutOfCore =
false;
2013template<
typename ValueType_,
typename Codec_>
2028template<
typename ValueType_,
typename Codec_>
2033 if(!otherT)
return false;
2034 if(this->mSize != otherT->mSize ||
2035 this->mStrideOrTotalSize != otherT->mStrideOrTotalSize ||
2037 this->attributeType() != this->attributeType())
return false;
2042 const StorageType *target = this->data(), *source = otherT->
data();
2043 if (!target && !source)
return true;
2044 if (!target || !source)
return false;
2045 Index n = this->mIsUniform ? 1 : mSize;
2051template<
typename ValueType_,
typename Codec_>
2053TypedAttributeArray<ValueType_, Codec_>::dataAsByteArray()
2055 return reinterpret_cast<char*
>(this->data());
2059template<
typename ValueType_,
typename Codec_>
2061TypedAttributeArray<ValueType_, Codec_>::dataAsByteArray()
const
2063 return reinterpret_cast<const char*
>(this->data());
2071template <
typename CodecType,
typename ValueType>
2092template <
typename ValueType>
2100 return (*functor)(array, n);
2105 (*functor)(array, n,
value);
2114template <
typename ValueType,
typename CodecType>
2122template <
typename ValueType,
typename CodecType>
2125 , mStrideOrTotalSize(array.hasConstantStride() ? array.stride() : 1)
2126 , mSize(array.hasConstantStride() ? array.size() : array.dataSize())
2127 , mCollapseOnDestruction(collapseOnDestruction && array.isStreaming())
2129 if (!this->compatibleType<std::is_same<CodecType, UnknownCodec>::value>()) {
2150template <
typename ValueType,
typename CodecType>
2154 if (mCollapseOnDestruction)
const_cast<AttributeArray*
>(this->mArray)->collapse();
2157template <
typename ValueType,
typename CodecType>
2158template <
bool IsUnknownCodec>
2159typename std::enable_if<IsUnknownCodec, bool>::type
2164 return mArray->hasValueType<ValueType>();
2167template <
typename ValueType,
typename CodecType>
2168template <
bool IsUnknownCodec>
2169typename std::enable_if<!IsUnknownCodec, bool>::type
2170AttributeHandle<ValueType, CodecType>::compatibleType()
const
2174 return mArray->isType<TypedAttributeArray<ValueType, CodecType>>();
2177template <
typename ValueType,
typename CodecType>
2184template <
typename ValueType,
typename CodecType>
2187 Index index = n * mStrideOrTotalSize + m;
2188 assert(index < (mSize * mStrideOrTotalSize));
2192template <
typename ValueType,
typename CodecType>
2195 return this->get<std::is_same<CodecType, UnknownCodec>::value>(this->index(n, m));
2198template <
typename ValueType,
typename CodecType>
2199template <
bool IsUnknownCodec>
2200typename std::enable_if<IsUnknownCodec, ValueType>::type
2205 return (*mGetter)(mArray, index);
2208template <
typename ValueType,
typename CodecType>
2209template <
bool IsUnknownCodec>
2210typename std::enable_if<!IsUnknownCodec, ValueType>::type
2218template <
typename ValueType,
typename CodecType>
2221 return mArray->isUniform();
2224template <
typename ValueType,
typename CodecType>
2227 return mArray->hasConstantStride();
2234template <
typename ValueType,
typename CodecType>
2242template <
typename ValueType,
typename CodecType>
2249template <
typename ValueType,
typename CodecType>
2252 this->set<std::is_same<CodecType, UnknownCodec>::value>(this->index(n, 0),
value);
2255template <
typename ValueType,
typename CodecType>
2258 this->set<std::is_same<CodecType, UnknownCodec>::value>(this->index(n, m),
value);
2261template <
typename ValueType,
typename CodecType>
2267template <
typename ValueType,
typename CodecType>
2273template <
typename ValueType,
typename CodecType>
2279template <
typename ValueType,
typename CodecType>
2282 this->mCollapser(
const_cast<AttributeArray*
>(this->mArray), uniformValue);
2285template <
typename ValueType,
typename CodecType>
2291template <
typename ValueType,
typename CodecType>
2292template <
bool IsUnknownCodec>
2293typename std::enable_if<IsUnknownCodec, void>::type
2301template <
typename ValueType,
typename CodecType>
2302template <
bool IsUnknownCodec>
2303typename std::enable_if<!IsUnknownCodec, void>::type
2311template <
typename ValueType,
typename CodecType>
2314 assert(this->mArray);
ValueT value
Definition GridBuilder.h:1290
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:172
A Paging wrapper to std::istream that is responsible for reading from a given input stream and creati...
Definition StreamCompression.h:207
PageHandle::Ptr createHandle(std::streamsize n)
Creates a PageHandle to access the next.
bool sizeOnly() const
Definition StreamCompression.h:217
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:220
A Paging wrapper to std::ostream that is responsible for writing from a given output stream at interv...
Definition StreamCompression.h:244
std::ostream & getOutputStream()
Set and get the output stream.
Definition StreamCompression.h:257
bool sizeOnly() const
Definition StreamCompression.h:254
PagedOutputStream & write(const char *str, std::streamsize n)
Writes the given.
T & x()
Reference to the component, e.g. v.x() = 4.5f;.
Definition Vec3.h:85
T & y()
Definition Vec3.h:86
T & z()
Definition Vec3.h:87
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").
const char * constDataAsByteArray() const
Indirect virtual function to retrieve the data buffer cast to a char byte array.
Definition AttributeArray.h:363
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:306
SerializationFlag
Definition AttributeArray.h:109
AttributeArray & operator=(const AttributeArray &rhs)
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 ~AttributeArray()
Definition AttributeArray.h:133
compression::PageHandle::Ptr mPageHandle
Definition AttributeArray.h:405
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:299
bool isType() const
Return true if this attribute is of the same type as the template parameter.
Definition AttributeArray.h:224
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.
uint8_t mFlags
Definition AttributeArray.h:400
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:320
bool hasValueType() const
Return true if this attribute has a value type the same as the template parameter.
Definition AttributeArray.h:228
std::atomic< Index32 > mOutOfCore
Definition AttributeArray.h:402
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 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 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:401
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:399
bool operator!=(const AttributeArray &other) const
Definition AttributeArray.h:359
bool isStreaming() const
Return true if this attribute is in streaming mode.
Definition AttributeArray.h:314
virtual void writeMetadata(std::ostream &, bool outputTransient, bool paged) const =0
AttributeArray & operator=(AttributeArray &&)=delete
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 size_t memUsageIfLoaded() const =0
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:317
virtual const NamePair & type() const =0
Return the name of this attribute's type.
size_t mCompressedBytes
Definition AttributeArray.h:406
bool mIsUniform
Definition AttributeArray.h:398
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:836
virtual ~AttributeHandle()
Definition AttributeArray.h:2151
Index size() const
Definition AttributeArray.h:858
void(*)(AttributeArray *array, const ValueType &value) ValuePtr
Definition AttributeArray.h:845
SetterPtr mSetter
Definition AttributeArray.h:873
Index stride() const
Definition AttributeArray.h:857
std::shared_ptr< Handle > Ptr
Definition AttributeArray.h:839
GetterPtr mGetter
Definition AttributeArray.h:872
void(*)(AttributeArray *array, const Index n, const ValueType &value) SetterPtr
Definition AttributeArray.h:844
static Ptr create(const AttributeArray &array, const bool collapseOnDestruction=true)
Definition AttributeArray.h:2116
AttributeHandle(const AttributeArray &array, const bool collapseOnDestruction=true)
Definition AttributeArray.h:2123
ValuePtr mFiller
Definition AttributeArray.h:875
ValueType get(Index n, Index m=0) const
Definition AttributeArray.h:2193
ValueType(*)(const AttributeArray *array, const Index n) GetterPtr
Definition AttributeArray.h:843
AttributeHandle(const AttributeHandle &)=default
ValuePtr mCollapser
Definition AttributeArray.h:874
const AttributeArray & array() const
Definition AttributeArray.h:2178
const AttributeArray * mArray
Definition AttributeArray.h:870
bool isUniform() const
Definition AttributeArray.h:2219
std::unique_ptr< Handle > UniquePtr
Definition AttributeArray.h:840
bool hasConstantStride() const
Definition AttributeArray.h:2225
AttributeHandle & operator=(const AttributeHandle &)=default
Index index(Index n, Index m) const
Definition AttributeArray.h:2185
Write-able version of AttributeHandle.
Definition AttributeArray.h:907
virtual ~AttributeWriteHandle()=default
AttributeWriteHandle(AttributeArray &array, const bool expand=true)
Definition AttributeArray.h:2243
std::shared_ptr< Handle > Ptr
Definition AttributeArray.h:910
bool compact()
Compact the existing array to become uniform if all values are identical.
Definition AttributeArray.h:2274
void collapse()
Replace the existing array with a uniform value (zero if none provided).
Definition AttributeArray.h:2268
void set(Index n, const ValueType &value)
Definition AttributeArray.h:2250
void expand(bool fill=true)
If this array is uniform, replace it with an array of length size().
Definition AttributeArray.h:2262
AttributeArray & array()
Definition AttributeArray.h:2312
std::unique_ptr< Handle > ScopedPtr
Definition AttributeArray.h:911
static Ptr create(AttributeArray &array, const bool expand=true)
Definition AttributeArray.h:2236
void set(Index n, Index m, const ValueType &value)
Definition AttributeArray.h:2256
void fill(const ValueType &value)
Fill the existing array with the given value.
Definition AttributeArray.h:2286
void collapse(const ValueType &uniformValue)
Definition AttributeArray.h:2280
Typed class for storing attribute data.
Definition AttributeArray.h:545
Index valueTypeSize() const override
Return the size in bytes of the value type of a single element in this array.
Definition AttributeArray.h:635
size_t memUsageIfLoaded() const override
Definition AttributeArray.h:1398
ValueType getUnsafe(Index n) const
Return the value at index n (assumes in-core)
Definition AttributeArray.h:1407
bool isUniform() const override
Return true if this array is stored as a single uniform value.
Definition AttributeArray.h:700
void readBuffers(std::istream &) override
Read attribute buffers from a stream.
Definition AttributeArray.h:1751
std::shared_ptr< TypedAttributeArray > Ptr
Definition AttributeArray.h:547
AccessorBasePtr getAccessor() const override
Obtain an Accessor that stores getter and setter functors.
Definition AttributeArray.h:2015
void write(std::ostream &os, bool outputTransient) const override
Definition AttributeArray.h:1853
typename Codec::template Storage< ValueType >::Type StorageType
Definition AttributeArray.h:552
size_t memUsage() const override
Return the number of bytes of memory used by this attribute.
Definition AttributeArray.h:1390
ValueType_ ValueType
Definition AttributeArray.h:550
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:1133
bool isDataLoaded() const override
Return true if all data has been loaded.
Definition AttributeArray.h:1683
bool isOutOfCore() const
Return true if this buffer's values have not yet been read from disk.
Definition AttributeArray.h:1643
std::shared_ptr< const TypedAttributeArray > ConstPtr
Definition AttributeArray.h:548
bool valueTypeIsVector() const override
Return true if the value type is a vector.
Definition AttributeArray.h:1364
bool validData() const
Verify that data is not out-of-core or in a partially-read state.
Definition AttributeArray.h:783
bool compact() override
Compact the existing array to become uniform if all values are identical.
Definition AttributeArray.h:1545
static TypedAttributeArray & cast(AttributeArray &attributeArray)
Cast an AttributeArray to TypedAttributeArray<T>
Definition AttributeArray.h:1259
TypedAttributeArray & operator=(TypedAttributeArray &&)=delete
Move assignment operator disabled.
void writeBuffers(std::ostream &os, bool outputTransient) const override
Definition AttributeArray.h:1921
AttributeArray::Ptr copy() const override
Definition AttributeArray.h:1279
Index storageTypeSize() const override
Definition AttributeArray.h:639
bool valueTypeIsQuaternion() const override
Return true if the value type is a quaternion.
Definition AttributeArray.h:1372
void readPagedBuffers(compression::PagedInputStream &) override
Read attribute buffers from a paged stream.
Definition AttributeArray.h:1790
void set(Index n, const ValueType &value)
Set value at the given index n.
Definition AttributeArray.h:1471
TypedAttributeArray & operator=(const TypedAttributeArray &)
Definition AttributeArray.h:1183
static void registerType()
Register this attribute type along with a factory function.
Definition AttributeArray.h:1231
bool valueTypeIsFloatingPoint() const override
Return true if the value type is floating point.
Definition AttributeArray.h:1335
void writeMetadata(std::ostream &os, bool outputTransient, bool paged) const override
Definition AttributeArray.h:1862
static void unregisterType()
Remove this attribute type from the registry.
Definition AttributeArray.h:1239
const StorageType * data() const
Definition AttributeArray.h:780
void loadData() const override
Ensures all data is in-core.
Definition AttributeArray.h:1675
void read(std::istream &) override
Read attribute data from a stream.
Definition AttributeArray.h:1691
ValueType get(Index n) const
Return the value at index n.
Definition AttributeArray.h:1419
TypedAttributeArray(TypedAttributeArray &&)=delete
Move constructor disabled.
static const NamePair & attributeType()
Return the name of this attribute's type (includes codec)
Definition AttributeArray.h:1210
const NamePair & type() const override
Return the name of this attribute's type.
Definition AttributeArray.h:607
bool valueTypeIsClass() const override
Return true if the value type is a class (ie vector, matrix or quaternion return true)
Definition AttributeArray.h:1355
Index size() const override
Return the number of elements in this array.
Definition AttributeArray.h:617
void collapse() override
Replace the existing array with a uniform zero value.
Definition AttributeArray.h:1562
Index dataSize() const override
Return the size of the data in this array.
Definition AttributeArray.h:624
Codec_ Codec
Definition AttributeArray.h:551
~TypedAttributeArray() override
Definition AttributeArray.h:581
void expand(bool fill=true) override
Replace the single value storage with an array of length size().
Definition AttributeArray.h:1524
static bool isRegistered()
Return true if this attribute type is registered.
Definition AttributeArray.h:1223
bool valueTypeIsMatrix() const override
Return true if the value type is a matrix.
Definition AttributeArray.h:1381
StorageType * data()
Return the raw data buffer.
Definition AttributeArray.h:779
const StorageType * constData() const
Return the raw data buffer.
Definition AttributeArray.h:772
void fill(const ValueType &value)
Fill the existing array with the given value.
Definition AttributeArray.h:1592
Index stride() const override
Definition AttributeArray.h:621
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:1247
Name codecType() const override
Return the name of the codec used by this array (e.g., "trnc" or "fxpt").
Definition AttributeArray.h:632
void writePagedBuffers(compression::PagedOutputStream &os, bool outputTransient) const override
Definition AttributeArray.h:1963
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:629
void setUnsafe(Index n, const ValueType &value)
Set value at the given index n (assumes in-core)
Definition AttributeArray.h:1456
void readMetadata(std::istream &) override
Read attribute metadata from a stream.
Definition AttributeArray.h:1700
#define OPENVDB_LOG_WARN(message)
Log a warning message of the form 'someVar << "some text" << ...'.
Definition logging.h:256
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 size_t bloscCompressedSize(const char *buffer, const size_t uncompressedBytes)
Convenience wrapper to retrieve the compressed size of buffer when compressed.
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 uint32_t getDataCompression(std::ios_base &)
Return a bitwise OR of compression option flags (COMPRESS_ZIP, COMPRESS_ACTIVE_MASK,...
@ COMPRESS_BLOSC
Definition Compression.h:56
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition Math.h:443
FloatT fixedPointToFloatingPoint(const IntegerT s)
Definition AttributeArray.h:61
IntegerT floatingPointToFixedPoint(const FloatT s)
Definition AttributeArray.h:50
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:2099
void(*)(AttributeArray *array, const Index n, const ValueType &value) SetterPtr
Definition AttributeArray.h:2096
static void set(SetterPtr functor, AttributeArray *array, const Index n, const ValueType &value)
Setter that calls the supplied functor.
Definition AttributeArray.h:2104
ValueType(*)(const AttributeArray *array, const Index n) GetterPtr
Definition AttributeArray.h:2095
Accessor to call unsafe get and set methods based on templated Codec and Value.
Definition AttributeArray.h:2073
void(*)(AttributeArray *array, const Index n, const ValueType &value) SetterPtr
Definition AttributeArray.h:2075
static ValueType get(GetterPtr, const AttributeArray *array, const Index n)
Definition AttributeArray.h:2079
ValueType(*)(const AttributeArray *array, const Index n) GetterPtr
Definition AttributeArray.h:2074
static void set(SetterPtr, AttributeArray *array, const Index n, const ValueType &value)
Definition AttributeArray.h:2085
Accessor base class for AttributeArray storage where type is not available.
Definition AttributeArray.h:415
virtual ~AccessorBase()=default
Definition AttributeArray.h:421
SetterPtr mSetter
Definition AttributeArray.h:430
GetterPtr mGetter
Definition AttributeArray.h:429
void(*)(AttributeArray *array, const T &value) ValuePtr
Definition AttributeArray.h:424
T(*)(const AttributeArray *array, const Index n) GetterPtr
Definition AttributeArray.h:422
void(*)(AttributeArray *array, const Index n, const T &value) SetterPtr
Definition AttributeArray.h:423
ValuePtr mFiller
Definition AttributeArray.h:432
Accessor(GetterPtr getter, SetterPtr setter, ValuePtr collapser, ValuePtr filler)
Definition AttributeArray.h:426
ValuePtr mCollapser
Definition AttributeArray.h:431
Definition AttributeArray.h:513
typename attribute_traits::UIntTypeTrait< OneByte, T >::Type Type
Definition AttributeArray.h:513
Definition AttributeArray.h:511
static const char * name()
Definition AttributeArray.h:518
Definition AttributeArray.h:472
T Type
Definition AttributeArray.h:472
Definition AttributeArray.h:470
static const char * name()
Definition AttributeArray.h:476
Definition AttributeArray.h:493
static ValueType decode(const ValueType &value)
Definition AttributeArray.h:496
static ValueType encode(const ValueType &value)
Definition AttributeArray.h:495
static const char * name()
Definition AttributeArray.h:494
Definition AttributeArray.h:483
typename attribute_traits::TruncateTrait< T >::Type Type
Definition AttributeArray.h:483
Definition AttributeArray.h:481
static const char * name()
Definition AttributeArray.h:487
Definition AttributeArray.h:502
static ValueType decode(const ValueType &value)
Definition AttributeArray.h:505
static ValueType encode(const ValueType &value)
Definition AttributeArray.h:504
static const char * name()
Definition AttributeArray.h:503
Definition AttributeArray.h:530
StorageType Type
Definition AttributeArray.h:530
Definition AttributeArray.h:526
uint16_t StorageType
Definition AttributeArray.h:527
static const char * name()
Definition AttributeArray.h:534
Definition AttributeArray.h:466
short Type
Definition AttributeArray.h:443
Definition AttributeArray.h:441
uint16_t Type
Definition AttributeArray.h:451
uint8_t Type
Definition AttributeArray.h:450
Definition AttributeArray.h:449
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:212