37 #ifndef OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED 38 #define OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED 40 #include <openvdb/math/Transform.h> 42 #include <openvdb/tools/PointIndexGrid.h> 43 #include <openvdb/tools/PointsToMask.h> 44 #include <openvdb/util/NullInterrupter.h> 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,
163 const std::vector<Index64>& pointOffsets,
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,
186 const std::vector<Index64>& pointOffsets,
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());
282 template<
typename Po
intDataTreeType,
typename Po
intIndexTreeType>
292 const AttributeSet::Descriptor::Ptr& attributeDescriptor)
293 : mPointIndexTree(pointIndexTree)
294 , mAttributeDescriptor(attributeDescriptor) { }
296 void operator()(
const typename LeafManagerT::LeafRange& range)
const {
297 for (
auto leaf = range.begin(); leaf; ++leaf) {
301 const PointIndexLeafNode* pointIndexLeaf = mPointIndexTree.probeConstLeaf(leaf->origin());
303 if (!pointIndexLeaf)
continue;
307 const IndexArray& indices = pointIndexLeaf->indices();
311 leaf->initializeAttributes(mAttributeDescriptor,
pointCount);
321 template<
typename PointDataTreeType,
322 typename PointIndexTreeType,
323 typename PositionListType>
332 using ValueType =
typename PositionListType::value_type;
336 const PositionListType& positions)
337 : mPointIndexTree(pointIndexTree)
338 , mTransform(transform)
339 , mPositions(positions) { }
341 void operator()(
const typename LeafManagerT::LeafRange& range)
const {
343 for (
auto leaf = range.begin(); leaf; ++leaf) {
347 const PointIndexLeafNode* pointIndexLeaf = mPointIndexTree.probeConstLeaf(leaf->origin());
349 if (!pointIndexLeaf)
continue;
355 const IndexArray& indices = pointIndexLeaf->indices();
357 for (
const Index64 i: indices) {
359 mPositions.getPos(i, positionWorldSpace);
361 const ValueType positionIndexSpace = mTransform.worldToIndex(positionWorldSpace);
364 positionIndexSpace.x() -
math::Round(positionIndexSpace.x()),
365 positionIndexSpace.y() -
math::Round(positionIndexSpace.y()),
366 positionIndexSpace.z() -
math::Round(positionIndexSpace.z()));
368 attributeWriteHandle->set(static_cast<Index>(index),
Vec3f(positionVoxelSpace));
382 template<
typename PointDataTreeType,
383 typename PointIndexTreeType,
384 typename AttributeListType>
391 using ValueType =
typename AttributeListType::value_type;
395 const AttributeListType& data,
397 const Index stride = 1)
398 : mPointIndexTree(pointIndexTree)
401 , mStride(stride) { }
403 void operator()(
const typename LeafManagerT::LeafRange& range)
const {
405 for (
auto leaf = range.begin(); leaf; ++leaf) {
410 mPointIndexTree.probeConstLeaf(leaf->origin());
412 if (!pointIndexLeaf)
continue;
414 typename HandleT::Ptr attributeWriteHandle =
419 const IndexArray& indices = pointIndexLeaf->indices();
421 for (
const Index64 leafIndex: indices)
424 for (
Index i = 0; i < mStride; i++) {
425 mData.get(value, leafIndex, i);
426 attributeWriteHandle->set(static_cast<Index>(index), i, value);
433 attributeWriteHandle->compact();
445 template<
typename Po
intDataTreeType,
typename Attribute,
typename FilterT>
448 using LeafNode =
typename PointDataTreeType::LeafNodeType;
456 const std::vector<Index64>& pointOffsets,
460 const FilterT& filter,
461 const bool inCoreOnly)
462 : mAttribute(attribute)
463 , mPointOffsets(pointOffsets)
464 , mStartOffset(startOffset)
465 , mTransform(transform)
468 , mInCoreOnly(inCoreOnly)
472 std::is_floating_point<typename ValueType::ValueType>::value,
473 "ValueType is not Vec3f");
476 template <
typename IterT>
480 for (; iter; ++iter) {
481 const Vec3d xyz = iter.getCoord().asVec3d();
482 const Vec3d pos = sourceHandle.
get(*iter);
483 targetHandle.set(static_cast<Index>(offset++), 0,
484 mTransform.indexToWorld(pos + xyz));
492 for (
auto leaf = range.begin(); leaf; ++leaf) {
494 assert(leaf.pos() < mPointOffsets.size());
496 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
500 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
502 auto handle = SourceHandleT::create(leaf->constAttributeArray(mIndex));
505 auto iter = leaf->beginIndexOn();
506 convert(iter, pHandle, *handle, offset);
509 auto iter = leaf->beginIndexOn(mFilter);
510 convert(iter, pHandle, *handle, offset);
527 template<
typename Po
intDataTreeType,
typename Attribute,
typename FilterT>
530 using LeafNode =
typename PointDataTreeType::LeafNodeType;
538 const std::vector<Index64>& pointOffsets,
542 const FilterT& filter,
543 const bool inCoreOnly)
544 : mAttribute(attribute)
545 , mPointOffsets(pointOffsets)
546 , mStartOffset(startOffset)
550 , mInCoreOnly(inCoreOnly) { }
552 template <
typename IterT>
556 if (sourceHandle.isUniform()) {
557 const ValueType uniformValue(sourceHandle.get(0));
558 for (; iter; ++iter) {
559 for (
Index i = 0; i < mStride; i++) {
560 targetHandle.set(static_cast<Index>(offset), i, uniformValue);
566 for (; iter; ++iter) {
567 for (
Index i = 0; i < mStride; i++) {
568 targetHandle.set(static_cast<Index>(offset), i,
569 sourceHandle.get(*iter, i));
580 for (
auto leaf = range.begin(); leaf; ++leaf) {
582 assert(leaf.pos() < mPointOffsets.size());
584 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
588 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
591 *leaf, static_cast<Index>(mIndex));
594 auto iter = leaf->beginIndexOn();
595 convert(iter, pHandle, *handle, offset);
597 auto iter = leaf->beginIndexOn(mFilter);
598 convert(iter, pHandle, *handle, offset);
614 template<
typename Po
intDataTreeType,
typename Group,
typename FilterT>
617 using LeafNode =
typename PointDataTreeType::LeafNodeType;
623 const std::vector<Index64>& pointOffsets,
625 const AttributeSet::Descriptor::GroupIndex index,
626 const FilterT& filter,
627 const bool inCoreOnly)
629 , mPointOffsets(pointOffsets)
630 , mStartOffset(startOffset)
633 , mInCoreOnly(inCoreOnly) { }
635 template <
typename IterT>
638 const auto bitmask =
static_cast<GroupType>(1 << mIndex.second);
641 if (groupArray.
get(0) & bitmask) {
642 for (; iter; ++iter) {
643 mGroup.setOffsetOn(static_cast<Index>(offset));
649 for (; iter; ++iter) {
650 if (groupArray.
get(*iter) & bitmask) {
651 mGroup.setOffsetOn(static_cast<Index>(offset));
660 for (
auto leaf = range.begin(); leaf; ++leaf) {
662 assert(leaf.pos() < mPointOffsets.size());
664 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
668 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
670 const AttributeArray& array = leaf->constAttributeArray(mIndex.first);
675 auto iter = leaf->beginIndexOn();
676 convert(iter, groupArray, offset);
679 auto iter = leaf->beginIndexOn(mFilter);
680 convert(iter, groupArray, offset);
695 template<
typename PositionArrayT>
700 : mPositions(positions)
701 , mInverseMat(inverse)
702 , mMin(std::numeric_limits<
Real>::
max())
703 , mMax(-std::numeric_limits<
Real>::
max()) {}
706 : mPositions(other.mPositions)
707 , mInverseMat(other.mInverseMat)
708 , mMin(std::numeric_limits<
Real>::
max())
709 , mMax(-std::numeric_limits<
Real>::
max()) {}
713 for (
size_t n = range.begin(), N = range.end(); n != N; ++n) {
714 mPositions.getPos(n, pos);
715 pos = mInverseMat.transform(pos);
727 return BBoxd(mMin, mMax);
731 const PositionArrayT& mPositions;
742 template<
typename CompressionT,
typename Po
intDataGr
idT,
typename PositionArrayT,
typename Po
intIndexGr
idT>
743 inline typename PointDataGridT::Ptr
747 using PointDataTreeT =
typename PointDataGridT::TreeType;
748 using PointIndexTreeT =
typename PointIndexGridT::TreeType;
750 using LeafRangeT =
typename LeafManagerT::LeafRange;
756 const NamePair positionType = PositionAttributeT::attributeType();
760 const PointIndexTreeT& pointIndexTree(pointIndexGrid.tree());
761 typename PointDataTreeT::Ptr treePtr(
new PointDataTreeT(pointIndexTree));
763 LeafManagerT leafManager = LeafManagerT(*treePtr);
764 LeafRangeT leafRange = leafManager.leafRange();
768 auto descriptor = AttributeSet::Descriptor::create(positionType);
772 if (positionDefaultValue) descriptor->setDefaultValue(
"P", *positionDefaultValue);
776 InitialiseAttributesOp<PointDataTreeT, PointIndexTreeT> initialise(
777 pointIndexGrid.tree(), descriptor);
778 tbb::parallel_for(leafRange, initialise);
782 PopulatePositionAttributeOp<PointDataTreeT,
784 PositionArrayT> populate(pointIndexTree,
788 tbb::parallel_for(leafRange, populate);
790 auto grid = PointDataGridT::create(treePtr);
791 grid->setTransform(xform.
copy());
799 template <
typename CompressionT,
typename Po
intDataGr
idT,
typename ValueT>
800 inline typename PointDataGridT::Ptr
808 return createPointDataGrid<CompressionT, PointDataGridT>(*pointIndexGrid, pointList, xform, positionDefaultValue);
815 template <
typename Po
intDataTreeT,
typename Po
intIndexTreeT,
typename Po
intArrayT>
819 const bool insertMetadata)
822 using ValueType =
typename PointArrayT::value_type;
824 auto iter = tree.cbeginLeaf();
828 const size_t index = iter->attributeSet().find(attributeName);
830 if (index == AttributeSet::INVALID_POS) {
834 if (insertMetadata) {
842 PopulateAttributeOp<PointDataTreeT,
844 PointArrayT> populate(pointIndexTree, data, index, stride);
845 tbb::parallel_for(leafManager.
leafRange(), populate);
852 template <
typename PositionAttribute,
typename Po
intDataGr
idT,
typename FilterT>
855 const PointDataGridT& grid,
856 const std::vector<Index64>& pointOffsets,
858 const FilterT& filter,
859 const bool inCoreOnly)
861 using TreeType =
typename PointDataGridT::TreeType;
866 const TreeType& tree = grid.tree();
867 auto iter = tree.cbeginLeaf();
871 const size_t positionIndex = iter->attributeSet().find(
"P");
873 positionAttribute.expand();
874 LeafManagerT leafManager(tree);
875 ConvertPointDataGridPositionOp<TreeType, PositionAttribute, FilterT> convert(
876 positionAttribute, pointOffsets, startOffset, grid.transform(), positionIndex,
878 tbb::parallel_for(leafManager.leafRange(), convert);
879 positionAttribute.compact();
886 template <
typename TypedAttribute,
typename Po
intDataTreeT,
typename FilterT>
889 const PointDataTreeT& tree,
890 const std::vector<Index64>& pointOffsets,
892 const unsigned arrayIndex,
894 const FilterT& filter,
895 const bool inCoreOnly)
901 auto iter = tree.cbeginLeaf();
906 LeafManagerT leafManager(tree);
907 ConvertPointDataGridAttributeOp<PointDataTreeT, TypedAttribute, FilterT> convert(
908 attribute, pointOffsets, startOffset, arrayIndex, stride,
910 tbb::parallel_for(leafManager.leafRange(), convert);
918 template <
typename Group,
typename Po
intDataTreeT,
typename FilterT>
921 const PointDataTreeT& tree,
922 const std::vector<Index64>& pointOffsets,
924 const AttributeSet::Descriptor::GroupIndex index,
925 const FilterT& filter,
926 const bool inCoreOnly)
932 auto iter = tree.cbeginLeaf();
935 LeafManagerT leafManager(tree);
936 ConvertPointDataGridGroupOp<PointDataTree, Group, FilterT> convert(
937 group, pointOffsets, startOffset, index,
939 tbb::parallel_for(leafManager.leafRange(), convert);
946 template<
typename PositionWrapper,
typename InterrupterT>
949 const uint32_t pointsPerVoxel,
951 const Index decimalPlaces,
952 InterrupterT*
const interrupter)
954 using namespace point_conversion_internal;
958 static bool voxelSizeFromVolume(
const double volume,
959 const size_t estimatedVoxelCount,
963 static const double minimumVoxelVolume(3e-15);
966 double voxelVolume = volume /
static_cast<double>(estimatedVoxelCount);
969 if (voxelVolume < minimumVoxelVolume) {
970 voxelVolume = minimumVoxelVolume;
973 else if (voxelVolume > maximumVoxelVolume) {
974 voxelVolume = maximumVoxelVolume;
978 voxelSize =
static_cast<float>(
math::Pow(voxelVolume, 1.0/3.0));
982 static float truncate(
const float voxelSize,
Index decPlaces)
984 float truncatedVoxelSize = voxelSize;
987 for (
int i = decPlaces; i < 11; i++) {
988 truncatedVoxelSize =
static_cast<float>(
math::Truncate(
double(voxelSize), i));
989 if (truncatedVoxelSize != 0.0f)
break;
992 return truncatedVoxelSize;
1000 float voxelSize(0.1f);
1002 const size_t numPoints = positions.size();
1006 if (numPoints <= 1)
return voxelSize;
1008 size_t targetVoxelCount(numPoints /
size_t(pointsPerVoxel));
1009 if (targetVoxelCount == 0) targetVoxelCount++;
1014 inverseTransform =
math::unit(inverseTransform);
1016 tbb::blocked_range<size_t> range(0, numPoints);
1017 CalculatePositionBounds<PositionWrapper>
calculateBounds(positions, inverseTransform);
1018 tbb::parallel_reduce(range, calculateBounds);
1020 BBoxd bbox = calculateBounds.getBoundingBox();
1024 if (bbox.
min() == bbox.
max())
return voxelSize;
1026 double volume = bbox.
volume();
1034 volume = extents[0]*extents[0]*extents[0];
1038 volume = extents[0]*extents[1]*extents[1];
1042 double previousVolume = volume;
1044 if (!Local::voxelSizeFromVolume(volume, targetVoxelCount, voxelSize)) {
1049 size_t previousVoxelCount(0);
1050 size_t voxelCount(1);
1052 if (interrupter) interrupter->start(
"Computing voxel size");
1054 while (voxelCount > previousVoxelCount)
1065 newTransform = math::Transform::createLinearTransform(matrix);
1069 newTransform = math::Transform::createLinearTransform(voxelSize);
1077 mask->setTransform(newTransform);
1083 previousVoxelCount = voxelCount;
1084 voxelCount = mask->activeVoxelCount();
1089 if (volume >= previousVolume)
break;
1090 previousVolume = volume;
1092 const float previousVoxelSize = voxelSize;
1096 if (!Local::voxelSizeFromVolume(volume, targetVoxelCount, voxelSize)) {
1097 voxelSize = previousVoxelSize;
1104 if (voxelSize / previousVoxelSize > 0.9f)
break;
1107 if (interrupter) interrupter->end();
1111 return Local::truncate(voxelSize, decimalPlaces);
1121 template <
typename PositionAttribute,
typename Po
intDataGr
idT>
1125 const PointDataGridT& grid,
1126 const std::vector<Index64>& pointOffsets,
1128 const std::vector<Name>& includeGroups,
1129 const std::vector<Name>& excludeGroups,
1130 const bool inCoreOnly =
false)
1132 auto leaf = grid.tree().cbeginLeaf();
1134 MultiGroupFilter filter(includeGroups, excludeGroups, leaf->attributeSet());
1136 filter, inCoreOnly);
1140 template <
typename TypedAttribute,
typename Po
intDataTreeT>
1144 const PointDataTreeT& tree,
1145 const std::vector<Index64>& pointOffsets,
1147 const unsigned arrayIndex,
1149 const std::vector<Name>& includeGroups,
1150 const std::vector<Name>& excludeGroups,
1151 const bool inCoreOnly =
false)
1153 auto leaf = tree.cbeginLeaf();
1155 MultiGroupFilter filter(includeGroups, excludeGroups, leaf->attributeSet());
1157 arrayIndex, stride, filter, inCoreOnly);
1161 template <
typename Group,
typename Po
intDataTreeT>
1165 const PointDataTreeT& tree,
1166 const std::vector<Index64>& pointOffsets,
1168 const AttributeSet::Descriptor::GroupIndex index,
1169 const std::vector<Name>& includeGroups,
1170 const std::vector<Name>& excludeGroups,
1171 const bool inCoreOnly =
false)
1173 auto leaf = tree.cbeginLeaf();
1175 MultiGroupFilter filter(includeGroups, excludeGroups, leaf->attributeSet());
1177 index, filter, inCoreOnly);
1185 #endif // OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED 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:1124
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
Vec2< T > maxComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise maximum of the two vectors.
Definition: Vec2.h:539
typename AttributeListType::value_type ValueType
Definition: PointConversion.h:391
typename Attribute::Handle HandleT
Definition: PointConversion.h:532
double Real
Definition: Types.h:67
std::shared_ptr< StringAttributeHandle > Ptr
Definition: AttributeArrayString.h:137
Write-able version of AttributeHandle.
Definition: AttributeArray.h:715
void join(const CalculatePositionBounds &other)
Definition: PointConversion.h:721
Point-partitioner compatible STL vector attribute wrapper for convenience.
Definition: PointConversion.h:218
Vec3T extents() const
Return the extents of this bounding box, i.e., the length along each axis.
Definition: BBox.h:280
const bool mInCoreOnly
Definition: PointConversion.h:523
Group & mGroup
Definition: PointConversion.h:687
Mat4 inverse(T tolerance=0) const
Definition: Mat4.h:531
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
PopulatePositionAttributeOp(const PointIndexTreeType &pointIndexTree, const math::Transform &transform, const PositionListType &positions)
Definition: PointConversion.h:334
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:455
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:620
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:576
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition: LeafManager.h:386
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
#define OPENVDB_LOG_DEBUG(message)
In debug builds only, log a debugging message of the form 'someVar << "text" << ...'.
Definition: logging.h:290
const AttributeSet::Descriptor::Ptr & mAttributeDescriptor
Definition: PointConversion.h:318
std::shared_ptr< Handle > Ptr
Definition: AttributeArray.h:719
void preScale(const Vec3< T0 > &v)
Definition: Mat4.h:782
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointConversion.h:387
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:65
typename PointIndexLeafNode::IndexArray IndexArray
Definition: PointConversion.h:390
Definition: PointConversion.h:324
void convert(IterT &iter, const GroupAttributeArray &groupArray, Index64 &offset) const
Definition: PointConversion.h:636
AttributeSet::Descriptor::GroupIndex GroupIndex
Definition: PointConversion.h:618
const Vec3T & min() const
Return a const reference to the minimum point of this bounding box.
Definition: BBox.h:89
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
const size_t mIndex
Definition: PointConversion.h:441
bool wasInterrupted(T *i, int percent=-1)
Definition: NullInterrupter.h:76
Definition: PointConversion.h:528
std::string Name
Definition: Name.h:44
typename PointIndexLeafNode::IndexArray IndexArray
Definition: PointConversion.h:289
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:537
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:1143
ValueType PosType
Definition: PointConversion.h:220
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:1164
typename PointIndexTreeType::LeafNodeType PointIndexLeafNode
Definition: PointConversion.h:288
const Index64 mStartOffset
Definition: PointConversion.h:607
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:606
ValueType value_type
Definition: PointConversion.h:221
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
Vec2< T > minComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise minimum of the two vectors.
Definition: Vec2.h:530
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...
Vec3< T > reversed() const
Return the vector (z, y, x)
Definition: Vec3.h:475
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
Definition: AttributeArrayString.h:160
typename ConversionTraits< ValueType >::WriteHandle HandleT
Definition: PointConversion.h:392
Definition: IndexFilter.h:163
CalculatePositionBounds(const CalculatePositionBounds &other, tbb::split)
Definition: PointConversion.h:705
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointConversion.h:285
math::Vec3< float > Vec3f
Definition: Types.h:81
const math::Transform & mTransform
Definition: PointConversion.h:520
Mat4< double > Mat4d
Definition: Mat4.h:1361
void getPos(size_t n, ValueType &xyz) const
Definition: PointConversion.h:229
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:617
void convert(IterT &iter, HandleT &targetHandle, SourceHandleT &sourceHandle, Index64 &offset) const
Definition: PointConversion.h:553
uint8_t GroupType
Definition: AttributeGroup.h:50
void convert(IterT &iter, HandleT &targetHandle, SourceHandleT &sourceHandle, Index64 &offset) const
Definition: PointConversion.h:477
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:453
const size_t mIndex
Definition: PointConversion.h:608
typename PointIndexTreeType::LeafNodeType PointIndexLeafNode
Definition: PointConversion.h:329
Point attribute manipulation in a VDB Point Grid.
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:530
ValueType get(Index n) const
Return the value at index n.
Definition: AttributeArray.h:1090
Point group manipulation in a VDB Point Grid.
Index filters primarily designed to be used with a FilterIndexIter.
Definition: AttributeArrayString.h:134
Definition: IndexIterator.h:70
PointAttributeVector(const std::vector< value_type > &data, const Index stride=1)
Definition: PointConversion.h:223
const PointIndexTreeType & mPointIndexTree
Definition: PointConversion.h:317
static Handle::Ptr handleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:252
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:452
const FilterT & mFilter
Definition: PointConversion.h:610
typename Attribute::Handle HandleT
Definition: PointConversion.h:450
const Index mStride
Definition: PointConversion.h:442
Vec3< double > Vec3d
Definition: Vec3.h:679
void operator()(const tbb::blocked_range< size_t > &range)
Definition: PointConversion.h:711
const Index mStride
Definition: PointConversion.h:609
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
const GroupIndex mIndex
Definition: PointConversion.h:690
const PointIndexTreeType & mPointIndexTree
Definition: PointConversion.h:439
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:658
ElementType volume() const
Return the volume enclosed by this bounding box.
Definition: BBox.h:127
static WriteHandle::Ptr writeHandleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:274
Definition: Exceptions.h:92
size_t size() const
Definition: PointConversion.h:228
std::shared_ptr< Handle > Ptr
Definition: AttributeArray.h:648
bool isGroup(const AttributeArray &array)
Definition: AttributeGroup.h:93
const bool mInCoreOnly
Definition: PointConversion.h:611
const FilterT & mFilter
Definition: PointConversion.h:691
SharedPtr< Grid > Ptr
Definition: Grid.h:502
const Index64 mStartOffset
Definition: PointConversion.h:689
Definition: PointConversion.h:246
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:535
Attribute & mAttribute
Definition: PointConversion.h:605
Definition: Exceptions.h:40
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:534
Type Pow(Type x, int n)
Return xn.
Definition: Math.h:515
typename PositionListType::value_type ValueType
Definition: PointConversion.h:332
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:518
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:448
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:622
const PointIndexTreeType & mPointIndexTree
Definition: PointConversion.h:377
Index32 Index
Definition: Types.h:61
static Handle::Ptr handleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:268
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:619
Definition: AttributeArray.h:644
Base class for storing attribute data.
Definition: AttributeArray.h:118
uint64_t Index64
Definition: Types.h:60
typename PointIndexTreeType::LeafNodeType PointIndexLeafNode
Definition: PointConversion.h:389
Vec3< T > sorted() const
Return a vector with the components of this in ascending order.
Definition: Vec3.h:465
Definition: PointConversion.h:615
const bool mInCoreOnly
Definition: PointConversion.h:692
This class manages a linear array of pointers to a given tree's leaf nodes, as well as optional auxil...
Definition: LeafManager.h:110
void operator()(const typename LeafManagerT::LeafRange &range) const
Definition: PointConversion.h:296
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:688
const Vec3T & max() const
Return a const reference to the maximum point of this bounding box.
Definition: BBox.h:91
const math::Transform & mTransform
Definition: PointConversion.h:378
const PositionListType & mPositions
Definition: PointConversion.h:379
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointConversion.h:326
static openvdb::Name zero()
Definition: PointConversion.h:266
typename PointIndexLeafNode::IndexArray IndexArray
Definition: PointConversion.h:330
Type Pow3(Type x)
Return x3.
Definition: Math.h:506
Definition: PointConversion.h:446
ValueType get(Index n, Index m=0) const
Definition: AttributeArray.h:1956
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
Definition: PointConversion.h:696
std::shared_ptr< StringAttributeWriteHandle > Ptr
Definition: AttributeArrayString.h:163
Type Truncate(Type x, unsigned int digits)
Return x truncated to the given number of decimal digits.
Definition: Math.h:824
typename Attribute::ValueType ValueType
Definition: PointConversion.h:449
bool isIdentity(const MatType &m)
Determine if a matrix is an identity matrix.
Definition: Mat.h:892
Definition: Exceptions.h:86
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:817
Attribute array storage for string data using Descriptor Metadata.
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:801
void operator()(const typename LeafManagerT::LeafRange &range) const
Definition: PointConversion.h:403
bool isUniform() const override
Return true if this array is stored as a single uniform value.
Definition: AttributeArray.h:539
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
typename Attribute::ValueType ValueType
Definition: PointConversion.h:531
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:488
math::BBox< Vec3d > BBoxd
Definition: Types.h:91
const FilterT & mFilter
Definition: PointConversion.h:522
std::vector< Index > IndexArray
Definition: PointMove.h:193
Attribute & mAttribute
Definition: PointConversion.h:517
float Round(float x)
Return x rounded to the nearest integer.
Definition: Math.h:773
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:388
PopulateAttributeOp(const PointIndexTreeType &pointIndexTree, const AttributeListType &data, const size_t index, const Index stride=1)
Definition: PointConversion.h:394
static T zero()
Definition: PointConversion.h:250
CalculatePositionBounds(const PositionArrayT &positions, const math::Mat4d &inverse)
Definition: PointConversion.h:698
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:327
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:948
typename ConversionTraits< ValueType >::Handle SourceHandleT
Definition: PointConversion.h:533
Set of Attribute Arrays which tracks metadata about each array.
const Index64 mStartOffset
Definition: PointConversion.h:519
BBoxd getBoundingBox() const
Definition: PointConversion.h:726
const size_t mIndex
Definition: PointConversion.h:521
Definition: PointConversion.h:283
static WriteHandle::Ptr writeHandleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:257
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:286
const AttributeListType & mData
Definition: PointConversion.h:440
Definition: PointConversion.h:385
void operator()(const typename LeafManagerT::LeafRange &range) const
Definition: PointConversion.h:341
InitialiseAttributesOp(const PointIndexTreeType &pointIndexTree, const AttributeSet::Descriptor::Ptr &attributeDescriptor)
Definition: PointConversion.h:291
Typed class for storing attribute data.
Definition: AttributeArray.h:441