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 std::unique_ptr<StorageType[]> mData;
824 Index mStrideOrTotalSize;
833template <
typename ValueType,
typename CodecType = UnknownCodec>
838 using Ptr = std::shared_ptr<Handle>;
877 friend class ::TestAttributeArray;
879 template <
bool IsUnknownCodec>
880 typename std::enable_if<IsUnknownCodec, bool>::type compatibleType()
const;
882 template <
bool IsUnknownCodec>
883 typename std::enable_if<!IsUnknownCodec, bool>::type compatibleType()
const;
885 template <
bool IsUnknownCodec>
886 typename std::enable_if<IsUnknownCodec, ValueType>::type get(
Index index)
const;
888 template <
bool IsUnknownCodec>
889 typename std::enable_if<!IsUnknownCodec, ValueType>::type get(
Index index)
const;
894 Index mStrideOrTotalSize;
896 bool mCollapseOnDestruction;
904template <
typename ValueType,
typename CodecType = UnknownCodec>
909 using Ptr = std::shared_ptr<Handle>;
939 friend class ::TestAttributeArray;
941 template <
bool IsUnknownCodec>
942 typename std::enable_if<IsUnknownCodec, void>::type set(
Index index,
const ValueType&
value)
const;
944 template <
bool IsUnknownCodec>
945 typename std::enable_if<!IsUnknownCodec, void>::type set(
Index index,
const ValueType&
value)
const;
955template<
typename ValueType>
957NullCodec::decode(
const ValueType& data, ValueType& val)
963template<
typename ValueType>
965NullCodec::encode(
const ValueType& val, ValueType& data)
971template<
typename StorageType,
typename ValueType>
973TruncateCodec::decode(
const StorageType& data, ValueType& val)
975 val =
static_cast<ValueType
>(data);
979template<
typename StorageType,
typename ValueType>
981TruncateCodec::encode(
const ValueType& val, StorageType& data)
983 data =
static_cast<StorageType
>(val);
987template <
bool OneByte,
typename Range>
988template<
typename StorageType,
typename ValueType>
992 val = fixedPointToFloatingPoint<ValueType>(data);
996 val = Range::template decode<ValueType>(val);
1000template <
bool OneByte,
typename Range>
1001template<
typename StorageType,
typename ValueType>
1007 const ValueType newVal = Range::template encode<ValueType>(val);
1009 data = floatingPointToFixedPoint<StorageType>(newVal);
1017 val = math::QuantizedUnitVec::unpack(data);
1025 data = math::QuantizedUnitVec::pack(val);
1033template <
typename IterT>
1034void AttributeArray::doCopyValues(
const AttributeArray& sourceArray,
const IterT& iter,
1040 assert(sourceArray.
isDataLoaded() && this->isDataLoaded());
1042 assert(this->storageTypeSize()*this->stride() ==
1046 const char*
const sourceBuffer = sourceArray.dataAsByteArray();
1047 char*
const targetBuffer = this->dataAsByteArray();
1048 assert(sourceBuffer && targetBuffer);
1050 if (rangeChecking && this->isUniform()) {
1054 const bool sourceIsUniform = sourceArray.
isUniform();
1056 const Index sourceDataSize = rangeChecking ? sourceArray.
dataSize() : 0;
1057 const Index targetDataSize = rangeChecking ? this->dataSize() : 0;
1059 for (IterT it(iter); it; ++it) {
1060 const Index sourceIndex = sourceIsUniform ? 0 : it.sourceIndex();
1061 const Index targetIndex = it.targetIndex();
1063 if (rangeChecking) {
1064 if (sourceIndex >= sourceDataSize) {
1066 "Cannot copy array data as source index exceeds size of source array.");
1068 if (targetIndex >= targetDataSize) {
1070 "Cannot copy array data as target index exceeds size of target array.");
1074 assert(sourceIndex < sourceArray.
dataSize());
1075 assert(targetIndex < this->dataSize());
1076 if (this->isUniform()) assert(targetIndex ==
Index(0));
1079 const size_t targetOffset(targetIndex * bytes);
1080 const size_t sourceOffset(sourceIndex * bytes);
1082 std::memcpy(targetBuffer + targetOffset, sourceBuffer + sourceOffset, bytes);
1086template <
typename IterT>
1087void AttributeArray::copyValuesUnsafe(
const AttributeArray& sourceArray,
const IterT& iter)
1089 this->doCopyValues(sourceArray, iter,
false);
1092template <
typename IterT>
1097 if (bytes != this->storageTypeSize()) {
1114 this->doCopyValues(sourceArray, iter,
true);
1128template<
typename ValueType_,
typename Codec_>
1134 , mStrideOrTotalSize(strideOrTotalSize)
1136 if (constantStride) {
1138 if (strideOrTotalSize == 0) {
1140 "stride to be at least one.")
1145 if (mStrideOrTotalSize < n) {
1147 "a total size of at least the number of elements in the array.")
1150 mSize = std::max(
Index(1), mSize);
1151 mStrideOrTotalSize = std::max(
Index(1), mStrideOrTotalSize);
1152 Codec::encode(uniformValue, this->
data()[0]);
1156template<
typename ValueType_,
typename Codec_>
1163template<
typename ValueType_,
typename Codec_>
1165 const tbb::spin_mutex::scoped_lock& lock)
1168 , mStrideOrTotalSize(rhs.mStrideOrTotalSize)
1172 std::memcpy(
static_cast<void*
>(this->
data()), rhs.
data(), this->arrayMemUsage());
1177template<
typename ValueType_,
typename Codec_>
1178TypedAttributeArray<ValueType_, Codec_>&
1183 tbb::spin_mutex::scoped_lock lock(mMutex);
1184 tbb::spin_mutex::scoped_lock rhsLock(rhs.
mMutex);
1191 mStrideOrTotalSize = rhs.mStrideOrTotalSize;
1194 if (this->validData()) {
1196 std::memcpy(
static_cast<void*
>(this->data()), rhs.
data(), this->arrayMemUsage());
1204template<
typename ValueType_,
typename Codec_>
1209 return NamePair(typeNameAsString<ValueType>(), Codec::name());
1215template<
typename ValueType_,
typename Codec_>
1223template<
typename ValueType_,
typename Codec_>
1231template<
typename ValueType_,
typename Codec_>
1239template<
typename ValueType_,
typename Codec_>
1248 typedMetadata ? typedMetadata->
value() : zeroVal<ValueType>()));
1251template<
typename ValueType_,
typename Codec_>
1261template<
typename ValueType_,
typename Codec_>
1271template<
typename ValueType_,
typename Codec_>
1279#if OPENVDB_ABI_VERSION_NUMBER < 10
1280template<
typename ValueType_,
typename Codec_>
1284 return this->copy();
1288template<
typename ValueType_,
typename Codec_>
1290TypedAttributeArray<ValueType_, Codec_>::arrayMemUsage()
const
1292 if (this->isOutOfCore())
return 0;
1294 return (mIsUniform ? 1 : this->dataSize()) * sizeof(StorageType);
1298template<
typename ValueType_,
typename Codec_>
1300TypedAttributeArray<ValueType_, Codec_>::allocate()
1304 mData.reset(
new StorageType[1]);
1307 const size_t size(this->dataSize());
1309 mData.reset(
new StorageType[size]);
1314template<
typename ValueType_,
typename Codec_>
1316TypedAttributeArray<ValueType_, Codec_>::deallocate()
1319 if (this->isOutOfCore()) {
1320 this->setOutOfCore(
false);
1321 this->mPageHandle.reset();
1323 if (mData) mData.reset();
1327template<
typename ValueType_,
typename Codec_>
1333 if (std::is_same<ValueType, Quats>::value ||
1334 std::is_same<ValueType, Quatd>::value ||
1335 std::is_same<ValueType, Mat3s>::value ||
1336 std::is_same<ValueType, Mat3d>::value ||
1337 std::is_same<ValueType, Mat4s>::value ||
1338 std::is_same<ValueType, Mat4d>::value)
return true;
1343 return std::is_floating_point<ElementT>::value || std::is_same<math::half, ElementT>::value;
1347template<
typename ValueType_,
typename Codec_>
1352 return std::is_class<ValueType>::value && !std::is_same<math::half, ValueType>::value;
1356template<
typename ValueType_,
typename Codec_>
1364template<
typename ValueType_,
typename Codec_>
1369 return !this->valueType().compare(0, 4,
"quat");
1373template<
typename ValueType_,
typename Codec_>
1378 return !this->valueType().compare(0, 3,
"mat");
1382template<
typename ValueType_,
typename Codec_>
1386 return sizeof(*this) + (bool(mData) ? this->arrayMemUsage() : 0);
1389#if OPENVDB_ABI_VERSION_NUMBER >= 10
1390template<
typename ValueType_,
typename Codec_>
1394 return sizeof(*this) + (mIsUniform ? 1 : this->dataSize()) *
sizeof(
StorageType);
1399template<
typename ValueType_,
typename Codec_>
1403 assert(n < this->dataSize());
1406 Codec::decode(this->data()[mIsUniform ? 0 : n], val);
1411template<
typename ValueType_,
typename Codec_>
1416 if (this->isOutOfCore()) this->doLoad();
1418 return this->getUnsafe(n);
1422template<
typename ValueType_,
typename Codec_>
1427 val =
static_cast<T
>(this->getUnsafe(n));
1431template<
typename ValueType_,
typename Codec_>
1436 val =
static_cast<T
>(this->get(n));
1440template<
typename ValueType_,
typename Codec_>
1448template<
typename ValueType_,
typename Codec_>
1452 assert(n < this->dataSize());
1453 assert(!this->isOutOfCore());
1454 assert(!this->isUniform());
1459 Codec::encode(val, this->data()[mIsUniform ? 0 : n]);
1463template<
typename ValueType_,
typename Codec_>
1468 if (this->isOutOfCore()) this->doLoad();
1469 if (this->isUniform()) this->expand();
1471 this->setUnsafe(n, val);
1475template<
typename ValueType_,
typename Codec_>
1480 this->setUnsafe(n,
static_cast<ValueType>(val));
1484template<
typename ValueType_,
typename Codec_>
1489 this->set(n,
static_cast<ValueType>(val));
1493template<
typename ValueType_,
typename Codec_>
1501#if OPENVDB_ABI_VERSION_NUMBER < 10
1502template<
typename ValueType_,
typename Codec_>
1508 ValueType sourceValue;
1509 sourceTypedArray.
get(sourceIndex, sourceValue);
1511 this->set(n, sourceValue);
1516template<
typename ValueType_,
typename Codec_>
1520 if (!mIsUniform)
return;
1525 tbb::spin_mutex::scoped_lock lock(mMutex);
1532 for (
Index i = 0; i < this->dataSize(); ++i) this->data()[i] = val;
1537template<
typename ValueType_,
typename Codec_>
1541 if (mIsUniform)
return true;
1544 const ValueType_ val = this->get(0);
1545 for (
Index i = 1; i < this->dataSize(); i++) {
1549 this->collapse(this->get(0));
1554template<
typename ValueType_,
typename Codec_>
1558 this->collapse(zeroVal<ValueType>());
1562template<
typename ValueType_,
typename Codec_>
1567 tbb::spin_mutex::scoped_lock lock(mMutex);
1572 Codec::encode(uniformValue, this->data()[0]);
1576template<
typename ValueType_,
typename Codec_>
1584template<
typename ValueType_,
typename Codec_>
1588 if (this->isOutOfCore()) {
1589 tbb::spin_mutex::scoped_lock lock(mMutex);
1594 const Index size = mIsUniform ? 1 : this->dataSize();
1595 for (
Index i = 0; i < size; ++i) {
1596 Codec::encode(
value, this->data()[i]);
1601template<
typename ValueType_,
typename Codec_>
1609#if OPENVDB_ABI_VERSION_NUMBER < 10
1610template<
typename ValueType_,
typename Codec_>
1618template<
typename ValueType_,
typename Codec_>
1620TypedAttributeArray<ValueType_, Codec_>::compressUnsafe()
1626template<
typename ValueType_,
typename Codec_>
1628TypedAttributeArray<ValueType_, Codec_>::decompress()
1635template<
typename ValueType_,
typename Codec_>
1643template<
typename ValueType_,
typename Codec_>
1651template<
typename ValueType_,
typename Codec_>
1653TypedAttributeArray<ValueType_, Codec_>::doLoad()
const
1655 if (!(this->isOutOfCore()))
return;
1657 TypedAttributeArray<ValueType_, Codec_>* self =
1658 const_cast<TypedAttributeArray<ValueType_, Codec_>*
>(
this);
1662 tbb::spin_mutex::scoped_lock lock(self->mMutex);
1663 this->doLoadUnsafe();
1667template<
typename ValueType_,
typename Codec_>
1675template<
typename ValueType_,
typename Codec_>
1679 return !this->isOutOfCore();
1683template<
typename ValueType_,
typename Codec_>
1687 this->readMetadata(is);
1688 this->readBuffers(is);
1692template<
typename ValueType_,
typename Codec_>
1699 is.read(
reinterpret_cast<char*
>(&bytes),
sizeof(
Index64));
1700 bytes = bytes -
sizeof(
Int16) -
sizeof(
Index);
1702 uint8_t flags = uint8_t(0);
1703 is.read(
reinterpret_cast<char*
>(&flags),
sizeof(uint8_t));
1706 uint8_t serializationFlags = uint8_t(0);
1707 is.read(
reinterpret_cast<char*
>(&serializationFlags),
sizeof(uint8_t));
1710 is.read(
reinterpret_cast<char*
>(&size),
sizeof(
Index));
1714 if (mFlags >= 0x20) {
1719 if (serializationFlags >= 0x10) {
1725 mIsUniform = serializationFlags & WRITEUNIFORM;
1726 mUsePagedRead = serializationFlags & WRITEPAGED;
1727 mCompressedBytes = bytes;
1728 mFlags |= PARTIALREAD;
1732 if (serializationFlags & WRITESTRIDED) {
1734 is.read(
reinterpret_cast<char*
>(&stride),
sizeof(
Index));
1735 mStrideOrTotalSize = stride;
1738 mStrideOrTotalSize = 1;
1743template<
typename ValueType_,
typename Codec_>
1747 if (mUsePagedRead) {
1752 tbb::spin_mutex::scoped_lock lock(mMutex);
1756 uint8_t bloscCompressed(0);
1757 if (!mIsUniform) is.read(
reinterpret_cast<char*
>(&bloscCompressed),
sizeof(uint8_t));
1759 assert(mFlags & PARTIALREAD);
1760 std::unique_ptr<char[]> buffer(
new char[mCompressedBytes]);
1761 is.read(buffer.get(), mCompressedBytes);
1762 mCompressedBytes = 0;
1763 mFlags =
static_cast<uint8_t
>(mFlags & ~PARTIALREAD);
1767 if (bloscCompressed == uint8_t(1)) {
1771 const size_t inBytes = this->dataSize() *
sizeof(
StorageType);
1773 if (newBuffer) buffer.reset(newBuffer.release());
1778 mData.reset(
reinterpret_cast<StorageType*
>(buffer.release()));
1782template<
typename ValueType_,
typename Codec_>
1786 if (!mUsePagedRead) {
1791#ifdef OPENVDB_USE_DELAYED_LOADING
1794 io::MappedFile::Ptr mappedFile = io::getMappedFilePtr(is.
getInputStream());
1795 const bool delayLoad = (mappedFile.get() !=
nullptr);
1800 size_t compressedBytes(mCompressedBytes);
1801 mCompressedBytes = 0;
1802 mFlags =
static_cast<uint8_t
>(mFlags & ~PARTIALREAD);
1803 assert(!mPageHandle);
1808 assert(mPageHandle);
1810 tbb::spin_mutex::scoped_lock lock(mMutex);
1814#ifdef OPENVDB_USE_DELAYED_LOADING
1815 this->setOutOfCore(delayLoad);
1816 is.
read(mPageHandle, std::streamsize(mPageHandle->size()), delayLoad);
1818 is.
read(mPageHandle, std::streamsize(mPageHandle->size()),
false);
1821#ifdef OPENVDB_USE_DELAYED_LOADING
1824 std::unique_ptr<char[]> buffer = mPageHandle->read();
1825 mData.reset(
reinterpret_cast<StorageType*
>(buffer.release()));
1826 mPageHandle.reset();
1827#ifdef OPENVDB_USE_DELAYED_LOADING
1837template<
typename ValueType_,
typename Codec_>
1841 this->write(os,
false);
1845template<
typename ValueType_,
typename Codec_>
1849 this->writeMetadata(os, outputTransient,
false);
1850 this->writeBuffers(os, outputTransient);
1854template<
typename ValueType_,
typename Codec_>
1858 if (!outputTransient && this->isTransient())
return;
1860 if (mFlags & PARTIALREAD) {
1864 uint8_t flags(mFlags);
1865 uint8_t serializationFlags(0);
1867 Index stride(mStrideOrTotalSize);
1868 bool strideOfOne(this->stride() == 1);
1873 if (bloscCompression) this->doLoad();
1875 size_t compressedBytes = 0;
1879 serializationFlags |= WRITESTRIDED;
1884 serializationFlags |= WRITEUNIFORM;
1885 if (bloscCompression && paged) serializationFlags |= WRITEPAGED;
1887 else if (bloscCompression)
1889 if (paged) serializationFlags |= WRITEPAGED;
1891 const char* charBuffer =
reinterpret_cast<const char*
>(this->data());
1892 const size_t inBytes = this->arrayMemUsage();
1899 bytes += (compressedBytes > 0) ? compressedBytes : this->arrayMemUsage();
1903 os.write(
reinterpret_cast<const char*
>(&bytes),
sizeof(
Index64));
1904 os.write(
reinterpret_cast<const char*
>(&flags),
sizeof(uint8_t));
1905 os.write(
reinterpret_cast<const char*
>(&serializationFlags),
sizeof(uint8_t));
1906 os.write(
reinterpret_cast<const char*
>(&size),
sizeof(
Index));
1909 if (!strideOfOne) os.write(
reinterpret_cast<const char*
>(&stride),
sizeof(
Index));
1913template<
typename ValueType_,
typename Codec_>
1917 if (!outputTransient && this->isTransient())
return;
1919 if (mFlags & PARTIALREAD) {
1925 if (this->isUniform()) {
1926 os.write(
reinterpret_cast<const char*
>(this->data()),
sizeof(
StorageType));
1930 std::unique_ptr<char[]> compressedBuffer;
1931 size_t compressedBytes = 0;
1932 const char* charBuffer =
reinterpret_cast<const char*
>(this->data());
1933 const size_t inBytes = this->arrayMemUsage();
1935 if (compressedBuffer) {
1936 uint8_t bloscCompressed(1);
1937 os.write(
reinterpret_cast<const char*
>(&bloscCompressed),
sizeof(uint8_t));
1938 os.write(
reinterpret_cast<const char*
>(compressedBuffer.get()), compressedBytes);
1941 uint8_t bloscCompressed(0);
1942 os.write(
reinterpret_cast<const char*
>(&bloscCompressed),
sizeof(uint8_t));
1943 os.write(
reinterpret_cast<const char*
>(this->data()), inBytes);
1948 uint8_t bloscCompressed(0);
1949 os.write(
reinterpret_cast<const char*
>(&bloscCompressed),
sizeof(uint8_t));
1950 os.write(
reinterpret_cast<const char*
>(this->data()), this->arrayMemUsage());
1955template<
typename ValueType_,
typename Codec_>
1959 if (!outputTransient && this->isTransient())
return;
1963 if (!bloscCompression) {
1968 if (mFlags & PARTIALREAD) {
1974 os.
write(
reinterpret_cast<const char*
>(this->data()), this->arrayMemUsage());
1978template<
typename ValueType_,
typename Codec_>
1980#if OPENVDB_ABI_VERSION_NUMBER >= 10
1986 if (!(this->isOutOfCore()))
return;
1992 assert(self->mPageHandle);
1993 assert(!(self->mFlags & PARTIALREAD));
1995 std::unique_ptr<char[]> buffer = self->mPageHandle->read();
1997 self->mData.reset(
reinterpret_cast<StorageType*
>(buffer.release()));
1999 self->mPageHandle.reset();
2003 self->mOutOfCore =
false;
2007template<
typename ValueType_,
typename Codec_>
2022template<
typename ValueType_,
typename Codec_>
2027 if(!otherT)
return false;
2028 if(this->mSize != otherT->mSize ||
2029 this->mStrideOrTotalSize != otherT->mStrideOrTotalSize ||
2031 this->attributeType() != this->attributeType())
return false;
2036 const StorageType *target = this->data(), *source = otherT->
data();
2037 if (!target && !source)
return true;
2038 if (!target || !source)
return false;
2039 Index n = this->mIsUniform ? 1 : mSize;
2045template<
typename ValueType_,
typename Codec_>
2047TypedAttributeArray<ValueType_, Codec_>::dataAsByteArray()
2049 return reinterpret_cast<char*
>(this->data());
2053template<
typename ValueType_,
typename Codec_>
2055TypedAttributeArray<ValueType_, Codec_>::dataAsByteArray()
const
2057 return reinterpret_cast<const char*
>(this->data());
2065template <
typename CodecType,
typename ValueType>
2086template <
typename ValueType>
2094 return (*functor)(array, n);
2099 (*functor)(array, n,
value);
2108template <
typename ValueType,
typename CodecType>
2116template <
typename ValueType,
typename CodecType>
2119 , mStrideOrTotalSize(array.hasConstantStride() ? array.stride() : 1)
2120 , mSize(array.hasConstantStride() ? array.size() : array.dataSize())
2121 , mCollapseOnDestruction(collapseOnDestruction && array.isStreaming())
2123 if (!this->compatibleType<std::is_same<CodecType, UnknownCodec>::value>()) {
2144template <
typename ValueType,
typename CodecType>
2148 if (mCollapseOnDestruction)
const_cast<AttributeArray*
>(this->mArray)->collapse();
2151template <
typename ValueType,
typename CodecType>
2152template <
bool IsUnknownCodec>
2153typename std::enable_if<IsUnknownCodec, bool>::type
2158 return mArray->hasValueType<ValueType>();
2161template <
typename ValueType,
typename CodecType>
2162template <
bool IsUnknownCodec>
2163typename std::enable_if<!IsUnknownCodec, bool>::type
2164AttributeHandle<ValueType, CodecType>::compatibleType()
const
2168 return mArray->isType<TypedAttributeArray<ValueType, CodecType>>();
2171template <
typename ValueType,
typename CodecType>
2178template <
typename ValueType,
typename CodecType>
2181 Index index = n * mStrideOrTotalSize + m;
2182 assert(index < (mSize * mStrideOrTotalSize));
2186template <
typename ValueType,
typename CodecType>
2189 return this->get<std::is_same<CodecType, UnknownCodec>::value>(this->index(n, m));
2192template <
typename ValueType,
typename CodecType>
2193template <
bool IsUnknownCodec>
2194typename std::enable_if<IsUnknownCodec, ValueType>::type
2199 return (*mGetter)(mArray, index);
2202template <
typename ValueType,
typename CodecType>
2203template <
bool IsUnknownCodec>
2204typename std::enable_if<!IsUnknownCodec, ValueType>::type
2212template <
typename ValueType,
typename CodecType>
2215 return mArray->isUniform();
2218template <
typename ValueType,
typename CodecType>
2221 return mArray->hasConstantStride();
2228template <
typename ValueType,
typename CodecType>
2236template <
typename ValueType,
typename CodecType>
2243template <
typename ValueType,
typename CodecType>
2246 this->set<std::is_same<CodecType, UnknownCodec>::value>(this->index(n, 0),
value);
2249template <
typename ValueType,
typename CodecType>
2252 this->set<std::is_same<CodecType, UnknownCodec>::value>(this->index(n, m),
value);
2255template <
typename ValueType,
typename CodecType>
2261template <
typename ValueType,
typename CodecType>
2267template <
typename ValueType,
typename CodecType>
2273template <
typename ValueType,
typename CodecType>
2276 this->mCollapser(
const_cast<AttributeArray*
>(this->mArray), uniformValue);
2279template <
typename ValueType,
typename CodecType>
2285template <
typename ValueType,
typename CodecType>
2286template <
bool IsUnknownCodec>
2287typename std::enable_if<IsUnknownCodec, void>::type
2295template <
typename ValueType,
typename CodecType>
2296template <
bool IsUnknownCodec>
2297typename std::enable_if<!IsUnknownCodec, void>::type
2305template <
typename ValueType,
typename CodecType>
2308 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:835
virtual ~AttributeHandle()
Definition AttributeArray.h:2145
Index size() const
Definition AttributeArray.h:857
void(*)(AttributeArray *array, const ValueType &value) ValuePtr
Definition AttributeArray.h:844
SetterPtr mSetter
Definition AttributeArray.h:872
Index stride() const
Definition AttributeArray.h:856
std::shared_ptr< Handle > Ptr
Definition AttributeArray.h:838
GetterPtr mGetter
Definition AttributeArray.h:871
void(*)(AttributeArray *array, const Index n, const ValueType &value) SetterPtr
Definition AttributeArray.h:843
static Ptr create(const AttributeArray &array, const bool collapseOnDestruction=true)
Definition AttributeArray.h:2110
AttributeHandle(const AttributeArray &array, const bool collapseOnDestruction=true)
Definition AttributeArray.h:2117
ValuePtr mFiller
Definition AttributeArray.h:874
ValueType get(Index n, Index m=0) const
Definition AttributeArray.h:2187
ValueType(*)(const AttributeArray *array, const Index n) GetterPtr
Definition AttributeArray.h:842
AttributeHandle(const AttributeHandle &)=default
ValuePtr mCollapser
Definition AttributeArray.h:873
const AttributeArray & array() const
Definition AttributeArray.h:2172
const AttributeArray * mArray
Definition AttributeArray.h:869
bool isUniform() const
Definition AttributeArray.h:2213
std::unique_ptr< Handle > UniquePtr
Definition AttributeArray.h:839
bool hasConstantStride() const
Definition AttributeArray.h:2219
AttributeHandle & operator=(const AttributeHandle &)=default
Index index(Index n, Index m) const
Definition AttributeArray.h:2179
Write-able version of AttributeHandle.
Definition AttributeArray.h:906
virtual ~AttributeWriteHandle()=default
AttributeWriteHandle(AttributeArray &array, const bool expand=true)
Definition AttributeArray.h:2237
std::shared_ptr< Handle > Ptr
Definition AttributeArray.h:909
bool compact()
Compact the existing array to become uniform if all values are identical.
Definition AttributeArray.h:2268
void collapse()
Replace the existing array with a uniform value (zero if none provided).
Definition AttributeArray.h:2262
void set(Index n, const ValueType &value)
Definition AttributeArray.h:2244
void expand(bool fill=true)
If this array is uniform, replace it with an array of length size().
Definition AttributeArray.h:2256
AttributeArray & array()
Definition AttributeArray.h:2306
std::unique_ptr< Handle > ScopedPtr
Definition AttributeArray.h:910
static Ptr create(AttributeArray &array, const bool expand=true)
Definition AttributeArray.h:2230
void set(Index n, Index m, const ValueType &value)
Definition AttributeArray.h:2250
void fill(const ValueType &value)
Fill the existing array with the given value.
Definition AttributeArray.h:2280
void collapse(const ValueType &uniformValue)
Definition AttributeArray.h:2274
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:1392
ValueType getUnsafe(Index n) const
Return the value at index n (assumes in-core)
Definition AttributeArray.h:1401
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:1745
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:2009
void write(std::ostream &os, bool outputTransient) const override
Definition AttributeArray.h:1847
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:1384
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:1129
bool isDataLoaded() const override
Return true if all data has been loaded.
Definition AttributeArray.h:1677
bool isOutOfCore() const
Return true if this buffer's values have not yet been read from disk.
Definition AttributeArray.h:1637
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:1358
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:1539
static TypedAttributeArray & cast(AttributeArray &attributeArray)
Cast an AttributeArray to TypedAttributeArray<T>
Definition AttributeArray.h:1253
TypedAttributeArray & operator=(TypedAttributeArray &&)=delete
Move assignment operator disabled.
void writeBuffers(std::ostream &os, bool outputTransient) const override
Definition AttributeArray.h:1915
AttributeArray::Ptr copy() const override
Definition AttributeArray.h:1273
Index storageTypeSize() const override
Definition AttributeArray.h:639
bool valueTypeIsQuaternion() const override
Return true if the value type is a quaternion.
Definition AttributeArray.h:1366
void readPagedBuffers(compression::PagedInputStream &) override
Read attribute buffers from a paged stream.
Definition AttributeArray.h:1784
void set(Index n, const ValueType &value)
Set value at the given index n.
Definition AttributeArray.h:1465
TypedAttributeArray & operator=(const TypedAttributeArray &)
Definition AttributeArray.h:1179
static void registerType()
Register this attribute type along with a factory function.
Definition AttributeArray.h:1225
bool valueTypeIsFloatingPoint() const override
Return true if the value type is floating point.
Definition AttributeArray.h:1329
void writeMetadata(std::ostream &os, bool outputTransient, bool paged) const override
Definition AttributeArray.h:1856
static void unregisterType()
Remove this attribute type from the registry.
Definition AttributeArray.h:1233
const StorageType * data() const
Definition AttributeArray.h:780
void loadData() const override
Ensures all data is in-core.
Definition AttributeArray.h:1669
void read(std::istream &) override
Read attribute data from a stream.
Definition AttributeArray.h:1685
ValueType get(Index n) const
Return the value at index n.
Definition AttributeArray.h:1413
TypedAttributeArray(TypedAttributeArray &&)=delete
Move constructor disabled.
static const NamePair & attributeType()
Return the name of this attribute's type (includes codec)
Definition AttributeArray.h:1206
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:1349
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:1556
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:1518
static bool isRegistered()
Return true if this attribute type is registered.
Definition AttributeArray.h:1217
bool valueTypeIsMatrix() const override
Return true if the value type is a matrix.
Definition AttributeArray.h:1375
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:1586
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:1241
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:1957
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:1450
void readMetadata(std::istream &) override
Read attribute metadata from a stream.
Definition AttributeArray.h:1694
#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:19
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:247
static ValueType get(GetterPtr functor, const AttributeArray *array, const Index n)
Getter that calls the supplied functor.
Definition AttributeArray.h:2093
void(*)(AttributeArray *array, const Index n, const ValueType &value) SetterPtr
Definition AttributeArray.h:2090
static void set(SetterPtr functor, AttributeArray *array, const Index n, const ValueType &value)
Setter that calls the supplied functor.
Definition AttributeArray.h:2098
ValueType(*)(const AttributeArray *array, const Index n) GetterPtr
Definition AttributeArray.h:2089
Accessor to call unsafe get and set methods based on templated Codec and Value.
Definition AttributeArray.h:2067
void(*)(AttributeArray *array, const Index n, const ValueType &value) SetterPtr
Definition AttributeArray.h:2069
static ValueType get(GetterPtr, const AttributeArray *array, const Index n)
Definition AttributeArray.h:2073
ValueType(*)(const AttributeArray *array, const Index n) GetterPtr
Definition AttributeArray.h:2068
static void set(SetterPtr, AttributeArray *array, const Index n, const ValueType &value)
Definition AttributeArray.h:2079
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