Go to the documentation of this file.
10 #ifndef OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED
11 #define OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED
26 #include <tbb/parallel_reduce.h>
28 #include <type_traits>
54 typename CompressionT,
55 typename PointDataGridT,
56 typename PositionArrayT,
57 typename PointIndexGridT>
58 inline typename PointDataGridT::Ptr
60 const PositionArrayT& positions,
61 const math::Transform& xform,
75 template <
typename CompressionT,
typename Po
intDataGr
idT,
typename ValueT>
76 inline typename PointDataGridT::Ptr
78 const math::Transform& xform,
93 template <
typename Po
intDataTreeT,
typename Po
intIndexTreeT,
typename Po
intArrayT>
96 const PointIndexTreeT& pointIndexTree,
98 const PointArrayT& data,
99 const Index stride = 1,
100 const bool insertMetadata =
true);
112 template <
typename PositionAttribute,
typename Po
intDataGr
idT,
typename FilterT = NullFilter>
115 const PointDataGridT& grid,
118 const FilterT& filter = NullFilter(),
119 const bool inCoreOnly =
false);
132 template <
typename TypedAttribute,
typename Po
intDataTreeT,
typename FilterT = NullFilter>
135 const PointDataTreeT& tree,
138 const unsigned arrayIndex,
139 const Index stride = 1,
140 const FilterT& filter = NullFilter(),
141 const bool inCoreOnly =
false);
155 template <
typename Group,
typename Po
intDataTreeT,
typename FilterT = NullFilter>
158 const PointDataTreeT& tree,
161 const AttributeSet::Descriptor::GroupIndex index,
162 const FilterT& filter = NullFilter(),
163 const bool inCoreOnly =
false);
177 template<
typename PositionWrapper,
typename InterrupterT = openvdb::util::NullInterrupter>
180 const uint32_t pointsPerVoxel,
181 const math::Mat4d transform = math::Mat4d::identity(),
182 const Index decimalPlaces = 5,
183 InterrupterT*
const interrupter =
nullptr);
190 template<
typename ValueType>
197 const Index stride = 1)
199 , mStride(stride) { }
201 size_t size()
const {
return mData.size(); }
202 void getPos(
size_t n, ValueType& xyz)
const { xyz = mData[n]; }
203 void get(ValueType& value,
size_t n)
const { value = mData[n]; }
204 void get(ValueType& value,
size_t n,
openvdb::Index m)
const { value = mData[n * mStride + m]; }
207 const std::vector<value_type>& mData;
215 namespace point_conversion_internal {
223 static T
zero() {
return zeroVal<T>(); }
224 template <
typename LeafT>
227 return Handle::create(array);
229 template <
typename LeafT>
232 return WriteHandle::create(array);
240 template <
typename LeafT>
243 const AttributeSet::Descriptor& descriptor = leaf.attributeSet().descriptor();
244 return Handle::create(array, descriptor.getMetadata());
246 template <
typename LeafT>
249 const AttributeSet::Descriptor& descriptor = leaf.attributeSet().descriptor();
250 return WriteHandle::create(array, descriptor.getMetadata());
254 template<
typename PointDataTreeType,
255 typename PointIndexTreeType,
256 typename AttributeListType>
263 using ValueType =
typename AttributeListType::value_type;
267 const AttributeListType& data,
269 const Index stride = 1)
270 : mPointIndexTree(pointIndexTree)
273 , mStride(stride) { }
275 void operator()(
const typename LeafManagerT::LeafRange& range)
const {
277 for (
auto leaf = range.begin(); leaf; ++leaf) {
282 mPointIndexTree.probeConstLeaf(leaf->origin());
284 if (!pointIndexLeaf)
continue;
286 typename HandleT::Ptr attributeWriteHandle =
291 const IndexArray& indices = pointIndexLeaf->indices();
293 for (
const Index64 leafIndex: indices)
296 for (
Index i = 0; i < mStride; i++) {
297 mData.get(value, leafIndex, i);
298 attributeWriteHandle->set(static_cast<Index>(index), i, value);
305 attributeWriteHandle->compact();
317 template<
typename Po
intDataTreeType,
typename Attribute,
typename FilterT>
320 using LeafNode =
typename PointDataTreeType::LeafNodeType;
332 const FilterT& filter,
333 const bool inCoreOnly)
334 : mAttribute(attribute)
336 , mStartOffset(startOffset)
337 , mTransform(transform)
340 , mInCoreOnly(inCoreOnly)
344 std::is_floating_point<typename ValueType::ValueType>::value,
345 "ValueType is not Vec3f");
348 template <
typename IterT>
352 for (; iter; ++iter) {
353 const Vec3d xyz = iter.getCoord().asVec3d();
354 const Vec3d pos = sourceHandle.
get(*iter);
355 targetHandle.set(static_cast<Index>(offset++), 0,
356 mTransform.indexToWorld(pos + xyz));
364 for (
auto leaf = range.begin(); leaf; ++leaf) {
366 assert(leaf.pos() < mPointOffsets.size());
368 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
372 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
374 auto handle = SourceHandleT::create(leaf->constAttributeArray(mIndex));
377 auto iter = leaf->beginIndexOn();
378 convert(iter, pHandle, *handle, offset);
381 auto iter = leaf->beginIndexOn(mFilter);
382 convert(iter, pHandle, *handle, offset);
399 template<
typename Po
intDataTreeType,
typename Attribute,
typename FilterT>
402 using LeafNode =
typename PointDataTreeType::LeafNodeType;
414 const FilterT& filter,
415 const bool inCoreOnly)
416 : mAttribute(attribute)
418 , mStartOffset(startOffset)
422 , mInCoreOnly(inCoreOnly) { }
424 template <
typename IterT>
428 if (sourceHandle.isUniform()) {
429 const ValueType uniformValue(sourceHandle.get(0));
430 for (; iter; ++iter) {
431 for (
Index i = 0; i < mStride; i++) {
432 targetHandle.set(static_cast<Index>(offset), i, uniformValue);
438 for (; iter; ++iter) {
439 for (
Index i = 0; i < mStride; i++) {
440 targetHandle.set(static_cast<Index>(offset), i,
441 sourceHandle.get(*iter, i));
452 for (
auto leaf = range.begin(); leaf; ++leaf) {
454 assert(leaf.pos() < mPointOffsets.size());
456 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
460 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
463 *leaf, static_cast<Index>(mIndex));
466 auto iter = leaf->beginIndexOn();
467 convert(iter, pHandle, *handle, offset);
469 auto iter = leaf->beginIndexOn(mFilter);
470 convert(iter, pHandle, *handle, offset);
486 template<
typename Po
intDataTreeType,
typename Group,
typename FilterT>
489 using LeafNode =
typename PointDataTreeType::LeafNodeType;
497 const AttributeSet::Descriptor::GroupIndex index,
498 const FilterT& filter,
499 const bool inCoreOnly)
502 , mStartOffset(startOffset)
505 , mInCoreOnly(inCoreOnly) { }
507 template <
typename IterT>
510 const auto bitmask = static_cast<GroupType>(1 << mIndex.second);
513 if (groupArray.
get(0) & bitmask) {
514 for (; iter; ++iter) {
515 mGroup.setOffsetOn(static_cast<Index>(offset));
521 for (; iter; ++iter) {
522 if (groupArray.
get(*iter) & bitmask) {
523 mGroup.setOffsetOn(static_cast<Index>(offset));
532 for (
auto leaf = range.begin(); leaf; ++leaf) {
534 assert(leaf.pos() < mPointOffsets.size());
536 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
540 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
542 const AttributeArray& array = leaf->constAttributeArray(mIndex.first);
547 auto iter = leaf->beginIndexOn();
548 convert(iter, groupArray, offset);
551 auto iter = leaf->beginIndexOn(mFilter);
552 convert(iter, groupArray, offset);
567 template<
typename PositionArrayT>
572 : mPositions(positions)
573 , mInverseMat(inverse)
578 : mPositions(other.mPositions)
579 , mInverseMat(other.mInverseMat)
585 for (
size_t n = range.begin(), N = range.end(); n != N; ++n) {
586 mPositions.getPos(n, pos);
587 pos = mInverseMat.transform(pos);
599 return BBoxd(mMin, mMax);
603 const PositionArrayT& mPositions;
614 template<
typename CompressionT,
typename Po
intDataGr
idT,
typename PositionArrayT,
typename Po
intIndexGr
idT>
615 inline typename PointDataGridT::Ptr
619 using PointDataTreeT =
typename PointDataGridT::TreeType;
621 using PointIndexLeafT =
typename PointIndexGridT::TreeType::LeafNodeType;
622 using PointIndexT =
typename PointIndexLeafT::ValueType;
626 const NamePair positionType = PositionAttributeT::attributeType();
630 const auto& pointIndexTree = pointIndexGrid.tree();
631 typename PointDataTreeT::Ptr treePtr(
new PointDataTreeT(pointIndexTree));
635 auto descriptor = AttributeSet::Descriptor::create(positionType);
639 if (positionDefaultValue) descriptor->setDefaultValue(
"P", *positionDefaultValue);
643 const size_t positionIndex = descriptor->find(
"P");
644 assert(positionIndex != AttributeSet::INVALID_POS);
652 LeafManagerT leafManager(*treePtr);
654 [&](LeafT& leaf,
size_t ) {
658 const auto* pointIndexLeaf = pointIndexTree.probeConstLeaf(leaf.origin());
659 assert(pointIndexLeaf);
663 Index pointCount(static_cast<Index>(pointIndexLeaf->indices().size()));
664 leaf.initializeAttributes(descriptor,
pointCount, &lock);
669 leaf.attributeArray(positionIndex));
674 *begin = static_cast<PointIndexT*>(
nullptr),
675 *end = static_cast<PointIndexT*>(
nullptr);
679 for (
auto iter = pointIndexLeaf->cbeginValueOn(); iter; ++iter) {
683 const Coord& ijk = iter.getCoord();
688 pointIndexLeaf->getIndices(ijk, begin, end);
690 while (begin < end) {
692 typename PositionArrayT::value_type positionWorldSpace;
693 positions.getPos(*begin, positionWorldSpace);
698 const Vec3f positionVoxelSpace(positionIndexSpace - positionCellCenter);
700 attributeWriteHandle->set(index++, positionVoxelSpace);
708 auto grid = PointDataGridT::create(treePtr);
709 grid->setTransform(xform.
copy());
717 template <
typename CompressionT,
typename Po
intDataGr
idT,
typename ValueT>
718 inline typename PointDataGridT::Ptr
726 return createPointDataGrid<CompressionT, PointDataGridT>(*pointIndexGrid, pointList, xform, positionDefaultValue);
733 template <
typename Po
intDataTreeT,
typename Po
intIndexTreeT,
typename Po
intArrayT>
737 const bool insertMetadata)
740 using ValueType =
typename PointArrayT::value_type;
742 auto iter = tree.cbeginLeaf();
746 const size_t index = iter->attributeSet().find(attributeName);
748 if (index == AttributeSet::INVALID_POS) {
752 if (insertMetadata) {
760 PopulateAttributeOp<PointDataTreeT,
762 PointArrayT> populate(pointIndexTree, data, index, stride);
763 tbb::parallel_for(leafManager.
leafRange(), populate);
770 template <
typename PositionAttribute,
typename Po
intDataGr
idT,
typename FilterT>
773 const PointDataGridT& grid,
776 const FilterT& filter,
777 const bool inCoreOnly)
779 using TreeType =
typename PointDataGridT::TreeType;
784 const TreeType& tree = grid.tree();
785 auto iter = tree.cbeginLeaf();
789 const size_t positionIndex = iter->attributeSet().find(
"P");
791 positionAttribute.expand();
792 LeafManagerT leafManager(tree);
793 ConvertPointDataGridPositionOp<TreeType, PositionAttribute, FilterT> convert(
794 positionAttribute,
pointOffsets, startOffset, grid.transform(), positionIndex,
796 tbb::parallel_for(leafManager.leafRange(), convert);
797 positionAttribute.compact();
804 template <
typename TypedAttribute,
typename Po
intDataTreeT,
typename FilterT>
807 const PointDataTreeT& tree,
810 const unsigned arrayIndex,
812 const FilterT& filter,
813 const bool inCoreOnly)
819 auto iter = tree.cbeginLeaf();
824 LeafManagerT leafManager(tree);
825 ConvertPointDataGridAttributeOp<PointDataTreeT, TypedAttribute, FilterT> convert(
826 attribute,
pointOffsets, startOffset, arrayIndex, stride,
828 tbb::parallel_for(leafManager.leafRange(), convert);
836 template <
typename Group,
typename Po
intDataTreeT,
typename FilterT>
839 const PointDataTreeT& tree,
842 const AttributeSet::Descriptor::GroupIndex index,
843 const FilterT& filter,
844 const bool inCoreOnly)
850 auto iter = tree.cbeginLeaf();
853 LeafManagerT leafManager(tree);
854 ConvertPointDataGridGroupOp<PointDataTree, Group, FilterT> convert(
857 tbb::parallel_for(leafManager.leafRange(), convert);
864 template<
typename PositionWrapper,
typename InterrupterT>
867 const uint32_t pointsPerVoxel,
869 const Index decimalPlaces,
870 InterrupterT*
const interrupter)
872 using namespace point_conversion_internal;
876 static bool voxelSizeFromVolume(
const double volume,
877 const size_t estimatedVoxelCount,
881 static const double minimumVoxelVolume(3e-15);
884 double voxelVolume = volume / static_cast<double>(estimatedVoxelCount);
887 if (voxelVolume < minimumVoxelVolume) {
888 voxelVolume = minimumVoxelVolume;
891 else if (voxelVolume > maximumVoxelVolume) {
892 voxelVolume = maximumVoxelVolume;
896 voxelSize = static_cast<float>(
math::Pow(voxelVolume, 1.0/3.0));
900 static float truncate(
const float voxelSize,
Index decPlaces)
902 float truncatedVoxelSize = voxelSize;
905 for (
int i = decPlaces; i < 11; i++) {
906 truncatedVoxelSize = static_cast<float>(
math::Truncate(
double(voxelSize), i));
907 if (truncatedVoxelSize != 0.0f)
break;
910 return truncatedVoxelSize;
918 float voxelSize(0.1f);
920 const size_t numPoints = positions.size();
924 if (numPoints <= 1)
return voxelSize;
926 size_t targetVoxelCount(numPoints /
size_t(pointsPerVoxel));
927 if (targetVoxelCount == 0) targetVoxelCount++;
932 inverseTransform =
math::unit(inverseTransform);
934 tbb::blocked_range<size_t> range(0, numPoints);
935 CalculatePositionBounds<PositionWrapper>
calculateBounds(positions, inverseTransform);
942 if (bbox.
min() == bbox.
max())
return voxelSize;
944 double volume = bbox.
volume();
952 volume = extents[0]*extents[0]*extents[0];
956 volume = extents[0]*extents[1]*extents[1];
960 double previousVolume = volume;
962 if (!Local::voxelSizeFromVolume(volume, targetVoxelCount, voxelSize)) {
967 size_t previousVoxelCount(0);
968 size_t voxelCount(1);
970 if (interrupter) interrupter->start(
"Computing voxel size");
972 while (voxelCount > previousVoxelCount)
983 newTransform = math::Transform::createLinearTransform(matrix);
987 newTransform = math::Transform::createLinearTransform(voxelSize);
995 mask->setTransform(newTransform);
1001 previousVoxelCount = voxelCount;
1002 voxelCount = mask->activeVoxelCount();
1003 volume =
math::Pow3(voxelSize) * static_cast<float>(voxelCount);
1007 if (volume >= previousVolume)
break;
1008 previousVolume = volume;
1010 const float previousVoxelSize = voxelSize;
1014 if (!Local::voxelSizeFromVolume(volume, targetVoxelCount, voxelSize)) {
1015 voxelSize = previousVoxelSize;
1022 if (voxelSize / previousVoxelSize > 0.9f)
break;
1025 if (interrupter) interrupter->end();
1029 return Local::truncate(voxelSize, decimalPlaces);
1039 template <
typename PositionAttribute,
typename Po
intDataGr
idT>
1043 const PointDataGridT& grid,
1046 const std::vector<Name>& includeGroups,
1047 const std::vector<Name>& excludeGroups,
1048 const bool inCoreOnly =
false)
1050 auto leaf = grid.tree().cbeginLeaf();
1052 MultiGroupFilter filter(includeGroups, excludeGroups, leaf->attributeSet());
1054 filter, inCoreOnly);
1058 template <
typename TypedAttribute,
typename Po
intDataTreeT>
1062 const PointDataTreeT& tree,
1065 const unsigned arrayIndex,
1067 const std::vector<Name>& includeGroups,
1068 const std::vector<Name>& excludeGroups,
1069 const bool inCoreOnly =
false)
1071 auto leaf = tree.cbeginLeaf();
1073 MultiGroupFilter filter(includeGroups, excludeGroups, leaf->attributeSet());
1075 arrayIndex, stride, filter, inCoreOnly);
1079 template <
typename Group,
typename Po
intDataTreeT>
1083 const PointDataTreeT& tree,
1086 const AttributeSet::Descriptor::GroupIndex index,
1087 const std::vector<Name>& includeGroups,
1088 const std::vector<Name>& excludeGroups,
1089 const bool inCoreOnly =
false)
1091 auto leaf = tree.cbeginLeaf();
1093 MultiGroupFilter filter(includeGroups, excludeGroups, leaf->attributeSet());
1095 index, filter, inCoreOnly);
1103 #endif // OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED
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:719
const math::Transform & mTransform
Definition: PointConversion.h:392
void convert(IterT &iter, const GroupAttributeArray &groupArray, Index64 &offset) const
Definition: PointConversion.h:508
ValueType PosType
Definition: PointConversion.h:193
std::shared_ptr< Handle > Ptr
Definition: AttributeArray.h:924
const Index64 mStartOffset
Definition: PointConversion.h:561
const Index mStride
Definition: PointConversion.h:481
Set of Attribute Arrays which tracks metadata about each array.
void preScale(const Vec3< T0 > &v)
Definition: Mat4.h:755
Point-partitioner compatible STL vector attribute wrapper for convenience.
Definition: PointConversion.h:191
bool isIdentity(const MatType &m)
Determine if a matrix is an identity matrix.
Definition: Mat.h:865
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:88
ValueType get(Index n) const
Return the value at index n.
Definition: AttributeArray.h:1433
size_t size() const
Definition: PointConversion.h:201
typename Attribute::ValueType ValueType
Definition: PointConversion.h:321
const FilterT & mFilter
Definition: PointConversion.h:563
ElementType volume() const
Return the volume enclosed by this bounding box.
Definition: BBox.h:100
const Index64 mStartOffset
Definition: PointConversion.h:391
Definition: AttributeArrayString.h:109
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:1061
Point group manipulation in a VDB Point Grid.
Base class for storing attribute data.
Definition: AttributeArray.h:92
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:638
std::shared_ptr< Handle > Ptr
Definition: AttributeArray.h:853
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:407
Mat4< double > Mat4d
Definition: Mat4.h:1334
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:448
CalculatePositionBounds(const PositionArrayT &positions, const math::Mat4d &inverse)
Definition: PointConversion.h:570
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:25
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:260
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointConversion.h:259
std::shared_ptr< StringAttributeHandle > Ptr
Definition: AttributeArrayString.h:112
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:360
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition: LeafManager.h:358
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:735
Vec2< T > minComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise minimum of the two vectors.
Definition: Vec2.h:503
static WriteHandle::Ptr writeHandleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:247
Definition: PointConversion.h:568
const AttributeListType & mData
Definition: PointConversion.h:312
const Vec3T & max() const
Return a const reference to the maximum point of this bounding box.
Definition: BBox.h:64
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:560
Space-partitioning acceleration structure for points. Partitions the points into voxels to accelerate...
typename Attribute::Handle HandleT
Definition: PointConversion.h:322
SharedPtr< Grid > Ptr
Definition: Grid.h:574
typename Attribute::Handle HandleT
Definition: PointConversion.h:404
Type Pow3(Type x)
Return x3.
Definition: Math.h:499
typename AttributeListType::value_type ValueType
Definition: PointConversion.h:263
const FilterT & mFilter
Definition: PointConversion.h:482
Definition: PointConversion.h:318
Index filters primarily designed to be used with a FilterIndexIter.
typename PointIndexTreeType::LeafNodeType PointIndexLeafNode
Definition: PointConversion.h:261
Definition: Exceptions.h:59
double Real
Definition: Types.h:37
AttributeSet::Descriptor::GroupIndex GroupIndex
Definition: PointConversion.h:490
bool isGroup(const AttributeArray &array)
Definition: AttributeGroup.h:66
Type Pow(Type x, int n)
Return xn.
Definition: Math.h:508
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:530
PopulateAttributeOp(const PointIndexTreeType &pointIndexTree, const AttributeListType &data, const size_t index, const Index stride=1)
Definition: PointConversion.h:266
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:491
static Handle::Ptr handleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:225
Vec3< double > Vec3d
Definition: Vec3.h:662
typename PointIndexLeafNode::IndexArray IndexArray
Definition: PointConversion.h:262
void convert(IterT &iter, HandleT &targetHandle, SourceHandleT &sourceHandle, Index64 &offset) const
Definition: PointConversion.h:349
const bool mInCoreOnly
Definition: PointConversion.h:483
Vec3< T > sorted() const
Return a vector with the components of this in ascending order.
Definition: Vec3.h:448
Group & mGroup
Definition: PointConversion.h:559
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:1042
std::shared_ptr< StringAttributeWriteHandle > Ptr
Definition: AttributeArrayString.h:144
Point attribute manipulation in a VDB Point Grid.
Definition: PointConversion.h:219
typename RootNodeType::LeafNodeType LeafNodeType
Definition: Tree.h:185
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:39
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
Definition: PointConversion.h:257
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:1082
Definition: AttributeArrayString.h:141
typename ConversionTraits< ValueType >::Handle SourceHandleT
Definition: PointConversion.h:405
Definition: PointConversion.h:400
Write-able version of AttributeHandle.
Definition: AttributeArray.h:920
Vec3d asVec3d() const
Definition: Coord.h:144
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:489
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:409
This class manages a linear array of pointers to a given tree's leaf nodes, as well as optional auxil...
Definition: LeafManager.h:82
const bool mInCoreOnly
Definition: PointConversion.h:395
Typed class for storing attribute data.
Definition: AttributeArray.h:566
const Index mStride
Definition: PointConversion.h:314
Vec3T extents() const
Return the extents of this bounding box, i.e., the length along each axis.
Definition: BBox.h:253
const GroupIndex mIndex
Definition: PointConversion.h:562
typename ConversionTraits< ValueType >::WriteHandle HandleT
Definition: PointConversion.h:264
void operator()(const tbb::blocked_range< size_t > &range)
Definition: PointConversion.h:583
Definition: AttributeArray.h:849
void get(ValueType &value, size_t n) const
Definition: PointConversion.h:203
Attribute & mAttribute
Definition: PointConversion.h:477
const bool mInCoreOnly
Definition: PointConversion.h:564
const Index64 mStartOffset
Definition: PointConversion.h:479
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:494
Attribute array storage for string data using Descriptor Metadata.
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:653
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:320
static Handle::Ptr handleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:241
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:154
Definition: AttributeArray.h:119
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:478
Definition: PointConversion.h:487
bool isApproxZero(const Type &x)
Return true if x is equal to zero to within the default floating-point comparison tolerance.
Definition: Math.h:293
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:324
void get(ValueType &value, size_t n, openvdb::Index m) const
Definition: PointConversion.h:204
void join(const CalculatePositionBounds &other)
Definition: PointConversion.h:593
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:325
math::BBox< Vec3d > BBoxd
Definition: Types.h:61
Vec3< T > reversed() const
Return the vector (z, y, x)
Definition: Vec3.h:458
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...
const PointIndexTreeType & mPointIndexTree
Definition: PointConversion.h:311
Index32 Index
Definition: Types.h:31
void convert(IterT &iter, HandleT &targetHandle, SourceHandleT &sourceHandle, Index64 &offset) const
Definition: PointConversion.h:425
const size_t mIndex
Definition: PointConversion.h:480
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:866
bool isUniform() const override
Return true if this array is stored as a single uniform value.
Definition: AttributeArray.h:718
std::vector< Index > IndexArray
Definition: PointMove.h:161
std::string Name
Definition: Name.h:17
Vec2< T > maxComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise maximum of the two vectors.
Definition: Vec2.h:512
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:492
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:327
const FilterT & mFilter
Definition: PointConversion.h:394
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:406
ValueType value_type
Definition: PointConversion.h:194
#define OPENVDB_LOG_DEBUG(message)
In debug builds only, log a debugging message of the form 'someVar << "text" << .....
Definition: logging.h:263
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:102
const size_t mIndex
Definition: PointConversion.h:313
static WriteHandle::Ptr writeHandleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:230
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:402
Attribute & mAttribute
Definition: PointConversion.h:389
Definition: IndexIterator.h:43
void getPos(size_t n, ValueType &xyz) const
Definition: PointConversion.h:202
void operator()(const typename LeafManagerT::LeafRange &range) const
Definition: PointConversion.h:275
Definition: Exceptions.h:65
Mat4 inverse(T tolerance=0) const
Definition: Mat4.h:504
static T zero()
Definition: PointConversion.h:223
bool wasInterrupted(T *i, int percent=-1)
Definition: NullInterrupter.h:49
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:390
Definition: Exceptions.h:13
const Vec3T & min() const
Return a const reference to the minimum point of this bounding box.
Definition: BBox.h:62
PointAttributeVector(const std::vector< value_type > &data, const Index stride=1)
Definition: PointConversion.h:196
uint64_t Index64
Definition: Types.h:30
const size_t mIndex
Definition: PointConversion.h:393
static openvdb::Name zero()
Definition: PointConversion.h:239
CalculatePositionBounds(const CalculatePositionBounds &other, tbb::split)
Definition: PointConversion.h:577
Definition: IndexFilter.h:135
Type Truncate(Type x, unsigned int digits)
Return x truncated to the given number of decimal digits.
Definition: Math.h:817
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:82
BBoxd getBoundingBox() const
Definition: PointConversion.h:598
ValueType get(Index n, Index m=0) const
Definition: AttributeArray.h:2209
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:122
typename Attribute::ValueType ValueType
Definition: PointConversion.h:403