Skip to content

Commit

Permalink
Merge pull request #593 from danrbailey/variousvdbpointchanges
Browse files Browse the repository at this point in the history
OVDB-136: Various VDB Point Changes
  • Loading branch information
danrbailey committed Dec 21, 2019
2 parents 9a6fffa + 4355265 commit f077a14
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 242 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Version 7.0.1 - In Development
method evalActiveVoxelBoundingBox is called. The correct behavior is to
only return true if the grid contains any active values.

Improvements:
- Added GroupWriteHandle::setUnsafe() for faster performance when the group
array is known to be in-core and non-uniform.

Houdini:
- Platonic SOP is now verbified.

Expand Down
5 changes: 5 additions & 0 deletions doc/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Bug fixes:
method <TT>evalActiveVoxelBoundingBox</TT> is called. The correct behavior is to
only return true if the grid contains any active values.

@par
Improvements:
- Added GroupWriteHandle::setUnsafe() for faster performance when the group
array is known to be in-core and non-uniform.

@par
Houdini:
- Platonic SOP is now verbified.
Expand Down
22 changes: 10 additions & 12 deletions openvdb/points/AttributeArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,6 @@ class OPENVDB_API AttributeArray
/// Compact the existing array to become uniform if all values are identical
virtual bool compact() = 0;

/// @deprecated Previously this returned @c true if the array was compressed,
/// now it always returns @c false.
OPENVDB_DEPRECATED bool isCompressed() const { return false; }
/// @deprecated Previously this compressed the attribute array, now it does nothing.
// Windows does not allow base classes to be deprecated
#ifndef _MSC_VER
Expand Down Expand Up @@ -612,8 +609,9 @@ class TypedAttributeArray: public AttributeArray
/// @note This method is thread-safe.
AttributeArray::Ptr copy() const override;

/// Return an uncompressed copy of this attribute (will just return a copy if not compressed).
/// Return a copy of this attribute.
/// @note This method is thread-safe.
/// @deprecated In-memory compression no longer supported, use AttributeArray::copy() instead.
OPENVDB_DEPRECATED AttributeArray::Ptr copyUncompressed() const override;

/// Return a new attribute array of the given length @a n and @a stride with uniform value zero.
Expand Down Expand Up @@ -682,30 +680,30 @@ class TypedAttributeArray: public AttributeArray
/// Return the number of bytes of memory used by this attribute.
size_t memUsage() const override;

/// Return the value at index @a n (assumes uncompressed and in-core)
/// Return the value at index @a n (assumes in-core)
ValueType getUnsafe(Index n) const;
/// Return the value at index @a n
ValueType get(Index n) const;
/// Return the @a value at index @a n (assumes uncompressed and in-core)
/// Return the @a value at index @a n (assumes in-core)
template<typename T> void getUnsafe(Index n, T& value) const;
/// Return the @a value at index @a n
template<typename T> void get(Index n, T& value) const;

/// Non-member equivalent to getUnsafe() that static_casts array to this TypedAttributeArray
/// (assumes uncompressed and in-core)
/// (assumes in-core)
static ValueType getUnsafe(const AttributeArray* array, const Index n);

/// Set @a value at the given index @a n (assumes uncompressed and in-core)
/// Set @a value at the given index @a n (assumes in-core)
void setUnsafe(Index n, const ValueType& value);
/// Set @a value at the given index @a n
void set(Index n, const ValueType& value);
/// Set @a value at the given index @a n (assumes uncompressed and in-core)
/// Set @a value at the given index @a n (assumes in-core)
template<typename T> void setUnsafe(Index n, const T& value);
/// Set @a value at the given index @a n
template<typename T> void set(Index n, const T& value);

/// Non-member equivalent to setUnsafe() that static_casts array to this TypedAttributeArray
/// (assumes uncompressed and in-core)
/// (assumes in-core)
static void setUnsafe(AttributeArray* array, const Index n, const ValueType& value);

/// Set value at given index @a n from @a sourceIndex of another @a sourceArray
Expand Down Expand Up @@ -803,7 +801,7 @@ class TypedAttributeArray: public AttributeArray
/// Load data from memory-mapped file.
inline void doLoad() const;
/// Load data from memory-mapped file (unsafe as this function is not protected by a mutex).
/// @param compression if true, loading previously compressed data will re-compressed it
/// @param compression parameter no longer used
inline void doLoadUnsafe(const bool compression = true) const;
/// Compress in-core data assuming mutex is locked
inline bool compressUnsafe();
Expand Down Expand Up @@ -2029,7 +2027,7 @@ AttributeArray::AccessorBasePtr
TypedAttributeArray<ValueType_, Codec_>::getAccessor() const
{
// use the faster 'unsafe' get and set methods as attribute handles
// ensure data is uncompressed and in-core when constructed
// ensure data is in-core when constructed

return AccessorBasePtr(new AttributeArray::Accessor<ValueType_>(
&TypedAttributeArray<ValueType_, Codec_>::getUnsafe,
Expand Down
4 changes: 4 additions & 0 deletions openvdb/points/AttributeArrayString.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ using StringAttributeArray = TypedAttributeArray<StringIndexType, StringCodec<fa
class OPENVDB_API StringMetaInserter
{
public:
using UniquePtr = std::unique_ptr<StringMetaInserter>;

StringMetaInserter(MetaMap& metadata);

/// Insert the string into the metadata
Expand Down Expand Up @@ -110,6 +112,7 @@ class OPENVDB_API StringAttributeHandle
{
public:
using Ptr = std::shared_ptr<StringAttributeHandle>;//SharedPtr<StringAttributeHandle>;
using UniquePtr = std::unique_ptr<StringAttributeHandle>;

static Ptr create(const AttributeArray& array, const MetaMap& metadata, const bool preserveCompression = true);

Expand Down Expand Up @@ -142,6 +145,7 @@ class OPENVDB_API StringAttributeWriteHandle : public StringAttributeHandle
{
public:
using Ptr = std::shared_ptr<StringAttributeWriteHandle>;//SharedPtr<StringAttributeWriteHandle>;
using UniquePtr = std::unique_ptr<StringAttributeWriteHandle>;

static Ptr create(AttributeArray& array, const MetaMap& metadata, const bool expand = true);

Expand Down
11 changes: 11 additions & 0 deletions openvdb/points/AttributeGroup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ void GroupWriteHandle::set(Index n, bool on)
}


void GroupWriteHandle::setUnsafe(Index n, bool on)
{
const GroupType& value = mArray.getUnsafe(n);

GroupAttributeArray& array(const_cast<GroupAttributeArray&>(mArray));

if (on) array.setUnsafe(n, value | mBitMask);
else array.setUnsafe(n, value & ~mBitMask);
}


bool GroupWriteHandle::collapse(bool on)
{
using ValueT = GroupAttributeArray::ValueType;
Expand Down
5 changes: 5 additions & 0 deletions openvdb/points/AttributeGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class OPENVDB_API GroupHandle
{
public:
using Ptr = std::shared_ptr<GroupHandle>;
using UniquePtr = std::unique_ptr<GroupHandle>;

// Dummy class that distinguishes an offset from a bitmask on construction
struct BitMask { };
Expand Down Expand Up @@ -104,10 +105,14 @@ class OPENVDB_API GroupWriteHandle : public GroupHandle
{
public:
using Ptr = std::shared_ptr<GroupWriteHandle>;
using UniquePtr = std::unique_ptr<GroupWriteHandle>;

GroupWriteHandle(GroupAttributeArray& array, const GroupType& offset);

/// Set @a on at the given index @a n
void set(Index n, bool on);
/// Set @a on at the given index @a n (assumes in-core and non-uniform)
void setUnsafe(Index n, bool on);

/// @brief Set membership for the whole array and attempt to collapse
///
Expand Down
11 changes: 0 additions & 11 deletions openvdb/points/PointAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,17 +531,6 @@ inline void compactAttributes(PointDataTreeT& tree)
////////////////////////////////////////


template <typename PointDataTreeT>
OPENVDB_DEPRECATED inline void bloscCompressAttribute( PointDataTreeT&,
const Name&)
{
// in-memory compression is no longer supported
}


////////////////////////////////////////


} // namespace points
} // namespace OPENVDB_VERSION_NAME
} // namespace openvdb
Expand Down
63 changes: 0 additions & 63 deletions openvdb/points/PointConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -1033,69 +1033,6 @@ computeVoxelSize( const PositionWrapper& positions,
////////////////////////////////////////


// deprecated functions


template <typename PositionAttribute, typename PointDataGridT>
OPENVDB_DEPRECATED
inline void
convertPointDataGridPosition( PositionAttribute& positionAttribute,
const PointDataGridT& grid,
const std::vector<Index64>& pointOffsets,
const Index64 startOffset,
const std::vector<Name>& includeGroups,
const std::vector<Name>& excludeGroups,
const bool inCoreOnly = false)
{
auto leaf = grid.tree().cbeginLeaf();
if (!leaf) return;
MultiGroupFilter filter(includeGroups, excludeGroups, leaf->attributeSet());
convertPointDataGridPosition(positionAttribute, grid, pointOffsets, startOffset,
filter, inCoreOnly);
}


template <typename TypedAttribute, typename PointDataTreeT>
OPENVDB_DEPRECATED
inline void
convertPointDataGridAttribute( TypedAttribute& attribute,
const PointDataTreeT& tree,
const std::vector<Index64>& pointOffsets,
const Index64 startOffset,
const unsigned arrayIndex,
const Index stride,
const std::vector<Name>& includeGroups,
const std::vector<Name>& excludeGroups,
const bool inCoreOnly = false)
{
auto leaf = tree.cbeginLeaf();
if (!leaf) return;
MultiGroupFilter filter(includeGroups, excludeGroups, leaf->attributeSet());
convertPointDataGridAttribute(attribute, tree, pointOffsets, startOffset,
arrayIndex, stride, filter, inCoreOnly);
}


template <typename Group, typename PointDataTreeT>
OPENVDB_DEPRECATED
inline void
convertPointDataGridGroup( Group& group,
const PointDataTreeT& tree,
const std::vector<Index64>& pointOffsets,
const Index64 startOffset,
const AttributeSet::Descriptor::GroupIndex index,
const std::vector<Name>& includeGroups,
const std::vector<Name>& excludeGroups,
const bool inCoreOnly = false)
{
auto leaf = tree.cbeginLeaf();
if (!leaf) return;
MultiGroupFilter filter(includeGroups, excludeGroups, leaf->attributeSet());
convertPointDataGridGroup(group, tree, pointOffsets, startOffset,
index, filter, inCoreOnly);
}


} // namespace points
} // namespace OPENVDB_VERSION_NAME
} // namespace openvdb
Expand Down
118 changes: 0 additions & 118 deletions openvdb/points/PointCount.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,124 +200,6 @@ pointCountGrid( const PointDataGridT& points,
////////////////////////////////////////


// deprecated functions


template <typename PointDataTreeT>
OPENVDB_DEPRECATED
inline Index64 pointCount(const PointDataTreeT& tree, const bool inCoreOnly)
{
NullFilter filter;
return pointCount(tree, filter, inCoreOnly);
}


template <typename PointDataTreeT>
OPENVDB_DEPRECATED
inline Index64 activePointCount(const PointDataTreeT& tree, const bool inCoreOnly = true)
{
ActiveFilter filter;
return pointCount(tree, filter, inCoreOnly);
}


template <typename PointDataTreeT>
OPENVDB_DEPRECATED
inline Index64 inactivePointCount(const PointDataTreeT& tree, const bool inCoreOnly = true)
{
InactiveFilter filter;
return pointCount(tree, filter, inCoreOnly);
}


template <typename PointDataTreeT>
OPENVDB_DEPRECATED
inline Index64 groupPointCount(const PointDataTreeT& tree, const Name& name,
const bool inCoreOnly = true)
{
auto iter = tree.cbeginLeaf();
if (!iter || !iter->attributeSet().descriptor().hasGroup(name)) {
return Index64(0);
}
GroupFilter filter(name, iter->attributeSet());
return pointCount(tree, filter, inCoreOnly);
}


template <typename PointDataTreeT>
OPENVDB_DEPRECATED
inline Index64 activeGroupPointCount(const PointDataTreeT& tree, const Name& name,
const bool inCoreOnly = true)
{
auto iter = tree.cbeginLeaf();
if (!iter || !iter->attributeSet().descriptor().hasGroup(name)) {
return Index64(0);
}
BinaryFilter<GroupFilter, ActiveFilter> filter(GroupFilter(name, iter->attributeSet()), ActiveFilter());
return pointCount(tree, filter, inCoreOnly);
}


template <typename PointDataTreeT>
OPENVDB_DEPRECATED
inline Index64 inactiveGroupPointCount(const PointDataTreeT& tree, const Name& name,
const bool inCoreOnly = true)
{
auto iter = tree.cbeginLeaf();
if (!iter || !iter->attributeSet().descriptor().hasGroup(name)) {
return Index64(0);
}
BinaryFilter<GroupFilter, InactiveFilter> filter(GroupFilter(name, iter->attributeSet()), InactiveFilter());
return pointCount(tree, filter, inCoreOnly);
}


template <typename PointDataTreeT>
OPENVDB_DEPRECATED
inline Index64 getPointOffsets(std::vector<Index64>& offsets, const PointDataTreeT& tree,
const std::vector<Name>& includeGroups,
const std::vector<Name>& excludeGroups,
const bool inCoreOnly = false)
{
MultiGroupFilter filter(includeGroups, excludeGroups, tree.cbeginLeaf()->attributeSet());
return pointOffsets(offsets, tree, filter, inCoreOnly);
}


template <typename PointDataGridT,
typename GridT = typename PointDataGridT::template ValueConverter<Int32>::Type>
OPENVDB_DEPRECATED
inline typename GridT::Ptr
pointCountGrid(const PointDataGridT& grid,
const std::vector<Name>& includeGroups,
const std::vector<Name>& excludeGroups)
{
auto leaf = grid.tree().cbeginLeaf();
if (!leaf) return GridT::create(0);
MultiGroupFilter filter(includeGroups, excludeGroups, leaf->attributeSet());
return pointCountGrid(grid, filter);
}


template <typename PointDataGridT,
typename GridT = typename PointDataGridT::template ValueConverter<Int32>::Type>
OPENVDB_DEPRECATED
inline typename GridT::Ptr
pointCountGrid(const PointDataGridT& grid,
const openvdb::math::Transform& transform,
const std::vector<Name>& includeGroups,
const std::vector<Name>& excludeGroups)
{
auto leaf = grid.tree().cbeginLeaf();
if (!leaf) return GridT::create(0);
MultiGroupFilter filter(includeGroups, excludeGroups, leaf->attributeSet());
return pointCountGrid(grid, transform, filter);
}


////////////////////////////////////////


} // namespace points
} // namespace OPENVDB_VERSION_NAME
} // namespace openvdb
Expand Down

0 comments on commit f077a14

Please sign in to comment.