OpenVDB 7.0.0

Dense.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
8
9 #ifndef OPENVDB_TOOLS_DENSE_HAS_BEEN_INCLUDED
10 #define OPENVDB_TOOLS_DENSE_HAS_BEEN_INCLUDED
11
12 #include <openvdb/Types.h>
13 #include <openvdb/Grid.h>
14 #include <openvdb/tree/ValueAccessor.h>
15 #include <openvdb/Exceptions.h>
16 #include <openvdb/util/Formats.h>
17 #include "Prune.h"
18 #include <tbb/parallel_for.h>
19 #include <iostream>
20 #include <memory>
21 #include <string>
22 #include <utility> // for std::pair
23 #include <vector>
24
25 namespace openvdb {
26 OPENVDB_USE_VERSION_NAMESPACE
27 namespace OPENVDB_VERSION_NAME {
28 namespace tools {
29
35 template<typename DenseT, typename GridOrTreeT>
36 void
37 copyToDense(
38 const GridOrTreeT& sparse,
39 DenseT& dense,
40 bool serial = false);
41
42
49 template<typename DenseT, typename GridOrTreeT>
50 void
51 copyFromDense(
52 const DenseT& dense,
53 GridOrTreeT& sparse,
54 const typename GridOrTreeT::ValueType& tolerance,
55 bool serial = false);
56
57
59
68 enum MemoryLayout { LayoutXYZ, LayoutZYX };
69
73 template<typename ValueT, MemoryLayout Layout> class DenseBase;
74
78 template<typename ValueT>
79 class DenseBase<ValueT, LayoutZYX>
80 {
81 public:
88 inline size_t coordToOffset(size_t i, size_t j, size_t k) const { return i*mX + j*mY + k; }
89
94 inline Coord offsetToLocalCoord(size_t n) const
95 {
96 const size_t x = n / mX;
97 n -= mX*x;
98 const size_t y = n / mY;
99 return Coord(Coord::ValueType(x), Coord::ValueType(y), Coord::ValueType(n - mY*y));
100 }
101
104 inline size_t xStride() const { return mX; }
105
108 inline size_t yStride() const { return mY; }
109
112 static size_t zStride() { return 1; }
113
114 protected:
116 DenseBase(const CoordBBox& bbox) : mBBox(bbox), mY(bbox.dim()[2]), mX(mY*bbox.dim()[1]) {}
117
118 const CoordBBox mBBox;//signed coordinates of the domain represented by the grid
119 const size_t mY, mX;//strides in the y and x direction
120 };// end of DenseBase<ValueT, LayoutZYX>
121
125 template<typename ValueT>
126 class DenseBase<ValueT, LayoutXYZ>
127 {
128 public:
135 inline size_t coordToOffset(size_t i, size_t j, size_t k) const { return i + j*mY + k*mZ; }
136
141 inline Coord offsetToLocalCoord(size_t n) const
142 {
143 const size_t z = n / mZ;
144 n -= mZ*z;
145 const size_t y = n / mY;
146 return Coord(Coord::ValueType(n - mY*y), Coord::ValueType(y), Coord::ValueType(z));
147 }
148
151 static size_t xStride() { return 1; }
152
155 inline size_t yStride() const { return mY; }
156
159 inline size_t zStride() const { return mZ; }
160
161 protected:
163 DenseBase(const CoordBBox& bbox) : mBBox(bbox), mY(bbox.dim()[0]), mZ(mY*bbox.dim()[1]) {}
164
165 const CoordBBox mBBox;//signed coordinates of the domain represented by the grid
166 const size_t mY, mZ;//strides in the y and z direction
167 };// end of DenseBase<ValueT, LayoutXYZ>
168
181 template<typename ValueT, MemoryLayout Layout = LayoutZYX>
182 class Dense : public DenseBase<ValueT, Layout>
183 {
184 public:
185 using ValueType = ValueT;
186 using BaseT = DenseBase<ValueT, Layout>;
187 using Ptr = SharedPtr<Dense>;
188 using ConstPtr = SharedPtr<const Dense>;
189
195 Dense(const CoordBBox& bbox) : BaseT(bbox) { this->init(); }
196
203 Dense(const CoordBBox& bbox, const ValueT& value) : BaseT(bbox)
204 {
205 this->init();
206 this->fill(value);
207 }
208
218 Dense(const CoordBBox& bbox, ValueT* data) : BaseT(bbox), mData(data)
219 {
220 if (BaseT::mBBox.empty()) {
221 OPENVDB_THROW(ValueError, "can't construct a dense grid with an empty bounding box");
222 }
223 }
224
232 Dense(const Coord& dim, const Coord& min = Coord(0))
233 : BaseT(CoordBBox(min, min+dim.offsetBy(-1)))
234 {
235 this->init();
236 }
237
239 static MemoryLayout memoryLayout() { return Layout; }
240
243 inline ValueT* data() { return mData; }
244
247 inline const ValueT* data() const { return mData; }
248
251 inline const CoordBBox& bbox() const { return BaseT::mBBox; }
252
254 inline const Coord& origin() const { return BaseT::mBBox.min(); }
255
257 inline Index64 valueCount() const { return BaseT::mBBox.volume(); }
258
260 inline void setValue(size_t offset, const ValueT& value) { mData[offset] = value; }
261
263 const ValueT& getValue(size_t offset) const { return mData[offset]; }
264
266 ValueT& getValue(size_t offset) { return mData[offset]; }
267
270 inline void setValue(size_t i, size_t j, size_t k, const ValueT& value)
271 {
272 mData[BaseT::coordToOffset(i,j,k)] = value;
273 }
274
278 inline const ValueT& getValue(size_t i, size_t j, size_t k) const
279 {
280 return mData[BaseT::coordToOffset(i,j,k)];
281 }
282
286 inline ValueT& getValue(size_t i, size_t j, size_t k)
287 {
288 return mData[BaseT::coordToOffset(i,j,k)];
289 }
290
293 inline void setValue(const Coord& xyz, const ValueT& value)
294 {
295 mData[this->coordToOffset(xyz)] = value;
296 }
297
300 inline const ValueT& getValue(const Coord& xyz) const
301 {
302 return mData[this->coordToOffset(xyz)];
303 }
304
308 inline ValueT& getValue(const Coord& xyz)
309 {
310 return mData[this->coordToOffset(xyz)];
311 }
312
314 inline void fill(const ValueT& value)
315 {
316 size_t size = this->valueCount();
317 ValueT* a = mData;
318 while(size--) *a++ = value;
319 }
320
327 inline size_t coordToOffset(const Coord& xyz) const
328 {
329 assert(BaseT::mBBox.isInside(xyz));
330 return BaseT::coordToOffset(size_t(xyz[0]-BaseT::mBBox.min()[0]),
331 size_t(xyz[1]-BaseT::mBBox.min()[1]),
332 size_t(xyz[2]-BaseT::mBBox.min()[2]));
333 }
334
336 inline Coord offsetToCoord(size_t n) const
337 {
338 return this->offsetToLocalCoord(n) + BaseT::mBBox.min();
339 }
340
342 inline Index64 memUsage() const
343 {
344 return sizeof(*this) + BaseT::mBBox.volume() * sizeof(ValueType);
345 }
346
349 void print(const std::string& name = "", std::ostream& os = std::cout) const
350 {
351 const Coord dim = BaseT::mBBox.dim();
352 os << "Dense Grid";
353 if (!name.empty()) os << " \"" << name << "\"";
354 util::printBytes(os, this->memUsage(), ":\n Memory footprint: ");
355 os << " Dimensions of grid : " << dim[0] << " x " << dim[1] << " x " << dim[2] << "\n";
356 os << " Number of voxels: " << util::formattedInt(this->valueCount()) << "\n";
357 os << " Bounding box of voxels: " << BaseT::mBBox << "\n";
358 os << " Memory layout: " << (Layout == LayoutZYX ? "ZYX (" : "XYZ (dis")
359 << "similar to VDB)\n";
360 }
361
362 private:
364 void init()
365 {
366 if (BaseT::mBBox.empty()) {
367 OPENVDB_THROW(ValueError, "can't construct a dense grid with an empty bounding box");
368 }
369 mArray.reset(new ValueT[BaseT::mBBox.volume()]);
370 mData = mArray.get();
371 }
372
373 std::unique_ptr<ValueT[]> mArray;
374 ValueT* mData;//raw c-style pointer to values
375 };// end of Dense
376
378
379
386 template<typename _TreeT, typename _DenseT = Dense<typename _TreeT::ValueType> >
387 class CopyToDense
388 {
389 public:
390 using DenseT = _DenseT;
391 using TreeT = _TreeT;
392 using ValueT = typename TreeT::ValueType;
393
394 CopyToDense(const TreeT& tree, DenseT& dense)
395 : mRoot(&(tree.root())), mDense(&dense) {}
396
397 void copy(bool serial = false) const
398 {
399 if (serial) {
400 mRoot->copyToDense(mDense->bbox(), *mDense);
401 } else {
402 tbb::parallel_for(mDense->bbox(), *this);
403 }
404 }
405
407 void operator()(const CoordBBox& bbox) const
408 {
409 mRoot->copyToDense(bbox, *mDense);
410 }
411
412 private:
413 const typename TreeT::RootNodeType* mRoot;
414 DenseT* mDense;
415 };// CopyToDense
416
417
418 // Convenient wrapper function for the CopyToDense class
419 template<typename DenseT, typename GridOrTreeT>
420 void
421 copyToDense(const GridOrTreeT& sparse, DenseT& dense, bool serial)
422 {
423 using Adapter = TreeAdapter<GridOrTreeT>;
424 using TreeT = typename Adapter::TreeType;
425
426 CopyToDense<TreeT, DenseT> op(Adapter::constTree(sparse), dense);
427 op.copy(serial);
428 }
429
430
432
433
443 template<typename _TreeT, typename _DenseT = Dense<typename _TreeT::ValueType> >
444 class CopyFromDense
445 {
446 public:
447 using DenseT = _DenseT;
448 using TreeT = _TreeT;
449 using ValueT = typename TreeT::ValueType;
450 using LeafT = typename TreeT::LeafNodeType;
451 using AccessorT = tree::ValueAccessor<TreeT>;
452
453 CopyFromDense(const DenseT& dense, TreeT& tree, const ValueT& tolerance)
454 : mDense(&dense),
455 mTree(&tree),
456 mBlocks(nullptr),
457 mTolerance(tolerance),
458 mAccessor(tree.empty() ? nullptr : new AccessorT(tree))
459 {
460 }
461 CopyFromDense(const CopyFromDense& other)
462 : mDense(other.mDense),
463 mTree(other.mTree),
464 mBlocks(other.mBlocks),
465 mTolerance(other.mTolerance),
466 mAccessor(other.mAccessor.get() == nullptr ? nullptr : new AccessorT(*mTree))
467 {
468 }
469
471 void copy(bool serial = false)
472 {
473 mBlocks = new std::vector<Block>();
474 const CoordBBox& bbox = mDense->bbox();
475 // Pre-process: Construct a list of blocks aligned with (potential) leaf nodes
476 for (CoordBBox sub=bbox; sub.min()[0] <= bbox.max()[0]; sub.min()[0] = sub.max()[0] + 1) {
477 for (sub.min()[1] = bbox.min()[1]; sub.min()[1] <= bbox.max()[1];
478 sub.min()[1] = sub.max()[1] + 1)
479 {
480 for (sub.min()[2] = bbox.min()[2]; sub.min()[2] <= bbox.max()[2];
481 sub.min()[2] = sub.max()[2] + 1)
482 {
483 sub.max() = Coord::minComponent(bbox.max(),
484 (sub.min()&(~(LeafT::DIM-1u))).offsetBy(LeafT::DIM-1u));
485 mBlocks->push_back(Block(sub));
486 }
487 }
488 }
489
490 // Multi-threaded process: Convert dense grid into leaf nodes and tiles
491 if (serial) {
492 (*this)(tbb::blocked_range<size_t>(0, mBlocks->size()));
493 } else {
494 tbb::parallel_for(tbb::blocked_range<size_t>(0, mBlocks->size()), *this);
495 }
496
497 // Post-process: Insert leaf nodes and tiles into the tree, and prune the tiles only!
498 tree::ValueAccessor<TreeT> acc(*mTree);
499 for (size_t m=0, size = mBlocks->size(); m<size; ++m) {
500 Block& block = (*mBlocks)[m];
501 if (block.leaf) {
502 acc.addLeaf(block.leaf);
503 } else if (block.tile.second) {//only background tiles are inactive
504 acc.addTile(1, block.bbox.min(), block.tile.first, true);//leaf tile
505 }
506 }
507 delete mBlocks;
508 mBlocks = nullptr;
509
510 tools::pruneTiles(*mTree, mTolerance);//multi-threaded
511 }
512
515 void operator()(const tbb::blocked_range<size_t> &r) const
516 {
517 assert(mBlocks);
518 LeafT* leaf = new LeafT();
519
520 for (size_t m=r.begin(), n=0, end = r.end(); m != end; ++m, ++n) {
521
522 Block& block = (*mBlocks)[m];
523 const CoordBBox &bbox = block.bbox;
524
525 if (mAccessor.get() == nullptr) {//i.e. empty target tree
526 leaf->fill(mTree->background(), false);
527 } else {//account for existing leaf nodes in the target tree
528 if (const LeafT* target = mAccessor->probeConstLeaf(bbox.min())) {
529 (*leaf) = (*target);
530 } else {
531 ValueT value = zeroVal<ValueT>();
532 bool state = mAccessor->probeValue(bbox.min(), value);
533 leaf->fill(value, state);
534 }
535 }
536
537 leaf->copyFromDense(bbox, *mDense, mTree->background(), mTolerance);
538
539 if (!leaf->isConstant(block.tile.first, block.tile.second, mTolerance)) {
540 leaf->setOrigin(bbox.min() & (~(LeafT::DIM - 1)));
541 block.leaf = leaf;
542 leaf = new LeafT();
543 }
544 }// loop over blocks
545
546 delete leaf;
547 }
548
549 private:
550 struct Block {
551 CoordBBox bbox;
552 LeafT* leaf;
553 std::pair<ValueT, bool> tile;
554 Block(const CoordBBox& b) : bbox(b), leaf(nullptr) {}
555 };
556
557 const DenseT* mDense;
558 TreeT* mTree;
559 std::vector<Block>* mBlocks;
560 ValueT mTolerance;
561 std::unique_ptr<AccessorT> mAccessor;
562 };// CopyFromDense
563
564
565 // Convenient wrapper function for the CopyFromDense class
566 template<typename DenseT, typename GridOrTreeT>
567 void
568 copyFromDense(const DenseT& dense, GridOrTreeT& sparse,
569 const typename GridOrTreeT::ValueType& tolerance, bool serial)
570 {
571 using Adapter = TreeAdapter<GridOrTreeT>;
572 using TreeT = typename Adapter::TreeType;
573
574 CopyFromDense<TreeT, DenseT> op(dense, Adapter::tree(sparse), tolerance);
575 op.copy(serial);
576 }
577
578 } // namespace tools
579 } // namespace OPENVDB_VERSION_NAME
580 } // namespace openvdb
581
582 #endif // OPENVDB_TOOLS_DENSE_HAS_BEEN_INCLUDED
openvdb::v7_0::tools::Dense::getValue
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:300
openvdb::v7_0::tools::CopyToDense::DenseT
_DenseT DenseT
Definition: Dense.h:390
openvdb::v7_0::tools::Dense::setValue
void setValue(size_t offset, const ValueT &value)
Set the value of the voxel at the given array offset.
Definition: Dense.h:260
openvdb::v7_0::tools::CopyFromDense::DenseT
_DenseT DenseT
Definition: Dense.h:447
openvdb::v7_0::tools::DenseBase< ValueT, LayoutXYZ >::coordToOffset
size_t coordToOffset(size_t i, size_t j, size_t k) const
Return the linear offset into this grid's value array given by unsigned coordinates (i,...
Definition: Dense.h:135
openvdb::v7_0::tools::CopyFromDense::LeafT
typename TreeT::LeafNodeType LeafT
Definition: Dense.h:450
openvdb::v7_0::util::printBytes
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)
openvdb::v7_0::tools::Dense::offsetToCoord
Coord offsetToCoord(size_t n) const
Return the global coordinate corresponding to the specified linear offset.
Definition: Dense.h:336
openvdb::v7_0::tools::Dense::origin
const Coord & origin() const
Return the grid's origin in index coordinates.
Definition: Dense.h:254
Types.h
openvdb::v7_0::tools::DenseBase< ValueT, LayoutXYZ >::DenseBase
DenseBase(const CoordBBox &bbox)
Protected constructor so as to prevent direct instantiation.
Definition: Dense.h:163
openvdb::v7_0::tools::DenseBase< ValueT, LayoutZYX >::zStride
static size_t zStride()
Return the stride of the array in the z direction ( = 1).
Definition: Dense.h:112
openvdb::v7_0::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:25
openvdb::v7_0::math::Coord::ValueType
Int32 ValueType
Definition: Coord.h:33
openvdb::v7_0::tools::CopyFromDense::copy
void copy(bool serial=false)
Copy values from the dense grid to the sparse tree.
Definition: Dense.h:471
openvdb::v7_0::tools::copyToDense
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:421
openvdb::v7_0::tools::Dense::Ptr
SharedPtr< Dense > Ptr
Definition: Dense.h:187
openvdb::v7_0::tools::Dense::data
ValueT * data()
Return a raw pointer to this grid's value array.
Definition: Dense.h:243
openvdb::v7_0::tools::LayoutXYZ
Definition: Dense.h:68
openvdb::v7_0::tools::Dense::print
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:349
openvdb::v7_0::tools::Dense::Dense
Dense(const CoordBBox &bbox)
Construct a dense grid with a given range of coordinates.
Definition: Dense.h:195
openvdb::v7_0::tools::DenseBase< ValueT, LayoutZYX >::DenseBase
DenseBase(const CoordBBox &bbox)
Protected constructor so as to prevent direct instantiation.
Definition: Dense.h:116
openvdb::v7_0::tools::copyFromDense
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:568
openvdb::v7_0::tools::Dense::Dense
Dense(const CoordBBox &bbox, const ValueT &value)
Construct a dense grid with a given range of coordinates and initial value.
Definition: Dense.h:203
openvdb::v7_0::tree::ValueAccessor< TreeT >
openvdb::v7_0::tools::Dense::setValue
void setValue(const Coord &xyz, const ValueT &value)
Set the value of the voxel at the given signed coordinates.
Definition: Dense.h:293
openvdb::v7_0::tools::Dense::getValue
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,...
Definition: Dense.h:278
openvdb::v7_0::tools::Dense::memUsage
Index64 memUsage() const
Return the memory footprint of this Dense grid in bytes.
Definition: Dense.h:342
openvdb::v7_0::util::formattedInt
FormattedInt< IntT > formattedInt(IntT n)
Definition: Formats.h:118
openvdb::v7_0::tools::CopyFromDense::CopyFromDense
CopyFromDense(const DenseT &dense, TreeT &tree, const ValueT &tolerance)
Definition: Dense.h:453
openvdb::v7_0::tools::LayoutZYX
Definition: Dense.h:68
openvdb::v7_0::tools::pruneTiles
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:344
Grid.h
openvdb::v7_0::SharedPtr
std::shared_ptr< T > SharedPtr
Definition: Types.h:91
openvdb::v7_0::tools::Dense::Dense
Dense(const CoordBBox &bbox, ValueT *data)
Construct a dense grid that wraps an external array.
Definition: Dense.h:218
openvdb::v7_0::tools::CopyFromDense::ValueT
typename TreeT::ValueType ValueT
Definition: Dense.h:449
ValueAccessor.h
openvdb::v7_0::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:248
openvdb::v7_0::tools::DenseBase< ValueT, LayoutXYZ >::mBBox
const CoordBBox mBBox
Definition: Dense.h:165
Formats.h
Utility routines to output nicely-formatted numeric values.
openvdb::v7_0::tools::DenseBase< ValueT, LayoutZYX >::mBBox
const CoordBBox mBBox
Definition: Dense.h:118
openvdb::v7_0::tree::ValueAccessor::addTile
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:348
openvdb::v7_0::tools::Dense::bbox
const CoordBBox & bbox() const
Return the bounding box of the signed index domain of this grid.
Definition: Dense.h:251
openvdb::v7_0::tools::DenseBase< ValueT, LayoutZYX >::coordToOffset
size_t coordToOffset(size_t i, size_t j, size_t k) const
Return the linear offset into this grid's value array given by unsigned coordinates (i,...
Definition: Dense.h:88
openvdb::v7_0::tools::CopyToDense
Copy an OpenVDB tree into an existing dense grid.
Definition: Dense.h:387
openvdb::v7_0::tools::Dense::getValue
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:263
openvdb::v7_0::tools::Dense::getValue
ValueT & getValue(size_t offset)
Return a non-const reference to the value of the voxel at the given array offset.
Definition: Dense.h:266
openvdb::v7_0::tools::CopyToDense::operator()
void operator()(const CoordBBox &bbox) const
Public method called by tbb::parallel_for.
Definition: Dense.h:407
openvdb::v7_0::tools::Dense::memoryLayout
static MemoryLayout memoryLayout()
Return the memory layout for this grid (see above for definitions).
Definition: Dense.h:239
Prune.h
Defined various multi-threaded utility functions for trees.
openvdb::v7_0::tools::CopyToDense::TreeT
_TreeT TreeT
Definition: Dense.h:391
openvdb::v7_0::tools::Dense::fill
void fill(const ValueT &value)
Fill this grid with a constant value.
Definition: Dense.h:314
openvdb::v7_0::tools::CopyFromDense::CopyFromDense
CopyFromDense(const CopyFromDense &other)
Definition: Dense.h:461
openvdb::v7_0::tools::DenseBase< ValueT, LayoutZYX >::offsetToLocalCoord
Coord offsetToLocalCoord(size_t n) const
Return the local coordinate corresponding to the specified linear offset.
Definition: Dense.h:94
openvdb::v7_0::tools::DenseBase< ValueT, LayoutZYX >::xStride
size_t xStride() const
Return the stride of the array in the x direction ( = dimY*dimZ).
Definition: Dense.h:104
openvdb::v7_0::tools::Dense::Dense
Dense(const Coord &dim, const Coord &min=Coord(0))
Construct a dense grid with a given origin and dimensions.
Definition: Dense.h:232
openvdb::v7_0::math::CoordBBox::max
const Coord & max() const
Definition: Coord.h:322
openvdb::v7_0::tools::Dense::ConstPtr
SharedPtr< const Dense > ConstPtr
Definition: Dense.h:188
openvdb::v7_0::math::Coord::max
static Coord max()
Return the largest possible coordinate.
Definition: Coord.h:47
openvdb::v7_0::math::CoordBBox::min
const Coord & min() const
Definition: Coord.h:321
openvdb::v7_0::tools::MemoryLayout
MemoryLayout
Definition: Dense.h:68
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:154
openvdb::v7_0::tools::Dense::coordToOffset
size_t coordToOffset(const Coord &xyz) const
Return the linear offset into this grid's value array given by the specified signed coordinates,...
Definition: Dense.h:327
openvdb::v7_0::TreeAdapter
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition: Grid.h:1065
openvdb::v7_0::tools::DenseBase< ValueT, LayoutZYX >::yStride
size_t yStride() const
Return the stride of the array in the y direction ( = dimZ).
Definition: Dense.h:108
openvdb::v7_0::tools::Dense::getValue
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:286
openvdb::v7_0::math::Coord::min
static Coord min()
Return the smallest possible coordinate.
Definition: Coord.h:44
openvdb::v7_0::tools::Dense::getValue
ValueT & getValue(const Coord &xyz)
Return a non-const reference to the value of the voxel at the given signed coordinates.
Definition: Dense.h:308
openvdb::v7_0::tree::ValueAccessor::addLeaf
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process....
Definition: ValueAccessor.h:340
openvdb::v7_0::tools::composite::min
const std::enable_if<!VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:102
openvdb::v7_0::tools::CopyToDense::CopyToDense
CopyToDense(const TreeT &tree, DenseT &dense)
Definition: Dense.h:394
openvdb::v7_0::tools::CopyFromDense
Copy the values from a dense grid into an OpenVDB tree.
Definition: Dense.h:444
openvdb::v7_0::tools::DenseBase< ValueT, LayoutZYX >::mY
const size_t mY
Definition: Dense.h:119
openvdb::v7_0::tools::Dense::data
const ValueT * data() const
Return a raw pointer to this grid's value array.
Definition: Dense.h:247
openvdb::v7_0::tools::DenseBase< ValueT, LayoutXYZ >::mZ
const size_t mZ
Definition: Dense.h:166
openvdb::v7_0::tools::CopyToDense::copy
void copy(bool serial=false) const
Definition: Dense.h:397
openvdb::v7_0::tools::DenseBase< ValueT, LayoutXYZ >::offsetToLocalCoord
Coord offsetToLocalCoord(size_t n) const
Return the index coordinate corresponding to the specified linear offset.
Definition: Dense.h:141
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:102
openvdb::v7_0::tools::Dense
Dense is a simple dense grid API used by the CopyToDense and CopyFromDense classes defined below.
Definition: Dense.h:182
openvdb::v7_0::tools::DenseBase< ValueT, LayoutXYZ >::yStride
size_t yStride() const
Return the stride of the array in the y direction ( = dimX).
Definition: Dense.h:155
openvdb::v7_0::tools::DenseBase< ValueT, LayoutXYZ >::xStride
static size_t xStride()
Return the stride of the array in the x direction ( = 1).
Definition: Dense.h:151
openvdb::v7_0::tools::CopyToDense::ValueT
typename TreeT::ValueType ValueT
Definition: Dense.h:392
openvdb::v7_0::ValueError
Definition: Exceptions.h:65
openvdb::v7_0::math::Coord::minComponent
void minComponent(const Coord &other)
Perform a component-wise minimum with the other Coord.
Definition: Coord.h:176
openvdb
Definition: Exceptions.h:13
openvdb::v7_0::Index64
uint64_t Index64
Definition: Types.h:30
openvdb::v7_0::tools::CopyFromDense::operator()
void operator()(const tbb::blocked_range< size_t > &r) const
Public method called by tbb::parallel_for.
Definition: Dense.h:515
openvdb::v7_0::tools::Dense::valueCount
Index64 valueCount() const
Return the number of voxels contained in this grid.
Definition: Dense.h:257
openvdb::v7_0::tools::DenseBase< ValueT, LayoutXYZ >::zStride
size_t zStride() const
Return the stride of the array in the y direction ( = dimX*dimY).
Definition: Dense.h:159
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:82
Exceptions.h
openvdb::v7_0::tools::Dense::setValue
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:270
openvdb::v7_0::tools::Dense::ValueType
ValueT ValueType
Definition: Dense.h:185
openvdb::v7_0::tools::DenseBase
Base class for Dense which is defined below.
Definition: Dense.h:73
openvdb::v7_0::tools::CopyFromDense::TreeT
_TreeT TreeT
Definition: Dense.h:448