12 #ifndef OPENVDB_POINTS_POINT_DATA_GRID_HAS_BEEN_INCLUDED
13 #define OPENVDB_POINTS_POINT_DATA_GRID_HAS_BEEN_INCLUDED
30 #include <type_traits>
34 class TestPointDataLeaf;
52 const bool seek = destBuf ==
nullptr;
56 if (destBytes >= maximumBytes) {
58 maximumBytes <<
" bytes in voxel values.")
68 bytes16 =
static_cast<uint16_t
>(meta->pass());
70 is.seekg(
sizeof(uint16_t), std::ios_base::cur);
74 is.read(reinterpret_cast<char*>(&bytes16),
sizeof(uint16_t));
80 is.seekg(destBytes, std::ios_base::cur);
83 is.read(reinterpret_cast<char*>(destBuf), destBytes);
89 is.seekg(
int(bytes16), std::ios_base::cur);
93 std::unique_ptr<char[]> bloscBuffer(
new char[
int(bytes16)]);
94 is.read(bloscBuffer.get(), bytes16);
98 std::memcpy(destBuf, buffer.get(), destBytes);
115 if (srcBytes >= maximumBytes) {
117 maximumBytes <<
" bytes in voxel values.")
120 const char* charBuffer =
reinterpret_cast<const char*
>(srcBuf);
122 size_t compressedBytes;
124 compressedBytes,
false);
126 if (compressedBytes > 0) {
127 auto bytes16 =
static_cast<uint16_t
>(compressedBytes);
128 os.write(reinterpret_cast<const char*>(&bytes16),
sizeof(uint16_t));
129 os.write(reinterpret_cast<const char*>(buffer.get()), compressedBytes);
132 auto bytes16 =
static_cast<uint16_t
>(maximumBytes);
133 os.write(reinterpret_cast<const char*>(&bytes16),
sizeof(uint16_t));
134 os.write(reinterpret_cast<const char*>(srcBuf), srcBytes);
138 template <
typename T>
144 const size_t srcBytes = srcCount*
sizeof(
T);
146 if (srcBytes >= maximumBytes) {
148 maximumBytes <<
" bytes in voxel values.")
151 const char* charBuffer =
reinterpret_cast<const char*
>(srcBuf);
156 if (compressedBytes > 0) {
157 auto bytes16 =
static_cast<uint16_t
>(compressedBytes);
158 os.write(reinterpret_cast<const char*>(&bytes16),
sizeof(uint16_t));
161 auto bytes16 =
static_cast<uint16_t
>(maximumBytes);
162 os.write(reinterpret_cast<const char*>(&bytes16),
sizeof(uint16_t));
187 #ifndef OPENVDB_DISABLE_POINT_DATA_TREE_ALIAS
206 template <
typename Po
intDataTreeT>
207 inline AttributeSet::Descriptor::Ptr
220 template <
typename Po
intDataTreeT>
231 template <
typename Po
intDataTreeT>
233 prefetch(PointDataTreeT& tree,
bool position =
true,
bool otherAttributes =
true);
239 template <
typename T, Index Log2Dim>
244 using Ptr = std::shared_ptr<PointDataLeafNode>;
260 using BaseLeaf::LOG2DIM;
261 using BaseLeaf::TOTAL;
263 using BaseLeaf::NUM_VALUES;
264 using BaseLeaf::NUM_VOXELS;
266 using BaseLeaf::LEVEL;
277 , mAttributeSet(new
AttributeSet(*other.mAttributeSet)) { }
288 const T&
value = zeroVal<T>(),
bool active =
false)
296 template<
typename OtherValueType>
303 template <
typename ValueType>
310 template <
typename ValueType>
316 const T&
value = zeroVal<T>(),
bool active =
false)
351 const size_t pos,
const Index strideOrTotalSize = 1,
352 const bool constantStride =
true,
361 const Descriptor& expected, Descriptor::Ptr& replacement);
439 template<
typename OtherType, Index OtherLog2Dim>
441 return BaseLeaf::hasSameTopology(other);
447 if(BaseLeaf::operator==(other) !=
true)
return false;
448 return (*this->mAttributeSet == *other.mAttributeSet);
454 template<
typename AccessorT>
460 template<
typename AccessorT>
463 template<
typename NodeT,
typename AccessorT>
468 return reinterpret_cast<NodeT*
>(
this);
472 template<
typename AccessorT>
479 template<
typename AccessorT>
481 template<
typename AccessorT>
484 template<
typename NodeT,
typename AccessorT>
489 return reinterpret_cast<const NodeT*
>(
this);
496 void readTopology(std::istream& is,
bool fromHalf =
false);
497 void writeTopology(std::ostream& os,
bool toHalf =
false)
const;
501 void readBuffers(std::istream& is,
bool fromHalf =
false);
503 void writeBuffers(std::ostream& os,
bool toHalf =
false)
const;
521 OPENVDB_ASSERT(
false &&
"Cannot modify voxel values in a PointDataTree.");
531 void setActiveState(
const Coord& xyz,
bool on) { BaseLeaf::setActiveState(xyz, on); }
537 void setValueOff(
const Coord& xyz) { BaseLeaf::setValueOff(xyz); }
543 void setValueOn(
const Coord& xyz) { BaseLeaf::setValueOn(xyz); }
554 template<
typename ModifyOp>
557 template<
typename ModifyOp>
560 template<
typename ModifyOp>
570 template<
typename AccessorT>
573 template<
typename ModifyOp,
typename AccessorT>
578 template<
typename AccessorT>
581 template<
typename AccessorT>
583 BaseLeaf::setActiveStateAndCache(xyz, on, parent);
595 friend class ::TestPointDataLeaf;
603 uint16_t mVoxelBufferSize = 0;
662 return this->beginIndex<ValueAllCIter, NullFilter>(
filter);
667 return this->beginIndex<ValueOnCIter, NullFilter>(
filter);
672 return this->beginIndex<ValueOffCIter, NullFilter>(
filter);
675 template<
typename IterT,
typename FilterT>
679 template<
typename FilterT>
682 return this->beginIndex<ValueAllCIter, FilterT>(
filter);
684 template<
typename FilterT>
687 return this->beginIndex<ValueOnCIter, FilterT>(
filter);
689 template<
typename FilterT>
692 return this->beginIndex<ValueOffCIter, FilterT>(
filter);
699 template<
typename FilterT>
702 #define VMASK_ this->getValueMask()
749 template<
typename T, Index Log2Dim>
758 template<
typename T, Index Log2Dim>
763 if (descriptor->size() != 1 ||
767 OPENVDB_THROW(IndexError,
"Initializing attributes only allowed with one Vec3f position attribute.");
770 mAttributeSet.reset(
new AttributeSet(descriptor, arrayLength, lock));
773 template<
typename T, Index Log2Dim>
778 mAttributeSet.reset(
new AttributeSet(*mAttributeSet, 0, lock));
786 if (updateValueMask) this->setValuesOff();
789 template<
typename T, Index Log2Dim>
793 return pos < mAttributeSet->size();
796 template<
typename T, Index Log2Dim>
800 const size_t pos = mAttributeSet->find(attributeName);
804 template<
typename T, Index Log2Dim>
807 const size_t pos,
const Index strideOrTotalSize,
808 const bool constantStride,
812 return mAttributeSet->appendAttribute(
813 expected, replacement, pos, strideOrTotalSize, constantStride, metadata, lock);
816 template<
typename T, Index Log2Dim>
819 const Descriptor& expected, Descriptor::Ptr& replacement)
821 mAttributeSet->dropAttributes(pos, expected, replacement);
824 template<
typename T, Index Log2Dim>
828 mAttributeSet->reorderAttributes(replacement);
831 template<
typename T, Index Log2Dim>
835 mAttributeSet->renameAttributes(expected, replacement);
838 template<
typename T, Index Log2Dim>
842 for (
size_t i = 0; i < mAttributeSet->size(); i++) {
848 template<
typename T, Index Log2Dim>
853 OPENVDB_THROW(ValueError,
"Cannot replace with a null attribute set");
856 if (!allowMismatchingDescriptors && mAttributeSet->descriptor() != attributeSet->
descriptor()) {
857 OPENVDB_THROW(ValueError,
"Attribute set descriptors are not equal.");
860 mAttributeSet.reset(attributeSet);
863 template<
typename T, Index Log2Dim>
867 mAttributeSet->resetDescriptor(replacement);
870 template<
typename T, Index Log2Dim>
874 if (offsets.size() != LeafNodeType::NUM_VALUES) {
875 OPENVDB_THROW(ValueError,
"Offset vector size doesn't match number of voxels.")
882 if (updateValueMask) this->updateValueMask();
885 template<
typename T, Index Log2Dim>
892 OPENVDB_THROW(ValueError,
"Voxel offset values are not monotonically increasing");
897 for (
size_t attributeIndex = 1; attributeIndex < mAttributeSet->size(); ++attributeIndex ) {
898 if (mAttributeSet->getConst(attributeIndex-1)->size() != mAttributeSet->getConst(attributeIndex)->size()) {
899 OPENVDB_THROW(ValueError,
"Attribute arrays have inconsistent length");
904 if (mAttributeSet->size() > 0 && this->
getValue(BaseLeaf::SIZE-1) != mAttributeSet->getConst(0)->size()) {
905 OPENVDB_THROW(ValueError,
"Last voxel offset value does not match attribute array length");
909 template<
typename T, Index Log2Dim>
913 if (pos >= mAttributeSet->size())
OPENVDB_THROW(LookupError,
"Attribute Out Of Range - " << pos);
914 return *mAttributeSet->get(pos);
917 template<
typename T, Index Log2Dim>
921 if (pos >= mAttributeSet->size())
OPENVDB_THROW(LookupError,
"Attribute Out Of Range - " << pos);
922 return *mAttributeSet->getConst(pos);
925 template<
typename T, Index Log2Dim>
929 return this->attributeArray(pos);
932 template<
typename T, Index Log2Dim>
936 const size_t pos = mAttributeSet->find(attributeName);
938 return *mAttributeSet->get(pos);
941 template<
typename T, Index Log2Dim>
945 const size_t pos = mAttributeSet->find(attributeName);
947 return *mAttributeSet->getConst(pos);
950 template<
typename T, Index Log2Dim>
954 return this->attributeArray(attributeName);
957 template<
typename T, Index Log2Dim>
969 template<
typename T, Index Log2Dim>
973 const AttributeSet::Descriptor::GroupIndex
index = this->attributeSet().groupIndex(name);
974 return this->groupHandle(index);
977 template<
typename T, Index Log2Dim>
989 template<
typename T, Index Log2Dim>
993 const AttributeSet::Descriptor::GroupIndex
index = this->attributeSet().groupIndex(name);
994 return this->groupWriteHandle(index);
997 template<
typename T, Index Log2Dim>
998 template<
typename ValueIterT,
typename FilterT>
1010 FilterT newFilter(filter);
1011 newFilter.reset(*
this);
1022 template<
typename T, Index Log2Dim>
1026 const Index index = LeafNodeType::coordToOffset(ijk);
1033 template<
typename T, Index Log2Dim>
1041 template<
typename T, Index Log2Dim>
1042 template<
typename FilterT>
1047 FilterT newFilter(filter);
1048 newFilter.reset(*
this);
1052 template<
typename T, Index Log2Dim>
1056 return this->getLastValue();
1059 template<
typename T, Index Log2Dim>
1063 if (this->isEmpty())
return 0;
1064 else if (this->isDense())
return this->
pointCount();
1068 template<
typename T, Index Log2Dim>
1072 if (this->isEmpty())
return this->
pointCount();
1073 else if (this->isDense())
return 0;
1074 return iterCount(this->beginIndexOff());
1077 template<
typename T, Index Log2Dim>
1081 if (!this->attributeSet().descriptor().hasGroup(groupName)) {
1088 return iterCount(this->beginIndexAll(filter));
1092 template<
typename T, Index Log2Dim>
1097 for (
Index n = 0;
n < LeafNodeType::NUM_VALUES;
n++) {
1099 this->setValueMask(
n, (
end - start) > 0);
1104 template<
typename T, Index Log2Dim>
1108 this->
buffer().setValue(offset, val);
1109 this->setValueMaskOn(offset);
1112 template<
typename T, Index Log2Dim>
1116 this->
buffer().setValue(offset, val);
1119 template<
typename T, Index Log2Dim>
1123 BaseLeaf::readTopology(is, fromHalf);
1126 template<
typename T, Index Log2Dim>
1130 BaseLeaf::writeTopology(os, toHalf);
1133 template<
typename T, Index Log2Dim>
1140 mAttributeSet->size() +
1141 mAttributeSet->size() +
1145 template<
typename T, Index Log2Dim>
1149 this->readBuffers(is, CoordBBox::inf(), fromHalf);
1152 template<
typename T, Index Log2Dim>
1162 auto it = auxData.find(key);
1163 if (it != auxData.end()) {
1172 auto it = auxData.find(key);
1173 if (it != auxData.end()) {
1179 return *pagedStream;
1185 std::string matchingKey(
"hasMatchingDescriptor");
1186 auto itMatching = auxData.find(matchingKey);
1187 return itMatching != auxData.end();
1192 std::string matchingKey(
"hasMatchingDescriptor");
1193 std::string descriptorKey(
"descriptorPtr");
1194 auto itMatching = auxData.find(matchingKey);
1195 auto itDescriptor = auxData.find(descriptorKey);
1196 if (itMatching != auxData.end()) (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(itMatching);
1197 if (itDescriptor != auxData.end()) (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(itDescriptor);
1201 const Descriptor::Ptr descriptor)
1203 std::string descriptorKey(
"descriptorPtr");
1204 std::string matchingKey(
"hasMatchingDescriptor");
1205 auto itMatching = auxData.find(matchingKey);
1206 if (itMatching == auxData.end()) {
1215 std::string descriptorKey(
"descriptorPtr");
1216 auto itDescriptor = auxData.find(descriptorKey);
1218 const Descriptor::Ptr descriptor = std::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
1226 OPENVDB_THROW(IoError,
"Cannot read in a PointDataLeaf without StreamMetadata.");
1229 const Index pass(static_cast<uint16_t>(meta->pass()));
1230 const Index maximumPass(static_cast<uint16_t>(meta->pass() >> 16));
1232 const Index attributes = (maximumPass - 4) / 2;
1236 is.read(reinterpret_cast<char*>(&mVoxelBufferSize),
sizeof(uint16_t));
1237 Local::clearMatchingDescriptor(meta->auxData());
1239 else if (pass == 1) {
1241 if (Local::hasMatchingDescriptor(meta->auxData())) {
1242 AttributeSet::Descriptor::Ptr descriptor = Local::retrieveMatchingDescriptor(meta->auxData());
1243 mAttributeSet->resetDescriptor(descriptor,
true);
1247 is.read(reinterpret_cast<char*>(&header),
sizeof(uint8_t));
1248 mAttributeSet->readDescriptor(is);
1249 if (header & uint8_t(1)) {
1251 Local::insertDescriptor(meta->auxData(), descriptor);
1255 if (header & uint8_t(2)) {
1256 uint64_t bytesToSkip;
1257 is.read(reinterpret_cast<char*>(&bytesToSkip),
sizeof(uint64_t));
1258 if (bytesToSkip > uint64_t(0)) {
1260 if (metadata && metadata->seekable()) {
1261 is.seekg(bytesToSkip, std::ios_base::cur);
1264 std::vector<uint8_t> tempData(bytesToSkip);
1265 is.read(reinterpret_cast<char*>(&tempData[0]), bytesToSkip);
1270 if (header > uint8_t(3)) {
1271 OPENVDB_THROW(IoError,
"Unrecognised header flags in PointDataLeafNode");
1274 mAttributeSet->readMetadata(is);
1276 else if (pass < (attributes + 2)) {
1278 const size_t attributeIndex = pass - 2;
1280 mAttributeSet->get(attributeIndex) :
nullptr;
1283 Local::getOrInsertPagedStream(meta->auxData(),
static_cast<Index>(attributeIndex));
1289 else if (pass == attributes + 2) {
1292 const Index passValue(meta->pass());
1296 nonConstMeta.
setPass(mVoxelBufferSize);
1299 BaseLeaf::readBuffers(is, fromHalf);
1302 nonConstMeta.setPass(passValue);
1304 else if (pass < (attributes*2 + 3)) {
1306 const Index attributeIndex = pass - attributes - 3;
1308 mAttributeSet->get(attributeIndex) :
nullptr;
1311 Local::getOrInsertPagedStream(meta->auxData(), attributeIndex);
1317 if (pass > attributes + 3) {
1318 Local::destroyPagedStream(meta->auxData(), attributeIndex-1);
1323 const Index attributeIndex = pass - attributes - 4;
1324 Local::destroyPagedStream(meta->auxData(), attributeIndex);
1328 template<
typename T, Index Log2Dim>
1338 auto it = auxData.find(key);
1339 if (it != auxData.end()) {
1350 auto it = auxData.find(key);
1351 if (it != auxData.end()) {
1357 return *pagedStream;
1362 const Descriptor::Ptr descriptor)
1364 std::string descriptorKey(
"descriptorPtr");
1365 std::string matchingKey(
"hasMatchingDescriptor");
1366 auto itMatching = auxData.find(matchingKey);
1367 auto itDescriptor = auxData.find(descriptorKey);
1368 if (itMatching == auxData.end()) {
1376 bool matching = std::any_cast<
bool>(itMatching->second);
1377 if (!matching)
return;
1381 const Descriptor::Ptr existingDescriptor = std::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
1382 if (*existingDescriptor != *descriptor) {
1390 std::string matchingKey(
"hasMatchingDescriptor");
1391 auto itMatching = auxData.find(matchingKey);
1393 if (itMatching == auxData.end())
return false;
1395 if (!std::any_cast<bool>(itMatching->second))
return false;
1401 std::string descriptorKey(
"descriptorPtr");
1402 auto itDescriptor = auxData.find(descriptorKey);
1404 if (itDescriptor == auxData.end())
return nullptr;
1406 const Descriptor::Ptr descriptor = std::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
1413 std::string matchingKey(
"hasMatchingDescriptor");
1414 std::string descriptorKey(
"descriptorPtr");
1415 auto itMatching = auxData.find(matchingKey);
1416 auto itDescriptor = auxData.find(descriptorKey);
1417 if (itMatching != auxData.end()) (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(itMatching);
1418 if (itDescriptor != auxData.end()) (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(itDescriptor);
1425 OPENVDB_THROW(IoError,
"Cannot write out a PointDataLeaf without StreamMetadata.");
1428 const Index pass(static_cast<uint16_t>(meta->pass()));
1433 if (meta->countingPasses()) {
1435 if (requiredPasses > pass) {
1436 meta->setPass(requiredPasses);
1441 const Index maximumPass(static_cast<uint16_t>(meta->pass() >> 16));
1442 const Index attributes = (maximumPass - 4) / 2;
1448 Local::insertDescriptor(meta->auxData(), mAttributeSet->descriptorPtr());
1450 else if (pass == 1) {
1452 bool matchingDescriptor = Local::hasMatchingDescriptor(meta->auxData());
1453 if (matchingDescriptor) {
1454 AttributeSet::Descriptor::Ptr descriptor = Local::retrieveMatchingDescriptor(meta->auxData());
1458 os.write(reinterpret_cast<const char*>(&header),
sizeof(uint8_t));
1459 mAttributeSet->writeDescriptor(os,
false);
1465 os.write(reinterpret_cast<const char*>(&header),
sizeof(uint8_t));
1466 mAttributeSet->writeDescriptor(os,
false);
1468 mAttributeSet->writeMetadata(os,
false,
true);
1470 else if (pass < attributes + 2) {
1472 const Index attributeIndex = pass - 2;
1475 Local::destroyPagedStream(meta->auxData(), attributeIndex-1);
1478 mAttributeSet->getConst(attributeIndex) :
nullptr;
1481 Local::getOrInsertPagedStream(meta->auxData(), attributeIndex);
1487 else if (pass == attributes + 2) {
1488 const Index attributeIndex = pass - 3;
1489 Local::destroyPagedStream(meta->auxData(), attributeIndex);
1491 BaseLeaf::writeBuffers(os, toHalf);
1493 else if (pass < (attributes*2 + 3)) {
1495 const Index attributeIndex = pass - attributes - 3;
1497 if (pass > attributes + 2) {
1498 Local::destroyPagedStream(meta->auxData(), attributeIndex-1);
1501 mAttributeSet->getConst(attributeIndex) :
nullptr;
1504 Local::getOrInsertPagedStream(meta->auxData(), attributeIndex);
1511 Local::clearMatchingDescriptor(meta->auxData());
1513 const Index attributeIndex = pass - attributes - 4;
1514 Local::destroyPagedStream(meta->auxData(), attributeIndex);
1518 template<
typename T, Index Log2Dim>
1522 return BaseLeaf::memUsage() + mAttributeSet->memUsage();
1525 template<
typename T, Index Log2Dim>
1532 template<
typename T, Index Log2Dim>
1536 BaseLeaf::evalActiveBoundingBox(bbox, visitVoxels);
1539 template<
typename T, Index Log2Dim>
1543 return BaseLeaf::getNodeBoundingBox();
1546 template<
typename T, Index Log2Dim>
1550 if (!this->allocate())
return;
1552 this->assertNonModifiableUnlessZero(value);
1556 for (
Int32 x = bbox.min().x();
x <= bbox.max().x(); ++
x) {
1557 const Index offsetX = (
x & (DIM-1u)) << 2*Log2Dim;
1558 for (
Int32 y = bbox.min().y();
y <= bbox.max().y(); ++
y) {
1559 const Index offsetXY = offsetX + ((
y & (DIM-1u)) << Log2Dim);
1560 for (
Int32 z = bbox.min().z();
z <= bbox.max().z(); ++
z) {
1562 this->setValueMask(offset, active);
1568 template<
typename T, Index Log2Dim>
1572 this->assertNonModifiableUnlessZero(value);
1576 if (active) this->setValuesOn();
1577 else this->setValuesOff();
1584 template <
typename Po
intDataTreeT>
1585 inline AttributeSet::Descriptor::Ptr
1588 auto leafIter = tree.beginLeaf();
1589 if (!leafIter)
return nullptr;
1592 auto newDescriptor = std::make_shared<AttributeSet::Descriptor>(descriptor);
1593 for (; leafIter; ++leafIter) {
1594 leafIter->resetDescriptor(newDescriptor);
1597 return newDescriptor;
1601 template <
typename Po
intDataTreeT>
1605 auto leafIter = tree.beginLeaf();
1606 for (; leafIter; ++leafIter) {
1607 for (
size_t i = 0; i < leafIter->attributeSet().size(); i++) {
1608 leafIter->attributeArray(i).setStreaming(on);
1614 template <
typename Po
intDataTreeT>
1621 auto leaf = tree.cbeginLeaf();
1624 const auto& attributeSet = leaf->attributeSet();
1628 for ( ; leaf; ++leaf) {
1629 leaf->buffer().data();
1634 size_t positionIndex = attributeSet.find(
"P");
1637 for (leaf = tree.cbeginLeaf(); leaf; ++leaf) {
1639 leaf->constAttributeArray(positionIndex).loadData();
1645 if (otherAttributes) {
1646 const size_t attributes = attributeSet.size();
1647 for (
size_t attributeIndex = 0; attributeIndex < attributes; attributeIndex++) {
1648 if (attributeIndex == positionIndex)
continue;
1649 for (leaf = tree.cbeginLeaf(); leaf; ++leaf) {
1651 leaf->constAttributeArray(attributeIndex).loadData();
1658 namespace internal {
1675 template<
typename HeadT,
int HeadLevel>
1680 using Type =
typename SubtreeT::template Append<RootNodeT>;
1685 template <
typename ChildT, Index Log2Dim,
int HeadLevel>
1690 using Type =
typename SubtreeT::template Append<InternalNodeT>;
1695 template <
typename ChildT, Index Log2Dim>
1709 template <
typename TreeType>
1728 template<Index Dim1,
typename T2>
1735 #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.
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 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
#define OPENVDB_ASSERT(X)
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
Index64 memUsageIfLoaded() 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.