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,
136 const std::vector<Index64>& pointOffsets,
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,
159 const std::vector<Index64>& pointOffsets,
161 const AttributeSet::Descriptor::GroupIndex index,
162 const FilterT& filter = NullFilter(),
163 const bool inCoreOnly =
false);
168 template <
typename...>
using void_t = void;
169 template <
typename T,
typename =
void>
171 template <
typename T>
189 template<
typename PositionWrapper,
190 typename InterrupterT = openvdb::util::NullInterrupter,
194 const uint32_t pointsPerVoxel,
195 const math::Mat4d transform = math::Mat4d::identity(),
196 const Index decimalPlaces = 5,
197 InterrupterT*
const interrupter =
nullptr);
204 template<
typename ValueType>
211 const Index stride = 1)
213 , mStride(stride) { }
215 size_t size()
const {
return mData.size(); }
216 void getPos(
size_t n, ValueType& xyz)
const { xyz = mData[n]; }
217 void get(ValueType&
value,
size_t n)
const { value = mData[n]; }
221 const std::vector<value_type>& mData;
230 namespace point_conversion_internal {
234 template <
typename T>
struct ConversionTraits
238 static T zero() {
return zeroVal<T>(); }
239 template <
typename LeafT>
240 static typename Handle::Ptr handleFromLeaf(LeafT& leaf,
Index index) {
242 return Handle::create(array);
244 template <
typename LeafT>
245 static typename WriteHandle::Ptr writeHandleFromLeaf(LeafT& leaf,
Index index) {
247 return WriteHandle::create(array);
250 template <>
struct ConversionTraits<openvdb::
Name>
255 template <
typename LeafT>
256 static typename Handle::Ptr handleFromLeaf(LeafT& leaf,
Index index) {
258 const AttributeSet::Descriptor& descriptor = leaf.attributeSet().descriptor();
259 return Handle::create(array, descriptor.getMetadata());
261 template <
typename LeafT>
262 static typename WriteHandle::Ptr writeHandleFromLeaf(LeafT& leaf,
Index index) {
264 const AttributeSet::Descriptor& descriptor = leaf.attributeSet().descriptor();
265 return WriteHandle::create(array, descriptor.getMetadata());
269 template<
typename PointDataTreeType,
270 typename PointIndexTreeType,
271 typename AttributeListType>
272 struct PopulateAttributeOp {
275 using LeafRangeT =
typename LeafManagerT::LeafRange;
276 using PointIndexLeafNode =
typename PointIndexTreeType::LeafNodeType;
278 using ValueType =
typename AttributeListType::value_type;
279 using HandleT =
typename ConversionTraits<ValueType>::WriteHandle;
281 PopulateAttributeOp(
const PointIndexTreeType& pointIndexTree,
282 const AttributeListType& data,
284 const Index stride = 1)
285 : mPointIndexTree(pointIndexTree)
288 , mStride(stride) { }
290 void operator()(
const typename LeafManagerT::LeafRange& range)
const {
292 for (
auto leaf = range.begin(); leaf; ++leaf) {
296 const PointIndexLeafNode* pointIndexLeaf =
297 mPointIndexTree.probeConstLeaf(leaf->origin());
299 if (!pointIndexLeaf)
continue;
301 typename HandleT::Ptr attributeWriteHandle =
302 ConversionTraits<ValueType>::writeHandleFromLeaf(*leaf, static_cast<Index>(mIndex));
306 const IndexArray& indices = pointIndexLeaf->indices();
308 for (
const Index64 leafIndex: indices)
311 for (
Index i = 0; i < mStride; i++) {
312 mData.get(value, leafIndex, i);
313 attributeWriteHandle->set(static_cast<Index>(index), i, value);
320 attributeWriteHandle->compact();
326 const PointIndexTreeType& mPointIndexTree;
327 const AttributeListType& mData;
332 template<
typename Po
intDataTreeType,
typename Attribute,
typename FilterT>
333 struct ConvertPointDataGridPositionOp {
335 using LeafNode =
typename PointDataTreeType::LeafNodeType;
336 using ValueType =
typename Attribute::ValueType;
337 using HandleT =
typename Attribute::Handle;
340 using LeafRangeT =
typename LeafManagerT::LeafRange;
342 ConvertPointDataGridPositionOp( Attribute& attribute,
343 const std::vector<Index64>& pointOffsets,
347 const FilterT& filter,
348 const bool inCoreOnly)
349 : mAttribute(attribute)
350 , mPointOffsets(pointOffsets)
351 , mStartOffset(startOffset)
352 , mTransform(transform)
355 , mInCoreOnly(inCoreOnly)
360 "ValueType is not Vec3f");
363 template <
typename IterT>
364 void convert(IterT& iter, HandleT& targetHandle,
365 SourceHandleT& sourceHandle,
Index64& offset)
const 367 for (; iter; ++iter) {
368 const Vec3d xyz = iter.getCoord().asVec3d();
369 const Vec3d pos = sourceHandle.get(*iter);
370 targetHandle.set(static_cast<Index>(offset++), 0,
371 mTransform.indexToWorld(pos + xyz));
375 void operator()(
const LeafRangeT& range)
const 377 HandleT pHandle(mAttribute);
379 for (
auto leaf = range.begin(); leaf; ++leaf) {
381 assert(leaf.pos() < mPointOffsets.size());
383 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
387 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
389 auto handle = SourceHandleT::create(leaf->constAttributeArray(mIndex));
392 auto iter = leaf->beginIndexOn();
393 convert(iter, pHandle, *handle, offset);
396 auto iter = leaf->beginIndexOn(mFilter);
397 convert(iter, pHandle, *handle, offset);
404 Attribute& mAttribute;
405 const std::vector<Index64>& mPointOffsets;
409 const FilterT& mFilter;
410 const bool mInCoreOnly;
414 template<
typename Po
intDataTreeType,
typename Attribute,
typename FilterT>
415 struct ConvertPointDataGridAttributeOp {
417 using LeafNode =
typename PointDataTreeType::LeafNodeType;
418 using ValueType =
typename Attribute::ValueType;
419 using HandleT =
typename Attribute::Handle;
420 using SourceHandleT =
typename ConversionTraits<ValueType>::Handle;
422 using LeafRangeT =
typename LeafManagerT::LeafRange;
424 ConvertPointDataGridAttributeOp(Attribute& attribute,
425 const std::vector<Index64>& pointOffsets,
429 const FilterT& filter,
430 const bool inCoreOnly)
431 : mAttribute(attribute)
432 , mPointOffsets(pointOffsets)
433 , mStartOffset(startOffset)
437 , mInCoreOnly(inCoreOnly) { }
439 template <
typename IterT>
440 void convert(IterT& iter, HandleT& targetHandle,
441 SourceHandleT& sourceHandle,
Index64& offset)
const 443 if (sourceHandle.isUniform()) {
444 const ValueType uniformValue(sourceHandle.get(0));
445 for (; iter; ++iter) {
446 for (
Index i = 0; i < mStride; i++) {
447 targetHandle.set(static_cast<Index>(offset), i, uniformValue);
453 for (; iter; ++iter) {
454 for (
Index i = 0; i < mStride; i++) {
455 targetHandle.set(static_cast<Index>(offset), i,
456 sourceHandle.get(*iter, i));
463 void operator()(
const LeafRangeT& range)
const 465 HandleT pHandle(mAttribute);
467 for (
auto leaf = range.begin(); leaf; ++leaf) {
469 assert(leaf.pos() < mPointOffsets.size());
471 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
475 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
477 typename SourceHandleT::Ptr handle = ConversionTraits<ValueType>::handleFromLeaf(
478 *leaf, static_cast<Index>(mIndex));
481 auto iter = leaf->beginIndexOn();
482 convert(iter, pHandle, *handle, offset);
484 auto iter = leaf->beginIndexOn(mFilter);
485 convert(iter, pHandle, *handle, offset);
492 Attribute& mAttribute;
493 const std::vector<Index64>& mPointOffsets;
497 const FilterT& mFilter;
498 const bool mInCoreOnly;
501 template<
typename Po
intDataTreeType,
typename Group,
typename FilterT>
502 struct ConvertPointDataGridGroupOp {
504 using LeafNode =
typename PointDataTreeType::LeafNodeType;
505 using GroupIndex = AttributeSet::Descriptor::GroupIndex;
507 using LeafRangeT =
typename LeafManagerT::LeafRange;
509 ConvertPointDataGridGroupOp(Group& group,
510 const std::vector<Index64>& pointOffsets,
512 const AttributeSet::Descriptor::GroupIndex index,
513 const FilterT& filter,
514 const bool inCoreOnly)
516 , mPointOffsets(pointOffsets)
517 , mStartOffset(startOffset)
520 , mInCoreOnly(inCoreOnly) { }
522 template <
typename IterT>
525 const auto bitmask =
static_cast<GroupType>(1 << mIndex.second);
528 if (groupArray.
get(0) & bitmask) {
529 for (; iter; ++iter) {
530 mGroup.setOffsetOn(static_cast<Index>(offset));
536 for (; iter; ++iter) {
537 if (groupArray.
get(*iter) & bitmask) {
538 mGroup.setOffsetOn(static_cast<Index>(offset));
545 void operator()(
const LeafRangeT& range)
const 547 for (
auto leaf = range.begin(); leaf; ++leaf) {
549 assert(leaf.pos() < mPointOffsets.size());
551 if (mInCoreOnly && leaf->buffer().isOutOfCore())
continue;
555 if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
557 const AttributeArray& array = leaf->constAttributeArray(mIndex.first);
562 auto iter = leaf->beginIndexOn();
563 convert(iter, groupArray, offset);
566 auto iter = leaf->beginIndexOn(mFilter);
567 convert(iter, groupArray, offset);
575 const std::vector<Index64>& mPointOffsets;
577 const GroupIndex mIndex;
578 const FilterT& mFilter;
579 const bool mInCoreOnly;
582 template<
typename PositionArrayT,
typename VecT = Vec3R>
583 struct CalculatePositionBounds
585 CalculatePositionBounds(
const PositionArrayT& positions,
587 : mPositions(positions)
588 , mInverseMat(inverse)
592 CalculatePositionBounds(
const CalculatePositionBounds& other, tbb::split)
593 : mPositions(other.mPositions)
594 , mInverseMat(other.mInverseMat)
598 void operator()(
const tbb::blocked_range<size_t>& range) {
600 for (
size_t n = range.begin(), N = range.end(); n != N; ++n) {
601 mPositions.getPos(n, pos);
602 pos = mInverseMat.transform(pos);
608 void join(
const CalculatePositionBounds& other) {
613 BBoxd getBoundingBox()
const {
614 return BBoxd(mMin, mMax);
618 const PositionArrayT& mPositions;
630 template<
typename CompressionT,
typename Po
intDataGr
idT,
typename PositionArrayT,
typename Po
intIndexGr
idT>
631 inline typename PointDataGridT::Ptr
633 const PositionArrayT& positions,
635 const Metadata* positionDefaultValue)
637 using PointDataTreeT =
typename PointDataGridT::TreeType;
638 using LeafT =
typename PointDataTreeT::LeafNodeType;
639 using PointIndexLeafT =
typename PointIndexGridT::TreeType::LeafNodeType;
640 using PointIndexT =
typename PointIndexLeafT::ValueType;
644 const NamePair positionType = PositionAttributeT::attributeType();
648 const auto& pointIndexTree = pointIndexGrid.tree();
649 typename PointDataTreeT::Ptr treePtr(
new PointDataTreeT(pointIndexTree));
653 auto descriptor = AttributeSet::Descriptor::create(positionType);
657 if (positionDefaultValue) descriptor->setDefaultValue(
"P", *positionDefaultValue);
661 const size_t positionIndex = descriptor->find(
"P");
662 assert(positionIndex != AttributeSet::INVALID_POS);
670 LeafManagerT leafManager(*treePtr);
672 [&](LeafT& leaf,
size_t ) {
676 const auto* pointIndexLeaf = pointIndexTree.probeConstLeaf(leaf.origin());
677 assert(pointIndexLeaf);
681 Index pointCount(static_cast<Index>(pointIndexLeaf->indices().size()));
682 leaf.initializeAttributes(descriptor, pointCount, &lock);
687 leaf.attributeArray(positionIndex));
692 *begin =
static_cast<PointIndexT*
>(
nullptr),
693 *end = static_cast<PointIndexT*>(
nullptr);
697 for (
auto iter = pointIndexLeaf->cbeginValueOn(); iter; ++iter) {
701 const Coord& ijk = iter.getCoord();
702 const Vec3d& positionCellCenter(ijk.asVec3d());
706 pointIndexLeaf->getIndices(ijk, begin, end);
708 while (begin < end) {
710 typename PositionArrayT::value_type positionWorldSpace;
711 positions.getPos(*begin, positionWorldSpace);
715 const Vec3d positionIndexSpace = xform.
worldToIndex(positionWorldSpace);
716 const Vec3f positionVoxelSpace(positionIndexSpace - positionCellCenter);
718 attributeWriteHandle->set(index++, positionVoxelSpace);
726 auto grid = PointDataGridT::create(treePtr);
727 grid->setTransform(xform.
copy());
735 template <
typename CompressionT,
typename Po
intDataGr
idT,
typename ValueT>
736 inline typename PointDataGridT::Ptr
739 const Metadata* positionDefaultValue)
744 tools::createPointIndexGrid<tools::PointIndexGrid>(pointList, xform);
745 return createPointDataGrid<CompressionT, PointDataGridT>(
746 *pointIndexGrid, pointList, xform, positionDefaultValue);
753 template <
typename Po
intDataTreeT,
typename Po
intIndexTreeT,
typename Po
intArrayT>
757 const bool insertMetadata)
759 using point_conversion_internal::PopulateAttributeOp;
760 using ValueType =
typename PointArrayT::value_type;
762 auto iter = tree.cbeginLeaf();
766 const size_t index = iter->attributeSet().find(attributeName);
768 if (index == AttributeSet::INVALID_POS) {
772 if (insertMetadata) {
773 point_attribute_internal::MetadataStorage<PointDataTreeT, ValueType>::add(tree, data);
780 PopulateAttributeOp<PointDataTreeT,
782 PointArrayT> populate(pointIndexTree, data, index, stride);
783 tbb::parallel_for(leafManager.
leafRange(), populate);
790 template <
typename PositionAttribute,
typename Po
intDataGr
idT,
typename FilterT>
793 const PointDataGridT& grid,
794 const std::vector<Index64>& pointOffsets,
796 const FilterT& filter,
797 const bool inCoreOnly)
799 using TreeType =
typename PointDataGridT::TreeType;
802 using point_conversion_internal::ConvertPointDataGridPositionOp;
804 const TreeType& tree = grid.
tree();
805 auto iter = tree.cbeginLeaf();
809 const size_t positionIndex = iter->attributeSet().find(
"P");
811 positionAttribute.expand();
812 LeafManagerT leafManager(tree);
813 ConvertPointDataGridPositionOp<TreeType, PositionAttribute, FilterT> convert(
814 positionAttribute, pointOffsets, startOffset, grid.transform(), positionIndex,
816 tbb::parallel_for(leafManager.leafRange(), convert);
817 positionAttribute.compact();
824 template <
typename TypedAttribute,
typename Po
intDataTreeT,
typename FilterT>
827 const PointDataTreeT& tree,
828 const std::vector<Index64>& pointOffsets,
830 const unsigned arrayIndex,
832 const FilterT& filter,
833 const bool inCoreOnly)
837 using point_conversion_internal::ConvertPointDataGridAttributeOp;
839 auto iter = tree.cbeginLeaf();
844 LeafManagerT leafManager(tree);
845 ConvertPointDataGridAttributeOp<PointDataTreeT, TypedAttribute, FilterT> convert(
846 attribute, pointOffsets, startOffset, arrayIndex, stride,
848 tbb::parallel_for(leafManager.leafRange(), convert);
856 template <
typename Group,
typename Po
intDataTreeT,
typename FilterT>
859 const PointDataTreeT& tree,
860 const std::vector<Index64>& pointOffsets,
862 const AttributeSet::Descriptor::GroupIndex index,
863 const FilterT& filter,
864 const bool inCoreOnly)
868 using point_conversion_internal::ConvertPointDataGridGroupOp;
870 auto iter = tree.cbeginLeaf();
873 LeafManagerT leafManager(tree);
874 ConvertPointDataGridGroupOp<PointDataTreeT, Group, FilterT> convert(
875 group, pointOffsets, startOffset, index,
877 tbb::parallel_for(leafManager.leafRange(), convert);
884 template<
typename PositionWrapper,
typename InterrupterT,
typename VecT>
887 const uint32_t pointsPerVoxel,
889 const Index decimalPlaces,
890 InterrupterT*
const interrupter)
892 using namespace point_conversion_internal;
896 static bool voxelSizeFromVolume(
const double volume,
897 const size_t estimatedVoxelCount,
901 static const double minimumVoxelVolume(3e-15);
904 double voxelVolume = volume /
static_cast<double>(estimatedVoxelCount);
907 if (voxelVolume < minimumVoxelVolume) {
908 voxelVolume = minimumVoxelVolume;
911 else if (voxelVolume > maximumVoxelVolume) {
912 voxelVolume = maximumVoxelVolume;
916 voxelSize =
static_cast<float>(
math::Pow(voxelVolume, 1.0/3.0));
920 static float truncate(
const float voxelSize,
Index decPlaces)
922 float truncatedVoxelSize = voxelSize;
925 for (
int i = decPlaces; i < 11; i++) {
926 truncatedVoxelSize =
static_cast<float>(
math::Truncate(
double(voxelSize), i));
927 if (truncatedVoxelSize != 0.0f)
break;
930 return truncatedVoxelSize;
938 float voxelSize(0.1f);
940 const size_t numPoints = positions.size();
944 if (numPoints <= 1)
return voxelSize;
946 size_t targetVoxelCount(numPoints /
size_t(pointsPerVoxel));
947 if (targetVoxelCount == 0) targetVoxelCount++;
952 inverseTransform =
math::unit(inverseTransform);
954 tbb::blocked_range<size_t> range(0, numPoints);
955 CalculatePositionBounds<PositionWrapper, VecT>
calculateBounds(positions, inverseTransform);
956 tbb::parallel_reduce(range, calculateBounds);
958 BBoxd bbox = calculateBounds.getBoundingBox();
962 if (bbox.
min() == bbox.
max())
return voxelSize;
964 double volume = bbox.
volume();
972 volume = extents[0]*extents[0]*extents[0];
976 volume = extents[0]*extents[1]*extents[1];
980 double previousVolume = volume;
982 if (!Local::voxelSizeFromVolume(volume, targetVoxelCount, voxelSize)) {
987 size_t previousVoxelCount(0);
988 size_t voxelCount(1);
990 if (interrupter) interrupter->start(
"Computing voxel size");
992 while (voxelCount > previousVoxelCount)
1003 newTransform = math::Transform::createLinearTransform(matrix);
1007 newTransform = math::Transform::createLinearTransform(voxelSize);
1015 mask->setTransform(newTransform);
1017 pointMaskOp.template addPoints<PositionWrapper, VecT>(positions);
1021 previousVoxelCount = voxelCount;
1022 voxelCount = mask->activeVoxelCount();
1023 volume =
math::Pow3(voxelSize) *
static_cast<float>(voxelCount);
1027 if (volume >= previousVolume)
break;
1028 previousVolume = volume;
1030 const float previousVoxelSize = voxelSize;
1034 if (!Local::voxelSizeFromVolume(volume, targetVoxelCount, voxelSize)) {
1035 voxelSize = previousVoxelSize;
1042 if (voxelSize / previousVoxelSize > 0.9f)
break;
1045 if (interrupter) interrupter->end();
1049 return Local::truncate(voxelSize, decimalPlaces);
1060 #endif // OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED Vec3< T > sorted() const
Return a vector with the components of this in ascending order.
Definition: Vec3.h:454
std::vector< Index > IndexArray
Definition: PointMove.h:161
bool wasInterrupted(T *i, int percent=-1)
Definition: NullInterrupter.h:49
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:755
ValueType value_type
Definition: PointConversion.h:208
Vec3T extents() const
Return the extents of this bounding box, i.e., the length along each axis.
Definition: BBox.h:253
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
SharedPtr< Grid > Ptr
Definition: Grid.h:579
Point-partitioner compatible STL vector attribute wrapper for convenience.
Definition: PointConversion.h:205
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition: LeafManager.h:345
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:74
const TreeType & tree() const
Return a const reference to tree associated with this manager.
Definition: LeafManager.h:302
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:266
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:886
const Vec3T & min() const
Return a const reference to the minimum point of this bounding box.
Definition: BBox.h:62
Mat4 inverse(T tolerance=0) const
Definition: Mat4.h:499
PointAttributeVector(const std::vector< value_type > &data, const Index stride=1)
Definition: PointConversion.h:210
bool isIdentity(const MatType &m)
Determine if a matrix is an identity matrix.
Definition: Mat.h:882
void getPos(size_t n, ValueType &xyz) const
Definition: PointConversion.h:216
Type Pow(Type x, int n)
Return xn.
Definition: Math.h:564
math::BBox< Vec3d > BBoxd
Definition: Types.h:84
Definition: AttributeArrayString.h:186
bool isApproxZero(const Type &x)
Return true if x is equal to zero to within the default floating-point comparison tolerance...
Definition: Math.h:350
Definition: AttributeArrayString.h:153
Definition: Exceptions.h:65
Base class for storing attribute data.
Definition: AttributeArray.h:92
Definition: AttributeArray.h:118
Definition: Exceptions.h:59
Point attribute manipulation in a VDB Point Grid.
typename T::value_type Type
Definition: PointConversion.h:172
Point group manipulation in a VDB Point Grid.
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:858
Index filters primarily designed to be used with a FilterIndexIter.
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:670
ValueType PosType
Definition: PointConversion.h:207
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
Type Pow3(Type x)
Return x3.
Definition: Math.h:555
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:826
const Vec3T & max() const
Return a const reference to the maximum point of this bounding box.
Definition: BBox.h:64
std::string Name
Definition: Name.h:17
math::Vec3< Real > Vec3R
Definition: Types.h:72
Vec3< T > reversed() const
Return the vector (z, y, x)
Definition: Vec3.h:464
uint8_t GroupType
Definition: AttributeSet.h:31
uint64_t Index64
Definition: Types.h:53
Definition: Exceptions.h:13
ValueT value
Definition: GridBuilder.h:1287
This tool produces a grid where every voxel that contains a point is active. It employs thread-local ...
Definition: IndexIterator.h:43
This class manages a linear array of pointers to a given tree's leaf nodes, as well as optional auxil...
Definition: LeafManager.h:84
Index32 Index
Definition: Types.h:54
bool isUniform() const override
Return true if this array is stored as a single uniform value.
Definition: AttributeArray.h:679
ValueType get(Index n) const
Return the value at index n.
Definition: AttributeArray.h:1393
PointDataGridT::Ptr createPointDataGrid(const std::vector< ValueT > &positions, const math::Transform &xform, const Metadata *positionDefaultValue=nullptr)
Convenience method to create a PointDataGrid from a std::vector of point positions.
Definition: PointConversion.h:737
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 void_t
Definition: PointConversion.h:168
Write-able version of AttributeHandle.
Definition: AttributeArray.h:881
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:655
bool isGroup(const AttributeArray &array)
Definition: AttributeGroup.h:63
Definition: AttributeArray.h:810
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:39
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:792
Attribute array storage for string data using Descriptor Metadata.
Vec2< T > minComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise minimum of the two vectors.
Definition: Vec2.h:508
ElementType volume() const
Return the volume enclosed by this bounding box.
Definition: BBox.h:100
size_t size() const
Definition: PointConversion.h:215
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
Typed class for storing attribute data.
Definition: AttributeArray.h:532
Set of Attribute Arrays which tracks metadata about each array.
void preScale(const Vec3< T0 > &v)
Definition: Mat4.h:750
Vec2< T > maxComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise maximum of the two vectors.
Definition: Vec2.h:517
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202
Definition: PointConversion.h:170
Type Truncate(Type x, unsigned int digits)
Return x truncated to the given number of decimal digits.
Definition: Math.h:873