OpenVDB 3.2.0

Dense.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2016 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>
41 #include <openvdb/tree/ValueAccessor.h>
42 #include <openvdb/Exceptions.h>
43 #include <openvdb/util/Formats.h>
44 #include <tbb/parallel_for.h>
45 #include <boost/scoped_array.hpp>
46 #include <boost/scoped_ptr.hpp>
47 #include "Prune.h"
48
49 namespace openvdb {
50 OPENVDB_USE_VERSION_NAMESPACE
51 namespace OPENVDB_VERSION_NAME {
52 namespace tools {
53
59 template<typename DenseT, typename GridOrTreeT>
60 void
61 copyToDense(
62 const GridOrTreeT& sparse,
63 DenseT& dense,
64 bool serial = false);
65
66
73 template<typename DenseT, typename GridOrTreeT>
74 void
75 copyFromDense(
76 const DenseT& dense,
77 GridOrTreeT& sparse,
78 const typename GridOrTreeT::ValueType& tolerance,
79 bool serial = false);
80
81
83
92 enum MemoryLayout { LayoutXYZ, LayoutZYX };
93
97 template<typename ValueT, MemoryLayout Layout> class DenseBase;
98
102 template<typename ValueT>
103 class DenseBase<ValueT, LayoutZYX>
104 {
105 public:
112 inline size_t coordToOffset(size_t i, size_t j, size_t k) const { return i*mX + j*mY + k; }
113
118 inline Coord offsetToLocalCoord(size_t n) const
119 {
120 const size_t x = n / mX;
121 n -= mX*x;
122 const size_t y = n / mY;
123 return Coord(Coord::ValueType(x), Coord::ValueType(y), Coord::ValueType(n - mY*y));
124 }
125
128 inline size_t xStride() const { return mX; }
129
132 inline size_t yStride() const { return mY; }
133
136 static size_t zStride() { return 1; }
137
138 protected:
140 DenseBase(const CoordBBox& bbox) : mBBox(bbox), mY(bbox.dim()[2]), mX(mY*bbox.dim()[1]) {}
141
142 const CoordBBox mBBox;//signed coordinates of the domain represented by the grid
143 const size_t mY, mX;//strides in the y and x direction
144 };// end of DenseBase<ValueT, LayoutZYX>
145
149 template<typename ValueT>
150 class DenseBase<ValueT, LayoutXYZ>
151 {
152 public:
159 inline size_t coordToOffset(size_t i, size_t j, size_t k) const { return i + j*mY + k*mZ; }
160
165 inline Coord offsetToLocalCoord(size_t n) const
166 {
167 const size_t z = n / mZ;
168 n -= mZ*z;
169 const size_t y = n / mY;
170 return Coord(Coord::ValueType(n - mY*y), Coord::ValueType(y), Coord::ValueType(z));
171 }
172
175 static size_t xStride() { return 1; }
176
179 inline size_t yStride() const { return mY; }
180
183 inline size_t zStride() const { return mZ; }
184
185 protected:
187 DenseBase(const CoordBBox& bbox) : mBBox(bbox), mY(bbox.dim()[0]), mZ(mY*bbox.dim()[1]) {}
188
189 const CoordBBox mBBox;//signed coordinates of the domain represented by the grid
190 const size_t mY, mZ;//strides in the y and z direction
191 };// end of DenseBase<ValueT, LayoutXYZ>
192
205 template<typename ValueT, MemoryLayout Layout = LayoutZYX>
206 class Dense : public DenseBase<ValueT, Layout>
207 {
208 public:
209 typedef ValueT ValueType;
210 typedef DenseBase<ValueT, Layout> BaseT;
211 typedef boost::shared_ptr<Dense> Ptr;
212 typedef boost::shared_ptr<const Dense> ConstPtr;
213
219 Dense(const CoordBBox& bbox) : BaseT(bbox) { this->init(); }
220
227 Dense(const CoordBBox& bbox, const ValueT& value) : BaseT(bbox)
228 {
229 this->init();
230 this->fill(value);
231 }
232
242 Dense(const CoordBBox& bbox, ValueT* data) : BaseT(bbox), mData(data)
243 {
244 if (BaseT::mBBox.empty()) {
245 OPENVDB_THROW(ValueError, "can't construct a dense grid with an empty bounding box");
246 }
247 }
248
256 Dense(const Coord& dim, const Coord& min = Coord(0))
257 : BaseT(CoordBBox(min, min+dim.offsetBy(-1)))
258 {
259 this->init();
260 }
261
263 static MemoryLayout memoryLayout() { return Layout; }
264
267 inline ValueT* data() { return mData; }
268
271 inline const ValueT* data() const { return mData; }
272
275 inline const CoordBBox& bbox() const { return BaseT::mBBox; }
276
278 inline const Coord& origin() const { return BaseT::mBBox.min(); }
279
281 inline Index64 valueCount() const { return BaseT::mBBox.volume(); }
282
284 inline void setValue(size_t offset, const ValueT& value) { mData[offset] = value; }
285
287 const ValueT& getValue(size_t offset) const { return mData[offset]; }
288
290 ValueT& getValue(size_t offset) { return mData[offset]; }
291
294 inline void setValue(size_t i, size_t j, size_t k, const ValueT& value)
295 {
296 mData[BaseT::coordToOffset(i,j,k)] = value;
297 }
298
301 inline const ValueT& getValue(size_t i, size_t j, size_t k) const
302 {
303 return mData[BaseT::coordToOffset(i,j,k)];
304 }
305
308 inline ValueT& getValue(size_t i, size_t j, size_t k)
309 {
310 return mData[BaseT::coordToOffset(i,j,k)];
311 }
312
315 inline void setValue(const Coord& xyz, const ValueT& value)
316 {
317 mData[this->coordToOffset(xyz)] = value;
318 }
319
322 inline const ValueT& getValue(const Coord& xyz) const
323 {
324 return mData[this->coordToOffset(xyz)];
325 }
326
329 inline ValueT& getValue(const Coord& xyz)
330 {
331 return mData[this->coordToOffset(xyz)];
332 }
333
335 inline void fill(const ValueT& value)
336 {
337 size_t size = this->valueCount();
338 ValueT* a = mData;
339 while(size--) *a++ = value;
340 }
341
348 inline size_t coordToOffset(const Coord& xyz) const
349 {
350 assert(BaseT::mBBox.isInside(xyz));
351 return BaseT::coordToOffset(size_t(xyz[0]-BaseT::mBBox.min()[0]),
352 size_t(xyz[1]-BaseT::mBBox.min()[1]),
353 size_t(xyz[2]-BaseT::mBBox.min()[2]));
354 }
355
357 inline Coord offsetToCoord(size_t n) const
358 {
359 return this->offsetToLocalCoord(n) + BaseT::mBBox.min();
360 }
361
363 inline Index64 memUsage() const
364 {
365 return sizeof(*this) + BaseT::mBBox.volume() * sizeof(ValueType);
366 }
367
370 void print(const std::string& name = "", std::ostream& os = std::cout) const
371 {
372 const Coord dim = BaseT::mBBox.dim();
373 os << "Dense Grid";
374 if (!name.empty()) os << " \"" << name << "\"";
375 util::printBytes(os, this->memUsage(), ":\n Memory footprint: ");
376 os << " Dimensions of grid : " << dim[0] << " x " << dim[1] << " x " << dim[2] << "\n";
377 os << " Number of voxels: " << util::formattedInt(this->valueCount()) << "\n";
378 os << " Bounding box of voxels: " << BaseT::mBBox << "\n";
379 os << " Memory layout: " << (Layout == LayoutZYX ? "ZYX (" : "XYZ (dis")
380 << "similar to VDB)\n";
381 }
382
383 private:
384
386 void init()
387 {
388 if (BaseT::mBBox.empty()) {
389 OPENVDB_THROW(ValueError, "can't construct a dense grid with an empty bounding box");
390 }
391 mArray.reset(new ValueT[BaseT::mBBox.volume()]);
392 mData = mArray.get();
393 }
394
395 boost::scoped_array<ValueT> mArray;
396 ValueT* mData;//raw c-style pointer to values
397 };// end of Dense
398
400
401
408 template<typename _TreeT, typename _DenseT = Dense<typename _TreeT::ValueType> >
409 class CopyToDense
410 {
411 public:
412 typedef _DenseT DenseT;
413 typedef _TreeT TreeT;
414 typedef typename TreeT::ValueType ValueT;
415
416 CopyToDense(const TreeT& tree, DenseT& dense)
417 : mRoot(&(tree.root())), mDense(&dense) {}
418
419 void copy(bool serial = false) const
420 {
421 if (serial) {
422 mRoot->copyToDense(mDense->bbox(), *mDense);
423 } else {
424 tbb::parallel_for(mDense->bbox(), *this);
425 }
426 }
427
429 void operator()(const CoordBBox& bbox) const
430 {
431 mRoot->copyToDense(bbox, *mDense);
432 }
433
434 private:
435 const typename TreeT::RootNodeType* mRoot;
436 DenseT* mDense;
437 };// CopyToDense
438
439
440 // Convenient wrapper function for the CopyToDense class
441 template<typename DenseT, typename GridOrTreeT>
442 void
443 copyToDense(const GridOrTreeT& sparse, DenseT& dense, bool serial)
444 {
445 typedef TreeAdapter<GridOrTreeT> Adapter;
446 typedef typename Adapter::TreeType TreeT;
447
448 CopyToDense<TreeT, DenseT> op(Adapter::constTree(sparse), dense);
449 op.copy(serial);
450 }
451
452
454
455
465 template<typename _TreeT, typename _DenseT = Dense<typename _TreeT::ValueType> >
466 class CopyFromDense
467 {
468 public:
469 typedef _DenseT DenseT;
470 typedef _TreeT TreeT;
471 typedef typename TreeT::ValueType ValueT;
472 typedef typename TreeT::LeafNodeType LeafT;
473 typedef tree::ValueAccessor<TreeT> AccessorT;
474
475 CopyFromDense(const DenseT& dense, TreeT& tree, const ValueT& tolerance)
476 : mDense(&dense),
477 mTree(&tree),
478 mBlocks(NULL),
479 mTolerance(tolerance),
480 mAccessor(tree.empty() ? NULL : new AccessorT(tree))
481 {
482 }
483 CopyFromDense(const CopyFromDense& other)
484 : mDense(other.mDense),
485 mTree(other.mTree),
486 mBlocks(other.mBlocks),
487 mTolerance(other.mTolerance),
488 mAccessor(other.mAccessor.get() == NULL ? NULL : new AccessorT(*mTree))
489 {
490 }
491
493 void copy(bool serial = false)
494 {
495 mBlocks = new std::vector<Block>();
496 const CoordBBox& bbox = mDense->bbox();
497 // Pre-process: Construct a list of blocks aligned with (potential) leaf nodes
498 for (CoordBBox sub=bbox; sub.min()[0] <= bbox.max()[0]; sub.min()[0] = sub.max()[0] + 1) {
499 for (sub.min()[1] = bbox.min()[1]; sub.min()[1] <= bbox.max()[1];
500 sub.min()[1] = sub.max()[1] + 1)
501 {
502 for (sub.min()[2] = bbox.min()[2]; sub.min()[2] <= bbox.max()[2];
503 sub.min()[2] = sub.max()[2] + 1)
504 {
505 sub.max() = Coord::minComponent(bbox.max(),
506 (sub.min()&(~(LeafT::DIM-1u))).offsetBy(LeafT::DIM-1u));
507 mBlocks->push_back(Block(sub));
508 }
509 }
510 }
511
512 // Multi-threaded process: Convert dense grid into leaf nodes and tiles
513 if (serial) {
514 (*this)(tbb::blocked_range<size_t>(0, mBlocks->size()));
515 } else {
516 tbb::parallel_for(tbb::blocked_range<size_t>(0, mBlocks->size()), *this);
517 }
518
519 // Post-process: Insert leaf nodes and tiles into the tree, and prune the tiles only!
520 tree::ValueAccessor<TreeT> acc(*mTree);
521 for (size_t m=0, size = mBlocks->size(); m<size; ++m) {
522 Block& block = (*mBlocks)[m];
523 if (block.leaf) {
524 acc.addLeaf(block.leaf);
525 } else if (block.tile.second) {//only background tiles are inactive
526 acc.addTile(1, block.bbox.min(), block.tile.first, true);//leaf tile
527 }
528 }
529 delete mBlocks;
530 mBlocks = NULL;
531
532 tools::pruneTiles(*mTree, mTolerance);//multi-threaded
533 }
534
537 void operator()(const tbb::blocked_range<size_t> &r) const
538 {
539 assert(mBlocks);
540 LeafT* leaf = new LeafT();
541
542 for (size_t m=r.begin(), n=0, end = r.end(); m != end; ++m, ++n) {
543
544 Block& block = (*mBlocks)[m];
545 const CoordBBox &bbox = block.bbox;
546
547 if (mAccessor.get() == NULL) {//i.e. empty target tree
548 leaf->fill(mTree->background(), false);
549 } else {//account for existing leaf nodes in the target tree
550 if (const LeafT* target = mAccessor->probeConstLeaf(bbox.min())) {
551 (*leaf) = (*target);
552 } else {
553 ValueT value = zeroVal<ValueT>();
554 bool state = mAccessor->probeValue(bbox.min(), value);
555 leaf->fill(value, state);
556 }
557 }
558
559 leaf->copyFromDense(bbox, *mDense, mTree->background(), mTolerance);
560
561 if (!leaf->isConstant(block.tile.first, block.tile.second, mTolerance)) {
562 leaf->setOrigin(bbox.min() & (~(LeafT::DIM - 1)));
563 block.leaf = leaf;
564 leaf = new LeafT();
565 }
566 }// loop over blocks
567
568 delete leaf;
569 }
570
571 private:
572 struct Block {
573 CoordBBox bbox;
574 LeafT* leaf;
575 std::pair<ValueT, bool> tile;
576 Block(const CoordBBox& b) : bbox(b), leaf(NULL) {}
577 };
578
579 const DenseT* mDense;
580 TreeT* mTree;
581 std::vector<Block>* mBlocks;
582 ValueT mTolerance;
583 boost::scoped_ptr<AccessorT> mAccessor;
584 };// CopyFromDense
585
586
587 // Convenient wrapper function for the CopyFromDense class
588 template<typename DenseT, typename GridOrTreeT>
589 void
590 copyFromDense(const DenseT& dense, GridOrTreeT& sparse,
591 const typename GridOrTreeT::ValueType& tolerance, bool serial)
592 {
593 typedef TreeAdapter<GridOrTreeT> Adapter;
594 typedef typename Adapter::TreeType TreeT;
595
596 CopyFromDense<TreeT, DenseT> op(dense, Adapter::tree(sparse), tolerance);
597 op.copy(serial);
598 }
599
600 } // namespace tools
601 } // namespace OPENVDB_VERSION_NAME
602 } // namespace openvdb
603
604 #endif // OPENVDB_TOOLS_DENSE_HAS_BEEN_INCLUDED
605
606 // Copyright (c) 2012-2016 DreamWorks Animation LLC
607 // All rights reserved. This software is distributed under the
608 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v3_2_0::tools::Dense::bbox
const CoordBBox & bbox() const
Return the bounding box of the signed index domain of this grid.
Definition: Dense.h:275
openvdb::v3_2_0::tree::ValueAccessor::addLeaf
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:374
openvdb::v3_2_0::math::Coord::max
static Coord max()
Return the largest possible coordinate.
Definition: Coord.h:72
openvdb::v3_2_0::tools::CopyFromDense::operator()
void operator()(const tbb::blocked_range< size_t > &r) const
Public method called by tbb::parallel_for.
Definition: Dense.h:537
openvdb::v3_2_0::math::Coord::minComponent
void minComponent(const Coord &other)
Perform a component-wise minimum with the other Coord.
Definition: Coord.h:191
Types.h
Formats.h
Utility routines to output nicely-formatted numeric values.
openvdb::v3_2_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&#39;s value array given by unsigned coordinates (i...
Definition: Dense.h:159
openvdb::v3_2_0::tools::LayoutXYZ
Definition: Dense.h:92
openvdb::v3_2_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:443
openvdb::v3_2_0::tools::CopyToDense::ValueT
TreeT::ValueType ValueT
Definition: Dense.h:414
openvdb::v3_2_0::tools::CopyFromDense::copy
void copy(bool serial=false)
Copy values from the dense grid to the sparse tree.
Definition: Dense.h:493
openvdb::v3_2_0::tools::CopyToDense::operator()
void operator()(const CoordBBox &bbox) const
Public method called by tbb::parallel_for.
Definition: Dense.h:429
openvdb::v3_2_0::tools::LayoutZYX
Definition: Dense.h:92
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:97
openvdb::v3_2_0::math::Coord::ValueType
Int32 ValueType
Definition: Coord.h:55
openvdb::v3_2_0::tools::Dense::memUsage
Index64 memUsage() const
Return the memory footprint of this Dense grid in bytes.
Definition: Dense.h:363
openvdb::v3_2_0::tools::Dense::coordToOffset
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:348
openvdb::v3_2_0::tools::CopyFromDense::ValueT
TreeT::ValueType ValueT
Definition: Dense.h:471
openvdb::v3_2_0::tools::CopyToDense
Copy an OpenVDB tree into an existing dense grid.
Definition: Dense.h:409
openvdb::v3_2_0::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:47
openvdb::v3_2_0::util::formattedInt
FormattedInt< IntT > formattedInt(IntT n)
Definition: Formats.h:130
openvdb::v3_2_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:322
openvdb::v3_2_0::tools::CopyFromDense::LeafT
TreeT::LeafNodeType LeafT
Definition: Dense.h:472
openvdb::v3_2_0::tools::CopyFromDense::CopyFromDense
CopyFromDense(const DenseT &dense, TreeT &tree, const ValueT &tolerance)
Definition: Dense.h:475
openvdb::v3_2_0::tools::DenseBase< ValueT, LayoutXYZ >::mZ
const size_t mZ
Definition: Dense.h:190
openvdb::v3_2_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:183
openvdb::v3_2_0::tree::ValueAccessor< TreeT >
openvdb::v3_2_0::tools::Dense
Dense is a simple dense grid API used by the CopyToDense and CopyFromDense classes defined below...
Definition: Dense.h:206
openvdb::v3_2_0::tools::Dense::data
const ValueT * data() const
Return a raw pointer to this grid&#39;s value array.
Definition: Dense.h:271
Prune.h
Defined various multi-threaded utility functions for trees.
openvdb::v3_2_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:590
openvdb::v3_2_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:287
openvdb::v3_2_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:227
openvdb::v3_2_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:370
openvdb::v3_2_0::tools::DenseBase< ValueT, LayoutXYZ >::mBBox
const CoordBBox mBBox
Definition: Dense.h:189
openvdb::v3_2_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:118
openvdb::v3_2_0::Index64
uint64_t Index64
Definition: Types.h:57
openvdb::v3_2_0::tools::Dense::ConstPtr
boost::shared_ptr< const Dense > ConstPtr
Definition: Dense.h:212
Exceptions.h
openvdb::v3_2_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:290
openvdb::v3_2_0::tools::DenseBase< ValueT, LayoutZYX >::mY
const size_t mY
Definition: Dense.h:143
openvdb::v3_2_0::tools::DenseBase< ValueT, LayoutXYZ >::xStride
static size_t xStride()
Return the stride of the array in the x direction ( = 1).
Definition: Dense.h:175
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
Definition: version.h:43
openvdb::v3_2_0::tools::CopyToDense::copy
void copy(bool serial=false) const
Definition: Dense.h:419
openvdb::v3_2_0::tools::Dense::Ptr
boost::shared_ptr< Dense > Ptr
Definition: Dense.h:211
openvdb::v3_2_0::tools::Dense::memoryLayout
static MemoryLayout memoryLayout()
Return the memory layout for this grid (see above for definitions).
Definition: Dense.h:263
openvdb::v3_2_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:294
openvdb::v3_2_0::tools::CopyToDense::TreeT
_TreeT TreeT
Definition: Dense.h:413
openvdb::v3_2_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:898
openvdb::v3_2_0::util::printBytes
OPENVDB_API int printBytes(std::ostream &os, uint64_t bytes, const std::string &head="", const std::string &tail="\, bool exact=false, int width=8, int precision=3)
openvdb::v3_2_0::tools::DenseBase< ValueT, LayoutZYX >::yStride
size_t yStride() const
Return the stride of the array in the y direction ( = dimZ).
Definition: Dense.h:132
openvdb::v3_2_0::tools::CopyFromDense::TreeT
_TreeT TreeT
Definition: Dense.h:470
openvdb
Definition: Exceptions.h:39
openvdb::v3_2_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:382
openvdb::v3_2_0::tools::DenseBase< ValueT, LayoutZYX >::mBBox
const CoordBBox mBBox
Definition: Dense.h:142
openvdb::v3_2_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, j, k).
Definition: Dense.h:301
openvdb::v3_2_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:128
openvdb::v3_2_0::tools::CopyToDense::CopyToDense
CopyToDense(const TreeT &tree, DenseT &dense)
Definition: Dense.h:416
openvdb::v3_2_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:308
openvdb::v3_2_0::tools::DenseBase< ValueT, LayoutZYX >::zStride
static size_t zStride()
Return the stride of the array in the z direction ( = 1).
Definition: Dense.h:136
openvdb::v3_2_0::tools::CopyFromDense::DenseT
_DenseT DenseT
Definition: Dense.h:469
openvdb::v3_2_0::tools::Dense::Dense
Dense(const CoordBBox &bbox, ValueT *data)
Construct a dense grid that wraps an external array.
Definition: Dense.h:242
openvdb::v3_2_0::tools::Dense::ValueType
ValueT ValueType
Definition: Dense.h:209
openvdb::v3_2_0::math::CoordBBox::min
const Coord & min() const
Definition: Coord.h:332
ValueAccessor.h
openvdb::v3_2_0::tools::DenseBase< ValueT, LayoutXYZ >::yStride
size_t yStride() const
Return the stride of the array in the y direction ( = dimX).
Definition: Dense.h:179
openvdb::v3_2_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:284
openvdb::v3_2_0::tools::MemoryLayout
MemoryLayout
Definition: Dense.h:92
openvdb::v3_2_0::math::Coord::min
static Coord min()
Return the smallest possible coordinate.
Definition: Coord.h:69
openvdb::v3_2_0::tools::Dense::origin
const Coord & origin() const
Return the grid&#39;s origin in index coordinates.
Definition: Dense.h:278
openvdb::v3_2_0::math::CoordBBox::max
const Coord & max() const
Definition: Coord.h:333
openvdb::v3_2_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:165
openvdb::v3_2_0::tools::Dense::offsetToCoord
Coord offsetToCoord(size_t n) const
Return the global coordinate corresponding to the specified linear offset.
Definition: Dense.h:357
openvdb::v3_2_0::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:259
openvdb::v3_2_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:384
openvdb::v3_2_0::tools::CopyFromDense::AccessorT
tree::ValueAccessor< TreeT > AccessorT
Definition: Dense.h:473
Grid.h
openvdb::v3_2_0::ValueError
Definition: Exceptions.h:88
openvdb::v3_2_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&#39;s value array given by unsigned coordinates (i...
Definition: Dense.h:112
openvdb::v3_2_0::tools::Dense::BaseT
DenseBase< ValueT, Layout > BaseT
Definition: Dense.h:210
openvdb::v3_2_0::tools::CopyFromDense
Copy the values from a dense grid into an OpenVDB tree.
Definition: Dense.h:466
openvdb::v3_2_0::tools::Dense::valueCount
Index64 valueCount() const
Return the number of voxels contained in this grid.
Definition: Dense.h:281
openvdb::v3_2_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:315
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
openvdb::v3_2_0::tools::Dense::Dense
Dense(const CoordBBox &bbox)
Construct a dense grid with a given range of coordinates.
Definition: Dense.h:219
openvdb::v3_2_0::tools::Dense::fill
void fill(const ValueT &value)
Fill this grid with a constant value.
Definition: Dense.h:335
openvdb::v3_2_0::tools::CopyFromDense::CopyFromDense
CopyFromDense(const CopyFromDense &other)
Definition: Dense.h:483
openvdb::v3_2_0::tools::DenseBase< ValueT, LayoutZYX >::DenseBase
DenseBase(const CoordBBox &bbox)
Protected constructor so as to prevent direct instantiation.
Definition: Dense.h:140
openvdb::v3_2_0::tools::DenseBase< ValueT, LayoutXYZ >::DenseBase
DenseBase(const CoordBBox &bbox)
Protected constructor so as to prevent direct instantiation.
Definition: Dense.h:187
openvdb::v3_2_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:329
openvdb::v3_2_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:256
openvdb::v3_2_0::tools::DenseBase
Base class for Dense which is defined below.
Definition: Dense.h:97
openvdb::v3_2_0::tools::CopyToDense::DenseT
_DenseT DenseT
Definition: Dense.h:412
openvdb::v3_2_0::tools::Dense::data
ValueT * data()
Return a raw pointer to this grid&#39;s value array.
Definition: Dense.h:267
openvdb::v3_2_0::tools::composite::min
const boost::disable_if_c< VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:128