9#ifndef OPENVDB_POINTS_POINT_CONVERSION_IMPL_HAS_BEEN_INCLUDED 
   10#define OPENVDB_POINTS_POINT_CONVERSION_IMPL_HAS_BEEN_INCLUDED 
   19namespace point_conversion_internal {
 
   23template <
typename T> 
struct ConversionTraits
 
   25    using Handle = AttributeHandle<T, UnknownCodec>;
 
   26    using WriteHandle = AttributeWriteHandle<T, UnknownCodec>;
 
   27    static T zero() { 
return zeroVal<T>(); }
 
   28    template <
typename LeafT>
 
   29    static std::unique_ptr<Handle> handleFromLeaf(
const LeafT& leaf, 
const Index index) {
 
   31        return std::make_unique<Handle>(array);
 
   33    template <
typename LeafT>
 
   34    static std::unique_ptr<WriteHandle> writeHandleFromLeaf(LeafT& leaf, 
const Index index) {
 
   36        return std::make_unique<WriteHandle>(array);
 
   39template <> 
struct ConversionTraits<openvdb::
Name>
 
   41    using Handle = StringAttributeHandle;
 
   42    using WriteHandle = StringAttributeWriteHandle;
 
   44    template <
typename LeafT>
 
   45    static std::unique_ptr<Handle> handleFromLeaf(
const LeafT& leaf, 
const Index index) {
 
   47        const AttributeSet::Descriptor& descriptor = leaf.attributeSet().descriptor();
 
   48        return std::make_unique<Handle>(array, descriptor.getMetadata());
 
   50    template <
typename LeafT>
 
   51    static std::unique_ptr<WriteHandle> writeHandleFromLeaf(LeafT& leaf, 
const Index index) {
 
   53        const AttributeSet::Descriptor& descriptor = leaf.attributeSet().descriptor();
 
   54        return std::make_unique<WriteHandle>(array, descriptor.getMetadata());
 
   58template<   
typename PointDataTreeType,
 
   59            typename PointIndexTreeType,
 
   60            typename AttributeListType>
 
   61struct PopulateAttributeOp {
 
   63    using LeafManagerT          = 
typename tree::LeafManager<PointDataTreeType>;
 
   64    using LeafRangeT            = 
typename LeafManagerT::LeafRange;
 
   65    using PointIndexLeafNode    = 
typename PointIndexTreeType::LeafNodeType;
 
   66    using IndexArray            = 
typename PointIndexLeafNode::IndexArray;
 
   67    using ValueType             = 
typename AttributeListType::value_type;
 
   68    using HandleT               = 
typename ConversionTraits<ValueType>::WriteHandle;
 
   70    PopulateAttributeOp(
const PointIndexTreeType& pointIndexTree,
 
   71                        const AttributeListType& data,
 
   73                        const Index stride = 1)
 
   74        : mPointIndexTree(pointIndexTree)
 
   79    void operator()(
const typename LeafManagerT::LeafRange& range)
 const {
 
   81        for (
auto leaf = range.begin(); leaf; ++leaf) {
 
   85            const PointIndexLeafNode* pointIndexLeaf =
 
   86                mPointIndexTree.probeConstLeaf(leaf->origin());
 
   88            if (!pointIndexLeaf)    
continue;
 
   90            auto attributeWriteHandle =
 
   91                ConversionTraits<ValueType>::writeHandleFromLeaf(*leaf, 
static_cast<Index>(mIndex));
 
   95            const IndexArray& indices = pointIndexLeaf->indices();
 
   97            for (
const Index64 leafIndex: indices)
 
  100                for (Index i = 0; i < mStride; i++) {
 
  101                    mData.get(value, leafIndex, i);
 
  102                    attributeWriteHandle->set(
static_cast<Index>(index), i, value);
 
  109            attributeWriteHandle->compact();
 
  115    const PointIndexTreeType&   mPointIndexTree;
 
  116    const AttributeListType&    mData;
 
  121template<
typename Po
intDataTreeType, 
typename Attribute, 
typename FilterT>
 
  122struct ConvertPointDataGridPositionOp {
 
  124    using LeafNode      = 
typename PointDataTreeType::LeafNodeType;
 
  125    using ValueType     = 
typename Attribute::ValueType;
 
  126    using HandleT       = 
typename Attribute::Handle;
 
  127    using SourceHandleT = AttributeHandle<ValueType>;
 
  128    using LeafManagerT  = 
typename tree::LeafManager<const PointDataTreeType>;
 
  129    using LeafRangeT    = 
typename LeafManagerT::LeafRange;
 
  131    ConvertPointDataGridPositionOp( Attribute& attribute,
 
  132                                    const std::vector<Index64>& pointOffsets,
 
  133                                    const Index64 startOffset,
 
  134                                    const math::Transform& transform,
 
  136                                    const FilterT& filter,
 
  137                                    const bool inCoreOnly)
 
  138        : mAttribute(attribute)
 
  140        , mStartOffset(startOffset)
 
  141        , mTransform(transform)
 
  144        , mInCoreOnly(inCoreOnly)
 
  147        static_assert(VecTraits<ValueType>::Size == 3 &&
 
  148                      std::is_floating_point<typename ValueType::ValueType>::value,
 
  149                      "ValueType is not Vec3f");
 
  152    template <
typename IterT>
 
  153    void convert(IterT& iter, HandleT& targetHandle,
 
  154        SourceHandleT& sourceHandle, Index64& offset)
 const 
  156        for (; iter; ++iter) {
 
  157            const Vec3d xyz = iter.getCoord().asVec3d();
 
  158            const Vec3d pos = sourceHandle.get(*iter);
 
  159            targetHandle.set(
static_cast<Index>(offset++), 0,
 
  160                mTransform.indexToWorld(pos + xyz));
 
  164    void operator()(
const LeafRangeT& range)
 const 
  166        HandleT pHandle(mAttribute);
 
  168        for (
auto leaf = range.begin(); leaf; ++leaf) {
 
  172            if (mInCoreOnly && leaf->buffer().isOutOfCore())    
continue;
 
  176            if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
 
  178            auto handle = SourceHandleT::create(leaf->constAttributeArray(mIndex));
 
  180            if (mFilter.state() == index::ALL) {
 
  181                auto iter = leaf->beginIndexOn();
 
  182                convert(iter, pHandle, *handle, offset);
 
  185                auto iter = leaf->beginIndexOn(mFilter);
 
  186                convert(iter, pHandle, *handle, offset);
 
  193    Attribute&                              mAttribute;
 
  194    const std::vector<Index64>&             mPointOffsets;
 
  196    const math::Transform&                  mTransform;
 
  198    const FilterT&                          mFilter;
 
  199    const bool                              mInCoreOnly;
 
  203template<
typename Po
intDataTreeType, 
typename Attribute, 
typename FilterT>
 
  204struct ConvertPointDataGridAttributeOp {
 
  206    using LeafNode      = 
typename PointDataTreeType::LeafNodeType;
 
  207    using ValueType     = 
typename Attribute::ValueType;
 
  208    using HandleT       = 
typename Attribute::Handle;
 
  209    using SourceHandleT = 
typename ConversionTraits<ValueType>::Handle;
 
  210    using LeafManagerT  = 
typename tree::LeafManager<const PointDataTreeType>;
 
  211    using LeafRangeT    = 
typename LeafManagerT::LeafRange;
 
  213    ConvertPointDataGridAttributeOp(Attribute& attribute,
 
  214                                    const std::vector<Index64>& pointOffsets,
 
  215                                    const Index64 startOffset,
 
  218                                    const FilterT& filter,
 
  219                                    const bool inCoreOnly)
 
  220        : mAttribute(attribute)
 
  222        , mStartOffset(startOffset)
 
  226        , mInCoreOnly(inCoreOnly) { }
 
  228    template <
typename IterT>
 
  229    void convert(IterT& iter, HandleT& targetHandle,
 
  230        SourceHandleT& sourceHandle, Index64& offset)
 const 
  232        if (sourceHandle.isUniform()) {
 
  233            const ValueType uniformValue(sourceHandle.get(0));
 
  234            for (; iter; ++iter) {
 
  235                for (Index i = 0; i < mStride; i++) {
 
  236                    targetHandle.set(
static_cast<Index>(offset), i, uniformValue);
 
  242            for (; iter; ++iter) {
 
  243                for (Index i = 0; i < mStride; i++) {
 
  244                    targetHandle.set(
static_cast<Index>(offset), i,
 
  245                        sourceHandle.get(*iter, i));
 
  252    void operator()(
const LeafRangeT& range)
 const 
  254        HandleT pHandle(mAttribute);
 
  256        for (
auto leaf = range.begin(); leaf; ++leaf) {
 
  260            if (mInCoreOnly && leaf->buffer().isOutOfCore())    
continue;
 
  264            if (leaf.pos() > 0) offset += mPointOffsets[leaf.pos() - 1];
 
  266            auto handle = ConversionTraits<ValueType>::handleFromLeaf(
 
  267                *leaf, 
static_cast<Index>(mIndex));
 
  269            if (mFilter.state() == index::ALL) {
 
  270                auto iter = leaf->beginIndexOn();
 
  271                convert(iter, pHandle, *handle, offset);
 
  273                auto iter = leaf->beginIndexOn(mFilter);
 
  274                convert(iter, pHandle, *handle, offset);
 
  281    Attribute&                              mAttribute;
 
  282    const std::vector<Index64>&             mPointOffsets;
 
  286    const FilterT&                          mFilter;
 
  287    const bool                              mInCoreOnly;
 
  290template<
typename Po
intDataTreeType, 
typename Group, 
typename FilterT>
 
  291struct ConvertPointDataGridGroupOp {
 
  293    using LeafNode      = 
typename PointDataTreeType::LeafNodeType;
 
  294    using GroupIndex    = AttributeSet::Descriptor::GroupIndex;
 
  295    using LeafManagerT  = 
typename tree::LeafManager<const PointDataTreeType>;
 
  296    using LeafRangeT    = 
typename LeafManagerT::LeafRange;
 
  298    ConvertPointDataGridGroupOp(Group& group,
 
  299                                const std::vector<Index64>& pointOffsets,
 
  300                                const Index64 startOffset,
 
  301                                const AttributeSet::Descriptor::GroupIndex index,
 
  302                                const FilterT& filter,
 
  303                                const bool inCoreOnly)
 
  306        , mStartOffset(startOffset)
 
  309        , mInCoreOnly(inCoreOnly) { }
 
  311    template <
typename IterT>
 
  312    void convert(IterT& iter, 
const GroupAttributeArray& groupArray, Index64& offset)
 const 
  314        const auto bitmask = 
static_cast<GroupType>(1 << mIndex.second);
 
  316        if (groupArray.isUniform()) {
 
  317            if (groupArray.get(0) & bitmask) {
 
  318                for (; iter; ++iter) {
 
  319                    mGroup.setOffsetOn(
static_cast<Index>(offset));
 
  325            for (; iter; ++iter) {
 
  326                if (groupArray.get(*iter) & bitmask) {
 
  327                    mGroup.setOffsetOn(
static_cast<Index>(offset));
 
  334    void operator()(
const LeafRangeT& range)
 const 
  336        for (
auto leaf = range.begin(); leaf; ++leaf) {
 
  340            if (mInCoreOnly && leaf->buffer().isOutOfCore())    
continue;
 
  344            if (leaf.pos() > 0)     offset += mPointOffsets[leaf.pos() - 1];
 
  346            const AttributeArray& array = leaf->constAttributeArray(mIndex.first);
 
  350            if (mFilter.state() == index::ALL) {
 
  351                auto iter = leaf->beginIndexOn();
 
  352                convert(iter, groupArray, offset);
 
  355                auto iter = leaf->beginIndexOn(mFilter);
 
  356                convert(iter, groupArray, offset);
 
  364    const std::vector<Index64>&             mPointOffsets;
 
  366    const GroupIndex                        mIndex;
 
  367    const FilterT&                          mFilter;
 
  368    const bool                              mInCoreOnly;
 
  371template<
typename PositionArrayT, 
typename VecT = Vec3R>
 
  372struct CalculatePositionBounds
 
  374    CalculatePositionBounds(
const PositionArrayT& positions,
 
  375                            const math::Mat4d& inverse)
 
  376        : mPositions(positions)
 
  377        , mInverseMat(inverse)
 
  378        , mMin(std::numeric_limits<
Real>::
max())
 
  379        , mMax(-std::numeric_limits<
Real>::
max()) {}
 
  381    CalculatePositionBounds(
const CalculatePositionBounds& other, tbb::split)
 
  382        : mPositions(other.mPositions)
 
  383        , mInverseMat(other.mInverseMat)
 
  384        , mMin(std::numeric_limits<
Real>::
max())
 
  385        , mMax(-std::numeric_limits<
Real>::
max()) {}
 
  387    void operator()(
const tbb::blocked_range<size_t>& range) {
 
  389        for (
size_t n = range.begin(), N = range.end(); n != N; ++n) {
 
  390            mPositions.getPos(n, pos);
 
  391            pos = mInverseMat.transform(pos);
 
  392            mMin = math::minComponent(mMin, pos);
 
  393            mMax = math::maxComponent(mMax, pos);
 
  397    void join(
const CalculatePositionBounds& other) {
 
  398        mMin = math::minComponent(mMin, other.mMin);
 
  399        mMax = math::maxComponent(mMax, other.mMax);
 
  402    BBoxd getBoundingBox()
 const {
 
  403        return BBoxd(mMin, mMax);
 
  407    const PositionArrayT& mPositions;
 
  408    const math::Mat4d&    mInverseMat;
 
  419template<
typename CompressionT, 
typename Po
intDataGr
idT, 
typename PositionArrayT, 
typename Po
intIndexGr
idT>
 
  420inline typename PointDataGridT::Ptr
 
  422                    const PositionArrayT& positions,
 
  424                    const Metadata* positionDefaultValue)
 
  426    using PointDataTreeT        = 
typename PointDataGridT::TreeType;
 
  427    using LeafT                 = 
typename PointDataTreeT::LeafNodeType;
 
  428    using PointIndexLeafT       = 
typename PointIndexGridT::TreeType::LeafNodeType;
 
  429    using PointIndexT           = 
typename PointIndexLeafT::ValueType;
 
  433    const NamePair positionType = PositionAttributeT::attributeType();
 
  437    const auto& pointIndexTree = pointIndexGrid.tree();
 
  438    typename PointDataTreeT::Ptr treePtr(
new PointDataTreeT(pointIndexTree));
 
  446    if (positionDefaultValue)   descriptor->setDefaultValue(
"P", *positionDefaultValue);
 
  450    const size_t positionIndex = descriptor->find(
"P");
 
  459    LeafManagerT leafManager(*treePtr);
 
  461        [&](LeafT& leaf, 
size_t ) {
 
  465            const auto* pointIndexLeaf = pointIndexTree.probeConstLeaf(leaf.origin());
 
  471            leaf.initializeAttributes(descriptor, 
pointCount, &lock);
 
  476                leaf.attributeArray(positionIndex));
 
  481                *begin = 
static_cast<PointIndexT*
>(
nullptr),
 
  482                *end = 
static_cast<PointIndexT*
>(
nullptr);
 
  486            for (
auto iter = pointIndexLeaf->cbeginValueOn(); iter; ++iter) {
 
  490                const Coord& ijk = iter.getCoord();
 
  495                pointIndexLeaf->getIndices(ijk, begin, end);
 
  497                while (begin < end) {
 
  499                    typename PositionArrayT::value_type positionWorldSpace;
 
  500                    positions.getPos(*begin, positionWorldSpace);
 
  505                    const Vec3f positionVoxelSpace(positionIndexSpace - positionCellCenter);
 
  507                    attributeWriteHandle->set(
index++, positionVoxelSpace);
 
  515    auto grid = PointDataGridT::create(treePtr);
 
  516    grid->setTransform(xform.
copy());
 
 
  524template <
typename CompressionT, 
typename Po
intDataGr
idT, 
typename ValueT>
 
  525inline typename PointDataGridT::Ptr
 
  528                    const Metadata* positionDefaultValue)
 
  535        *pointIndexGrid, pointList, xform, positionDefaultValue);
 
 
  542template <
typename Po
intDataTreeT, 
typename Po
intIndexTreeT, 
typename Po
intArrayT>
 
  546    const bool insertMetadata)
 
  548    using point_conversion_internal::PopulateAttributeOp;
 
  549    using ValueType = 
typename PointArrayT::value_type;
 
  551    auto iter = 
tree.cbeginLeaf();
 
  555    const size_t index = iter->attributeSet().find(attributeName);
 
  561    if (insertMetadata) {
 
  562        point_attribute_internal::MetadataStorage<PointDataTreeT, ValueType>::add(
tree, data);
 
  569    PopulateAttributeOp<PointDataTreeT,
 
  571                        PointArrayT> populate(pointIndexTree, data, 
index, stride);
 
  572    tbb::parallel_for(leafManager.
leafRange(), populate);
 
 
  579template <
typename PositionAttribute, 
typename Po
intDataGr
idT, 
typename FilterT>
 
  582                                const PointDataGridT& grid,
 
  585                                const FilterT& filter,
 
  586                                const bool inCoreOnly)
 
  588    using TreeType      = 
typename PointDataGridT::TreeType;
 
  591    using point_conversion_internal::ConvertPointDataGridPositionOp;
 
  593    const TreeType& 
tree = grid.tree();
 
  594    auto iter = 
tree.cbeginLeaf();
 
  598    const size_t positionIndex = iter->attributeSet().find(
"P");
 
  600    positionAttribute.expand();
 
  601    LeafManagerT leafManager(
tree);
 
  602    ConvertPointDataGridPositionOp<TreeType, PositionAttribute, FilterT> convert(
 
  603                    positionAttribute, 
pointOffsets, startOffset, grid.transform(), positionIndex,
 
  605    tbb::parallel_for(leafManager.leafRange(), convert);
 
  606    positionAttribute.compact();
 
 
  613template <
typename TypedAttribute, 
typename Po
intDataTreeT, 
typename FilterT>
 
  616                                const PointDataTreeT& 
tree,
 
  619                                const unsigned arrayIndex,
 
  621                                const FilterT& filter,
 
  622                                const bool inCoreOnly)
 
  626    using point_conversion_internal::ConvertPointDataGridAttributeOp;
 
  628    auto iter = 
tree.cbeginLeaf();
 
  633    LeafManagerT leafManager(
tree);
 
  634    ConvertPointDataGridAttributeOp<PointDataTreeT, TypedAttribute, FilterT> convert(
 
  635                        attribute, 
pointOffsets, startOffset, arrayIndex, stride,
 
  637        tbb::parallel_for(leafManager.leafRange(), convert);
 
 
  645template <
typename Group, 
typename Po
intDataTreeT, 
typename FilterT>
 
  648                            const PointDataTreeT& 
tree,
 
  652                            const FilterT& filter,
 
  653                            const bool inCoreOnly)
 
  657    using point_conversion_internal::ConvertPointDataGridGroupOp;
 
  659    auto iter = 
tree.cbeginLeaf();
 
  662    LeafManagerT leafManager(
tree);
 
  663    ConvertPointDataGridGroupOp<PointDataTreeT, Group, FilterT> convert(
 
  666    tbb::parallel_for(leafManager.leafRange(), convert);
 
 
  673template<
typename PositionWrapper, 
typename InterrupterT, 
typename VecT>
 
  676                   const uint32_t pointsPerVoxel,
 
  678                   const Index decimalPlaces,
 
  679                   InterrupterT* 
const interrupter)
 
  681    using namespace point_conversion_internal;
 
  685        static bool voxelSizeFromVolume(
const double volume,
 
  686                                        const size_t estimatedVoxelCount,
 
  690            static const double minimumVoxelVolume(3e-15);
 
  691            static const double maximumVoxelVolume(std::numeric_limits<float>::max());
 
  693            double voxelVolume = volume / 
static_cast<double>(estimatedVoxelCount);
 
  696            if (voxelVolume < minimumVoxelVolume) {
 
  697                voxelVolume = minimumVoxelVolume;
 
  700            else if (voxelVolume > maximumVoxelVolume) {
 
  701                voxelVolume = maximumVoxelVolume;
 
  705            voxelSize = 
static_cast<float>(
math::Pow(voxelVolume, 1.0/3.0));
 
  709        static float truncate(
const float voxelSize, 
Index decPlaces)
 
  711            float truncatedVoxelSize = voxelSize;
 
  714            for (
int i = decPlaces; i < 11; i++) {
 
  715                truncatedVoxelSize = 
static_cast<float>(
math::Truncate(
double(voxelSize), i));
 
  716                if (truncatedVoxelSize != 0.0f)     
break;
 
  719            return truncatedVoxelSize;
 
  727    float voxelSize(0.1f);
 
  729    const size_t numPoints = positions.size();
 
  733    if (numPoints <= 1) 
return voxelSize;
 
  735    size_t targetVoxelCount(numPoints / 
size_t(pointsPerVoxel));
 
  736    if (targetVoxelCount == 0)   targetVoxelCount++;
 
  741    inverseTransform = 
math::unit(inverseTransform);
 
  743    tbb::blocked_range<size_t> range(0, numPoints);
 
  744    CalculatePositionBounds<PositionWrapper, VecT> calculateBounds(positions, inverseTransform);
 
  745    tbb::parallel_reduce(range, calculateBounds);
 
  747    BBoxd bbox = calculateBounds.getBoundingBox();
 
  751    if (bbox.
min() == bbox.
max())  
return voxelSize;
 
  753    double volume = bbox.
volume();
 
  761            volume = extents[0]*extents[0]*extents[0];
 
  765            volume = extents[0]*extents[1]*extents[1];
 
  769    double previousVolume = volume;
 
  771    if (!Local::voxelSizeFromVolume(volume, targetVoxelCount, voxelSize)) {
 
  776    size_t previousVoxelCount(0);
 
  777    size_t voxelCount(1);
 
  779    if (interrupter) interrupter->start(
"Computing voxel size");
 
  781    while (voxelCount > previousVoxelCount)
 
  804        mask->setTransform(newTransform);
 
  806        pointMaskOp.template addPoints<PositionWrapper, VecT>(positions);
 
  810        previousVoxelCount = voxelCount;
 
  811        voxelCount = mask->activeVoxelCount();
 
  812        volume = 
math::Pow3(voxelSize) * 
static_cast<float>(voxelCount);
 
  816        if (volume >= previousVolume) 
break;
 
  817        previousVolume = volume;
 
  819        const float previousVoxelSize = voxelSize;
 
  823        if (!Local::voxelSizeFromVolume(volume, targetVoxelCount, voxelSize)) {
 
  824            voxelSize = previousVoxelSize;
 
  831        if (voxelSize / previousVoxelSize > 0.9f) 
break;
 
  834    if (interrupter) interrupter->end();
 
  838    return Local::truncate(voxelSize, decimalPlaces);
 
 
#define OPENVDB_ASSERT(X)
Definition Assert.h:41
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:26
Vec3d asVec3d() const
Definition Coord.h:144
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:451
Vec3< T > reversed() const
Return the vector (z, y, x)
Definition Vec3.h:461
Definition AttributeArray.h:120
Util::GroupIndex GroupIndex
Definition AttributeSet.h:317
static Ptr create(const NamePair &)
Create a new descriptor from a position attribute type and assumes "P" (for convenience).
@ INVALID_POS
Definition AttributeSet.h:42
static Ptr create(AttributeArray &array, const bool expand=true)
Definition AttributeArray.h:2104
Point-partitioner compatible STL vector attribute wrapper for convenience.
Definition PointConversion.h:41
Typed class for storing attribute data.
Definition AttributeArray.h:512
This class manages a linear array of pointers to a given tree's leaf nodes, as well as optional auxil...
Definition LeafManager.h:86
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition LeafManager.h:346
#define OPENVDB_LOG_DEBUG(message)
In debug builds only, log a debugging message of the form 'someVar << "text" << .....
Definition logging.h:266
@ AttributeArray
Definition NanoVDB.h:418
bool isApproxZero(const Type &x)
Return true if x is equal to zero to within the default floating-point comparison tolerance.
Definition Math.h:349
Type Pow(Type x, int n)
Return xn.
Definition Math.h:561
Vec3< double > Vec3d
Definition Vec3.h:665
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:648
Mat4< double > Mat4d
Definition Mat4.h:1355
Type Truncate(Type x, unsigned int digits)
Return x truncated to the given number of decimal digits.
Definition Math.h:870
Type Pow3(Type x)
Return x3.
Definition Math.h:552
bool isIdentity(const MatType &m)
Determine if a matrix is an identity matrix.
Definition Mat.h:860
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:633
Definition IndexIterator.h:35
std::vector< Index > IndexArray
Definition PointMoveImpl.h:88
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 PointConversionImpl.h:647
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 PointCountImpl.h:52
uint8_t GroupType
Definition AttributeSet.h:32
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 PointConversionImpl.h:675
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 PointCountImpl.h:18
bool isGroup(const AttributeArray &array)
Definition AttributeGroup.h:64
TypedAttributeArray< GroupType, GroupCodec > GroupAttributeArray
Definition AttributeGroup.h:41
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 PointConversionImpl.h:421
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 PointConversionImpl.h:615
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 PointConversionImpl.h:581
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 PointConversionImpl.h:544
Definition PointDataGrid.h:170
bool wasInterrupted(T *i, int percent=-1)
Definition NullInterrupter.h:49
std::string Name
Definition Name.h:19
Index32 Index
Definition Types.h:54
std::pair< Name, Name > NamePair
Definition AttributeArray.h:40
math::Vec3< float > Vec3f
Definition Types.h:74
double Real
Definition Types.h:60
math::BBox< Vec3d > BBoxd
Definition Types.h:84
GridType::Ptr createGrid(const typename GridType::ValueType &background)
Create a new grid of type GridType with a given background value.
Definition Grid.h:1757
uint64_t Index64
Definition Types.h:53
Definition Exceptions.h:13
#define OPENVDB_THROW(exception, message)
Definition Exceptions.h:74
#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:218