37 #ifndef OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED 38 #define OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED 53 #include <tbb/parallel_reduce.h> 55 #include <type_traits> 81 typename CompressionT,
82 typename PointDataGridT,
83 typename PositionArrayT,
84 typename PointIndexGridT>
85 inline typename PointDataGridT::Ptr
87 const PointIndexGridT& pointIndexGrid,
const PositionArrayT& positions,
101 template <
typename CompressionT,
typename Po
intDataGr
idT,
typename ValueT>
102 inline typename PointDataGridT::Ptr
118 template <
typename Po
intDataTreeT,
typename Po
intIndexTreeT,
typename Po
intArrayT>
122 const Index stride = 1,
const bool insertMetadata =
true);
135 template <
typename PositionAttribute,
typename Po
intDataGr
idT>
138 const PointDataGridT& grid,
139 const std::vector<Index64>& pointOffsets,
141 const std::vector<Name>& includeGroups = std::vector<Name>(),
142 const std::vector<Name>& excludeGroups = std::vector<Name>(),
143 const bool inCoreOnly =
false);
157 template <
typename TypedAttribute,
typename Po
intDataTreeT>
160 const PointDataTreeT& tree,
161 const std::vector<Index64>& pointOffsets,
163 const unsigned arrayIndex,
164 const Index stride = 1,
165 const std::vector<Name>& includeGroups = std::vector<Name>(),
166 const std::vector<Name>& excludeGroups = std::vector<Name>(),
167 const bool inCoreOnly =
false);
182 template <
typename Group,
typename Po
intDataTreeT>
185 const PointDataTreeT& tree,
186 const std::vector<Index64>& pointOffsets,
188 const AttributeSet::Descriptor::GroupIndex index,
189 const std::vector<Name>& includeGroups = std::vector<Name>(),
190 const std::vector<Name>& excludeGroups = std::vector<Name>(),
191 const bool inCoreOnly =
false);
205 template<
typename PositionWrapper,
typename InterrupterT = openvdb::util::NullInterrupter>
208 const uint32_t pointsPerVoxel,
209 const math::Mat4d transform = math::Mat4d::identity(),
210 const Index decimalPlaces = 5,
211 InterrupterT*
const interrupter =
nullptr);
218 template<
typename ValueType>
225 const Index stride = 1)
227 , mStride(stride) { }
229 size_t size()
const {
return mData.size(); }
230 void getPos(
size_t n, ValueType& xyz)
const { xyz = mData[n]; }
231 void get(ValueType& value,
size_t n)
const { value = mData[n]; }
232 void get(ValueType& value,
size_t n,
openvdb::Index m)
const { value = mData[n * mStride + m]; }
235 const std::vector<value_type>& mData;
243 namespace point_conversion_internal {
251 static T
zero() {
return zeroVal<T>(); }
252 template <
typename LeafT>
255 return Handle::create(array);
257 template <
typename LeafT>
260 return WriteHandle::create(array);
268 template <
typename LeafT>
271 const AttributeSet::Descriptor& descriptor = leaf.attributeSet().descriptor();
272 return Handle::create(array, descriptor.getMetadata());
274 template <
typename LeafT>
277 const AttributeSet::Descriptor& descriptor = leaf.attributeSet().descriptor();
278 return WriteHandle::create(array, descriptor.getMetadata());
283 template<
typename Po
intDataTreeType,
typename Po
intIndexTreeType>
293 const AttributeSet::Descriptor::Ptr& attributeDescriptor)
294 : mPointIndexTree(pointIndexTree)
295 , mAttributeDescriptor(attributeDescriptor) { }
297 void operator()(
const typename LeafManagerT::LeafRange& range)
const {
298 for (
auto leaf = range.begin(); leaf; ++leaf) {
302 const PointIndexLeafNode* pointIndexLeaf = mPointIndexTree.probeConstLeaf(leaf->origin());
304 if (!pointIndexLeaf)
continue;
308 const IndexArray& indices = pointIndexLeaf->indices();
312 leaf->initializeAttributes(mAttributeDescriptor,
pointCount);
322 template<
typename PointDataTreeType,
323 typename PointIndexTreeType,
324 typename PositionListType>
333 using ValueType =
typename PositionListType::value_type;
337 const PositionListType& positions)
338 : mPointIndexTree(pointIndexTree)
339 , mTransform(transform)
340 , mPositions(positions) { }
342 void operator()(
const typename LeafManagerT::LeafRange& range)
const {
344 for (
auto leaf = range.begin(); leaf; ++leaf) {
348 const PointIndexLeafNode* pointIndexLeaf = mPointIndexTree.probeConstLeaf(leaf->origin());
350 if (!pointIndexLeaf)
continue;
356 const IndexArray& indices = pointIndexLeaf->indices();
360 mPositions.getPos(
i, positionWorldSpace);
362 const ValueType positionIndexSpace = mTransform.worldToIndex(positionWorldSpace);
365 positionIndexSpace.x() -
math::Round(positionIndexSpace.x()),
366 positionIndexSpace.y() -
math::Round(positionIndexSpace.y()),
367 positionIndexSpace.z() -
math::Round(positionIndexSpace.z()));
369 attributeWriteHandle->set(static_cast<Index>(index),
Vec3f(positionVoxelSpace));
383 template<
typename PointDataTreeType,
384 typename PointIndexTreeType,
385 typename AttributeListType>
392 using ValueType =
typename AttributeListType::value_type;
396 const AttributeListType&
data,
398 const Index stride = 1)
399 : mPointIndexTree(pointIndexTree)
402 , mStride(stride) { }
404 void operator()(
const typename LeafManagerT::LeafRange& range)
const {
406 for (
auto leaf = range.begin(); leaf; ++leaf) {
411 mPointIndexTree.probeConstLeaf(leaf->origin());
413 if (!pointIndexLeaf)
continue;
415 typename HandleT::Ptr attributeWriteHandle =
420 const IndexArray& indices = pointIndexLeaf->indices();
422 for (
const Index64 leafIndex: indices)
425 for (
Index i = 0;
i < mStride;
i++) {
426 mData.get(value, leafIndex,
i);
427 attributeWriteHandle->set(static_cast<Index>(index),
i, value);
434 attributeWriteHandle->compact();
446 template<
typename Po
intDataTreeType,
typename Attribute>
449 using LeafNode =
typename PointDataTreeType::LeafNodeType;
455 const std::vector<Index64>& pointOffsets,
459 const std::vector<Name>& includeGroups = std::vector<Name>(),
460 const std::vector<Name>& excludeGroups = std::vector<Name>(),
461 const bool inCoreOnly =
false)
462 : mAttribute(attribute)
463 , mPointOffsets(pointOffsets)
464 , mStartOffset(startOffset)
465 , mTransform(transform)
467 , mIncludeGroups(includeGroups)
468 , mExcludeGroups(excludeGroups)
469 , mInCoreOnly(inCoreOnly)
473 std::is_floating_point<typename ValueType::ValueType>::value,
474 "ValueType is not Vec3f");
479 const bool useGroups = !mIncludeGroups.empty() || !mExcludeGroups.empty();
481 typename Attribute::Handle pHandle(mAttribute);
483 for (
auto leaf = range.begin(); leaf; ++leaf) {
485 assert(leaf.pos() < mPointOffsets.size());
487 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
491 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
496 auto iter = leaf->beginIndexOn(
MultiGroupFilter(mIncludeGroups, mExcludeGroups));
498 for (; iter; ++iter) {
499 const Vec3d xyz = iter.getCoord().asVec3d();
500 const Vec3d pos = handle->get(*iter);
501 pHandle.set(static_cast<Index>(offset++), 0,
502 mTransform.indexToWorld(pos + xyz));
506 auto iter = leaf->beginIndexOn();
508 for (; iter; ++iter) {
509 const Vec3d xyz = iter.getCoord().asVec3d();
510 const Vec3d pos = handle->get(*iter);
511 pHandle.set(static_cast<Index>(offset++), 0,
512 mTransform.indexToWorld(pos + xyz));
531 template<
typename Po
intDataTreeType,
typename Attribute>
534 using LeafNode =
typename PointDataTreeType::LeafNodeType;
541 const std::vector<Index64>& pointOffsets,
544 const Index stride = 1,
545 const std::vector<Name>& includeGroups = std::vector<Name>(),
546 const std::vector<Name>& excludeGroups = std::vector<Name>(),
547 const bool inCoreOnly =
false)
548 : mAttribute(attribute)
549 , mPointOffsets(pointOffsets)
550 , mStartOffset(startOffset)
553 , mIncludeGroups(includeGroups)
554 , mExcludeGroups(excludeGroups)
555 , mInCoreOnly(inCoreOnly) { }
559 const bool useGroups = !mIncludeGroups.empty() || !mExcludeGroups.empty();
561 typename Attribute::Handle pHandle(mAttribute);
563 for (
auto leaf = range.begin(); leaf; ++leaf) {
565 assert(leaf.pos() < mPointOffsets.size());
567 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
571 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
574 *leaf, static_cast<Index>(mIndex));
576 const bool uniform = handle->isUniform();
579 if (uniform) uniformValue =
ValueType(handle->get(0));
582 auto iter = leaf->beginIndexOn(
MultiGroupFilter(mIncludeGroups, mExcludeGroups));
585 for (; iter; ++iter) {
586 for (
Index i = 0;
i < mStride;
i++) {
587 pHandle.set(static_cast<Index>(offset),
i, uniformValue);
593 for (; iter; ++iter) {
594 for (
Index i = 0;
i < mStride;
i++) {
595 pHandle.set(static_cast<Index>(offset),
i, handle->get(*iter));
602 auto iter = leaf->beginIndexOn();
605 for (; iter; ++iter) {
606 for (
Index i = 0;
i < mStride;
i++) {
607 pHandle.set(static_cast<Index>(offset),
i, uniformValue);
613 for (; iter; ++iter) {
614 for (
Index i = 0;
i < mStride;
i++) {
615 pHandle.set(static_cast<Index>(offset),
i,
616 handle->get(*iter,
i));
637 template<
typename Po
intDataTreeType,
typename Group>
640 using LeafNode =
typename PointDataTreeType::LeafNodeType;
646 const std::vector<Index64>& pointOffsets,
648 const AttributeSet::Descriptor::GroupIndex index,
649 const std::vector<Name>& includeGroups = std::vector<Name>(),
650 const std::vector<Name>& excludeGroups = std::vector<Name>(),
651 const bool inCoreOnly =
false)
653 , mPointOffsets(pointOffsets)
654 , mStartOffset(startOffset)
656 , mIncludeGroups(includeGroups)
657 , mExcludeGroups(excludeGroups)
658 , mInCoreOnly(inCoreOnly) { }
662 const bool useGroups = !mIncludeGroups.empty() || !mExcludeGroups.empty();
664 for (
auto leaf = range.begin(); leaf; ++leaf) {
666 assert(leaf.pos() < mPointOffsets.size());
668 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
672 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
674 const AttributeArray& array = leaf->constAttributeArray(mIndex.first);
675 const auto bitmask =
static_cast<GroupType>(1 << mIndex.second);
681 const bool uniform = groupArray.
isUniform();
684 if (!(groupArray.
get(0) & bitmask))
continue;
688 auto iter = leaf->beginIndexOn(
MultiGroupFilter(mIncludeGroups, mExcludeGroups));
691 for (; iter; ++iter) {
692 mGroup.setOffsetOn(static_cast<Index>(offset));
697 for (; iter; ++iter) {
698 if (groupArray.
get(*iter) & bitmask) {
699 mGroup.setOffsetOn(static_cast<Index>(offset));
706 auto iter = leaf->beginIndexOn();
709 for (; iter; ++iter) {
710 mGroup.setOffsetOn(static_cast<Index>(offset));
715 for (; iter; ++iter) {
716 if (groupArray.
get(*iter) & bitmask) {
717 mGroup.setOffsetOn(static_cast<Index>(offset));
737 template<
typename PositionArrayT>
742 : mPositions(positions)
743 , mInverseMat(inverse)
744 , mMin(std::numeric_limits<
Real>::
max())
745 , mMax(-std::numeric_limits<
Real>::
max()) {}
748 : mPositions(other.mPositions)
749 , mInverseMat(other.mInverseMat)
750 , mMin(std::numeric_limits<
Real>::
max())
751 , mMax(-std::numeric_limits<
Real>::
max()) {}
755 for (
size_t n = range.begin(), N = range.end(); n != N; ++n) {
756 mPositions.getPos(n, pos);
757 pos = mInverseMat.transform(pos);
769 return BBoxd(mMin, mMax);
773 const PositionArrayT& mPositions;
784 template<
typename CompressionT,
typename Po
intDataGr
idT,
typename PositionArrayT,
typename Po
intIndexGr
idT>
785 inline typename PointDataGridT::Ptr
789 using PointDataTreeT =
typename PointDataGridT::TreeType;
790 using PointIndexTreeT =
typename PointIndexGridT::TreeType;
792 using LeafRangeT =
typename LeafManagerT::LeafRange;
798 const NamePair positionType = PositionAttributeT::attributeType();
802 const PointIndexTreeT& pointIndexTree(pointIndexGrid.tree());
803 typename PointDataTreeT::Ptr treePtr(
new PointDataTreeT(pointIndexTree));
805 LeafManagerT leafManager = LeafManagerT(*treePtr);
806 LeafRangeT leafRange = leafManager.leafRange();
810 auto descriptor = AttributeSet::Descriptor::create(positionType);
814 if (positionDefaultValue) descriptor->setDefaultValue(
"P", *positionDefaultValue);
818 InitialiseAttributesOp<PointDataTreeT, PointIndexTreeT> initialise(
819 pointIndexGrid.tree(), descriptor);
820 tbb::parallel_for(leafRange, initialise);
824 PopulatePositionAttributeOp<PointDataTreeT,
826 PositionArrayT> populate(pointIndexTree,
830 tbb::parallel_for(leafRange, populate);
832 auto grid = PointDataGridT::create(treePtr);
833 grid->setTransform(xform.
copy());
841 template <
typename CompressionT,
typename Po
intDataGr
idT,
typename ValueT>
842 inline typename PointDataGridT::Ptr
850 return createPointDataGrid<CompressionT, PointDataGridT>(*pointIndexGrid, pointList, xform, positionDefaultValue);
857 template <
typename Po
intDataTreeT,
typename Po
intIndexTreeT,
typename Po
intArrayT>
861 const bool insertMetadata)
864 using ValueType =
typename PointArrayT::value_type;
866 auto iter = tree.cbeginLeaf();
870 const size_t index = iter->attributeSet().find(attributeName);
872 if (index == AttributeSet::INVALID_POS) {
876 if (insertMetadata) {
884 PopulateAttributeOp<PointDataTreeT,
886 PointArrayT> populate(pointIndexTree,
data, index, stride);
887 tbb::parallel_for(leafManager.
leafRange(), populate);
894 template <
typename PositionAttribute,
typename Po
intDataGr
idT>
897 const PointDataGridT& grid,
898 const std::vector<Index64>& pointOffsets,
900 const std::vector<Name>& includeGroups,
901 const std::vector<Name>& excludeGroups,
902 const bool inCoreOnly)
904 using TreeType =
typename PointDataGridT::TreeType;
909 const TreeType& tree = grid.tree();
910 auto iter = tree.cbeginLeaf();
916 const AttributeSet::Descriptor& descriptor = iter->attributeSet().descriptor();
918 std::vector<Name> newIncludeGroups(includeGroups);
919 std::vector<Name> newExcludeGroups(excludeGroups);
924 LeafManagerT leafManager(tree);
926 const size_t positionIndex = iter->attributeSet().find(
"P");
928 positionAttribute.expand();
929 ConvertPointDataGridPositionOp<TreeType, PositionAttribute> convert(
930 positionAttribute, pointOffsets, startOffset, grid.transform(), positionIndex,
931 newIncludeGroups, newExcludeGroups, inCoreOnly);
932 tbb::parallel_for(leafManager.leafRange(), convert);
933 positionAttribute.compact();
940 template <
typename TypedAttribute,
typename Po
intDataTreeT>
943 const PointDataTreeT& tree,
944 const std::vector<Index64>& pointOffsets,
946 const unsigned arrayIndex,
948 const std::vector<Name>& includeGroups,
949 const std::vector<Name>& excludeGroups,
950 const bool inCoreOnly)
956 auto iter = tree.cbeginLeaf();
962 const AttributeSet::Descriptor& descriptor = iter->attributeSet().descriptor();
964 std::vector<Name> newIncludeGroups(includeGroups);
965 std::vector<Name> newExcludeGroups(excludeGroups);
970 LeafManagerT leafManager(tree);
973 ConvertPointDataGridAttributeOp<PointDataTreeT, TypedAttribute> convert(
974 attribute, pointOffsets, startOffset, arrayIndex, stride,
975 newIncludeGroups, newExcludeGroups, inCoreOnly);
976 tbb::parallel_for(leafManager.leafRange(), convert);
984 template <
typename Group,
typename Po
intDataTreeT>
987 const PointDataTreeT& tree,
988 const std::vector<Index64>& pointOffsets,
990 const AttributeSet::Descriptor::GroupIndex index,
991 const std::vector<Name>& includeGroups,
992 const std::vector<Name>& excludeGroups,
993 const bool inCoreOnly)
999 auto iter = tree.cbeginLeaf();
1005 const AttributeSet::Descriptor& descriptor = iter->attributeSet().descriptor();
1007 std::vector<Name> newIncludeGroups(includeGroups);
1008 std::vector<Name> newExcludeGroups(excludeGroups);
1013 LeafManagerT leafManager(tree);
1015 ConvertPointDataGridGroupOp<PointDataTree, Group> convert(
1016 group, pointOffsets, startOffset, index,
1017 newIncludeGroups, newExcludeGroups, inCoreOnly);
1018 tbb::parallel_for(leafManager.leafRange(), convert);
1025 template<
typename PositionWrapper,
typename InterrupterT>
1028 const uint32_t pointsPerVoxel,
1030 const Index decimalPlaces,
1031 InterrupterT*
const interrupter)
1033 using namespace point_conversion_internal;
1037 static bool voxelSizeFromVolume(
const double volume,
1038 const size_t estimatedVoxelCount,
1042 static const double minimumVoxelVolume(3e-15);
1045 double voxelVolume = volume /
static_cast<double>(estimatedVoxelCount);
1048 if (voxelVolume < minimumVoxelVolume) {
1049 voxelVolume = minimumVoxelVolume;
1052 else if (voxelVolume > maximumVoxelVolume) {
1053 voxelVolume = maximumVoxelVolume;
1057 voxelSize =
static_cast<float>(
math::Pow(voxelVolume, 1.0/3.0));
1061 static float truncate(
const float voxelSize,
Index decPlaces)
1063 float truncatedVoxelSize = voxelSize;
1066 for (
int i = decPlaces;
i < 11;
i++) {
1067 truncatedVoxelSize =
static_cast<float>(
math::Truncate(
double(voxelSize),
i));
1068 if (truncatedVoxelSize != 0.0f)
break;
1071 return truncatedVoxelSize;
1079 float voxelSize(0.1f);
1081 const size_t numPoints = positions.size();
1085 if (numPoints <= 1)
return voxelSize;
1087 size_t targetVoxelCount(numPoints /
size_t(pointsPerVoxel));
1088 if (targetVoxelCount == 0) targetVoxelCount++;
1093 inverseTransform =
math::unit(inverseTransform);
1095 tbb::blocked_range<size_t> range(0, numPoints);
1096 CalculatePositionBounds<PositionWrapper>
calculateBounds(positions, inverseTransform);
1103 if (bbox.
min() == bbox.
max())
return voxelSize;
1105 double volume = bbox.
volume();
1113 volume = extents[0]*extents[0]*extents[0];
1117 volume = extents[0]*extents[1]*extents[1];
1121 double previousVolume = volume;
1123 if (!Local::voxelSizeFromVolume(volume, targetVoxelCount, voxelSize)) {
1128 size_t previousVoxelCount(0);
1129 size_t voxelCount(1);
1131 if (interrupter) interrupter->start(
"Computing voxel size");
1133 while (voxelCount > previousVoxelCount)
1144 newTransform = math::Transform::createLinearTransform(matrix);
1148 newTransform = math::Transform::createLinearTransform(voxelSize);
1156 mask->setTransform(newTransform);
1162 previousVoxelCount = voxelCount;
1163 voxelCount = mask->activeVoxelCount();
1168 if (volume >= previousVolume)
break;
1169 previousVolume = volume;
1171 const float previousVoxelSize = voxelSize;
1175 if (!Local::voxelSizeFromVolume(volume, targetVoxelCount, voxelSize)) {
1176 voxelSize = previousVoxelSize;
1183 if (voxelSize / previousVoxelSize > 0.9f)
break;
1186 if (interrupter) interrupter->end();
1190 return Local::truncate(voxelSize, decimalPlaces);
1198 #endif // OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED math::Mat4< double > Mat4d
Definition: Types.h:103
std::shared_ptr< Handle > Ptr
Definition: AttributeArray.h:713
static Handle::Ptr handleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:253
const bool mInCoreOnly
Definition: PointConversion.h:734
const bool mInCoreOnly
Definition: PointConversion.h:527
Definition: AttributeArrayString.h:160
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:521
void operator()(const typename LeafManagerT::LeafRange &range) const
Definition: PointConversion.h:297
void convertPointDataGridAttribute(TypedAttribute &attribute, const PointDataTreeT &tree, const std::vector< Index64 > &pointOffsets, const Index64 startOffset, const unsigned arrayIndex, const Index stride=1, const std::vector< Name > &includeGroups=std::vector< Name >(), const std::vector< Name > &excludeGroups=std::vector< Name >(), const bool inCoreOnly=false)
Convert the attribute from a PointDataGrid.
Definition: PointConversion.h:942
Definition: Exceptions.h:86
double Real
Definition: Types.h:63
bool isGroup(const AttributeArray &array)
Definition: AttributeGroup.h:92
std::shared_ptr< StringAttributeWriteHandle > Ptr
Definition: AttributeArrayString.h:163
void operator()(const typename LeafManagerT::LeafRange &range) const
Definition: PointConversion.h:404
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointConversion.h:286
typename PointIndexLeafNode::IndexArray IndexArray
Definition: PointConversion.h:331
typename ConversionTraits< ValueType >::WriteHandle HandleT
Definition: PointConversion.h:393
void convertPointDataGridPosition(PositionAttribute &positionAttribute, const PointDataGridT &grid, const std::vector< Index64 > &pointOffsets, const Index64 startOffset, const std::vector< Name > &includeGroups=std::vector< Name >(), const std::vector< Name > &excludeGroups=std::vector< Name >(), const bool inCoreOnly=false)
Convert the position attribute from a Point Data Grid.
Definition: PointConversion.h:896
Space-partitioning acceleration structure for points. Partitions the points into voxels to accelerate...
#define OPENVDB_LOG_DEBUG(message)
In debug builds only, log a debugging message of the form 'someVar << "text" << ...'.
Definition: logging.h:289
AttributeSet::Descriptor::GroupIndex GroupIndex
Definition: PointConversion.h:641
bool isIdentity(const MatType &m)
Determine if a matrix is an identity matrix.
Definition: Mat.h:888
static T zero()
Definition: PointConversion.h:251
size_t size() const
Definition: PointConversion.h:229
Mat4 inverse(T tolerance=0) const
Definition: Mat4.h:539
SharedPtr< Grid > Ptr
Definition: Grid.h:502
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:451
ConvertPointDataGridPositionOp(Attribute &attribute, const std::vector< Index64 > &pointOffsets, const Index64 startOffset, const math::Transform &transform, const size_t index, const std::vector< Name > &includeGroups=std::vector< Name >(), const std::vector< Name > &excludeGroups=std::vector< Name >(), const bool inCoreOnly=false)
Definition: PointConversion.h:454
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:477
void operator()(const tbb::blocked_range< size_t > &range)
Definition: PointConversion.h:753
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:101
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:287
const AttributeListType & mData
Definition: PointConversion.h:441
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:628
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:538
const bool mInCoreOnly
Definition: PointConversion.h:634
tbb::atomic< Index32 > i
Definition: LeafBuffer.h:71
const size_t mIndex
Definition: PointConversion.h:442
Vec3T extents() const
Returns the extents of the BBox, i.e. the length per axis for floating points values or number of gri...
Definition: BBox.h:288
ElementType volume() const
Return the volume spanned by this BBox.
Definition: BBox.h:126
Vec3< typename MatType::value_type > getScale(const MatType &mat)
Return a Vec3 representing the lengths of the passed matrix's upper 3x3's rows.
Definition: Mat.h:661
Type Pow(Type x, int n)
Return .
Definition: Math.h:511
T * data
Definition: LeafBuffer.h:71
const PointIndexTreeType & mPointIndexTree
Definition: PointConversion.h:440
const Index mStride
Definition: PointConversion.h:443
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:660
Group & mGroup
Definition: PointConversion.h:728
Index32 Index
Definition: Types.h:57
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...
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:843
Definition: PointConversion.h:284
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:328
Definition: PointConversion.h:386
typename PointIndexTreeType::LeafNodeType PointIndexLeafNode
Definition: PointConversion.h:390
void deleteMissingPointGroups(std::vector< std::string > &groups, const AttributeSet::Descriptor &descriptor)
Delete any group that is not present in the Descriptor.
Definition: PointGroup.h:434
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointConversion.h:388
Point attribute manipulation in a VDB Point Grid.
ConvertPointDataGridAttributeOp(Attribute &attribute, const std::vector< Index64 > &pointOffsets, const Index64 startOffset, const size_t index, const Index stride=1, const std::vector< Name > &includeGroups=std::vector< Name >(), const std::vector< Name > &excludeGroups=std::vector< Name >(), const bool inCoreOnly=false)
Definition: PointConversion.h:540
PointAttributeVector(const std::vector< value_type > &data, const Index stride=1)
Definition: PointConversion.h:224
const std::vector< std::string > & mExcludeGroups
Definition: PointConversion.h:633
Point group manipulation in a VDB Point Grid.
const Index64 mStartOffset
Definition: PointConversion.h:730
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:534
Definition: IndexFilter.h:103
typename PointIndexLeafNode::IndexArray IndexArray
Definition: PointConversion.h:391
Index filters primarily designed to be used with a FilterIndexIter.
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:859
Vec2< T > minComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise minimum of the two vectors.
Definition: Vec2.h:529
uint64_t Index64
Definition: Types.h:56
bool wasInterrupted(T *i, int percent=-1)
Definition: NullInterrupter.h:76
typename PointIndexLeafNode::IndexArray IndexArray
Definition: PointConversion.h:290
void preScale(const Vec3< T0 > &v)
Definition: Mat4.h:790
Definition: PointConversion.h:447
std::string Name
Definition: Name.h:44
void getPos(size_t n, ValueType &xyz) const
Definition: PointConversion.h:230
const std::vector< std::string > & mIncludeGroups
Definition: PointConversion.h:525
const Index64 mStartOffset
Definition: PointConversion.h:629
typename Attribute::ValueType ValueType
Definition: PointConversion.h:450
#define OPENVDB_VERSION_NAME
Definition: version.h:43
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointConversion.h:327
Definition: PointConversion.h:638
const std::vector< Index64 > & mPointOffsets
Definition: PointConversion.h:729
CalculatePositionBounds(const CalculatePositionBounds &other, tbb::split)
Definition: PointConversion.h:747
Vec3< T > reversed() const
Return the vector (z, y, x)
Definition: Vec3.h:474
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=std::vector< Name >(), const std::vector< Name > &excludeGroups=std::vector< Name >(), const bool inCoreOnly=false)
Convert the group from a PointDataGrid.
Definition: PointConversion.h:986
bool isUniform() const override
Return true if this array is stored as a single uniform value.
Definition: AttributeArray.h:535
PopulatePositionAttributeOp(const PointIndexTreeType &pointIndexTree, const math::Transform &transform, const PositionListType &positions)
Definition: PointConversion.h:335
math::BBox< Vec3d > BBoxd
Definition: Types.h:87
const AttributeSet::Descriptor::Ptr & mAttributeDescriptor
Definition: PointConversion.h:319
InitialiseAttributesOp(const PointIndexTreeType &pointIndexTree, const AttributeSet::Descriptor::Ptr &attributeDescriptor)
Definition: PointConversion.h:292
typename AttributeListType::value_type ValueType
Definition: PointConversion.h:392
const Vec3T & min() const
Return a const reference to the minimum point of the BBox.
Definition: BBox.h:84
Definition: AttributeArrayString.h:134
Definition: PointConversion.h:247
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:640
const Vec3T & max() const
Return a const reference to the maximum point of the BBox.
Definition: BBox.h:87
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:643
Definition: Exceptions.h:39
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:537
const std::vector< std::string > & mExcludeGroups
Definition: PointConversion.h:733
const PointIndexTreeType & mPointIndexTree
Definition: PointConversion.h:378
typename PointDataTreeType::LeafNodeType LeafNode
Definition: PointConversion.h:449
const PointIndexTreeType & mPointIndexTree
Definition: PointConversion.h:318
const GroupIndex mIndex
Definition: PointConversion.h:731
Vec3< double > Vec3d
Definition: Vec3.h:678
This tool produces a grid where every voxel that contains a point is active. It employes thread-local...
static Handle::Ptr handleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:269
Typed class for storing attribute data.
Definition: AttributeArray.h:437
const size_t mIndex
Definition: PointConversion.h:524
Definition: PointConversion.h:325
const Index mStride
Definition: PointConversion.h:631
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition: LeafManager.h:386
typename PositionListType::value_type ValueType
Definition: PointConversion.h:333
void join(const CalculatePositionBounds &other)
Definition: PointConversion.h:763
uint8_t GroupType
Definition: AttributeGroup.h:49
const Index64 mStartOffset
Definition: PointConversion.h:522
typename PointIndexTreeType::LeafNodeType PointIndexLeafNode
Definition: PointConversion.h:330
Vec2< T > maxComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise maximum of the two vectors.
Definition: Vec2.h:538
math::Vec3< float > Vec3f
Definition: Types.h:77
Definition: AttributeArray.h:640
const std::vector< std::string > & mIncludeGroups
Definition: PointConversion.h:732
PopulateAttributeOp(const PointIndexTreeType &pointIndexTree, const AttributeListType &data, const size_t index, const Index stride=1)
Definition: PointConversion.h:395
typename ConversionTraits< ValueType >::Handle HandleT
Definition: PointConversion.h:536
Definition: Exceptions.h:92
This class manages a linear array of pointers to a given tree's leaf nodes, as well as optional auxil...
Definition: LeafManager.h:110
Vec3< T > sorted() const
Return a vector with the components of this in ascending order.
Definition: Vec3.h:464
const std::vector< std::string > & mExcludeGroups
Definition: PointConversion.h:526
ValueType get(Index n) const
Return the value at index n.
Definition: AttributeArray.h:1082
static WriteHandle::Ptr writeHandleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:275
typename PointIndexTreeType::LeafNodeType PointIndexLeafNode
Definition: PointConversion.h:289
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
MatType unit(const MatType &mat, typename MatType::value_type eps=1.0e-8)
Return a copy of the given matrix with its upper 3x3 rows normalized.
Definition: Mat.h:676
Attribute & mAttribute
Definition: PointConversion.h:520
Type Pow3(Type x)
Return .
Definition: Math.h:502
typename Attribute::ValueType ValueType
Definition: PointConversion.h:535
const PositionListType & mPositions
Definition: PointConversion.h:380
std::shared_ptr< Handle > Ptr
Definition: AttributeArray.h:644
typename tree::LeafManager< const PointDataTreeType > LeafManagerT
Definition: PointConversion.h:642
const math::Transform & mTransform
Definition: PointConversion.h:523
Definition: PointConversion.h:738
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
CalculatePositionBounds(const PositionArrayT &positions, const math::Mat4d &inverse)
Definition: PointConversion.h:740
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:1027
static WriteHandle::Ptr writeHandleFromLeaf(LeafT &leaf, Index index)
Definition: PointConversion.h:258
Base class for storing attribute data.
Definition: AttributeArray.h:118
Point-partitioner compatible STL vector attribute wrapper for convenience.
Definition: PointConversion.h:219
float Round(float x)
Return x rounded to the nearest integer.
Definition: Math.h:769
Attribute array storage for string data using Descriptor Metadata.
Definition: PointConversion.h:532
Type Truncate(Type x, unsigned int digits)
Return x truncated to the given number of decimal digits.
Definition: Math.h:820
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:389
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:65
const math::Transform & mTransform
Definition: PointConversion.h:379
ValueType value_type
Definition: PointConversion.h:222
std::shared_ptr< StringAttributeHandle > Ptr
Definition: AttributeArrayString.h:137
const size_t mIndex
Definition: PointConversion.h:630
ValueType PosType
Definition: PointConversion.h:221
void operator()(const typename LeafManagerT::LeafRange &range) const
Definition: PointConversion.h:342
static openvdb::Name zero()
Definition: PointConversion.h:267
Attribute & mAttribute
Definition: PointConversion.h:627
void operator()(const LeafRangeT &range) const
Definition: PointConversion.h:557
Index64 pointCount(const PointDataTreeT &tree, const bool inCoreOnly=false)
Total points in the PointDataTree.
Definition: PointCount.h:198
Set of Attribute Arrays which tracks metadata about each array.
ConvertPointDataGridGroupOp(Group &group, const std::vector< Index64 > &pointOffsets, const Index64 startOffset, const AttributeSet::Descriptor::GroupIndex index, const std::vector< Name > &includeGroups=std::vector< Name >(), const std::vector< Name > &excludeGroups=std::vector< Name >(), const bool inCoreOnly=false)
Definition: PointConversion.h:645
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointConversion.h:452
const std::vector< std::string > & mIncludeGroups
Definition: PointConversion.h:632
BBoxd getBoundingBox() const
Definition: PointConversion.h:768
Write-able version of AttributeHandle.
Definition: AttributeArray.h:709