16 #ifndef OPENVDB_TOOLS_POINT_INDEX_GRID_HAS_BEEN_INCLUDED
17 #define OPENVDB_TOOLS_POINT_INDEX_GRID_HAS_BEEN_INCLUDED
30 #include <tbb/atomic.h>
31 #include <tbb/blocked_range.h>
32 #include <tbb/parallel_for.h>
37 #include <type_traits>
47 template<Index,
typename>
struct SameLeafConfig;
91 template<
typename Gr
idT,
typename Po
intArrayT>
92 inline typename GridT::Ptr
101 template<
typename Gr
idT,
typename Po
intArrayT>
102 inline typename GridT::Ptr
111 template<
typename Po
intArrayT,
typename Gr
idT>
117 template<
typename Gr
idT,
typename Po
intArrayT>
118 inline typename GridT::ConstPtr
122 template<
typename Gr
idT,
typename Po
intArrayT>
123 inline typename GridT::Ptr
131 template<
typename TreeType = Po
intIndexTree>
179 template<
typename Po
intArray>
194 template<
typename Po
intArray>
205 template<
typename Po
intArray>
220 template<
typename Po
intArray>
233 bool test()
const {
return mRange.first < mRange.second || mIter != mRangeList.end(); }
234 operator bool()
const {
return this->
test(); }
257 using Range = std::pair<const ValueType*, const ValueType*>;
258 using RangeDeque = std::deque<Range>;
259 using RangeDequeCIter =
typename RangeDeque::const_iterator;
260 using IndexArray = std::unique_ptr<ValueType[]>;
266 RangeDeque mRangeList;
267 RangeDequeCIter mIter;
269 IndexArray mIndexArray;
270 size_t mIndexArraySize;
303 template<
typename Po
intArray,
typename TreeType = Po
intIndexTree>
324 template<
typename FilterType>
341 namespace point_index_grid_internal {
343 template<
typename Po
intArrayT>
350 , mHasChanged(&hasChanged)
354 template <
typename LeafT>
357 if ((*mHasChanged)) {
358 tbb::task::self().cancel_group_execution();
364 using PosType =
typename PointArrayT::PosType;
366 typename LeafT::ValueOnCIter iter;
371 *
begin =
static_cast<IndexT*
>(
nullptr),
372 *
end = static_cast<IndexT*>(
nullptr);
374 for (iter = leaf.cbeginValueOn(); iter; ++iter) {
376 if ((*mHasChanged))
break;
378 voxelCoord = iter.getCoord();
379 leaf.getIndices(iter.pos(),
begin,
end);
381 while (begin <
end) {
383 mPoints->getPos(*begin, point);
385 mHasChanged->fetch_and_store(
true);
395 PointArrayT
const *
const mPoints;
397 tbb::atomic<bool> *
const mHasChanged;
401 template<
typename LeafNodeT>
418 size_t maxPointCount = 0;
419 for (
size_t n = range.begin(),
N = range.
end();
n !=
N; ++
n) {
426 std::unique_ptr<VoxelOffsetT[]>
offsets{
new VoxelOffsetT[maxPointCount]};
431 for (
size_t n = range.begin(),
N = range.
end();
n !=
N; ++
n) {
433 LeafNodeT* node =
new LeafNodeT();
443 offsets[i] = voxelOffsets[ indices[i] ];
452 typename LeafNodeT::NodeMaskType&
mask = node->getValueMask();
453 typename LeafNodeT::Buffer&
buffer = node->buffer();
457 for (
int i = 0; i <
int(voxelCount); ++i) {
464 buffer.setValue(i, count);
468 node->indices().resize(pointCount);
469 typename LeafNodeT::ValueType *
const orderedIndices = node->indices().data();
488 template<
typename TreeType,
typename Po
intArray>
492 using LeafType =
typename TreeType::LeafNodeType;
494 std::unique_ptr<LeafType*[]> leafNodes;
495 size_t leafNodeCount = 0;
502 partitioner.
construct(points, xform,
false,
true);
506 "cell-centered transform.");
509 leafNodeCount = partitioner.
size();
510 leafNodes.reset(
new LeafType*[leafNodeCount]);
512 const tbb::blocked_range<size_t>
range(0, leafNodeCount);
517 for (
size_t n = 0;
n < leafNodeCount; ++
n) {
531 a.reset(
new T[size]);
532 typename std::deque<T>::const_iterator it = d.begin(), itEnd = d.end();
534 for ( ; it != itEnd; ++it, ++item) *item = *it;
540 const CoordBBox& bbox,
const CoordBBox& ibox)
544 Coord cmin = ibox.min();
545 Coord cmax = ibox.max();
548 regions.push_back(bbox);
549 regions.back().max().z() = cmin.z();
552 regions.push_back(bbox);
553 regions.back().min().z() = cmax.z();
559 regions.push_back(bbox);
560 CoordBBox* lastRegion = ®ions.back();
561 lastRegion->min().z() = cmin.z();
562 lastRegion->max().z() = cmax.z();
563 lastRegion->max().x() = cmin.x();
566 regions.push_back(*lastRegion);
567 lastRegion = ®ions.back();
568 lastRegion->min().x() = cmax.x();
569 lastRegion->max().x() = bbox.max().x();
575 regions.push_back(*lastRegion);
576 lastRegion = ®ions.back();
577 lastRegion->min().x() = cmin.x();
578 lastRegion->max().x() = cmax.x();
579 lastRegion->max().y() = cmin.y();
582 regions.push_back(*lastRegion);
583 lastRegion = ®ions.back();
584 lastRegion->min().y() = cmax.y();
585 lastRegion->max().y() = bbox.max().y();
589 template<
typename Po
intArray,
typename IndexT>
594 using Range = std::pair<const IndexT*, const IndexT*>;
604 , mMap(*xform.baseMap())
608 template <
typename LeafNodeType>
611 typename LeafNodeType::ValueOnCIter iter;
613 *
begin =
static_cast<IndexT*
>(
nullptr),
614 *
end = static_cast<IndexT*>(
nullptr);
615 for (iter = leaf.cbeginValueOn(); iter; ++iter) {
616 leaf.getIndices(iter.pos(),
begin,
end);
626 mPoints.getPos(*begin, vec);
629 mIndices.push_back(*begin);
643 template<
typename Po
intArray,
typename IndexT>
648 using Range = std::pair<const IndexT*, const IndexT*>;
654 const double leafNodeDim,
const bool subvoxelAccuracy)
658 , mWSCenter(xform.indexToWorld(xyz))
663 , mWSRadiusSqr(
ScalarType(radius * xform.voxelSize()[0]))
665 , mSubvoxelAccuracy(subvoxelAccuracy)
668 mVoxelDist1 = voxelRadius +
ScalarType(radius);
669 mVoxelDist1 *= mVoxelDist1;
671 if (radius > voxelRadius) {
672 mVoxelDist2 =
ScalarType(radius) - voxelRadius;
673 mVoxelDist2 *= mVoxelDist2;
677 mLeafNodeDist1 = leafNodeRadius +
ScalarType(radius);
678 mLeafNodeDist1 *= mLeafNodeDist1;
680 if (radius > leafNodeRadius) {
681 mLeafNodeDist2 =
ScalarType(radius) - leafNodeRadius;
682 mLeafNodeDist2 *= mLeafNodeDist2;
685 mWSRadiusSqr *= mWSRadiusSqr;
688 template <
typename LeafNodeType>
692 const Coord& ijk = leaf.origin();
697 vec +=
ScalarType(LeafNodeType::DIM - 1) * 0.5;
701 if (dist > mLeafNodeDist1)
return;
703 if (mLeafNodeDist2 > 0.0 && dist < mLeafNodeDist2) {
704 const IndexT*
begin = &leaf.indices().front();
705 mRanges.push_back(
Range(begin, begin + leaf.indices().size()));
710 typename LeafNodeType::ValueOnCIter iter;
712 *
begin =
static_cast<IndexT*
>(
nullptr),
713 *
end = static_cast<IndexT*>(
nullptr);
714 for (iter = leaf.cbeginValueOn(); iter; ++iter) {
715 leaf.getIndices(iter.pos(),
begin,
end);
729 const ScalarType
dist = vec.lengthSqr();
730 if (dist > mVoxelDist1)
return;
732 if (!mSubvoxelAccuracy || (mVoxelDist2 > 0.0 && dist < mVoxelDist2)) {
733 if (!mRanges.empty() && mRanges.back().second ==
begin) {
734 mRanges.back().second =
end;
736 mRanges.push_back(
Range(begin, end));
743 while (begin < end) {
744 mPoints.getPos(*begin, vec);
745 vec = mWSCenter - vec;
747 if (vec.lengthSqr() < mWSRadiusSqr) {
748 mIndices.push_back(*begin);
757 const PosType mCenter, mWSCenter;
758 ScalarType mVoxelDist1, mVoxelDist2, mLeafNodeDist1, mLeafNodeDist2, mWSRadiusSqr;
760 const bool mSubvoxelAccuracy;
767 template<
typename RangeFilterType,
typename LeafNodeType>
770 const LeafNodeType& leaf,
const Coord&
min,
const Coord&
max)
772 using PointIndexT =
typename LeafNodeType::ValueType;
773 Index xPos(0), yPos(0), pos(0);
776 const PointIndexT* dataPtr = &leaf.indices().front();
777 PointIndexT beginOffset, endOffset;
779 for (ijk[0] = min[0]; ijk[0] <= max[0]; ++ijk[0]) {
780 xPos = (ijk[0] & (LeafNodeType::DIM - 1u)) << (2 * LeafNodeType::LOG2DIM);
781 for (ijk[1] = min[1]; ijk[1] <= max[1]; ++ijk[1]) {
782 yPos = xPos + ((ijk[1] & (LeafNodeType::DIM - 1u)) << LeafNodeType::LOG2DIM);
783 for (ijk[2] = min[2]; ijk[2] <= max[2]; ++ijk[2]) {
784 pos = yPos + (ijk[2] & (LeafNodeType::DIM - 1u));
786 beginOffset = (pos == 0 ? PointIndexT(0) : leaf.getValue(pos - 1));
787 endOffset = leaf.getValue(pos);
789 if (endOffset > beginOffset) {
790 filter.filterVoxel(ijk, dataPtr + beginOffset, dataPtr + endOffset);
798 template<
typename RangeFilterType,
typename ConstAccessor>
802 using LeafNodeType =
typename ConstAccessor::TreeType::LeafNodeType;
803 Coord ijk(0), ijkMax(0), ijkA(0), ijkB(0);
804 const Coord leafMin = bbox.min() & ~(LeafNodeType::DIM - 1);
805 const Coord leafMax = bbox.max() & ~(LeafNodeType::DIM - 1);
807 for (ijk[0] = leafMin[0]; ijk[0] <= leafMax[0]; ijk[0] += LeafNodeType::DIM) {
808 for (ijk[1] = leafMin[1]; ijk[1] <= leafMax[1]; ijk[1] += LeafNodeType::DIM) {
809 for (ijk[2] = leafMin[2]; ijk[2] <= leafMax[2]; ijk[2] += LeafNodeType::DIM) {
811 if (
const LeafNodeType* leaf = acc.probeConstLeaf(ijk)) {
813 ijkMax.offset(LeafNodeType::DIM - 1);
819 if (ijkA != ijk || ijkB != ijkMax) {
822 filter.filterLeafNode(*leaf);
834 template<
typename RangeDeque,
typename LeafNodeType>
837 const LeafNodeType& leaf,
const Coord&
min,
const Coord&
max)
839 using PointIndexT =
typename LeafNodeType::ValueType;
840 using IntT =
typename PointIndexT::IntType;
843 Index xPos(0), pos(0), zStride =
Index(max[2] - min[2]);
844 const PointIndexT* dataPtr = &leaf.indices().front();
845 PointIndexT beginOffset(0), endOffset(0),
846 previousOffset(static_cast<IntT>(leaf.indices().size() + 1u));
849 for (ijk[0] = min[0]; ijk[0] <= max[0]; ++ijk[0]) {
850 xPos = (ijk[0] & (LeafNodeType::DIM - 1u)) << (2 * LeafNodeType::LOG2DIM);
852 for (ijk[1] = min[1]; ijk[1] <= max[1]; ++ijk[1]) {
853 pos = xPos + ((ijk[1] & (LeafNodeType::DIM - 1u)) << LeafNodeType::LOG2DIM);
854 pos += (min[2] & (LeafNodeType::DIM - 1u));
856 beginOffset = (pos == 0 ? PointIndexT(0) : leaf.getValue(pos - 1));
857 endOffset = leaf.getValue(pos+zStride);
859 if (endOffset > beginOffset) {
861 if (beginOffset == previousOffset) {
862 rangeList.back().second = dataPtr + endOffset;
864 rangeList.push_back(Range(dataPtr + beginOffset, dataPtr + endOffset));
867 previousOffset = endOffset;
874 template<
typename RangeDeque,
typename ConstAccessor>
878 using LeafNodeType =
typename ConstAccessor::TreeType::LeafNodeType;
879 using PointIndexT =
typename LeafNodeType::ValueType;
882 Coord ijk(0), ijkMax(0), ijkA(0), ijkB(0);
883 const Coord leafMin = bbox.min() & ~(LeafNodeType::DIM - 1);
884 const Coord leafMax = bbox.max() & ~(LeafNodeType::DIM - 1);
886 for (ijk[0] = leafMin[0]; ijk[0] <= leafMax[0]; ijk[0] += LeafNodeType::DIM) {
887 for (ijk[1] = leafMin[1]; ijk[1] <= leafMax[1]; ijk[1] += LeafNodeType::DIM) {
888 for (ijk[2] = leafMin[2]; ijk[2] <= leafMax[2]; ijk[2] += LeafNodeType::DIM) {
890 if (
const LeafNodeType* leaf = acc.probeConstLeaf(ijk)) {
892 ijkMax.offset(LeafNodeType::DIM - 1);
898 if (ijkA != ijk || ijkB != ijkMax) {
902 const PointIndexT*
begin = &leaf->indices().front();
903 rangeList.push_back(Range(begin, (begin + leaf->indices().size())));
917 template<
typename TreeType>
922 , mIter(mRangeList.
begin())
929 template<
typename TreeType>
933 , mRangeList(rhs.mRangeList)
934 , mIter(mRangeList.
begin())
936 , mIndexArraySize(rhs.mIndexArraySize)
938 if (rhs.mIndexArray) {
939 mIndexArray.reset(
new ValueType[mIndexArraySize]);
940 memcpy(mIndexArray.get(), rhs.mIndexArray.get(), mIndexArraySize *
sizeof(
ValueType));
945 template<
typename TreeType>
951 mRangeList = rhs.mRangeList;
952 mIter = mRangeList.begin();
954 mIndexArraySize = rhs.mIndexArraySize;
956 if (rhs.mIndexArray) {
957 mIndexArray.reset(
new ValueType[mIndexArraySize]);
958 memcpy(mIndexArray.get(), rhs.mIndexArray.get(), mIndexArraySize *
sizeof(
ValueType));
965 template<
typename TreeType>
970 , mIter(mRangeList.
begin())
975 if (leaf && leaf->getIndices(ijk, mRange.first, mRange.second)) {
976 mRangeList.push_back(mRange);
977 mIter = mRangeList.begin();
982 template<
typename TreeType>
987 , mIter(mRangeList.
begin())
993 if (!mRangeList.empty()) {
994 mIter = mRangeList.begin();
995 mRange = mRangeList.front();
1000 template<
typename TreeType>
1004 mIter = mRangeList.begin();
1005 if (!mRangeList.empty()) {
1006 mRange = mRangeList.front();
1007 }
else if (mIndexArray) {
1008 mRange.first = mIndexArray.get();
1009 mRange.second = mRange.first + mIndexArraySize;
1011 mRange.first =
static_cast<ValueType*
>(
nullptr);
1012 mRange.second =
static_cast<ValueType*
>(
nullptr);
1017 template<
typename TreeType>
1022 if (mRange.first >= mRange.second && mIter != mRangeList.end()) {
1024 if (mIter != mRangeList.end()) {
1026 }
else if (mIndexArray) {
1027 mRange.first = mIndexArray.get();
1028 mRange.second = mRange.first + mIndexArraySize;
1034 template<
typename TreeType>
1038 if (!this->
test())
return false;
1040 return this->
test();
1044 template<
typename TreeType>
1049 typename RangeDeque::const_iterator it = mRangeList.begin();
1051 for ( ; it != mRangeList.end(); ++it) {
1052 count += it->second - it->first;
1055 return count + mIndexArraySize;
1059 template<
typename TreeType>
1063 mRange.first =
static_cast<ValueType*
>(
nullptr);
1064 mRange.second =
static_cast<ValueType*
>(
nullptr);
1066 mIter = mRangeList.end();
1067 mIndexArray.reset();
1068 mIndexArraySize = 0;
1072 template<
typename TreeType>
1078 if (leaf && leaf->getIndices(ijk, mRange.first, mRange.second)) {
1079 mRangeList.push_back(mRange);
1080 mIter = mRangeList.begin();
1085 template<
typename TreeType>
1092 if (!mRangeList.empty()) {
1093 mIter = mRangeList.begin();
1094 mRange = mRangeList.front();
1099 template<
typename TreeType>
1100 template<
typename Po
intArray>
1107 std::vector<CoordBBox> searchRegions;
1110 const Coord dim = region.dim();
1113 if (minExtent > 2) {
1115 CoordBBox ibox = region;
1124 searchRegions.push_back(region);
1128 std::deque<ValueType> filteredIndices;
1130 filter(mRangeList, filteredIndices, bbox, points, xform);
1132 for (
size_t n = 0,
N = searchRegions.size();
n <
N; ++
n) {
1142 template<
typename TreeType>
1143 template<
typename Po
intArray>
1147 bool subvoxelAccuracy)
1150 std::vector<CoordBBox> searchRegions;
1154 Coord::round(
Vec3d(center[0] - radius, center[1] - radius, center[2] - radius)),
1155 Coord::round(
Vec3d(center[0] + radius, center[1] + radius, center[2] + radius)));
1158 const double iRadius = radius * double(1.0 /
std::sqrt(3.0));
1159 if (iRadius > 2.0) {
1162 Coord::round(
Vec3d(center[0] - iRadius, center[1] - iRadius, center[2] - iRadius)),
1163 Coord::round(
Vec3d(center[0] + iRadius, center[1] + iRadius, center[2] + iRadius)));
1172 searchRegions.push_back(bbox);
1176 std::deque<ValueType> filteredIndices;
1177 const double leafNodeDim = double(TreeType::LeafNodeType::DIM);
1181 FilterT
filter(mRangeList, filteredIndices,
1182 center, radius, points, xform, leafNodeDim, subvoxelAccuracy);
1184 for (
size_t n = 0,
N = searchRegions.size();
n <
N; ++
n) {
1194 template<
typename TreeType>
1195 template<
typename Po
intArray>
1200 this->searchAndUpdate(
1205 template<
typename TreeType>
1206 template<
typename Po
intArray>
1210 bool subvoxelAccuracy)
1213 (radius / xform.
voxelSize()[0]), acc, points, xform, subvoxelAccuracy);
1221 template<
typename Po
intArray,
typename TreeType>
1225 : mPoints(&points), mAcc(tree), mXform(xform), mInvVoxelSize(1.0/xform.voxelSize()[0])
1230 template<
typename Po
intArray,
typename TreeType>
1233 : mPoints(rhs.mPoints)
1234 , mAcc(rhs.mAcc.tree())
1235 , mXform(rhs.mXform)
1236 , mInvVoxelSize(rhs.mInvVoxelSize)
1241 template<
typename Po
intArray,
typename TreeType>
1242 template<
typename FilterType>
1247 if (radius * mInvVoxelSize <
ScalarType(8.0)) {
1248 mIter.searchAndUpdate(openvdb::CoordBBox(
1249 mXform.worldToIndexCellCentered(center - radius),
1250 mXform.worldToIndexCellCentered(center + radius)), mAcc);
1252 mIter.worldSpaceSearchAndUpdate(
1253 center, radius, mAcc, *mPoints, mXform,
false);
1256 const ScalarType radiusSqr = radius * radius;
1259 for (; mIter; ++mIter) {
1260 mPoints->getPos(*mIter, pos);
1262 distSqr = pos.lengthSqr();
1264 if (distSqr < radiusSqr) {
1265 op(distSqr, *mIter);
1274 template<
typename Gr
idT,
typename Po
intArrayT>
1275 inline typename GridT::Ptr
1278 typename GridT::Ptr grid = GridT::create(
typename GridT::ValueType(0));
1279 grid->setTransform(xform.
copy());
1281 if (points.size() > 0) {
1283 grid->tree(), grid->transform(),
points);
1290 template<
typename Gr
idT,
typename Po
intArrayT>
1291 inline typename GridT::Ptr
1295 return createPointIndexGrid<GridT>(
points, *xform);
1299 template<
typename Po
intArrayT,
typename Gr
idT>
1306 for (
size_t n = 0,
N = leafs.leafCount();
n <
N; ++
n) {
1307 pointCount += leafs.
leaf(
n).indices().size();
1314 tbb::atomic<bool> changed;
1318 op(changed, points, grid.transform());
1322 return !bool(changed);
1326 template<
typename Gr
idT,
typename Po
intArrayT>
1327 inline typename GridT::ConstPtr
1334 return createPointIndexGrid<GridT>(
points, grid->transform());
1338 template<
typename Gr
idT,
typename Po
intArrayT>
1339 inline typename GridT::Ptr
1346 return createPointIndexGrid<GridT>(
points, grid->transform());
1353 template<
typename T, Index Log2Dim>
1372 bool isEmpty(
const CoordBBox& bbox)
const;
1405 const T&
value = zeroVal<T>(),
bool active =
false)
1416 template<
typename OtherType, Index OtherLog2Dim>
1427 BaseLeaf::merge<Policy>(rhs);
1429 template<MergePolicy Policy>
void merge(
const ValueType& tileValue,
bool tileActive) {
1430 BaseLeaf::template merge<Policy>(tileValue, tileActive);
1433 template<MergePolicy Policy>
1437 BaseLeaf::template merge<Policy>(other);
1441 template<
typename AccessorT>
1447 template<
typename AccessorT>
1450 template<
typename NodeT,
typename AccessorT>
1455 return reinterpret_cast<NodeT*
>(
this);
1459 template<
typename AccessorT>
1466 template<
typename AccessorT>
1468 template<
typename AccessorT>
1471 template<
typename NodeT,
typename AccessorT>
1476 return reinterpret_cast<const NodeT*
>(
this);
1484 void readBuffers(std::istream& is,
bool fromHalf =
false);
1485 void readBuffers(std::istream& is,
const CoordBBox&,
bool fromHalf =
false);
1486 void writeBuffers(std::ostream& os,
bool toHalf =
false)
const;
1498 assert(
false &&
"Cannot modify voxel values in a PointIndexTree.");
1524 template<
typename ModifyOp>
1527 template<
typename ModifyOp>
1530 template<
typename ModifyOp>
1539 template<
typename AccessorT>
1542 template<
typename ModifyOp,
typename AccessorT>
1547 template<
typename AccessorT>
1550 template<
typename AccessorT>
1606 #define VMASK_ this->getValueMask()
1650 template<
typename T, Index Log2Dim>
1655 return getIndices(LeafNodeType::coordToOffset(ijk), begin, end);
1659 template<
typename T, Index Log2Dim>
1664 if (this->isValueMaskOn(offset)) {
1665 const ValueType* dataPtr = &mIndices.front();
1666 begin = dataPtr + (offset == 0 ?
ValueType(0) : this->
buffer()[offset - 1]);
1674 template<
typename T, Index Log2Dim>
1678 this->
buffer().setValue(offset, val);
1679 this->setValueMaskOn(offset);
1683 template<
typename T, Index Log2Dim>
1687 this->
buffer().setValue(offset, val);
1691 template<
typename T, Index Log2Dim>
1695 Index xPos, pos, zStride =
Index(bbox.max()[2] - bbox.min()[2]);
1698 for (ijk[0] = bbox.min()[0]; ijk[0] <= bbox.max()[0]; ++ijk[0]) {
1699 xPos = (ijk[0] & (DIM - 1u)) << (2 * LOG2DIM);
1701 for (ijk[1] = bbox.min()[1]; ijk[1] <= bbox.max()[1]; ++ijk[1]) {
1702 pos = xPos + ((ijk[1] & (DIM - 1u)) << LOG2DIM);
1703 pos += (bbox.min()[2] & (DIM - 1u));
1705 if (this->
buffer()[pos+zStride] > (pos == 0 ?
T(0) : this->
buffer()[pos - 1])) {
1715 template<
typename T, Index Log2Dim>
1719 BaseLeaf::readBuffers(is, fromHalf);
1722 is.read(reinterpret_cast<char*>(&numIndices),
sizeof(
Index64));
1724 mIndices.resize(
size_t(numIndices));
1725 is.read(reinterpret_cast<char*>(mIndices.data()), numIndices *
sizeof(
T));
1729 template<
typename T, Index Log2Dim>
1734 BaseLeaf::readBuffers(is, bbox, fromHalf);
1737 is.read(reinterpret_cast<char*>(&numIndices),
sizeof(
Index64));
1739 const Index64 numBytes = numIndices *
sizeof(
T);
1741 if (bbox.hasOverlap(
this->getNodeBoundingBox())) {
1742 mIndices.resize(
size_t(numIndices));
1743 is.read(reinterpret_cast<char*>(mIndices.data()), numBytes);
1749 std::unique_ptr<char[]>
buf{
new char[numBytes]};
1750 is.read(
buf.get(), numBytes);
1755 is.read(reinterpret_cast<char*>(&auxDataBytes),
sizeof(
Index64));
1756 if (auxDataBytes > 0) {
1758 std::unique_ptr<char[]> auxData{
new char[auxDataBytes]};
1759 is.read(auxData.get(), auxDataBytes);
1764 template<
typename T, Index Log2Dim>
1768 BaseLeaf::writeBuffers(os, toHalf);
1771 os.write(reinterpret_cast<const char*>(&numIndices),
sizeof(
Index64));
1772 os.write(reinterpret_cast<const char*>(mIndices.data()), numIndices *
sizeof(
T));
1776 os.write(reinterpret_cast<const char*>(&auxDataBytes),
sizeof(
Index64));
1780 template<
typename T, Index Log2Dim>
1784 return BaseLeaf::memUsage() +
Index64((
sizeof(
T)*mIndices.capacity()) +
sizeof(mIndices));
1797 template<Index Dim1,
typename T2>
1807 #endif // OPENVDB_TOOLS_POINT_INDEX_GRID_HAS_BEEN_INCLUDED
Vec2< T > minComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise minimum of the two vectors.
vint4 max(const vint4 &a, const vint4 &b)
void parallel_for(int64_t start, int64_t end, std::function< void(int64_t index)> &&task, parallel_options opt=parallel_options(0, Split_Y, 1))
GA_API const UT_StringHolder dist
Leaf nodes have no children, so their child iterators have no get/set accessors.
cvex test(vector P=0;int unbound=3;export float s=0;export vector Cf=0;)
static const Index NUM_VOXELS
FMT_CONSTEXPR auto begin(const C &c) -> decltype(c.begin())
GLuint const GLfloat * val
GLuint GLsizei const GLuint const GLintptr * offsets
static const Index NUM_VALUES
GLboolean GLboolean GLboolean GLboolean a
vfloat4 sqrt(const vfloat4 &a)
virtual Vec3d applyInverseMap(const Vec3d &in) const =0
#define OPENVDB_USE_VERSION_NAMESPACE
Base class for iterators over internal and leaf nodes.
Selectively extract and filter point data using a custom filter operator.
bool isEmpty() const
Return true if this node has no active voxels.
Tag dispatch class that distinguishes constructors during file input.
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process. If the leaf node already exists, replace it.
Spatially partitions points using a parallel radix-based sorting algorithm.
std::shared_ptr< T > SharedPtr
SYS_FORCE_INLINE const_iterator end() const
std::vector< Index > IndexArray
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
OffMaskIterator< NodeMask > OffIterator
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Return a pointer to the leaf node that contains voxel (x, y, z), or nullptr if no such node exists...
const Vec3T & min() const
Return a const reference to the minimum point of this bounding box.
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
*But if you need a or simply need to know when the task has note that the like this
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
GLuint GLuint GLsizei GLenum const void * indices
This class manages a linear array of pointers to a given tree's leaf nodes, as well as optional auxil...
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
static const Index LOG2DIM
Index64 pointCount(const PointDataTreeT &tree, const FilterT &filter=NullFilter(), const bool inCoreOnly=false, const bool threaded=true)
Count the total number of points in a PointDataTree.
vfloat4 round(const vfloat4 &a)
Container class that associates a tree with a transform and metadata.
const Vec3T & max() const
Return a const reference to the maximum point of this bounding box.
DenseMaskIterator< NodeMask > DenseIterator
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
OnMaskIterator< NodeMask > OnIterator
GLuint GLuint GLsizei count
math::BBox< Vec3d > BBoxd
Vec2< T > maxComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise maximum of the two vectors.
GA_API const UT_StringHolder N
A LeafManager manages a linear array of pointers to a given tree's leaf nodes, as well as optional au...
LeafType & leaf(size_t leafIdx) const
Return a pointer to the leaf node at index leafIdx in the array.
vint4 min(const vint4 &a, const vint4 &b)
bool hasSameTopology(const LeafNode< OtherType, OtherLog2Dim > *other) const
Return true if the given node (which may have a different ValueType than this node) has the same acti...
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
GLenum GLuint GLsizei const GLchar * buf
Abstract base class for maps.
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
GLsizei const GLfloat * value
#define OPENVDB_THROW(exception, message)
bool isInside(const Vec3T &xyz) const
Return true if the given point is inside this bounding box.