Go to the documentation of this file.
37 #ifndef OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED
38 #define OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED
53 #include <tbb/parallel_reduce.h>
55 #include <type_traits>
81 typename CompressionT,
82 typename PointDataGridT,
83 typename PositionArrayT,
84 typename PointIndexGridT>
85 inline typename PointDataGridT::Ptr
87 const PositionArrayT& positions,
88 const math::Transform& xform,
102 template <
typename CompressionT,
typename Po
intDataGr
idT,
typename ValueT>
103 inline typename PointDataGridT::Ptr
105 const math::Transform& xform,
120 template <
typename Po
intDataTreeT,
typename Po
intIndexTreeT,
typename Po
intArrayT>
123 const PointIndexTreeT& pointIndexTree,
125 const PointArrayT& data,
126 const Index stride = 1,
127 const bool insertMetadata =
true);
139 template <
typename PositionAttribute,
typename Po
intDataGr
idT,
typename FilterT = NullFilter>
142 const PointDataGridT& grid,
145 const FilterT& filter = NullFilter(),
146 const bool inCoreOnly =
false);
159 template <
typename TypedAttribute,
typename Po
intDataTreeT,
typename FilterT = NullFilter>
162 const PointDataTreeT& tree,
165 const unsigned arrayIndex,
166 const Index stride = 1,
167 const FilterT& filter = NullFilter(),
168 const bool inCoreOnly =
false);
182 template <
typename Group,
typename Po
intDataTreeT,
typename FilterT = NullFilter>
185 const PointDataTreeT& tree,
188 const AttributeSet::Descriptor::GroupIndex index,
189 const FilterT& filter = NullFilter(),
190 const bool inCoreOnly =
false);
204 template<
typename PositionWrapper,
typename InterrupterT = openvdb::util::NullInterrupter>
207 const uint32_t pointsPerVoxel,
208 const math::Mat4d transform = math::Mat4d::identity(),
209 const Index decimalPlaces = 5,
210 InterrupterT*
const interrupter =
nullptr);
217 template<
typename ValueType>
224 const Index stride = 1)
226 , mStride(stride) { }
228 size_t size()
const {
return mData.size(); }
229 void getPos(
size_t n, ValueType& xyz)
const { xyz = mData[n]; }
230 void get(ValueType& value,
size_t n)
const { value = mData[n]; }
231 void get(ValueType& value,
size_t n,
openvdb::Index m)
const { value = mData[n * mStride + m]; }
234 const std::vector<value_type>& mData;
242 namespace point_conversion_internal {
250 static T
zero() {
return zeroVal<T>(); }
251 template <
typename LeafT>
254 return Handle::create(array);
256 template <
typename LeafT>
259 return WriteHandle::create(array);
267 template <
typename LeafT>
270 const AttributeSet::Descriptor& descriptor = leaf.attributeSet().descriptor();
271 return Handle::create(array, descriptor.getMetadata());
273 template <
typename LeafT>
276 const AttributeSet::Descriptor& descriptor = leaf.attributeSet().descriptor();
277 return WriteHandle::create(array, descriptor.getMetadata());
281 template<
typename PointDataTreeType,
282 typename PointIndexTreeType,
283 typename AttributeListType>
290 using ValueType =
typename AttributeListType::value_type;
294 const AttributeListType& data,
296 const Index stride = 1)
297 : mPointIndexTree(pointIndexTree)
300 , mStride(stride) { }
302 void operator()(
const typename LeafManagerT::LeafRange& range)
const {
304 for (
auto leaf = range.begin(); leaf; ++leaf) {
309 mPointIndexTree.probeConstLeaf(leaf->origin());
311 if (!pointIndexLeaf)
continue;
313 typename HandleT::Ptr attributeWriteHandle =
318 const IndexArray& indices = pointIndexLeaf->indices();
320 for (
const Index64 leafIndex: indices)
323 for (
Index i = 0; i < mStride; i++) {
324 mData.get(value, leafIndex, i);
325 attributeWriteHandle->set(static_cast<Index>(index), i, value);
332 attributeWriteHandle->compact();
344 template<
typename Po
intDataTreeType,
typename Attribute,
typename FilterT>
347 using LeafNode =
typename PointDataTreeType::LeafNodeType;
359 const FilterT& filter,
360 const bool inCoreOnly)
361 : mAttribute(attribute)
363 , mStartOffset(startOffset)
364 , mTransform(transform)
367 , mInCoreOnly(inCoreOnly)
371 std::is_floating_point<typename ValueType::ValueType>::value,
372 "ValueType is not Vec3f");
375 template <
typename IterT>
379 for (; iter; ++iter) {
380 const Vec3d xyz = iter.getCoord().asVec3d();
381 const Vec3d pos = sourceHandle.
get(*iter);
382 targetHandle.set(static_cast<Index>(offset++), 0,
383 mTransform.indexToWorld(pos + xyz));
391 for (
auto leaf = range.begin(); leaf; ++leaf) {
393 assert(leaf.pos() < mPointOffsets.size());
395 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
399 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
401 auto handle = SourceHandleT::create(leaf->constAttributeArray(mIndex));
404 auto iter = leaf->beginIndexOn();
405 convert(iter, pHandle, *handle, offset);
408 auto iter = leaf->beginIndexOn(mFilter);
409 convert(iter, pHandle, *handle, offset);
426 template<
typename Po
intDataTreeType,
typename Attribute,
typename FilterT>
429 using LeafNode =
typename PointDataTreeType::LeafNodeType;
441 const FilterT& filter,
442 const bool inCoreOnly)
443 : mAttribute(attribute)
445 , mStartOffset(startOffset)
449 , mInCoreOnly(inCoreOnly) { }
451 template <
typename IterT>
455 if (sourceHandle.isUniform()) {
456 const ValueType uniformValue(sourceHandle.get(0));
457 for (; iter; ++iter) {
458 for (
Index i = 0; i < mStride; i++) {
459 targetHandle.set(static_cast<Index>(offset), i, uniformValue);
465 for (; iter; ++iter) {
466 for (
Index i = 0; i < mStride; i++) {
467 targetHandle.set(static_cast<Index>(offset), i,
468 sourceHandle.get(*iter, i));
479 for (
auto leaf = range.begin(); leaf; ++leaf) {
481 assert(leaf.pos() < mPointOffsets.size());
483 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
487 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
490 *leaf, static_cast<Index>(mIndex));
493 auto iter = leaf->beginIndexOn();
494 convert(iter, pHandle, *handle, offset);
496 auto iter = leaf->beginIndexOn(mFilter);
497 convert(iter, pHandle, *handle, offset);
513 template<
typename Po
intDataTreeType,
typename Group,
typename FilterT>
516 using LeafNode =
typename PointDataTreeType::LeafNodeType;
524 const AttributeSet::Descriptor::GroupIndex index,
525 const FilterT& filter,
526 const bool inCoreOnly)
529 , mStartOffset(startOffset)
532 , mInCoreOnly(inCoreOnly) { }
534 template <
typename IterT>
537 const auto bitmask = static_cast<GroupType>(1 << mIndex.second);
540 if (groupArray.
get(0) & bitmask) {
541 for (; iter; ++iter) {
542 mGroup.setOffsetOn(static_cast<Index>(offset));
548 for (; iter; ++iter) {
549 if (groupArray.
get(*iter) & bitmask) {
550 mGroup.setOffsetOn(static_cast<Index>(offset));
559 for (
auto leaf = range.begin(); leaf; ++leaf) {
561 assert(leaf.pos() < mPointOffsets.size());
563 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
567 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
569 const AttributeArray& array = leaf->constAttributeArray(mIndex.first);
574 auto iter = leaf->beginIndexOn();
575 convert(iter, groupArray, offset);
578 auto iter = leaf->beginIndexOn(mFilter);
579 convert(iter, groupArray, offset);
594 template<
typename PositionArrayT>
599 : mPositions(positions)
600 , mInverseMat(inverse)
605 : mPositions(other.mPositions)
606 , mInverseMat(other.mInverseMat)
612 for (
size_t n = range.begin(), N = range.end(); n != N; ++n) {
613 mPositions.getPos(n, pos);
614 pos = mInverseMat.transform(pos);
626 return BBoxd(mMin, mMax);
630 const PositionArrayT& mPositions;
641 template<
typename CompressionT,
typename Po
intDataGr
idT,
typename PositionArrayT,
typename Po
intIndexGr
idT>
642 inline typename PointDataGridT::Ptr
646 using PointDataTreeT =
typename PointDataGridT::TreeType;
648 using PointIndexLeafT =
typename PointIndexGridT::TreeType::LeafNodeType;
649 using PointIndexT =
typename PointIndexLeafT::ValueType;
653 const NamePair positionType = PositionAttributeT::attributeType();
657 const auto& pointIndexTree = pointIndexGrid.tree();
658 typename PointDataTreeT::Ptr treePtr(
new PointDataTreeT(pointIndexTree));
662 auto descriptor = AttributeSet::Descriptor::create(positionType);
666 if (positionDefaultValue) descriptor->setDefaultValue(
"P", *positionDefaultValue);
670 const size_t positionIndex = descriptor->find(
"P");
671 assert(positionIndex != AttributeSet::INVALID_POS);
675 LeafManagerT leafManager(*treePtr);
677 [&](LeafT& leaf,
size_t ) {
681 const auto* pointIndexLeaf = pointIndexTree.probeConstLeaf(leaf.origin());
682 assert(pointIndexLeaf);
686 Index pointCount(static_cast<Index>(pointIndexLeaf->indices().size()));
687 leaf.initializeAttributes(descriptor,
pointCount);
692 leaf.attributeArray(positionIndex));
697 *begin = static_cast<PointIndexT*>(
nullptr),
698 *end = static_cast<PointIndexT*>(
nullptr);
702 for (
auto iter = pointIndexLeaf->cbeginValueOn(); iter; ++iter) {
706 const Coord& ijk = iter.getCoord();
711 pointIndexLeaf->getIndices(ijk, begin, end);
713 while (begin < end) {
715 typename PositionArrayT::value_type positionWorldSpace;
716 positions.getPos(*begin, positionWorldSpace);
721 const Vec3f positionVoxelSpace(positionIndexSpace - positionCellCenter);
723 attributeWriteHandle->set(index++, positionVoxelSpace);
731 auto grid = PointDataGridT::create(treePtr);
732 grid->setTransform(xform.
copy());
740 template <
typename CompressionT,
typename Po
intDataGr
idT,
typename ValueT>
741 inline typename PointDataGridT::Ptr
749 return createPointDataGrid<CompressionT, PointDataGridT>(*pointIndexGrid, pointList, xform, positionDefaultValue);
756 template <
typename Po
intDataTreeT,
typename Po
intIndexTreeT,
typename Po
intArrayT>
760 const bool insertMetadata)
763 using ValueType =
typename PointArrayT::value_type;
765 auto iter = tree.cbeginLeaf();
769 const size_t index = iter->attributeSet().find(attributeName);
771 if (index == AttributeSet::INVALID_POS) {
775 if (insertMetadata) {
783 PopulateAttributeOp<PointDataTreeT,
785 PointArrayT> populate(pointIndexTree, data, index, stride);
786 tbb::parallel_for(leafManager.
leafRange(), populate);
793 template <
typename PositionAttribute,
typename Po
intDataGr
idT,
typename FilterT>
796 const PointDataGridT& grid,
799 const FilterT& filter,
800 const bool inCoreOnly)
802 using TreeType =
typename PointDataGridT::TreeType;
807 const TreeType& tree = grid.tree();
808 auto iter = tree.cbeginLeaf();
812 const size_t positionIndex = iter->attributeSet().find(
"P");
814 positionAttribute.expand();
815 LeafManagerT leafManager(tree);
816 ConvertPointDataGridPositionOp<TreeType, PositionAttribute, FilterT> convert(
817 positionAttribute,
pointOffsets, startOffset, grid.transform(), positionIndex,
819 tbb::parallel_for(leafManager.leafRange(), convert);
820 positionAttribute.compact();
827 template <
typename TypedAttribute,
typename Po
intDataTreeT,
typename FilterT>
830 const PointDataTreeT& tree,
833 const unsigned arrayIndex,
835 const FilterT& filter,
836 const bool inCoreOnly)
842 auto iter = tree.cbeginLeaf();
847 LeafManagerT leafManager(tree);
848 ConvertPointDataGridAttributeOp<PointDataTreeT, TypedAttribute, FilterT> convert(
849 attribute,
pointOffsets, startOffset, arrayIndex, stride,
851 tbb::parallel_for(leafManager.leafRange(), convert);
859 template <
typename Group,
typename Po
intDataTreeT,
typename FilterT>
862 const PointDataTreeT& tree,
865 const AttributeSet::Descriptor::GroupIndex index,
866 const FilterT& filter,
867 const bool inCoreOnly)
873 auto iter = tree.cbeginLeaf();
876 LeafManagerT leafManager(tree);
877 ConvertPointDataGridGroupOp<PointDataTree, Group, FilterT> convert(
880 tbb::parallel_for(leafManager.leafRange(), convert);
887 template<
typename PositionWrapper,
typename InterrupterT>
890 const uint32_t pointsPerVoxel,
892 const Index decimalPlaces,
893 InterrupterT*
const interrupter)
895 using namespace point_conversion_internal;
899 static bool voxelSizeFromVolume(
const double volume,
900 const size_t estimatedVoxelCount,
904 static const double minimumVoxelVolume(3e-15);
907 double voxelVolume = volume / static_cast<double>(estimatedVoxelCount);
910 if (voxelVolume < minimumVoxelVolume) {
911 voxelVolume = minimumVoxelVolume;
914 else if (voxelVolume > maximumVoxelVolume) {
915 voxelVolume = maximumVoxelVolume;
919 voxelSize = static_cast<float>(
math::Pow(voxelVolume, 1.0/3.0));
923 static float truncate(
const float voxelSize,
Index decPlaces)
925 float truncatedVoxelSize = voxelSize;
928 for (
int i = decPlaces; i < 11; i++) {
929 truncatedVoxelSize = static_cast<float>(
math::Truncate(
double(voxelSize), i));
930 if (truncatedVoxelSize != 0.0f)
break;
933 return truncatedVoxelSize;
941 float voxelSize(0.1f);
943 const size_t numPoints = positions.size();
947 if (numPoints <= 1)
return voxelSize;
949 size_t targetVoxelCount(numPoints /
size_t(pointsPerVoxel));
950 if (targetVoxelCount == 0) targetVoxelCount++;
955 inverseTransform =
math::unit(inverseTransform);
957 tbb::blocked_range<size_t> range(0, numPoints);
958 CalculatePositionBounds<PositionWrapper>
calculateBounds(positions, inverseTransform);
965 if (bbox.
min() == bbox.
max())
return voxelSize;
967 double volume = bbox.
volume();
975 volume = extents[0]*extents[0]*extents[0];
979 volume = extents[0]*extents[1]*extents[1];
983 double previousVolume = volume;
985 if (!Local::voxelSizeFromVolume(volume, targetVoxelCount, voxelSize)) {
990 size_t previousVoxelCount(0);
991 size_t voxelCount(1);
993 if (interrupter) interrupter->start(
"Computing voxel size");
995 while (voxelCount > previousVoxelCount)
1006 newTransform = math::Transform::createLinearTransform(matrix);
1010 newTransform = math::Transform::createLinearTransform(voxelSize);
1018 mask->setTransform(newTransform);
1024 previousVoxelCount = voxelCount;
1025 voxelCount = mask->activeVoxelCount();
1026 volume =
math::Pow3(voxelSize) * static_cast<float>(voxelCount);
1030 if (volume >= previousVolume)
break;
1031 previousVolume = volume;
1033 const float previousVoxelSize = voxelSize;
1037 if (!Local::voxelSizeFromVolume(volume, targetVoxelCount, voxelSize)) {
1038 voxelSize = previousVoxelSize;
1045 if (voxelSize / previousVoxelSize > 0.9f)
break;
1048 if (interrupter) interrupter->end();
1052 return Local::truncate(voxelSize, decimalPlaces);
1062 template <
typename PositionAttribute,
typename Po
intDataGr
idT>
1066 const PointDataGridT& grid,
1069 const std::vector<Name>& includeGroups,
1070 const std::vector<Name>& excludeGroups,
1071 const bool inCoreOnly =
false)
1073 auto leaf = grid.tree().cbeginLeaf();
1075 MultiGroupFilter filter(includeGroups, excludeGroups, leaf->attributeSet());
1077 filter, inCoreOnly);
1081 template <
typename TypedAttribute,
typename Po
intDataTreeT>
1085 const PointDataTreeT& tree,
1088 const unsigned arrayIndex,
1090 const std::vector<Name>& includeGroups,
1091 const std::vector<Name>& excludeGroups,
1092 const bool inCoreOnly =
false)
1094 auto leaf = tree.cbeginLeaf();
1096 MultiGroupFilter filter(includeGroups, excludeGroups, leaf->attributeSet());
1098 arrayIndex, stride, filter, inCoreOnly);
1102 template <
typename Group,
typename Po
intDataTreeT>
1106 const PointDataTreeT& tree,
1109 const AttributeSet::Descriptor::GroupIndex index,
1110 const std::vector<Name>& includeGroups,
1111 const std::vector<Name>& excludeGroups,
1112 const bool inCoreOnly =
false)
1114 auto leaf = tree.cbeginLeaf();
1116 MultiGroupFilter filter(includeGroups, excludeGroups, leaf->attributeSet());
1118 index, filter, inCoreOnly);
1126 #endif // OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:518
ValueType get(Index n) const
Return the value at index n.
Definition: AttributeArray.h:1414
Mat4 inverse(T tolerance=0) const
Definition: Mat4.h:531
typename ConversionTraits< ValueType >::WriteHandle HandleT
Definition: PointConversion.h:291
Set of Attribute Arrays which tracks metadata about each array.
Group & mGroup
Definition: PointConversion.h:586
const Index64 mStartOffset
Definition: PointConversion.h:588
const math::Transform & mTransform
Definition: PointConversion.h:419
Definition: AttributeArray.h:846
SharedPtr< Grid > Ptr
Definition: Grid.h:592
const Index mStride
Definition: PointConversion.h:508
const Index64 mStartOffset
Definition: PointConversion.h:418
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:352
void get(ValueType &value, size_t n) const
Definition: PointConversion.h:230
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:347
typename ConversionTraits< ValueType >::Handle SourceHandleT
Definition: PointConversion.h:432
const size_t mIndex
Definition: PointConversion.h:420
Definition: Exceptions.h:86
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:519
const Index mStride
Definition: PointConversion.h:341
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:434
OPENVDB_DEPRECATED void convertPointDataGridPosition(PositionAttribute &positionAttribute, const PointDataGridT &grid, const std::vector< Index64 > &pointOffsets, const Index64 startOffset, const std::vector< Name > &includeGroups, const std::vector< Name > &excludeGroups, const bool inCoreOnly=false)
Definition: PointConversion.h:1065
ValueType get(Index n, Index m=0) const
Definition: AttributeArray.h:2190
Point group manipulation in a VDB Point Grid.
Vec3T extents() const
Return the extents of this bounding box, i.e., the length along each axis.
Definition: BBox.h:280
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:387
typename Attribute::ValueType ValueType
Definition: PointConversion.h:348
void join(const CalculatePositionBounds &other)
Definition: PointConversion.h:620
ValueType value_type
Definition: PointConversion.h:221
Base class for storing attribute data.
Definition: AttributeArray.h:118
void get(ValueType &value, size_t n, openvdb::Index m) const
Definition: PointConversion.h:231
OPENVDB_DEPRECATED void convertPointDataGridGroup(Group &group, const PointDataTreeT &tree, const std::vector< Index64 > &pointOffsets, const Index64 startOffset, const AttributeSet::Descriptor::GroupIndex index, const std::vector< Name > &includeGroups, const std::vector< Name > &excludeGroups, const bool inCoreOnly=false)
Definition: PointConversion.h:1105
void convert(IterT &iter, HandleT &targetHandle, SourceHandleT &sourceHandle, Index64 &offset) const
Definition: PointConversion.h:376
Definition: PointConversion.h:345
Vec3< T > reversed() const
Return the vector (z, y, x)
Definition: Vec3.h:485
CalculatePositionBounds(const CalculatePositionBounds &other, tbb::split)
Definition: PointConversion.h:604
typename Attribute::Handle HandleT
Definition: PointConversion.h:349
Definition: IndexFilter.h:163
bool isIdentity(const MatType &m)
Determine if a matrix is an identity matrix.
Definition: Mat.h:892
void convert(IterT &iter, HandleT &targetHandle, SourceHandleT &sourceHandle, Index64 &offset) const
Definition: PointConversion.h:452
Space-partitioning acceleration structure for points. Partitions the points into voxels to accelerate...
bool isGroup(const AttributeArray &array)
Definition: AttributeGroup.h:93
Type Pow(Type x, int n)
Return xn.
Definition: Math.h:515
Definition: PointConversion.h:427
Definition: IndexIterator.h:70
AttributeSet::Descriptor::GroupIndex GroupIndex
Definition: PointConversion.h:517
void operator()(const tbb::blocked_range< size_t > &range)
Definition: PointConversion.h:610
const PointIndexTreeType & mPointIndexTree
Definition: PointConversion.h:338
CalculatePositionBounds(const PositionArrayT &positions, const math::Mat4d &inverse)
Definition: PointConversion.h:597
OPENVDB_API void calculateBounds(const Transform &t, const Vec3d &minWS, const Vec3d &maxWS, Vec3d &minIS, Vec3d &maxIS)
Calculate an axis-aligned bounding box in index space from an axis-aligned bounding box in world spac...
This class manages a linear array of pointers to a given tree's leaf nodes, as well as optional auxil...
Definition: LeafManager.h:109
void operator()(const typename LeafManagerT::LeafRange &range) const
Definition: PointConversion.h:302
bool wasInterrupted(T *i, int percent=-1)
Definition: NullInterrupter.h:76
const GroupIndex mIndex
Definition: PointConversion.h:589
Type Pow3(Type x)
Return x3.
Definition: Math.h:506
static Handle::Ptr handleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:268
Index filters primarily designed to be used with a FilterIndexIter.
typename Attribute::Handle HandleT
Definition: PointConversion.h:431
float computeVoxelSize(const PositionWrapper &positions, const uint32_t pointsPerVoxel, const math::Mat4d transform=math::Mat4d::identity(), const Index decimalPlaces=5, InterrupterT *const interrupter=nullptr)
Definition: PointConversion.h:889
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:433
Vec3d asVec3d() const
Definition: Coord.h:171
const size_t mIndex
Definition: PointConversion.h:340
Vec2< T > minComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise minimum of the two vectors.
Definition: Vec2.h:530
Point-partitioner compatible STL vector attribute wrapper for convenience.
Definition: PointConversion.h:218
const FilterT & mFilter
Definition: PointConversion.h:421
static WriteHandle::Ptr writeHandleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:257
void getPos(size_t n, ValueType &xyz) const
Definition: PointConversion.h:229
std::vector< Index > IndexArray
Definition: PointMove.h:188
BBoxd getBoundingBox() const
Definition: PointConversion.h:625
typename RootNodeType::LeafNodeType LeafNodeType
Definition: Tree.h:212
const size_t mIndex
Definition: PointConversion.h:507
const bool mInCoreOnly
Definition: PointConversion.h:591
Definition: Exceptions.h:92
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:587
size_t size() const
Definition: PointConversion.h:228
Point attribute manipulation in a VDB Point Grid.
OPENVDB_DEPRECATED void convertPointDataGridAttribute(TypedAttribute &attribute, const PointDataTreeT &tree, const std::vector< Index64 > &pointOffsets, const Index64 startOffset, const unsigned arrayIndex, const Index stride, const std::vector< Name > &includeGroups, const std::vector< Name > &excludeGroups, const bool inCoreOnly=false)
Definition: PointConversion.h:1084
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition: LeafManager.h:385
static Handle::Ptr handleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:252
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
Vec2< T > maxComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise maximum of the two vectors.
Definition: Vec2.h:539
ConvertPointDataGridGroupOp(Group &group, const std::vector< Index64 > &pointOffsets, const Index64 startOffset, const AttributeSet::Descriptor::GroupIndex index, const FilterT &filter, const bool inCoreOnly)
Definition: PointConversion.h:521
const bool mInCoreOnly
Definition: PointConversion.h:422
const bool mInCoreOnly
Definition: PointConversion.h:510
const FilterT & mFilter
Definition: PointConversion.h:590
Definition: PointConversion.h:246
Index32 Index
Definition: Types.h:61
Definition: AttributeArrayString.h:168
void populateAttribute(PointDataTreeT &tree, const PointIndexTreeT &pointIndexTree, const openvdb::Name &attributeName, const PointArrayT &data, const Index stride=1, const bool insertMetadata=true)
Stores point attribute data in an existing PointDataGrid attribute.
Definition: PointConversion.h:758
static WriteHandle::Ptr writeHandleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:274
PointDataGridT::Ptr createPointDataGrid(const std::vector< ValueT > &positions, const math::Transform &xform, Metadata::Ptr positionDefaultValue=Metadata::Ptr())
Convenience method to create a PointDataGrid from a std::vector of point positions.
Definition: PointConversion.h:742
PointAttributeVector(const std::vector< value_type > &data, const Index stride=1)
Definition: PointConversion.h:223
Definition: PointConversion.h:595
Attribute & mAttribute
Definition: PointConversion.h:504
ElementType volume() const
Return the volume enclosed by this bounding box.
Definition: BBox.h:127
ValueType PosType
Definition: PointConversion.h:220
double Real
Definition: Types.h:67
uint64_t Index64
Definition: Types.h:60
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.
Definition: PointCount.h:115
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:52
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:65
void preScale(const Vec3< T0 > &v)
Definition: Mat4.h:782
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointConversion.h:286
std::shared_ptr< Handle > Ptr
Definition: AttributeArray.h:850
Index64 pointOffsets(std::vector< Index64 > &pointOffsets, const PointDataTreeT &tree, const FilterT &filter=NullFilter(), const bool inCoreOnly=false, const bool threaded=true)
Populate an array of cumulative point offsets per leaf node.
Definition: PointCount.h:149
Type Truncate(Type x, unsigned int digits)
Return x truncated to the given number of decimal digits.
Definition: Math.h:824
const Vec3T & min() const
Return a const reference to the minimum point of this bounding box.
Definition: BBox.h:89
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:287
MatType unit(const MatType &mat, typename MatType::value_type eps=1.0e-8)
Return a copy of the given matrix with its upper 3×3 rows normalized.
Definition: Mat.h:680
Attribute array storage for string data using Descriptor Metadata.
const AttributeListType & mData
Definition: PointConversion.h:339
Definition: AttributeArrayString.h:136
std::shared_ptr< Handle > Ptr
Definition: AttributeArray.h:921
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:177
const Vec3T & max() const
Return a const reference to the maximum point of this bounding box.
Definition: BBox.h:91
static openvdb::Name zero()
Definition: PointConversion.h:266
Vec3< double > Vec3d
Definition: Vec3.h:689
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:475
const FilterT & mFilter
Definition: PointConversion.h:509
std::shared_ptr< StringAttributeWriteHandle > Ptr
Definition: AttributeArrayString.h:171
Definition: PointConversion.h:514
Definition: PointConversion.h:284
typename AttributeListType::value_type ValueType
Definition: PointConversion.h:290
static T zero()
Definition: PointConversion.h:250
Write-able version of AttributeHandle.
Definition: AttributeArray.h:917
bool isUniform() const override
Return true if this array is stored as a single uniform value.
Definition: AttributeArray.h:719
ConvertPointDataGridPositionOp(Attribute &attribute, const std::vector< Index64 > &pointOffsets, const Index64 startOffset, const math::Transform &transform, const size_t index, const FilterT &filter, const bool inCoreOnly)
Definition: PointConversion.h:354
Vec3< T > sorted() const
Return a vector with the components of this in ascending order.
Definition: Vec3.h:475
Attribute & mAttribute
Definition: PointConversion.h:416
typename Attribute::ValueType ValueType
Definition: PointConversion.h:430
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:516
typename PointIndexTreeType::LeafNodeType PointIndexLeafNode
Definition: PointConversion.h:288
Vec3< typename MatType::value_type > getScale(const MatType &mat)
Return a Vec3 representing the lengths of the passed matrix's upper 3×3's rows.
Definition: Mat.h:665
PopulateAttributeOp(const PointIndexTreeType &pointIndexTree, const AttributeListType &data, const size_t index, const Index stride=1)
Definition: PointConversion.h:293
#define OPENVDB_LOG_DEBUG(message)
In debug builds only, log a debugging message of the form 'someVar << "text" << .....
Definition: logging.h:290
This tool produces a grid where every voxel that contains a point is active. It employes thread-local...
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:125
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:505
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:417
Typed class for storing attribute data.
Definition: AttributeArray.h:584
Mat4< double > Mat4d
Definition: Mat4.h:1361
typename PointIndexLeafNode::IndexArray IndexArray
Definition: PointConversion.h:289
Definition: Exceptions.h:40
ConvertPointDataGridAttributeOp(Attribute &attribute, const std::vector< Index64 > &pointOffsets, const Index64 startOffset, const size_t index, const Index stride, const FilterT &filter, const bool inCoreOnly)
Definition: PointConversion.h:436
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:429
std::shared_ptr< StringAttributeHandle > Ptr
Definition: AttributeArrayString.h:139
const Index64 mStartOffset
Definition: PointConversion.h:506
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:557
std::string Name
Definition: Name.h:44
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
math::BBox< Vec3d > BBoxd
Definition: Types.h:91
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:351
bool isApproxZero(const Type &x)
Return true if x is equal to zero to within the default floating-point comparison tolerance.
Definition: Math.h:320
void convert(IterT &iter, const GroupAttributeArray &groupArray, Index64 &offset) const
Definition: PointConversion.h:535