Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions openvdb/openvdb/Grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,10 @@ class OPENVDB_API GridBase: public MetaMap

/// @}


/// @name I/O
/// @{

#if OPENVDB_ABI_VERSION_NUMBER < 14
/// @brief Read the grid topology from a stream.
/// This will read only the grid structure, not the actual data buffers.
virtual void readTopology(std::istream&) = 0;
Expand All @@ -459,13 +459,12 @@ class OPENVDB_API GridBase: public MetaMap
/// Read all of this grid's data buffers that intersect the given index-space bounding box.
virtual void readBuffers(std::istream&, const CoordBBox&) = 0;

#if OPENVDB_ABI_VERSION_NUMBER < 14
OPENVDB_DEPRECATED_MESSAGE("This method is deprecated and will be removed. Delayed loading is no longer supported.")
virtual void readNonresidentBuffers() const = 0;
#endif

/// Write out all data buffers for this grid.
virtual void writeBuffers(std::ostream&) const = 0;
#endif

/// Read in the transform for this grid.
void readTransform(std::istream& is) { transform().read(is); }
Expand Down Expand Up @@ -931,6 +930,7 @@ class Grid: public GridBase
/// @name I/O
/// @{

#if OPENVDB_ABI_VERSION_NUMBER < 14
/// @brief Read the grid topology from a stream.
/// This will read only the grid structure, not the actual data buffers.
void readTopology(std::istream&) override;
Expand All @@ -943,14 +943,14 @@ class Grid: public GridBase
/// Read all of this grid's data buffers that intersect the given index-space bounding box.
void readBuffers(std::istream&, const CoordBBox&) override;

#if OPENVDB_ABI_VERSION_NUMBER < 14
OPENVDB_DEPRECATED_MESSAGE("This method is deprecated and will be removed. Delayed loading is no longer supported.")
void readNonresidentBuffers() const override { }
#endif

/// Write out all data buffers for this grid.
void writeBuffers(std::ostream&) const override;

#endif // OPENVDB_ABI_VERSION_NUMBER < 14

/// Output a human-readable description of this grid.
void print(std::ostream& = std::cout, int verboseLevel = 1) const override;

Expand Down Expand Up @@ -1624,6 +1624,7 @@ Grid<TreeT>::evalActiveVoxelDim() const

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

#if OPENVDB_ABI_VERSION_NUMBER < 14

/// @internal Consider using the stream tagging mechanism (see io::Archive)
/// to specify the float precision, but note that the setting is per-grid.
Expand Down Expand Up @@ -1742,6 +1743,8 @@ Grid<TreeT>::writeBuffers(std::ostream& os) const
}
}

#endif // OPENVDB_ABI_VERSION_NUMBER < 14


//static
template<typename TreeT>
Expand Down
10 changes: 9 additions & 1 deletion openvdb/openvdb/codecs/PointDataCodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <openvdb/tools/Clip.h>

#include <openvdb/points/PointDataIO.h> // io::readCompressedValues(), io::writeCompressedValues(), io::writeCompressedValuesSize()
#include <openvdb/points/PointDataGrid.h>
#include <openvdb/points/AttributeSet.h>
#include <openvdb/points/StreamCompression.h>
Expand Down Expand Up @@ -181,7 +182,14 @@ inline Index countPointDataPasses(const std::vector<const LeafT*>& leaves)
{
Index maxRequiredPasses = 0;
for (const auto* leaf : leaves) {
const Index requiredPasses = leaf->buffers();
const Index attributes = static_cast<Index>(leaf->attributeSet().size());
const Index requiredPasses =
/*voxel buffer sizes*/ 1 +
/*voxel buffers*/ 1 +
/*attribute metadata*/ 1 +
/*attribute uniform values*/ attributes +
/*attribute buffers*/ attributes +
/*cleanup*/ 1;
if (requiredPasses > maxRequiredPasses) {
maxRequiredPasses = requiredPasses;
}
Expand Down
8 changes: 8 additions & 0 deletions openvdb/openvdb/io/Archive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,7 @@ Archive::readGrid(const GridDescriptor& gd, std::istream& is, const io::ReadOpti
if (codec) {
codec->readTopology(is, *codecData, readOptions, diagnostics);
} else {
#if OPENVDB_ABI_VERSION_NUMBER < 14
io::StreamMetadata::Ptr allocateLeafBuffersMeta;
if (readOptions.readMode == io::ReadMode::TopologyOnly) {
// Signal Grid<TreeT>::readTopology to allocate leaf buffers and
Expand All @@ -1040,6 +1041,7 @@ Archive::readGrid(const GridDescriptor& gd, std::istream& is, const io::ReadOpti
}
throw;
}
#endif // OPENVDB_ABI_VERSION_NUMBER < 14
}
}
if (readBuffers) {
Expand All @@ -1049,6 +1051,7 @@ Archive::readGrid(const GridDescriptor& gd, std::istream& is, const io::ReadOpti
const Index64 size = static_cast<Index64>(gd.getEndPos() - gd.getGridPos());
codec->readBuffers(is, size, *codecData, readOptions, diagnostics);
} else {
#if OPENVDB_ABI_VERSION_NUMBER < 14
const auto& worldBBox = readOptions.clipBBox;
const bool clip = worldBBox.isSorted();
if (clip) {
Expand All @@ -1057,6 +1060,7 @@ Archive::readGrid(const GridDescriptor& gd, std::istream& is, const io::ReadOpti
} else {
grid->readBuffers(is);
}
#endif // OPENVDB_ABI_VERSION_NUMBER < 14
}
}

Expand Down Expand Up @@ -1242,7 +1246,9 @@ Archive::writeGrid(GridDescriptor& gd, GridBase::ConstPtr grid,
if (codec) {
codec->writeTopology(os, *grid, writeOptions);
} else {
#if OPENVDB_ABI_VERSION_NUMBER < 14
grid->writeTopology(os);
#endif // OPENVDB_ABI_VERSION_NUMBER < 14
}

// Now we know the grid block storage position.
Expand All @@ -1252,7 +1258,9 @@ Archive::writeGrid(GridDescriptor& gd, GridBase::ConstPtr grid,
if (codec) {
codec->writeBuffers(os, *grid, writeOptions);
} else {
#if OPENVDB_ABI_VERSION_NUMBER < 14
grid->writeBuffers(os);
#endif // OPENVDB_ABI_VERSION_NUMBER < 14
}

// Now we know the end position of this grid.
Expand Down
14 changes: 12 additions & 2 deletions openvdb/openvdb/points/PointDataGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
#include <utility> // std::pair, std::make_pair
#include <vector>

// This header is only needed when PointData I/O methods are present (ie ABI<14)
// otherwise, this header is included in the PointDataCodec instead.
#if OPENVDB_ABI_VERSION_NUMBER < 14
#include <openvdb/points/PointDataIO.h> // io::readCompressedValues(), io::writeCompressedValues(), io::writeCompressedValuesSize()
#endif

class TestPointDataLeaf;

Expand Down Expand Up @@ -363,6 +367,7 @@ class PointDataLeafNode : public tree::LeafNode<T, Log2Dim>, io::PointDataGridMu

// I/O methods

#if OPENVDB_ABI_VERSION_NUMBER < 14
void readTopology(std::istream& is, bool fromHalf = false);
void writeTopology(std::ostream& os, bool toHalf = false) const;

Expand All @@ -372,10 +377,11 @@ class PointDataLeafNode : public tree::LeafNode<T, Log2Dim>, io::PointDataGridMu
void readBuffers(std::istream& is, const CoordBBox&, bool fromHalf = false);
void writeBuffers(std::ostream& os, bool toHalf = false) const;


Index64 memUsage() const;
OPENVDB_DEPRECATED_MESSAGE("Use memUsage() instead. This method is deprecated and will be removed. Delayed loading is no longer supported.")
Index64 memUsageIfLoaded() const { return memUsage(); }
#endif // OPENVDB_ABI_VERSION_NUMBER < 14

Index64 memUsage() const;

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

Expand Down Expand Up @@ -987,6 +993,8 @@ PointDataLeafNode<T, Log2Dim>::setOffsetOnly(Index offset, const ValueType& val)
this->buffer().setValue(offset, val);
}

#if OPENVDB_ABI_VERSION_NUMBER < 14

template<typename T, Index Log2Dim>
inline void
PointDataLeafNode<T, Log2Dim>::readTopology(std::istream& is, bool fromHalf)
Expand Down Expand Up @@ -1386,6 +1394,8 @@ PointDataLeafNode<T, Log2Dim>::writeBuffers(std::ostream& os, bool toHalf) const
}
}

#endif // OPENVDB_ABI_VERSION_NUMBER < 14

template<typename T, Index Log2Dim>
inline Index64
PointDataLeafNode<T, Log2Dim>::memUsage() const
Expand Down
4 changes: 4 additions & 0 deletions openvdb/openvdb/points/PointDataIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#ifndef OPENVDB_POINTS_POINT_DATA_IO_HAS_BEEN_INCLUDED
#define OPENVDB_POINTS_POINT_DATA_IO_HAS_BEEN_INCLUDED

#include <openvdb/io/Compression.h> // for io::readCompressedValues(), etc
#include <openvdb/points/StreamCompression.h>
#include <openvdb/util/NodeMasks.h>


namespace openvdb {
OPENVDB_USE_VERSION_NAMESPACE
Expand Down
11 changes: 10 additions & 1 deletion openvdb/openvdb/tree/InternalNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ class InternalNode
/// Mark all values (both tiles and voxels) as active.
void setValuesOn();

#if OPENVDB_ABI_VERSION_NUMBER < 14
//
// I/O
//
Expand All @@ -466,7 +467,7 @@ class InternalNode
void writeBuffers(std::ostream&, bool toHalf = false) const;
void readBuffers(std::istream&, bool fromHalf = false);
void readBuffers(std::istream&, const CoordBBox&, bool fromHalf = false);

#endif // OPENVDB_ABI_VERSION_NUMBER < 14

//
// Unsafe methods
Expand Down Expand Up @@ -2394,6 +2395,8 @@ InternalNode<ChildT, Log2Dim>::copyToDense(const CoordBBox& bbox, DenseT& dense)
////////////////////////////////////////


#if OPENVDB_ABI_VERSION_NUMBER < 14

template<typename ChildT, Index Log2Dim>
inline void
InternalNode<ChildT, Log2Dim>::writeTopology(std::ostream& os, bool toHalf) const
Expand Down Expand Up @@ -2463,6 +2466,8 @@ InternalNode<ChildT, Log2Dim>::readTopology(std::istream& is, bool fromHalf)
}
}

#endif // OPENVDB_ABI_VERSION_NUMBER < 14


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

Expand Down Expand Up @@ -3218,6 +3223,8 @@ InternalNode<ChildT, Log2Dim>::combine2(const InternalNode& other, const OtherVa
////////////////////////////////////////


#if OPENVDB_ABI_VERSION_NUMBER < 14

template<typename ChildT, Index Log2Dim>
inline void
InternalNode<ChildT, Log2Dim>::writeBuffers(std::ostream& os, bool toHalf) const
Expand Down Expand Up @@ -3259,6 +3266,8 @@ InternalNode<ChildT, Log2Dim>::readBuffers(std::istream& is,
this->clip(clipBBox, background);
}

#endif // OPENVDB_ABI_VERSION_NUMBER < 14


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

Expand Down
13 changes: 9 additions & 4 deletions openvdb/openvdb/tree/LeafNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ class LeafNode
const Buffer& buffer() const { return mBuffer; }
Buffer& buffer() { return mBuffer; }

#if OPENVDB_ABI_VERSION_NUMBER < 14
//
// I/O methods
//
Expand All @@ -406,6 +407,7 @@ class LeafNode
/// @param os the stream to which to write
/// @param toHalf if true, output floating-point values as 16-bit half floats
void writeBuffers(std::ostream& os, bool toHalf = false) const;
#endif // OPENVDB_ABI_VERSION_NUMBER < 14

size_t streamingSize(bool toHalf = false) const;

Expand Down Expand Up @@ -924,7 +926,10 @@ class LeafNode
void setValueMaskOn(Index n) { mValueMask.setOn(n); }
void setValueMaskOff(Index n) { mValueMask.setOff(n); }


#if OPENVDB_ABI_VERSION_NUMBER < 14
inline void skipCompressedValues(bool seekable, std::istream&, bool fromHalf);
#endif // OPENVDB_ABI_VERSION_NUMBER < 14

/// Compute the origin of the leaf node that contains the voxel with the given coordinates.
static void evalNodeOrigin(Coord& xyz) { xyz &= ~(DIM - 1); }
Expand Down Expand Up @@ -1326,6 +1331,8 @@ LeafNode<T, Log2Dim>::copyFromDense(const CoordBBox& bbox, const DenseT& dense,
////////////////////////////////////////


#if OPENVDB_ABI_VERSION_NUMBER < 14

template<typename T, Index Log2Dim>
inline void
LeafNode<T, Log2Dim>::readTopology(std::istream& is, bool /*fromHalf*/)
Expand All @@ -1342,10 +1349,6 @@ LeafNode<T, Log2Dim>::writeTopology(std::ostream& os, bool /*toHalf*/) const
}


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



template<typename T, Index Log2Dim>
inline void
LeafNode<T,Log2Dim>::skipCompressedValues(bool seekable, std::istream& is, bool fromHalf)
Expand Down Expand Up @@ -1440,6 +1443,8 @@ LeafNode<T, Log2Dim>::writeBuffers(std::ostream& os, bool toHalf) const
mValueMask, /*childMask=*/NodeMaskType(), toHalf);
}

#endif // OPENVDB_ABI_VERSION_NUMBER < 14


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

Expand Down
6 changes: 6 additions & 0 deletions openvdb/openvdb/tree/LeafNodeBool.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class LeafNode<bool, Log2Dim>
const Buffer& buffer() const { return mBuffer; }
Buffer& buffer() { return mBuffer; }

#if OPENVDB_ABI_VERSION_NUMBER < 14
//
// I/O methods
//
Expand All @@ -213,6 +214,7 @@ class LeafNode<bool, Log2Dim>
void readBuffers(std::istream& is, const CoordBBox&, bool fromHalf = false);
/// Write out the topology and the origin.
void writeBuffers(std::ostream&, bool toHalf = false) const;
#endif // OPENVDB_ABI_VERSION_NUMBER < 14

//
// Accessor methods
Expand Down Expand Up @@ -976,6 +978,8 @@ LeafNode<bool, Log2Dim>::offsetToGlobalCoord(Index n) const
////////////////////////////////////////


#if OPENVDB_ABI_VERSION_NUMBER < 14

template<Index Log2Dim>
inline void
LeafNode<bool, Log2Dim>::readTopology(std::istream& is, bool /*fromHalf*/)
Expand Down Expand Up @@ -1038,6 +1042,8 @@ LeafNode<bool, Log2Dim>::writeBuffers(std::ostream& os, bool /*toHalf*/) const
mBuffer.mData.save(os);
}

#endif // OPENVDB_ABI_VERSION_NUMBER < 14


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

Expand Down
6 changes: 6 additions & 0 deletions openvdb/openvdb/tree/LeafNodeMask.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class LeafNode<ValueMask, Log2Dim>
const Buffer& buffer() const { return mBuffer; }
Buffer& buffer() { return mBuffer; }

#if OPENVDB_ABI_VERSION_NUMBER < 14
//
// I/O methods
//
Expand All @@ -212,6 +213,7 @@ class LeafNode<ValueMask, Log2Dim>
void readBuffers(std::istream& is, const CoordBBox&, bool fromHalf = false);
/// Write out the topology and the origin.
void writeBuffers(std::ostream&, bool toHalf = false) const;
#endif // OPENVDB_ABI_VERSION_NUMBER < 14

//
// Accessor methods
Expand Down Expand Up @@ -962,6 +964,8 @@ LeafNode<ValueMask, Log2Dim>::offsetToGlobalCoord(Index n) const
////////////////////////////////////////


#if OPENVDB_ABI_VERSION_NUMBER < 14

template<Index Log2Dim>
inline void
LeafNode<ValueMask, Log2Dim>::readTopology(std::istream& is, bool /*fromHalf*/)
Expand Down Expand Up @@ -1017,6 +1021,8 @@ LeafNode<ValueMask, Log2Dim>::writeBuffers(std::ostream& os, bool /*toHalf*/) co
os.write(reinterpret_cast<const char*>(&mOrigin), sizeof(Coord::ValueType) * 3);
}

#endif // OPENVDB_ABI_VERSION_NUMBER < 14


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

Expand Down
Loading
Loading