12 #ifndef OPENVDB_POINTS_POINT_DATA_GRID_HAS_BEEN_INCLUDED
13 #define OPENVDB_POINTS_POINT_DATA_GRID_HAS_BEEN_INCLUDED
29 #include <type_traits>
33 class TestPointDataLeaf;
51 const bool seek = destBuf ==
nullptr;
55 if (destBytes >= maximumBytes) {
57 maximumBytes <<
" bytes in voxel values.")
67 bytes16 =
static_cast<uint16_t
>(meta->pass());
69 is.seekg(
sizeof(uint16_t), std::ios_base::cur);
73 is.read(reinterpret_cast<char*>(&bytes16),
sizeof(uint16_t));
79 is.seekg(destBytes, std::ios_base::cur);
82 is.read(reinterpret_cast<char*>(destBuf), destBytes);
88 is.seekg(
int(bytes16), std::ios_base::cur);
92 std::unique_ptr<char[]> bloscBuffer(
new char[
int(bytes16)]);
93 is.read(bloscBuffer.get(), bytes16);
97 std::memcpy(destBuf, buffer.get(), destBytes);
114 if (srcBytes >= maximumBytes) {
116 maximumBytes <<
" bytes in voxel values.")
119 const char* charBuffer =
reinterpret_cast<const char*
>(srcBuf);
121 size_t compressedBytes;
123 compressedBytes,
false);
125 if (compressedBytes > 0) {
126 auto bytes16 =
static_cast<uint16_t
>(compressedBytes);
127 os.write(reinterpret_cast<const char*>(&bytes16),
sizeof(uint16_t));
128 os.write(reinterpret_cast<const char*>(buffer.get()), compressedBytes);
131 auto bytes16 =
static_cast<uint16_t
>(maximumBytes);
132 os.write(reinterpret_cast<const char*>(&bytes16),
sizeof(uint16_t));
133 os.write(reinterpret_cast<const char*>(srcBuf), srcBytes);
137 template <
typename T>
143 const size_t srcBytes = srcCount*
sizeof(
T);
145 if (srcBytes >= maximumBytes) {
147 maximumBytes <<
" bytes in voxel values.")
150 const char* charBuffer =
reinterpret_cast<const char*
>(srcBuf);
155 if (compressedBytes > 0) {
156 auto bytes16 =
static_cast<uint16_t
>(compressedBytes);
157 os.write(reinterpret_cast<const char*>(&bytes16),
sizeof(uint16_t));
160 auto bytes16 =
static_cast<uint16_t
>(maximumBytes);
161 os.write(reinterpret_cast<const char*>(&bytes16),
sizeof(uint16_t));
186 #ifndef OPENVDB_DISABLE_POINT_DATA_TREE_ALIAS
205 template <
typename Po
intDataTreeT>
206 inline AttributeSet::Descriptor::Ptr
219 template <
typename Po
intDataTreeT>
230 template <
typename Po
intDataTreeT>
232 prefetch(PointDataTreeT& tree,
bool position =
true,
bool otherAttributes =
true);
238 template <
typename T, Index Log2Dim>
243 using Ptr = std::shared_ptr<PointDataLeafNode>;
259 using BaseLeaf::LOG2DIM;
260 using BaseLeaf::TOTAL;
262 using BaseLeaf::NUM_VALUES;
263 using BaseLeaf::NUM_VOXELS;
265 using BaseLeaf::LEVEL;
276 , mAttributeSet(new
AttributeSet(*other.mAttributeSet)) { }
287 const T&
value = zeroVal<T>(),
bool active =
false)
295 template<
typename OtherValueType>
302 template <
typename ValueType>
309 template <
typename ValueType>
315 const T&
value = zeroVal<T>(),
bool active =
false)
350 const size_t pos,
const Index strideOrTotalSize = 1,
351 const bool constantStride =
true,
360 const Descriptor& expected, Descriptor::Ptr& replacement);
438 template<
typename OtherType, Index OtherLog2Dim>
440 return BaseLeaf::hasSameTopology(other);
446 if(BaseLeaf::operator==(other) !=
true)
return false;
447 return (*this->mAttributeSet == *other.mAttributeSet);
453 template<
typename AccessorT>
459 template<
typename AccessorT>
462 template<
typename NodeT,
typename AccessorT>
467 return reinterpret_cast<NodeT*
>(
this);
471 template<
typename AccessorT>
478 template<
typename AccessorT>
480 template<
typename AccessorT>
483 template<
typename NodeT,
typename AccessorT>
488 return reinterpret_cast<const NodeT*
>(
this);
495 void readTopology(std::istream& is,
bool fromHalf =
false);
496 void writeTopology(std::ostream& os,
bool toHalf =
false)
const;
500 void readBuffers(std::istream& is,
bool fromHalf =
false);
502 void writeBuffers(std::ostream& os,
bool toHalf =
false)
const;
506 #if OPENVDB_ABI_VERSION_NUMBER >= 10
522 assert(
false &&
"Cannot modify voxel values in a PointDataTree.");
532 void setActiveState(
const Coord& xyz,
bool on) { BaseLeaf::setActiveState(xyz, on); }
538 void setValueOff(
const Coord& xyz) { BaseLeaf::setValueOff(xyz); }
544 void setValueOn(
const Coord& xyz) { BaseLeaf::setValueOn(xyz); }
555 template<
typename ModifyOp>
558 template<
typename ModifyOp>
561 template<
typename ModifyOp>
571 template<
typename AccessorT>
574 template<
typename ModifyOp,
typename AccessorT>
579 template<
typename AccessorT>
582 template<
typename AccessorT>
584 BaseLeaf::setActiveStateAndCache(xyz, on, parent);
596 friend class ::TestPointDataLeaf;
604 uint16_t mVoxelBufferSize = 0;
663 return this->beginIndex<ValueAllCIter, NullFilter>(
filter);
668 return this->beginIndex<ValueOnCIter, NullFilter>(
filter);
673 return this->beginIndex<ValueOffCIter, NullFilter>(
filter);
676 template<
typename IterT,
typename FilterT>
680 template<
typename FilterT>
683 return this->beginIndex<ValueAllCIter, FilterT>(
filter);
685 template<
typename FilterT>
688 return this->beginIndex<ValueOnCIter, FilterT>(
filter);
690 template<
typename FilterT>
693 return this->beginIndex<ValueOffCIter, FilterT>(
filter);
700 template<
typename FilterT>
703 #define VMASK_ this->getValueMask()
750 template<
typename T, Index Log2Dim>
759 template<
typename T, Index Log2Dim>
764 if (descriptor->size() != 1 ||
768 OPENVDB_THROW(IndexError,
"Initializing attributes only allowed with one Vec3f position attribute.");
771 mAttributeSet.reset(
new AttributeSet(descriptor, arrayLength, lock));
774 template<
typename T, Index Log2Dim>
779 mAttributeSet.reset(
new AttributeSet(*mAttributeSet, 0, lock));
787 if (updateValueMask) this->setValuesOff();
790 template<
typename T, Index Log2Dim>
794 return pos < mAttributeSet->size();
797 template<
typename T, Index Log2Dim>
801 const size_t pos = mAttributeSet->find(attributeName);
805 template<
typename T, Index Log2Dim>
808 const size_t pos,
const Index strideOrTotalSize,
809 const bool constantStride,
813 return mAttributeSet->appendAttribute(
814 expected, replacement, pos, strideOrTotalSize, constantStride, metadata, lock);
817 template<
typename T, Index Log2Dim>
820 const Descriptor& expected, Descriptor::Ptr& replacement)
822 mAttributeSet->dropAttributes(pos, expected, replacement);
825 template<
typename T, Index Log2Dim>
829 mAttributeSet->reorderAttributes(replacement);
832 template<
typename T, Index Log2Dim>
836 mAttributeSet->renameAttributes(expected, replacement);
839 template<
typename T, Index Log2Dim>
843 for (
size_t i = 0; i < mAttributeSet->size(); i++) {
849 template<
typename T, Index Log2Dim>
854 OPENVDB_THROW(ValueError,
"Cannot replace with a null attribute set");
857 if (!allowMismatchingDescriptors && mAttributeSet->descriptor() != attributeSet->
descriptor()) {
858 OPENVDB_THROW(ValueError,
"Attribute set descriptors are not equal.");
861 mAttributeSet.reset(attributeSet);
864 template<
typename T, Index Log2Dim>
868 mAttributeSet->resetDescriptor(replacement);
871 template<
typename T, Index Log2Dim>
875 if (offsets.size() != LeafNodeType::NUM_VALUES) {
876 OPENVDB_THROW(ValueError,
"Offset vector size doesn't match number of voxels.")
883 if (updateValueMask) this->updateValueMask();
886 template<
typename T, Index Log2Dim>
893 OPENVDB_THROW(ValueError,
"Voxel offset values are not monotonically increasing");
898 for (
size_t attributeIndex = 1; attributeIndex < mAttributeSet->size(); ++attributeIndex ) {
899 if (mAttributeSet->getConst(attributeIndex-1)->size() != mAttributeSet->getConst(attributeIndex)->size()) {
900 OPENVDB_THROW(ValueError,
"Attribute arrays have inconsistent length");
905 if (mAttributeSet->size() > 0 && this->
getValue(BaseLeaf::SIZE-1) != mAttributeSet->getConst(0)->size()) {
906 OPENVDB_THROW(ValueError,
"Last voxel offset value does not match attribute array length");
910 template<
typename T, Index Log2Dim>
914 if (pos >= mAttributeSet->size())
OPENVDB_THROW(LookupError,
"Attribute Out Of Range - " << pos);
915 return *mAttributeSet->get(pos);
918 template<
typename T, Index Log2Dim>
922 if (pos >= mAttributeSet->size())
OPENVDB_THROW(LookupError,
"Attribute Out Of Range - " << pos);
923 return *mAttributeSet->getConst(pos);
926 template<
typename T, Index Log2Dim>
930 return this->attributeArray(pos);
933 template<
typename T, Index Log2Dim>
937 const size_t pos = mAttributeSet->find(attributeName);
939 return *mAttributeSet->get(pos);
942 template<
typename T, Index Log2Dim>
946 const size_t pos = mAttributeSet->find(attributeName);
948 return *mAttributeSet->getConst(pos);
951 template<
typename T, Index Log2Dim>
955 return this->attributeArray(attributeName);
958 template<
typename T, Index Log2Dim>
970 template<
typename T, Index Log2Dim>
974 const AttributeSet::Descriptor::GroupIndex
index = this->attributeSet().groupIndex(name);
975 return this->groupHandle(index);
978 template<
typename T, Index Log2Dim>
990 template<
typename T, Index Log2Dim>
994 const AttributeSet::Descriptor::GroupIndex
index = this->attributeSet().groupIndex(name);
995 return this->groupWriteHandle(index);
998 template<
typename T, Index Log2Dim>
999 template<
typename ValueIterT,
typename FilterT>
1011 FilterT newFilter(filter);
1012 newFilter.reset(*
this);
1023 template<
typename T, Index Log2Dim>
1027 const Index index = LeafNodeType::coordToOffset(ijk);
1034 template<
typename T, Index Log2Dim>
1042 template<
typename T, Index Log2Dim>
1043 template<
typename FilterT>
1048 FilterT newFilter(filter);
1049 newFilter.reset(*
this);
1053 template<
typename T, Index Log2Dim>
1057 return this->getLastValue();
1060 template<
typename T, Index Log2Dim>
1064 if (this->isEmpty())
return 0;
1065 else if (this->isDense())
return this->
pointCount();
1069 template<
typename T, Index Log2Dim>
1073 if (this->isEmpty())
return this->
pointCount();
1074 else if (this->isDense())
return 0;
1075 return iterCount(this->beginIndexOff());
1078 template<
typename T, Index Log2Dim>
1082 if (!this->attributeSet().descriptor().hasGroup(groupName)) {
1089 return iterCount(this->beginIndexAll(filter));
1093 template<
typename T, Index Log2Dim>
1098 for (
Index n = 0;
n < LeafNodeType::NUM_VALUES;
n++) {
1100 this->setValueMask(
n, (
end - start) > 0);
1105 template<
typename T, Index Log2Dim>
1109 this->
buffer().setValue(offset, val);
1110 this->setValueMaskOn(offset);
1113 template<
typename T, Index Log2Dim>
1117 this->
buffer().setValue(offset, val);
1120 template<
typename T, Index Log2Dim>
1124 BaseLeaf::readTopology(is, fromHalf);
1127 template<
typename T, Index Log2Dim>
1131 BaseLeaf::writeTopology(os, toHalf);
1134 template<
typename T, Index Log2Dim>
1141 mAttributeSet->size() +
1142 mAttributeSet->size() +
1146 template<
typename T, Index Log2Dim>
1150 this->readBuffers(is, CoordBBox::inf(), fromHalf);
1153 template<
typename T, Index Log2Dim>
1163 auto it = auxData.find(key);
1164 if (it != auxData.end()) {
1173 auto it = auxData.find(key);
1174 if (it != auxData.end()) {
1180 return *pagedStream;
1187 auto itMatching = auxData.find(matchingKey);
1188 return itMatching != auxData.end();
1195 auto itMatching = auxData.find(matchingKey);
1196 auto itDescriptor = auxData.find(descriptorKey);
1197 if (itMatching != auxData.end()) (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(itMatching);
1198 if (itDescriptor != auxData.end()) (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(itDescriptor);
1202 const Descriptor::Ptr descriptor)
1206 auto itMatching = auxData.find(matchingKey);
1207 if (itMatching == auxData.end()) {
1217 auto itDescriptor = auxData.find(descriptorKey);
1218 assert(itDescriptor != auxData.end());
1219 const Descriptor::Ptr descriptor = std::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
1227 OPENVDB_THROW(IoError,
"Cannot read in a PointDataLeaf without StreamMetadata.");
1230 const Index pass(static_cast<uint16_t>(meta->pass()));
1231 const Index maximumPass(static_cast<uint16_t>(meta->pass() >> 16));
1233 const Index attributes = (maximumPass - 4) / 2;
1237 is.read(reinterpret_cast<char*>(&mVoxelBufferSize),
sizeof(uint16_t));
1238 Local::clearMatchingDescriptor(meta->auxData());
1240 else if (pass == 1) {
1242 if (Local::hasMatchingDescriptor(meta->auxData())) {
1243 AttributeSet::Descriptor::Ptr descriptor = Local::retrieveMatchingDescriptor(meta->auxData());
1244 mAttributeSet->resetDescriptor(descriptor,
true);
1248 is.read(reinterpret_cast<char*>(&header),
sizeof(uint8_t));
1249 mAttributeSet->readDescriptor(is);
1250 if (header & uint8_t(1)) {
1252 Local::insertDescriptor(meta->auxData(), descriptor);
1256 if (header & uint8_t(2)) {
1257 uint64_t bytesToSkip;
1258 is.read(reinterpret_cast<char*>(&bytesToSkip),
sizeof(uint64_t));
1259 if (bytesToSkip > uint64_t(0)) {
1261 if (metadata && metadata->seekable()) {
1262 is.seekg(bytesToSkip, std::ios_base::cur);
1265 std::vector<uint8_t> tempData(bytesToSkip);
1266 is.read(reinterpret_cast<char*>(&tempData[0]), bytesToSkip);
1271 if (header > uint8_t(3)) {
1272 OPENVDB_THROW(IoError,
"Unrecognised header flags in PointDataLeafNode");
1275 mAttributeSet->readMetadata(is);
1277 else if (pass < (attributes + 2)) {
1279 const size_t attributeIndex = pass - 2;
1281 mAttributeSet->get(attributeIndex) :
nullptr;
1284 Local::getOrInsertPagedStream(meta->auxData(),
static_cast<Index>(attributeIndex));
1290 else if (pass == attributes + 2) {
1293 const Index passValue(meta->pass());
1297 nonConstMeta.
setPass(mVoxelBufferSize);
1300 BaseLeaf::readBuffers(is, fromHalf);
1303 nonConstMeta.setPass(passValue);
1305 else if (pass < (attributes*2 + 3)) {
1307 const Index attributeIndex = pass - attributes - 3;
1309 mAttributeSet->get(attributeIndex) :
nullptr;
1312 Local::getOrInsertPagedStream(meta->auxData(), attributeIndex);
1318 if (pass > attributes + 3) {
1319 Local::destroyPagedStream(meta->auxData(), attributeIndex-1);
1324 const Index attributeIndex = pass - attributes - 4;
1325 Local::destroyPagedStream(meta->auxData(), attributeIndex);
1329 template<
typename T, Index Log2Dim>
1339 auto it = auxData.find(key);
1340 if (it != auxData.end()) {
1351 auto it = auxData.find(key);
1352 if (it != auxData.end()) {
1358 return *pagedStream;
1363 const Descriptor::Ptr descriptor)
1367 auto itMatching = auxData.find(matchingKey);
1368 auto itDescriptor = auxData.find(descriptorKey);
1369 if (itMatching == auxData.end()) {
1372 assert(itDescriptor == auxData.end());
1377 bool matching = std::any_cast<
bool>(itMatching->second);
1378 if (!matching)
return;
1379 assert(itDescriptor != auxData.end());
1382 const Descriptor::Ptr existingDescriptor = std::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
1383 if (*existingDescriptor != *descriptor) {
1392 auto itMatching = auxData.find(matchingKey);
1394 if (itMatching == auxData.end())
return false;
1396 if (!std::any_cast<bool>(itMatching->second))
return false;
1403 auto itDescriptor = auxData.find(descriptorKey);
1405 if (itDescriptor == auxData.end())
return nullptr;
1407 const Descriptor::Ptr descriptor = std::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
1416 auto itMatching = auxData.find(matchingKey);
1417 auto itDescriptor = auxData.find(descriptorKey);
1418 if (itMatching != auxData.end()) (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(itMatching);
1419 if (itDescriptor != auxData.end()) (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(itDescriptor);
1426 OPENVDB_THROW(IoError,
"Cannot write out a PointDataLeaf without StreamMetadata.");
1429 const Index pass(static_cast<uint16_t>(meta->pass()));
1434 if (meta->countingPasses()) {
1436 if (requiredPasses > pass) {
1437 meta->setPass(requiredPasses);
1442 const Index maximumPass(static_cast<uint16_t>(meta->pass() >> 16));
1443 const Index attributes = (maximumPass - 4) / 2;
1449 Local::insertDescriptor(meta->auxData(), mAttributeSet->descriptorPtr());
1451 else if (pass == 1) {
1453 bool matchingDescriptor = Local::hasMatchingDescriptor(meta->auxData());
1454 if (matchingDescriptor) {
1455 AttributeSet::Descriptor::Ptr descriptor = Local::retrieveMatchingDescriptor(meta->auxData());
1459 os.write(reinterpret_cast<const char*>(&header),
sizeof(uint8_t));
1460 mAttributeSet->writeDescriptor(os,
false);
1466 os.write(reinterpret_cast<const char*>(&header),
sizeof(uint8_t));
1467 mAttributeSet->writeDescriptor(os,
false);
1469 mAttributeSet->writeMetadata(os,
false,
true);
1471 else if (pass < attributes + 2) {
1473 const Index attributeIndex = pass - 2;
1476 Local::destroyPagedStream(meta->auxData(), attributeIndex-1);
1479 mAttributeSet->getConst(attributeIndex) :
nullptr;
1482 Local::getOrInsertPagedStream(meta->auxData(), attributeIndex);
1488 else if (pass == attributes + 2) {
1489 const Index attributeIndex = pass - 3;
1490 Local::destroyPagedStream(meta->auxData(), attributeIndex);
1492 BaseLeaf::writeBuffers(os, toHalf);
1494 else if (pass < (attributes*2 + 3)) {
1496 const Index attributeIndex = pass - attributes - 3;
1498 if (pass > attributes + 2) {
1499 Local::destroyPagedStream(meta->auxData(), attributeIndex-1);
1502 mAttributeSet->getConst(attributeIndex) :
nullptr;
1505 Local::getOrInsertPagedStream(meta->auxData(), attributeIndex);
1512 Local::clearMatchingDescriptor(meta->auxData());
1514 const Index attributeIndex = pass - attributes - 4;
1515 Local::destroyPagedStream(meta->auxData(), attributeIndex);
1519 template<
typename T, Index Log2Dim>
1523 return BaseLeaf::memUsage() + mAttributeSet->memUsage();
1526 #if OPENVDB_ABI_VERSION_NUMBER >= 10
1527 template<
typename T, Index Log2Dim>
1535 template<
typename T, Index Log2Dim>
1539 BaseLeaf::evalActiveBoundingBox(bbox, visitVoxels);
1542 template<
typename T, Index Log2Dim>
1546 return BaseLeaf::getNodeBoundingBox();
1549 template<
typename T, Index Log2Dim>
1553 if (!this->allocate())
return;
1555 this->assertNonModifiableUnlessZero(value);
1559 for (
Int32 x = bbox.min().x();
x <= bbox.max().x(); ++
x) {
1560 const Index offsetX = (
x & (DIM-1u)) << 2*Log2Dim;
1561 for (
Int32 y = bbox.min().y();
y <= bbox.max().y(); ++
y) {
1562 const Index offsetXY = offsetX + ((
y & (DIM-1u)) << Log2Dim);
1563 for (
Int32 z = bbox.min().z();
z <= bbox.max().z(); ++
z) {
1565 this->setValueMask(offset, active);
1571 template<
typename T, Index Log2Dim>
1575 this->assertNonModifiableUnlessZero(value);
1579 if (active) this->setValuesOn();
1580 else this->setValuesOff();
1587 template <
typename Po
intDataTreeT>
1588 inline AttributeSet::Descriptor::Ptr
1591 auto leafIter = tree.beginLeaf();
1592 if (!leafIter)
return nullptr;
1595 auto newDescriptor = std::make_shared<AttributeSet::Descriptor>(descriptor);
1596 for (; leafIter; ++leafIter) {
1597 leafIter->resetDescriptor(newDescriptor);
1600 return newDescriptor;
1604 template <
typename Po
intDataTreeT>
1608 auto leafIter = tree.beginLeaf();
1609 for (; leafIter; ++leafIter) {
1610 for (
size_t i = 0; i < leafIter->attributeSet().size(); i++) {
1611 leafIter->attributeArray(i).setStreaming(on);
1617 template <
typename Po
intDataTreeT>
1624 auto leaf = tree.cbeginLeaf();
1627 const auto& attributeSet = leaf->attributeSet();
1631 for ( ; leaf; ++leaf) {
1632 leaf->buffer().data();
1637 size_t positionIndex = attributeSet.find(
"P");
1640 for (leaf = tree.cbeginLeaf(); leaf; ++leaf) {
1641 assert(leaf->hasAttribute(positionIndex));
1642 leaf->constAttributeArray(positionIndex).loadData();
1648 if (otherAttributes) {
1649 const size_t attributes = attributeSet.size();
1650 for (
size_t attributeIndex = 0; attributeIndex < attributes; attributeIndex++) {
1651 if (attributeIndex == positionIndex)
continue;
1652 for (leaf = tree.cbeginLeaf(); leaf; ++leaf) {
1653 assert(leaf->hasAttribute(attributeIndex));
1654 leaf->constAttributeArray(attributeIndex).loadData();
1661 namespace internal {
1678 template<
typename HeadT,
int HeadLevel>
1683 using Type =
typename SubtreeT::template Append<RootNodeT>;
1688 template <
typename ChildT, Index Log2Dim,
int HeadLevel>
1693 using Type =
typename SubtreeT::template Append<InternalNodeT>;
1698 template <
typename ChildT, Index Log2Dim>
1712 template <
typename TreeType>
1731 template<Index Dim1,
typename T2>
1738 #endif // OPENVDB_POINTS_POINT_DATA_GRID_HAS_BEEN_INCLUDED
void modifyValueAndActiveStateAndCache(const Coord &, const ModifyOp &, AccessorT &)
void initializeAttributes(const Descriptor::Ptr &descriptor, const Index arrayLength, const AttributeArray::ScopedRegistryLock *lock=nullptr)
Create a new attribute set. Existing attributes will be removed.
PointIndex< Index32, 1 > PointDataIndex32
Index64 onPointCount() const
Compute the total active (on) point count for the leaf.
AttributeSet::Descriptor::Ptr makeDescriptorUnique(PointDataTreeT &tree)
Deep copy the descriptor across all leaf nodes.
Index64 memUsageIfLoaded() const
ValueOnCIter beginValueOn() const
AttributeSet::UniquePtr stealAttributeSet()
Steal the attribute set, a new, empty attribute set is inserted in it's place.
typename BaseLeaf::ValueOn ValueOn
void setValue(const Coord &, const ValueType &)
Leaf nodes have no children, so their child iterators have no get/set accessors.
std::vector< ValueType > IndexArray
Descriptor & descriptor()
Return a reference to this attribute set's descriptor, which might be shared with other sets...
bool operator!=(const PointDataLeafNode &other) const
std::shared_ptr< Descriptor > DescriptorPtr
virtual void readPagedBuffers(compression::PagedInputStream &)=0
Read attribute buffers from a paged stream.
typename BaseLeaf::template DenseIter< const PointDataLeafNode, const ValueType, ChildAll > ChildAllCIter
PointDataLeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
ValueAllCIter cendValueAll() const
GLdouble GLdouble GLint GLint const GLdouble * points
const PointDataLeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a pointer to this node.
void assertNonModifiableUnlessZero(const ValueType &value)
IndexVoxelIter beginIndexVoxel(const Coord &ijk) const
Leaf index iterator from voxel.
typename BaseLeaf::template ValueIter< MaskOffIterator, PointDataLeafNode, const ValueType, ValueOff > ValueOffIter
void modifyValueAndActiveState(const Coord &, const ModifyOp &)
PointDataLeafNode(const tree::LeafNode< ValueType, Log2Dim > &other, const T &value, TopologyCopy)
void setOffsets(const std::vector< ValueType > &offsets, const bool updateValueMask=true)
Sets all of the voxel offset values on this leaf, from the given vector of offsets. If updateValueMask is true, then the active value mask will be updated so voxels with points are active and empty voxels are inactive.
void modifyValue(const Coord &, const ModifyOp &)
GroupWriteHandle groupWriteHandle(const AttributeSet::Descriptor::GroupIndex &index)
Read-write group handle from group index.
bool hasSameTopology(const PointDataLeafNode< OtherType, OtherLog2Dim > *other) const
Return true if the given node (which may have a different ValueType than this node) has the same acti...
ValueOffIter endValueOff()
void swap(UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &a, UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &b)
void setValueOff(const Coord &, const ValueType &)
ChildAllIter beginChildAll()
void setValueOnly(Index, const ValueType &)
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
void writeCompressedValues(std::ostream &os, ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
void renameAttributes(const Descriptor &expected, Descriptor::Ptr &replacement)
Rename attributes in attribute set (order must remain the same).
void writeTopology(std::ostream &os, bool toHalf=false) const
void dropAttributes(const std::vector< size_t > &pos, const Descriptor &expected, Descriptor::Ptr &replacement)
Drop list of attributes.
void prefetch(PointDataTreeT &tree, bool position=true, bool otherAttributes=true)
Sequentially pre-fetch all delayed-load voxel and attribute data from disk in order to accelerate sub...
ValueOffIter beginValueOff()
void addLeaf(PointDataLeafNode *)
void setValueOff(const Coord &xyz)
~PointDataLeafNode()=default
void setActiveState(Index offset, bool on)
bool hasAttribute(const size_t pos) const
Returns true if an attribute with this index exists.
typename BaseLeaf::template ValueIter< MaskOnIterator, PointDataLeafNode, const ValueType, ValueOn > ValueOnIter
PointDataLeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
GLdouble GLdouble GLdouble z
void validateOffsets() const
Throws an error if the voxel values on this leaf are not monotonically increasing or within the bound...
ValueOffCIter cbeginValueOff() const
Leaf nodes that require multi-pass I/O must inherit from this struct.
void updateValueMask()
Activate voxels with non-zero points, deactivate voxels with zero points.
PointDataLeafNode * touchLeaf(const Coord &)
Return a pointer to this node.
ChildOnIter beginChildOn()
ValueOnIter beginValueOn()
typename BaseLeaf::template ChildIter< MaskOnIterator, const PointDataLeafNode, ChildOn > ChildOnCIter
void setSizeOnly(bool sizeOnly)
Size-only mode tags the stream as only reading size data.
typename BaseLeaf::template ValueIter< MaskDenseIterator, const PointDataLeafNode, const ValueType, ValueAll > ValueAllCIter
typename internal::PointDataNodeChain< RootNodeT, RootNodeT::LEVEL >::Type NodeChainT
#define OPENVDB_USE_VERSION_NAMESPACE
typename BaseLeaf::template ChildIter< MaskOffIterator, const PointDataLeafNode, ChildOff > ChildOffCIter
ValueOffCIter beginValueOff() const
IndexIter< IterT, FilterT > beginIndex(const FilterT &filter) const
void assertNonmodifiable()
void readBuffers(std::istream &is, bool fromHalf=false)
Base class for iterators over internal and leaf nodes.
const PointDataLeafNode * probeLeaf(const Coord &) const
Return a pointer to this node.
void signedFloodFill(const ValueType &, const ValueType &)
typename BaseLeaf::template DenseIter< PointDataLeafNode, ValueType, ChildAll > ChildAllIter
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
void initialize()
Global registration of point data-related types.
A Paging wrapper to std::istream that is responsible for reading from a given input stream and creati...
A no-op filter that can be used when iterating over all indices.
void setValueOn(Index, const ValueType &)
Tag dispatch class that distinguishes constructors during file input.
virtual void writePagedBuffers(compression::PagedOutputStream &, bool outputTransient) const =0
void readTopology(std::istream &is, bool fromHalf=false)
ChildAllCIter beginChildAll() const
PointDataLeafNode(const tree::LeafNode< ValueType, Log2Dim > &other, const T &, const T &, TopologyCopy)
typename SubtreeT::template Append< RootNodeT > Type
void setSizeOnly(bool sizeOnly)
Size-only mode tags the stream as only writing size data.
typename TreeType::RootNodeType RootNodeT
AttributeSet::Descriptor Descriptor
bool isGroup(const AttributeArray &array)
__hostdev__ float getValue(uint32_t i) const
ChildAllCIter cendChildAll() const
GLuint GLsizei const GLuint const GLintptr * offsets
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
ValueOnCIter cbeginValueOn() const
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a pointer to this node.
PointDataLeafNode(const Coord &coords, const T &value=zeroVal< T >(), bool active=false)
Construct using supplied origin, value and active status.
const PointDataLeafNode * probeConstLeaf(const Coord &) const
Return a pointer to this node.
typename BaseLeaf::template ChildIter< MaskOffIterator, PointDataLeafNode, ChildOff > ChildOffIter
void compactAttributes()
Compact all attributes in attribute set.
constexpr T zeroVal()
Return the value of type T that corresponds to zero.
IndexIter< ValueAllCIter, FilterT > beginIndexAll(const FilterT &filter) const
Filtered leaf index iterator.
ChildAllCIter endChildAll() const
const char * typeNameAsString< Vec3f >()
static index::State state()
IndexOffIter beginIndexOff() const
void setValueOff(Index offset)
ChildOffIter endChildOff()
Base class for storing attribute data.
typename NodeMaskType::OffIterator MaskOffIterator
void setInputStream(std::istream &is)
typename PointDataNodeChain< typename HeadT::ChildNodeType, HeadLevel-1 >::Type SubtreeT
SYS_FORCE_INLINE const X * cast(const InstancablePtr *o)
IndexIter< ValueVoxelCIter, NullFilter > IndexVoxelIter
size_t writeCompressedValuesSize(ValueT *srcBuf, Index srcCount, const MaskT &valueMask, uint8_t maskMetadata, bool toHalf, uint32_t compress)
A forward iterator over array indices in a single voxel.
void setActiveStateAndCache(const Coord &xyz, bool on, AccessorT &parent)
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
PointDataLeafNode()
Default constructor.
void setStreamingMode(PointDataTreeT &tree, bool on=true)
Toggle the streaming mode on all attributes in the tree to collapse the attributes after deconstructi...
const PointDataLeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a pointer to this node.
void uninitialize()
Global deregistration of point data-related types.
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
IndexAllIter beginIndexAll() const
Leaf index iterator.
void clearAttributes(const bool updateValueMask=true, const AttributeArray::ScopedRegistryLock *lock=nullptr)
Clear the attribute set.
bool operator==(const PointDataLeafNode &other) const
Attribute array storage for string data using Descriptor Metadata.
typename BaseLeaf::template ValueIter< MaskOnIterator, const PointDataLeafNode, const ValueType, ValueOn > ValueOnCIter
typename BaseLeaf::template ChildIter< MaskOnIterator, PointDataLeafNode, ChildOn > ChildOnIter
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...
void clip(const CoordBBox &, const ValueType &value)
std::shared_ptr< AttributeArray > Ptr
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
AttributeArray::Ptr appendAttribute(const Descriptor &expected, Descriptor::Ptr &replacement, const size_t pos, const Index strideOrTotalSize=1, const bool constantStride=true, const Metadata *metadata=nullptr, const AttributeArray::ScopedRegistryLock *lock=nullptr)
Append an attribute to the leaf.
void signedFloodFill(const ValueType &)
void setValueOnly(const Coord &, const ValueType &)
void setOffsetOn(Index offset, const ValueType &val)
Convenience wrappers to using Blosc and reading and writing of Paged data.
ValueAllCIter cbeginValueAll() const
virtual Index size() const =0
ChildOffIter beginChildOff()
Recursive node chain which generates a openvdb::TypeList value converted types of nodes to PointDataG...
Index64 pointCount(const PointDataTreeT &tree, const FilterT &filter, const bool inCoreOnly, const bool threaded)
Count the total number of points in a PointDataTree.
GLuint const GLchar * name
A forward iterator over array indices with filtering IteratorT can be either IndexIter or ValueIndexI...
Index64 offPointCount() const
Compute the total inactive (off) point count for the leaf.
std::pair< ValueType, ValueType > ValueTypePair
typename BaseLeaf::ChildAll ChildAll
ChildOnCIter cendChildOn() const
void setValueOffAndCache(const Coord &, const ValueType &, AccessorT &)
void reorderAttributes(const Descriptor::Ptr &replacement)
Reorder attribute set.
PointDataLeafNode(const PointDataLeafNode &other, const Coord &coords, const T &value=zeroVal< T >(), bool active=false)
Index filtering on group membership.
typename SubtreeT::template Append< InternalNodeT > Type
Container class that associates a tree with a transform and metadata.
that also have some descendant prim *whose name begins with which in turn has a child named baz where *the predicate active
const AttributeArray & constAttributeArray(const size_t pos) const
ChildOnCIter endChildOn() const
PointDataLeafNode(const PointDataLeafNode &other)
Construct using deep copy of other PointDataLeafNode.
typename BaseLeaf::template ValueIter< MaskDenseIterator, PointDataLeafNode, const ValueType, ValueAll > ValueAllIter
void setActiveState(const Coord &xyz, bool on)
void flush()
Manually flushes the current page to disk if non-zero.
ValueAllIter endValueAll()
IndexIter< ValueOffCIter, FilterT > beginIndexOff(const FilterT &filter) const
typename BaseLeaf::ValueAll ValueAll
std::shared_ptr< PointDataLeafNode > Ptr
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.
std::unique_ptr< AttributeSet > UniquePtr
void fill(const CoordBBox &, const ValueType &, bool)
Library and file format version numbers.
ValueVoxelCIter beginValueVoxel(const Coord &ijk) const
Leaf value voxel iterator.
ChildOffCIter endChildOff() const
GroupHandle groupHandle(const AttributeSet::Descriptor::GroupIndex &index) const
}
void setOffsetOnly(Index offset, const ValueType &val)
Typed class for storing attribute data.
Set of Attribute Arrays which tracks metadata about each array.
typename BaseLeaf::ChildOff ChildOff
ChildOffCIter cbeginChildOff() const
PointDataLeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
Space-partitioning acceleration structure for points. Partitions the points into voxels to accelerate...
Attribute Group access and filtering for iteration.
OPENVDB_API size_t bloscCompressedSize(const char *buffer, const size_t uncompressedBytes)
Convenience wrapper to retrieve the compressed size of buffer when compressed.
typename BaseLeaf::ValueOff ValueOff
ValueAllCIter beginValueAll() const
SIM_API const UT_StringHolder position
void setValueOn(const Coord &xyz)
void resetBackground(const ValueType &, const ValueType &newBackground)
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
Ordered collection of uniquely-named attribute arrays.
ChildAllCIter cbeginChildAll() const
ChildOnCIter cbeginChildOn() const
A Paging wrapper to std::ostream that is responsible for writing from a given output stream at interv...
void replaceAttributeSet(AttributeSet *attributeSet, bool allowMismatchingDescriptors=false)
Replace the underlying attribute set with the given attributeSet.
typename NodeMaskType::OnIterator MaskOnIterator
OPENVDB_API SharedPtr< StreamMetadata > getStreamMetadataPtr(std::ios_base &)
Return a shared pointer to an object that stores metadata (file format, compression scheme...
Integer wrapper, required to distinguish PointIndexGrid and PointDataGrid from Int32Grid and Int64Gri...
void setValueOn(Index offset)
ValueOnCIter cendValueOn() const
PointDataLeafNode(PartialCreate, const Coord &coords, const T &value=zeroVal< T >(), bool active=false)
virtual bool compact()=0
Compact the existing array to become uniform if all values are identical.
void writeBuffers(std::ostream &os, bool toHalf=false) const
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
std::shared_ptr< PagedOutputStream > Ptr
std::shared_ptr< PagedInputStream > Ptr
Index64 iterCount(const IterT &iter)
Count up the number of times the iterator can iterate.
typename BaseLeaf::template ValueIter< MaskOffIterator, const PointDataLeafNode, const ValueType, ValueOff > ValueOffCIter
ChildOffCIter beginChildOff() const
Index64 groupPointCount(const Name &groupName) const
Compute the point count in a specific group for the leaf.
ValueOffCIter cendValueOff() const
PointDataLeafNode(const tools::PointIndexLeafNode< OtherValueType, Log2Dim > &other)
void setOutputStream(std::ostream &os)
void addLeafAndCache(PointDataLeafNode *, AccessorT &)
void setValueOff(Index, const ValueType &)
Attribute Array storage templated on type and compression codec.
void modifyValue(Index, const ModifyOp &)
const AttributeSet & attributeSet() const
Retrieve the attribute set.
Similiar to ValueConverter, but allows for tree configuration conversion to a PointDataTree. ValueConverter<PointDataIndex32> cannot be used as a PointDataLeafNode is not a specialization of LeafNode.
typename NodeMaskType::DenseIterator MaskDenseIterator
void setValueOnlyAndCache(const Coord &, const ValueType &, AccessorT &)
ValueOnCIter endValueOn() const
ChildOnCIter beginChildOn() const
AttributeArray & attributeArray(const size_t pos)
Read-write attribute array reference from index.
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
IndexIter< ValueOnCIter, FilterT > beginIndexOn(const FilterT &filter) const
void setValueOn(const Coord &, const ValueType &)
A list of types (not necessarily unique)
ValueOffCIter endValueOff() const
ChildAllIter endChildAll()
ChildOffCIter cendChildOff() const
ValueAllCIter endValueAll() const
void fill(const ValueType &value)
Index64 pointCount() const
Compute the total point count for the leaf.
typename BaseLeaf::ChildOn ChildOn
#define OPENVDB_THROW(exception, message)
IndexOnIter beginIndexOn() const
void resetDescriptor(const Descriptor::Ptr &replacement)
Replace the descriptor with a new one The new Descriptor must exactly match the old one...
ValueAllIter beginValueAll()
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
typename PointDataNodeChain< ChildT, HeadLevel-1 >::Type SubtreeT
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.