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,
62 const Metadata* positionDefaultValue =
nullptr);
75 template <
typename CompressionT,
typename Po
intDataGr
idT,
typename ValueT>
76 inline typename PointDataGridT::Ptr
78 const math::Transform& xform,
79 const Metadata* positionDefaultValue =
nullptr);
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
617 const PositionArrayT& positions,
619 const Metadata* positionDefaultValue)
621 using PointDataTreeT =
typename PointDataGridT::TreeType;
623 using PointIndexLeafT =
typename PointIndexGridT::TreeType::LeafNodeType;
624 using PointIndexT =
typename PointIndexLeafT::ValueType;
628 const NamePair positionType = PositionAttributeT::attributeType();
632 const auto& pointIndexTree = pointIndexGrid.tree();
633 typename PointDataTreeT::Ptr treePtr(
new PointDataTreeT(pointIndexTree));
637 auto descriptor = AttributeSet::Descriptor::create(positionType);
641 if (positionDefaultValue) descriptor->setDefaultValue(
"P", *positionDefaultValue);
645 const size_t positionIndex = descriptor->find(
"P");
646 assert(positionIndex != AttributeSet::INVALID_POS);
654 LeafManagerT leafManager(*treePtr);
656 [&](LeafT& leaf,
size_t ) {
660 const auto* pointIndexLeaf = pointIndexTree.probeConstLeaf(leaf.origin());
661 assert(pointIndexLeaf);
666 leaf.initializeAttributes(descriptor,
pointCount, &lock);
671 leaf.attributeArray(positionIndex));
676 *begin =
static_cast<PointIndexT*
>(
nullptr),
677 *end =
static_cast<PointIndexT*
>(
nullptr);
681 for (
auto iter = pointIndexLeaf->cbeginValueOn(); iter; ++iter) {
685 const Coord& ijk = iter.getCoord();
690 pointIndexLeaf->getIndices(ijk, begin, end);
692 while (begin < end) {
694 typename PositionArrayT::value_type positionWorldSpace;
695 positions.getPos(*begin, positionWorldSpace);
700 const Vec3f positionVoxelSpace(positionIndexSpace - positionCellCenter);
702 attributeWriteHandle->set(index++, positionVoxelSpace);
710 auto grid = PointDataGridT::create(treePtr);
711 grid->setTransform(xform.
copy());
719 template <
typename CompressionT,
typename Po
intDataGr
idT,
typename ValueT>
720 inline typename PointDataGridT::Ptr
723 const Metadata* positionDefaultValue)
728 tools::createPointIndexGrid<tools::PointIndexGrid>(pointList, xform);
729 return createPointDataGrid<CompressionT, PointDataGridT>(
730 *pointIndexGrid, pointList, xform, positionDefaultValue);
737 template <
typename Po
intDataTreeT,
typename Po
intIndexTreeT,
typename Po
intArrayT>
741 const bool insertMetadata)
744 using ValueType =
typename PointArrayT::value_type;
746 auto iter = tree.cbeginLeaf();
750 const size_t index = iter->attributeSet().find(attributeName);
752 if (index == AttributeSet::INVALID_POS) {
756 if (insertMetadata) {
764 PopulateAttributeOp<PointDataTreeT,
766 PointArrayT> populate(pointIndexTree, data, index, stride);
767 tbb::parallel_for(leafManager.
leafRange(), populate);
774 template <
typename PositionAttribute,
typename Po
intDataGr
idT,
typename FilterT>
777 const PointDataGridT& grid,
780 const FilterT& filter,
781 const bool inCoreOnly)
783 using TreeType =
typename PointDataGridT::TreeType;
788 const TreeType& tree = grid.tree();
789 auto iter = tree.cbeginLeaf();
793 const size_t positionIndex = iter->attributeSet().find(
"P");
795 positionAttribute.expand();
796 LeafManagerT leafManager(tree);
797 ConvertPointDataGridPositionOp<TreeType, PositionAttribute, FilterT> convert(
798 positionAttribute,
pointOffsets, startOffset, grid.transform(), positionIndex,
800 tbb::parallel_for(leafManager.leafRange(), convert);
801 positionAttribute.compact();
808 template <
typename TypedAttribute,
typename Po
intDataTreeT,
typename FilterT>
811 const PointDataTreeT& tree,
814 const unsigned arrayIndex,
816 const FilterT& filter,
817 const bool inCoreOnly)
823 auto iter = tree.cbeginLeaf();
828 LeafManagerT leafManager(tree);
829 ConvertPointDataGridAttributeOp<PointDataTreeT, TypedAttribute, FilterT> convert(
830 attribute,
pointOffsets, startOffset, arrayIndex, stride,
832 tbb::parallel_for(leafManager.leafRange(), convert);
840 template <
typename Group,
typename Po
intDataTreeT,
typename FilterT>
843 const PointDataTreeT& tree,
846 const AttributeSet::Descriptor::GroupIndex index,
847 const FilterT& filter,
848 const bool inCoreOnly)
854 auto iter = tree.cbeginLeaf();
857 LeafManagerT leafManager(tree);
858 ConvertPointDataGridGroupOp<PointDataTree, Group, FilterT> convert(
861 tbb::parallel_for(leafManager.leafRange(), convert);
868 template<
typename PositionWrapper,
typename InterrupterT>
871 const uint32_t pointsPerVoxel,
873 const Index decimalPlaces,
874 InterrupterT*
const interrupter)
876 using namespace point_conversion_internal;
880 static bool voxelSizeFromVolume(
const double volume,
881 const size_t estimatedVoxelCount,
885 static const double minimumVoxelVolume(3e-15);
888 double voxelVolume = volume /
static_cast<double>(estimatedVoxelCount);
891 if (voxelVolume < minimumVoxelVolume) {
892 voxelVolume = minimumVoxelVolume;
895 else if (voxelVolume > maximumVoxelVolume) {
896 voxelVolume = maximumVoxelVolume;
900 voxelSize =
static_cast<float>(
math::Pow(voxelVolume, 1.0/3.0));
904 static float truncate(
const float voxelSize,
Index decPlaces)
906 float truncatedVoxelSize = voxelSize;
909 for (
int i = decPlaces; i < 11; i++) {
910 truncatedVoxelSize =
static_cast<float>(
math::Truncate(
double(voxelSize), i));
911 if (truncatedVoxelSize != 0.0f)
break;
914 return truncatedVoxelSize;
922 float voxelSize(0.1f);
924 const size_t numPoints = positions.size();
928 if (numPoints <= 1)
return voxelSize;
930 size_t targetVoxelCount(numPoints /
size_t(pointsPerVoxel));
931 if (targetVoxelCount == 0) targetVoxelCount++;
936 inverseTransform =
math::unit(inverseTransform);
938 tbb::blocked_range<size_t> range(0, numPoints);
939 CalculatePositionBounds<PositionWrapper>
calculateBounds(positions, inverseTransform);
946 if (bbox.
min() == bbox.
max())
return voxelSize;
948 double volume = bbox.
volume();
956 volume = extents[0]*extents[0]*extents[0];
960 volume = extents[0]*extents[1]*extents[1];
964 double previousVolume = volume;
966 if (!Local::voxelSizeFromVolume(volume, targetVoxelCount, voxelSize)) {
971 size_t previousVoxelCount(0);
972 size_t voxelCount(1);
974 if (interrupter) interrupter->start(
"Computing voxel size");
976 while (voxelCount > previousVoxelCount)
987 newTransform = math::Transform::createLinearTransform(matrix);
991 newTransform = math::Transform::createLinearTransform(voxelSize);
999 mask->setTransform(newTransform);
1005 previousVoxelCount = voxelCount;
1006 voxelCount = mask->activeVoxelCount();
1007 volume =
math::Pow3(voxelSize) *
static_cast<float>(voxelCount);
1011 if (volume >= previousVolume)
break;
1012 previousVolume = volume;
1014 const float previousVoxelSize = voxelSize;
1018 if (!Local::voxelSizeFromVolume(volume, targetVoxelCount, voxelSize)) {
1019 voxelSize = previousVoxelSize;
1026 if (voxelSize / previousVoxelSize > 0.9f)
break;
1029 if (interrupter) interrupter->end();
1033 return Local::truncate(voxelSize, decimalPlaces);
1043 typename CompressionT,
1044 typename PointDataGridT,
1045 typename PositionArrayT,
1046 typename PointIndexGridT>
1048 inline typename PointDataGridT::Ptr
1050 const PositionArrayT& positions,
1054 return createPointDataGrid<CompressionT, PointDataGridT>(
1055 pointIndexGrid, positions, xform, positionDefaultValue.get());
1059 template <
typename CompressionT,
typename Po
intDataGr
idT,
typename ValueT>
1061 inline typename PointDataGridT::Ptr
1066 return createPointDataGrid<CompressionT, PointDataGridT>(
1067 positions, xform, positionDefaultValue.get());
1078 #endif // OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:530
OPENVDB_DEPRECATED PointDataGridT::Ptr createPointDataGrid(const std::vector< ValueT > &positions, const math::Transform &xform, Metadata::Ptr positionDefaultValue)
Definition: PointConversion.h:1062
void convertPointDataGridAttribute(TypedAttribute &attribute, const PointDataTreeT &tree, const std::vector< Index64 > &pointOffsets, const Index64 startOffset, const unsigned arrayIndex, const Index stride=1, const FilterT &filter=NullFilter(), const bool inCoreOnly=false)
Convert the attribute from a PointDataGrid.
Definition: PointConversion.h:810
std::shared_ptr< Handle > Ptr
Definition: AttributeArray.h:923
ValueType PosType
Definition: PointConversion.h:193
SharedPtr< Grid > Ptr
Definition: Grid.h:574
const FilterT & mFilter
Definition: PointConversion.h:482
Set of Attribute Arrays which tracks metadata about each array.
typename Attribute::ValueType ValueType
Definition: PointConversion.h:403
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
const size_t mIndex
Definition: PointConversion.h:480
ValueType get(Index n, Index m=0) const
Definition: AttributeArray.h:2196
Definition: PointConversion.h:257
void preScale(const Vec3< T0 > &v)
Definition: Mat4.h:755
Type Pow(Type x, int n)
Return xn.
Definition: Math.h:528
Definition: AttributeArray.h:849
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:406
size_t size() const
Definition: PointConversion.h:201
Definition: AttributeArrayString.h:195
void join(const CalculatePositionBounds &other)
Definition: PointConversion.h:593
std::shared_ptr< Handle > Ptr
Definition: AttributeArray.h:852
Type Pow3(Type x)
Return x3.
Definition: Math.h:519
ElementType volume() const
Return the volume enclosed by this bounding box.
Definition: BBox.h:100
static WriteHandle::Ptr writeHandleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:247
Point group manipulation in a VDB Point Grid.
Definition: Exceptions.h:59
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
const Index64 mStartOffset
Definition: PointConversion.h:561
CalculatePositionBounds(const CalculatePositionBounds &other, tbb::split)
Definition: PointConversion.h:577
math::BBox< Vec3d > BBoxd
Definition: Types.h:61
std::shared_ptr< StringAttributeHandle > Ptr
Definition: AttributeArrayString.h:164
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointConversion.h:259
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
Attribute & mAttribute
Definition: PointConversion.h:389
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:402
Index32 Index
Definition: Types.h:31
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:491
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:739
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:260
std::string Name
Definition: Name.h:17
const AttributeListType & mData
Definition: PointConversion.h:312
Definition: PointConversion.h:569
void convertPointDataGridGroup(Group &group, const PointDataTreeT &tree, const std::vector< Index64 > &pointOffsets, const Index64 startOffset, const AttributeSet::Descriptor::GroupIndex index, const FilterT &filter=NullFilter(), const bool inCoreOnly=false)
Convert the group from a PointDataGrid.
Definition: PointConversion.h:842
bool isApproxZero(const Type &x)
Return true if x is equal to zero to within the default floating-point comparison tolerance.
Definition: Math.h:313
const Vec3T & max() const
Return a const reference to the maximum point of this bounding box.
Definition: BBox.h:64
bool wasInterrupted(T *i, int percent=-1)
Definition: NullInterrupter.h:49
CalculatePositionBounds(const PositionArrayT &positions, const math::Mat4d &inverse)
Definition: PointConversion.h:570
bool isUniform() const override
Return true if this array is stored as a single uniform value.
Definition: AttributeArray.h:716
Space-partitioning acceleration structure for points. Partitions the points into voxels to accelerate...
void operator()(const tbb::blocked_range< size_t > &range)
Definition: PointConversion.h:583
const bool mInCoreOnly
Definition: PointConversion.h:564
typename AttributeListType::value_type ValueType
Definition: PointConversion.h:263
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:560
const Index64 mStartOffset
Definition: PointConversion.h:479
Write-able version of AttributeHandle.
Definition: AttributeArray.h:920
const Index mStride
Definition: PointConversion.h:481
This class manages a linear array of pointers to a given tree's leaf nodes, as well as optional auxil...
Definition: LeafManager.h:83
BBoxd getBoundingBox() const
Definition: PointConversion.h:598
uint64_t Index64
Definition: Types.h:30
Index filters primarily designed to be used with a FilterIndexIter.
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
AttributeSet::Descriptor::GroupIndex GroupIndex
Definition: PointConversion.h:490
typename PointIndexTreeType::LeafNodeType PointIndexLeafNode
Definition: PointConversion.h:261
const FilterT & mFilter
Definition: PointConversion.h:563
PopulateAttributeOp(const PointIndexTreeType &pointIndexTree, const AttributeListType &data, const size_t index, const Index stride=1)
Definition: PointConversion.h:266
static WriteHandle::Ptr writeHandleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:230
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:324
void convertPointDataGridPosition(PositionAttribute &positionAttribute, const PointDataGridT &grid, const std::vector< Index64 > &pointOffsets, const Index64 startOffset, const FilterT &filter=NullFilter(), const bool inCoreOnly=false)
Convert the position attribute from a Point Data Grid.
Definition: PointConversion.h:776
const GroupIndex mIndex
Definition: PointConversion.h:562
Definition: PointConversion.h:318
Vec3< T > sorted() const
Return a vector with the components of this in ascending order.
Definition: Vec3.h:448
bool isGroup(const AttributeArray &array)
Definition: AttributeGroup.h:63
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:390
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
Definition: PointConversion.h:400
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:448
typename ConversionTraits< ValueType >::Handle SourceHandleT
Definition: PointConversion.h:405
std::shared_ptr< StringAttributeWriteHandle > Ptr
Definition: AttributeArrayString.h:197
Point attribute manipulation in a VDB Point Grid.
typename PointIndexLeafNode::IndexArray IndexArray
Definition: PointConversion.h:262
typename RootNodeType::LeafNodeType LeafNodeType
Definition: Tree.h:183
static Handle::Ptr handleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:225
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:407
const Index64 mStartOffset
Definition: PointConversion.h:391
Definition: PointConversion.h:220
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:325
void convert(IterT &iter, HandleT &targetHandle, SourceHandleT &sourceHandle, Index64 &offset) const
Definition: PointConversion.h:425
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:320
ValueType get(Index n) const
Return the value at index n.
Definition: AttributeArray.h:1437
Definition: PointConversion.h:487
Typed class for storing attribute data.
Definition: AttributeArray.h:566
Vec3d asVec3d() const
Definition: Coord.h:144
const Index mStride
Definition: PointConversion.h:314
typename Attribute::ValueType ValueType
Definition: PointConversion.h:321
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:478
Vec3T extents() const
Return the extents of this bounding box, i.e., the length along each axis.
Definition: BBox.h:253
void convert(IterT &iter, HandleT &targetHandle, SourceHandleT &sourceHandle, Index64 &offset) const
Definition: PointConversion.h:349
typename ConversionTraits< ValueType >::WriteHandle HandleT
Definition: PointConversion.h:264
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:26
Vec3< double > Vec3d
Definition: Vec3.h:662
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
void get(ValueType &value, size_t n) const
Definition: PointConversion.h:203
const math::Transform & mTransform
Definition: PointConversion.h:392
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
Attribute array storage for string data using Descriptor Metadata.
Definition: AttributeArrayString.h:162
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:146
const size_t mIndex
Definition: PointConversion.h:393
Base class for storing attribute data.
Definition: AttributeArray.h:93
void get(ValueType &value, size_t n, openvdb::Index m) const
Definition: PointConversion.h:204
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:489
static T zero()
Definition: PointConversion.h:223
Vec3< T > reversed() const
Return the vector (z, y, x)
Definition: Vec3.h:458
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:360
static openvdb::Name zero()
Definition: PointConversion.h:239
const PointIndexTreeType & mPointIndexTree
Definition: PointConversion.h:311
const bool mInCoreOnly
Definition: PointConversion.h:483
std::vector< Index > IndexArray
Definition: PointMove.h:161
Type Truncate(Type x, unsigned int digits)
Return x truncated to the given number of decimal digits.
Definition: Math.h:837
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:870
Mat4< double > Mat4d
Definition: Mat4.h:1334
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition: LeafManager.h:358
const size_t mIndex
Definition: PointConversion.h:313
Vec2< T > minComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise minimum of the two vectors.
Definition: Vec2.h:503
#define OPENVDB_LOG_DEBUG(message)
In debug builds only, log a debugging message of the form 'someVar << "text" << .....
Definition: logging.h:263
typename Attribute::Handle HandleT
Definition: PointConversion.h:322
This tool produces a grid where every voxel that contains a point is active. It employes thread-local...
ValueType value_type
Definition: PointConversion.h:194
@ ALL
Definition: IndexIterator.h:43
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:94
Point-partitioner compatible STL vector attribute wrapper for convenience.
Definition: PointConversion.h:191
void getPos(size_t n, ValueType &xyz) const
Definition: PointConversion.h:202
Definition: AttributeArray.h:119
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...
void operator()(const typename LeafManagerT::LeafRange &range) const
Definition: PointConversion.h:275
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:39
Definition: Exceptions.h:65
Mat4 inverse(T tolerance=0) const
Definition: Mat4.h:504
Definition: Exceptions.h:13
const Vec3T & min() const
Return a const reference to the minimum point of this bounding box.
Definition: BBox.h:62
uint8_t GroupType
Definition: AttributeSet.h:31
PointAttributeVector(const std::vector< value_type > &data, const Index stride=1)
Definition: PointConversion.h:196
const bool mInCoreOnly
Definition: PointConversion.h:395
Attribute & mAttribute
Definition: PointConversion.h:477
double Real
Definition: Types.h:37
void convert(IterT &iter, const GroupAttributeArray &groupArray, Index64 &offset) const
Definition: PointConversion.h:508
static Handle::Ptr handleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:241
const FilterT & mFilter
Definition: PointConversion.h:394
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:82
typename Attribute::Handle HandleT
Definition: PointConversion.h:404
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
Group & mGroup
Definition: PointConversion.h:559
bool isIdentity(const MatType &m)
Determine if a matrix is an identity matrix.
Definition: Mat.h:865