10#ifndef OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED
11#define OPENVDB_POINTS_POINT_CONVERSION_HAS_BEEN_INCLUDED
26#include <tbb/parallel_reduce.h>
54 typename CompressionT,
55 typename PointDataGridT,
56 typename PositionArrayT,
57 typename PointIndexGridT>
58inline typename PointDataGridT::Ptr
60 const PositionArrayT& positions,
61 const math::Transform& xform,
62 const Metadata* positionDefaultValue =
nullptr);
75template <
typename CompressionT,
typename Po
intDataGr
idT,
typename ValueT>
76inline typename PointDataGridT::Ptr
78 const math::Transform& xform,
79 const Metadata* positionDefaultValue =
nullptr);
93template <
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);
112template <
typename PositionAttribute,
typename Po
intDataGr
idT,
typename FilterT = NullFilter>
115 const PointDataGridT& grid,
116 const std::vector<Index64>& pointOffsets,
117 const Index64 startOffset,
118 const FilterT& filter = NullFilter(),
119 const bool inCoreOnly =
false);
132template <
typename TypedAttribute,
typename Po
intDataTreeT,
typename FilterT = NullFilter>
135 const PointDataTreeT& tree,
136 const std::vector<Index64>& pointOffsets,
137 const Index64 startOffset,
138 const unsigned arrayIndex,
139 const Index stride = 1,
140 const FilterT& filter = NullFilter(),
141 const bool inCoreOnly =
false);
155template <
typename Group,
typename Po
intDataTreeT,
typename FilterT = NullFilter>
158 const PointDataTreeT& tree,
159 const std::vector<Index64>& pointOffsets,
160 const Index64 startOffset,
161 const AttributeSet::Descriptor::GroupIndex index,
162 const FilterT& filter = NullFilter(),
163 const bool inCoreOnly =
false);
168template <
typename...>
using void_t = void;
169template <
typename T,
typename =
void>
172struct ValueTypeTraits <T, void_t<typename T::value_type>> {
using Type =
typename T::value_type; };
189template<
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);
204template<
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]; }
221 const std::vector<value_type>& mData;
230namespace point_conversion_internal {
234template <
typename T>
struct ConversionTraits
236 using Handle = AttributeHandle<T, UnknownCodec>;
237 using WriteHandle = AttributeWriteHandle<T, UnknownCodec>;
238 static T zero() {
return zeroVal<T>(); }
239 template <
typename LeafT>
240 static std::unique_ptr<Handle> handleFromLeaf(
const LeafT& leaf,
const Index index) {
241 const AttributeArray& array = leaf.constAttributeArray(index);
242 return std::make_unique<Handle>(array);
244 template <
typename LeafT>
245 static std::unique_ptr<WriteHandle> writeHandleFromLeaf(LeafT& leaf,
const Index index) {
246 AttributeArray& array = leaf.attributeArray(index);
247 return std::make_unique<WriteHandle>(array);
252 using Handle = StringAttributeHandle;
253 using WriteHandle = StringAttributeWriteHandle;
255 template <
typename LeafT>
256 static std::unique_ptr<Handle> handleFromLeaf(
const LeafT& leaf,
const Index index) {
258 const AttributeSet::Descriptor& descriptor = leaf.attributeSet().descriptor();
259 return std::make_unique<Handle>(array, descriptor.getMetadata());
261 template <
typename LeafT>
262 static std::unique_ptr<WriteHandle> writeHandleFromLeaf(LeafT& leaf,
const Index index) {
264 const AttributeSet::Descriptor& descriptor = leaf.attributeSet().descriptor();
265 return std::make_unique<WriteHandle>(array, descriptor.getMetadata());
269template<
typename PointDataTreeType,
270 typename PointIndexTreeType,
271 typename AttributeListType>
272struct PopulateAttributeOp {
274 using LeafManagerT =
typename tree::LeafManager<PointDataTreeType>;
275 using LeafRangeT =
typename LeafManagerT::LeafRange;
276 using PointIndexLeafNode =
typename PointIndexTreeType::LeafNodeType;
277 using IndexArray =
typename PointIndexLeafNode::IndexArray;
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 auto 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;
332template<
typename Po
intDataTreeType,
typename Attribute,
typename FilterT>
333struct ConvertPointDataGridPositionOp {
335 using LeafNode =
typename PointDataTreeType::LeafNodeType;
336 using ValueType =
typename Attribute::ValueType;
337 using HandleT =
typename Attribute::Handle;
338 using SourceHandleT = AttributeHandle<ValueType>;
339 using LeafManagerT =
typename tree::LeafManager<const PointDataTreeType>;
340 using LeafRangeT =
typename LeafManagerT::LeafRange;
342 ConvertPointDataGridPositionOp( Attribute& attribute,
343 const std::vector<Index64>& pointOffsets,
344 const Index64 startOffset,
345 const math::Transform& transform,
347 const FilterT& filter,
348 const bool inCoreOnly)
349 : mAttribute(attribute)
351 , mStartOffset(startOffset)
352 , mTransform(transform)
355 , mInCoreOnly(inCoreOnly)
358 static_assert(VecTraits<ValueType>::Size == 3 &&
359 std::is_floating_point<typename ValueType::ValueType>::value,
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));
391 if (mFilter.state() == index::ALL) {
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;
407 const math::Transform& mTransform;
409 const FilterT& mFilter;
410 const bool mInCoreOnly;
414template<
typename Po
intDataTreeType,
typename Attribute,
typename FilterT>
415struct 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;
421 using LeafManagerT =
typename tree::LeafManager<const PointDataTreeType>;
422 using LeafRangeT =
typename LeafManagerT::LeafRange;
424 ConvertPointDataGridAttributeOp(Attribute& attribute,
425 const std::vector<Index64>& pointOffsets,
426 const Index64 startOffset,
429 const FilterT& filter,
430 const bool inCoreOnly)
431 : mAttribute(attribute)
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 auto handle = ConversionTraits<ValueType>::handleFromLeaf(
478 *leaf,
static_cast<Index>(mIndex));
480 if (mFilter.state() == index::ALL) {
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;
501template<
typename Po
intDataTreeType,
typename Group,
typename FilterT>
502struct ConvertPointDataGridGroupOp {
504 using LeafNode =
typename PointDataTreeType::LeafNodeType;
505 using GroupIndex = AttributeSet::Descriptor::GroupIndex;
506 using LeafManagerT =
typename tree::LeafManager<const PointDataTreeType>;
507 using LeafRangeT =
typename LeafManagerT::LeafRange;
509 ConvertPointDataGridGroupOp(Group& group,
510 const std::vector<Index64>& pointOffsets,
511 const Index64 startOffset,
512 const AttributeSet::Descriptor::GroupIndex index,
513 const FilterT& filter,
514 const bool inCoreOnly)
517 , mStartOffset(startOffset)
520 , mInCoreOnly(inCoreOnly) { }
522 template <
typename IterT>
523 void convert(IterT& iter,
const GroupAttributeArray& groupArray, Index64& offset)
const
525 const auto bitmask =
static_cast<GroupType>(1 << mIndex.second);
527 if (groupArray.isUniform()) {
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);
561 if (mFilter.state() == index::ALL) {
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;
582template<
typename PositionArrayT,
typename VecT = Vec3R>
583struct CalculatePositionBounds
585 CalculatePositionBounds(
const PositionArrayT& positions,
586 const math::Mat4d& inverse)
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);
603 mMin = math::minComponent(mMin, pos);
604 mMax = math::maxComponent(mMax, pos);
608 void join(
const CalculatePositionBounds& other) {
609 mMin = math::minComponent(mMin, other.mMin);
610 mMax = math::maxComponent(mMax, other.mMax);
613 BBoxd getBoundingBox()
const {
614 return BBoxd(mMin, mMax);
618 const PositionArrayT& mPositions;
619 const math::Mat4d& mInverseMat;
630template<
typename CompressionT,
typename Po
intDataGr
idT,
typename PositionArrayT,
typename Po
intIndexGr
idT>
631inline 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);
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());
735template <
typename CompressionT,
typename Po
intDataGr
idT,
typename ValueT>
736inline typename PointDataGridT::Ptr
739 const Metadata* positionDefaultValue)
744 tools::createPointIndexGrid<tools::PointIndexGrid>(pointList, xform);
745 return createPointDataGrid<CompressionT, PointDataGridT>(
746 *pointIndexGrid, pointList, xform, positionDefaultValue);
753template <
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);
790template <
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();
824template <
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);
856template <
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(
877 tbb::parallel_for(leafManager.leafRange(), convert);
884template<
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);
902 static const double maximumVoxelVolume(std::numeric_limits<float>::max());
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();
968 if (math::isApproxZero(volume)) {
970 if (math::isApproxZero(extents[1])) {
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)
996 if (!math::isIdentity(transform))
1002 matrix.
preScale(Vec3d(voxelSize) / math::getScale(matrix));
1003 newTransform = math::Transform::createLinearTransform(matrix);
1007 newTransform = math::Transform::createLinearTransform(voxelSize);
1015 mask->setTransform(newTransform);
1017 pointMaskOp.template addPoints<PositionWrapper, VecT>(positions);
1019 if (interrupter && util::wasInterrupted(interrupter))
break;
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);
Attribute array storage for string data using Descriptor Metadata.
Set of Attribute Arrays which tracks metadata about each array.
ValueT value
Definition GridBuilder.h:1290
Index filters primarily designed to be used with a FilterIndexIter.
Point attribute manipulation in a VDB Point Grid.
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
Point group manipulation in a VDB Point Grid.
Space-partitioning acceleration structure for points. Partitions the points into voxels to accelerate...
This tool produces a grid where every voxel that contains a point is active. It employs thread-local ...
SharedPtr< Grid > Ptr
Definition Grid.h:573
Definition Exceptions.h:59
Definition Exceptions.h:65
const Vec3T & max() const
Return a const reference to the maximum point of this bounding box.
Definition BBox.h:64
ElementType volume() const
Return the volume enclosed by this bounding box.
Definition BBox.h:100
Vec3T extents() const
Return the extents of this bounding box, i.e., the length along each axis.
Definition BBox.h:253
const Vec3T & min() const
Return a const reference to the minimum point of this bounding box.
Definition BBox.h:62
Signed (x, y, z) 32-bit integer coordinates.
Definition Coord.h:25
Vec3d asVec3d() const
Definition Coord.h:143
void preScale(const Vec3< T0 > &v)
Definition Mat4.h:736
Mat4 inverse(T tolerance=0) const
Definition Mat4.h:485
Vec3< T > sorted() const
Return a vector with the components of this in ascending order.
Definition Vec3.h:450
Definition AttributeArray.h:119
Write-able version of AttributeHandle.
Definition AttributeArray.h:907
Point-partitioner compatible STL vector attribute wrapper for convenience.
Definition PointConversion.h:205
size_t size() const
Definition PointConversion.h:215
void get(ValueType &value, size_t n, openvdb::Index m) const
Definition PointConversion.h:218
void get(ValueType &value, size_t n) const
Definition PointConversion.h:217
ValueType value_type
Definition PointConversion.h:208
PointAttributeVector(const std::vector< value_type > &data, const Index stride=1)
Definition PointConversion.h:210
void getPos(size_t n, ValueType &xyz) const
Definition PointConversion.h:216
ValueType PosType
Definition PointConversion.h:207
Typed class for storing attribute data.
Definition AttributeArray.h:545
This class manages a linear array of pointers to a given tree's leaf nodes, as well as optional auxil...
Definition LeafManager.h:85
const TreeType & tree() const
Return a const reference to tree associated with this manager.
Definition LeafManager.h:302
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition LeafManager.h:345
#define OPENVDB_LOG_DEBUG(message)
In debug builds only, log a debugging message of the form 'someVar << "text" << .....
Definition logging.h:266
Vec3< double > Vec3d
Definition Vec3.h:664
void void_t
Definition PointConversion.h:168
std::vector< Index > IndexArray
Definition PointMove.h:161
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
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
uint8_t GroupType
Definition AttributeSet.h:31
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
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
bool isGroup(const AttributeArray &array)
Definition AttributeGroup.h:63
TypedAttributeArray< GroupType, GroupCodec > GroupAttributeArray
Definition AttributeGroup.h:40
PointDataGridT::Ptr createPointDataGrid(const PointIndexGridT &pointIndexGrid, const PositionArrayT &positions, const math::Transform &xform, const Metadata *positionDefaultValue=nullptr)
Localises points with position into a PointDataGrid into two stages: allocation of the leaf attribute...
Definition PointConversion.h:632
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
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
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
std::string Name
Definition Name.h:17
Index32 Index
Definition Types.h:54
std::pair< Name, Name > NamePair
Definition AttributeArray.h:39
double Real
Definition Types.h:60
math::BBox< Vec3d > BBoxd
Definition Types.h:84
uint64_t Index64
Definition Types.h:53
Definition Exceptions.h:13
#define OPENVDB_THROW(exception, message)
Definition Exceptions.h:74
typename T::value_type Type
Definition PointConversion.h:172
Definition PointConversion.h:170
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:212