Skip to content

Commit

Permalink
Merge pull request AcademySoftwareFoundation#1931 from danrbailey/roo…
Browse files Browse the repository at this point in the history
…t_api_changes

RootNode API Changes
  • Loading branch information
danrbailey authored Oct 28, 2024
2 parents 5201109 + 02abba7 commit 60a9314
Show file tree
Hide file tree
Showing 16 changed files with 662 additions and 469 deletions.
1 change: 0 additions & 1 deletion ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ set -x
# - always enabled the python tests with OPENVDB_BUILD_PYTHON_UNITTESTS if the python module is in use,
# regardless of the 'test' component being enabled or not (see the OPENVDB_BUILD_PYTHON_UNITTESTS option).
cmake \
-DOPENVDB_USE_DEPRECATED_ABI_9=ON \
-DOPENVDB_USE_DEPRECATED_ABI_10=ON \
-DOPENVDB_BUILD_VDB_PRINT=ON \
-DOPENVDB_BUILD_VDB_LOD=ON \
Expand Down
9 changes: 2 additions & 7 deletions openvdb/openvdb/openvdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,13 @@
#include <blosc.h>
#endif

#if OPENVDB_ABI_VERSION_NUMBER <= 8
#error ABI <= 8 is no longer supported
#if OPENVDB_ABI_VERSION_NUMBER <= 9
#error ABI <= 9 is no longer supported
#endif

// If using an OPENVDB_ABI_VERSION_NUMBER that has been deprecated, issue an
// error directive. This can be optionally suppressed by defining:
// OPENVDB_USE_DEPRECATED_ABI_<VERSION>=ON.
#ifndef OPENVDB_USE_DEPRECATED_ABI_9
#if OPENVDB_ABI_VERSION_NUMBER == 9
#error ABI = 9 is deprecated, CMake option OPENVDB_USE_DEPRECATED_ABI_9 suppresses this error
#endif
#endif
#ifndef OPENVDB_USE_DEPRECATED_ABI_10
#if OPENVDB_ABI_VERSION_NUMBER == 10
#error ABI = 10 is deprecated, CMake option OPENVDB_USE_DEPRECATED_ABI_10 suppresses this error
Expand Down
127 changes: 1 addition & 126 deletions openvdb/openvdb/points/AttributeArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,6 @@ class OPENVDB_API AttributeArray
/// Return a copy of this attribute.
virtual AttributeArray::Ptr copy() const = 0;

#if OPENVDB_ABI_VERSION_NUMBER < 10
/// Return a copy of this attribute.
#ifndef _MSC_VER
OPENVDB_DEPRECATED_MESSAGE("In-memory compression no longer supported, use AttributeArray::copy() instead")
#endif
virtual AttributeArray::Ptr copyUncompressed() const = 0;
#endif

/// Return the number of elements in this array.
/// @note This does not count each data element in a strided array
virtual Index size() const = 0;
Expand Down Expand Up @@ -197,13 +189,11 @@ class OPENVDB_API AttributeArray
/// Return the number of bytes of memory used by this attribute.
virtual size_t memUsage() const = 0;

#if OPENVDB_ABI_VERSION_NUMBER >= 10
/// Return the number of bytes of memory used by this attribute array once it
/// has been deserialized (this may be different to memUsage() if delay-loading
/// is in use). Note that this method does NOT consider the fact that a
/// uniform attribute could be expanded and only deals with delay-loading.
virtual size_t memUsageIfLoaded() const = 0;
#endif

/// Create a new attribute array of the given (registered) type, length and stride.
/// @details If @a lock is non-null, the AttributeArray registry mutex
Expand All @@ -228,15 +218,6 @@ class OPENVDB_API AttributeArray
template<typename ValueType>
bool hasValueType() const { return this->type().first == typeNameAsString<ValueType>(); }

#if OPENVDB_ABI_VERSION_NUMBER < 10
/// @brief Set value at given index @a n from @a sourceIndex of another @a sourceArray.
// Windows does not allow base classes to be easily deprecated.
#ifndef _MSC_VER
OPENVDB_DEPRECATED_MESSAGE("Use copyValues() with source-target index pairs")
#endif
virtual void set(const Index n, const AttributeArray& sourceArray, const Index sourceIndex) = 0;
#endif

/// @brief Copy values into this array from a source array to a target array
/// as referenced by an iterator.
/// @details Iterators must adhere to the ForwardIterator interface described
Expand Down Expand Up @@ -278,19 +259,6 @@ class OPENVDB_API AttributeArray
/// Compact the existing array to become uniform if all values are identical
virtual bool compact() = 0;

#if OPENVDB_ABI_VERSION_NUMBER < 10
// Windows does not allow base classes to be deprecated
#ifndef _MSC_VER
OPENVDB_DEPRECATED_MESSAGE("Previously this compressed the attribute array, now it does nothing")
#endif
virtual bool compress() = 0;
// Windows does not allow base classes to be deprecated
#ifndef _MSC_VER
OPENVDB_DEPRECATED_MESSAGE("Previously this uncompressed the attribute array, now it does nothing")
#endif
virtual bool decompress() = 0;
#endif

/// @brief Specify whether this attribute should be hidden (e.g., from UI or iterators).
/// @details This is useful if the attribute is used for blind data or as scratch space
/// for a calculation.
Expand Down Expand Up @@ -359,10 +327,8 @@ class OPENVDB_API AttributeArray
bool operator==(const AttributeArray& other) const;
bool operator!=(const AttributeArray& other) const { return !this->operator==(other); }

#if OPENVDB_ABI_VERSION_NUMBER >= 9
/// Indirect virtual function to retrieve the data buffer cast to a char byte array
const char* constDataAsByteArray() const { return this->dataAsByteArray(); }
#endif

private:
friend class ::TestAttributeArray;
Expand Down Expand Up @@ -565,11 +531,6 @@ class TypedAttributeArray final: public AttributeArray
/// while being copied using this copy-constructor in another thread.
/// It is not thread-safe for write.
TypedAttributeArray(const TypedAttributeArray&);
#if OPENVDB_ABI_VERSION_NUMBER < 10
/// Deep copy constructor.
OPENVDB_DEPRECATED_MESSAGE("Use copy-constructor without unused bool parameter")
TypedAttributeArray(const TypedAttributeArray&, bool /*unused*/);
#endif

/// Deep copy assignment operator.
/// @note this operator is thread-safe.
Expand All @@ -585,13 +546,6 @@ class TypedAttributeArray final: public AttributeArray
/// @note This method is thread-safe.
AttributeArray::Ptr copy() const override;

#if OPENVDB_ABI_VERSION_NUMBER < 10
/// Return a copy of this attribute.
/// @note This method is thread-safe.
OPENVDB_DEPRECATED_MESSAGE("In-memory compression no longer supported, use AttributeArray::copy() instead")
AttributeArray::Ptr copyUncompressed() const override;
#endif

/// Return a new attribute array of the given length @a n and @a stride with uniform value zero.
static Ptr create(Index n, Index strideOrTotalSize = 1, bool constantStride = true,
const Metadata* metadata = nullptr);
Expand Down Expand Up @@ -657,13 +611,11 @@ class TypedAttributeArray final: public AttributeArray
/// Return the number of bytes of memory used by this attribute.
size_t memUsage() const override;

#if OPENVDB_ABI_VERSION_NUMBER >= 10
/// Return the number of bytes of memory used by this attribute array once it
/// has been deserialized (this may be different to memUsage() if delay-loading
/// is in use). Note that this method does NOT consider the fact that a
/// uniform attribute could be expanded and only deals with delay-loading.
size_t memUsageIfLoaded() const override;
#endif

/// Return the value at index @a n (assumes in-core)
ValueType getUnsafe(Index n) const;
Expand Down Expand Up @@ -691,12 +643,6 @@ class TypedAttributeArray final: public AttributeArray
/// (assumes in-core)
static void setUnsafe(AttributeArray* array, const Index n, const ValueType& value);

#if OPENVDB_ABI_VERSION_NUMBER < 10
/// Set value at given index @a n from @a sourceIndex of another @a sourceArray
OPENVDB_DEPRECATED_MESSAGE("Use copyValues() with source-target index pairs")
void set(const Index n, const AttributeArray& sourceArray, const Index sourceIndex) override;
#endif

/// Return @c true if this array is stored as a single uniform value.
bool isUniform() const override { return mIsUniform; }
/// @brief Replace the single value storage with an array of length size().
Expand All @@ -719,15 +665,6 @@ class TypedAttributeArray final: public AttributeArray
/// Non-member equivalent to fill() that static_casts array to this TypedAttributeArray
static void fill(AttributeArray* array, const ValueType& value);

#if OPENVDB_ABI_VERSION_NUMBER < 10
/// Compress the attribute array.
OPENVDB_DEPRECATED_MESSAGE("Previously this compressed the attribute array, now it does nothing")
bool compress() override;
/// Uncompress the attribute array.
OPENVDB_DEPRECATED_MESSAGE("Previously this uncompressed the attribute array, now it does nothing")
bool decompress() override;
#endif

/// Read attribute data from a stream.
void read(std::istream&) override;
/// Write attribute data to a stream.
Expand Down Expand Up @@ -789,14 +726,7 @@ class TypedAttributeArray final: 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).
#if OPENVDB_ABI_VERSION_NUMBER >= 10
inline void doLoadUnsafe() const;
#else
/// @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();
#endif

/// Toggle out-of-core state
inline void setOutOfCore(const bool);
Expand Down Expand Up @@ -1275,15 +1205,6 @@ TypedAttributeArray<ValueType_, Codec_>::copy() const
}


#if OPENVDB_ABI_VERSION_NUMBER < 10
template<typename ValueType_, typename Codec_>
AttributeArray::Ptr
TypedAttributeArray<ValueType_, Codec_>::copyUncompressed() const
{
return this->copy();
}
#endif

template<typename ValueType_, typename Codec_>
size_t
TypedAttributeArray<ValueType_, Codec_>::arrayMemUsage() const
Expand Down Expand Up @@ -1385,14 +1306,13 @@ TypedAttributeArray<ValueType_, Codec_>::memUsage() const
return sizeof(*this) + (bool(mData) ? this->arrayMemUsage() : 0);
}

#if OPENVDB_ABI_VERSION_NUMBER >= 10

template<typename ValueType_, typename Codec_>
size_t
TypedAttributeArray<ValueType_, Codec_>::memUsageIfLoaded() const
{
return sizeof(*this) + (mIsUniform ? 1 : this->dataSize()) * sizeof(StorageType);
}
#endif


template<typename ValueType_, typename Codec_>
Expand Down Expand Up @@ -1497,21 +1417,6 @@ TypedAttributeArray<ValueType_, Codec_>::setUnsafe(AttributeArray* array, const
}


#if OPENVDB_ABI_VERSION_NUMBER < 10
template<typename ValueType_, typename Codec_>
void
TypedAttributeArray<ValueType_, Codec_>::set(Index n, const AttributeArray& sourceArray, const Index sourceIndex)
{
const TypedAttributeArray& sourceTypedArray = static_cast<const TypedAttributeArray&>(sourceArray);

ValueType sourceValue;
sourceTypedArray.get(sourceIndex, sourceValue);

this->set(n, sourceValue);
}
#endif


template<typename ValueType_, typename Codec_>
void
TypedAttributeArray<ValueType_, Codec_>::expand(bool fill)
Expand Down Expand Up @@ -1605,32 +1510,6 @@ TypedAttributeArray<ValueType_, Codec_>::fill(AttributeArray* array, const Value
}


#if OPENVDB_ABI_VERSION_NUMBER < 10
template<typename ValueType_, typename Codec_>
inline bool
TypedAttributeArray<ValueType_, Codec_>::compress()
{
return false;
}


template<typename ValueType_, typename Codec_>
inline bool
TypedAttributeArray<ValueType_, Codec_>::compressUnsafe()
{
return false;
}


template<typename ValueType_, typename Codec_>
inline bool
TypedAttributeArray<ValueType_, Codec_>::decompress()
{
return false;
}
#endif


template<typename ValueType_, typename Codec_>
bool
TypedAttributeArray<ValueType_, Codec_>::isOutOfCore() const
Expand Down Expand Up @@ -1976,11 +1855,7 @@ TypedAttributeArray<ValueType_, Codec_>::writePagedBuffers(compression::PagedOut

template<typename ValueType_, typename Codec_>
void
#if OPENVDB_ABI_VERSION_NUMBER >= 10
TypedAttributeArray<ValueType_, Codec_>::doLoadUnsafe() const
#else
TypedAttributeArray<ValueType_, Codec_>::doLoadUnsafe(const bool /*compression*/) const
#endif
{
if (!(this->isOutOfCore())) return;

Expand Down
2 changes: 0 additions & 2 deletions openvdb/openvdb/points/AttributeSet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ AttributeSet::memUsage() const
}


#if OPENVDB_ABI_VERSION_NUMBER >= 10
size_t
AttributeSet::memUsageIfLoaded() const
{
Expand All @@ -150,7 +149,6 @@ AttributeSet::memUsageIfLoaded() const
}
return bytes;
}
#endif


size_t
Expand Down
2 changes: 0 additions & 2 deletions openvdb/openvdb/points/AttributeSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,10 @@ class OPENVDB_API AttributeSet
/// Return the number of bytes of memory used by this attribute set.
size_t memUsage() const;

#if OPENVDB_ABI_VERSION_NUMBER >= 10
/// Return the number of bytes of memory used by this attribute set once it
/// has been deserialized (this may be different to memUsage() if delay-loading
/// is in use).
size_t memUsageIfLoaded() const;
#endif

/// @brief Return the position of the attribute array whose name is @a name,
/// or @c INVALID_POS if no match is found.
Expand Down
4 changes: 0 additions & 4 deletions openvdb/openvdb/points/PointDataGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,7 @@ class PointDataLeafNode : public tree::LeafNode<T, Log2Dim>, io::MultiPass {


Index64 memUsage() const;
#if OPENVDB_ABI_VERSION_NUMBER >= 10
Index64 memUsageIfLoaded() const;
#endif

void evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels = true) const;

Expand Down Expand Up @@ -1524,14 +1522,12 @@ PointDataLeafNode<T, Log2Dim>::memUsage() const
return BaseLeaf::memUsage() + mAttributeSet->memUsage();
}

#if OPENVDB_ABI_VERSION_NUMBER >= 10
template<typename T, Index Log2Dim>
inline Index64
PointDataLeafNode<T, Log2Dim>::memUsageIfLoaded() const
{
return BaseLeaf::memUsageIfLoaded() + mAttributeSet->memUsageIfLoaded();
}
#endif

template<typename T, Index Log2Dim>
inline void
Expand Down
Loading

0 comments on commit 60a9314

Please sign in to comment.