OpenVDB  6.2.0
Dense.h
Go to the documentation of this file.
1 //
3 // Copyright (c) DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
30 
35 
36 #ifndef OPENVDB_TOOLS_DENSE_HAS_BEEN_INCLUDED
37 #define OPENVDB_TOOLS_DENSE_HAS_BEEN_INCLUDED
38 
39 #include <openvdb/Types.h>
40 #include <openvdb/Grid.h>
42 #include <openvdb/Exceptions.h>
43 #include <openvdb/util/Formats.h>
44 #include "Prune.h"
45 #include <tbb/parallel_for.h>
46 #include <iostream>
47 #include <memory>
48 #include <string>
49 #include <utility> // for std::pair
50 #include <vector>
51 
52 namespace openvdb {
54 namespace OPENVDB_VERSION_NAME {
55 namespace tools {
56 
62 template<typename DenseT, typename GridOrTreeT>
63 void
65  const GridOrTreeT& sparse,
66  DenseT& dense,
67  bool serial = false);
68 
69 
76 template<typename DenseT, typename GridOrTreeT>
77 void
79  const DenseT& dense,
80  GridOrTreeT& sparse,
81  const typename GridOrTreeT::ValueType& tolerance,
82  bool serial = false);
83 
84 
86 
96 
100 template<typename ValueT, MemoryLayout Layout> class DenseBase;
101 
105 template<typename ValueT>
106 class DenseBase<ValueT, LayoutZYX>
107 {
108 public:
115  inline size_t coordToOffset(size_t i, size_t j, size_t k) const { return i*mX + j*mY + k; }
116 
121  inline Coord offsetToLocalCoord(size_t n) const
122  {
123  const size_t x = n / mX;
124  n -= mX*x;
125  const size_t y = n / mY;
126  return Coord(Coord::ValueType(x), Coord::ValueType(y), Coord::ValueType(n - mY*y));
127  }
128 
131  inline size_t xStride() const { return mX; }
132 
135  inline size_t yStride() const { return mY; }
136 
139  static size_t zStride() { return 1; }
140 
141 protected:
143  DenseBase(const CoordBBox& bbox) : mBBox(bbox), mY(bbox.dim()[2]), mX(mY*bbox.dim()[1]) {}
144 
145  const CoordBBox mBBox;//signed coordinates of the domain represented by the grid
146  const size_t mY, mX;//strides in the y and x direction
147 };// end of DenseBase<ValueT, LayoutZYX>
148 
152 template<typename ValueT>
153 class DenseBase<ValueT, LayoutXYZ>
154 {
155 public:
162  inline size_t coordToOffset(size_t i, size_t j, size_t k) const { return i + j*mY + k*mZ; }
163 
168  inline Coord offsetToLocalCoord(size_t n) const
169  {
170  const size_t z = n / mZ;
171  n -= mZ*z;
172  const size_t y = n / mY;
173  return Coord(Coord::ValueType(n - mY*y), Coord::ValueType(y), Coord::ValueType(z));
174  }
175 
178  static size_t xStride() { return 1; }
179 
182  inline size_t yStride() const { return mY; }
183 
186  inline size_t zStride() const { return mZ; }
187 
188 protected:
190  DenseBase(const CoordBBox& bbox) : mBBox(bbox), mY(bbox.dim()[0]), mZ(mY*bbox.dim()[1]) {}
191 
192  const CoordBBox mBBox;//signed coordinates of the domain represented by the grid
193  const size_t mY, mZ;//strides in the y and z direction
194 };// end of DenseBase<ValueT, LayoutXYZ>
195 
208 template<typename ValueT, MemoryLayout Layout = LayoutZYX>
209 class Dense : public DenseBase<ValueT, Layout>
210 {
211 public:
212  using ValueType = ValueT;
216 
222  Dense(const CoordBBox& bbox) : BaseT(bbox) { this->init(); }
223 
230  Dense(const CoordBBox& bbox, const ValueT& value) : BaseT(bbox)
231  {
232  this->init();
233  this->fill(value);
234  }
235 
245  Dense(const CoordBBox& bbox, ValueT* data) : BaseT(bbox), mData(data)
246  {
247  if (BaseT::mBBox.empty()) {
248  OPENVDB_THROW(ValueError, "can't construct a dense grid with an empty bounding box");
249  }
250  }
251 
259  Dense(const Coord& dim, const Coord& min = Coord(0))
260  : BaseT(CoordBBox(min, min+dim.offsetBy(-1)))
261  {
262  this->init();
263  }
264 
266  static MemoryLayout memoryLayout() { return Layout; }
267 
270  inline ValueT* data() { return mData; }
271 
274  inline const ValueT* data() const { return mData; }
275 
278  inline const CoordBBox& bbox() const { return BaseT::mBBox; }
279 
281  inline const Coord& origin() const { return BaseT::mBBox.min(); }
282 
284  inline Index64 valueCount() const { return BaseT::mBBox.volume(); }
285 
287  inline void setValue(size_t offset, const ValueT& value) { mData[offset] = value; }
288 
290  const ValueT& getValue(size_t offset) const { return mData[offset]; }
291 
293  ValueT& getValue(size_t offset) { return mData[offset]; }
294 
297  inline void setValue(size_t i, size_t j, size_t k, const ValueT& value)
298  {
299  mData[BaseT::coordToOffset(i,j,k)] = value;
300  }
301 
305  inline const ValueT& getValue(size_t i, size_t j, size_t k) const
306  {
307  return mData[BaseT::coordToOffset(i,j,k)];
308  }
309 
313  inline ValueT& getValue(size_t i, size_t j, size_t k)
314  {
315  return mData[BaseT::coordToOffset(i,j,k)];
316  }
317 
320  inline void setValue(const Coord& xyz, const ValueT& value)
321  {
322  mData[this->coordToOffset(xyz)] = value;
323  }
324 
327  inline const ValueT& getValue(const Coord& xyz) const
328  {
329  return mData[this->coordToOffset(xyz)];
330  }
331 
335  inline ValueT& getValue(const Coord& xyz)
336  {
337  return mData[this->coordToOffset(xyz)];
338  }
339 
341  inline void fill(const ValueT& value)
342  {
343  size_t size = this->valueCount();
344  ValueT* a = mData;
345  while(size--) *a++ = value;
346  }
347 
354  inline size_t coordToOffset(const Coord& xyz) const
355  {
356  assert(BaseT::mBBox.isInside(xyz));
357  return BaseT::coordToOffset(size_t(xyz[0]-BaseT::mBBox.min()[0]),
358  size_t(xyz[1]-BaseT::mBBox.min()[1]),
359  size_t(xyz[2]-BaseT::mBBox.min()[2]));
360  }
361 
363  inline Coord offsetToCoord(size_t n) const
364  {
365  return this->offsetToLocalCoord(n) + BaseT::mBBox.min();
366  }
367 
369  inline Index64 memUsage() const
370  {
371  return sizeof(*this) + BaseT::mBBox.volume() * sizeof(ValueType);
372  }
373 
376  void print(const std::string& name = "", std::ostream& os = std::cout) const
377  {
378  const Coord dim = BaseT::mBBox.dim();
379  os << "Dense Grid";
380  if (!name.empty()) os << " \"" << name << "\"";
381  util::printBytes(os, this->memUsage(), ":\n Memory footprint: ");
382  os << " Dimensions of grid : " << dim[0] << " x " << dim[1] << " x " << dim[2] << "\n";
383  os << " Number of voxels: " << util::formattedInt(this->valueCount()) << "\n";
384  os << " Bounding box of voxels: " << BaseT::mBBox << "\n";
385  os << " Memory layout: " << (Layout == LayoutZYX ? "ZYX (" : "XYZ (dis")
386  << "similar to VDB)\n";
387  }
388 
389 private:
391  void init()
392  {
393  if (BaseT::mBBox.empty()) {
394  OPENVDB_THROW(ValueError, "can't construct a dense grid with an empty bounding box");
395  }
396  mArray.reset(new ValueT[BaseT::mBBox.volume()]);
397  mData = mArray.get();
398  }
399 
400  std::unique_ptr<ValueT[]> mArray;
401  ValueT* mData;//raw c-style pointer to values
402 };// end of Dense
403 
405 
406 
413 template<typename _TreeT, typename _DenseT = Dense<typename _TreeT::ValueType> >
415 {
416 public:
417  using DenseT = _DenseT;
418  using TreeT = _TreeT;
419  using ValueT = typename TreeT::ValueType;
420 
421  CopyToDense(const TreeT& tree, DenseT& dense)
422  : mRoot(&(tree.root())), mDense(&dense) {}
423 
424  void copy(bool serial = false) const
425  {
426  if (serial) {
427  mRoot->copyToDense(mDense->bbox(), *mDense);
428  } else {
429  tbb::parallel_for(mDense->bbox(), *this);
430  }
431  }
432 
434  void operator()(const CoordBBox& bbox) const
435  {
436  mRoot->copyToDense(bbox, *mDense);
437  }
438 
439 private:
440  const typename TreeT::RootNodeType* mRoot;
441  DenseT* mDense;
442 };// CopyToDense
443 
444 
445 // Convenient wrapper function for the CopyToDense class
446 template<typename DenseT, typename GridOrTreeT>
447 void
448 copyToDense(const GridOrTreeT& sparse, DenseT& dense, bool serial)
449 {
450  using Adapter = TreeAdapter<GridOrTreeT>;
451  using TreeT = typename Adapter::TreeType;
452 
453  CopyToDense<TreeT, DenseT> op(Adapter::constTree(sparse), dense);
454  op.copy(serial);
455 }
456 
457 
459 
460 
470 template<typename _TreeT, typename _DenseT = Dense<typename _TreeT::ValueType> >
472 {
473 public:
474  using DenseT = _DenseT;
475  using TreeT = _TreeT;
476  using ValueT = typename TreeT::ValueType;
477  using LeafT = typename TreeT::LeafNodeType;
479 
480  CopyFromDense(const DenseT& dense, TreeT& tree, const ValueT& tolerance)
481  : mDense(&dense),
482  mTree(&tree),
483  mBlocks(nullptr),
484  mTolerance(tolerance),
485  mAccessor(tree.empty() ? nullptr : new AccessorT(tree))
486  {
487  }
489  : mDense(other.mDense),
490  mTree(other.mTree),
491  mBlocks(other.mBlocks),
492  mTolerance(other.mTolerance),
493  mAccessor(other.mAccessor.get() == nullptr ? nullptr : new AccessorT(*mTree))
494  {
495  }
496 
498  void copy(bool serial = false)
499  {
500  mBlocks = new std::vector<Block>();
501  const CoordBBox& bbox = mDense->bbox();
502  // Pre-process: Construct a list of blocks aligned with (potential) leaf nodes
503  for (CoordBBox sub=bbox; sub.min()[0] <= bbox.max()[0]; sub.min()[0] = sub.max()[0] + 1) {
504  for (sub.min()[1] = bbox.min()[1]; sub.min()[1] <= bbox.max()[1];
505  sub.min()[1] = sub.max()[1] + 1)
506  {
507  for (sub.min()[2] = bbox.min()[2]; sub.min()[2] <= bbox.max()[2];
508  sub.min()[2] = sub.max()[2] + 1)
509  {
510  sub.max() = Coord::minComponent(bbox.max(),
511  (sub.min()&(~(LeafT::DIM-1u))).offsetBy(LeafT::DIM-1u));
512  mBlocks->push_back(Block(sub));
513  }
514  }
515  }
516 
517  // Multi-threaded process: Convert dense grid into leaf nodes and tiles
518  if (serial) {
519  (*this)(tbb::blocked_range<size_t>(0, mBlocks->size()));
520  } else {
521  tbb::parallel_for(tbb::blocked_range<size_t>(0, mBlocks->size()), *this);
522  }
523 
524  // Post-process: Insert leaf nodes and tiles into the tree, and prune the tiles only!
525  tree::ValueAccessor<TreeT> acc(*mTree);
526  for (size_t m=0, size = mBlocks->size(); m<size; ++m) {
527  Block& block = (*mBlocks)[m];
528  if (block.leaf) {
529  acc.addLeaf(block.leaf);
530  } else if (block.tile.second) {//only background tiles are inactive
531  acc.addTile(1, block.bbox.min(), block.tile.first, true);//leaf tile
532  }
533  }
534  delete mBlocks;
535  mBlocks = nullptr;
536 
537  tools::pruneTiles(*mTree, mTolerance);//multi-threaded
538  }
539 
542  void operator()(const tbb::blocked_range<size_t> &r) const
543  {
544  assert(mBlocks);
545  LeafT* leaf = new LeafT();
546 
547  for (size_t m=r.begin(), n=0, end = r.end(); m != end; ++m, ++n) {
548 
549  Block& block = (*mBlocks)[m];
550  const CoordBBox &bbox = block.bbox;
551 
552  if (mAccessor.get() == nullptr) {//i.e. empty target tree
553  leaf->fill(mTree->background(), false);
554  } else {//account for existing leaf nodes in the target tree
555  if (const LeafT* target = mAccessor->probeConstLeaf(bbox.min())) {
556  (*leaf) = (*target);
557  } else {
558  ValueT value = zeroVal<ValueT>();
559  bool state = mAccessor->probeValue(bbox.min(), value);
560  leaf->fill(value, state);
561  }
562  }
563 
564  leaf->copyFromDense(bbox, *mDense, mTree->background(), mTolerance);
565 
566  if (!leaf->isConstant(block.tile.first, block.tile.second, mTolerance)) {
567  leaf->setOrigin(bbox.min() & (~(LeafT::DIM - 1)));
568  block.leaf = leaf;
569  leaf = new LeafT();
570  }
571  }// loop over blocks
572 
573  delete leaf;
574  }
575 
576 private:
577  struct Block {
578  CoordBBox bbox;
579  LeafT* leaf;
580  std::pair<ValueT, bool> tile;
581  Block(const CoordBBox& b) : bbox(b), leaf(nullptr) {}
582  };
583 
584  const DenseT* mDense;
585  TreeT* mTree;
586  std::vector<Block>* mBlocks;
587  ValueT mTolerance;
588  std::unique_ptr<AccessorT> mAccessor;
589 };// CopyFromDense
590 
591 
592 // Convenient wrapper function for the CopyFromDense class
593 template<typename DenseT, typename GridOrTreeT>
594 void
595 copyFromDense(const DenseT& dense, GridOrTreeT& sparse,
596  const typename GridOrTreeT::ValueType& tolerance, bool serial)
597 {
598  using Adapter = TreeAdapter<GridOrTreeT>;
599  using TreeT = typename Adapter::TreeType;
600 
601  CopyFromDense<TreeT, DenseT> op(dense, Adapter::tree(sparse), tolerance);
602  op.copy(serial);
603 }
604 
605 } // namespace tools
606 } // namespace OPENVDB_VERSION_NAME
607 } // namespace openvdb
608 
609 #endif // OPENVDB_TOOLS_DENSE_HAS_BEEN_INCLUDED
610 
611 // Copyright (c) DreamWorks Animation LLC
612 // All rights reserved. This software is distributed under the
613 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
Dense(const CoordBBox &bbox)
Construct a dense grid with a given range of coordinates.
Definition: Dense.h:222
const ValueT & getValue(size_t i, size_t j, size_t k) const
Return a const reference to the value of the voxel at unsigned index coordinates (i, j, k).
Definition: Dense.h:305
static MemoryLayout memoryLayout()
Return the memory layout for this grid (see above for definitions).
Definition: Dense.h:266
Utility routines to output nicely-formatted numeric values.
void setValue(size_t i, size_t j, size_t k, const ValueT &value)
Set the value of the voxel at unsigned index coordinates (i, j, k).
Definition: Dense.h:297
static size_t zStride()
Return the stride of the array in the z direction ( = 1).
Definition: Dense.h:139
void pruneTiles(TreeT &tree, typename TreeT::ValueType tolerance=zeroVal< typename TreeT::ValueType >(), bool threaded=true, size_t grainSize=1)
Reduce the memory footprint of a tree by replacing with tiles any non-leaf nodes whose values are all...
Definition: Prune.h:371
const ValueT & getValue(const Coord &xyz) const
Return a const reference to the value of the voxel at the given signed coordinates.
Definition: Dense.h:327
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process. If the leaf node already exists, replace it.
Definition: ValueAccessor.h:367
const ValueT & getValue(size_t offset) const
Return a const reference to the value of the voxel at the given array offset.
Definition: Dense.h:290
void copy(bool serial=false) const
Definition: Dense.h:424
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
size_t coordToOffset(const Coord &xyz) const
Return the linear offset into this grid&#39;s value array given by the specified signed coordinates...
Definition: Dense.h:354
SharedPtr< const Dense > ConstPtr
Definition: Dense.h:215
void fill(const ValueT &value)
Fill this grid with a constant value.
Definition: Dense.h:341
const ValueT * data() const
Return a raw pointer to this grid&#39;s value array.
Definition: Dense.h:274
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Add a tile at the specified tree level that contains voxel (x, y, z), possibly deleting existing node...
Definition: ValueAccessor.h:375
void operator()(const CoordBBox &bbox) const
Public method called by tbb::parallel_for.
Definition: Dense.h:434
ValueT ValueType
Definition: Dense.h:212
std::shared_ptr< T > SharedPtr
Definition: Types.h:139
const CoordBBox mBBox
Definition: Dense.h:192
typename TreeT::ValueType ValueT
Definition: Dense.h:419
Index64 memUsage() const
Return the memory footprint of this Dense grid in bytes.
Definition: Dense.h:369
Defined various multi-threaded utility functions for trees.
ValueT * data()
Return a raw pointer to this grid&#39;s value array.
Definition: Dense.h:270
Definition: Dense.h:95
Coord offsetToLocalCoord(size_t n) const
Return the local coordinate corresponding to the specified linear offset.
Definition: Dense.h:121
typename TreeT::ValueType ValueT
Definition: Dense.h:476
void setValue(const Coord &xyz, const ValueT &value)
Set the value of the voxel at the given signed coordinates.
Definition: Dense.h:320
void operator()(const tbb::blocked_range< size_t > &r) const
Public method called by tbb::parallel_for.
Definition: Dense.h:542
ValueT & getValue(const Coord &xyz)
Return a non-const reference to the value of the voxel at the given signed coordinates.
Definition: Dense.h:335
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:128
const CoordBBox mBBox
Definition: Dense.h:145
Coord offsetToLocalCoord(size_t n) const
Return the index coordinate corresponding to the specified linear offset.
Definition: Dense.h:168
typename TreeT::LeafNodeType LeafT
Definition: Dense.h:477
CopyFromDense(const CopyFromDense &other)
Definition: Dense.h:488
Dense(const CoordBBox &bbox, ValueT *data)
Construct a dense grid that wraps an external array.
Definition: Dense.h:245
SharedPtr< Dense > Ptr
Definition: Dense.h:214
void print(const std::string &name="", std::ostream &os=std::cout) const
Output a human-readable description of this grid to the specified stream.
Definition: Dense.h:376
MemoryLayout
Definition: Dense.h:95
void setValue(size_t offset, const ValueT &value)
Set the value of the voxel at the given array offset.
Definition: Dense.h:287
Base class for Dense which is defined below.
Definition: Dense.h:100
const CoordBBox & bbox() const
Return the bounding box of the signed index domain of this grid.
Definition: Dense.h:278
Definition: Exceptions.h:40
Coord offsetToCoord(size_t n) const
Return the global coordinate corresponding to the specified linear offset.
Definition: Dense.h:363
const size_t mY
Definition: Dense.h:146
CopyToDense(const TreeT &tree, DenseT &dense)
Definition: Dense.h:421
const size_t mZ
Definition: Dense.h:193
size_t xStride() const
Return the stride of the array in the x direction ( = dimY*dimZ).
Definition: Dense.h:131
void copy(bool serial=false)
Copy values from the dense grid to the sparse tree.
Definition: Dense.h:498
_TreeT TreeT
Definition: Dense.h:418
size_t coordToOffset(size_t i, size_t j, size_t k) const
Return the linear offset into this grid&#39;s value array given by unsigned coordinates (i...
Definition: Dense.h:115
ValueT & getValue(size_t i, size_t j, size_t k)
Return a non-const reference to the value of the voxel at unsigned index coordinates (i...
Definition: Dense.h:313
size_t zStride() const
Return the stride of the array in the y direction ( = dimX*dimY).
Definition: Dense.h:186
size_t yStride() const
Return the stride of the array in the y direction ( = dimZ).
Definition: Dense.h:135
void copyFromDense(const DenseT &dense, GridOrTreeT &sparse, const typename GridOrTreeT::ValueType &tolerance, bool serial=false)
Populate a sparse grid with the values of all of the voxels of a dense grid.
Definition: Dense.h:595
uint64_t Index64
Definition: Types.h:60
_DenseT DenseT
Definition: Dense.h:417
_DenseT DenseT
Definition: Dense.h:474
Definition: Dense.h:95
DenseBase(const CoordBBox &bbox)
Protected constructor so as to prevent direct instantiation.
Definition: Dense.h:143
void copyToDense(const GridOrTreeT &sparse, DenseT &dense, bool serial=false)
Populate a dense grid with the values of voxels from a sparse grid, where the sparse grid intersects ...
Definition: Dense.h:448
Index64 valueCount() const
Return the number of voxels contained in this grid.
Definition: Dense.h:284
const std::enable_if<!VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:129
const Coord & origin() const
Return the grid&#39;s origin in index coordinates.
Definition: Dense.h:281
Copy the values from a dense grid into an OpenVDB tree.
Definition: Dense.h:471
FormattedInt< IntT > formattedInt(IntT n)
Definition: Formats.h:145
size_t coordToOffset(size_t i, size_t j, size_t k) const
Return the linear offset into this grid&#39;s value array given by unsigned coordinates (i...
Definition: Dense.h:162
Dense(const CoordBBox &bbox, const ValueT &value)
Construct a dense grid with a given range of coordinates and initial value.
Definition: Dense.h:230
OPENVDB_API int printBytes(std::ostream &os, uint64_t bytes, const std::string &head="", const std::string &tail="\n", bool exact=false, int width=8, int precision=3)
Vec2< T > minComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise minimum of the two vectors.
Definition: Vec2.h:530
_TreeT TreeT
Definition: Dense.h:475
Definition: Exceptions.h:92
CopyFromDense(const DenseT &dense, TreeT &tree, const ValueT &tolerance)
Definition: Dense.h:480
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition: Grid.h:1076
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:180
size_t yStride() const
Return the stride of the array in the y direction ( = dimX).
Definition: Dense.h:182
Dense is a simple dense grid API used by the CopyToDense and CopyFromDense classes defined below...
Definition: Dense.h:209
DenseBase(const CoordBBox &bbox)
Protected constructor so as to prevent direct instantiation.
Definition: Dense.h:190
static size_t xStride()
Return the stride of the array in the x direction ( = 1).
Definition: Dense.h:178
Copy an OpenVDB tree into an existing dense grid.
Definition: Dense.h:414
ValueT & getValue(size_t offset)
Return a non-const reference to the value of the voxel at the given array offset. ...
Definition: Dense.h:293
Dense(const Coord &dim, const Coord &min=Coord(0))
Construct a dense grid with a given origin and dimensions.
Definition: Dense.h:259